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 "VxLAN with inner TCP/IPv4 packet, "
4806 "GRE with inner TCP/IPv4 packet\n",
4807 gso_max_segment_size);
4809 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4813 cmdline_parse_token_string_t cmd_gso_show_show =
4814 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4816 cmdline_parse_token_string_t cmd_gso_show_port =
4817 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4819 cmdline_parse_token_string_t cmd_gso_show_keyword =
4820 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4821 cmd_keyword, "gso");
4822 cmdline_parse_token_num_t cmd_gso_show_pid =
4823 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4826 cmdline_parse_inst_t cmd_gso_show = {
4827 .f = cmd_gso_show_parsed,
4829 .help_str = "show port <port_id> gso",
4831 (void *)&cmd_gso_show_show,
4832 (void *)&cmd_gso_show_port,
4833 (void *)&cmd_gso_show_pid,
4834 (void *)&cmd_gso_show_keyword,
4839 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4840 struct cmd_set_flush_rx {
4841 cmdline_fixed_string_t set;
4842 cmdline_fixed_string_t flush_rx;
4843 cmdline_fixed_string_t mode;
4847 cmd_set_flush_rx_parsed(void *parsed_result,
4848 __attribute__((unused)) struct cmdline *cl,
4849 __attribute__((unused)) void *data)
4851 struct cmd_set_flush_rx *res = parsed_result;
4852 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4855 cmdline_parse_token_string_t cmd_setflushrx_set =
4856 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4858 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4859 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4860 flush_rx, "flush_rx");
4861 cmdline_parse_token_string_t cmd_setflushrx_mode =
4862 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4866 cmdline_parse_inst_t cmd_set_flush_rx = {
4867 .f = cmd_set_flush_rx_parsed,
4868 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4871 (void *)&cmd_setflushrx_set,
4872 (void *)&cmd_setflushrx_flush_rx,
4873 (void *)&cmd_setflushrx_mode,
4878 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4879 struct cmd_set_link_check {
4880 cmdline_fixed_string_t set;
4881 cmdline_fixed_string_t link_check;
4882 cmdline_fixed_string_t mode;
4886 cmd_set_link_check_parsed(void *parsed_result,
4887 __attribute__((unused)) struct cmdline *cl,
4888 __attribute__((unused)) void *data)
4890 struct cmd_set_link_check *res = parsed_result;
4891 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4894 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4895 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4897 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4898 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4899 link_check, "link_check");
4900 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4901 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4905 cmdline_parse_inst_t cmd_set_link_check = {
4906 .f = cmd_set_link_check_parsed,
4907 .help_str = "set link_check on|off: Enable/Disable link status check "
4908 "when starting/stopping a port",
4911 (void *)&cmd_setlinkcheck_set,
4912 (void *)&cmd_setlinkcheck_link_check,
4913 (void *)&cmd_setlinkcheck_mode,
4918 /* *** SET NIC BYPASS MODE *** */
4919 struct cmd_set_bypass_mode_result {
4920 cmdline_fixed_string_t set;
4921 cmdline_fixed_string_t bypass;
4922 cmdline_fixed_string_t mode;
4923 cmdline_fixed_string_t value;
4928 cmd_set_bypass_mode_parsed(void *parsed_result,
4929 __attribute__((unused)) struct cmdline *cl,
4930 __attribute__((unused)) void *data)
4932 struct cmd_set_bypass_mode_result *res = parsed_result;
4933 portid_t port_id = res->port_id;
4934 int32_t rc = -EINVAL;
4936 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4937 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4939 if (!strcmp(res->value, "bypass"))
4940 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4941 else if (!strcmp(res->value, "isolate"))
4942 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4944 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4946 /* Set the bypass mode for the relevant port. */
4947 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4950 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4953 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4954 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4956 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4957 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4959 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4960 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4962 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4963 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4964 value, "normal#bypass#isolate");
4965 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4966 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4969 cmdline_parse_inst_t cmd_set_bypass_mode = {
4970 .f = cmd_set_bypass_mode_parsed,
4971 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4972 "Set the NIC bypass mode for port_id",
4975 (void *)&cmd_setbypass_mode_set,
4976 (void *)&cmd_setbypass_mode_bypass,
4977 (void *)&cmd_setbypass_mode_mode,
4978 (void *)&cmd_setbypass_mode_value,
4979 (void *)&cmd_setbypass_mode_port,
4984 /* *** SET NIC BYPASS EVENT *** */
4985 struct cmd_set_bypass_event_result {
4986 cmdline_fixed_string_t set;
4987 cmdline_fixed_string_t bypass;
4988 cmdline_fixed_string_t event;
4989 cmdline_fixed_string_t event_value;
4990 cmdline_fixed_string_t mode;
4991 cmdline_fixed_string_t mode_value;
4996 cmd_set_bypass_event_parsed(void *parsed_result,
4997 __attribute__((unused)) struct cmdline *cl,
4998 __attribute__((unused)) void *data)
5000 int32_t rc = -EINVAL;
5001 struct cmd_set_bypass_event_result *res = parsed_result;
5002 portid_t port_id = res->port_id;
5004 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5005 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5006 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5008 if (!strcmp(res->event_value, "timeout"))
5009 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5010 else if (!strcmp(res->event_value, "os_on"))
5011 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5012 else if (!strcmp(res->event_value, "os_off"))
5013 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5014 else if (!strcmp(res->event_value, "power_on"))
5015 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5016 else if (!strcmp(res->event_value, "power_off"))
5017 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5019 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5021 if (!strcmp(res->mode_value, "bypass"))
5022 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5023 else if (!strcmp(res->mode_value, "isolate"))
5024 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5026 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5028 /* Set the watchdog timeout. */
5029 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5032 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5033 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5037 printf("Failed to set timeout value %u "
5038 "for port %d, errto code: %d.\n",
5039 bypass_timeout, port_id, rc);
5043 /* Set the bypass event to transition to bypass mode. */
5044 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5049 printf("\t Failed to set bypass event for port = %d.\n",
5053 cmdline_parse_token_string_t cmd_setbypass_event_set =
5054 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5056 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5057 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5059 cmdline_parse_token_string_t cmd_setbypass_event_event =
5060 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5062 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5063 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5064 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5065 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5066 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5068 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5069 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5070 mode_value, "normal#bypass#isolate");
5071 cmdline_parse_token_num_t cmd_setbypass_event_port =
5072 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5075 cmdline_parse_inst_t cmd_set_bypass_event = {
5076 .f = cmd_set_bypass_event_parsed,
5077 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5078 "power_off mode normal|bypass|isolate <port_id>: "
5079 "Set the NIC bypass event mode for port_id",
5082 (void *)&cmd_setbypass_event_set,
5083 (void *)&cmd_setbypass_event_bypass,
5084 (void *)&cmd_setbypass_event_event,
5085 (void *)&cmd_setbypass_event_event_value,
5086 (void *)&cmd_setbypass_event_mode,
5087 (void *)&cmd_setbypass_event_mode_value,
5088 (void *)&cmd_setbypass_event_port,
5094 /* *** SET NIC BYPASS TIMEOUT *** */
5095 struct cmd_set_bypass_timeout_result {
5096 cmdline_fixed_string_t set;
5097 cmdline_fixed_string_t bypass;
5098 cmdline_fixed_string_t timeout;
5099 cmdline_fixed_string_t value;
5103 cmd_set_bypass_timeout_parsed(void *parsed_result,
5104 __attribute__((unused)) struct cmdline *cl,
5105 __attribute__((unused)) void *data)
5107 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5109 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5110 if (!strcmp(res->value, "1.5"))
5111 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5112 else if (!strcmp(res->value, "2"))
5113 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5114 else if (!strcmp(res->value, "3"))
5115 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5116 else if (!strcmp(res->value, "4"))
5117 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5118 else if (!strcmp(res->value, "8"))
5119 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5120 else if (!strcmp(res->value, "16"))
5121 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5122 else if (!strcmp(res->value, "32"))
5123 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5125 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5129 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5130 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5132 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5133 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5135 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5136 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5137 timeout, "timeout");
5138 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5139 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5140 value, "0#1.5#2#3#4#8#16#32");
5142 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5143 .f = cmd_set_bypass_timeout_parsed,
5144 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5145 "Set the NIC bypass watchdog timeout in seconds",
5148 (void *)&cmd_setbypass_timeout_set,
5149 (void *)&cmd_setbypass_timeout_bypass,
5150 (void *)&cmd_setbypass_timeout_timeout,
5151 (void *)&cmd_setbypass_timeout_value,
5156 /* *** SHOW NIC BYPASS MODE *** */
5157 struct cmd_show_bypass_config_result {
5158 cmdline_fixed_string_t show;
5159 cmdline_fixed_string_t bypass;
5160 cmdline_fixed_string_t config;
5165 cmd_show_bypass_config_parsed(void *parsed_result,
5166 __attribute__((unused)) struct cmdline *cl,
5167 __attribute__((unused)) void *data)
5169 struct cmd_show_bypass_config_result *res = parsed_result;
5170 portid_t port_id = res->port_id;
5172 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5173 uint32_t event_mode;
5174 uint32_t bypass_mode;
5175 uint32_t timeout = bypass_timeout;
5178 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5179 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5180 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5181 {"UNKNOWN", "normal", "bypass", "isolate"};
5182 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5189 int num_events = (sizeof events) / (sizeof events[0]);
5191 /* Display the bypass mode.*/
5192 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5193 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5197 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5198 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5200 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5203 /* Display the bypass timeout.*/
5204 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5205 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5207 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5209 /* Display the bypass events and associated modes. */
5210 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5212 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5213 printf("\tFailed to get bypass mode for event = %s\n",
5216 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5217 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5219 printf("\tbypass event: %-16s = %s\n", events[i],
5225 printf("\tFailed to get bypass configuration for port = %d\n",
5229 cmdline_parse_token_string_t cmd_showbypass_config_show =
5230 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5232 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5233 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5235 cmdline_parse_token_string_t cmd_showbypass_config_config =
5236 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5238 cmdline_parse_token_num_t cmd_showbypass_config_port =
5239 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5242 cmdline_parse_inst_t cmd_show_bypass_config = {
5243 .f = cmd_show_bypass_config_parsed,
5244 .help_str = "show bypass config <port_id>: "
5245 "Show the NIC bypass config for port_id",
5248 (void *)&cmd_showbypass_config_show,
5249 (void *)&cmd_showbypass_config_bypass,
5250 (void *)&cmd_showbypass_config_config,
5251 (void *)&cmd_showbypass_config_port,
5256 #ifdef RTE_LIBRTE_PMD_BOND
5257 /* *** SET BONDING MODE *** */
5258 struct cmd_set_bonding_mode_result {
5259 cmdline_fixed_string_t set;
5260 cmdline_fixed_string_t bonding;
5261 cmdline_fixed_string_t mode;
5266 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5267 __attribute__((unused)) struct cmdline *cl,
5268 __attribute__((unused)) void *data)
5270 struct cmd_set_bonding_mode_result *res = parsed_result;
5271 portid_t port_id = res->port_id;
5273 /* Set the bonding mode for the relevant port. */
5274 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5275 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5278 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5279 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5281 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5282 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5283 bonding, "bonding");
5284 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5285 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5287 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5288 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5290 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5291 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5294 cmdline_parse_inst_t cmd_set_bonding_mode = {
5295 .f = cmd_set_bonding_mode_parsed,
5296 .help_str = "set bonding mode <mode_value> <port_id>: "
5297 "Set the bonding mode for port_id",
5300 (void *) &cmd_setbonding_mode_set,
5301 (void *) &cmd_setbonding_mode_bonding,
5302 (void *) &cmd_setbonding_mode_mode,
5303 (void *) &cmd_setbonding_mode_value,
5304 (void *) &cmd_setbonding_mode_port,
5309 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5310 struct cmd_set_bonding_lacp_dedicated_queues_result {
5311 cmdline_fixed_string_t set;
5312 cmdline_fixed_string_t bonding;
5313 cmdline_fixed_string_t lacp;
5314 cmdline_fixed_string_t dedicated_queues;
5316 cmdline_fixed_string_t mode;
5319 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5320 __attribute__((unused)) struct cmdline *cl,
5321 __attribute__((unused)) void *data)
5323 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5324 portid_t port_id = res->port_id;
5325 struct rte_port *port;
5327 port = &ports[port_id];
5329 /** Check if the port is not started **/
5330 if (port->port_status != RTE_PORT_STOPPED) {
5331 printf("Please stop port %d first\n", port_id);
5335 if (!strcmp(res->mode, "enable")) {
5336 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5337 printf("Dedicate queues for LACP control packets"
5340 printf("Enabling dedicate queues for LACP control "
5341 "packets on port %d failed\n", port_id);
5342 } else if (!strcmp(res->mode, "disable")) {
5343 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5344 printf("Dedicated queues for LACP control packets "
5347 printf("Disabling dedicated queues for LACP control "
5348 "traffic on port %d failed\n", port_id);
5352 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5353 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5355 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5356 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5357 bonding, "bonding");
5358 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5359 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5361 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5362 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5363 dedicated_queues, "dedicated_queues");
5364 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5365 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5367 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5368 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5369 mode, "enable#disable");
5371 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5372 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5373 .help_str = "set bonding lacp dedicated_queues <port_id> "
5375 "Enable/disable dedicated queues for LACP control traffic for port_id",
5378 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5379 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5380 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5381 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5382 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5383 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5388 /* *** SET BALANCE XMIT POLICY *** */
5389 struct cmd_set_bonding_balance_xmit_policy_result {
5390 cmdline_fixed_string_t set;
5391 cmdline_fixed_string_t bonding;
5392 cmdline_fixed_string_t balance_xmit_policy;
5394 cmdline_fixed_string_t policy;
5397 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5398 __attribute__((unused)) struct cmdline *cl,
5399 __attribute__((unused)) void *data)
5401 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5402 portid_t port_id = res->port_id;
5405 if (!strcmp(res->policy, "l2")) {
5406 policy = BALANCE_XMIT_POLICY_LAYER2;
5407 } else if (!strcmp(res->policy, "l23")) {
5408 policy = BALANCE_XMIT_POLICY_LAYER23;
5409 } else if (!strcmp(res->policy, "l34")) {
5410 policy = BALANCE_XMIT_POLICY_LAYER34;
5412 printf("\t Invalid xmit policy selection");
5416 /* Set the bonding mode for the relevant port. */
5417 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5418 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5423 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5424 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5426 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5427 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5428 bonding, "bonding");
5429 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5430 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5431 balance_xmit_policy, "balance_xmit_policy");
5432 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5433 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5435 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5436 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5437 policy, "l2#l23#l34");
5439 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5440 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5441 .help_str = "set bonding balance_xmit_policy <port_id> "
5443 "Set the bonding balance_xmit_policy for port_id",
5446 (void *)&cmd_setbonding_balance_xmit_policy_set,
5447 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5448 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5449 (void *)&cmd_setbonding_balance_xmit_policy_port,
5450 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5455 /* *** SHOW NIC BONDING CONFIGURATION *** */
5456 struct cmd_show_bonding_config_result {
5457 cmdline_fixed_string_t show;
5458 cmdline_fixed_string_t bonding;
5459 cmdline_fixed_string_t config;
5463 static void cmd_show_bonding_config_parsed(void *parsed_result,
5464 __attribute__((unused)) struct cmdline *cl,
5465 __attribute__((unused)) void *data)
5467 struct cmd_show_bonding_config_result *res = parsed_result;
5468 int bonding_mode, agg_mode;
5469 portid_t slaves[RTE_MAX_ETHPORTS];
5470 int num_slaves, num_active_slaves;
5473 portid_t port_id = res->port_id;
5475 /* Display the bonding mode.*/
5476 bonding_mode = rte_eth_bond_mode_get(port_id);
5477 if (bonding_mode < 0) {
5478 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5481 printf("\tBonding mode: %d\n", bonding_mode);
5483 if (bonding_mode == BONDING_MODE_BALANCE) {
5484 int balance_xmit_policy;
5486 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5487 if (balance_xmit_policy < 0) {
5488 printf("\tFailed to get balance xmit policy for port = %d\n",
5492 printf("\tBalance Xmit Policy: ");
5494 switch (balance_xmit_policy) {
5495 case BALANCE_XMIT_POLICY_LAYER2:
5496 printf("BALANCE_XMIT_POLICY_LAYER2");
5498 case BALANCE_XMIT_POLICY_LAYER23:
5499 printf("BALANCE_XMIT_POLICY_LAYER23");
5501 case BALANCE_XMIT_POLICY_LAYER34:
5502 printf("BALANCE_XMIT_POLICY_LAYER34");
5509 if (bonding_mode == BONDING_MODE_8023AD) {
5510 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5511 printf("\tIEEE802.3AD Aggregator Mode: ");
5514 printf("bandwidth");
5526 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5528 if (num_slaves < 0) {
5529 printf("\tFailed to get slave list for port = %d\n", port_id);
5532 if (num_slaves > 0) {
5533 printf("\tSlaves (%d): [", num_slaves);
5534 for (i = 0; i < num_slaves - 1; i++)
5535 printf("%d ", slaves[i]);
5537 printf("%d]\n", slaves[num_slaves - 1]);
5539 printf("\tSlaves: []\n");
5543 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5546 if (num_active_slaves < 0) {
5547 printf("\tFailed to get active slave list for port = %d\n", port_id);
5550 if (num_active_slaves > 0) {
5551 printf("\tActive Slaves (%d): [", num_active_slaves);
5552 for (i = 0; i < num_active_slaves - 1; i++)
5553 printf("%d ", slaves[i]);
5555 printf("%d]\n", slaves[num_active_slaves - 1]);
5558 printf("\tActive Slaves: []\n");
5562 primary_id = rte_eth_bond_primary_get(port_id);
5563 if (primary_id < 0) {
5564 printf("\tFailed to get primary slave for port = %d\n", port_id);
5567 printf("\tPrimary: [%d]\n", primary_id);
5571 cmdline_parse_token_string_t cmd_showbonding_config_show =
5572 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5574 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5575 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5576 bonding, "bonding");
5577 cmdline_parse_token_string_t cmd_showbonding_config_config =
5578 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5580 cmdline_parse_token_num_t cmd_showbonding_config_port =
5581 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5584 cmdline_parse_inst_t cmd_show_bonding_config = {
5585 .f = cmd_show_bonding_config_parsed,
5586 .help_str = "show bonding config <port_id>: "
5587 "Show the bonding config for port_id",
5590 (void *)&cmd_showbonding_config_show,
5591 (void *)&cmd_showbonding_config_bonding,
5592 (void *)&cmd_showbonding_config_config,
5593 (void *)&cmd_showbonding_config_port,
5598 /* *** SET BONDING PRIMARY *** */
5599 struct cmd_set_bonding_primary_result {
5600 cmdline_fixed_string_t set;
5601 cmdline_fixed_string_t bonding;
5602 cmdline_fixed_string_t primary;
5607 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5608 __attribute__((unused)) struct cmdline *cl,
5609 __attribute__((unused)) void *data)
5611 struct cmd_set_bonding_primary_result *res = parsed_result;
5612 portid_t master_port_id = res->port_id;
5613 portid_t slave_port_id = res->slave_id;
5615 /* Set the primary slave for a bonded device. */
5616 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5617 printf("\t Failed to set primary slave for port = %d.\n",
5624 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5625 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5627 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5628 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5629 bonding, "bonding");
5630 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5631 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5632 primary, "primary");
5633 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5634 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5636 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5637 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5640 cmdline_parse_inst_t cmd_set_bonding_primary = {
5641 .f = cmd_set_bonding_primary_parsed,
5642 .help_str = "set bonding primary <slave_id> <port_id>: "
5643 "Set the primary slave for port_id",
5646 (void *)&cmd_setbonding_primary_set,
5647 (void *)&cmd_setbonding_primary_bonding,
5648 (void *)&cmd_setbonding_primary_primary,
5649 (void *)&cmd_setbonding_primary_slave,
5650 (void *)&cmd_setbonding_primary_port,
5655 /* *** ADD SLAVE *** */
5656 struct cmd_add_bonding_slave_result {
5657 cmdline_fixed_string_t add;
5658 cmdline_fixed_string_t bonding;
5659 cmdline_fixed_string_t slave;
5664 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5665 __attribute__((unused)) struct cmdline *cl,
5666 __attribute__((unused)) void *data)
5668 struct cmd_add_bonding_slave_result *res = parsed_result;
5669 portid_t master_port_id = res->port_id;
5670 portid_t slave_port_id = res->slave_id;
5672 /* add the slave for a bonded device. */
5673 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5674 printf("\t Failed to add slave %d to master port = %d.\n",
5675 slave_port_id, master_port_id);
5679 set_port_slave_flag(slave_port_id);
5682 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5683 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5685 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5686 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5687 bonding, "bonding");
5688 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5689 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5691 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5692 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5694 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5695 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5698 cmdline_parse_inst_t cmd_add_bonding_slave = {
5699 .f = cmd_add_bonding_slave_parsed,
5700 .help_str = "add bonding slave <slave_id> <port_id>: "
5701 "Add a slave device to a bonded device",
5704 (void *)&cmd_addbonding_slave_add,
5705 (void *)&cmd_addbonding_slave_bonding,
5706 (void *)&cmd_addbonding_slave_slave,
5707 (void *)&cmd_addbonding_slave_slaveid,
5708 (void *)&cmd_addbonding_slave_port,
5713 /* *** REMOVE SLAVE *** */
5714 struct cmd_remove_bonding_slave_result {
5715 cmdline_fixed_string_t remove;
5716 cmdline_fixed_string_t bonding;
5717 cmdline_fixed_string_t slave;
5722 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5723 __attribute__((unused)) struct cmdline *cl,
5724 __attribute__((unused)) void *data)
5726 struct cmd_remove_bonding_slave_result *res = parsed_result;
5727 portid_t master_port_id = res->port_id;
5728 portid_t slave_port_id = res->slave_id;
5730 /* remove the slave from a bonded device. */
5731 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5732 printf("\t Failed to remove slave %d from master port = %d.\n",
5733 slave_port_id, master_port_id);
5737 clear_port_slave_flag(slave_port_id);
5740 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5741 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5743 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5744 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5745 bonding, "bonding");
5746 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5747 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5749 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5750 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5752 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5753 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5756 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5757 .f = cmd_remove_bonding_slave_parsed,
5758 .help_str = "remove bonding slave <slave_id> <port_id>: "
5759 "Remove a slave device from a bonded device",
5762 (void *)&cmd_removebonding_slave_remove,
5763 (void *)&cmd_removebonding_slave_bonding,
5764 (void *)&cmd_removebonding_slave_slave,
5765 (void *)&cmd_removebonding_slave_slaveid,
5766 (void *)&cmd_removebonding_slave_port,
5771 /* *** CREATE BONDED DEVICE *** */
5772 struct cmd_create_bonded_device_result {
5773 cmdline_fixed_string_t create;
5774 cmdline_fixed_string_t bonded;
5775 cmdline_fixed_string_t device;
5780 static int bond_dev_num = 0;
5782 static void cmd_create_bonded_device_parsed(void *parsed_result,
5783 __attribute__((unused)) struct cmdline *cl,
5784 __attribute__((unused)) void *data)
5786 struct cmd_create_bonded_device_result *res = parsed_result;
5787 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5790 if (test_done == 0) {
5791 printf("Please stop forwarding first\n");
5795 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5798 /* Create a new bonded device. */
5799 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5801 printf("\t Failed to create bonded device.\n");
5804 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5807 /* Update number of ports */
5808 nb_ports = rte_eth_dev_count_avail();
5809 reconfig(port_id, res->socket);
5810 rte_eth_promiscuous_enable(port_id);
5815 cmdline_parse_token_string_t cmd_createbonded_device_create =
5816 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5818 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5819 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5821 cmdline_parse_token_string_t cmd_createbonded_device_device =
5822 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5824 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5825 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5827 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5828 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5831 cmdline_parse_inst_t cmd_create_bonded_device = {
5832 .f = cmd_create_bonded_device_parsed,
5833 .help_str = "create bonded device <mode> <socket>: "
5834 "Create a new bonded device with specific bonding mode and socket",
5837 (void *)&cmd_createbonded_device_create,
5838 (void *)&cmd_createbonded_device_bonded,
5839 (void *)&cmd_createbonded_device_device,
5840 (void *)&cmd_createbonded_device_mode,
5841 (void *)&cmd_createbonded_device_socket,
5846 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5847 struct cmd_set_bond_mac_addr_result {
5848 cmdline_fixed_string_t set;
5849 cmdline_fixed_string_t bonding;
5850 cmdline_fixed_string_t mac_addr;
5852 struct ether_addr address;
5855 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5856 __attribute__((unused)) struct cmdline *cl,
5857 __attribute__((unused)) void *data)
5859 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5862 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5865 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5867 /* check the return value and print it if is < 0 */
5869 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5872 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5873 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5874 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5875 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5877 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5878 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5880 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5881 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5883 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5884 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5886 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5887 .f = cmd_set_bond_mac_addr_parsed,
5889 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5891 (void *)&cmd_set_bond_mac_addr_set,
5892 (void *)&cmd_set_bond_mac_addr_bonding,
5893 (void *)&cmd_set_bond_mac_addr_mac,
5894 (void *)&cmd_set_bond_mac_addr_portnum,
5895 (void *)&cmd_set_bond_mac_addr_addr,
5901 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5902 struct cmd_set_bond_mon_period_result {
5903 cmdline_fixed_string_t set;
5904 cmdline_fixed_string_t bonding;
5905 cmdline_fixed_string_t mon_period;
5910 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5911 __attribute__((unused)) struct cmdline *cl,
5912 __attribute__((unused)) void *data)
5914 struct cmd_set_bond_mon_period_result *res = parsed_result;
5917 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5919 /* check the return value and print it if is < 0 */
5921 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5924 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5925 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5927 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5928 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5929 bonding, "bonding");
5930 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5931 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5932 mon_period, "mon_period");
5933 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5934 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5936 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5937 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5940 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5941 .f = cmd_set_bond_mon_period_parsed,
5943 .help_str = "set bonding mon_period <port_id> <period_ms>",
5945 (void *)&cmd_set_bond_mon_period_set,
5946 (void *)&cmd_set_bond_mon_period_bonding,
5947 (void *)&cmd_set_bond_mon_period_mon_period,
5948 (void *)&cmd_set_bond_mon_period_portnum,
5949 (void *)&cmd_set_bond_mon_period_period_ms,
5956 struct cmd_set_bonding_agg_mode_policy_result {
5957 cmdline_fixed_string_t set;
5958 cmdline_fixed_string_t bonding;
5959 cmdline_fixed_string_t agg_mode;
5961 cmdline_fixed_string_t policy;
5966 cmd_set_bonding_agg_mode(void *parsed_result,
5967 __attribute__((unused)) struct cmdline *cl,
5968 __attribute__((unused)) void *data)
5970 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5971 uint8_t policy = AGG_BANDWIDTH;
5973 if (!strcmp(res->policy, "bandwidth"))
5974 policy = AGG_BANDWIDTH;
5975 else if (!strcmp(res->policy, "stable"))
5976 policy = AGG_STABLE;
5977 else if (!strcmp(res->policy, "count"))
5980 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5984 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5985 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5987 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5988 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5989 bonding, "bonding");
5991 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5992 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5993 agg_mode, "agg_mode");
5995 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5996 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5999 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6000 TOKEN_STRING_INITIALIZER(
6001 struct cmd_set_bonding_balance_xmit_policy_result,
6002 policy, "stable#bandwidth#count");
6004 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6005 .f = cmd_set_bonding_agg_mode,
6007 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6009 (void *)&cmd_set_bonding_agg_mode_set,
6010 (void *)&cmd_set_bonding_agg_mode_bonding,
6011 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6012 (void *)&cmd_set_bonding_agg_mode_portnum,
6013 (void *)&cmd_set_bonding_agg_mode_policy_string,
6019 #endif /* RTE_LIBRTE_PMD_BOND */
6021 /* *** SET FORWARDING MODE *** */
6022 struct cmd_set_fwd_mode_result {
6023 cmdline_fixed_string_t set;
6024 cmdline_fixed_string_t fwd;
6025 cmdline_fixed_string_t mode;
6028 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6029 __attribute__((unused)) struct cmdline *cl,
6030 __attribute__((unused)) void *data)
6032 struct cmd_set_fwd_mode_result *res = parsed_result;
6035 set_pkt_forwarding_mode(res->mode);
6038 cmdline_parse_token_string_t cmd_setfwd_set =
6039 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6040 cmdline_parse_token_string_t cmd_setfwd_fwd =
6041 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6042 cmdline_parse_token_string_t cmd_setfwd_mode =
6043 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6044 "" /* defined at init */);
6046 cmdline_parse_inst_t cmd_set_fwd_mode = {
6047 .f = cmd_set_fwd_mode_parsed,
6049 .help_str = NULL, /* defined at init */
6051 (void *)&cmd_setfwd_set,
6052 (void *)&cmd_setfwd_fwd,
6053 (void *)&cmd_setfwd_mode,
6058 static void cmd_set_fwd_mode_init(void)
6061 static char token[128];
6062 static char help[256];
6063 cmdline_parse_token_string_t *token_struct;
6065 modes = list_pkt_forwarding_modes();
6066 snprintf(help, sizeof(help), "set fwd %s: "
6067 "Set packet forwarding mode", modes);
6068 cmd_set_fwd_mode.help_str = help;
6070 /* string token separator is # */
6071 for (c = token; *modes != '\0'; modes++)
6076 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6077 token_struct->string_data.str = token;
6080 /* *** SET RETRY FORWARDING MODE *** */
6081 struct cmd_set_fwd_retry_mode_result {
6082 cmdline_fixed_string_t set;
6083 cmdline_fixed_string_t fwd;
6084 cmdline_fixed_string_t mode;
6085 cmdline_fixed_string_t retry;
6088 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6089 __attribute__((unused)) struct cmdline *cl,
6090 __attribute__((unused)) void *data)
6092 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6095 set_pkt_forwarding_mode(res->mode);
6098 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6099 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6101 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6102 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6104 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6105 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6107 "" /* defined at init */);
6108 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6109 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6112 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6113 .f = cmd_set_fwd_retry_mode_parsed,
6115 .help_str = NULL, /* defined at init */
6117 (void *)&cmd_setfwd_retry_set,
6118 (void *)&cmd_setfwd_retry_fwd,
6119 (void *)&cmd_setfwd_retry_mode,
6120 (void *)&cmd_setfwd_retry_retry,
6125 static void cmd_set_fwd_retry_mode_init(void)
6128 static char token[128];
6129 static char help[256];
6130 cmdline_parse_token_string_t *token_struct;
6132 modes = list_pkt_forwarding_retry_modes();
6133 snprintf(help, sizeof(help), "set fwd %s retry: "
6134 "Set packet forwarding mode with retry", modes);
6135 cmd_set_fwd_retry_mode.help_str = help;
6137 /* string token separator is # */
6138 for (c = token; *modes != '\0'; modes++)
6143 token_struct = (cmdline_parse_token_string_t *)
6144 cmd_set_fwd_retry_mode.tokens[2];
6145 token_struct->string_data.str = token;
6148 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6149 struct cmd_set_burst_tx_retry_result {
6150 cmdline_fixed_string_t set;
6151 cmdline_fixed_string_t burst;
6152 cmdline_fixed_string_t tx;
6153 cmdline_fixed_string_t delay;
6155 cmdline_fixed_string_t retry;
6159 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6160 __attribute__((unused)) struct cmdline *cl,
6161 __attribute__((unused)) void *data)
6163 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6165 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6166 && !strcmp(res->tx, "tx")) {
6167 if (!strcmp(res->delay, "delay"))
6168 burst_tx_delay_time = res->time;
6169 if (!strcmp(res->retry, "retry"))
6170 burst_tx_retry_num = res->retry_num;
6175 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6176 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6177 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6178 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6180 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6181 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6182 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6183 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6184 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6185 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6186 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6187 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6188 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6189 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6191 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6192 .f = cmd_set_burst_tx_retry_parsed,
6193 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6195 (void *)&cmd_set_burst_tx_retry_set,
6196 (void *)&cmd_set_burst_tx_retry_burst,
6197 (void *)&cmd_set_burst_tx_retry_tx,
6198 (void *)&cmd_set_burst_tx_retry_delay,
6199 (void *)&cmd_set_burst_tx_retry_time,
6200 (void *)&cmd_set_burst_tx_retry_retry,
6201 (void *)&cmd_set_burst_tx_retry_retry_num,
6206 /* *** SET PROMISC MODE *** */
6207 struct cmd_set_promisc_mode_result {
6208 cmdline_fixed_string_t set;
6209 cmdline_fixed_string_t promisc;
6210 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6211 uint16_t port_num; /* valid if "allports" argument == 0 */
6212 cmdline_fixed_string_t mode;
6215 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6216 __attribute__((unused)) struct cmdline *cl,
6219 struct cmd_set_promisc_mode_result *res = parsed_result;
6223 if (!strcmp(res->mode, "on"))
6230 RTE_ETH_FOREACH_DEV(i) {
6232 rte_eth_promiscuous_enable(i);
6234 rte_eth_promiscuous_disable(i);
6239 rte_eth_promiscuous_enable(res->port_num);
6241 rte_eth_promiscuous_disable(res->port_num);
6245 cmdline_parse_token_string_t cmd_setpromisc_set =
6246 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6247 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6248 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6250 cmdline_parse_token_string_t cmd_setpromisc_portall =
6251 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6253 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6254 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6256 cmdline_parse_token_string_t cmd_setpromisc_mode =
6257 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6260 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6261 .f = cmd_set_promisc_mode_parsed,
6263 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6265 (void *)&cmd_setpromisc_set,
6266 (void *)&cmd_setpromisc_promisc,
6267 (void *)&cmd_setpromisc_portall,
6268 (void *)&cmd_setpromisc_mode,
6273 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6274 .f = cmd_set_promisc_mode_parsed,
6276 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6278 (void *)&cmd_setpromisc_set,
6279 (void *)&cmd_setpromisc_promisc,
6280 (void *)&cmd_setpromisc_portnum,
6281 (void *)&cmd_setpromisc_mode,
6286 /* *** SET ALLMULTI MODE *** */
6287 struct cmd_set_allmulti_mode_result {
6288 cmdline_fixed_string_t set;
6289 cmdline_fixed_string_t allmulti;
6290 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6291 uint16_t port_num; /* valid if "allports" argument == 0 */
6292 cmdline_fixed_string_t mode;
6295 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6296 __attribute__((unused)) struct cmdline *cl,
6299 struct cmd_set_allmulti_mode_result *res = parsed_result;
6303 if (!strcmp(res->mode, "on"))
6310 RTE_ETH_FOREACH_DEV(i) {
6312 rte_eth_allmulticast_enable(i);
6314 rte_eth_allmulticast_disable(i);
6319 rte_eth_allmulticast_enable(res->port_num);
6321 rte_eth_allmulticast_disable(res->port_num);
6325 cmdline_parse_token_string_t cmd_setallmulti_set =
6326 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6327 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6328 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6330 cmdline_parse_token_string_t cmd_setallmulti_portall =
6331 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6333 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6334 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6336 cmdline_parse_token_string_t cmd_setallmulti_mode =
6337 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6340 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6341 .f = cmd_set_allmulti_mode_parsed,
6343 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6345 (void *)&cmd_setallmulti_set,
6346 (void *)&cmd_setallmulti_allmulti,
6347 (void *)&cmd_setallmulti_portall,
6348 (void *)&cmd_setallmulti_mode,
6353 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6354 .f = cmd_set_allmulti_mode_parsed,
6356 .help_str = "set allmulti <port_id> on|off: "
6357 "Set allmulti mode on port_id",
6359 (void *)&cmd_setallmulti_set,
6360 (void *)&cmd_setallmulti_allmulti,
6361 (void *)&cmd_setallmulti_portnum,
6362 (void *)&cmd_setallmulti_mode,
6367 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6368 struct cmd_link_flow_ctrl_set_result {
6369 cmdline_fixed_string_t set;
6370 cmdline_fixed_string_t flow_ctrl;
6371 cmdline_fixed_string_t rx;
6372 cmdline_fixed_string_t rx_lfc_mode;
6373 cmdline_fixed_string_t tx;
6374 cmdline_fixed_string_t tx_lfc_mode;
6375 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6376 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6377 cmdline_fixed_string_t autoneg_str;
6378 cmdline_fixed_string_t autoneg;
6379 cmdline_fixed_string_t hw_str;
6380 uint32_t high_water;
6381 cmdline_fixed_string_t lw_str;
6383 cmdline_fixed_string_t pt_str;
6384 uint16_t pause_time;
6385 cmdline_fixed_string_t xon_str;
6390 cmdline_parse_token_string_t cmd_lfc_set_set =
6391 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6393 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6394 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6395 flow_ctrl, "flow_ctrl");
6396 cmdline_parse_token_string_t cmd_lfc_set_rx =
6397 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6399 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6400 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6401 rx_lfc_mode, "on#off");
6402 cmdline_parse_token_string_t cmd_lfc_set_tx =
6403 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6405 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6406 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6407 tx_lfc_mode, "on#off");
6408 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6409 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6410 hw_str, "high_water");
6411 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6412 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6413 high_water, UINT32);
6414 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6415 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6416 lw_str, "low_water");
6417 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6418 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6420 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6421 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6422 pt_str, "pause_time");
6423 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6424 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6425 pause_time, UINT16);
6426 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6427 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6428 xon_str, "send_xon");
6429 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6430 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6432 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6433 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6434 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6435 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6436 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6437 mac_ctrl_frame_fwd_mode, "on#off");
6438 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6439 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6440 autoneg_str, "autoneg");
6441 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6442 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6444 cmdline_parse_token_num_t cmd_lfc_set_portid =
6445 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6448 /* forward declaration */
6450 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6453 cmdline_parse_inst_t cmd_link_flow_control_set = {
6454 .f = cmd_link_flow_ctrl_set_parsed,
6456 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6457 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6458 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6460 (void *)&cmd_lfc_set_set,
6461 (void *)&cmd_lfc_set_flow_ctrl,
6462 (void *)&cmd_lfc_set_rx,
6463 (void *)&cmd_lfc_set_rx_mode,
6464 (void *)&cmd_lfc_set_tx,
6465 (void *)&cmd_lfc_set_tx_mode,
6466 (void *)&cmd_lfc_set_high_water,
6467 (void *)&cmd_lfc_set_low_water,
6468 (void *)&cmd_lfc_set_pause_time,
6469 (void *)&cmd_lfc_set_send_xon,
6470 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6471 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6472 (void *)&cmd_lfc_set_autoneg_str,
6473 (void *)&cmd_lfc_set_autoneg,
6474 (void *)&cmd_lfc_set_portid,
6479 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6480 .f = cmd_link_flow_ctrl_set_parsed,
6481 .data = (void *)&cmd_link_flow_control_set_rx,
6482 .help_str = "set flow_ctrl rx on|off <port_id>: "
6483 "Change rx flow control parameter",
6485 (void *)&cmd_lfc_set_set,
6486 (void *)&cmd_lfc_set_flow_ctrl,
6487 (void *)&cmd_lfc_set_rx,
6488 (void *)&cmd_lfc_set_rx_mode,
6489 (void *)&cmd_lfc_set_portid,
6494 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6495 .f = cmd_link_flow_ctrl_set_parsed,
6496 .data = (void *)&cmd_link_flow_control_set_tx,
6497 .help_str = "set flow_ctrl tx on|off <port_id>: "
6498 "Change tx flow control parameter",
6500 (void *)&cmd_lfc_set_set,
6501 (void *)&cmd_lfc_set_flow_ctrl,
6502 (void *)&cmd_lfc_set_tx,
6503 (void *)&cmd_lfc_set_tx_mode,
6504 (void *)&cmd_lfc_set_portid,
6509 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6510 .f = cmd_link_flow_ctrl_set_parsed,
6511 .data = (void *)&cmd_link_flow_control_set_hw,
6512 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6513 "Change high water flow control parameter",
6515 (void *)&cmd_lfc_set_set,
6516 (void *)&cmd_lfc_set_flow_ctrl,
6517 (void *)&cmd_lfc_set_high_water_str,
6518 (void *)&cmd_lfc_set_high_water,
6519 (void *)&cmd_lfc_set_portid,
6524 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6525 .f = cmd_link_flow_ctrl_set_parsed,
6526 .data = (void *)&cmd_link_flow_control_set_lw,
6527 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6528 "Change low water flow control parameter",
6530 (void *)&cmd_lfc_set_set,
6531 (void *)&cmd_lfc_set_flow_ctrl,
6532 (void *)&cmd_lfc_set_low_water_str,
6533 (void *)&cmd_lfc_set_low_water,
6534 (void *)&cmd_lfc_set_portid,
6539 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6540 .f = cmd_link_flow_ctrl_set_parsed,
6541 .data = (void *)&cmd_link_flow_control_set_pt,
6542 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6543 "Change pause time flow control parameter",
6545 (void *)&cmd_lfc_set_set,
6546 (void *)&cmd_lfc_set_flow_ctrl,
6547 (void *)&cmd_lfc_set_pause_time_str,
6548 (void *)&cmd_lfc_set_pause_time,
6549 (void *)&cmd_lfc_set_portid,
6554 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6555 .f = cmd_link_flow_ctrl_set_parsed,
6556 .data = (void *)&cmd_link_flow_control_set_xon,
6557 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6558 "Change send_xon flow control parameter",
6560 (void *)&cmd_lfc_set_set,
6561 (void *)&cmd_lfc_set_flow_ctrl,
6562 (void *)&cmd_lfc_set_send_xon_str,
6563 (void *)&cmd_lfc_set_send_xon,
6564 (void *)&cmd_lfc_set_portid,
6569 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6570 .f = cmd_link_flow_ctrl_set_parsed,
6571 .data = (void *)&cmd_link_flow_control_set_macfwd,
6572 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6573 "Change mac ctrl fwd flow control parameter",
6575 (void *)&cmd_lfc_set_set,
6576 (void *)&cmd_lfc_set_flow_ctrl,
6577 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6578 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6579 (void *)&cmd_lfc_set_portid,
6584 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6585 .f = cmd_link_flow_ctrl_set_parsed,
6586 .data = (void *)&cmd_link_flow_control_set_autoneg,
6587 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6588 "Change autoneg flow control parameter",
6590 (void *)&cmd_lfc_set_set,
6591 (void *)&cmd_lfc_set_flow_ctrl,
6592 (void *)&cmd_lfc_set_autoneg_str,
6593 (void *)&cmd_lfc_set_autoneg,
6594 (void *)&cmd_lfc_set_portid,
6600 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6601 __attribute__((unused)) struct cmdline *cl,
6604 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6605 cmdline_parse_inst_t *cmd = data;
6606 struct rte_eth_fc_conf fc_conf;
6612 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6613 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6614 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6615 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6617 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6618 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6621 /* Partial command line, retrieve current configuration */
6623 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6625 printf("cannot get current flow ctrl parameters, return"
6626 "code = %d\n", ret);
6630 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6631 (fc_conf.mode == RTE_FC_FULL))
6633 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6634 (fc_conf.mode == RTE_FC_FULL))
6638 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6639 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6641 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6642 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6644 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6646 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6647 fc_conf.high_water = res->high_water;
6649 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6650 fc_conf.low_water = res->low_water;
6652 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6653 fc_conf.pause_time = res->pause_time;
6655 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6656 fc_conf.send_xon = res->send_xon;
6658 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6659 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6660 fc_conf.mac_ctrl_frame_fwd = 1;
6662 fc_conf.mac_ctrl_frame_fwd = 0;
6665 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6666 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6668 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6670 printf("bad flow contrl parameter, return code = %d \n", ret);
6673 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6674 struct cmd_priority_flow_ctrl_set_result {
6675 cmdline_fixed_string_t set;
6676 cmdline_fixed_string_t pfc_ctrl;
6677 cmdline_fixed_string_t rx;
6678 cmdline_fixed_string_t rx_pfc_mode;
6679 cmdline_fixed_string_t tx;
6680 cmdline_fixed_string_t tx_pfc_mode;
6681 uint32_t high_water;
6683 uint16_t pause_time;
6689 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6690 __attribute__((unused)) struct cmdline *cl,
6691 __attribute__((unused)) void *data)
6693 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6694 struct rte_eth_pfc_conf pfc_conf;
6695 int rx_fc_enable, tx_fc_enable;
6699 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6700 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6701 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6702 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6704 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6705 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6708 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6709 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6710 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6711 pfc_conf.fc.high_water = res->high_water;
6712 pfc_conf.fc.low_water = res->low_water;
6713 pfc_conf.fc.pause_time = res->pause_time;
6714 pfc_conf.priority = res->priority;
6716 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6718 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6721 cmdline_parse_token_string_t cmd_pfc_set_set =
6722 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6724 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6725 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6726 pfc_ctrl, "pfc_ctrl");
6727 cmdline_parse_token_string_t cmd_pfc_set_rx =
6728 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6730 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6731 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6732 rx_pfc_mode, "on#off");
6733 cmdline_parse_token_string_t cmd_pfc_set_tx =
6734 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6736 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6737 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6738 tx_pfc_mode, "on#off");
6739 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6740 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6741 high_water, UINT32);
6742 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6743 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6745 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6746 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6747 pause_time, UINT16);
6748 cmdline_parse_token_num_t cmd_pfc_set_priority =
6749 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6751 cmdline_parse_token_num_t cmd_pfc_set_portid =
6752 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6755 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6756 .f = cmd_priority_flow_ctrl_set_parsed,
6758 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6759 "<pause_time> <priority> <port_id>: "
6760 "Configure the Ethernet priority flow control",
6762 (void *)&cmd_pfc_set_set,
6763 (void *)&cmd_pfc_set_flow_ctrl,
6764 (void *)&cmd_pfc_set_rx,
6765 (void *)&cmd_pfc_set_rx_mode,
6766 (void *)&cmd_pfc_set_tx,
6767 (void *)&cmd_pfc_set_tx_mode,
6768 (void *)&cmd_pfc_set_high_water,
6769 (void *)&cmd_pfc_set_low_water,
6770 (void *)&cmd_pfc_set_pause_time,
6771 (void *)&cmd_pfc_set_priority,
6772 (void *)&cmd_pfc_set_portid,
6777 /* *** RESET CONFIGURATION *** */
6778 struct cmd_reset_result {
6779 cmdline_fixed_string_t reset;
6780 cmdline_fixed_string_t def;
6783 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6785 __attribute__((unused)) void *data)
6787 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6788 set_def_fwd_config();
6791 cmdline_parse_token_string_t cmd_reset_set =
6792 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6793 cmdline_parse_token_string_t cmd_reset_def =
6794 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6797 cmdline_parse_inst_t cmd_reset = {
6798 .f = cmd_reset_parsed,
6800 .help_str = "set default: Reset default forwarding configuration",
6802 (void *)&cmd_reset_set,
6803 (void *)&cmd_reset_def,
6808 /* *** START FORWARDING *** */
6809 struct cmd_start_result {
6810 cmdline_fixed_string_t start;
6813 cmdline_parse_token_string_t cmd_start_start =
6814 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6816 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6817 __attribute__((unused)) struct cmdline *cl,
6818 __attribute__((unused)) void *data)
6820 start_packet_forwarding(0);
6823 cmdline_parse_inst_t cmd_start = {
6824 .f = cmd_start_parsed,
6826 .help_str = "start: Start packet forwarding",
6828 (void *)&cmd_start_start,
6833 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6834 struct cmd_start_tx_first_result {
6835 cmdline_fixed_string_t start;
6836 cmdline_fixed_string_t tx_first;
6840 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6841 __attribute__((unused)) struct cmdline *cl,
6842 __attribute__((unused)) void *data)
6844 start_packet_forwarding(1);
6847 cmdline_parse_token_string_t cmd_start_tx_first_start =
6848 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6850 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6851 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6852 tx_first, "tx_first");
6854 cmdline_parse_inst_t cmd_start_tx_first = {
6855 .f = cmd_start_tx_first_parsed,
6857 .help_str = "start tx_first: Start packet forwarding, "
6858 "after sending 1 burst of packets",
6860 (void *)&cmd_start_tx_first_start,
6861 (void *)&cmd_start_tx_first_tx_first,
6866 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6867 struct cmd_start_tx_first_n_result {
6868 cmdline_fixed_string_t start;
6869 cmdline_fixed_string_t tx_first;
6874 cmd_start_tx_first_n_parsed(void *parsed_result,
6875 __attribute__((unused)) struct cmdline *cl,
6876 __attribute__((unused)) void *data)
6878 struct cmd_start_tx_first_n_result *res = parsed_result;
6880 start_packet_forwarding(res->tx_num);
6883 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6884 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6886 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6887 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6888 tx_first, "tx_first");
6889 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6890 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6893 cmdline_parse_inst_t cmd_start_tx_first_n = {
6894 .f = cmd_start_tx_first_n_parsed,
6896 .help_str = "start tx_first <num>: "
6897 "packet forwarding, after sending <num> bursts of packets",
6899 (void *)&cmd_start_tx_first_n_start,
6900 (void *)&cmd_start_tx_first_n_tx_first,
6901 (void *)&cmd_start_tx_first_n_tx_num,
6906 /* *** SET LINK UP *** */
6907 struct cmd_set_link_up_result {
6908 cmdline_fixed_string_t set;
6909 cmdline_fixed_string_t link_up;
6910 cmdline_fixed_string_t port;
6914 cmdline_parse_token_string_t cmd_set_link_up_set =
6915 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6916 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6917 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6919 cmdline_parse_token_string_t cmd_set_link_up_port =
6920 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6921 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6922 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6924 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6925 __attribute__((unused)) struct cmdline *cl,
6926 __attribute__((unused)) void *data)
6928 struct cmd_set_link_up_result *res = parsed_result;
6929 dev_set_link_up(res->port_id);
6932 cmdline_parse_inst_t cmd_set_link_up = {
6933 .f = cmd_set_link_up_parsed,
6935 .help_str = "set link-up port <port id>",
6937 (void *)&cmd_set_link_up_set,
6938 (void *)&cmd_set_link_up_link_up,
6939 (void *)&cmd_set_link_up_port,
6940 (void *)&cmd_set_link_up_port_id,
6945 /* *** SET LINK DOWN *** */
6946 struct cmd_set_link_down_result {
6947 cmdline_fixed_string_t set;
6948 cmdline_fixed_string_t link_down;
6949 cmdline_fixed_string_t port;
6953 cmdline_parse_token_string_t cmd_set_link_down_set =
6954 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6955 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6956 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6958 cmdline_parse_token_string_t cmd_set_link_down_port =
6959 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6960 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6961 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6963 static void cmd_set_link_down_parsed(
6964 __attribute__((unused)) void *parsed_result,
6965 __attribute__((unused)) struct cmdline *cl,
6966 __attribute__((unused)) void *data)
6968 struct cmd_set_link_down_result *res = parsed_result;
6969 dev_set_link_down(res->port_id);
6972 cmdline_parse_inst_t cmd_set_link_down = {
6973 .f = cmd_set_link_down_parsed,
6975 .help_str = "set link-down port <port id>",
6977 (void *)&cmd_set_link_down_set,
6978 (void *)&cmd_set_link_down_link_down,
6979 (void *)&cmd_set_link_down_port,
6980 (void *)&cmd_set_link_down_port_id,
6985 /* *** SHOW CFG *** */
6986 struct cmd_showcfg_result {
6987 cmdline_fixed_string_t show;
6988 cmdline_fixed_string_t cfg;
6989 cmdline_fixed_string_t what;
6992 static void cmd_showcfg_parsed(void *parsed_result,
6993 __attribute__((unused)) struct cmdline *cl,
6994 __attribute__((unused)) void *data)
6996 struct cmd_showcfg_result *res = parsed_result;
6997 if (!strcmp(res->what, "rxtx"))
6998 rxtx_config_display();
6999 else if (!strcmp(res->what, "cores"))
7000 fwd_lcores_config_display();
7001 else if (!strcmp(res->what, "fwd"))
7002 pkt_fwd_config_display(&cur_fwd_config);
7003 else if (!strcmp(res->what, "txpkts"))
7004 show_tx_pkt_segments();
7007 cmdline_parse_token_string_t cmd_showcfg_show =
7008 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7009 cmdline_parse_token_string_t cmd_showcfg_port =
7010 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7011 cmdline_parse_token_string_t cmd_showcfg_what =
7012 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7013 "rxtx#cores#fwd#txpkts");
7015 cmdline_parse_inst_t cmd_showcfg = {
7016 .f = cmd_showcfg_parsed,
7018 .help_str = "show config rxtx|cores|fwd|txpkts",
7020 (void *)&cmd_showcfg_show,
7021 (void *)&cmd_showcfg_port,
7022 (void *)&cmd_showcfg_what,
7027 /* *** SHOW ALL PORT INFO *** */
7028 struct cmd_showportall_result {
7029 cmdline_fixed_string_t show;
7030 cmdline_fixed_string_t port;
7031 cmdline_fixed_string_t what;
7032 cmdline_fixed_string_t all;
7035 static void cmd_showportall_parsed(void *parsed_result,
7036 __attribute__((unused)) struct cmdline *cl,
7037 __attribute__((unused)) void *data)
7041 struct cmd_showportall_result *res = parsed_result;
7042 if (!strcmp(res->show, "clear")) {
7043 if (!strcmp(res->what, "stats"))
7044 RTE_ETH_FOREACH_DEV(i)
7046 else if (!strcmp(res->what, "xstats"))
7047 RTE_ETH_FOREACH_DEV(i)
7048 nic_xstats_clear(i);
7049 } else if (!strcmp(res->what, "info"))
7050 RTE_ETH_FOREACH_DEV(i)
7051 port_infos_display(i);
7052 else if (!strcmp(res->what, "stats"))
7053 RTE_ETH_FOREACH_DEV(i)
7054 nic_stats_display(i);
7055 else if (!strcmp(res->what, "xstats"))
7056 RTE_ETH_FOREACH_DEV(i)
7057 nic_xstats_display(i);
7058 else if (!strcmp(res->what, "fdir"))
7059 RTE_ETH_FOREACH_DEV(i)
7061 else if (!strcmp(res->what, "stat_qmap"))
7062 RTE_ETH_FOREACH_DEV(i)
7063 nic_stats_mapping_display(i);
7064 else if (!strcmp(res->what, "dcb_tc"))
7065 RTE_ETH_FOREACH_DEV(i)
7066 port_dcb_info_display(i);
7067 else if (!strcmp(res->what, "cap"))
7068 RTE_ETH_FOREACH_DEV(i)
7069 port_offload_cap_display(i);
7072 cmdline_parse_token_string_t cmd_showportall_show =
7073 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7075 cmdline_parse_token_string_t cmd_showportall_port =
7076 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7077 cmdline_parse_token_string_t cmd_showportall_what =
7078 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7079 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7080 cmdline_parse_token_string_t cmd_showportall_all =
7081 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7082 cmdline_parse_inst_t cmd_showportall = {
7083 .f = cmd_showportall_parsed,
7085 .help_str = "show|clear port "
7086 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7088 (void *)&cmd_showportall_show,
7089 (void *)&cmd_showportall_port,
7090 (void *)&cmd_showportall_what,
7091 (void *)&cmd_showportall_all,
7096 /* *** SHOW PORT INFO *** */
7097 struct cmd_showport_result {
7098 cmdline_fixed_string_t show;
7099 cmdline_fixed_string_t port;
7100 cmdline_fixed_string_t what;
7104 static void cmd_showport_parsed(void *parsed_result,
7105 __attribute__((unused)) struct cmdline *cl,
7106 __attribute__((unused)) void *data)
7108 struct cmd_showport_result *res = parsed_result;
7109 if (!strcmp(res->show, "clear")) {
7110 if (!strcmp(res->what, "stats"))
7111 nic_stats_clear(res->portnum);
7112 else if (!strcmp(res->what, "xstats"))
7113 nic_xstats_clear(res->portnum);
7114 } else if (!strcmp(res->what, "info"))
7115 port_infos_display(res->portnum);
7116 else if (!strcmp(res->what, "stats"))
7117 nic_stats_display(res->portnum);
7118 else if (!strcmp(res->what, "xstats"))
7119 nic_xstats_display(res->portnum);
7120 else if (!strcmp(res->what, "fdir"))
7121 fdir_get_infos(res->portnum);
7122 else if (!strcmp(res->what, "stat_qmap"))
7123 nic_stats_mapping_display(res->portnum);
7124 else if (!strcmp(res->what, "dcb_tc"))
7125 port_dcb_info_display(res->portnum);
7126 else if (!strcmp(res->what, "cap"))
7127 port_offload_cap_display(res->portnum);
7130 cmdline_parse_token_string_t cmd_showport_show =
7131 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7133 cmdline_parse_token_string_t cmd_showport_port =
7134 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7135 cmdline_parse_token_string_t cmd_showport_what =
7136 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7137 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7138 cmdline_parse_token_num_t cmd_showport_portnum =
7139 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7141 cmdline_parse_inst_t cmd_showport = {
7142 .f = cmd_showport_parsed,
7144 .help_str = "show|clear port "
7145 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7148 (void *)&cmd_showport_show,
7149 (void *)&cmd_showport_port,
7150 (void *)&cmd_showport_what,
7151 (void *)&cmd_showport_portnum,
7156 /* *** SHOW QUEUE INFO *** */
7157 struct cmd_showqueue_result {
7158 cmdline_fixed_string_t show;
7159 cmdline_fixed_string_t type;
7160 cmdline_fixed_string_t what;
7166 cmd_showqueue_parsed(void *parsed_result,
7167 __attribute__((unused)) struct cmdline *cl,
7168 __attribute__((unused)) void *data)
7170 struct cmd_showqueue_result *res = parsed_result;
7172 if (!strcmp(res->type, "rxq"))
7173 rx_queue_infos_display(res->portnum, res->queuenum);
7174 else if (!strcmp(res->type, "txq"))
7175 tx_queue_infos_display(res->portnum, res->queuenum);
7178 cmdline_parse_token_string_t cmd_showqueue_show =
7179 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7180 cmdline_parse_token_string_t cmd_showqueue_type =
7181 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7182 cmdline_parse_token_string_t cmd_showqueue_what =
7183 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7184 cmdline_parse_token_num_t cmd_showqueue_portnum =
7185 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7186 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7187 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7189 cmdline_parse_inst_t cmd_showqueue = {
7190 .f = cmd_showqueue_parsed,
7192 .help_str = "show rxq|txq info <port_id> <queue_id>",
7194 (void *)&cmd_showqueue_show,
7195 (void *)&cmd_showqueue_type,
7196 (void *)&cmd_showqueue_what,
7197 (void *)&cmd_showqueue_portnum,
7198 (void *)&cmd_showqueue_queuenum,
7203 /* *** READ PORT REGISTER *** */
7204 struct cmd_read_reg_result {
7205 cmdline_fixed_string_t read;
7206 cmdline_fixed_string_t reg;
7212 cmd_read_reg_parsed(void *parsed_result,
7213 __attribute__((unused)) struct cmdline *cl,
7214 __attribute__((unused)) void *data)
7216 struct cmd_read_reg_result *res = parsed_result;
7217 port_reg_display(res->port_id, res->reg_off);
7220 cmdline_parse_token_string_t cmd_read_reg_read =
7221 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7222 cmdline_parse_token_string_t cmd_read_reg_reg =
7223 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7224 cmdline_parse_token_num_t cmd_read_reg_port_id =
7225 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7226 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7227 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7229 cmdline_parse_inst_t cmd_read_reg = {
7230 .f = cmd_read_reg_parsed,
7232 .help_str = "read reg <port_id> <reg_off>",
7234 (void *)&cmd_read_reg_read,
7235 (void *)&cmd_read_reg_reg,
7236 (void *)&cmd_read_reg_port_id,
7237 (void *)&cmd_read_reg_reg_off,
7242 /* *** READ PORT REGISTER BIT FIELD *** */
7243 struct cmd_read_reg_bit_field_result {
7244 cmdline_fixed_string_t read;
7245 cmdline_fixed_string_t regfield;
7253 cmd_read_reg_bit_field_parsed(void *parsed_result,
7254 __attribute__((unused)) struct cmdline *cl,
7255 __attribute__((unused)) void *data)
7257 struct cmd_read_reg_bit_field_result *res = parsed_result;
7258 port_reg_bit_field_display(res->port_id, res->reg_off,
7259 res->bit1_pos, res->bit2_pos);
7262 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7263 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7265 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7266 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7267 regfield, "regfield");
7268 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7269 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7271 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7272 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7274 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7275 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7277 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7278 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7281 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7282 .f = cmd_read_reg_bit_field_parsed,
7284 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7285 "Read register bit field between bit_x and bit_y included",
7287 (void *)&cmd_read_reg_bit_field_read,
7288 (void *)&cmd_read_reg_bit_field_regfield,
7289 (void *)&cmd_read_reg_bit_field_port_id,
7290 (void *)&cmd_read_reg_bit_field_reg_off,
7291 (void *)&cmd_read_reg_bit_field_bit1_pos,
7292 (void *)&cmd_read_reg_bit_field_bit2_pos,
7297 /* *** READ PORT REGISTER BIT *** */
7298 struct cmd_read_reg_bit_result {
7299 cmdline_fixed_string_t read;
7300 cmdline_fixed_string_t regbit;
7307 cmd_read_reg_bit_parsed(void *parsed_result,
7308 __attribute__((unused)) struct cmdline *cl,
7309 __attribute__((unused)) void *data)
7311 struct cmd_read_reg_bit_result *res = parsed_result;
7312 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7315 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7316 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7317 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7318 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7320 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7321 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7322 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7323 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7324 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7325 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7327 cmdline_parse_inst_t cmd_read_reg_bit = {
7328 .f = cmd_read_reg_bit_parsed,
7330 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7332 (void *)&cmd_read_reg_bit_read,
7333 (void *)&cmd_read_reg_bit_regbit,
7334 (void *)&cmd_read_reg_bit_port_id,
7335 (void *)&cmd_read_reg_bit_reg_off,
7336 (void *)&cmd_read_reg_bit_bit_pos,
7341 /* *** WRITE PORT REGISTER *** */
7342 struct cmd_write_reg_result {
7343 cmdline_fixed_string_t write;
7344 cmdline_fixed_string_t reg;
7351 cmd_write_reg_parsed(void *parsed_result,
7352 __attribute__((unused)) struct cmdline *cl,
7353 __attribute__((unused)) void *data)
7355 struct cmd_write_reg_result *res = parsed_result;
7356 port_reg_set(res->port_id, res->reg_off, res->value);
7359 cmdline_parse_token_string_t cmd_write_reg_write =
7360 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7361 cmdline_parse_token_string_t cmd_write_reg_reg =
7362 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7363 cmdline_parse_token_num_t cmd_write_reg_port_id =
7364 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7365 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7366 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7367 cmdline_parse_token_num_t cmd_write_reg_value =
7368 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7370 cmdline_parse_inst_t cmd_write_reg = {
7371 .f = cmd_write_reg_parsed,
7373 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7375 (void *)&cmd_write_reg_write,
7376 (void *)&cmd_write_reg_reg,
7377 (void *)&cmd_write_reg_port_id,
7378 (void *)&cmd_write_reg_reg_off,
7379 (void *)&cmd_write_reg_value,
7384 /* *** WRITE PORT REGISTER BIT FIELD *** */
7385 struct cmd_write_reg_bit_field_result {
7386 cmdline_fixed_string_t write;
7387 cmdline_fixed_string_t regfield;
7396 cmd_write_reg_bit_field_parsed(void *parsed_result,
7397 __attribute__((unused)) struct cmdline *cl,
7398 __attribute__((unused)) void *data)
7400 struct cmd_write_reg_bit_field_result *res = parsed_result;
7401 port_reg_bit_field_set(res->port_id, res->reg_off,
7402 res->bit1_pos, res->bit2_pos, res->value);
7405 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7406 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7408 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7409 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7410 regfield, "regfield");
7411 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7412 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7414 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7415 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7417 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7418 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7420 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7421 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7423 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7424 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7427 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7428 .f = cmd_write_reg_bit_field_parsed,
7430 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7432 "Set register bit field between bit_x and bit_y included",
7434 (void *)&cmd_write_reg_bit_field_write,
7435 (void *)&cmd_write_reg_bit_field_regfield,
7436 (void *)&cmd_write_reg_bit_field_port_id,
7437 (void *)&cmd_write_reg_bit_field_reg_off,
7438 (void *)&cmd_write_reg_bit_field_bit1_pos,
7439 (void *)&cmd_write_reg_bit_field_bit2_pos,
7440 (void *)&cmd_write_reg_bit_field_value,
7445 /* *** WRITE PORT REGISTER BIT *** */
7446 struct cmd_write_reg_bit_result {
7447 cmdline_fixed_string_t write;
7448 cmdline_fixed_string_t regbit;
7456 cmd_write_reg_bit_parsed(void *parsed_result,
7457 __attribute__((unused)) struct cmdline *cl,
7458 __attribute__((unused)) void *data)
7460 struct cmd_write_reg_bit_result *res = parsed_result;
7461 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7464 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7465 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7467 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7468 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7470 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7471 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7472 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7473 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7474 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7475 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7476 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7477 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7479 cmdline_parse_inst_t cmd_write_reg_bit = {
7480 .f = cmd_write_reg_bit_parsed,
7482 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7485 (void *)&cmd_write_reg_bit_write,
7486 (void *)&cmd_write_reg_bit_regbit,
7487 (void *)&cmd_write_reg_bit_port_id,
7488 (void *)&cmd_write_reg_bit_reg_off,
7489 (void *)&cmd_write_reg_bit_bit_pos,
7490 (void *)&cmd_write_reg_bit_value,
7495 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7496 struct cmd_read_rxd_txd_result {
7497 cmdline_fixed_string_t read;
7498 cmdline_fixed_string_t rxd_txd;
7505 cmd_read_rxd_txd_parsed(void *parsed_result,
7506 __attribute__((unused)) struct cmdline *cl,
7507 __attribute__((unused)) void *data)
7509 struct cmd_read_rxd_txd_result *res = parsed_result;
7511 if (!strcmp(res->rxd_txd, "rxd"))
7512 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7513 else if (!strcmp(res->rxd_txd, "txd"))
7514 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7517 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7518 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7519 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7520 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7522 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7523 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7524 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7525 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7526 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7527 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7529 cmdline_parse_inst_t cmd_read_rxd_txd = {
7530 .f = cmd_read_rxd_txd_parsed,
7532 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7534 (void *)&cmd_read_rxd_txd_read,
7535 (void *)&cmd_read_rxd_txd_rxd_txd,
7536 (void *)&cmd_read_rxd_txd_port_id,
7537 (void *)&cmd_read_rxd_txd_queue_id,
7538 (void *)&cmd_read_rxd_txd_desc_id,
7544 struct cmd_quit_result {
7545 cmdline_fixed_string_t quit;
7548 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7550 __attribute__((unused)) void *data)
7556 cmdline_parse_token_string_t cmd_quit_quit =
7557 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7559 cmdline_parse_inst_t cmd_quit = {
7560 .f = cmd_quit_parsed,
7562 .help_str = "quit: Exit application",
7564 (void *)&cmd_quit_quit,
7569 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7570 struct cmd_mac_addr_result {
7571 cmdline_fixed_string_t mac_addr_cmd;
7572 cmdline_fixed_string_t what;
7574 struct ether_addr address;
7577 static void cmd_mac_addr_parsed(void *parsed_result,
7578 __attribute__((unused)) struct cmdline *cl,
7579 __attribute__((unused)) void *data)
7581 struct cmd_mac_addr_result *res = parsed_result;
7584 if (strcmp(res->what, "add") == 0)
7585 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7586 else if (strcmp(res->what, "set") == 0)
7587 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7590 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7592 /* check the return value and print it if is < 0 */
7594 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7598 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7599 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7601 cmdline_parse_token_string_t cmd_mac_addr_what =
7602 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7604 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7605 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7607 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7608 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7610 cmdline_parse_inst_t cmd_mac_addr = {
7611 .f = cmd_mac_addr_parsed,
7613 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7614 "Add/Remove/Set MAC address on port_id",
7616 (void *)&cmd_mac_addr_cmd,
7617 (void *)&cmd_mac_addr_what,
7618 (void *)&cmd_mac_addr_portnum,
7619 (void *)&cmd_mac_addr_addr,
7624 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7625 struct cmd_eth_peer_result {
7626 cmdline_fixed_string_t set;
7627 cmdline_fixed_string_t eth_peer;
7629 cmdline_fixed_string_t peer_addr;
7632 static void cmd_set_eth_peer_parsed(void *parsed_result,
7633 __attribute__((unused)) struct cmdline *cl,
7634 __attribute__((unused)) void *data)
7636 struct cmd_eth_peer_result *res = parsed_result;
7638 if (test_done == 0) {
7639 printf("Please stop forwarding first\n");
7642 if (!strcmp(res->eth_peer, "eth-peer")) {
7643 set_fwd_eth_peer(res->port_id, res->peer_addr);
7647 cmdline_parse_token_string_t cmd_eth_peer_set =
7648 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7649 cmdline_parse_token_string_t cmd_eth_peer =
7650 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7651 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7652 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7653 cmdline_parse_token_string_t cmd_eth_peer_addr =
7654 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7656 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7657 .f = cmd_set_eth_peer_parsed,
7659 .help_str = "set eth-peer <port_id> <peer_mac>",
7661 (void *)&cmd_eth_peer_set,
7662 (void *)&cmd_eth_peer,
7663 (void *)&cmd_eth_peer_port_id,
7664 (void *)&cmd_eth_peer_addr,
7669 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7670 struct cmd_set_qmap_result {
7671 cmdline_fixed_string_t set;
7672 cmdline_fixed_string_t qmap;
7673 cmdline_fixed_string_t what;
7680 cmd_set_qmap_parsed(void *parsed_result,
7681 __attribute__((unused)) struct cmdline *cl,
7682 __attribute__((unused)) void *data)
7684 struct cmd_set_qmap_result *res = parsed_result;
7685 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7687 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7690 cmdline_parse_token_string_t cmd_setqmap_set =
7691 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7693 cmdline_parse_token_string_t cmd_setqmap_qmap =
7694 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7696 cmdline_parse_token_string_t cmd_setqmap_what =
7697 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7699 cmdline_parse_token_num_t cmd_setqmap_portid =
7700 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7702 cmdline_parse_token_num_t cmd_setqmap_queueid =
7703 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7705 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7706 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7709 cmdline_parse_inst_t cmd_set_qmap = {
7710 .f = cmd_set_qmap_parsed,
7712 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7713 "Set statistics mapping value on tx|rx queue_id of port_id",
7715 (void *)&cmd_setqmap_set,
7716 (void *)&cmd_setqmap_qmap,
7717 (void *)&cmd_setqmap_what,
7718 (void *)&cmd_setqmap_portid,
7719 (void *)&cmd_setqmap_queueid,
7720 (void *)&cmd_setqmap_mapvalue,
7725 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7726 struct cmd_set_xstats_hide_zero_result {
7727 cmdline_fixed_string_t keyword;
7728 cmdline_fixed_string_t name;
7729 cmdline_fixed_string_t on_off;
7733 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7734 __attribute__((unused)) struct cmdline *cl,
7735 __attribute__((unused)) void *data)
7737 struct cmd_set_xstats_hide_zero_result *res;
7738 uint16_t on_off = 0;
7740 res = parsed_result;
7741 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7742 set_xstats_hide_zero(on_off);
7745 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7746 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7748 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7749 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7750 name, "xstats-hide-zero");
7751 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7752 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7755 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7756 .f = cmd_set_xstats_hide_zero_parsed,
7758 .help_str = "set xstats-hide-zero on|off",
7760 (void *)&cmd_set_xstats_hide_zero_keyword,
7761 (void *)&cmd_set_xstats_hide_zero_name,
7762 (void *)&cmd_set_xstats_hide_zero_on_off,
7767 /* *** CONFIGURE UNICAST HASH TABLE *** */
7768 struct cmd_set_uc_hash_table {
7769 cmdline_fixed_string_t set;
7770 cmdline_fixed_string_t port;
7772 cmdline_fixed_string_t what;
7773 struct ether_addr address;
7774 cmdline_fixed_string_t mode;
7778 cmd_set_uc_hash_parsed(void *parsed_result,
7779 __attribute__((unused)) struct cmdline *cl,
7780 __attribute__((unused)) void *data)
7783 struct cmd_set_uc_hash_table *res = parsed_result;
7785 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7787 if (strcmp(res->what, "uta") == 0)
7788 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7789 &res->address,(uint8_t)is_on);
7791 printf("bad unicast hash table parameter, return code = %d \n", ret);
7795 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7796 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7798 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7799 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7801 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7802 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7804 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7805 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7807 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7808 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7810 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7811 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7814 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7815 .f = cmd_set_uc_hash_parsed,
7817 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7819 (void *)&cmd_set_uc_hash_set,
7820 (void *)&cmd_set_uc_hash_port,
7821 (void *)&cmd_set_uc_hash_portid,
7822 (void *)&cmd_set_uc_hash_what,
7823 (void *)&cmd_set_uc_hash_mac,
7824 (void *)&cmd_set_uc_hash_mode,
7829 struct cmd_set_uc_all_hash_table {
7830 cmdline_fixed_string_t set;
7831 cmdline_fixed_string_t port;
7833 cmdline_fixed_string_t what;
7834 cmdline_fixed_string_t value;
7835 cmdline_fixed_string_t mode;
7839 cmd_set_uc_all_hash_parsed(void *parsed_result,
7840 __attribute__((unused)) struct cmdline *cl,
7841 __attribute__((unused)) void *data)
7844 struct cmd_set_uc_all_hash_table *res = parsed_result;
7846 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7848 if ((strcmp(res->what, "uta") == 0) &&
7849 (strcmp(res->value, "all") == 0))
7850 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7852 printf("bad unicast hash table parameter,"
7853 "return code = %d \n", ret);
7856 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7857 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7859 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7860 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7862 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7863 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7865 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7866 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7868 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7869 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7871 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7872 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7875 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7876 .f = cmd_set_uc_all_hash_parsed,
7878 .help_str = "set port <port_id> uta all on|off",
7880 (void *)&cmd_set_uc_all_hash_set,
7881 (void *)&cmd_set_uc_all_hash_port,
7882 (void *)&cmd_set_uc_all_hash_portid,
7883 (void *)&cmd_set_uc_all_hash_what,
7884 (void *)&cmd_set_uc_all_hash_value,
7885 (void *)&cmd_set_uc_all_hash_mode,
7890 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7891 struct cmd_set_vf_macvlan_filter {
7892 cmdline_fixed_string_t set;
7893 cmdline_fixed_string_t port;
7895 cmdline_fixed_string_t vf;
7897 struct ether_addr address;
7898 cmdline_fixed_string_t filter_type;
7899 cmdline_fixed_string_t mode;
7903 cmd_set_vf_macvlan_parsed(void *parsed_result,
7904 __attribute__((unused)) struct cmdline *cl,
7905 __attribute__((unused)) void *data)
7908 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7909 struct rte_eth_mac_filter filter;
7911 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7913 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7915 /* set VF MAC filter */
7919 filter.dst_id = res->vf_id;
7921 if (!strcmp(res->filter_type, "exact-mac"))
7922 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7923 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7924 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7925 else if (!strcmp(res->filter_type, "hashmac"))
7926 filter.filter_type = RTE_MAC_HASH_MATCH;
7927 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7928 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7930 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7933 ret = rte_eth_dev_filter_ctrl(res->port_id,
7934 RTE_ETH_FILTER_MACVLAN,
7938 ret = rte_eth_dev_filter_ctrl(res->port_id,
7939 RTE_ETH_FILTER_MACVLAN,
7940 RTE_ETH_FILTER_DELETE,
7944 printf("bad set MAC hash parameter, return code = %d\n", ret);
7948 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7949 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7951 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7952 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7954 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7955 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7957 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7958 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7960 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7961 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7963 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7964 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7966 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7967 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7968 filter_type, "exact-mac#exact-mac-vlan"
7969 "#hashmac#hashmac-vlan");
7970 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7971 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7974 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7975 .f = cmd_set_vf_macvlan_parsed,
7977 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7978 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7979 "Exact match rule: exact match of MAC or MAC and VLAN; "
7980 "hash match rule: hash match of MAC and exact match of VLAN",
7982 (void *)&cmd_set_vf_macvlan_set,
7983 (void *)&cmd_set_vf_macvlan_port,
7984 (void *)&cmd_set_vf_macvlan_portid,
7985 (void *)&cmd_set_vf_macvlan_vf,
7986 (void *)&cmd_set_vf_macvlan_vf_id,
7987 (void *)&cmd_set_vf_macvlan_mac,
7988 (void *)&cmd_set_vf_macvlan_filter_type,
7989 (void *)&cmd_set_vf_macvlan_mode,
7994 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7995 struct cmd_set_vf_traffic {
7996 cmdline_fixed_string_t set;
7997 cmdline_fixed_string_t port;
7999 cmdline_fixed_string_t vf;
8001 cmdline_fixed_string_t what;
8002 cmdline_fixed_string_t mode;
8006 cmd_set_vf_traffic_parsed(void *parsed_result,
8007 __attribute__((unused)) struct cmdline *cl,
8008 __attribute__((unused)) void *data)
8010 struct cmd_set_vf_traffic *res = parsed_result;
8011 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8012 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8014 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8017 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8018 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8020 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8021 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8023 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8024 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8026 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8027 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8029 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8030 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8032 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8033 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8035 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8036 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8039 cmdline_parse_inst_t cmd_set_vf_traffic = {
8040 .f = cmd_set_vf_traffic_parsed,
8042 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8044 (void *)&cmd_setvf_traffic_set,
8045 (void *)&cmd_setvf_traffic_port,
8046 (void *)&cmd_setvf_traffic_portid,
8047 (void *)&cmd_setvf_traffic_vf,
8048 (void *)&cmd_setvf_traffic_vfid,
8049 (void *)&cmd_setvf_traffic_what,
8050 (void *)&cmd_setvf_traffic_mode,
8055 /* *** CONFIGURE VF RECEIVE MODE *** */
8056 struct cmd_set_vf_rxmode {
8057 cmdline_fixed_string_t set;
8058 cmdline_fixed_string_t port;
8060 cmdline_fixed_string_t vf;
8062 cmdline_fixed_string_t what;
8063 cmdline_fixed_string_t mode;
8064 cmdline_fixed_string_t on;
8068 cmd_set_vf_rxmode_parsed(void *parsed_result,
8069 __attribute__((unused)) struct cmdline *cl,
8070 __attribute__((unused)) void *data)
8073 uint16_t rx_mode = 0;
8074 struct cmd_set_vf_rxmode *res = parsed_result;
8076 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8077 if (!strcmp(res->what,"rxmode")) {
8078 if (!strcmp(res->mode, "AUPE"))
8079 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8080 else if (!strcmp(res->mode, "ROPE"))
8081 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8082 else if (!strcmp(res->mode, "BAM"))
8083 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8084 else if (!strncmp(res->mode, "MPE",3))
8085 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8088 RTE_SET_USED(is_on);
8090 #ifdef RTE_LIBRTE_IXGBE_PMD
8091 if (ret == -ENOTSUP)
8092 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8093 rx_mode, (uint8_t)is_on);
8095 #ifdef RTE_LIBRTE_BNXT_PMD
8096 if (ret == -ENOTSUP)
8097 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8098 rx_mode, (uint8_t)is_on);
8101 printf("bad VF receive mode parameter, return code = %d \n",
8105 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8106 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8108 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8109 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8111 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8112 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8114 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8115 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8117 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8118 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8120 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8121 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8123 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8124 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8125 mode, "AUPE#ROPE#BAM#MPE");
8126 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8127 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8130 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8131 .f = cmd_set_vf_rxmode_parsed,
8133 .help_str = "set port <port_id> vf <vf_id> rxmode "
8134 "AUPE|ROPE|BAM|MPE on|off",
8136 (void *)&cmd_set_vf_rxmode_set,
8137 (void *)&cmd_set_vf_rxmode_port,
8138 (void *)&cmd_set_vf_rxmode_portid,
8139 (void *)&cmd_set_vf_rxmode_vf,
8140 (void *)&cmd_set_vf_rxmode_vfid,
8141 (void *)&cmd_set_vf_rxmode_what,
8142 (void *)&cmd_set_vf_rxmode_mode,
8143 (void *)&cmd_set_vf_rxmode_on,
8148 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8149 struct cmd_vf_mac_addr_result {
8150 cmdline_fixed_string_t mac_addr_cmd;
8151 cmdline_fixed_string_t what;
8152 cmdline_fixed_string_t port;
8154 cmdline_fixed_string_t vf;
8156 struct ether_addr address;
8159 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8160 __attribute__((unused)) struct cmdline *cl,
8161 __attribute__((unused)) void *data)
8163 struct cmd_vf_mac_addr_result *res = parsed_result;
8166 if (strcmp(res->what, "add") != 0)
8169 #ifdef RTE_LIBRTE_I40E_PMD
8170 if (ret == -ENOTSUP)
8171 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8174 #ifdef RTE_LIBRTE_BNXT_PMD
8175 if (ret == -ENOTSUP)
8176 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8181 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8185 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8186 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8187 mac_addr_cmd,"mac_addr");
8188 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8189 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8191 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8192 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8194 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8195 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8197 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8198 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8200 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8201 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8203 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8204 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8207 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8208 .f = cmd_vf_mac_addr_parsed,
8210 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8211 "Add MAC address filtering for a VF on port_id",
8213 (void *)&cmd_vf_mac_addr_cmd,
8214 (void *)&cmd_vf_mac_addr_what,
8215 (void *)&cmd_vf_mac_addr_port,
8216 (void *)&cmd_vf_mac_addr_portnum,
8217 (void *)&cmd_vf_mac_addr_vf,
8218 (void *)&cmd_vf_mac_addr_vfnum,
8219 (void *)&cmd_vf_mac_addr_addr,
8224 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8225 struct cmd_vf_rx_vlan_filter {
8226 cmdline_fixed_string_t rx_vlan;
8227 cmdline_fixed_string_t what;
8229 cmdline_fixed_string_t port;
8231 cmdline_fixed_string_t vf;
8236 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8237 __attribute__((unused)) struct cmdline *cl,
8238 __attribute__((unused)) void *data)
8240 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8243 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8245 #ifdef RTE_LIBRTE_IXGBE_PMD
8246 if (ret == -ENOTSUP)
8247 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8248 res->vlan_id, res->vf_mask, is_add);
8250 #ifdef RTE_LIBRTE_I40E_PMD
8251 if (ret == -ENOTSUP)
8252 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8253 res->vlan_id, res->vf_mask, is_add);
8255 #ifdef RTE_LIBRTE_BNXT_PMD
8256 if (ret == -ENOTSUP)
8257 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8258 res->vlan_id, res->vf_mask, is_add);
8265 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8266 res->vlan_id, res->vf_mask);
8269 printf("invalid port_id %d\n", res->port_id);
8272 printf("function not implemented or supported\n");
8275 printf("programming error: (%s)\n", strerror(-ret));
8279 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8280 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8281 rx_vlan, "rx_vlan");
8282 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8283 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8285 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8286 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8288 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8289 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8291 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8292 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8294 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8295 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8297 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8298 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8301 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8302 .f = cmd_vf_rx_vlan_filter_parsed,
8304 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8305 "(vf_mask = hexadecimal VF mask)",
8307 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8308 (void *)&cmd_vf_rx_vlan_filter_what,
8309 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8310 (void *)&cmd_vf_rx_vlan_filter_port,
8311 (void *)&cmd_vf_rx_vlan_filter_portid,
8312 (void *)&cmd_vf_rx_vlan_filter_vf,
8313 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8318 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8319 struct cmd_queue_rate_limit_result {
8320 cmdline_fixed_string_t set;
8321 cmdline_fixed_string_t port;
8323 cmdline_fixed_string_t queue;
8325 cmdline_fixed_string_t rate;
8329 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8330 __attribute__((unused)) struct cmdline *cl,
8331 __attribute__((unused)) void *data)
8333 struct cmd_queue_rate_limit_result *res = parsed_result;
8336 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8337 && (strcmp(res->queue, "queue") == 0)
8338 && (strcmp(res->rate, "rate") == 0))
8339 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8342 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8346 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8347 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8349 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8350 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8352 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8353 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8355 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8356 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8358 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8359 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8361 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8362 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8364 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8365 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8368 cmdline_parse_inst_t cmd_queue_rate_limit = {
8369 .f = cmd_queue_rate_limit_parsed,
8371 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8372 "Set rate limit for a queue on port_id",
8374 (void *)&cmd_queue_rate_limit_set,
8375 (void *)&cmd_queue_rate_limit_port,
8376 (void *)&cmd_queue_rate_limit_portnum,
8377 (void *)&cmd_queue_rate_limit_queue,
8378 (void *)&cmd_queue_rate_limit_queuenum,
8379 (void *)&cmd_queue_rate_limit_rate,
8380 (void *)&cmd_queue_rate_limit_ratenum,
8385 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8386 struct cmd_vf_rate_limit_result {
8387 cmdline_fixed_string_t set;
8388 cmdline_fixed_string_t port;
8390 cmdline_fixed_string_t vf;
8392 cmdline_fixed_string_t rate;
8394 cmdline_fixed_string_t q_msk;
8398 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8399 __attribute__((unused)) struct cmdline *cl,
8400 __attribute__((unused)) void *data)
8402 struct cmd_vf_rate_limit_result *res = parsed_result;
8405 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8406 && (strcmp(res->vf, "vf") == 0)
8407 && (strcmp(res->rate, "rate") == 0)
8408 && (strcmp(res->q_msk, "queue_mask") == 0))
8409 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8410 res->rate_num, res->q_msk_val);
8412 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8416 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8417 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8419 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8420 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8422 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8423 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8425 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8426 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8428 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8429 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8431 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8432 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8434 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8435 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8437 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8438 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8439 q_msk, "queue_mask");
8440 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8441 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8444 cmdline_parse_inst_t cmd_vf_rate_limit = {
8445 .f = cmd_vf_rate_limit_parsed,
8447 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8448 "queue_mask <queue_mask_value>: "
8449 "Set rate limit for queues of VF on port_id",
8451 (void *)&cmd_vf_rate_limit_set,
8452 (void *)&cmd_vf_rate_limit_port,
8453 (void *)&cmd_vf_rate_limit_portnum,
8454 (void *)&cmd_vf_rate_limit_vf,
8455 (void *)&cmd_vf_rate_limit_vfnum,
8456 (void *)&cmd_vf_rate_limit_rate,
8457 (void *)&cmd_vf_rate_limit_ratenum,
8458 (void *)&cmd_vf_rate_limit_q_msk,
8459 (void *)&cmd_vf_rate_limit_q_msk_val,
8464 /* *** ADD TUNNEL FILTER OF A PORT *** */
8465 struct cmd_tunnel_filter_result {
8466 cmdline_fixed_string_t cmd;
8467 cmdline_fixed_string_t what;
8469 struct ether_addr outer_mac;
8470 struct ether_addr inner_mac;
8471 cmdline_ipaddr_t ip_value;
8472 uint16_t inner_vlan;
8473 cmdline_fixed_string_t tunnel_type;
8474 cmdline_fixed_string_t filter_type;
8480 cmd_tunnel_filter_parsed(void *parsed_result,
8481 __attribute__((unused)) struct cmdline *cl,
8482 __attribute__((unused)) void *data)
8484 struct cmd_tunnel_filter_result *res = parsed_result;
8485 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8488 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8490 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8491 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8492 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8494 if (res->ip_value.family == AF_INET) {
8495 tunnel_filter_conf.ip_addr.ipv4_addr =
8496 res->ip_value.addr.ipv4.s_addr;
8497 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8499 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8500 &(res->ip_value.addr.ipv6),
8501 sizeof(struct in6_addr));
8502 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8505 if (!strcmp(res->filter_type, "imac-ivlan"))
8506 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8507 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8508 tunnel_filter_conf.filter_type =
8509 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8510 else if (!strcmp(res->filter_type, "imac-tenid"))
8511 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8512 else if (!strcmp(res->filter_type, "imac"))
8513 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8514 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8515 tunnel_filter_conf.filter_type =
8516 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8517 else if (!strcmp(res->filter_type, "oip"))
8518 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8519 else if (!strcmp(res->filter_type, "iip"))
8520 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8522 printf("The filter type is not supported");
8526 if (!strcmp(res->tunnel_type, "vxlan"))
8527 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8528 else if (!strcmp(res->tunnel_type, "nvgre"))
8529 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8530 else if (!strcmp(res->tunnel_type, "ipingre"))
8531 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8533 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8537 tunnel_filter_conf.tenant_id = res->tenant_id;
8538 tunnel_filter_conf.queue_id = res->queue_num;
8539 if (!strcmp(res->what, "add"))
8540 ret = rte_eth_dev_filter_ctrl(res->port_id,
8541 RTE_ETH_FILTER_TUNNEL,
8543 &tunnel_filter_conf);
8545 ret = rte_eth_dev_filter_ctrl(res->port_id,
8546 RTE_ETH_FILTER_TUNNEL,
8547 RTE_ETH_FILTER_DELETE,
8548 &tunnel_filter_conf);
8550 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8554 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8555 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8556 cmd, "tunnel_filter");
8557 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8558 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8560 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8561 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8563 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8564 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8566 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8567 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8569 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8570 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8571 inner_vlan, UINT16);
8572 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8573 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8575 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8576 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8577 tunnel_type, "vxlan#nvgre#ipingre");
8579 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8580 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8581 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8582 "imac#omac-imac-tenid");
8583 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8584 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8586 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8587 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8590 cmdline_parse_inst_t cmd_tunnel_filter = {
8591 .f = cmd_tunnel_filter_parsed,
8593 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8594 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8595 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8596 "<queue_id>: Add/Rm tunnel filter of a port",
8598 (void *)&cmd_tunnel_filter_cmd,
8599 (void *)&cmd_tunnel_filter_what,
8600 (void *)&cmd_tunnel_filter_port_id,
8601 (void *)&cmd_tunnel_filter_outer_mac,
8602 (void *)&cmd_tunnel_filter_inner_mac,
8603 (void *)&cmd_tunnel_filter_ip_value,
8604 (void *)&cmd_tunnel_filter_innner_vlan,
8605 (void *)&cmd_tunnel_filter_tunnel_type,
8606 (void *)&cmd_tunnel_filter_filter_type,
8607 (void *)&cmd_tunnel_filter_tenant_id,
8608 (void *)&cmd_tunnel_filter_queue_num,
8613 /* *** CONFIGURE TUNNEL UDP PORT *** */
8614 struct cmd_tunnel_udp_config {
8615 cmdline_fixed_string_t cmd;
8616 cmdline_fixed_string_t what;
8622 cmd_tunnel_udp_config_parsed(void *parsed_result,
8623 __attribute__((unused)) struct cmdline *cl,
8624 __attribute__((unused)) void *data)
8626 struct cmd_tunnel_udp_config *res = parsed_result;
8627 struct rte_eth_udp_tunnel tunnel_udp;
8630 tunnel_udp.udp_port = res->udp_port;
8632 if (!strcmp(res->cmd, "rx_vxlan_port"))
8633 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8635 if (!strcmp(res->what, "add"))
8636 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8639 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8643 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8646 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8647 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8648 cmd, "rx_vxlan_port");
8649 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8650 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8652 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8653 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8655 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8656 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8659 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8660 .f = cmd_tunnel_udp_config_parsed,
8662 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8663 "Add/Remove a tunneling UDP port filter",
8665 (void *)&cmd_tunnel_udp_config_cmd,
8666 (void *)&cmd_tunnel_udp_config_what,
8667 (void *)&cmd_tunnel_udp_config_udp_port,
8668 (void *)&cmd_tunnel_udp_config_port_id,
8673 struct cmd_config_tunnel_udp_port {
8674 cmdline_fixed_string_t port;
8675 cmdline_fixed_string_t config;
8677 cmdline_fixed_string_t udp_tunnel_port;
8678 cmdline_fixed_string_t action;
8679 cmdline_fixed_string_t tunnel_type;
8684 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8685 __attribute__((unused)) struct cmdline *cl,
8686 __attribute__((unused)) void *data)
8688 struct cmd_config_tunnel_udp_port *res = parsed_result;
8689 struct rte_eth_udp_tunnel tunnel_udp;
8692 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8695 tunnel_udp.udp_port = res->udp_port;
8697 if (!strcmp(res->tunnel_type, "vxlan")) {
8698 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8699 } else if (!strcmp(res->tunnel_type, "geneve")) {
8700 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8702 printf("Invalid tunnel type\n");
8706 if (!strcmp(res->action, "add"))
8707 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8710 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8714 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8717 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8718 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8720 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8721 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8723 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8724 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8726 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8727 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8730 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8731 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8733 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8734 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8736 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8737 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8740 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8741 .f = cmd_cfg_tunnel_udp_port_parsed,
8743 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8745 (void *)&cmd_config_tunnel_udp_port_port,
8746 (void *)&cmd_config_tunnel_udp_port_config,
8747 (void *)&cmd_config_tunnel_udp_port_port_id,
8748 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8749 (void *)&cmd_config_tunnel_udp_port_action,
8750 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8751 (void *)&cmd_config_tunnel_udp_port_value,
8756 /* *** GLOBAL CONFIG *** */
8757 struct cmd_global_config_result {
8758 cmdline_fixed_string_t cmd;
8760 cmdline_fixed_string_t cfg_type;
8765 cmd_global_config_parsed(void *parsed_result,
8766 __attribute__((unused)) struct cmdline *cl,
8767 __attribute__((unused)) void *data)
8769 struct cmd_global_config_result *res = parsed_result;
8770 struct rte_eth_global_cfg conf;
8773 memset(&conf, 0, sizeof(conf));
8774 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8775 conf.cfg.gre_key_len = res->len;
8776 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8777 RTE_ETH_FILTER_SET, &conf);
8779 printf("Global config error\n");
8782 cmdline_parse_token_string_t cmd_global_config_cmd =
8783 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8785 cmdline_parse_token_num_t cmd_global_config_port_id =
8786 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8788 cmdline_parse_token_string_t cmd_global_config_type =
8789 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8790 cfg_type, "gre-key-len");
8791 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8792 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8795 cmdline_parse_inst_t cmd_global_config = {
8796 .f = cmd_global_config_parsed,
8797 .data = (void *)NULL,
8798 .help_str = "global_config <port_id> gre-key-len <key_len>",
8800 (void *)&cmd_global_config_cmd,
8801 (void *)&cmd_global_config_port_id,
8802 (void *)&cmd_global_config_type,
8803 (void *)&cmd_global_config_gre_key_len,
8808 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8809 struct cmd_set_mirror_mask_result {
8810 cmdline_fixed_string_t set;
8811 cmdline_fixed_string_t port;
8813 cmdline_fixed_string_t mirror;
8815 cmdline_fixed_string_t what;
8816 cmdline_fixed_string_t value;
8817 cmdline_fixed_string_t dstpool;
8819 cmdline_fixed_string_t on;
8822 cmdline_parse_token_string_t cmd_mirror_mask_set =
8823 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8825 cmdline_parse_token_string_t cmd_mirror_mask_port =
8826 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8828 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8829 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8831 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8832 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8833 mirror, "mirror-rule");
8834 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8835 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8837 cmdline_parse_token_string_t cmd_mirror_mask_what =
8838 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8839 what, "pool-mirror-up#pool-mirror-down"
8841 cmdline_parse_token_string_t cmd_mirror_mask_value =
8842 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8844 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8845 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8846 dstpool, "dst-pool");
8847 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8848 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8850 cmdline_parse_token_string_t cmd_mirror_mask_on =
8851 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8855 cmd_set_mirror_mask_parsed(void *parsed_result,
8856 __attribute__((unused)) struct cmdline *cl,
8857 __attribute__((unused)) void *data)
8860 struct cmd_set_mirror_mask_result *res = parsed_result;
8861 struct rte_eth_mirror_conf mr_conf;
8863 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8865 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8867 mr_conf.dst_pool = res->dstpool_id;
8869 if (!strcmp(res->what, "pool-mirror-up")) {
8870 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8871 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8872 } else if (!strcmp(res->what, "pool-mirror-down")) {
8873 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8874 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8875 } else if (!strcmp(res->what, "vlan-mirror")) {
8876 mr_conf.rule_type = ETH_MIRROR_VLAN;
8877 nb_item = parse_item_list(res->value, "vlan",
8878 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8882 for (i = 0; i < nb_item; i++) {
8883 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8884 printf("Invalid vlan_id: must be < 4096\n");
8888 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8889 mr_conf.vlan.vlan_mask |= 1ULL << i;
8893 if (!strcmp(res->on, "on"))
8894 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8897 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8900 printf("mirror rule add error: (%s)\n", strerror(-ret));
8903 cmdline_parse_inst_t cmd_set_mirror_mask = {
8904 .f = cmd_set_mirror_mask_parsed,
8906 .help_str = "set port <port_id> mirror-rule <rule_id> "
8907 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8908 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8910 (void *)&cmd_mirror_mask_set,
8911 (void *)&cmd_mirror_mask_port,
8912 (void *)&cmd_mirror_mask_portid,
8913 (void *)&cmd_mirror_mask_mirror,
8914 (void *)&cmd_mirror_mask_ruleid,
8915 (void *)&cmd_mirror_mask_what,
8916 (void *)&cmd_mirror_mask_value,
8917 (void *)&cmd_mirror_mask_dstpool,
8918 (void *)&cmd_mirror_mask_poolid,
8919 (void *)&cmd_mirror_mask_on,
8924 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8925 struct cmd_set_mirror_link_result {
8926 cmdline_fixed_string_t set;
8927 cmdline_fixed_string_t port;
8929 cmdline_fixed_string_t mirror;
8931 cmdline_fixed_string_t what;
8932 cmdline_fixed_string_t dstpool;
8934 cmdline_fixed_string_t on;
8937 cmdline_parse_token_string_t cmd_mirror_link_set =
8938 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8940 cmdline_parse_token_string_t cmd_mirror_link_port =
8941 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8943 cmdline_parse_token_num_t cmd_mirror_link_portid =
8944 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8946 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8947 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8948 mirror, "mirror-rule");
8949 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8950 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8952 cmdline_parse_token_string_t cmd_mirror_link_what =
8953 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8954 what, "uplink-mirror#downlink-mirror");
8955 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8956 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8957 dstpool, "dst-pool");
8958 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8959 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8961 cmdline_parse_token_string_t cmd_mirror_link_on =
8962 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8966 cmd_set_mirror_link_parsed(void *parsed_result,
8967 __attribute__((unused)) struct cmdline *cl,
8968 __attribute__((unused)) void *data)
8971 struct cmd_set_mirror_link_result *res = parsed_result;
8972 struct rte_eth_mirror_conf mr_conf;
8974 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8975 if (!strcmp(res->what, "uplink-mirror"))
8976 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8978 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8980 mr_conf.dst_pool = res->dstpool_id;
8982 if (!strcmp(res->on, "on"))
8983 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8986 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8989 /* check the return value and print it if is < 0 */
8991 printf("mirror rule add error: (%s)\n", strerror(-ret));
8995 cmdline_parse_inst_t cmd_set_mirror_link = {
8996 .f = cmd_set_mirror_link_parsed,
8998 .help_str = "set port <port_id> mirror-rule <rule_id> "
8999 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9001 (void *)&cmd_mirror_link_set,
9002 (void *)&cmd_mirror_link_port,
9003 (void *)&cmd_mirror_link_portid,
9004 (void *)&cmd_mirror_link_mirror,
9005 (void *)&cmd_mirror_link_ruleid,
9006 (void *)&cmd_mirror_link_what,
9007 (void *)&cmd_mirror_link_dstpool,
9008 (void *)&cmd_mirror_link_poolid,
9009 (void *)&cmd_mirror_link_on,
9014 /* *** RESET VM MIRROR RULE *** */
9015 struct cmd_rm_mirror_rule_result {
9016 cmdline_fixed_string_t reset;
9017 cmdline_fixed_string_t port;
9019 cmdline_fixed_string_t mirror;
9023 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9024 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9026 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9027 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9029 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9030 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9032 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9033 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9034 mirror, "mirror-rule");
9035 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9036 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9040 cmd_reset_mirror_rule_parsed(void *parsed_result,
9041 __attribute__((unused)) struct cmdline *cl,
9042 __attribute__((unused)) void *data)
9045 struct cmd_set_mirror_link_result *res = parsed_result;
9047 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9049 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9052 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9053 .f = cmd_reset_mirror_rule_parsed,
9055 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9057 (void *)&cmd_rm_mirror_rule_reset,
9058 (void *)&cmd_rm_mirror_rule_port,
9059 (void *)&cmd_rm_mirror_rule_portid,
9060 (void *)&cmd_rm_mirror_rule_mirror,
9061 (void *)&cmd_rm_mirror_rule_ruleid,
9066 /* ******************************************************************************** */
9068 struct cmd_dump_result {
9069 cmdline_fixed_string_t dump;
9073 dump_struct_sizes(void)
9075 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9076 DUMP_SIZE(struct rte_mbuf);
9077 DUMP_SIZE(struct rte_mempool);
9078 DUMP_SIZE(struct rte_ring);
9082 static void cmd_dump_parsed(void *parsed_result,
9083 __attribute__((unused)) struct cmdline *cl,
9084 __attribute__((unused)) void *data)
9086 struct cmd_dump_result *res = parsed_result;
9088 if (!strcmp(res->dump, "dump_physmem"))
9089 rte_dump_physmem_layout(stdout);
9090 else if (!strcmp(res->dump, "dump_memzone"))
9091 rte_memzone_dump(stdout);
9092 else if (!strcmp(res->dump, "dump_struct_sizes"))
9093 dump_struct_sizes();
9094 else if (!strcmp(res->dump, "dump_ring"))
9095 rte_ring_list_dump(stdout);
9096 else if (!strcmp(res->dump, "dump_mempool"))
9097 rte_mempool_list_dump(stdout);
9098 else if (!strcmp(res->dump, "dump_devargs"))
9099 rte_devargs_dump(stdout);
9100 else if (!strcmp(res->dump, "dump_log_types"))
9101 rte_log_dump(stdout);
9104 cmdline_parse_token_string_t cmd_dump_dump =
9105 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9108 "dump_struct_sizes#"
9114 cmdline_parse_inst_t cmd_dump = {
9115 .f = cmd_dump_parsed, /* function to call */
9116 .data = NULL, /* 2nd arg of func */
9117 .help_str = "Dump status",
9118 .tokens = { /* token list, NULL terminated */
9119 (void *)&cmd_dump_dump,
9124 /* ******************************************************************************** */
9126 struct cmd_dump_one_result {
9127 cmdline_fixed_string_t dump;
9128 cmdline_fixed_string_t name;
9131 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9132 __attribute__((unused)) void *data)
9134 struct cmd_dump_one_result *res = parsed_result;
9136 if (!strcmp(res->dump, "dump_ring")) {
9138 r = rte_ring_lookup(res->name);
9140 cmdline_printf(cl, "Cannot find ring\n");
9143 rte_ring_dump(stdout, r);
9144 } else if (!strcmp(res->dump, "dump_mempool")) {
9145 struct rte_mempool *mp;
9146 mp = rte_mempool_lookup(res->name);
9148 cmdline_printf(cl, "Cannot find mempool\n");
9151 rte_mempool_dump(stdout, mp);
9155 cmdline_parse_token_string_t cmd_dump_one_dump =
9156 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9157 "dump_ring#dump_mempool");
9159 cmdline_parse_token_string_t cmd_dump_one_name =
9160 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9162 cmdline_parse_inst_t cmd_dump_one = {
9163 .f = cmd_dump_one_parsed, /* function to call */
9164 .data = NULL, /* 2nd arg of func */
9165 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9166 .tokens = { /* token list, NULL terminated */
9167 (void *)&cmd_dump_one_dump,
9168 (void *)&cmd_dump_one_name,
9173 /* *** Add/Del syn filter *** */
9174 struct cmd_syn_filter_result {
9175 cmdline_fixed_string_t filter;
9177 cmdline_fixed_string_t ops;
9178 cmdline_fixed_string_t priority;
9179 cmdline_fixed_string_t high;
9180 cmdline_fixed_string_t queue;
9185 cmd_syn_filter_parsed(void *parsed_result,
9186 __attribute__((unused)) struct cmdline *cl,
9187 __attribute__((unused)) void *data)
9189 struct cmd_syn_filter_result *res = parsed_result;
9190 struct rte_eth_syn_filter syn_filter;
9193 ret = rte_eth_dev_filter_supported(res->port_id,
9194 RTE_ETH_FILTER_SYN);
9196 printf("syn filter is not supported on port %u.\n",
9201 memset(&syn_filter, 0, sizeof(syn_filter));
9203 if (!strcmp(res->ops, "add")) {
9204 if (!strcmp(res->high, "high"))
9205 syn_filter.hig_pri = 1;
9207 syn_filter.hig_pri = 0;
9209 syn_filter.queue = res->queue_id;
9210 ret = rte_eth_dev_filter_ctrl(res->port_id,
9215 ret = rte_eth_dev_filter_ctrl(res->port_id,
9217 RTE_ETH_FILTER_DELETE,
9221 printf("syn filter programming error: (%s)\n",
9225 cmdline_parse_token_string_t cmd_syn_filter_filter =
9226 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9227 filter, "syn_filter");
9228 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9229 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9231 cmdline_parse_token_string_t cmd_syn_filter_ops =
9232 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9234 cmdline_parse_token_string_t cmd_syn_filter_priority =
9235 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9236 priority, "priority");
9237 cmdline_parse_token_string_t cmd_syn_filter_high =
9238 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9240 cmdline_parse_token_string_t cmd_syn_filter_queue =
9241 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9243 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9244 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9247 cmdline_parse_inst_t cmd_syn_filter = {
9248 .f = cmd_syn_filter_parsed,
9250 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9251 "<queue_id>: Add/Delete syn filter",
9253 (void *)&cmd_syn_filter_filter,
9254 (void *)&cmd_syn_filter_port_id,
9255 (void *)&cmd_syn_filter_ops,
9256 (void *)&cmd_syn_filter_priority,
9257 (void *)&cmd_syn_filter_high,
9258 (void *)&cmd_syn_filter_queue,
9259 (void *)&cmd_syn_filter_queue_id,
9264 /* *** queue region set *** */
9265 struct cmd_queue_region_result {
9266 cmdline_fixed_string_t set;
9267 cmdline_fixed_string_t port;
9269 cmdline_fixed_string_t cmd;
9270 cmdline_fixed_string_t region;
9272 cmdline_fixed_string_t queue_start_index;
9274 cmdline_fixed_string_t queue_num;
9275 uint8_t queue_num_value;
9279 cmd_queue_region_parsed(void *parsed_result,
9280 __attribute__((unused)) struct cmdline *cl,
9281 __attribute__((unused)) void *data)
9283 struct cmd_queue_region_result *res = parsed_result;
9285 #ifdef RTE_LIBRTE_I40E_PMD
9286 struct rte_pmd_i40e_queue_region_conf region_conf;
9287 enum rte_pmd_i40e_queue_region_op op_type;
9290 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9293 #ifdef RTE_LIBRTE_I40E_PMD
9294 memset(®ion_conf, 0, sizeof(region_conf));
9295 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9296 region_conf.region_id = res->region_id;
9297 region_conf.queue_num = res->queue_num_value;
9298 region_conf.queue_start_index = res->queue_id;
9300 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9301 op_type, ®ion_conf);
9308 printf("function not implemented or supported\n");
9311 printf("queue region config error: (%s)\n", strerror(-ret));
9315 cmdline_parse_token_string_t cmd_queue_region_set =
9316 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9318 cmdline_parse_token_string_t cmd_queue_region_port =
9319 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9320 cmdline_parse_token_num_t cmd_queue_region_port_id =
9321 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9323 cmdline_parse_token_string_t cmd_queue_region_cmd =
9324 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9325 cmd, "queue-region");
9326 cmdline_parse_token_string_t cmd_queue_region_id =
9327 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9328 region, "region_id");
9329 cmdline_parse_token_num_t cmd_queue_region_index =
9330 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9332 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9333 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9334 queue_start_index, "queue_start_index");
9335 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9336 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9338 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9339 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9340 queue_num, "queue_num");
9341 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9342 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9343 queue_num_value, UINT8);
9345 cmdline_parse_inst_t cmd_queue_region = {
9346 .f = cmd_queue_region_parsed,
9348 .help_str = "set port <port_id> queue-region region_id <value> "
9349 "queue_start_index <value> queue_num <value>: Set a queue region",
9351 (void *)&cmd_queue_region_set,
9352 (void *)&cmd_queue_region_port,
9353 (void *)&cmd_queue_region_port_id,
9354 (void *)&cmd_queue_region_cmd,
9355 (void *)&cmd_queue_region_id,
9356 (void *)&cmd_queue_region_index,
9357 (void *)&cmd_queue_region_queue_start_index,
9358 (void *)&cmd_queue_region_queue_id,
9359 (void *)&cmd_queue_region_queue_num,
9360 (void *)&cmd_queue_region_queue_num_value,
9365 /* *** queue region and flowtype set *** */
9366 struct cmd_region_flowtype_result {
9367 cmdline_fixed_string_t set;
9368 cmdline_fixed_string_t port;
9370 cmdline_fixed_string_t cmd;
9371 cmdline_fixed_string_t region;
9373 cmdline_fixed_string_t flowtype;
9374 uint8_t flowtype_id;
9378 cmd_region_flowtype_parsed(void *parsed_result,
9379 __attribute__((unused)) struct cmdline *cl,
9380 __attribute__((unused)) void *data)
9382 struct cmd_region_flowtype_result *res = parsed_result;
9384 #ifdef RTE_LIBRTE_I40E_PMD
9385 struct rte_pmd_i40e_queue_region_conf region_conf;
9386 enum rte_pmd_i40e_queue_region_op op_type;
9389 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9392 #ifdef RTE_LIBRTE_I40E_PMD
9393 memset(®ion_conf, 0, sizeof(region_conf));
9395 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9396 region_conf.region_id = res->region_id;
9397 region_conf.hw_flowtype = res->flowtype_id;
9399 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9400 op_type, ®ion_conf);
9407 printf("function not implemented or supported\n");
9410 printf("region flowtype config error: (%s)\n", strerror(-ret));
9414 cmdline_parse_token_string_t cmd_region_flowtype_set =
9415 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9417 cmdline_parse_token_string_t cmd_region_flowtype_port =
9418 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9420 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9421 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9423 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9424 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9425 cmd, "queue-region");
9426 cmdline_parse_token_string_t cmd_region_flowtype_index =
9427 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9428 region, "region_id");
9429 cmdline_parse_token_num_t cmd_region_flowtype_id =
9430 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9432 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9433 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9434 flowtype, "flowtype");
9435 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9436 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9437 flowtype_id, UINT8);
9438 cmdline_parse_inst_t cmd_region_flowtype = {
9439 .f = cmd_region_flowtype_parsed,
9441 .help_str = "set port <port_id> queue-region region_id <value> "
9442 "flowtype <value>: Set a flowtype region index",
9444 (void *)&cmd_region_flowtype_set,
9445 (void *)&cmd_region_flowtype_port,
9446 (void *)&cmd_region_flowtype_port_index,
9447 (void *)&cmd_region_flowtype_cmd,
9448 (void *)&cmd_region_flowtype_index,
9449 (void *)&cmd_region_flowtype_id,
9450 (void *)&cmd_region_flowtype_flow_index,
9451 (void *)&cmd_region_flowtype_flow_id,
9456 /* *** User Priority (UP) to queue region (region_id) set *** */
9457 struct cmd_user_priority_region_result {
9458 cmdline_fixed_string_t set;
9459 cmdline_fixed_string_t port;
9461 cmdline_fixed_string_t cmd;
9462 cmdline_fixed_string_t user_priority;
9463 uint8_t user_priority_id;
9464 cmdline_fixed_string_t region;
9469 cmd_user_priority_region_parsed(void *parsed_result,
9470 __attribute__((unused)) struct cmdline *cl,
9471 __attribute__((unused)) void *data)
9473 struct cmd_user_priority_region_result *res = parsed_result;
9475 #ifdef RTE_LIBRTE_I40E_PMD
9476 struct rte_pmd_i40e_queue_region_conf region_conf;
9477 enum rte_pmd_i40e_queue_region_op op_type;
9480 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9483 #ifdef RTE_LIBRTE_I40E_PMD
9484 memset(®ion_conf, 0, sizeof(region_conf));
9485 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9486 region_conf.user_priority = res->user_priority_id;
9487 region_conf.region_id = res->region_id;
9489 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9490 op_type, ®ion_conf);
9497 printf("function not implemented or supported\n");
9500 printf("user_priority region config error: (%s)\n",
9505 cmdline_parse_token_string_t cmd_user_priority_region_set =
9506 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9508 cmdline_parse_token_string_t cmd_user_priority_region_port =
9509 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9511 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9512 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9514 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9515 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9516 cmd, "queue-region");
9517 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9518 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9519 user_priority, "UP");
9520 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9521 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9522 user_priority_id, UINT8);
9523 cmdline_parse_token_string_t cmd_user_priority_region_region =
9524 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9525 region, "region_id");
9526 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9527 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9530 cmdline_parse_inst_t cmd_user_priority_region = {
9531 .f = cmd_user_priority_region_parsed,
9533 .help_str = "set port <port_id> queue-region UP <value> "
9534 "region_id <value>: Set the mapping of User Priority (UP) "
9535 "to queue region (region_id) ",
9537 (void *)&cmd_user_priority_region_set,
9538 (void *)&cmd_user_priority_region_port,
9539 (void *)&cmd_user_priority_region_port_index,
9540 (void *)&cmd_user_priority_region_cmd,
9541 (void *)&cmd_user_priority_region_UP,
9542 (void *)&cmd_user_priority_region_UP_id,
9543 (void *)&cmd_user_priority_region_region,
9544 (void *)&cmd_user_priority_region_region_id,
9549 /* *** flush all queue region related configuration *** */
9550 struct cmd_flush_queue_region_result {
9551 cmdline_fixed_string_t set;
9552 cmdline_fixed_string_t port;
9554 cmdline_fixed_string_t cmd;
9555 cmdline_fixed_string_t flush;
9556 cmdline_fixed_string_t what;
9560 cmd_flush_queue_region_parsed(void *parsed_result,
9561 __attribute__((unused)) struct cmdline *cl,
9562 __attribute__((unused)) void *data)
9564 struct cmd_flush_queue_region_result *res = parsed_result;
9566 #ifdef RTE_LIBRTE_I40E_PMD
9567 struct rte_pmd_i40e_queue_region_conf region_conf;
9568 enum rte_pmd_i40e_queue_region_op op_type;
9571 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9574 #ifdef RTE_LIBRTE_I40E_PMD
9575 memset(®ion_conf, 0, sizeof(region_conf));
9577 if (strcmp(res->what, "on") == 0)
9578 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9580 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9582 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9583 op_type, ®ion_conf);
9590 printf("function not implemented or supported\n");
9593 printf("queue region config flush error: (%s)\n",
9598 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9599 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9601 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9602 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9604 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9605 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9607 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9608 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9609 cmd, "queue-region");
9610 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9611 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9613 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9614 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9617 cmdline_parse_inst_t cmd_flush_queue_region = {
9618 .f = cmd_flush_queue_region_parsed,
9620 .help_str = "set port <port_id> queue-region flush on|off"
9621 ": flush all queue region related configuration",
9623 (void *)&cmd_flush_queue_region_set,
9624 (void *)&cmd_flush_queue_region_port,
9625 (void *)&cmd_flush_queue_region_port_index,
9626 (void *)&cmd_flush_queue_region_cmd,
9627 (void *)&cmd_flush_queue_region_flush,
9628 (void *)&cmd_flush_queue_region_what,
9633 /* *** get all queue region related configuration info *** */
9634 struct cmd_show_queue_region_info {
9635 cmdline_fixed_string_t show;
9636 cmdline_fixed_string_t port;
9638 cmdline_fixed_string_t cmd;
9642 cmd_show_queue_region_info_parsed(void *parsed_result,
9643 __attribute__((unused)) struct cmdline *cl,
9644 __attribute__((unused)) void *data)
9646 struct cmd_show_queue_region_info *res = parsed_result;
9648 #ifdef RTE_LIBRTE_I40E_PMD
9649 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9650 enum rte_pmd_i40e_queue_region_op op_type;
9653 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9656 #ifdef RTE_LIBRTE_I40E_PMD
9657 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9659 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9661 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9662 op_type, &rte_pmd_regions);
9664 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9671 printf("function not implemented or supported\n");
9674 printf("queue region config info show error: (%s)\n",
9679 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9680 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9682 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9683 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9685 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9686 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9688 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9689 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9690 cmd, "queue-region");
9692 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9693 .f = cmd_show_queue_region_info_parsed,
9695 .help_str = "show port <port_id> queue-region"
9696 ": show all queue region related configuration info",
9698 (void *)&cmd_show_queue_region_info_get,
9699 (void *)&cmd_show_queue_region_info_port,
9700 (void *)&cmd_show_queue_region_info_port_index,
9701 (void *)&cmd_show_queue_region_info_cmd,
9706 /* *** ADD/REMOVE A 2tuple FILTER *** */
9707 struct cmd_2tuple_filter_result {
9708 cmdline_fixed_string_t filter;
9710 cmdline_fixed_string_t ops;
9711 cmdline_fixed_string_t dst_port;
9712 uint16_t dst_port_value;
9713 cmdline_fixed_string_t protocol;
9714 uint8_t protocol_value;
9715 cmdline_fixed_string_t mask;
9717 cmdline_fixed_string_t tcp_flags;
9718 uint8_t tcp_flags_value;
9719 cmdline_fixed_string_t priority;
9720 uint8_t priority_value;
9721 cmdline_fixed_string_t queue;
9726 cmd_2tuple_filter_parsed(void *parsed_result,
9727 __attribute__((unused)) struct cmdline *cl,
9728 __attribute__((unused)) void *data)
9730 struct rte_eth_ntuple_filter filter;
9731 struct cmd_2tuple_filter_result *res = parsed_result;
9734 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9736 printf("ntuple filter is not supported on port %u.\n",
9741 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9743 filter.flags = RTE_2TUPLE_FLAGS;
9744 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9745 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9746 filter.proto = res->protocol_value;
9747 filter.priority = res->priority_value;
9748 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9749 printf("nonzero tcp_flags is only meaningful"
9750 " when protocol is TCP.\n");
9753 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9754 printf("invalid TCP flags.\n");
9758 if (res->tcp_flags_value != 0) {
9759 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9760 filter.tcp_flags = res->tcp_flags_value;
9763 /* need convert to big endian. */
9764 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9765 filter.queue = res->queue_id;
9767 if (!strcmp(res->ops, "add"))
9768 ret = rte_eth_dev_filter_ctrl(res->port_id,
9769 RTE_ETH_FILTER_NTUPLE,
9773 ret = rte_eth_dev_filter_ctrl(res->port_id,
9774 RTE_ETH_FILTER_NTUPLE,
9775 RTE_ETH_FILTER_DELETE,
9778 printf("2tuple filter programming error: (%s)\n",
9783 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9784 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9785 filter, "2tuple_filter");
9786 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9787 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9789 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9790 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9792 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9793 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9794 dst_port, "dst_port");
9795 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9796 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9797 dst_port_value, UINT16);
9798 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9799 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9800 protocol, "protocol");
9801 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9802 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9803 protocol_value, UINT8);
9804 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9805 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9807 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9808 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9810 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9811 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9812 tcp_flags, "tcp_flags");
9813 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9814 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9815 tcp_flags_value, UINT8);
9816 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9817 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9818 priority, "priority");
9819 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9820 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9821 priority_value, UINT8);
9822 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9823 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9825 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9826 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9829 cmdline_parse_inst_t cmd_2tuple_filter = {
9830 .f = cmd_2tuple_filter_parsed,
9832 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9833 "<value> mask <value> tcp_flags <value> priority <value> queue "
9834 "<queue_id>: Add a 2tuple filter",
9836 (void *)&cmd_2tuple_filter_filter,
9837 (void *)&cmd_2tuple_filter_port_id,
9838 (void *)&cmd_2tuple_filter_ops,
9839 (void *)&cmd_2tuple_filter_dst_port,
9840 (void *)&cmd_2tuple_filter_dst_port_value,
9841 (void *)&cmd_2tuple_filter_protocol,
9842 (void *)&cmd_2tuple_filter_protocol_value,
9843 (void *)&cmd_2tuple_filter_mask,
9844 (void *)&cmd_2tuple_filter_mask_value,
9845 (void *)&cmd_2tuple_filter_tcp_flags,
9846 (void *)&cmd_2tuple_filter_tcp_flags_value,
9847 (void *)&cmd_2tuple_filter_priority,
9848 (void *)&cmd_2tuple_filter_priority_value,
9849 (void *)&cmd_2tuple_filter_queue,
9850 (void *)&cmd_2tuple_filter_queue_id,
9855 /* *** ADD/REMOVE A 5tuple FILTER *** */
9856 struct cmd_5tuple_filter_result {
9857 cmdline_fixed_string_t filter;
9859 cmdline_fixed_string_t ops;
9860 cmdline_fixed_string_t dst_ip;
9861 cmdline_ipaddr_t dst_ip_value;
9862 cmdline_fixed_string_t src_ip;
9863 cmdline_ipaddr_t src_ip_value;
9864 cmdline_fixed_string_t dst_port;
9865 uint16_t dst_port_value;
9866 cmdline_fixed_string_t src_port;
9867 uint16_t src_port_value;
9868 cmdline_fixed_string_t protocol;
9869 uint8_t protocol_value;
9870 cmdline_fixed_string_t mask;
9872 cmdline_fixed_string_t tcp_flags;
9873 uint8_t tcp_flags_value;
9874 cmdline_fixed_string_t priority;
9875 uint8_t priority_value;
9876 cmdline_fixed_string_t queue;
9881 cmd_5tuple_filter_parsed(void *parsed_result,
9882 __attribute__((unused)) struct cmdline *cl,
9883 __attribute__((unused)) void *data)
9885 struct rte_eth_ntuple_filter filter;
9886 struct cmd_5tuple_filter_result *res = parsed_result;
9889 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9891 printf("ntuple filter is not supported on port %u.\n",
9896 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9898 filter.flags = RTE_5TUPLE_FLAGS;
9899 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9900 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9901 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9902 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9903 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9904 filter.proto = res->protocol_value;
9905 filter.priority = res->priority_value;
9906 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9907 printf("nonzero tcp_flags is only meaningful"
9908 " when protocol is TCP.\n");
9911 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9912 printf("invalid TCP flags.\n");
9916 if (res->tcp_flags_value != 0) {
9917 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9918 filter.tcp_flags = res->tcp_flags_value;
9921 if (res->dst_ip_value.family == AF_INET)
9922 /* no need to convert, already big endian. */
9923 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9925 if (filter.dst_ip_mask == 0) {
9926 printf("can not support ipv6 involved compare.\n");
9932 if (res->src_ip_value.family == AF_INET)
9933 /* no need to convert, already big endian. */
9934 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9936 if (filter.src_ip_mask == 0) {
9937 printf("can not support ipv6 involved compare.\n");
9942 /* need convert to big endian. */
9943 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9944 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9945 filter.queue = res->queue_id;
9947 if (!strcmp(res->ops, "add"))
9948 ret = rte_eth_dev_filter_ctrl(res->port_id,
9949 RTE_ETH_FILTER_NTUPLE,
9953 ret = rte_eth_dev_filter_ctrl(res->port_id,
9954 RTE_ETH_FILTER_NTUPLE,
9955 RTE_ETH_FILTER_DELETE,
9958 printf("5tuple filter programming error: (%s)\n",
9962 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9963 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9964 filter, "5tuple_filter");
9965 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9966 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9968 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9969 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9971 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9972 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9974 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9975 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9977 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9978 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9980 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9981 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9983 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9984 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9985 dst_port, "dst_port");
9986 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9987 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9988 dst_port_value, UINT16);
9989 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9990 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9991 src_port, "src_port");
9992 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9993 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9994 src_port_value, UINT16);
9995 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9996 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9997 protocol, "protocol");
9998 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9999 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10000 protocol_value, UINT8);
10001 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10002 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10004 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10005 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10007 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10008 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10009 tcp_flags, "tcp_flags");
10010 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10011 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10012 tcp_flags_value, UINT8);
10013 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10014 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10015 priority, "priority");
10016 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10017 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10018 priority_value, UINT8);
10019 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10020 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10022 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10023 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10026 cmdline_parse_inst_t cmd_5tuple_filter = {
10027 .f = cmd_5tuple_filter_parsed,
10029 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10030 "src_ip <value> dst_port <value> src_port <value> "
10031 "protocol <value> mask <value> tcp_flags <value> "
10032 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10034 (void *)&cmd_5tuple_filter_filter,
10035 (void *)&cmd_5tuple_filter_port_id,
10036 (void *)&cmd_5tuple_filter_ops,
10037 (void *)&cmd_5tuple_filter_dst_ip,
10038 (void *)&cmd_5tuple_filter_dst_ip_value,
10039 (void *)&cmd_5tuple_filter_src_ip,
10040 (void *)&cmd_5tuple_filter_src_ip_value,
10041 (void *)&cmd_5tuple_filter_dst_port,
10042 (void *)&cmd_5tuple_filter_dst_port_value,
10043 (void *)&cmd_5tuple_filter_src_port,
10044 (void *)&cmd_5tuple_filter_src_port_value,
10045 (void *)&cmd_5tuple_filter_protocol,
10046 (void *)&cmd_5tuple_filter_protocol_value,
10047 (void *)&cmd_5tuple_filter_mask,
10048 (void *)&cmd_5tuple_filter_mask_value,
10049 (void *)&cmd_5tuple_filter_tcp_flags,
10050 (void *)&cmd_5tuple_filter_tcp_flags_value,
10051 (void *)&cmd_5tuple_filter_priority,
10052 (void *)&cmd_5tuple_filter_priority_value,
10053 (void *)&cmd_5tuple_filter_queue,
10054 (void *)&cmd_5tuple_filter_queue_id,
10059 /* *** ADD/REMOVE A flex FILTER *** */
10060 struct cmd_flex_filter_result {
10061 cmdline_fixed_string_t filter;
10062 cmdline_fixed_string_t ops;
10064 cmdline_fixed_string_t len;
10066 cmdline_fixed_string_t bytes;
10067 cmdline_fixed_string_t bytes_value;
10068 cmdline_fixed_string_t mask;
10069 cmdline_fixed_string_t mask_value;
10070 cmdline_fixed_string_t priority;
10071 uint8_t priority_value;
10072 cmdline_fixed_string_t queue;
10076 static int xdigit2val(unsigned char c)
10081 else if (isupper(c))
10082 val = c - 'A' + 10;
10084 val = c - 'a' + 10;
10089 cmd_flex_filter_parsed(void *parsed_result,
10090 __attribute__((unused)) struct cmdline *cl,
10091 __attribute__((unused)) void *data)
10094 struct rte_eth_flex_filter filter;
10095 struct cmd_flex_filter_result *res = parsed_result;
10096 char *bytes_ptr, *mask_ptr;
10097 uint16_t len, i, j = 0;
10102 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10103 printf("the len exceed the max length 128\n");
10106 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10107 filter.len = res->len_value;
10108 filter.priority = res->priority_value;
10109 filter.queue = res->queue_id;
10110 bytes_ptr = res->bytes_value;
10111 mask_ptr = res->mask_value;
10113 /* translate bytes string to array. */
10114 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10115 (bytes_ptr[1] == 'X')))
10117 len = strnlen(bytes_ptr, res->len_value * 2);
10118 if (len == 0 || (len % 8 != 0)) {
10119 printf("please check len and bytes input\n");
10122 for (i = 0; i < len; i++) {
10124 if (isxdigit(c) == 0) {
10125 /* invalid characters. */
10126 printf("invalid input\n");
10129 val = xdigit2val(c);
10132 filter.bytes[j] = byte;
10133 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10140 /* translate mask string to uint8_t array. */
10141 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10142 (mask_ptr[1] == 'X')))
10144 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10146 printf("invalid input\n");
10151 for (i = 0; i < len; i++) {
10153 if (isxdigit(c) == 0) {
10154 /* invalid characters. */
10155 printf("invalid input\n");
10158 val = xdigit2val(c);
10161 filter.mask[j] = byte;
10162 printf("mask[%d]:%02x ", j, filter.mask[j]);
10170 if (!strcmp(res->ops, "add"))
10171 ret = rte_eth_dev_filter_ctrl(res->port_id,
10172 RTE_ETH_FILTER_FLEXIBLE,
10173 RTE_ETH_FILTER_ADD,
10176 ret = rte_eth_dev_filter_ctrl(res->port_id,
10177 RTE_ETH_FILTER_FLEXIBLE,
10178 RTE_ETH_FILTER_DELETE,
10182 printf("flex filter setting error: (%s)\n", strerror(-ret));
10185 cmdline_parse_token_string_t cmd_flex_filter_filter =
10186 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10187 filter, "flex_filter");
10188 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10189 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10191 cmdline_parse_token_string_t cmd_flex_filter_ops =
10192 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10194 cmdline_parse_token_string_t cmd_flex_filter_len =
10195 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10197 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10198 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10200 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10201 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10203 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10204 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10205 bytes_value, NULL);
10206 cmdline_parse_token_string_t cmd_flex_filter_mask =
10207 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10209 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10210 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10212 cmdline_parse_token_string_t cmd_flex_filter_priority =
10213 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10214 priority, "priority");
10215 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10216 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10217 priority_value, UINT8);
10218 cmdline_parse_token_string_t cmd_flex_filter_queue =
10219 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10221 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10222 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10224 cmdline_parse_inst_t cmd_flex_filter = {
10225 .f = cmd_flex_filter_parsed,
10227 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10228 "<value> mask <value> priority <value> queue <queue_id>: "
10229 "Add/Del a flex filter",
10231 (void *)&cmd_flex_filter_filter,
10232 (void *)&cmd_flex_filter_port_id,
10233 (void *)&cmd_flex_filter_ops,
10234 (void *)&cmd_flex_filter_len,
10235 (void *)&cmd_flex_filter_len_value,
10236 (void *)&cmd_flex_filter_bytes,
10237 (void *)&cmd_flex_filter_bytes_value,
10238 (void *)&cmd_flex_filter_mask,
10239 (void *)&cmd_flex_filter_mask_value,
10240 (void *)&cmd_flex_filter_priority,
10241 (void *)&cmd_flex_filter_priority_value,
10242 (void *)&cmd_flex_filter_queue,
10243 (void *)&cmd_flex_filter_queue_id,
10248 /* *** Filters Control *** */
10250 /* *** deal with ethertype filter *** */
10251 struct cmd_ethertype_filter_result {
10252 cmdline_fixed_string_t filter;
10254 cmdline_fixed_string_t ops;
10255 cmdline_fixed_string_t mac;
10256 struct ether_addr mac_addr;
10257 cmdline_fixed_string_t ethertype;
10258 uint16_t ethertype_value;
10259 cmdline_fixed_string_t drop;
10260 cmdline_fixed_string_t queue;
10264 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10265 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10266 filter, "ethertype_filter");
10267 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10268 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10270 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10271 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10273 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10274 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10275 mac, "mac_addr#mac_ignr");
10276 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10277 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10279 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10280 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10281 ethertype, "ethertype");
10282 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10283 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10284 ethertype_value, UINT16);
10285 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10286 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10288 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10289 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10291 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10292 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10296 cmd_ethertype_filter_parsed(void *parsed_result,
10297 __attribute__((unused)) struct cmdline *cl,
10298 __attribute__((unused)) void *data)
10300 struct cmd_ethertype_filter_result *res = parsed_result;
10301 struct rte_eth_ethertype_filter filter;
10304 ret = rte_eth_dev_filter_supported(res->port_id,
10305 RTE_ETH_FILTER_ETHERTYPE);
10307 printf("ethertype filter is not supported on port %u.\n",
10312 memset(&filter, 0, sizeof(filter));
10313 if (!strcmp(res->mac, "mac_addr")) {
10314 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10315 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10316 sizeof(struct ether_addr));
10318 if (!strcmp(res->drop, "drop"))
10319 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10320 filter.ether_type = res->ethertype_value;
10321 filter.queue = res->queue_id;
10323 if (!strcmp(res->ops, "add"))
10324 ret = rte_eth_dev_filter_ctrl(res->port_id,
10325 RTE_ETH_FILTER_ETHERTYPE,
10326 RTE_ETH_FILTER_ADD,
10329 ret = rte_eth_dev_filter_ctrl(res->port_id,
10330 RTE_ETH_FILTER_ETHERTYPE,
10331 RTE_ETH_FILTER_DELETE,
10334 printf("ethertype filter programming error: (%s)\n",
10338 cmdline_parse_inst_t cmd_ethertype_filter = {
10339 .f = cmd_ethertype_filter_parsed,
10341 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10342 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10343 "Add or delete an ethertype filter entry",
10345 (void *)&cmd_ethertype_filter_filter,
10346 (void *)&cmd_ethertype_filter_port_id,
10347 (void *)&cmd_ethertype_filter_ops,
10348 (void *)&cmd_ethertype_filter_mac,
10349 (void *)&cmd_ethertype_filter_mac_addr,
10350 (void *)&cmd_ethertype_filter_ethertype,
10351 (void *)&cmd_ethertype_filter_ethertype_value,
10352 (void *)&cmd_ethertype_filter_drop,
10353 (void *)&cmd_ethertype_filter_queue,
10354 (void *)&cmd_ethertype_filter_queue_id,
10359 /* *** deal with flow director filter *** */
10360 struct cmd_flow_director_result {
10361 cmdline_fixed_string_t flow_director_filter;
10363 cmdline_fixed_string_t mode;
10364 cmdline_fixed_string_t mode_value;
10365 cmdline_fixed_string_t ops;
10366 cmdline_fixed_string_t flow;
10367 cmdline_fixed_string_t flow_type;
10368 cmdline_fixed_string_t ether;
10369 uint16_t ether_type;
10370 cmdline_fixed_string_t src;
10371 cmdline_ipaddr_t ip_src;
10373 cmdline_fixed_string_t dst;
10374 cmdline_ipaddr_t ip_dst;
10376 cmdline_fixed_string_t verify_tag;
10377 uint32_t verify_tag_value;
10378 cmdline_fixed_string_t tos;
10380 cmdline_fixed_string_t proto;
10381 uint8_t proto_value;
10382 cmdline_fixed_string_t ttl;
10384 cmdline_fixed_string_t vlan;
10385 uint16_t vlan_value;
10386 cmdline_fixed_string_t flexbytes;
10387 cmdline_fixed_string_t flexbytes_value;
10388 cmdline_fixed_string_t pf_vf;
10389 cmdline_fixed_string_t drop;
10390 cmdline_fixed_string_t queue;
10392 cmdline_fixed_string_t fd_id;
10393 uint32_t fd_id_value;
10394 cmdline_fixed_string_t mac;
10395 struct ether_addr mac_addr;
10396 cmdline_fixed_string_t tunnel;
10397 cmdline_fixed_string_t tunnel_type;
10398 cmdline_fixed_string_t tunnel_id;
10399 uint32_t tunnel_id_value;
10400 cmdline_fixed_string_t packet;
10405 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10408 const char *p, *p0 = q_arg;
10410 unsigned long int_fld;
10411 char *str_fld[max_num];
10416 p = strchr(p0, '(');
10420 p0 = strchr(p, ')');
10425 if (size >= sizeof(s))
10428 snprintf(s, sizeof(s), "%.*s", size, p);
10429 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10430 if (ret < 0 || ret > max_num)
10432 for (i = 0; i < ret; i++) {
10434 int_fld = strtoul(str_fld[i], &end, 0);
10435 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10437 flexbytes[i] = (uint8_t)int_fld;
10443 str2flowtype(char *string)
10446 static const struct {
10449 } flowtype_str[] = {
10450 {"raw", RTE_ETH_FLOW_RAW},
10451 {"ipv4", RTE_ETH_FLOW_IPV4},
10452 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10453 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10454 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10455 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10456 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10457 {"ipv6", RTE_ETH_FLOW_IPV6},
10458 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10459 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10460 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10461 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10462 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10463 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10466 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10467 if (!strcmp(flowtype_str[i].str, string))
10468 return flowtype_str[i].type;
10471 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10472 return (uint16_t)atoi(string);
10474 return RTE_ETH_FLOW_UNKNOWN;
10477 static enum rte_eth_fdir_tunnel_type
10478 str2fdir_tunneltype(char *string)
10482 static const struct {
10484 enum rte_eth_fdir_tunnel_type type;
10485 } tunneltype_str[] = {
10486 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10487 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10490 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10491 if (!strcmp(tunneltype_str[i].str, string))
10492 return tunneltype_str[i].type;
10494 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10497 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10499 if ((ip_addr).family == AF_INET) \
10500 (ip) = (ip_addr).addr.ipv4.s_addr; \
10502 printf("invalid parameter.\n"); \
10507 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10509 if ((ip_addr).family == AF_INET6) \
10510 rte_memcpy(&(ip), \
10511 &((ip_addr).addr.ipv6), \
10512 sizeof(struct in6_addr)); \
10514 printf("invalid parameter.\n"); \
10520 cmd_flow_director_filter_parsed(void *parsed_result,
10521 __attribute__((unused)) struct cmdline *cl,
10522 __attribute__((unused)) void *data)
10524 struct cmd_flow_director_result *res = parsed_result;
10525 struct rte_eth_fdir_filter entry;
10526 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10528 unsigned long vf_id;
10531 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10533 printf("flow director is not supported on port %u.\n",
10537 memset(flexbytes, 0, sizeof(flexbytes));
10538 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10540 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10541 if (strcmp(res->mode_value, "MAC-VLAN")) {
10542 printf("Please set mode to MAC-VLAN.\n");
10545 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10546 if (strcmp(res->mode_value, "Tunnel")) {
10547 printf("Please set mode to Tunnel.\n");
10551 if (!strcmp(res->mode_value, "raw")) {
10552 #ifdef RTE_LIBRTE_I40E_PMD
10553 struct rte_pmd_i40e_flow_type_mapping
10554 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10555 struct rte_pmd_i40e_pkt_template_conf conf;
10556 uint16_t flow_type = str2flowtype(res->flow_type);
10557 uint16_t i, port = res->port_id;
10560 memset(&conf, 0, sizeof(conf));
10562 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10563 printf("Invalid flow type specified.\n");
10566 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10570 if (mapping[flow_type].pctype == 0ULL) {
10571 printf("Invalid flow type specified.\n");
10574 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10575 if (mapping[flow_type].pctype & (1ULL << i)) {
10576 conf.input.pctype = i;
10581 conf.input.packet = open_file(res->filepath,
10582 &conf.input.length);
10583 if (!conf.input.packet)
10585 if (!strcmp(res->drop, "drop"))
10586 conf.action.behavior =
10587 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10589 conf.action.behavior =
10590 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10591 conf.action.report_status =
10592 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10593 conf.action.rx_queue = res->queue_id;
10594 conf.soft_id = res->fd_id_value;
10595 add = strcmp(res->ops, "del") ? 1 : 0;
10596 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10600 printf("flow director config error: (%s)\n",
10602 close_file(conf.input.packet);
10605 } else if (strcmp(res->mode_value, "IP")) {
10606 printf("Please set mode to IP or raw.\n");
10609 entry.input.flow_type = str2flowtype(res->flow_type);
10612 ret = parse_flexbytes(res->flexbytes_value,
10614 RTE_ETH_FDIR_MAX_FLEXLEN);
10616 printf("error: Cannot parse flexbytes input.\n");
10620 switch (entry.input.flow_type) {
10621 case RTE_ETH_FLOW_FRAG_IPV4:
10622 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10623 entry.input.flow.ip4_flow.proto = res->proto_value;
10625 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10626 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10627 IPV4_ADDR_TO_UINT(res->ip_dst,
10628 entry.input.flow.ip4_flow.dst_ip);
10629 IPV4_ADDR_TO_UINT(res->ip_src,
10630 entry.input.flow.ip4_flow.src_ip);
10631 entry.input.flow.ip4_flow.tos = res->tos_value;
10632 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10633 /* need convert to big endian. */
10634 entry.input.flow.udp4_flow.dst_port =
10635 rte_cpu_to_be_16(res->port_dst);
10636 entry.input.flow.udp4_flow.src_port =
10637 rte_cpu_to_be_16(res->port_src);
10639 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10640 IPV4_ADDR_TO_UINT(res->ip_dst,
10641 entry.input.flow.sctp4_flow.ip.dst_ip);
10642 IPV4_ADDR_TO_UINT(res->ip_src,
10643 entry.input.flow.sctp4_flow.ip.src_ip);
10644 entry.input.flow.ip4_flow.tos = res->tos_value;
10645 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10646 /* need convert to big endian. */
10647 entry.input.flow.sctp4_flow.dst_port =
10648 rte_cpu_to_be_16(res->port_dst);
10649 entry.input.flow.sctp4_flow.src_port =
10650 rte_cpu_to_be_16(res->port_src);
10651 entry.input.flow.sctp4_flow.verify_tag =
10652 rte_cpu_to_be_32(res->verify_tag_value);
10654 case RTE_ETH_FLOW_FRAG_IPV6:
10655 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10656 entry.input.flow.ipv6_flow.proto = res->proto_value;
10658 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10659 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10660 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10661 entry.input.flow.ipv6_flow.dst_ip);
10662 IPV6_ADDR_TO_ARRAY(res->ip_src,
10663 entry.input.flow.ipv6_flow.src_ip);
10664 entry.input.flow.ipv6_flow.tc = res->tos_value;
10665 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10666 /* need convert to big endian. */
10667 entry.input.flow.udp6_flow.dst_port =
10668 rte_cpu_to_be_16(res->port_dst);
10669 entry.input.flow.udp6_flow.src_port =
10670 rte_cpu_to_be_16(res->port_src);
10672 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10673 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10674 entry.input.flow.sctp6_flow.ip.dst_ip);
10675 IPV6_ADDR_TO_ARRAY(res->ip_src,
10676 entry.input.flow.sctp6_flow.ip.src_ip);
10677 entry.input.flow.ipv6_flow.tc = res->tos_value;
10678 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10679 /* need convert to big endian. */
10680 entry.input.flow.sctp6_flow.dst_port =
10681 rte_cpu_to_be_16(res->port_dst);
10682 entry.input.flow.sctp6_flow.src_port =
10683 rte_cpu_to_be_16(res->port_src);
10684 entry.input.flow.sctp6_flow.verify_tag =
10685 rte_cpu_to_be_32(res->verify_tag_value);
10687 case RTE_ETH_FLOW_L2_PAYLOAD:
10688 entry.input.flow.l2_flow.ether_type =
10689 rte_cpu_to_be_16(res->ether_type);
10695 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10696 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10698 sizeof(struct ether_addr));
10700 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10701 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10703 sizeof(struct ether_addr));
10704 entry.input.flow.tunnel_flow.tunnel_type =
10705 str2fdir_tunneltype(res->tunnel_type);
10706 entry.input.flow.tunnel_flow.tunnel_id =
10707 rte_cpu_to_be_32(res->tunnel_id_value);
10710 rte_memcpy(entry.input.flow_ext.flexbytes,
10712 RTE_ETH_FDIR_MAX_FLEXLEN);
10714 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10716 entry.action.flex_off = 0; /*use 0 by default */
10717 if (!strcmp(res->drop, "drop"))
10718 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10720 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10722 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10723 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10724 if (!strcmp(res->pf_vf, "pf"))
10725 entry.input.flow_ext.is_vf = 0;
10726 else if (!strncmp(res->pf_vf, "vf", 2)) {
10727 struct rte_eth_dev_info dev_info;
10729 memset(&dev_info, 0, sizeof(dev_info));
10730 rte_eth_dev_info_get(res->port_id, &dev_info);
10732 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10733 if (errno != 0 || *end != '\0' ||
10734 vf_id >= dev_info.max_vfs) {
10735 printf("invalid parameter %s.\n", res->pf_vf);
10738 entry.input.flow_ext.is_vf = 1;
10739 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10741 printf("invalid parameter %s.\n", res->pf_vf);
10746 /* set to report FD ID by default */
10747 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10748 entry.action.rx_queue = res->queue_id;
10749 entry.soft_id = res->fd_id_value;
10750 if (!strcmp(res->ops, "add"))
10751 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10752 RTE_ETH_FILTER_ADD, &entry);
10753 else if (!strcmp(res->ops, "del"))
10754 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10755 RTE_ETH_FILTER_DELETE, &entry);
10757 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10758 RTE_ETH_FILTER_UPDATE, &entry);
10760 printf("flow director programming error: (%s)\n",
10764 cmdline_parse_token_string_t cmd_flow_director_filter =
10765 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10766 flow_director_filter, "flow_director_filter");
10767 cmdline_parse_token_num_t cmd_flow_director_port_id =
10768 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10770 cmdline_parse_token_string_t cmd_flow_director_ops =
10771 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10772 ops, "add#del#update");
10773 cmdline_parse_token_string_t cmd_flow_director_flow =
10774 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10776 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10777 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10779 cmdline_parse_token_string_t cmd_flow_director_ether =
10780 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10782 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10783 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10784 ether_type, UINT16);
10785 cmdline_parse_token_string_t cmd_flow_director_src =
10786 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10788 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10789 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10791 cmdline_parse_token_num_t cmd_flow_director_port_src =
10792 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10794 cmdline_parse_token_string_t cmd_flow_director_dst =
10795 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10797 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10798 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10800 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10801 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10803 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10804 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10805 verify_tag, "verify_tag");
10806 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10807 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10808 verify_tag_value, UINT32);
10809 cmdline_parse_token_string_t cmd_flow_director_tos =
10810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10812 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10813 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10815 cmdline_parse_token_string_t cmd_flow_director_proto =
10816 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10818 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10819 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10820 proto_value, UINT8);
10821 cmdline_parse_token_string_t cmd_flow_director_ttl =
10822 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10824 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10825 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10827 cmdline_parse_token_string_t cmd_flow_director_vlan =
10828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10830 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10831 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10832 vlan_value, UINT16);
10833 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10835 flexbytes, "flexbytes");
10836 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10837 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10838 flexbytes_value, NULL);
10839 cmdline_parse_token_string_t cmd_flow_director_drop =
10840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10842 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10843 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10845 cmdline_parse_token_string_t cmd_flow_director_queue =
10846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10848 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10849 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10851 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10854 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10855 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10856 fd_id_value, UINT32);
10858 cmdline_parse_token_string_t cmd_flow_director_mode =
10859 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10861 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10862 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10864 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10865 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10866 mode_value, "MAC-VLAN");
10867 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10868 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10869 mode_value, "Tunnel");
10870 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10871 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10872 mode_value, "raw");
10873 cmdline_parse_token_string_t cmd_flow_director_mac =
10874 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10876 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10877 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10879 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10880 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10882 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10883 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10884 tunnel_type, "NVGRE#VxLAN");
10885 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10887 tunnel_id, "tunnel-id");
10888 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10889 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10890 tunnel_id_value, UINT32);
10891 cmdline_parse_token_string_t cmd_flow_director_packet =
10892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10894 cmdline_parse_token_string_t cmd_flow_director_filepath =
10895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10898 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10899 .f = cmd_flow_director_filter_parsed,
10901 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10902 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10903 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10904 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10905 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10906 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10907 "fd_id <fd_id_value>: "
10908 "Add or delete an ip flow director entry on NIC",
10910 (void *)&cmd_flow_director_filter,
10911 (void *)&cmd_flow_director_port_id,
10912 (void *)&cmd_flow_director_mode,
10913 (void *)&cmd_flow_director_mode_ip,
10914 (void *)&cmd_flow_director_ops,
10915 (void *)&cmd_flow_director_flow,
10916 (void *)&cmd_flow_director_flow_type,
10917 (void *)&cmd_flow_director_src,
10918 (void *)&cmd_flow_director_ip_src,
10919 (void *)&cmd_flow_director_dst,
10920 (void *)&cmd_flow_director_ip_dst,
10921 (void *)&cmd_flow_director_tos,
10922 (void *)&cmd_flow_director_tos_value,
10923 (void *)&cmd_flow_director_proto,
10924 (void *)&cmd_flow_director_proto_value,
10925 (void *)&cmd_flow_director_ttl,
10926 (void *)&cmd_flow_director_ttl_value,
10927 (void *)&cmd_flow_director_vlan,
10928 (void *)&cmd_flow_director_vlan_value,
10929 (void *)&cmd_flow_director_flexbytes,
10930 (void *)&cmd_flow_director_flexbytes_value,
10931 (void *)&cmd_flow_director_drop,
10932 (void *)&cmd_flow_director_pf_vf,
10933 (void *)&cmd_flow_director_queue,
10934 (void *)&cmd_flow_director_queue_id,
10935 (void *)&cmd_flow_director_fd_id,
10936 (void *)&cmd_flow_director_fd_id_value,
10941 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10942 .f = cmd_flow_director_filter_parsed,
10944 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10945 "director entry on NIC",
10947 (void *)&cmd_flow_director_filter,
10948 (void *)&cmd_flow_director_port_id,
10949 (void *)&cmd_flow_director_mode,
10950 (void *)&cmd_flow_director_mode_ip,
10951 (void *)&cmd_flow_director_ops,
10952 (void *)&cmd_flow_director_flow,
10953 (void *)&cmd_flow_director_flow_type,
10954 (void *)&cmd_flow_director_src,
10955 (void *)&cmd_flow_director_ip_src,
10956 (void *)&cmd_flow_director_port_src,
10957 (void *)&cmd_flow_director_dst,
10958 (void *)&cmd_flow_director_ip_dst,
10959 (void *)&cmd_flow_director_port_dst,
10960 (void *)&cmd_flow_director_tos,
10961 (void *)&cmd_flow_director_tos_value,
10962 (void *)&cmd_flow_director_ttl,
10963 (void *)&cmd_flow_director_ttl_value,
10964 (void *)&cmd_flow_director_vlan,
10965 (void *)&cmd_flow_director_vlan_value,
10966 (void *)&cmd_flow_director_flexbytes,
10967 (void *)&cmd_flow_director_flexbytes_value,
10968 (void *)&cmd_flow_director_drop,
10969 (void *)&cmd_flow_director_pf_vf,
10970 (void *)&cmd_flow_director_queue,
10971 (void *)&cmd_flow_director_queue_id,
10972 (void *)&cmd_flow_director_fd_id,
10973 (void *)&cmd_flow_director_fd_id_value,
10978 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10979 .f = cmd_flow_director_filter_parsed,
10981 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10982 "director entry on NIC",
10984 (void *)&cmd_flow_director_filter,
10985 (void *)&cmd_flow_director_port_id,
10986 (void *)&cmd_flow_director_mode,
10987 (void *)&cmd_flow_director_mode_ip,
10988 (void *)&cmd_flow_director_ops,
10989 (void *)&cmd_flow_director_flow,
10990 (void *)&cmd_flow_director_flow_type,
10991 (void *)&cmd_flow_director_src,
10992 (void *)&cmd_flow_director_ip_src,
10993 (void *)&cmd_flow_director_port_src,
10994 (void *)&cmd_flow_director_dst,
10995 (void *)&cmd_flow_director_ip_dst,
10996 (void *)&cmd_flow_director_port_dst,
10997 (void *)&cmd_flow_director_verify_tag,
10998 (void *)&cmd_flow_director_verify_tag_value,
10999 (void *)&cmd_flow_director_tos,
11000 (void *)&cmd_flow_director_tos_value,
11001 (void *)&cmd_flow_director_ttl,
11002 (void *)&cmd_flow_director_ttl_value,
11003 (void *)&cmd_flow_director_vlan,
11004 (void *)&cmd_flow_director_vlan_value,
11005 (void *)&cmd_flow_director_flexbytes,
11006 (void *)&cmd_flow_director_flexbytes_value,
11007 (void *)&cmd_flow_director_drop,
11008 (void *)&cmd_flow_director_pf_vf,
11009 (void *)&cmd_flow_director_queue,
11010 (void *)&cmd_flow_director_queue_id,
11011 (void *)&cmd_flow_director_fd_id,
11012 (void *)&cmd_flow_director_fd_id_value,
11017 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11018 .f = cmd_flow_director_filter_parsed,
11020 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11021 "director entry on NIC",
11023 (void *)&cmd_flow_director_filter,
11024 (void *)&cmd_flow_director_port_id,
11025 (void *)&cmd_flow_director_mode,
11026 (void *)&cmd_flow_director_mode_ip,
11027 (void *)&cmd_flow_director_ops,
11028 (void *)&cmd_flow_director_flow,
11029 (void *)&cmd_flow_director_flow_type,
11030 (void *)&cmd_flow_director_ether,
11031 (void *)&cmd_flow_director_ether_type,
11032 (void *)&cmd_flow_director_flexbytes,
11033 (void *)&cmd_flow_director_flexbytes_value,
11034 (void *)&cmd_flow_director_drop,
11035 (void *)&cmd_flow_director_pf_vf,
11036 (void *)&cmd_flow_director_queue,
11037 (void *)&cmd_flow_director_queue_id,
11038 (void *)&cmd_flow_director_fd_id,
11039 (void *)&cmd_flow_director_fd_id_value,
11044 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11045 .f = cmd_flow_director_filter_parsed,
11047 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11048 "director entry on NIC",
11050 (void *)&cmd_flow_director_filter,
11051 (void *)&cmd_flow_director_port_id,
11052 (void *)&cmd_flow_director_mode,
11053 (void *)&cmd_flow_director_mode_mac_vlan,
11054 (void *)&cmd_flow_director_ops,
11055 (void *)&cmd_flow_director_mac,
11056 (void *)&cmd_flow_director_mac_addr,
11057 (void *)&cmd_flow_director_vlan,
11058 (void *)&cmd_flow_director_vlan_value,
11059 (void *)&cmd_flow_director_flexbytes,
11060 (void *)&cmd_flow_director_flexbytes_value,
11061 (void *)&cmd_flow_director_drop,
11062 (void *)&cmd_flow_director_queue,
11063 (void *)&cmd_flow_director_queue_id,
11064 (void *)&cmd_flow_director_fd_id,
11065 (void *)&cmd_flow_director_fd_id_value,
11070 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11071 .f = cmd_flow_director_filter_parsed,
11073 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11074 "director entry on NIC",
11076 (void *)&cmd_flow_director_filter,
11077 (void *)&cmd_flow_director_port_id,
11078 (void *)&cmd_flow_director_mode,
11079 (void *)&cmd_flow_director_mode_tunnel,
11080 (void *)&cmd_flow_director_ops,
11081 (void *)&cmd_flow_director_mac,
11082 (void *)&cmd_flow_director_mac_addr,
11083 (void *)&cmd_flow_director_vlan,
11084 (void *)&cmd_flow_director_vlan_value,
11085 (void *)&cmd_flow_director_tunnel,
11086 (void *)&cmd_flow_director_tunnel_type,
11087 (void *)&cmd_flow_director_tunnel_id,
11088 (void *)&cmd_flow_director_tunnel_id_value,
11089 (void *)&cmd_flow_director_flexbytes,
11090 (void *)&cmd_flow_director_flexbytes_value,
11091 (void *)&cmd_flow_director_drop,
11092 (void *)&cmd_flow_director_queue,
11093 (void *)&cmd_flow_director_queue_id,
11094 (void *)&cmd_flow_director_fd_id,
11095 (void *)&cmd_flow_director_fd_id_value,
11100 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11101 .f = cmd_flow_director_filter_parsed,
11103 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11104 "director entry on NIC",
11106 (void *)&cmd_flow_director_filter,
11107 (void *)&cmd_flow_director_port_id,
11108 (void *)&cmd_flow_director_mode,
11109 (void *)&cmd_flow_director_mode_raw,
11110 (void *)&cmd_flow_director_ops,
11111 (void *)&cmd_flow_director_flow,
11112 (void *)&cmd_flow_director_flow_type,
11113 (void *)&cmd_flow_director_drop,
11114 (void *)&cmd_flow_director_queue,
11115 (void *)&cmd_flow_director_queue_id,
11116 (void *)&cmd_flow_director_fd_id,
11117 (void *)&cmd_flow_director_fd_id_value,
11118 (void *)&cmd_flow_director_packet,
11119 (void *)&cmd_flow_director_filepath,
11124 struct cmd_flush_flow_director_result {
11125 cmdline_fixed_string_t flush_flow_director;
11129 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11130 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11131 flush_flow_director, "flush_flow_director");
11132 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11133 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11137 cmd_flush_flow_director_parsed(void *parsed_result,
11138 __attribute__((unused)) struct cmdline *cl,
11139 __attribute__((unused)) void *data)
11141 struct cmd_flow_director_result *res = parsed_result;
11144 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11146 printf("flow director is not supported on port %u.\n",
11151 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11152 RTE_ETH_FILTER_FLUSH, NULL);
11154 printf("flow director table flushing error: (%s)\n",
11158 cmdline_parse_inst_t cmd_flush_flow_director = {
11159 .f = cmd_flush_flow_director_parsed,
11161 .help_str = "flush_flow_director <port_id>: "
11162 "Flush all flow director entries of a device on NIC",
11164 (void *)&cmd_flush_flow_director_flush,
11165 (void *)&cmd_flush_flow_director_port_id,
11170 /* *** deal with flow director mask *** */
11171 struct cmd_flow_director_mask_result {
11172 cmdline_fixed_string_t flow_director_mask;
11174 cmdline_fixed_string_t mode;
11175 cmdline_fixed_string_t mode_value;
11176 cmdline_fixed_string_t vlan;
11177 uint16_t vlan_mask;
11178 cmdline_fixed_string_t src_mask;
11179 cmdline_ipaddr_t ipv4_src;
11180 cmdline_ipaddr_t ipv6_src;
11182 cmdline_fixed_string_t dst_mask;
11183 cmdline_ipaddr_t ipv4_dst;
11184 cmdline_ipaddr_t ipv6_dst;
11186 cmdline_fixed_string_t mac;
11187 uint8_t mac_addr_byte_mask;
11188 cmdline_fixed_string_t tunnel_id;
11189 uint32_t tunnel_id_mask;
11190 cmdline_fixed_string_t tunnel_type;
11191 uint8_t tunnel_type_mask;
11195 cmd_flow_director_mask_parsed(void *parsed_result,
11196 __attribute__((unused)) struct cmdline *cl,
11197 __attribute__((unused)) void *data)
11199 struct cmd_flow_director_mask_result *res = parsed_result;
11200 struct rte_eth_fdir_masks *mask;
11201 struct rte_port *port;
11203 port = &ports[res->port_id];
11204 /** Check if the port is not started **/
11205 if (port->port_status != RTE_PORT_STOPPED) {
11206 printf("Please stop port %d first\n", res->port_id);
11210 mask = &port->dev_conf.fdir_conf.mask;
11212 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11213 if (strcmp(res->mode_value, "MAC-VLAN")) {
11214 printf("Please set mode to MAC-VLAN.\n");
11218 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11219 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11220 if (strcmp(res->mode_value, "Tunnel")) {
11221 printf("Please set mode to Tunnel.\n");
11225 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11226 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11227 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11228 mask->tunnel_type_mask = res->tunnel_type_mask;
11230 if (strcmp(res->mode_value, "IP")) {
11231 printf("Please set mode to IP.\n");
11235 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11236 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11237 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11238 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11239 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11240 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11241 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11244 cmd_reconfig_device_queue(res->port_id, 1, 1);
11247 cmdline_parse_token_string_t cmd_flow_director_mask =
11248 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11249 flow_director_mask, "flow_director_mask");
11250 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11251 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11253 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11254 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11256 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11257 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11258 vlan_mask, UINT16);
11259 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11260 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11261 src_mask, "src_mask");
11262 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11263 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11265 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11266 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11268 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11269 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11271 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11273 dst_mask, "dst_mask");
11274 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11275 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11277 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11278 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11280 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11281 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11284 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11285 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11287 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11288 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11290 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11291 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11292 mode_value, "MAC-VLAN");
11293 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11294 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11295 mode_value, "Tunnel");
11296 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11297 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11299 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11300 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11301 mac_addr_byte_mask, UINT8);
11302 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11303 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11304 tunnel_type, "tunnel-type");
11305 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11306 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11307 tunnel_type_mask, UINT8);
11308 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11310 tunnel_id, "tunnel-id");
11311 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11312 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11313 tunnel_id_mask, UINT32);
11315 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11316 .f = cmd_flow_director_mask_parsed,
11318 .help_str = "flow_director_mask ... : "
11319 "Set IP mode flow director's mask on NIC",
11321 (void *)&cmd_flow_director_mask,
11322 (void *)&cmd_flow_director_mask_port_id,
11323 (void *)&cmd_flow_director_mask_mode,
11324 (void *)&cmd_flow_director_mask_mode_ip,
11325 (void *)&cmd_flow_director_mask_vlan,
11326 (void *)&cmd_flow_director_mask_vlan_value,
11327 (void *)&cmd_flow_director_mask_src,
11328 (void *)&cmd_flow_director_mask_ipv4_src,
11329 (void *)&cmd_flow_director_mask_ipv6_src,
11330 (void *)&cmd_flow_director_mask_port_src,
11331 (void *)&cmd_flow_director_mask_dst,
11332 (void *)&cmd_flow_director_mask_ipv4_dst,
11333 (void *)&cmd_flow_director_mask_ipv6_dst,
11334 (void *)&cmd_flow_director_mask_port_dst,
11339 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11340 .f = cmd_flow_director_mask_parsed,
11342 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11343 "flow director's mask on NIC",
11345 (void *)&cmd_flow_director_mask,
11346 (void *)&cmd_flow_director_mask_port_id,
11347 (void *)&cmd_flow_director_mask_mode,
11348 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11349 (void *)&cmd_flow_director_mask_vlan,
11350 (void *)&cmd_flow_director_mask_vlan_value,
11355 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11356 .f = cmd_flow_director_mask_parsed,
11358 .help_str = "flow_director_mask ... : Set tunnel mode "
11359 "flow director's mask on NIC",
11361 (void *)&cmd_flow_director_mask,
11362 (void *)&cmd_flow_director_mask_port_id,
11363 (void *)&cmd_flow_director_mask_mode,
11364 (void *)&cmd_flow_director_mask_mode_tunnel,
11365 (void *)&cmd_flow_director_mask_vlan,
11366 (void *)&cmd_flow_director_mask_vlan_value,
11367 (void *)&cmd_flow_director_mask_mac,
11368 (void *)&cmd_flow_director_mask_mac_value,
11369 (void *)&cmd_flow_director_mask_tunnel_type,
11370 (void *)&cmd_flow_director_mask_tunnel_type_value,
11371 (void *)&cmd_flow_director_mask_tunnel_id,
11372 (void *)&cmd_flow_director_mask_tunnel_id_value,
11377 /* *** deal with flow director mask on flexible payload *** */
11378 struct cmd_flow_director_flex_mask_result {
11379 cmdline_fixed_string_t flow_director_flexmask;
11381 cmdline_fixed_string_t flow;
11382 cmdline_fixed_string_t flow_type;
11383 cmdline_fixed_string_t mask;
11387 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11388 __attribute__((unused)) struct cmdline *cl,
11389 __attribute__((unused)) void *data)
11391 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11392 struct rte_eth_fdir_info fdir_info;
11393 struct rte_eth_fdir_flex_mask flex_mask;
11394 struct rte_port *port;
11395 uint64_t flow_type_mask;
11399 port = &ports[res->port_id];
11400 /** Check if the port is not started **/
11401 if (port->port_status != RTE_PORT_STOPPED) {
11402 printf("Please stop port %d first\n", res->port_id);
11406 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11407 ret = parse_flexbytes(res->mask,
11409 RTE_ETH_FDIR_MAX_FLEXLEN);
11411 printf("error: Cannot parse mask input.\n");
11415 memset(&fdir_info, 0, sizeof(fdir_info));
11416 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11417 RTE_ETH_FILTER_INFO, &fdir_info);
11419 printf("Cannot get FDir filter info\n");
11423 if (!strcmp(res->flow_type, "none")) {
11424 /* means don't specify the flow type */
11425 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11426 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11427 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11428 0, sizeof(struct rte_eth_fdir_flex_mask));
11429 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11430 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11432 sizeof(struct rte_eth_fdir_flex_mask));
11433 cmd_reconfig_device_queue(res->port_id, 1, 1);
11436 flow_type_mask = fdir_info.flow_types_mask[0];
11437 if (!strcmp(res->flow_type, "all")) {
11438 if (!flow_type_mask) {
11439 printf("No flow type supported\n");
11442 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11443 if (flow_type_mask & (1ULL << i)) {
11444 flex_mask.flow_type = i;
11445 fdir_set_flex_mask(res->port_id, &flex_mask);
11448 cmd_reconfig_device_queue(res->port_id, 1, 1);
11451 flex_mask.flow_type = str2flowtype(res->flow_type);
11452 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11453 printf("Flow type %s not supported on port %d\n",
11454 res->flow_type, res->port_id);
11457 fdir_set_flex_mask(res->port_id, &flex_mask);
11458 cmd_reconfig_device_queue(res->port_id, 1, 1);
11461 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11462 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11463 flow_director_flexmask,
11464 "flow_director_flex_mask");
11465 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11466 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11468 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11469 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11471 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11472 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11473 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11474 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11475 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11476 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11479 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11480 .f = cmd_flow_director_flex_mask_parsed,
11482 .help_str = "flow_director_flex_mask ... : "
11483 "Set flow director's flex mask on NIC",
11485 (void *)&cmd_flow_director_flexmask,
11486 (void *)&cmd_flow_director_flexmask_port_id,
11487 (void *)&cmd_flow_director_flexmask_flow,
11488 (void *)&cmd_flow_director_flexmask_flow_type,
11489 (void *)&cmd_flow_director_flexmask_mask,
11494 /* *** deal with flow director flexible payload configuration *** */
11495 struct cmd_flow_director_flexpayload_result {
11496 cmdline_fixed_string_t flow_director_flexpayload;
11498 cmdline_fixed_string_t payload_layer;
11499 cmdline_fixed_string_t payload_cfg;
11503 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11506 const char *p, *p0 = q_arg;
11508 unsigned long int_fld;
11509 char *str_fld[max_num];
11514 p = strchr(p0, '(');
11518 p0 = strchr(p, ')');
11523 if (size >= sizeof(s))
11526 snprintf(s, sizeof(s), "%.*s", size, p);
11527 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11528 if (ret < 0 || ret > max_num)
11530 for (i = 0; i < ret; i++) {
11532 int_fld = strtoul(str_fld[i], &end, 0);
11533 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11535 offsets[i] = (uint16_t)int_fld;
11541 cmd_flow_director_flxpld_parsed(void *parsed_result,
11542 __attribute__((unused)) struct cmdline *cl,
11543 __attribute__((unused)) void *data)
11545 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11546 struct rte_eth_flex_payload_cfg flex_cfg;
11547 struct rte_port *port;
11550 port = &ports[res->port_id];
11551 /** Check if the port is not started **/
11552 if (port->port_status != RTE_PORT_STOPPED) {
11553 printf("Please stop port %d first\n", res->port_id);
11557 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11559 if (!strcmp(res->payload_layer, "raw"))
11560 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11561 else if (!strcmp(res->payload_layer, "l2"))
11562 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11563 else if (!strcmp(res->payload_layer, "l3"))
11564 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11565 else if (!strcmp(res->payload_layer, "l4"))
11566 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11568 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11569 RTE_ETH_FDIR_MAX_FLEXLEN);
11571 printf("error: Cannot parse flex payload input.\n");
11575 fdir_set_flex_payload(res->port_id, &flex_cfg);
11576 cmd_reconfig_device_queue(res->port_id, 1, 1);
11579 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11580 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11581 flow_director_flexpayload,
11582 "flow_director_flex_payload");
11583 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11584 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11586 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11587 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11588 payload_layer, "raw#l2#l3#l4");
11589 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11590 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11591 payload_cfg, NULL);
11593 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11594 .f = cmd_flow_director_flxpld_parsed,
11596 .help_str = "flow_director_flexpayload ... : "
11597 "Set flow director's flex payload on NIC",
11599 (void *)&cmd_flow_director_flexpayload,
11600 (void *)&cmd_flow_director_flexpayload_port_id,
11601 (void *)&cmd_flow_director_flexpayload_payload_layer,
11602 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11607 /* Generic flow interface command. */
11608 extern cmdline_parse_inst_t cmd_flow;
11610 /* *** Classification Filters Control *** */
11611 /* *** Get symmetric hash enable per port *** */
11612 struct cmd_get_sym_hash_ena_per_port_result {
11613 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11618 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11619 __rte_unused struct cmdline *cl,
11620 __rte_unused void *data)
11622 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11623 struct rte_eth_hash_filter_info info;
11626 if (rte_eth_dev_filter_supported(res->port_id,
11627 RTE_ETH_FILTER_HASH) < 0) {
11628 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11633 memset(&info, 0, sizeof(info));
11634 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11635 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11636 RTE_ETH_FILTER_GET, &info);
11639 printf("Cannot get symmetric hash enable per port "
11640 "on port %u\n", res->port_id);
11644 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11645 "enabled" : "disabled", res->port_id);
11648 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11649 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11650 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11651 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11652 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11655 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11656 .f = cmd_get_sym_hash_per_port_parsed,
11658 .help_str = "get_sym_hash_ena_per_port <port_id>",
11660 (void *)&cmd_get_sym_hash_ena_per_port_all,
11661 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11666 /* *** Set symmetric hash enable per port *** */
11667 struct cmd_set_sym_hash_ena_per_port_result {
11668 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11669 cmdline_fixed_string_t enable;
11674 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11675 __rte_unused struct cmdline *cl,
11676 __rte_unused void *data)
11678 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11679 struct rte_eth_hash_filter_info info;
11682 if (rte_eth_dev_filter_supported(res->port_id,
11683 RTE_ETH_FILTER_HASH) < 0) {
11684 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11689 memset(&info, 0, sizeof(info));
11690 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11691 if (!strcmp(res->enable, "enable"))
11692 info.info.enable = 1;
11693 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11694 RTE_ETH_FILTER_SET, &info);
11696 printf("Cannot set symmetric hash enable per port on "
11697 "port %u\n", res->port_id);
11700 printf("Symmetric hash has been set to %s on port %u\n",
11701 res->enable, res->port_id);
11704 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11705 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11706 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11707 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11708 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11710 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11711 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11712 enable, "enable#disable");
11714 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11715 .f = cmd_set_sym_hash_per_port_parsed,
11717 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11719 (void *)&cmd_set_sym_hash_ena_per_port_all,
11720 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11721 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11726 /* Get global config of hash function */
11727 struct cmd_get_hash_global_config_result {
11728 cmdline_fixed_string_t get_hash_global_config;
11733 flowtype_to_str(uint16_t ftype)
11739 } ftype_table[] = {
11740 {"ipv4", RTE_ETH_FLOW_IPV4},
11741 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11742 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11743 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11744 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11745 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11746 {"ipv6", RTE_ETH_FLOW_IPV6},
11747 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11748 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11749 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11750 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11751 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11752 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11753 {"port", RTE_ETH_FLOW_PORT},
11754 {"vxlan", RTE_ETH_FLOW_VXLAN},
11755 {"geneve", RTE_ETH_FLOW_GENEVE},
11756 {"nvgre", RTE_ETH_FLOW_NVGRE},
11759 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11760 if (ftype_table[i].ftype == ftype)
11761 return ftype_table[i].str;
11768 cmd_get_hash_global_config_parsed(void *parsed_result,
11769 __rte_unused struct cmdline *cl,
11770 __rte_unused void *data)
11772 struct cmd_get_hash_global_config_result *res = parsed_result;
11773 struct rte_eth_hash_filter_info info;
11774 uint32_t idx, offset;
11779 if (rte_eth_dev_filter_supported(res->port_id,
11780 RTE_ETH_FILTER_HASH) < 0) {
11781 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11786 memset(&info, 0, sizeof(info));
11787 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11788 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11789 RTE_ETH_FILTER_GET, &info);
11791 printf("Cannot get hash global configurations by port %d\n",
11796 switch (info.info.global_conf.hash_func) {
11797 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11798 printf("Hash function is Toeplitz\n");
11800 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11801 printf("Hash function is Simple XOR\n");
11804 printf("Unknown hash function\n");
11808 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11809 idx = i / UINT64_BIT;
11810 offset = i % UINT64_BIT;
11811 if (!(info.info.global_conf.valid_bit_mask[idx] &
11814 str = flowtype_to_str(i);
11817 printf("Symmetric hash is %s globally for flow type %s "
11819 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11820 (1ULL << offset)) ? "enabled" : "disabled"), str,
11825 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11826 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11827 get_hash_global_config, "get_hash_global_config");
11828 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11829 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11832 cmdline_parse_inst_t cmd_get_hash_global_config = {
11833 .f = cmd_get_hash_global_config_parsed,
11835 .help_str = "get_hash_global_config <port_id>",
11837 (void *)&cmd_get_hash_global_config_all,
11838 (void *)&cmd_get_hash_global_config_port_id,
11843 /* Set global config of hash function */
11844 struct cmd_set_hash_global_config_result {
11845 cmdline_fixed_string_t set_hash_global_config;
11847 cmdline_fixed_string_t hash_func;
11848 cmdline_fixed_string_t flow_type;
11849 cmdline_fixed_string_t enable;
11853 cmd_set_hash_global_config_parsed(void *parsed_result,
11854 __rte_unused struct cmdline *cl,
11855 __rte_unused void *data)
11857 struct cmd_set_hash_global_config_result *res = parsed_result;
11858 struct rte_eth_hash_filter_info info;
11859 uint32_t ftype, idx, offset;
11862 if (rte_eth_dev_filter_supported(res->port_id,
11863 RTE_ETH_FILTER_HASH) < 0) {
11864 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11868 memset(&info, 0, sizeof(info));
11869 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11870 if (!strcmp(res->hash_func, "toeplitz"))
11871 info.info.global_conf.hash_func =
11872 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11873 else if (!strcmp(res->hash_func, "simple_xor"))
11874 info.info.global_conf.hash_func =
11875 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11876 else if (!strcmp(res->hash_func, "default"))
11877 info.info.global_conf.hash_func =
11878 RTE_ETH_HASH_FUNCTION_DEFAULT;
11880 ftype = str2flowtype(res->flow_type);
11881 idx = ftype / UINT64_BIT;
11882 offset = ftype % UINT64_BIT;
11883 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11884 if (!strcmp(res->enable, "enable"))
11885 info.info.global_conf.sym_hash_enable_mask[idx] |=
11887 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11888 RTE_ETH_FILTER_SET, &info);
11890 printf("Cannot set global hash configurations by port %d\n",
11893 printf("Global hash configurations have been set "
11894 "succcessfully by port %d\n", res->port_id);
11897 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11898 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11899 set_hash_global_config, "set_hash_global_config");
11900 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11901 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11903 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11904 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11905 hash_func, "toeplitz#simple_xor#default");
11906 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11907 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11909 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11910 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11911 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11912 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11913 enable, "enable#disable");
11915 cmdline_parse_inst_t cmd_set_hash_global_config = {
11916 .f = cmd_set_hash_global_config_parsed,
11918 .help_str = "set_hash_global_config <port_id> "
11919 "toeplitz|simple_xor|default "
11920 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11921 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11922 "l2_payload enable|disable",
11924 (void *)&cmd_set_hash_global_config_all,
11925 (void *)&cmd_set_hash_global_config_port_id,
11926 (void *)&cmd_set_hash_global_config_hash_func,
11927 (void *)&cmd_set_hash_global_config_flow_type,
11928 (void *)&cmd_set_hash_global_config_enable,
11933 /* Set hash input set */
11934 struct cmd_set_hash_input_set_result {
11935 cmdline_fixed_string_t set_hash_input_set;
11937 cmdline_fixed_string_t flow_type;
11938 cmdline_fixed_string_t inset_field;
11939 cmdline_fixed_string_t select;
11942 static enum rte_eth_input_set_field
11943 str2inset(char *string)
11947 static const struct {
11949 enum rte_eth_input_set_field inset;
11950 } inset_table[] = {
11951 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11952 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11953 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11954 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11955 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11956 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11957 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11958 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11959 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11960 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11961 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11962 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11963 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11964 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11965 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11966 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11967 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11968 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11969 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11970 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11971 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11972 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11973 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11974 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11975 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11976 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11977 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11978 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11979 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11980 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11981 {"none", RTE_ETH_INPUT_SET_NONE},
11984 for (i = 0; i < RTE_DIM(inset_table); i++) {
11985 if (!strcmp(string, inset_table[i].str))
11986 return inset_table[i].inset;
11989 return RTE_ETH_INPUT_SET_UNKNOWN;
11993 cmd_set_hash_input_set_parsed(void *parsed_result,
11994 __rte_unused struct cmdline *cl,
11995 __rte_unused void *data)
11997 struct cmd_set_hash_input_set_result *res = parsed_result;
11998 struct rte_eth_hash_filter_info info;
12000 memset(&info, 0, sizeof(info));
12001 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12002 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12003 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12004 info.info.input_set_conf.inset_size = 1;
12005 if (!strcmp(res->select, "select"))
12006 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12007 else if (!strcmp(res->select, "add"))
12008 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12009 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12010 RTE_ETH_FILTER_SET, &info);
12013 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12014 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12015 set_hash_input_set, "set_hash_input_set");
12016 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12017 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12019 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12020 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12022 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12023 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12025 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12026 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12027 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12028 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12029 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12031 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12032 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12033 select, "select#add");
12035 cmdline_parse_inst_t cmd_set_hash_input_set = {
12036 .f = cmd_set_hash_input_set_parsed,
12038 .help_str = "set_hash_input_set <port_id> "
12039 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12040 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12041 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12042 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12043 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12044 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12045 "fld-7th|fld-8th|none select|add",
12047 (void *)&cmd_set_hash_input_set_cmd,
12048 (void *)&cmd_set_hash_input_set_port_id,
12049 (void *)&cmd_set_hash_input_set_flow_type,
12050 (void *)&cmd_set_hash_input_set_field,
12051 (void *)&cmd_set_hash_input_set_select,
12056 /* Set flow director input set */
12057 struct cmd_set_fdir_input_set_result {
12058 cmdline_fixed_string_t set_fdir_input_set;
12060 cmdline_fixed_string_t flow_type;
12061 cmdline_fixed_string_t inset_field;
12062 cmdline_fixed_string_t select;
12066 cmd_set_fdir_input_set_parsed(void *parsed_result,
12067 __rte_unused struct cmdline *cl,
12068 __rte_unused void *data)
12070 struct cmd_set_fdir_input_set_result *res = parsed_result;
12071 struct rte_eth_fdir_filter_info info;
12073 memset(&info, 0, sizeof(info));
12074 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12075 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12076 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12077 info.info.input_set_conf.inset_size = 1;
12078 if (!strcmp(res->select, "select"))
12079 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12080 else if (!strcmp(res->select, "add"))
12081 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12082 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12083 RTE_ETH_FILTER_SET, &info);
12086 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12087 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12088 set_fdir_input_set, "set_fdir_input_set");
12089 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12090 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12092 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12093 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12095 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12096 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12097 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12098 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12100 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12101 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12102 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12103 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12104 "sctp-veri-tag#none");
12105 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12106 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12107 select, "select#add");
12109 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12110 .f = cmd_set_fdir_input_set_parsed,
12112 .help_str = "set_fdir_input_set <port_id> "
12113 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12114 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12115 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12116 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12117 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12118 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12119 "sctp-veri-tag|none select|add",
12121 (void *)&cmd_set_fdir_input_set_cmd,
12122 (void *)&cmd_set_fdir_input_set_port_id,
12123 (void *)&cmd_set_fdir_input_set_flow_type,
12124 (void *)&cmd_set_fdir_input_set_field,
12125 (void *)&cmd_set_fdir_input_set_select,
12130 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12131 struct cmd_mcast_addr_result {
12132 cmdline_fixed_string_t mcast_addr_cmd;
12133 cmdline_fixed_string_t what;
12135 struct ether_addr mc_addr;
12138 static void cmd_mcast_addr_parsed(void *parsed_result,
12139 __attribute__((unused)) struct cmdline *cl,
12140 __attribute__((unused)) void *data)
12142 struct cmd_mcast_addr_result *res = parsed_result;
12144 if (!is_multicast_ether_addr(&res->mc_addr)) {
12145 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12146 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12147 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12148 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12151 if (strcmp(res->what, "add") == 0)
12152 mcast_addr_add(res->port_num, &res->mc_addr);
12154 mcast_addr_remove(res->port_num, &res->mc_addr);
12157 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12158 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12159 mcast_addr_cmd, "mcast_addr");
12160 cmdline_parse_token_string_t cmd_mcast_addr_what =
12161 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12163 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12164 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12165 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12166 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12168 cmdline_parse_inst_t cmd_mcast_addr = {
12169 .f = cmd_mcast_addr_parsed,
12171 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12172 "Add/Remove multicast MAC address on port_id",
12174 (void *)&cmd_mcast_addr_cmd,
12175 (void *)&cmd_mcast_addr_what,
12176 (void *)&cmd_mcast_addr_portnum,
12177 (void *)&cmd_mcast_addr_addr,
12182 /* l2 tunnel config
12183 * only support E-tag now.
12186 /* Ether type config */
12187 struct cmd_config_l2_tunnel_eth_type_result {
12188 cmdline_fixed_string_t port;
12189 cmdline_fixed_string_t config;
12190 cmdline_fixed_string_t all;
12192 cmdline_fixed_string_t l2_tunnel;
12193 cmdline_fixed_string_t l2_tunnel_type;
12194 cmdline_fixed_string_t eth_type;
12195 uint16_t eth_type_val;
12198 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12199 TOKEN_STRING_INITIALIZER
12200 (struct cmd_config_l2_tunnel_eth_type_result,
12202 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12203 TOKEN_STRING_INITIALIZER
12204 (struct cmd_config_l2_tunnel_eth_type_result,
12206 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12207 TOKEN_STRING_INITIALIZER
12208 (struct cmd_config_l2_tunnel_eth_type_result,
12210 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12211 TOKEN_NUM_INITIALIZER
12212 (struct cmd_config_l2_tunnel_eth_type_result,
12214 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12215 TOKEN_STRING_INITIALIZER
12216 (struct cmd_config_l2_tunnel_eth_type_result,
12217 l2_tunnel, "l2-tunnel");
12218 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12219 TOKEN_STRING_INITIALIZER
12220 (struct cmd_config_l2_tunnel_eth_type_result,
12221 l2_tunnel_type, "E-tag");
12222 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12223 TOKEN_STRING_INITIALIZER
12224 (struct cmd_config_l2_tunnel_eth_type_result,
12225 eth_type, "ether-type");
12226 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12227 TOKEN_NUM_INITIALIZER
12228 (struct cmd_config_l2_tunnel_eth_type_result,
12229 eth_type_val, UINT16);
12231 static enum rte_eth_tunnel_type
12232 str2fdir_l2_tunnel_type(char *string)
12236 static const struct {
12238 enum rte_eth_tunnel_type type;
12239 } l2_tunnel_type_str[] = {
12240 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12243 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12244 if (!strcmp(l2_tunnel_type_str[i].str, string))
12245 return l2_tunnel_type_str[i].type;
12247 return RTE_TUNNEL_TYPE_NONE;
12250 /* ether type config for all ports */
12252 cmd_config_l2_tunnel_eth_type_all_parsed
12253 (void *parsed_result,
12254 __attribute__((unused)) struct cmdline *cl,
12255 __attribute__((unused)) void *data)
12257 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12258 struct rte_eth_l2_tunnel_conf entry;
12261 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12262 entry.ether_type = res->eth_type_val;
12264 RTE_ETH_FOREACH_DEV(pid) {
12265 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12269 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12270 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12272 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12274 (void *)&cmd_config_l2_tunnel_eth_type_port,
12275 (void *)&cmd_config_l2_tunnel_eth_type_config,
12276 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12277 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12278 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12279 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12280 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12285 /* ether type config for a specific port */
12287 cmd_config_l2_tunnel_eth_type_specific_parsed(
12288 void *parsed_result,
12289 __attribute__((unused)) struct cmdline *cl,
12290 __attribute__((unused)) void *data)
12292 struct cmd_config_l2_tunnel_eth_type_result *res =
12294 struct rte_eth_l2_tunnel_conf entry;
12296 if (port_id_is_invalid(res->id, ENABLED_WARN))
12299 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12300 entry.ether_type = res->eth_type_val;
12302 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12305 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12306 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12308 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12310 (void *)&cmd_config_l2_tunnel_eth_type_port,
12311 (void *)&cmd_config_l2_tunnel_eth_type_config,
12312 (void *)&cmd_config_l2_tunnel_eth_type_id,
12313 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12314 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12315 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12316 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12321 /* Enable/disable l2 tunnel */
12322 struct cmd_config_l2_tunnel_en_dis_result {
12323 cmdline_fixed_string_t port;
12324 cmdline_fixed_string_t config;
12325 cmdline_fixed_string_t all;
12327 cmdline_fixed_string_t l2_tunnel;
12328 cmdline_fixed_string_t l2_tunnel_type;
12329 cmdline_fixed_string_t en_dis;
12332 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12333 TOKEN_STRING_INITIALIZER
12334 (struct cmd_config_l2_tunnel_en_dis_result,
12336 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12337 TOKEN_STRING_INITIALIZER
12338 (struct cmd_config_l2_tunnel_en_dis_result,
12340 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12341 TOKEN_STRING_INITIALIZER
12342 (struct cmd_config_l2_tunnel_en_dis_result,
12344 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12345 TOKEN_NUM_INITIALIZER
12346 (struct cmd_config_l2_tunnel_en_dis_result,
12348 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12349 TOKEN_STRING_INITIALIZER
12350 (struct cmd_config_l2_tunnel_en_dis_result,
12351 l2_tunnel, "l2-tunnel");
12352 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12353 TOKEN_STRING_INITIALIZER
12354 (struct cmd_config_l2_tunnel_en_dis_result,
12355 l2_tunnel_type, "E-tag");
12356 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12357 TOKEN_STRING_INITIALIZER
12358 (struct cmd_config_l2_tunnel_en_dis_result,
12359 en_dis, "enable#disable");
12361 /* enable/disable l2 tunnel for all ports */
12363 cmd_config_l2_tunnel_en_dis_all_parsed(
12364 void *parsed_result,
12365 __attribute__((unused)) struct cmdline *cl,
12366 __attribute__((unused)) void *data)
12368 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12369 struct rte_eth_l2_tunnel_conf entry;
12373 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12375 if (!strcmp("enable", res->en_dis))
12380 RTE_ETH_FOREACH_DEV(pid) {
12381 rte_eth_dev_l2_tunnel_offload_set(pid,
12383 ETH_L2_TUNNEL_ENABLE_MASK,
12388 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12389 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12391 .help_str = "port config all l2-tunnel E-tag enable|disable",
12393 (void *)&cmd_config_l2_tunnel_en_dis_port,
12394 (void *)&cmd_config_l2_tunnel_en_dis_config,
12395 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12396 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12397 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12398 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12403 /* enable/disable l2 tunnel for a port */
12405 cmd_config_l2_tunnel_en_dis_specific_parsed(
12406 void *parsed_result,
12407 __attribute__((unused)) struct cmdline *cl,
12408 __attribute__((unused)) void *data)
12410 struct cmd_config_l2_tunnel_en_dis_result *res =
12412 struct rte_eth_l2_tunnel_conf entry;
12414 if (port_id_is_invalid(res->id, ENABLED_WARN))
12417 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12419 if (!strcmp("enable", res->en_dis))
12420 rte_eth_dev_l2_tunnel_offload_set(res->id,
12422 ETH_L2_TUNNEL_ENABLE_MASK,
12425 rte_eth_dev_l2_tunnel_offload_set(res->id,
12427 ETH_L2_TUNNEL_ENABLE_MASK,
12431 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12432 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12434 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12436 (void *)&cmd_config_l2_tunnel_en_dis_port,
12437 (void *)&cmd_config_l2_tunnel_en_dis_config,
12438 (void *)&cmd_config_l2_tunnel_en_dis_id,
12439 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12440 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12441 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12446 /* E-tag configuration */
12448 /* Common result structure for all E-tag configuration */
12449 struct cmd_config_e_tag_result {
12450 cmdline_fixed_string_t e_tag;
12451 cmdline_fixed_string_t set;
12452 cmdline_fixed_string_t insertion;
12453 cmdline_fixed_string_t stripping;
12454 cmdline_fixed_string_t forwarding;
12455 cmdline_fixed_string_t filter;
12456 cmdline_fixed_string_t add;
12457 cmdline_fixed_string_t del;
12458 cmdline_fixed_string_t on;
12459 cmdline_fixed_string_t off;
12460 cmdline_fixed_string_t on_off;
12461 cmdline_fixed_string_t port_tag_id;
12462 uint32_t port_tag_id_val;
12463 cmdline_fixed_string_t e_tag_id;
12464 uint16_t e_tag_id_val;
12465 cmdline_fixed_string_t dst_pool;
12466 uint8_t dst_pool_val;
12467 cmdline_fixed_string_t port;
12469 cmdline_fixed_string_t vf;
12473 /* Common CLI fields for all E-tag configuration */
12474 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12475 TOKEN_STRING_INITIALIZER
12476 (struct cmd_config_e_tag_result,
12478 cmdline_parse_token_string_t cmd_config_e_tag_set =
12479 TOKEN_STRING_INITIALIZER
12480 (struct cmd_config_e_tag_result,
12482 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12483 TOKEN_STRING_INITIALIZER
12484 (struct cmd_config_e_tag_result,
12485 insertion, "insertion");
12486 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12487 TOKEN_STRING_INITIALIZER
12488 (struct cmd_config_e_tag_result,
12489 stripping, "stripping");
12490 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12491 TOKEN_STRING_INITIALIZER
12492 (struct cmd_config_e_tag_result,
12493 forwarding, "forwarding");
12494 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12495 TOKEN_STRING_INITIALIZER
12496 (struct cmd_config_e_tag_result,
12498 cmdline_parse_token_string_t cmd_config_e_tag_add =
12499 TOKEN_STRING_INITIALIZER
12500 (struct cmd_config_e_tag_result,
12502 cmdline_parse_token_string_t cmd_config_e_tag_del =
12503 TOKEN_STRING_INITIALIZER
12504 (struct cmd_config_e_tag_result,
12506 cmdline_parse_token_string_t cmd_config_e_tag_on =
12507 TOKEN_STRING_INITIALIZER
12508 (struct cmd_config_e_tag_result,
12510 cmdline_parse_token_string_t cmd_config_e_tag_off =
12511 TOKEN_STRING_INITIALIZER
12512 (struct cmd_config_e_tag_result,
12514 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12515 TOKEN_STRING_INITIALIZER
12516 (struct cmd_config_e_tag_result,
12518 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12519 TOKEN_STRING_INITIALIZER
12520 (struct cmd_config_e_tag_result,
12521 port_tag_id, "port-tag-id");
12522 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12523 TOKEN_NUM_INITIALIZER
12524 (struct cmd_config_e_tag_result,
12525 port_tag_id_val, UINT32);
12526 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12527 TOKEN_STRING_INITIALIZER
12528 (struct cmd_config_e_tag_result,
12529 e_tag_id, "e-tag-id");
12530 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12531 TOKEN_NUM_INITIALIZER
12532 (struct cmd_config_e_tag_result,
12533 e_tag_id_val, UINT16);
12534 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12535 TOKEN_STRING_INITIALIZER
12536 (struct cmd_config_e_tag_result,
12537 dst_pool, "dst-pool");
12538 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12539 TOKEN_NUM_INITIALIZER
12540 (struct cmd_config_e_tag_result,
12541 dst_pool_val, UINT8);
12542 cmdline_parse_token_string_t cmd_config_e_tag_port =
12543 TOKEN_STRING_INITIALIZER
12544 (struct cmd_config_e_tag_result,
12546 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12547 TOKEN_NUM_INITIALIZER
12548 (struct cmd_config_e_tag_result,
12550 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12551 TOKEN_STRING_INITIALIZER
12552 (struct cmd_config_e_tag_result,
12554 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12555 TOKEN_NUM_INITIALIZER
12556 (struct cmd_config_e_tag_result,
12559 /* E-tag insertion configuration */
12561 cmd_config_e_tag_insertion_en_parsed(
12562 void *parsed_result,
12563 __attribute__((unused)) struct cmdline *cl,
12564 __attribute__((unused)) void *data)
12566 struct cmd_config_e_tag_result *res =
12568 struct rte_eth_l2_tunnel_conf entry;
12570 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12573 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12574 entry.tunnel_id = res->port_tag_id_val;
12575 entry.vf_id = res->vf_id;
12576 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12578 ETH_L2_TUNNEL_INSERTION_MASK,
12583 cmd_config_e_tag_insertion_dis_parsed(
12584 void *parsed_result,
12585 __attribute__((unused)) struct cmdline *cl,
12586 __attribute__((unused)) void *data)
12588 struct cmd_config_e_tag_result *res =
12590 struct rte_eth_l2_tunnel_conf entry;
12592 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12595 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12596 entry.vf_id = res->vf_id;
12598 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12600 ETH_L2_TUNNEL_INSERTION_MASK,
12604 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12605 .f = cmd_config_e_tag_insertion_en_parsed,
12607 .help_str = "E-tag ... : E-tag insertion enable",
12609 (void *)&cmd_config_e_tag_e_tag,
12610 (void *)&cmd_config_e_tag_set,
12611 (void *)&cmd_config_e_tag_insertion,
12612 (void *)&cmd_config_e_tag_on,
12613 (void *)&cmd_config_e_tag_port_tag_id,
12614 (void *)&cmd_config_e_tag_port_tag_id_val,
12615 (void *)&cmd_config_e_tag_port,
12616 (void *)&cmd_config_e_tag_port_id,
12617 (void *)&cmd_config_e_tag_vf,
12618 (void *)&cmd_config_e_tag_vf_id,
12623 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12624 .f = cmd_config_e_tag_insertion_dis_parsed,
12626 .help_str = "E-tag ... : E-tag insertion disable",
12628 (void *)&cmd_config_e_tag_e_tag,
12629 (void *)&cmd_config_e_tag_set,
12630 (void *)&cmd_config_e_tag_insertion,
12631 (void *)&cmd_config_e_tag_off,
12632 (void *)&cmd_config_e_tag_port,
12633 (void *)&cmd_config_e_tag_port_id,
12634 (void *)&cmd_config_e_tag_vf,
12635 (void *)&cmd_config_e_tag_vf_id,
12640 /* E-tag stripping configuration */
12642 cmd_config_e_tag_stripping_parsed(
12643 void *parsed_result,
12644 __attribute__((unused)) struct cmdline *cl,
12645 __attribute__((unused)) void *data)
12647 struct cmd_config_e_tag_result *res =
12649 struct rte_eth_l2_tunnel_conf entry;
12651 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12654 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12656 if (!strcmp(res->on_off, "on"))
12657 rte_eth_dev_l2_tunnel_offload_set
12660 ETH_L2_TUNNEL_STRIPPING_MASK,
12663 rte_eth_dev_l2_tunnel_offload_set
12666 ETH_L2_TUNNEL_STRIPPING_MASK,
12670 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12671 .f = cmd_config_e_tag_stripping_parsed,
12673 .help_str = "E-tag ... : E-tag stripping enable/disable",
12675 (void *)&cmd_config_e_tag_e_tag,
12676 (void *)&cmd_config_e_tag_set,
12677 (void *)&cmd_config_e_tag_stripping,
12678 (void *)&cmd_config_e_tag_on_off,
12679 (void *)&cmd_config_e_tag_port,
12680 (void *)&cmd_config_e_tag_port_id,
12685 /* E-tag forwarding configuration */
12687 cmd_config_e_tag_forwarding_parsed(
12688 void *parsed_result,
12689 __attribute__((unused)) struct cmdline *cl,
12690 __attribute__((unused)) void *data)
12692 struct cmd_config_e_tag_result *res = parsed_result;
12693 struct rte_eth_l2_tunnel_conf entry;
12695 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12698 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12700 if (!strcmp(res->on_off, "on"))
12701 rte_eth_dev_l2_tunnel_offload_set
12704 ETH_L2_TUNNEL_FORWARDING_MASK,
12707 rte_eth_dev_l2_tunnel_offload_set
12710 ETH_L2_TUNNEL_FORWARDING_MASK,
12714 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12715 .f = cmd_config_e_tag_forwarding_parsed,
12717 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12719 (void *)&cmd_config_e_tag_e_tag,
12720 (void *)&cmd_config_e_tag_set,
12721 (void *)&cmd_config_e_tag_forwarding,
12722 (void *)&cmd_config_e_tag_on_off,
12723 (void *)&cmd_config_e_tag_port,
12724 (void *)&cmd_config_e_tag_port_id,
12729 /* E-tag filter configuration */
12731 cmd_config_e_tag_filter_add_parsed(
12732 void *parsed_result,
12733 __attribute__((unused)) struct cmdline *cl,
12734 __attribute__((unused)) void *data)
12736 struct cmd_config_e_tag_result *res = parsed_result;
12737 struct rte_eth_l2_tunnel_conf entry;
12740 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12743 if (res->e_tag_id_val > 0x3fff) {
12744 printf("e-tag-id must be equal or less than 0x3fff.\n");
12748 ret = rte_eth_dev_filter_supported(res->port_id,
12749 RTE_ETH_FILTER_L2_TUNNEL);
12751 printf("E-tag filter is not supported on port %u.\n",
12756 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12757 entry.tunnel_id = res->e_tag_id_val;
12758 entry.pool = res->dst_pool_val;
12760 ret = rte_eth_dev_filter_ctrl(res->port_id,
12761 RTE_ETH_FILTER_L2_TUNNEL,
12762 RTE_ETH_FILTER_ADD,
12765 printf("E-tag filter programming error: (%s)\n",
12769 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12770 .f = cmd_config_e_tag_filter_add_parsed,
12772 .help_str = "E-tag ... : E-tag filter add",
12774 (void *)&cmd_config_e_tag_e_tag,
12775 (void *)&cmd_config_e_tag_set,
12776 (void *)&cmd_config_e_tag_filter,
12777 (void *)&cmd_config_e_tag_add,
12778 (void *)&cmd_config_e_tag_e_tag_id,
12779 (void *)&cmd_config_e_tag_e_tag_id_val,
12780 (void *)&cmd_config_e_tag_dst_pool,
12781 (void *)&cmd_config_e_tag_dst_pool_val,
12782 (void *)&cmd_config_e_tag_port,
12783 (void *)&cmd_config_e_tag_port_id,
12789 cmd_config_e_tag_filter_del_parsed(
12790 void *parsed_result,
12791 __attribute__((unused)) struct cmdline *cl,
12792 __attribute__((unused)) void *data)
12794 struct cmd_config_e_tag_result *res = parsed_result;
12795 struct rte_eth_l2_tunnel_conf entry;
12798 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12801 if (res->e_tag_id_val > 0x3fff) {
12802 printf("e-tag-id must be less than 0x3fff.\n");
12806 ret = rte_eth_dev_filter_supported(res->port_id,
12807 RTE_ETH_FILTER_L2_TUNNEL);
12809 printf("E-tag filter is not supported on port %u.\n",
12814 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12815 entry.tunnel_id = res->e_tag_id_val;
12817 ret = rte_eth_dev_filter_ctrl(res->port_id,
12818 RTE_ETH_FILTER_L2_TUNNEL,
12819 RTE_ETH_FILTER_DELETE,
12822 printf("E-tag filter programming error: (%s)\n",
12826 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12827 .f = cmd_config_e_tag_filter_del_parsed,
12829 .help_str = "E-tag ... : E-tag filter delete",
12831 (void *)&cmd_config_e_tag_e_tag,
12832 (void *)&cmd_config_e_tag_set,
12833 (void *)&cmd_config_e_tag_filter,
12834 (void *)&cmd_config_e_tag_del,
12835 (void *)&cmd_config_e_tag_e_tag_id,
12836 (void *)&cmd_config_e_tag_e_tag_id_val,
12837 (void *)&cmd_config_e_tag_port,
12838 (void *)&cmd_config_e_tag_port_id,
12843 /* vf vlan anti spoof configuration */
12845 /* Common result structure for vf vlan anti spoof */
12846 struct cmd_vf_vlan_anti_spoof_result {
12847 cmdline_fixed_string_t set;
12848 cmdline_fixed_string_t vf;
12849 cmdline_fixed_string_t vlan;
12850 cmdline_fixed_string_t antispoof;
12853 cmdline_fixed_string_t on_off;
12856 /* Common CLI fields for vf vlan anti spoof enable disable */
12857 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12858 TOKEN_STRING_INITIALIZER
12859 (struct cmd_vf_vlan_anti_spoof_result,
12861 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12862 TOKEN_STRING_INITIALIZER
12863 (struct cmd_vf_vlan_anti_spoof_result,
12865 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12866 TOKEN_STRING_INITIALIZER
12867 (struct cmd_vf_vlan_anti_spoof_result,
12869 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12870 TOKEN_STRING_INITIALIZER
12871 (struct cmd_vf_vlan_anti_spoof_result,
12872 antispoof, "antispoof");
12873 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12874 TOKEN_NUM_INITIALIZER
12875 (struct cmd_vf_vlan_anti_spoof_result,
12877 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12878 TOKEN_NUM_INITIALIZER
12879 (struct cmd_vf_vlan_anti_spoof_result,
12881 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12882 TOKEN_STRING_INITIALIZER
12883 (struct cmd_vf_vlan_anti_spoof_result,
12887 cmd_set_vf_vlan_anti_spoof_parsed(
12888 void *parsed_result,
12889 __attribute__((unused)) struct cmdline *cl,
12890 __attribute__((unused)) void *data)
12892 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12893 int ret = -ENOTSUP;
12895 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12897 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12900 #ifdef RTE_LIBRTE_IXGBE_PMD
12901 if (ret == -ENOTSUP)
12902 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12903 res->vf_id, is_on);
12905 #ifdef RTE_LIBRTE_I40E_PMD
12906 if (ret == -ENOTSUP)
12907 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12908 res->vf_id, is_on);
12910 #ifdef RTE_LIBRTE_BNXT_PMD
12911 if (ret == -ENOTSUP)
12912 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12913 res->vf_id, is_on);
12920 printf("invalid vf_id %d\n", res->vf_id);
12923 printf("invalid port_id %d\n", res->port_id);
12926 printf("function not implemented\n");
12929 printf("programming error: (%s)\n", strerror(-ret));
12933 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12934 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12936 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12938 (void *)&cmd_vf_vlan_anti_spoof_set,
12939 (void *)&cmd_vf_vlan_anti_spoof_vf,
12940 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12941 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12942 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12943 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12944 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12949 /* vf mac anti spoof configuration */
12951 /* Common result structure for vf mac anti spoof */
12952 struct cmd_vf_mac_anti_spoof_result {
12953 cmdline_fixed_string_t set;
12954 cmdline_fixed_string_t vf;
12955 cmdline_fixed_string_t mac;
12956 cmdline_fixed_string_t antispoof;
12959 cmdline_fixed_string_t on_off;
12962 /* Common CLI fields for vf mac anti spoof enable disable */
12963 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12964 TOKEN_STRING_INITIALIZER
12965 (struct cmd_vf_mac_anti_spoof_result,
12967 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12968 TOKEN_STRING_INITIALIZER
12969 (struct cmd_vf_mac_anti_spoof_result,
12971 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12972 TOKEN_STRING_INITIALIZER
12973 (struct cmd_vf_mac_anti_spoof_result,
12975 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12976 TOKEN_STRING_INITIALIZER
12977 (struct cmd_vf_mac_anti_spoof_result,
12978 antispoof, "antispoof");
12979 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12980 TOKEN_NUM_INITIALIZER
12981 (struct cmd_vf_mac_anti_spoof_result,
12983 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12984 TOKEN_NUM_INITIALIZER
12985 (struct cmd_vf_mac_anti_spoof_result,
12987 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12988 TOKEN_STRING_INITIALIZER
12989 (struct cmd_vf_mac_anti_spoof_result,
12993 cmd_set_vf_mac_anti_spoof_parsed(
12994 void *parsed_result,
12995 __attribute__((unused)) struct cmdline *cl,
12996 __attribute__((unused)) void *data)
12998 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12999 int ret = -ENOTSUP;
13001 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13003 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13006 #ifdef RTE_LIBRTE_IXGBE_PMD
13007 if (ret == -ENOTSUP)
13008 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13009 res->vf_id, is_on);
13011 #ifdef RTE_LIBRTE_I40E_PMD
13012 if (ret == -ENOTSUP)
13013 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13014 res->vf_id, is_on);
13016 #ifdef RTE_LIBRTE_BNXT_PMD
13017 if (ret == -ENOTSUP)
13018 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13019 res->vf_id, is_on);
13026 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13029 printf("invalid port_id %d\n", res->port_id);
13032 printf("function not implemented\n");
13035 printf("programming error: (%s)\n", strerror(-ret));
13039 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13040 .f = cmd_set_vf_mac_anti_spoof_parsed,
13042 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13044 (void *)&cmd_vf_mac_anti_spoof_set,
13045 (void *)&cmd_vf_mac_anti_spoof_vf,
13046 (void *)&cmd_vf_mac_anti_spoof_mac,
13047 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13048 (void *)&cmd_vf_mac_anti_spoof_port_id,
13049 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13050 (void *)&cmd_vf_mac_anti_spoof_on_off,
13055 /* vf vlan strip queue configuration */
13057 /* Common result structure for vf mac anti spoof */
13058 struct cmd_vf_vlan_stripq_result {
13059 cmdline_fixed_string_t set;
13060 cmdline_fixed_string_t vf;
13061 cmdline_fixed_string_t vlan;
13062 cmdline_fixed_string_t stripq;
13065 cmdline_fixed_string_t on_off;
13068 /* Common CLI fields for vf vlan strip enable disable */
13069 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13070 TOKEN_STRING_INITIALIZER
13071 (struct cmd_vf_vlan_stripq_result,
13073 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13074 TOKEN_STRING_INITIALIZER
13075 (struct cmd_vf_vlan_stripq_result,
13077 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13078 TOKEN_STRING_INITIALIZER
13079 (struct cmd_vf_vlan_stripq_result,
13081 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13082 TOKEN_STRING_INITIALIZER
13083 (struct cmd_vf_vlan_stripq_result,
13085 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13086 TOKEN_NUM_INITIALIZER
13087 (struct cmd_vf_vlan_stripq_result,
13089 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13090 TOKEN_NUM_INITIALIZER
13091 (struct cmd_vf_vlan_stripq_result,
13093 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13094 TOKEN_STRING_INITIALIZER
13095 (struct cmd_vf_vlan_stripq_result,
13099 cmd_set_vf_vlan_stripq_parsed(
13100 void *parsed_result,
13101 __attribute__((unused)) struct cmdline *cl,
13102 __attribute__((unused)) void *data)
13104 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13105 int ret = -ENOTSUP;
13107 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13109 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13112 #ifdef RTE_LIBRTE_IXGBE_PMD
13113 if (ret == -ENOTSUP)
13114 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13115 res->vf_id, is_on);
13117 #ifdef RTE_LIBRTE_I40E_PMD
13118 if (ret == -ENOTSUP)
13119 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13120 res->vf_id, is_on);
13122 #ifdef RTE_LIBRTE_BNXT_PMD
13123 if (ret == -ENOTSUP)
13124 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13125 res->vf_id, is_on);
13132 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13135 printf("invalid port_id %d\n", res->port_id);
13138 printf("function not implemented\n");
13141 printf("programming error: (%s)\n", strerror(-ret));
13145 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13146 .f = cmd_set_vf_vlan_stripq_parsed,
13148 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13150 (void *)&cmd_vf_vlan_stripq_set,
13151 (void *)&cmd_vf_vlan_stripq_vf,
13152 (void *)&cmd_vf_vlan_stripq_vlan,
13153 (void *)&cmd_vf_vlan_stripq_stripq,
13154 (void *)&cmd_vf_vlan_stripq_port_id,
13155 (void *)&cmd_vf_vlan_stripq_vf_id,
13156 (void *)&cmd_vf_vlan_stripq_on_off,
13161 /* vf vlan insert configuration */
13163 /* Common result structure for vf vlan insert */
13164 struct cmd_vf_vlan_insert_result {
13165 cmdline_fixed_string_t set;
13166 cmdline_fixed_string_t vf;
13167 cmdline_fixed_string_t vlan;
13168 cmdline_fixed_string_t insert;
13174 /* Common CLI fields for vf vlan insert enable disable */
13175 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13176 TOKEN_STRING_INITIALIZER
13177 (struct cmd_vf_vlan_insert_result,
13179 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13180 TOKEN_STRING_INITIALIZER
13181 (struct cmd_vf_vlan_insert_result,
13183 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13184 TOKEN_STRING_INITIALIZER
13185 (struct cmd_vf_vlan_insert_result,
13187 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13188 TOKEN_STRING_INITIALIZER
13189 (struct cmd_vf_vlan_insert_result,
13191 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13192 TOKEN_NUM_INITIALIZER
13193 (struct cmd_vf_vlan_insert_result,
13195 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13196 TOKEN_NUM_INITIALIZER
13197 (struct cmd_vf_vlan_insert_result,
13199 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13200 TOKEN_NUM_INITIALIZER
13201 (struct cmd_vf_vlan_insert_result,
13205 cmd_set_vf_vlan_insert_parsed(
13206 void *parsed_result,
13207 __attribute__((unused)) struct cmdline *cl,
13208 __attribute__((unused)) void *data)
13210 struct cmd_vf_vlan_insert_result *res = parsed_result;
13211 int ret = -ENOTSUP;
13213 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13216 #ifdef RTE_LIBRTE_IXGBE_PMD
13217 if (ret == -ENOTSUP)
13218 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13221 #ifdef RTE_LIBRTE_I40E_PMD
13222 if (ret == -ENOTSUP)
13223 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13226 #ifdef RTE_LIBRTE_BNXT_PMD
13227 if (ret == -ENOTSUP)
13228 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13236 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13239 printf("invalid port_id %d\n", res->port_id);
13242 printf("function not implemented\n");
13245 printf("programming error: (%s)\n", strerror(-ret));
13249 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13250 .f = cmd_set_vf_vlan_insert_parsed,
13252 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13254 (void *)&cmd_vf_vlan_insert_set,
13255 (void *)&cmd_vf_vlan_insert_vf,
13256 (void *)&cmd_vf_vlan_insert_vlan,
13257 (void *)&cmd_vf_vlan_insert_insert,
13258 (void *)&cmd_vf_vlan_insert_port_id,
13259 (void *)&cmd_vf_vlan_insert_vf_id,
13260 (void *)&cmd_vf_vlan_insert_vlan_id,
13265 /* tx loopback configuration */
13267 /* Common result structure for tx loopback */
13268 struct cmd_tx_loopback_result {
13269 cmdline_fixed_string_t set;
13270 cmdline_fixed_string_t tx;
13271 cmdline_fixed_string_t loopback;
13273 cmdline_fixed_string_t on_off;
13276 /* Common CLI fields for tx loopback enable disable */
13277 cmdline_parse_token_string_t cmd_tx_loopback_set =
13278 TOKEN_STRING_INITIALIZER
13279 (struct cmd_tx_loopback_result,
13281 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13282 TOKEN_STRING_INITIALIZER
13283 (struct cmd_tx_loopback_result,
13285 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13286 TOKEN_STRING_INITIALIZER
13287 (struct cmd_tx_loopback_result,
13288 loopback, "loopback");
13289 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13290 TOKEN_NUM_INITIALIZER
13291 (struct cmd_tx_loopback_result,
13293 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13294 TOKEN_STRING_INITIALIZER
13295 (struct cmd_tx_loopback_result,
13299 cmd_set_tx_loopback_parsed(
13300 void *parsed_result,
13301 __attribute__((unused)) struct cmdline *cl,
13302 __attribute__((unused)) void *data)
13304 struct cmd_tx_loopback_result *res = parsed_result;
13305 int ret = -ENOTSUP;
13307 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13309 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13312 #ifdef RTE_LIBRTE_IXGBE_PMD
13313 if (ret == -ENOTSUP)
13314 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13316 #ifdef RTE_LIBRTE_I40E_PMD
13317 if (ret == -ENOTSUP)
13318 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13320 #ifdef RTE_LIBRTE_BNXT_PMD
13321 if (ret == -ENOTSUP)
13322 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13324 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13325 if (ret == -ENOTSUP)
13326 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13333 printf("invalid is_on %d\n", is_on);
13336 printf("invalid port_id %d\n", res->port_id);
13339 printf("function not implemented\n");
13342 printf("programming error: (%s)\n", strerror(-ret));
13346 cmdline_parse_inst_t cmd_set_tx_loopback = {
13347 .f = cmd_set_tx_loopback_parsed,
13349 .help_str = "set tx loopback <port_id> on|off",
13351 (void *)&cmd_tx_loopback_set,
13352 (void *)&cmd_tx_loopback_tx,
13353 (void *)&cmd_tx_loopback_loopback,
13354 (void *)&cmd_tx_loopback_port_id,
13355 (void *)&cmd_tx_loopback_on_off,
13360 /* all queues drop enable configuration */
13362 /* Common result structure for all queues drop enable */
13363 struct cmd_all_queues_drop_en_result {
13364 cmdline_fixed_string_t set;
13365 cmdline_fixed_string_t all;
13366 cmdline_fixed_string_t queues;
13367 cmdline_fixed_string_t drop;
13369 cmdline_fixed_string_t on_off;
13372 /* Common CLI fields for tx loopback enable disable */
13373 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13374 TOKEN_STRING_INITIALIZER
13375 (struct cmd_all_queues_drop_en_result,
13377 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13378 TOKEN_STRING_INITIALIZER
13379 (struct cmd_all_queues_drop_en_result,
13381 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13382 TOKEN_STRING_INITIALIZER
13383 (struct cmd_all_queues_drop_en_result,
13385 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13386 TOKEN_STRING_INITIALIZER
13387 (struct cmd_all_queues_drop_en_result,
13389 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13390 TOKEN_NUM_INITIALIZER
13391 (struct cmd_all_queues_drop_en_result,
13393 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13394 TOKEN_STRING_INITIALIZER
13395 (struct cmd_all_queues_drop_en_result,
13399 cmd_set_all_queues_drop_en_parsed(
13400 void *parsed_result,
13401 __attribute__((unused)) struct cmdline *cl,
13402 __attribute__((unused)) void *data)
13404 struct cmd_all_queues_drop_en_result *res = parsed_result;
13405 int ret = -ENOTSUP;
13406 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13408 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13411 #ifdef RTE_LIBRTE_IXGBE_PMD
13412 if (ret == -ENOTSUP)
13413 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13415 #ifdef RTE_LIBRTE_BNXT_PMD
13416 if (ret == -ENOTSUP)
13417 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13423 printf("invalid is_on %d\n", is_on);
13426 printf("invalid port_id %d\n", res->port_id);
13429 printf("function not implemented\n");
13432 printf("programming error: (%s)\n", strerror(-ret));
13436 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13437 .f = cmd_set_all_queues_drop_en_parsed,
13439 .help_str = "set all queues drop <port_id> on|off",
13441 (void *)&cmd_all_queues_drop_en_set,
13442 (void *)&cmd_all_queues_drop_en_all,
13443 (void *)&cmd_all_queues_drop_en_queues,
13444 (void *)&cmd_all_queues_drop_en_drop,
13445 (void *)&cmd_all_queues_drop_en_port_id,
13446 (void *)&cmd_all_queues_drop_en_on_off,
13451 /* vf split drop enable configuration */
13453 /* Common result structure for vf split drop enable */
13454 struct cmd_vf_split_drop_en_result {
13455 cmdline_fixed_string_t set;
13456 cmdline_fixed_string_t vf;
13457 cmdline_fixed_string_t split;
13458 cmdline_fixed_string_t drop;
13461 cmdline_fixed_string_t on_off;
13464 /* Common CLI fields for vf split drop enable disable */
13465 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13466 TOKEN_STRING_INITIALIZER
13467 (struct cmd_vf_split_drop_en_result,
13469 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13470 TOKEN_STRING_INITIALIZER
13471 (struct cmd_vf_split_drop_en_result,
13473 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13474 TOKEN_STRING_INITIALIZER
13475 (struct cmd_vf_split_drop_en_result,
13477 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13478 TOKEN_STRING_INITIALIZER
13479 (struct cmd_vf_split_drop_en_result,
13481 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13482 TOKEN_NUM_INITIALIZER
13483 (struct cmd_vf_split_drop_en_result,
13485 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13486 TOKEN_NUM_INITIALIZER
13487 (struct cmd_vf_split_drop_en_result,
13489 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13490 TOKEN_STRING_INITIALIZER
13491 (struct cmd_vf_split_drop_en_result,
13495 cmd_set_vf_split_drop_en_parsed(
13496 void *parsed_result,
13497 __attribute__((unused)) struct cmdline *cl,
13498 __attribute__((unused)) void *data)
13500 struct cmd_vf_split_drop_en_result *res = parsed_result;
13501 int ret = -ENOTSUP;
13502 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13507 #ifdef RTE_LIBRTE_IXGBE_PMD
13508 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13515 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13518 printf("invalid port_id %d\n", res->port_id);
13521 printf("not supported on port %d\n", res->port_id);
13524 printf("programming error: (%s)\n", strerror(-ret));
13528 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13529 .f = cmd_set_vf_split_drop_en_parsed,
13531 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13533 (void *)&cmd_vf_split_drop_en_set,
13534 (void *)&cmd_vf_split_drop_en_vf,
13535 (void *)&cmd_vf_split_drop_en_split,
13536 (void *)&cmd_vf_split_drop_en_drop,
13537 (void *)&cmd_vf_split_drop_en_port_id,
13538 (void *)&cmd_vf_split_drop_en_vf_id,
13539 (void *)&cmd_vf_split_drop_en_on_off,
13544 /* vf mac address configuration */
13546 /* Common result structure for vf mac address */
13547 struct cmd_set_vf_mac_addr_result {
13548 cmdline_fixed_string_t set;
13549 cmdline_fixed_string_t vf;
13550 cmdline_fixed_string_t mac;
13551 cmdline_fixed_string_t addr;
13554 struct ether_addr mac_addr;
13558 /* Common CLI fields for vf split drop enable disable */
13559 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13560 TOKEN_STRING_INITIALIZER
13561 (struct cmd_set_vf_mac_addr_result,
13563 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13564 TOKEN_STRING_INITIALIZER
13565 (struct cmd_set_vf_mac_addr_result,
13567 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13568 TOKEN_STRING_INITIALIZER
13569 (struct cmd_set_vf_mac_addr_result,
13571 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13572 TOKEN_STRING_INITIALIZER
13573 (struct cmd_set_vf_mac_addr_result,
13575 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13576 TOKEN_NUM_INITIALIZER
13577 (struct cmd_set_vf_mac_addr_result,
13579 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13580 TOKEN_NUM_INITIALIZER
13581 (struct cmd_set_vf_mac_addr_result,
13583 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13584 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13588 cmd_set_vf_mac_addr_parsed(
13589 void *parsed_result,
13590 __attribute__((unused)) struct cmdline *cl,
13591 __attribute__((unused)) void *data)
13593 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13594 int ret = -ENOTSUP;
13596 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13599 #ifdef RTE_LIBRTE_IXGBE_PMD
13600 if (ret == -ENOTSUP)
13601 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13604 #ifdef RTE_LIBRTE_I40E_PMD
13605 if (ret == -ENOTSUP)
13606 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13609 #ifdef RTE_LIBRTE_BNXT_PMD
13610 if (ret == -ENOTSUP)
13611 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13619 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13622 printf("invalid port_id %d\n", res->port_id);
13625 printf("function not implemented\n");
13628 printf("programming error: (%s)\n", strerror(-ret));
13632 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13633 .f = cmd_set_vf_mac_addr_parsed,
13635 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13637 (void *)&cmd_set_vf_mac_addr_set,
13638 (void *)&cmd_set_vf_mac_addr_vf,
13639 (void *)&cmd_set_vf_mac_addr_mac,
13640 (void *)&cmd_set_vf_mac_addr_addr,
13641 (void *)&cmd_set_vf_mac_addr_port_id,
13642 (void *)&cmd_set_vf_mac_addr_vf_id,
13643 (void *)&cmd_set_vf_mac_addr_mac_addr,
13648 /* MACsec configuration */
13650 /* Common result structure for MACsec offload enable */
13651 struct cmd_macsec_offload_on_result {
13652 cmdline_fixed_string_t set;
13653 cmdline_fixed_string_t macsec;
13654 cmdline_fixed_string_t offload;
13656 cmdline_fixed_string_t on;
13657 cmdline_fixed_string_t encrypt;
13658 cmdline_fixed_string_t en_on_off;
13659 cmdline_fixed_string_t replay_protect;
13660 cmdline_fixed_string_t rp_on_off;
13663 /* Common CLI fields for MACsec offload disable */
13664 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13665 TOKEN_STRING_INITIALIZER
13666 (struct cmd_macsec_offload_on_result,
13668 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13669 TOKEN_STRING_INITIALIZER
13670 (struct cmd_macsec_offload_on_result,
13672 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13673 TOKEN_STRING_INITIALIZER
13674 (struct cmd_macsec_offload_on_result,
13675 offload, "offload");
13676 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13677 TOKEN_NUM_INITIALIZER
13678 (struct cmd_macsec_offload_on_result,
13680 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13681 TOKEN_STRING_INITIALIZER
13682 (struct cmd_macsec_offload_on_result,
13684 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13685 TOKEN_STRING_INITIALIZER
13686 (struct cmd_macsec_offload_on_result,
13687 encrypt, "encrypt");
13688 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13689 TOKEN_STRING_INITIALIZER
13690 (struct cmd_macsec_offload_on_result,
13691 en_on_off, "on#off");
13692 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13693 TOKEN_STRING_INITIALIZER
13694 (struct cmd_macsec_offload_on_result,
13695 replay_protect, "replay-protect");
13696 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13697 TOKEN_STRING_INITIALIZER
13698 (struct cmd_macsec_offload_on_result,
13699 rp_on_off, "on#off");
13702 cmd_set_macsec_offload_on_parsed(
13703 void *parsed_result,
13704 __attribute__((unused)) struct cmdline *cl,
13705 __attribute__((unused)) void *data)
13707 struct cmd_macsec_offload_on_result *res = parsed_result;
13708 int ret = -ENOTSUP;
13709 portid_t port_id = res->port_id;
13710 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13711 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13712 struct rte_eth_dev_info dev_info;
13714 if (port_id_is_invalid(port_id, ENABLED_WARN))
13716 if (!port_is_stopped(port_id)) {
13717 printf("Please stop port %d first\n", port_id);
13721 rte_eth_dev_info_get(port_id, &dev_info);
13722 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13723 #ifdef RTE_LIBRTE_IXGBE_PMD
13724 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13732 ports[port_id].dev_conf.txmode.offloads |=
13733 DEV_TX_OFFLOAD_MACSEC_INSERT;
13734 cmd_reconfig_device_queue(port_id, 1, 1);
13737 printf("invalid port_id %d\n", port_id);
13740 printf("not supported on port %d\n", port_id);
13743 printf("programming error: (%s)\n", strerror(-ret));
13747 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13748 .f = cmd_set_macsec_offload_on_parsed,
13750 .help_str = "set macsec offload <port_id> on "
13751 "encrypt on|off replay-protect on|off",
13753 (void *)&cmd_macsec_offload_on_set,
13754 (void *)&cmd_macsec_offload_on_macsec,
13755 (void *)&cmd_macsec_offload_on_offload,
13756 (void *)&cmd_macsec_offload_on_port_id,
13757 (void *)&cmd_macsec_offload_on_on,
13758 (void *)&cmd_macsec_offload_on_encrypt,
13759 (void *)&cmd_macsec_offload_on_en_on_off,
13760 (void *)&cmd_macsec_offload_on_replay_protect,
13761 (void *)&cmd_macsec_offload_on_rp_on_off,
13766 /* Common result structure for MACsec offload disable */
13767 struct cmd_macsec_offload_off_result {
13768 cmdline_fixed_string_t set;
13769 cmdline_fixed_string_t macsec;
13770 cmdline_fixed_string_t offload;
13772 cmdline_fixed_string_t off;
13775 /* Common CLI fields for MACsec offload disable */
13776 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13777 TOKEN_STRING_INITIALIZER
13778 (struct cmd_macsec_offload_off_result,
13780 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13781 TOKEN_STRING_INITIALIZER
13782 (struct cmd_macsec_offload_off_result,
13784 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13785 TOKEN_STRING_INITIALIZER
13786 (struct cmd_macsec_offload_off_result,
13787 offload, "offload");
13788 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13789 TOKEN_NUM_INITIALIZER
13790 (struct cmd_macsec_offload_off_result,
13792 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13793 TOKEN_STRING_INITIALIZER
13794 (struct cmd_macsec_offload_off_result,
13798 cmd_set_macsec_offload_off_parsed(
13799 void *parsed_result,
13800 __attribute__((unused)) struct cmdline *cl,
13801 __attribute__((unused)) void *data)
13803 struct cmd_macsec_offload_off_result *res = parsed_result;
13804 int ret = -ENOTSUP;
13805 struct rte_eth_dev_info dev_info;
13806 portid_t port_id = res->port_id;
13808 if (port_id_is_invalid(port_id, ENABLED_WARN))
13810 if (!port_is_stopped(port_id)) {
13811 printf("Please stop port %d first\n", port_id);
13815 rte_eth_dev_info_get(port_id, &dev_info);
13816 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13817 #ifdef RTE_LIBRTE_IXGBE_PMD
13818 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13823 ports[port_id].dev_conf.txmode.offloads &=
13824 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13825 cmd_reconfig_device_queue(port_id, 1, 1);
13828 printf("invalid port_id %d\n", port_id);
13831 printf("not supported on port %d\n", port_id);
13834 printf("programming error: (%s)\n", strerror(-ret));
13838 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13839 .f = cmd_set_macsec_offload_off_parsed,
13841 .help_str = "set macsec offload <port_id> off",
13843 (void *)&cmd_macsec_offload_off_set,
13844 (void *)&cmd_macsec_offload_off_macsec,
13845 (void *)&cmd_macsec_offload_off_offload,
13846 (void *)&cmd_macsec_offload_off_port_id,
13847 (void *)&cmd_macsec_offload_off_off,
13852 /* Common result structure for MACsec secure connection configure */
13853 struct cmd_macsec_sc_result {
13854 cmdline_fixed_string_t set;
13855 cmdline_fixed_string_t macsec;
13856 cmdline_fixed_string_t sc;
13857 cmdline_fixed_string_t tx_rx;
13859 struct ether_addr mac;
13863 /* Common CLI fields for MACsec secure connection configure */
13864 cmdline_parse_token_string_t cmd_macsec_sc_set =
13865 TOKEN_STRING_INITIALIZER
13866 (struct cmd_macsec_sc_result,
13868 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13869 TOKEN_STRING_INITIALIZER
13870 (struct cmd_macsec_sc_result,
13872 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13873 TOKEN_STRING_INITIALIZER
13874 (struct cmd_macsec_sc_result,
13876 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13877 TOKEN_STRING_INITIALIZER
13878 (struct cmd_macsec_sc_result,
13880 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13881 TOKEN_NUM_INITIALIZER
13882 (struct cmd_macsec_sc_result,
13884 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13885 TOKEN_ETHERADDR_INITIALIZER
13886 (struct cmd_macsec_sc_result,
13888 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13889 TOKEN_NUM_INITIALIZER
13890 (struct cmd_macsec_sc_result,
13894 cmd_set_macsec_sc_parsed(
13895 void *parsed_result,
13896 __attribute__((unused)) struct cmdline *cl,
13897 __attribute__((unused)) void *data)
13899 struct cmd_macsec_sc_result *res = parsed_result;
13900 int ret = -ENOTSUP;
13901 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13903 #ifdef RTE_LIBRTE_IXGBE_PMD
13905 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13906 res->mac.addr_bytes) :
13907 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13908 res->mac.addr_bytes, res->pi);
13910 RTE_SET_USED(is_tx);
13916 printf("invalid port_id %d\n", res->port_id);
13919 printf("not supported on port %d\n", res->port_id);
13922 printf("programming error: (%s)\n", strerror(-ret));
13926 cmdline_parse_inst_t cmd_set_macsec_sc = {
13927 .f = cmd_set_macsec_sc_parsed,
13929 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13931 (void *)&cmd_macsec_sc_set,
13932 (void *)&cmd_macsec_sc_macsec,
13933 (void *)&cmd_macsec_sc_sc,
13934 (void *)&cmd_macsec_sc_tx_rx,
13935 (void *)&cmd_macsec_sc_port_id,
13936 (void *)&cmd_macsec_sc_mac,
13937 (void *)&cmd_macsec_sc_pi,
13942 /* Common result structure for MACsec secure connection configure */
13943 struct cmd_macsec_sa_result {
13944 cmdline_fixed_string_t set;
13945 cmdline_fixed_string_t macsec;
13946 cmdline_fixed_string_t sa;
13947 cmdline_fixed_string_t tx_rx;
13952 cmdline_fixed_string_t key;
13955 /* Common CLI fields for MACsec secure connection configure */
13956 cmdline_parse_token_string_t cmd_macsec_sa_set =
13957 TOKEN_STRING_INITIALIZER
13958 (struct cmd_macsec_sa_result,
13960 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13961 TOKEN_STRING_INITIALIZER
13962 (struct cmd_macsec_sa_result,
13964 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13965 TOKEN_STRING_INITIALIZER
13966 (struct cmd_macsec_sa_result,
13968 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13969 TOKEN_STRING_INITIALIZER
13970 (struct cmd_macsec_sa_result,
13972 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13973 TOKEN_NUM_INITIALIZER
13974 (struct cmd_macsec_sa_result,
13976 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13977 TOKEN_NUM_INITIALIZER
13978 (struct cmd_macsec_sa_result,
13980 cmdline_parse_token_num_t cmd_macsec_sa_an =
13981 TOKEN_NUM_INITIALIZER
13982 (struct cmd_macsec_sa_result,
13984 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13985 TOKEN_NUM_INITIALIZER
13986 (struct cmd_macsec_sa_result,
13988 cmdline_parse_token_string_t cmd_macsec_sa_key =
13989 TOKEN_STRING_INITIALIZER
13990 (struct cmd_macsec_sa_result,
13994 cmd_set_macsec_sa_parsed(
13995 void *parsed_result,
13996 __attribute__((unused)) struct cmdline *cl,
13997 __attribute__((unused)) void *data)
13999 struct cmd_macsec_sa_result *res = parsed_result;
14000 int ret = -ENOTSUP;
14001 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14002 uint8_t key[16] = { 0 };
14008 key_len = strlen(res->key) / 2;
14012 for (i = 0; i < key_len; i++) {
14013 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14016 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14019 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14022 #ifdef RTE_LIBRTE_IXGBE_PMD
14024 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14025 res->idx, res->an, res->pn, key) :
14026 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14027 res->idx, res->an, res->pn, key);
14029 RTE_SET_USED(is_tx);
14036 printf("invalid idx %d or an %d\n", res->idx, res->an);
14039 printf("invalid port_id %d\n", res->port_id);
14042 printf("not supported on port %d\n", res->port_id);
14045 printf("programming error: (%s)\n", strerror(-ret));
14049 cmdline_parse_inst_t cmd_set_macsec_sa = {
14050 .f = cmd_set_macsec_sa_parsed,
14052 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14054 (void *)&cmd_macsec_sa_set,
14055 (void *)&cmd_macsec_sa_macsec,
14056 (void *)&cmd_macsec_sa_sa,
14057 (void *)&cmd_macsec_sa_tx_rx,
14058 (void *)&cmd_macsec_sa_port_id,
14059 (void *)&cmd_macsec_sa_idx,
14060 (void *)&cmd_macsec_sa_an,
14061 (void *)&cmd_macsec_sa_pn,
14062 (void *)&cmd_macsec_sa_key,
14067 /* VF unicast promiscuous mode configuration */
14069 /* Common result structure for VF unicast promiscuous mode */
14070 struct cmd_vf_promisc_result {
14071 cmdline_fixed_string_t set;
14072 cmdline_fixed_string_t vf;
14073 cmdline_fixed_string_t promisc;
14076 cmdline_fixed_string_t on_off;
14079 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14080 cmdline_parse_token_string_t cmd_vf_promisc_set =
14081 TOKEN_STRING_INITIALIZER
14082 (struct cmd_vf_promisc_result,
14084 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14085 TOKEN_STRING_INITIALIZER
14086 (struct cmd_vf_promisc_result,
14088 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14089 TOKEN_STRING_INITIALIZER
14090 (struct cmd_vf_promisc_result,
14091 promisc, "promisc");
14092 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14093 TOKEN_NUM_INITIALIZER
14094 (struct cmd_vf_promisc_result,
14096 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14097 TOKEN_NUM_INITIALIZER
14098 (struct cmd_vf_promisc_result,
14100 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14101 TOKEN_STRING_INITIALIZER
14102 (struct cmd_vf_promisc_result,
14106 cmd_set_vf_promisc_parsed(
14107 void *parsed_result,
14108 __attribute__((unused)) struct cmdline *cl,
14109 __attribute__((unused)) void *data)
14111 struct cmd_vf_promisc_result *res = parsed_result;
14112 int ret = -ENOTSUP;
14114 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14116 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14119 #ifdef RTE_LIBRTE_I40E_PMD
14120 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14121 res->vf_id, is_on);
14128 printf("invalid vf_id %d\n", res->vf_id);
14131 printf("invalid port_id %d\n", res->port_id);
14134 printf("function not implemented\n");
14137 printf("programming error: (%s)\n", strerror(-ret));
14141 cmdline_parse_inst_t cmd_set_vf_promisc = {
14142 .f = cmd_set_vf_promisc_parsed,
14144 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14145 "Set unicast promiscuous mode for a VF from the PF",
14147 (void *)&cmd_vf_promisc_set,
14148 (void *)&cmd_vf_promisc_vf,
14149 (void *)&cmd_vf_promisc_promisc,
14150 (void *)&cmd_vf_promisc_port_id,
14151 (void *)&cmd_vf_promisc_vf_id,
14152 (void *)&cmd_vf_promisc_on_off,
14157 /* VF multicast promiscuous mode configuration */
14159 /* Common result structure for VF multicast promiscuous mode */
14160 struct cmd_vf_allmulti_result {
14161 cmdline_fixed_string_t set;
14162 cmdline_fixed_string_t vf;
14163 cmdline_fixed_string_t allmulti;
14166 cmdline_fixed_string_t on_off;
14169 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14170 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14171 TOKEN_STRING_INITIALIZER
14172 (struct cmd_vf_allmulti_result,
14174 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14175 TOKEN_STRING_INITIALIZER
14176 (struct cmd_vf_allmulti_result,
14178 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14179 TOKEN_STRING_INITIALIZER
14180 (struct cmd_vf_allmulti_result,
14181 allmulti, "allmulti");
14182 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14183 TOKEN_NUM_INITIALIZER
14184 (struct cmd_vf_allmulti_result,
14186 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14187 TOKEN_NUM_INITIALIZER
14188 (struct cmd_vf_allmulti_result,
14190 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14191 TOKEN_STRING_INITIALIZER
14192 (struct cmd_vf_allmulti_result,
14196 cmd_set_vf_allmulti_parsed(
14197 void *parsed_result,
14198 __attribute__((unused)) struct cmdline *cl,
14199 __attribute__((unused)) void *data)
14201 struct cmd_vf_allmulti_result *res = parsed_result;
14202 int ret = -ENOTSUP;
14204 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14206 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14209 #ifdef RTE_LIBRTE_I40E_PMD
14210 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14211 res->vf_id, is_on);
14218 printf("invalid vf_id %d\n", res->vf_id);
14221 printf("invalid port_id %d\n", res->port_id);
14224 printf("function not implemented\n");
14227 printf("programming error: (%s)\n", strerror(-ret));
14231 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14232 .f = cmd_set_vf_allmulti_parsed,
14234 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14235 "Set multicast promiscuous mode for a VF from the PF",
14237 (void *)&cmd_vf_allmulti_set,
14238 (void *)&cmd_vf_allmulti_vf,
14239 (void *)&cmd_vf_allmulti_allmulti,
14240 (void *)&cmd_vf_allmulti_port_id,
14241 (void *)&cmd_vf_allmulti_vf_id,
14242 (void *)&cmd_vf_allmulti_on_off,
14247 /* vf broadcast mode configuration */
14249 /* Common result structure for vf broadcast */
14250 struct cmd_set_vf_broadcast_result {
14251 cmdline_fixed_string_t set;
14252 cmdline_fixed_string_t vf;
14253 cmdline_fixed_string_t broadcast;
14256 cmdline_fixed_string_t on_off;
14259 /* Common CLI fields for vf broadcast enable disable */
14260 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14261 TOKEN_STRING_INITIALIZER
14262 (struct cmd_set_vf_broadcast_result,
14264 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14265 TOKEN_STRING_INITIALIZER
14266 (struct cmd_set_vf_broadcast_result,
14268 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14269 TOKEN_STRING_INITIALIZER
14270 (struct cmd_set_vf_broadcast_result,
14271 broadcast, "broadcast");
14272 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14273 TOKEN_NUM_INITIALIZER
14274 (struct cmd_set_vf_broadcast_result,
14276 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14277 TOKEN_NUM_INITIALIZER
14278 (struct cmd_set_vf_broadcast_result,
14280 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14281 TOKEN_STRING_INITIALIZER
14282 (struct cmd_set_vf_broadcast_result,
14286 cmd_set_vf_broadcast_parsed(
14287 void *parsed_result,
14288 __attribute__((unused)) struct cmdline *cl,
14289 __attribute__((unused)) void *data)
14291 struct cmd_set_vf_broadcast_result *res = parsed_result;
14292 int ret = -ENOTSUP;
14294 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14296 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14299 #ifdef RTE_LIBRTE_I40E_PMD
14300 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14301 res->vf_id, is_on);
14308 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14311 printf("invalid port_id %d\n", res->port_id);
14314 printf("function not implemented\n");
14317 printf("programming error: (%s)\n", strerror(-ret));
14321 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14322 .f = cmd_set_vf_broadcast_parsed,
14324 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14326 (void *)&cmd_set_vf_broadcast_set,
14327 (void *)&cmd_set_vf_broadcast_vf,
14328 (void *)&cmd_set_vf_broadcast_broadcast,
14329 (void *)&cmd_set_vf_broadcast_port_id,
14330 (void *)&cmd_set_vf_broadcast_vf_id,
14331 (void *)&cmd_set_vf_broadcast_on_off,
14336 /* vf vlan tag configuration */
14338 /* Common result structure for vf vlan tag */
14339 struct cmd_set_vf_vlan_tag_result {
14340 cmdline_fixed_string_t set;
14341 cmdline_fixed_string_t vf;
14342 cmdline_fixed_string_t vlan;
14343 cmdline_fixed_string_t tag;
14346 cmdline_fixed_string_t on_off;
14349 /* Common CLI fields for vf vlan tag enable disable */
14350 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14351 TOKEN_STRING_INITIALIZER
14352 (struct cmd_set_vf_vlan_tag_result,
14354 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14355 TOKEN_STRING_INITIALIZER
14356 (struct cmd_set_vf_vlan_tag_result,
14358 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14359 TOKEN_STRING_INITIALIZER
14360 (struct cmd_set_vf_vlan_tag_result,
14362 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14363 TOKEN_STRING_INITIALIZER
14364 (struct cmd_set_vf_vlan_tag_result,
14366 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14367 TOKEN_NUM_INITIALIZER
14368 (struct cmd_set_vf_vlan_tag_result,
14370 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14371 TOKEN_NUM_INITIALIZER
14372 (struct cmd_set_vf_vlan_tag_result,
14374 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14375 TOKEN_STRING_INITIALIZER
14376 (struct cmd_set_vf_vlan_tag_result,
14380 cmd_set_vf_vlan_tag_parsed(
14381 void *parsed_result,
14382 __attribute__((unused)) struct cmdline *cl,
14383 __attribute__((unused)) void *data)
14385 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14386 int ret = -ENOTSUP;
14388 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14390 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14393 #ifdef RTE_LIBRTE_I40E_PMD
14394 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14395 res->vf_id, is_on);
14402 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14405 printf("invalid port_id %d\n", res->port_id);
14408 printf("function not implemented\n");
14411 printf("programming error: (%s)\n", strerror(-ret));
14415 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14416 .f = cmd_set_vf_vlan_tag_parsed,
14418 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14420 (void *)&cmd_set_vf_vlan_tag_set,
14421 (void *)&cmd_set_vf_vlan_tag_vf,
14422 (void *)&cmd_set_vf_vlan_tag_vlan,
14423 (void *)&cmd_set_vf_vlan_tag_tag,
14424 (void *)&cmd_set_vf_vlan_tag_port_id,
14425 (void *)&cmd_set_vf_vlan_tag_vf_id,
14426 (void *)&cmd_set_vf_vlan_tag_on_off,
14431 /* Common definition of VF and TC TX bandwidth configuration */
14432 struct cmd_vf_tc_bw_result {
14433 cmdline_fixed_string_t set;
14434 cmdline_fixed_string_t vf;
14435 cmdline_fixed_string_t tc;
14436 cmdline_fixed_string_t tx;
14437 cmdline_fixed_string_t min_bw;
14438 cmdline_fixed_string_t max_bw;
14439 cmdline_fixed_string_t strict_link_prio;
14444 cmdline_fixed_string_t bw_list;
14448 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14449 TOKEN_STRING_INITIALIZER
14450 (struct cmd_vf_tc_bw_result,
14452 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14453 TOKEN_STRING_INITIALIZER
14454 (struct cmd_vf_tc_bw_result,
14456 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14457 TOKEN_STRING_INITIALIZER
14458 (struct cmd_vf_tc_bw_result,
14460 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14461 TOKEN_STRING_INITIALIZER
14462 (struct cmd_vf_tc_bw_result,
14464 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14465 TOKEN_STRING_INITIALIZER
14466 (struct cmd_vf_tc_bw_result,
14467 strict_link_prio, "strict-link-priority");
14468 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14469 TOKEN_STRING_INITIALIZER
14470 (struct cmd_vf_tc_bw_result,
14471 min_bw, "min-bandwidth");
14472 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14473 TOKEN_STRING_INITIALIZER
14474 (struct cmd_vf_tc_bw_result,
14475 max_bw, "max-bandwidth");
14476 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14477 TOKEN_NUM_INITIALIZER
14478 (struct cmd_vf_tc_bw_result,
14480 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14481 TOKEN_NUM_INITIALIZER
14482 (struct cmd_vf_tc_bw_result,
14484 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14485 TOKEN_NUM_INITIALIZER
14486 (struct cmd_vf_tc_bw_result,
14488 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14489 TOKEN_NUM_INITIALIZER
14490 (struct cmd_vf_tc_bw_result,
14492 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14493 TOKEN_STRING_INITIALIZER
14494 (struct cmd_vf_tc_bw_result,
14496 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14497 TOKEN_NUM_INITIALIZER
14498 (struct cmd_vf_tc_bw_result,
14501 /* VF max bandwidth setting */
14503 cmd_vf_max_bw_parsed(
14504 void *parsed_result,
14505 __attribute__((unused)) struct cmdline *cl,
14506 __attribute__((unused)) void *data)
14508 struct cmd_vf_tc_bw_result *res = parsed_result;
14509 int ret = -ENOTSUP;
14511 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14514 #ifdef RTE_LIBRTE_I40E_PMD
14515 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14516 res->vf_id, res->bw);
14523 printf("invalid vf_id %d or bandwidth %d\n",
14524 res->vf_id, res->bw);
14527 printf("invalid port_id %d\n", res->port_id);
14530 printf("function not implemented\n");
14533 printf("programming error: (%s)\n", strerror(-ret));
14537 cmdline_parse_inst_t cmd_vf_max_bw = {
14538 .f = cmd_vf_max_bw_parsed,
14540 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14542 (void *)&cmd_vf_tc_bw_set,
14543 (void *)&cmd_vf_tc_bw_vf,
14544 (void *)&cmd_vf_tc_bw_tx,
14545 (void *)&cmd_vf_tc_bw_max_bw,
14546 (void *)&cmd_vf_tc_bw_port_id,
14547 (void *)&cmd_vf_tc_bw_vf_id,
14548 (void *)&cmd_vf_tc_bw_bw,
14554 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14559 const char *p, *p0 = str;
14566 p = strchr(p0, '(');
14568 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14572 p0 = strchr(p, ')');
14574 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14578 if (size >= sizeof(s)) {
14579 printf("The string size exceeds the internal buffer size\n");
14582 snprintf(s, sizeof(s), "%.*s", size, p);
14583 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14585 printf("Failed to get the bandwidth list. ");
14589 for (i = 0; i < ret; i++)
14590 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14595 /* TC min bandwidth setting */
14597 cmd_vf_tc_min_bw_parsed(
14598 void *parsed_result,
14599 __attribute__((unused)) struct cmdline *cl,
14600 __attribute__((unused)) void *data)
14602 struct cmd_vf_tc_bw_result *res = parsed_result;
14605 int ret = -ENOTSUP;
14607 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14610 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14614 #ifdef RTE_LIBRTE_I40E_PMD
14615 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14623 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14626 printf("invalid port_id %d\n", res->port_id);
14629 printf("function not implemented\n");
14632 printf("programming error: (%s)\n", strerror(-ret));
14636 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14637 .f = cmd_vf_tc_min_bw_parsed,
14639 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14640 " <bw1, bw2, ...>",
14642 (void *)&cmd_vf_tc_bw_set,
14643 (void *)&cmd_vf_tc_bw_vf,
14644 (void *)&cmd_vf_tc_bw_tc,
14645 (void *)&cmd_vf_tc_bw_tx,
14646 (void *)&cmd_vf_tc_bw_min_bw,
14647 (void *)&cmd_vf_tc_bw_port_id,
14648 (void *)&cmd_vf_tc_bw_vf_id,
14649 (void *)&cmd_vf_tc_bw_bw_list,
14655 cmd_tc_min_bw_parsed(
14656 void *parsed_result,
14657 __attribute__((unused)) struct cmdline *cl,
14658 __attribute__((unused)) void *data)
14660 struct cmd_vf_tc_bw_result *res = parsed_result;
14661 struct rte_port *port;
14664 int ret = -ENOTSUP;
14666 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14669 port = &ports[res->port_id];
14670 /** Check if the port is not started **/
14671 if (port->port_status != RTE_PORT_STOPPED) {
14672 printf("Please stop port %d first\n", res->port_id);
14676 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14680 #ifdef RTE_LIBRTE_IXGBE_PMD
14681 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14688 printf("invalid bandwidth\n");
14691 printf("invalid port_id %d\n", res->port_id);
14694 printf("function not implemented\n");
14697 printf("programming error: (%s)\n", strerror(-ret));
14701 cmdline_parse_inst_t cmd_tc_min_bw = {
14702 .f = cmd_tc_min_bw_parsed,
14704 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14706 (void *)&cmd_vf_tc_bw_set,
14707 (void *)&cmd_vf_tc_bw_tc,
14708 (void *)&cmd_vf_tc_bw_tx,
14709 (void *)&cmd_vf_tc_bw_min_bw,
14710 (void *)&cmd_vf_tc_bw_port_id,
14711 (void *)&cmd_vf_tc_bw_bw_list,
14716 /* TC max bandwidth setting */
14718 cmd_vf_tc_max_bw_parsed(
14719 void *parsed_result,
14720 __attribute__((unused)) struct cmdline *cl,
14721 __attribute__((unused)) void *data)
14723 struct cmd_vf_tc_bw_result *res = parsed_result;
14724 int ret = -ENOTSUP;
14726 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14729 #ifdef RTE_LIBRTE_I40E_PMD
14730 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14731 res->tc_no, res->bw);
14738 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14739 res->vf_id, res->tc_no, res->bw);
14742 printf("invalid port_id %d\n", res->port_id);
14745 printf("function not implemented\n");
14748 printf("programming error: (%s)\n", strerror(-ret));
14752 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14753 .f = cmd_vf_tc_max_bw_parsed,
14755 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14758 (void *)&cmd_vf_tc_bw_set,
14759 (void *)&cmd_vf_tc_bw_vf,
14760 (void *)&cmd_vf_tc_bw_tc,
14761 (void *)&cmd_vf_tc_bw_tx,
14762 (void *)&cmd_vf_tc_bw_max_bw,
14763 (void *)&cmd_vf_tc_bw_port_id,
14764 (void *)&cmd_vf_tc_bw_vf_id,
14765 (void *)&cmd_vf_tc_bw_tc_no,
14766 (void *)&cmd_vf_tc_bw_bw,
14772 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14774 /* *** Set Port default Traffic Management Hierarchy *** */
14775 struct cmd_set_port_tm_hierarchy_default_result {
14776 cmdline_fixed_string_t set;
14777 cmdline_fixed_string_t port;
14778 cmdline_fixed_string_t tm;
14779 cmdline_fixed_string_t hierarchy;
14780 cmdline_fixed_string_t def;
14784 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14785 TOKEN_STRING_INITIALIZER(
14786 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14787 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14788 TOKEN_STRING_INITIALIZER(
14789 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14790 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14791 TOKEN_STRING_INITIALIZER(
14792 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14793 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14794 TOKEN_STRING_INITIALIZER(
14795 struct cmd_set_port_tm_hierarchy_default_result,
14796 hierarchy, "hierarchy");
14797 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14798 TOKEN_STRING_INITIALIZER(
14799 struct cmd_set_port_tm_hierarchy_default_result,
14801 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14802 TOKEN_NUM_INITIALIZER(
14803 struct cmd_set_port_tm_hierarchy_default_result,
14806 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14807 __attribute__((unused)) struct cmdline *cl,
14808 __attribute__((unused)) void *data)
14810 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14811 struct rte_port *p;
14812 portid_t port_id = res->port_id;
14814 if (port_id_is_invalid(port_id, ENABLED_WARN))
14817 p = &ports[port_id];
14820 if (p->softport.tm_flag == 0) {
14821 printf(" tm not enabled on port %u (error)\n", port_id);
14825 /* Forward mode: tm */
14826 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14827 printf(" tm mode not enabled(error)\n");
14831 /* Set the default tm hierarchy */
14832 p->softport.tm.default_hierarchy_enable = 1;
14835 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14836 .f = cmd_set_port_tm_hierarchy_default_parsed,
14838 .help_str = "set port tm hierarchy default <port_id>",
14840 (void *)&cmd_set_port_tm_hierarchy_default_set,
14841 (void *)&cmd_set_port_tm_hierarchy_default_port,
14842 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14843 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14844 (void *)&cmd_set_port_tm_hierarchy_default_default,
14845 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14851 /* Strict link priority scheduling mode setting */
14853 cmd_strict_link_prio_parsed(
14854 void *parsed_result,
14855 __attribute__((unused)) struct cmdline *cl,
14856 __attribute__((unused)) void *data)
14858 struct cmd_vf_tc_bw_result *res = parsed_result;
14859 int ret = -ENOTSUP;
14861 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14864 #ifdef RTE_LIBRTE_I40E_PMD
14865 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14872 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14875 printf("invalid port_id %d\n", res->port_id);
14878 printf("function not implemented\n");
14881 printf("programming error: (%s)\n", strerror(-ret));
14885 cmdline_parse_inst_t cmd_strict_link_prio = {
14886 .f = cmd_strict_link_prio_parsed,
14888 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14890 (void *)&cmd_vf_tc_bw_set,
14891 (void *)&cmd_vf_tc_bw_tx,
14892 (void *)&cmd_vf_tc_bw_strict_link_prio,
14893 (void *)&cmd_vf_tc_bw_port_id,
14894 (void *)&cmd_vf_tc_bw_tc_map,
14899 /* Load dynamic device personalization*/
14900 struct cmd_ddp_add_result {
14901 cmdline_fixed_string_t ddp;
14902 cmdline_fixed_string_t add;
14907 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14908 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14909 cmdline_parse_token_string_t cmd_ddp_add_add =
14910 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14911 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14912 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14913 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14914 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14917 cmd_ddp_add_parsed(
14918 void *parsed_result,
14919 __attribute__((unused)) struct cmdline *cl,
14920 __attribute__((unused)) void *data)
14922 struct cmd_ddp_add_result *res = parsed_result;
14928 int ret = -ENOTSUP;
14930 if (!all_ports_stopped()) {
14931 printf("Please stop all ports first\n");
14935 filepath = strdup(res->filepath);
14936 if (filepath == NULL) {
14937 printf("Failed to allocate memory\n");
14940 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14942 buff = open_file(file_fld[0], &size);
14944 free((void *)filepath);
14948 #ifdef RTE_LIBRTE_I40E_PMD
14949 if (ret == -ENOTSUP)
14950 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14952 RTE_PMD_I40E_PKG_OP_WR_ADD);
14955 if (ret == -EEXIST)
14956 printf("Profile has already existed.\n");
14958 printf("Failed to load profile.\n");
14959 else if (file_num == 2)
14960 save_file(file_fld[1], buff, size);
14963 free((void *)filepath);
14966 cmdline_parse_inst_t cmd_ddp_add = {
14967 .f = cmd_ddp_add_parsed,
14969 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14971 (void *)&cmd_ddp_add_ddp,
14972 (void *)&cmd_ddp_add_add,
14973 (void *)&cmd_ddp_add_port_id,
14974 (void *)&cmd_ddp_add_filepath,
14979 /* Delete dynamic device personalization*/
14980 struct cmd_ddp_del_result {
14981 cmdline_fixed_string_t ddp;
14982 cmdline_fixed_string_t del;
14987 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14988 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14989 cmdline_parse_token_string_t cmd_ddp_del_del =
14990 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14991 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14992 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14993 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14994 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14997 cmd_ddp_del_parsed(
14998 void *parsed_result,
14999 __attribute__((unused)) struct cmdline *cl,
15000 __attribute__((unused)) void *data)
15002 struct cmd_ddp_del_result *res = parsed_result;
15005 int ret = -ENOTSUP;
15007 if (!all_ports_stopped()) {
15008 printf("Please stop all ports first\n");
15012 buff = open_file(res->filepath, &size);
15016 #ifdef RTE_LIBRTE_I40E_PMD
15017 if (ret == -ENOTSUP)
15018 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15020 RTE_PMD_I40E_PKG_OP_WR_DEL);
15023 if (ret == -EACCES)
15024 printf("Profile does not exist.\n");
15026 printf("Failed to delete profile.\n");
15031 cmdline_parse_inst_t cmd_ddp_del = {
15032 .f = cmd_ddp_del_parsed,
15034 .help_str = "ddp del <port_id> <backup_profile_path>",
15036 (void *)&cmd_ddp_del_ddp,
15037 (void *)&cmd_ddp_del_del,
15038 (void *)&cmd_ddp_del_port_id,
15039 (void *)&cmd_ddp_del_filepath,
15044 /* Get dynamic device personalization profile info */
15045 struct cmd_ddp_info_result {
15046 cmdline_fixed_string_t ddp;
15047 cmdline_fixed_string_t get;
15048 cmdline_fixed_string_t info;
15052 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15053 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15054 cmdline_parse_token_string_t cmd_ddp_info_get =
15055 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15056 cmdline_parse_token_string_t cmd_ddp_info_info =
15057 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15058 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15059 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15062 cmd_ddp_info_parsed(
15063 void *parsed_result,
15064 __attribute__((unused)) struct cmdline *cl,
15065 __attribute__((unused)) void *data)
15067 struct cmd_ddp_info_result *res = parsed_result;
15070 int ret = -ENOTSUP;
15071 #ifdef RTE_LIBRTE_I40E_PMD
15074 uint32_t buff_size = 0;
15075 struct rte_pmd_i40e_profile_info info;
15076 uint32_t dev_num = 0;
15077 struct rte_pmd_i40e_ddp_device_id *devs;
15078 uint32_t proto_num = 0;
15079 struct rte_pmd_i40e_proto_info *proto = NULL;
15080 uint32_t pctype_num = 0;
15081 struct rte_pmd_i40e_ptype_info *pctype;
15082 uint32_t ptype_num = 0;
15083 struct rte_pmd_i40e_ptype_info *ptype;
15088 pkg = open_file(res->filepath, &pkg_size);
15092 #ifdef RTE_LIBRTE_I40E_PMD
15093 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15094 (uint8_t *)&info, sizeof(info),
15095 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15097 printf("Global Track id: 0x%x\n", info.track_id);
15098 printf("Global Version: %d.%d.%d.%d\n",
15099 info.version.major,
15100 info.version.minor,
15101 info.version.update,
15102 info.version.draft);
15103 printf("Global Package name: %s\n\n", info.name);
15106 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15107 (uint8_t *)&info, sizeof(info),
15108 RTE_PMD_I40E_PKG_INFO_HEADER);
15110 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15111 printf("i40e Profile Version: %d.%d.%d.%d\n",
15112 info.version.major,
15113 info.version.minor,
15114 info.version.update,
15115 info.version.draft);
15116 printf("i40e Profile name: %s\n\n", info.name);
15119 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15120 (uint8_t *)&buff_size, sizeof(buff_size),
15121 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15122 if (!ret && buff_size) {
15123 buff = (uint8_t *)malloc(buff_size);
15125 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15127 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15129 printf("Package Notes:\n%s\n\n", buff);
15134 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15135 (uint8_t *)&dev_num, sizeof(dev_num),
15136 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15137 if (!ret && dev_num) {
15138 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15139 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15141 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15142 (uint8_t *)devs, buff_size,
15143 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15145 printf("List of supported devices:\n");
15146 for (i = 0; i < dev_num; i++) {
15147 printf(" %04X:%04X %04X:%04X\n",
15148 devs[i].vendor_dev_id >> 16,
15149 devs[i].vendor_dev_id & 0xFFFF,
15150 devs[i].sub_vendor_dev_id >> 16,
15151 devs[i].sub_vendor_dev_id & 0xFFFF);
15159 /* get information about protocols and packet types */
15160 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15161 (uint8_t *)&proto_num, sizeof(proto_num),
15162 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15163 if (ret || !proto_num)
15164 goto no_print_return;
15166 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15167 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15169 goto no_print_return;
15171 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15173 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15175 printf("List of used protocols:\n");
15176 for (i = 0; i < proto_num; i++)
15177 printf(" %2u: %s\n", proto[i].proto_id,
15181 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15182 (uint8_t *)&pctype_num, sizeof(pctype_num),
15183 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15184 if (ret || !pctype_num)
15185 goto no_print_pctypes;
15187 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15188 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15190 goto no_print_pctypes;
15192 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15194 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15197 goto no_print_pctypes;
15200 printf("List of defined packet classification types:\n");
15201 for (i = 0; i < pctype_num; i++) {
15202 printf(" %2u:", pctype[i].ptype_id);
15203 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15204 proto_id = pctype[i].protocols[j];
15205 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15206 for (n = 0; n < proto_num; n++) {
15207 if (proto[n].proto_id == proto_id) {
15208 printf(" %s", proto[n].name);
15221 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15223 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15224 if (ret || !ptype_num)
15225 goto no_print_return;
15227 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15228 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15230 goto no_print_return;
15232 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15234 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15237 goto no_print_return;
15239 printf("List of defined packet types:\n");
15240 for (i = 0; i < ptype_num; i++) {
15241 printf(" %2u:", ptype[i].ptype_id);
15242 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15243 proto_id = ptype[i].protocols[j];
15244 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15245 for (n = 0; n < proto_num; n++) {
15246 if (proto[n].proto_id == proto_id) {
15247 printf(" %s", proto[n].name);
15263 if (ret == -ENOTSUP)
15264 printf("Function not supported in PMD driver\n");
15268 cmdline_parse_inst_t cmd_ddp_get_info = {
15269 .f = cmd_ddp_info_parsed,
15271 .help_str = "ddp get info <profile_path>",
15273 (void *)&cmd_ddp_info_ddp,
15274 (void *)&cmd_ddp_info_get,
15275 (void *)&cmd_ddp_info_info,
15276 (void *)&cmd_ddp_info_filepath,
15281 /* Get dynamic device personalization profile info list*/
15282 #define PROFILE_INFO_SIZE 48
15283 #define MAX_PROFILE_NUM 16
15285 struct cmd_ddp_get_list_result {
15286 cmdline_fixed_string_t ddp;
15287 cmdline_fixed_string_t get;
15288 cmdline_fixed_string_t list;
15292 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15293 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15294 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15295 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15296 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15297 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15298 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15299 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15302 cmd_ddp_get_list_parsed(
15303 __attribute__((unused)) void *parsed_result,
15304 __attribute__((unused)) struct cmdline *cl,
15305 __attribute__((unused)) void *data)
15307 #ifdef RTE_LIBRTE_I40E_PMD
15308 struct cmd_ddp_get_list_result *res = parsed_result;
15309 struct rte_pmd_i40e_profile_list *p_list;
15310 struct rte_pmd_i40e_profile_info *p_info;
15315 int ret = -ENOTSUP;
15317 #ifdef RTE_LIBRTE_I40E_PMD
15318 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15319 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15321 printf("%s: Failed to malloc buffer\n", __func__);
15323 if (ret == -ENOTSUP)
15324 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15325 (uint8_t *)p_list, size);
15328 p_num = p_list->p_count;
15329 printf("Profile number is: %d\n\n", p_num);
15331 for (i = 0; i < p_num; i++) {
15332 p_info = &p_list->p_info[i];
15333 printf("Profile %d:\n", i);
15334 printf("Track id: 0x%x\n", p_info->track_id);
15335 printf("Version: %d.%d.%d.%d\n",
15336 p_info->version.major,
15337 p_info->version.minor,
15338 p_info->version.update,
15339 p_info->version.draft);
15340 printf("Profile name: %s\n\n", p_info->name);
15348 printf("Failed to get ddp list\n");
15351 cmdline_parse_inst_t cmd_ddp_get_list = {
15352 .f = cmd_ddp_get_list_parsed,
15354 .help_str = "ddp get list <port_id>",
15356 (void *)&cmd_ddp_get_list_ddp,
15357 (void *)&cmd_ddp_get_list_get,
15358 (void *)&cmd_ddp_get_list_list,
15359 (void *)&cmd_ddp_get_list_port_id,
15364 /* Configure input set */
15365 struct cmd_cfg_input_set_result {
15366 cmdline_fixed_string_t port;
15367 cmdline_fixed_string_t cfg;
15369 cmdline_fixed_string_t pctype;
15371 cmdline_fixed_string_t inset_type;
15372 cmdline_fixed_string_t opt;
15373 cmdline_fixed_string_t field;
15378 cmd_cfg_input_set_parsed(
15379 __attribute__((unused)) void *parsed_result,
15380 __attribute__((unused)) struct cmdline *cl,
15381 __attribute__((unused)) void *data)
15383 #ifdef RTE_LIBRTE_I40E_PMD
15384 struct cmd_cfg_input_set_result *res = parsed_result;
15385 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15386 struct rte_pmd_i40e_inset inset;
15388 int ret = -ENOTSUP;
15390 if (!all_ports_stopped()) {
15391 printf("Please stop all ports first\n");
15395 #ifdef RTE_LIBRTE_I40E_PMD
15396 if (!strcmp(res->inset_type, "hash_inset"))
15397 inset_type = INSET_HASH;
15398 else if (!strcmp(res->inset_type, "fdir_inset"))
15399 inset_type = INSET_FDIR;
15400 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15401 inset_type = INSET_FDIR_FLX;
15402 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15403 &inset, inset_type);
15405 printf("Failed to get input set.\n");
15409 if (!strcmp(res->opt, "get")) {
15410 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15413 printf("Field index %d is enabled.\n", res->field_idx);
15415 printf("Field index %d is disabled.\n", res->field_idx);
15417 } else if (!strcmp(res->opt, "set"))
15418 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15420 else if (!strcmp(res->opt, "clear"))
15421 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15424 printf("Failed to configure input set field.\n");
15428 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15429 &inset, inset_type);
15431 printf("Failed to set input set.\n");
15436 if (ret == -ENOTSUP)
15437 printf("Function not supported\n");
15440 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15441 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15443 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15444 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15446 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15447 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15449 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15450 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15452 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15453 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15455 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15456 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15458 "hash_inset#fdir_inset#fdir_flx_inset");
15459 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15460 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15461 opt, "get#set#clear");
15462 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15463 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15465 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15466 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15469 cmdline_parse_inst_t cmd_cfg_input_set = {
15470 .f = cmd_cfg_input_set_parsed,
15472 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15473 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15475 (void *)&cmd_cfg_input_set_port,
15476 (void *)&cmd_cfg_input_set_cfg,
15477 (void *)&cmd_cfg_input_set_port_id,
15478 (void *)&cmd_cfg_input_set_pctype,
15479 (void *)&cmd_cfg_input_set_pctype_id,
15480 (void *)&cmd_cfg_input_set_inset_type,
15481 (void *)&cmd_cfg_input_set_opt,
15482 (void *)&cmd_cfg_input_set_field,
15483 (void *)&cmd_cfg_input_set_field_idx,
15488 /* Clear input set */
15489 struct cmd_clear_input_set_result {
15490 cmdline_fixed_string_t port;
15491 cmdline_fixed_string_t cfg;
15493 cmdline_fixed_string_t pctype;
15495 cmdline_fixed_string_t inset_type;
15496 cmdline_fixed_string_t clear;
15497 cmdline_fixed_string_t all;
15501 cmd_clear_input_set_parsed(
15502 __attribute__((unused)) void *parsed_result,
15503 __attribute__((unused)) struct cmdline *cl,
15504 __attribute__((unused)) void *data)
15506 #ifdef RTE_LIBRTE_I40E_PMD
15507 struct cmd_clear_input_set_result *res = parsed_result;
15508 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15509 struct rte_pmd_i40e_inset inset;
15511 int ret = -ENOTSUP;
15513 if (!all_ports_stopped()) {
15514 printf("Please stop all ports first\n");
15518 #ifdef RTE_LIBRTE_I40E_PMD
15519 if (!strcmp(res->inset_type, "hash_inset"))
15520 inset_type = INSET_HASH;
15521 else if (!strcmp(res->inset_type, "fdir_inset"))
15522 inset_type = INSET_FDIR;
15523 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15524 inset_type = INSET_FDIR_FLX;
15526 memset(&inset, 0, sizeof(inset));
15528 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15529 &inset, inset_type);
15531 printf("Failed to clear input set.\n");
15537 if (ret == -ENOTSUP)
15538 printf("Function not supported\n");
15541 cmdline_parse_token_string_t cmd_clear_input_set_port =
15542 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15544 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15545 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15547 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15548 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15550 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15551 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15553 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15554 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15556 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15557 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15559 "hash_inset#fdir_inset#fdir_flx_inset");
15560 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15561 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15563 cmdline_parse_token_string_t cmd_clear_input_set_all =
15564 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15567 cmdline_parse_inst_t cmd_clear_input_set = {
15568 .f = cmd_clear_input_set_parsed,
15570 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15571 "fdir_inset|fdir_flx_inset clear all",
15573 (void *)&cmd_clear_input_set_port,
15574 (void *)&cmd_clear_input_set_cfg,
15575 (void *)&cmd_clear_input_set_port_id,
15576 (void *)&cmd_clear_input_set_pctype,
15577 (void *)&cmd_clear_input_set_pctype_id,
15578 (void *)&cmd_clear_input_set_inset_type,
15579 (void *)&cmd_clear_input_set_clear,
15580 (void *)&cmd_clear_input_set_all,
15585 /* show vf stats */
15587 /* Common result structure for show vf stats */
15588 struct cmd_show_vf_stats_result {
15589 cmdline_fixed_string_t show;
15590 cmdline_fixed_string_t vf;
15591 cmdline_fixed_string_t stats;
15596 /* Common CLI fields show vf stats*/
15597 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15598 TOKEN_STRING_INITIALIZER
15599 (struct cmd_show_vf_stats_result,
15601 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15602 TOKEN_STRING_INITIALIZER
15603 (struct cmd_show_vf_stats_result,
15605 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15606 TOKEN_STRING_INITIALIZER
15607 (struct cmd_show_vf_stats_result,
15609 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15610 TOKEN_NUM_INITIALIZER
15611 (struct cmd_show_vf_stats_result,
15613 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15614 TOKEN_NUM_INITIALIZER
15615 (struct cmd_show_vf_stats_result,
15619 cmd_show_vf_stats_parsed(
15620 void *parsed_result,
15621 __attribute__((unused)) struct cmdline *cl,
15622 __attribute__((unused)) void *data)
15624 struct cmd_show_vf_stats_result *res = parsed_result;
15625 struct rte_eth_stats stats;
15626 int ret = -ENOTSUP;
15627 static const char *nic_stats_border = "########################";
15629 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15632 memset(&stats, 0, sizeof(stats));
15634 #ifdef RTE_LIBRTE_I40E_PMD
15635 if (ret == -ENOTSUP)
15636 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15640 #ifdef RTE_LIBRTE_BNXT_PMD
15641 if (ret == -ENOTSUP)
15642 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15651 printf("invalid vf_id %d\n", res->vf_id);
15654 printf("invalid port_id %d\n", res->port_id);
15657 printf("function not implemented\n");
15660 printf("programming error: (%s)\n", strerror(-ret));
15663 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15664 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15666 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15668 stats.ipackets, stats.imissed, stats.ibytes);
15669 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15670 printf(" RX-nombuf: %-10"PRIu64"\n",
15672 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15674 stats.opackets, stats.oerrors, stats.obytes);
15676 printf(" %s############################%s\n",
15677 nic_stats_border, nic_stats_border);
15680 cmdline_parse_inst_t cmd_show_vf_stats = {
15681 .f = cmd_show_vf_stats_parsed,
15683 .help_str = "show vf stats <port_id> <vf_id>",
15685 (void *)&cmd_show_vf_stats_show,
15686 (void *)&cmd_show_vf_stats_vf,
15687 (void *)&cmd_show_vf_stats_stats,
15688 (void *)&cmd_show_vf_stats_port_id,
15689 (void *)&cmd_show_vf_stats_vf_id,
15694 /* clear vf stats */
15696 /* Common result structure for clear vf stats */
15697 struct cmd_clear_vf_stats_result {
15698 cmdline_fixed_string_t clear;
15699 cmdline_fixed_string_t vf;
15700 cmdline_fixed_string_t stats;
15705 /* Common CLI fields clear vf stats*/
15706 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15707 TOKEN_STRING_INITIALIZER
15708 (struct cmd_clear_vf_stats_result,
15710 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15711 TOKEN_STRING_INITIALIZER
15712 (struct cmd_clear_vf_stats_result,
15714 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15715 TOKEN_STRING_INITIALIZER
15716 (struct cmd_clear_vf_stats_result,
15718 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15719 TOKEN_NUM_INITIALIZER
15720 (struct cmd_clear_vf_stats_result,
15722 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15723 TOKEN_NUM_INITIALIZER
15724 (struct cmd_clear_vf_stats_result,
15728 cmd_clear_vf_stats_parsed(
15729 void *parsed_result,
15730 __attribute__((unused)) struct cmdline *cl,
15731 __attribute__((unused)) void *data)
15733 struct cmd_clear_vf_stats_result *res = parsed_result;
15734 int ret = -ENOTSUP;
15736 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15739 #ifdef RTE_LIBRTE_I40E_PMD
15740 if (ret == -ENOTSUP)
15741 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15744 #ifdef RTE_LIBRTE_BNXT_PMD
15745 if (ret == -ENOTSUP)
15746 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15754 printf("invalid vf_id %d\n", res->vf_id);
15757 printf("invalid port_id %d\n", res->port_id);
15760 printf("function not implemented\n");
15763 printf("programming error: (%s)\n", strerror(-ret));
15767 cmdline_parse_inst_t cmd_clear_vf_stats = {
15768 .f = cmd_clear_vf_stats_parsed,
15770 .help_str = "clear vf stats <port_id> <vf_id>",
15772 (void *)&cmd_clear_vf_stats_clear,
15773 (void *)&cmd_clear_vf_stats_vf,
15774 (void *)&cmd_clear_vf_stats_stats,
15775 (void *)&cmd_clear_vf_stats_port_id,
15776 (void *)&cmd_clear_vf_stats_vf_id,
15781 /* port config pctype mapping reset */
15783 /* Common result structure for port config pctype mapping reset */
15784 struct cmd_pctype_mapping_reset_result {
15785 cmdline_fixed_string_t port;
15786 cmdline_fixed_string_t config;
15788 cmdline_fixed_string_t pctype;
15789 cmdline_fixed_string_t mapping;
15790 cmdline_fixed_string_t reset;
15793 /* Common CLI fields for port config pctype mapping reset*/
15794 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15795 TOKEN_STRING_INITIALIZER
15796 (struct cmd_pctype_mapping_reset_result,
15798 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15799 TOKEN_STRING_INITIALIZER
15800 (struct cmd_pctype_mapping_reset_result,
15802 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15803 TOKEN_NUM_INITIALIZER
15804 (struct cmd_pctype_mapping_reset_result,
15806 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15807 TOKEN_STRING_INITIALIZER
15808 (struct cmd_pctype_mapping_reset_result,
15810 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15811 TOKEN_STRING_INITIALIZER
15812 (struct cmd_pctype_mapping_reset_result,
15813 mapping, "mapping");
15814 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15815 TOKEN_STRING_INITIALIZER
15816 (struct cmd_pctype_mapping_reset_result,
15820 cmd_pctype_mapping_reset_parsed(
15821 void *parsed_result,
15822 __attribute__((unused)) struct cmdline *cl,
15823 __attribute__((unused)) void *data)
15825 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15826 int ret = -ENOTSUP;
15828 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15831 #ifdef RTE_LIBRTE_I40E_PMD
15832 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15839 printf("invalid port_id %d\n", res->port_id);
15842 printf("function not implemented\n");
15845 printf("programming error: (%s)\n", strerror(-ret));
15849 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15850 .f = cmd_pctype_mapping_reset_parsed,
15852 .help_str = "port config <port_id> pctype mapping reset",
15854 (void *)&cmd_pctype_mapping_reset_port,
15855 (void *)&cmd_pctype_mapping_reset_config,
15856 (void *)&cmd_pctype_mapping_reset_port_id,
15857 (void *)&cmd_pctype_mapping_reset_pctype,
15858 (void *)&cmd_pctype_mapping_reset_mapping,
15859 (void *)&cmd_pctype_mapping_reset_reset,
15864 /* show port pctype mapping */
15866 /* Common result structure for show port pctype mapping */
15867 struct cmd_pctype_mapping_get_result {
15868 cmdline_fixed_string_t show;
15869 cmdline_fixed_string_t port;
15871 cmdline_fixed_string_t pctype;
15872 cmdline_fixed_string_t mapping;
15875 /* Common CLI fields for pctype mapping get */
15876 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15877 TOKEN_STRING_INITIALIZER
15878 (struct cmd_pctype_mapping_get_result,
15880 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15881 TOKEN_STRING_INITIALIZER
15882 (struct cmd_pctype_mapping_get_result,
15884 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15885 TOKEN_NUM_INITIALIZER
15886 (struct cmd_pctype_mapping_get_result,
15888 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15889 TOKEN_STRING_INITIALIZER
15890 (struct cmd_pctype_mapping_get_result,
15892 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15893 TOKEN_STRING_INITIALIZER
15894 (struct cmd_pctype_mapping_get_result,
15895 mapping, "mapping");
15898 cmd_pctype_mapping_get_parsed(
15899 void *parsed_result,
15900 __attribute__((unused)) struct cmdline *cl,
15901 __attribute__((unused)) void *data)
15903 struct cmd_pctype_mapping_get_result *res = parsed_result;
15904 int ret = -ENOTSUP;
15905 #ifdef RTE_LIBRTE_I40E_PMD
15906 struct rte_pmd_i40e_flow_type_mapping
15907 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15908 int i, j, first_pctype;
15911 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15914 #ifdef RTE_LIBRTE_I40E_PMD
15915 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15922 printf("invalid port_id %d\n", res->port_id);
15925 printf("function not implemented\n");
15928 printf("programming error: (%s)\n", strerror(-ret));
15932 #ifdef RTE_LIBRTE_I40E_PMD
15933 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15934 if (mapping[i].pctype != 0ULL) {
15937 printf("pctype: ");
15938 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15939 if (mapping[i].pctype & (1ULL << j)) {
15940 printf(first_pctype ?
15941 "%02d" : ",%02d", j);
15945 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15951 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15952 .f = cmd_pctype_mapping_get_parsed,
15954 .help_str = "show port <port_id> pctype mapping",
15956 (void *)&cmd_pctype_mapping_get_show,
15957 (void *)&cmd_pctype_mapping_get_port,
15958 (void *)&cmd_pctype_mapping_get_port_id,
15959 (void *)&cmd_pctype_mapping_get_pctype,
15960 (void *)&cmd_pctype_mapping_get_mapping,
15965 /* port config pctype mapping update */
15967 /* Common result structure for port config pctype mapping update */
15968 struct cmd_pctype_mapping_update_result {
15969 cmdline_fixed_string_t port;
15970 cmdline_fixed_string_t config;
15972 cmdline_fixed_string_t pctype;
15973 cmdline_fixed_string_t mapping;
15974 cmdline_fixed_string_t update;
15975 cmdline_fixed_string_t pctype_list;
15976 uint16_t flow_type;
15979 /* Common CLI fields for pctype mapping update*/
15980 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15981 TOKEN_STRING_INITIALIZER
15982 (struct cmd_pctype_mapping_update_result,
15984 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15985 TOKEN_STRING_INITIALIZER
15986 (struct cmd_pctype_mapping_update_result,
15988 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15989 TOKEN_NUM_INITIALIZER
15990 (struct cmd_pctype_mapping_update_result,
15992 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15993 TOKEN_STRING_INITIALIZER
15994 (struct cmd_pctype_mapping_update_result,
15996 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15997 TOKEN_STRING_INITIALIZER
15998 (struct cmd_pctype_mapping_update_result,
15999 mapping, "mapping");
16000 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16001 TOKEN_STRING_INITIALIZER
16002 (struct cmd_pctype_mapping_update_result,
16004 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16005 TOKEN_STRING_INITIALIZER
16006 (struct cmd_pctype_mapping_update_result,
16007 pctype_list, NULL);
16008 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16009 TOKEN_NUM_INITIALIZER
16010 (struct cmd_pctype_mapping_update_result,
16011 flow_type, UINT16);
16014 cmd_pctype_mapping_update_parsed(
16015 void *parsed_result,
16016 __attribute__((unused)) struct cmdline *cl,
16017 __attribute__((unused)) void *data)
16019 struct cmd_pctype_mapping_update_result *res = parsed_result;
16020 int ret = -ENOTSUP;
16021 #ifdef RTE_LIBRTE_I40E_PMD
16022 struct rte_pmd_i40e_flow_type_mapping mapping;
16024 unsigned int nb_item;
16025 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16028 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16031 #ifdef RTE_LIBRTE_I40E_PMD
16032 nb_item = parse_item_list(res->pctype_list, "pctypes",
16033 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16034 mapping.flow_type = res->flow_type;
16035 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16036 mapping.pctype |= (1ULL << pctype_list[i]);
16037 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16047 printf("invalid pctype or flow type\n");
16050 printf("invalid port_id %d\n", res->port_id);
16053 printf("function not implemented\n");
16056 printf("programming error: (%s)\n", strerror(-ret));
16060 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16061 .f = cmd_pctype_mapping_update_parsed,
16063 .help_str = "port config <port_id> pctype mapping update"
16064 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16066 (void *)&cmd_pctype_mapping_update_port,
16067 (void *)&cmd_pctype_mapping_update_config,
16068 (void *)&cmd_pctype_mapping_update_port_id,
16069 (void *)&cmd_pctype_mapping_update_pctype,
16070 (void *)&cmd_pctype_mapping_update_mapping,
16071 (void *)&cmd_pctype_mapping_update_update,
16072 (void *)&cmd_pctype_mapping_update_pc_type,
16073 (void *)&cmd_pctype_mapping_update_flow_type,
16078 /* ptype mapping get */
16080 /* Common result structure for ptype mapping get */
16081 struct cmd_ptype_mapping_get_result {
16082 cmdline_fixed_string_t ptype;
16083 cmdline_fixed_string_t mapping;
16084 cmdline_fixed_string_t get;
16086 uint8_t valid_only;
16089 /* Common CLI fields for ptype mapping get */
16090 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16091 TOKEN_STRING_INITIALIZER
16092 (struct cmd_ptype_mapping_get_result,
16094 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16095 TOKEN_STRING_INITIALIZER
16096 (struct cmd_ptype_mapping_get_result,
16097 mapping, "mapping");
16098 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16099 TOKEN_STRING_INITIALIZER
16100 (struct cmd_ptype_mapping_get_result,
16102 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16103 TOKEN_NUM_INITIALIZER
16104 (struct cmd_ptype_mapping_get_result,
16106 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16107 TOKEN_NUM_INITIALIZER
16108 (struct cmd_ptype_mapping_get_result,
16109 valid_only, UINT8);
16112 cmd_ptype_mapping_get_parsed(
16113 void *parsed_result,
16114 __attribute__((unused)) struct cmdline *cl,
16115 __attribute__((unused)) void *data)
16117 struct cmd_ptype_mapping_get_result *res = parsed_result;
16118 int ret = -ENOTSUP;
16119 #ifdef RTE_LIBRTE_I40E_PMD
16120 int max_ptype_num = 256;
16121 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16126 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16129 #ifdef RTE_LIBRTE_I40E_PMD
16130 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16141 printf("invalid port_id %d\n", res->port_id);
16144 printf("function not implemented\n");
16147 printf("programming error: (%s)\n", strerror(-ret));
16150 #ifdef RTE_LIBRTE_I40E_PMD
16152 for (i = 0; i < count; i++)
16153 printf("%3d\t0x%08x\n",
16154 mapping[i].hw_ptype, mapping[i].sw_ptype);
16159 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16160 .f = cmd_ptype_mapping_get_parsed,
16162 .help_str = "ptype mapping get <port_id> <valid_only>",
16164 (void *)&cmd_ptype_mapping_get_ptype,
16165 (void *)&cmd_ptype_mapping_get_mapping,
16166 (void *)&cmd_ptype_mapping_get_get,
16167 (void *)&cmd_ptype_mapping_get_port_id,
16168 (void *)&cmd_ptype_mapping_get_valid_only,
16173 /* ptype mapping replace */
16175 /* Common result structure for ptype mapping replace */
16176 struct cmd_ptype_mapping_replace_result {
16177 cmdline_fixed_string_t ptype;
16178 cmdline_fixed_string_t mapping;
16179 cmdline_fixed_string_t replace;
16186 /* Common CLI fields for ptype mapping replace */
16187 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16188 TOKEN_STRING_INITIALIZER
16189 (struct cmd_ptype_mapping_replace_result,
16191 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16192 TOKEN_STRING_INITIALIZER
16193 (struct cmd_ptype_mapping_replace_result,
16194 mapping, "mapping");
16195 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16196 TOKEN_STRING_INITIALIZER
16197 (struct cmd_ptype_mapping_replace_result,
16198 replace, "replace");
16199 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16200 TOKEN_NUM_INITIALIZER
16201 (struct cmd_ptype_mapping_replace_result,
16203 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16204 TOKEN_NUM_INITIALIZER
16205 (struct cmd_ptype_mapping_replace_result,
16207 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16208 TOKEN_NUM_INITIALIZER
16209 (struct cmd_ptype_mapping_replace_result,
16211 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16212 TOKEN_NUM_INITIALIZER
16213 (struct cmd_ptype_mapping_replace_result,
16217 cmd_ptype_mapping_replace_parsed(
16218 void *parsed_result,
16219 __attribute__((unused)) struct cmdline *cl,
16220 __attribute__((unused)) void *data)
16222 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16223 int ret = -ENOTSUP;
16225 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16228 #ifdef RTE_LIBRTE_I40E_PMD
16229 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16239 printf("invalid ptype 0x%8x or 0x%8x\n",
16240 res->target, res->pkt_type);
16243 printf("invalid port_id %d\n", res->port_id);
16246 printf("function not implemented\n");
16249 printf("programming error: (%s)\n", strerror(-ret));
16253 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16254 .f = cmd_ptype_mapping_replace_parsed,
16257 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16259 (void *)&cmd_ptype_mapping_replace_ptype,
16260 (void *)&cmd_ptype_mapping_replace_mapping,
16261 (void *)&cmd_ptype_mapping_replace_replace,
16262 (void *)&cmd_ptype_mapping_replace_port_id,
16263 (void *)&cmd_ptype_mapping_replace_target,
16264 (void *)&cmd_ptype_mapping_replace_mask,
16265 (void *)&cmd_ptype_mapping_replace_pkt_type,
16270 /* ptype mapping reset */
16272 /* Common result structure for ptype mapping reset */
16273 struct cmd_ptype_mapping_reset_result {
16274 cmdline_fixed_string_t ptype;
16275 cmdline_fixed_string_t mapping;
16276 cmdline_fixed_string_t reset;
16280 /* Common CLI fields for ptype mapping reset*/
16281 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16282 TOKEN_STRING_INITIALIZER
16283 (struct cmd_ptype_mapping_reset_result,
16285 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16286 TOKEN_STRING_INITIALIZER
16287 (struct cmd_ptype_mapping_reset_result,
16288 mapping, "mapping");
16289 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16290 TOKEN_STRING_INITIALIZER
16291 (struct cmd_ptype_mapping_reset_result,
16293 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16294 TOKEN_NUM_INITIALIZER
16295 (struct cmd_ptype_mapping_reset_result,
16299 cmd_ptype_mapping_reset_parsed(
16300 void *parsed_result,
16301 __attribute__((unused)) struct cmdline *cl,
16302 __attribute__((unused)) void *data)
16304 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16305 int ret = -ENOTSUP;
16307 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16310 #ifdef RTE_LIBRTE_I40E_PMD
16311 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16318 printf("invalid port_id %d\n", res->port_id);
16321 printf("function not implemented\n");
16324 printf("programming error: (%s)\n", strerror(-ret));
16328 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16329 .f = cmd_ptype_mapping_reset_parsed,
16331 .help_str = "ptype mapping reset <port_id>",
16333 (void *)&cmd_ptype_mapping_reset_ptype,
16334 (void *)&cmd_ptype_mapping_reset_mapping,
16335 (void *)&cmd_ptype_mapping_reset_reset,
16336 (void *)&cmd_ptype_mapping_reset_port_id,
16341 /* ptype mapping update */
16343 /* Common result structure for ptype mapping update */
16344 struct cmd_ptype_mapping_update_result {
16345 cmdline_fixed_string_t ptype;
16346 cmdline_fixed_string_t mapping;
16347 cmdline_fixed_string_t reset;
16353 /* Common CLI fields for ptype mapping update*/
16354 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16355 TOKEN_STRING_INITIALIZER
16356 (struct cmd_ptype_mapping_update_result,
16358 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16359 TOKEN_STRING_INITIALIZER
16360 (struct cmd_ptype_mapping_update_result,
16361 mapping, "mapping");
16362 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16363 TOKEN_STRING_INITIALIZER
16364 (struct cmd_ptype_mapping_update_result,
16366 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16367 TOKEN_NUM_INITIALIZER
16368 (struct cmd_ptype_mapping_update_result,
16370 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16371 TOKEN_NUM_INITIALIZER
16372 (struct cmd_ptype_mapping_update_result,
16374 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16375 TOKEN_NUM_INITIALIZER
16376 (struct cmd_ptype_mapping_update_result,
16380 cmd_ptype_mapping_update_parsed(
16381 void *parsed_result,
16382 __attribute__((unused)) struct cmdline *cl,
16383 __attribute__((unused)) void *data)
16385 struct cmd_ptype_mapping_update_result *res = parsed_result;
16386 int ret = -ENOTSUP;
16387 #ifdef RTE_LIBRTE_I40E_PMD
16388 struct rte_pmd_i40e_ptype_mapping mapping;
16390 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16393 #ifdef RTE_LIBRTE_I40E_PMD
16394 mapping.hw_ptype = res->hw_ptype;
16395 mapping.sw_ptype = res->sw_ptype;
16396 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16406 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16409 printf("invalid port_id %d\n", res->port_id);
16412 printf("function not implemented\n");
16415 printf("programming error: (%s)\n", strerror(-ret));
16419 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16420 .f = cmd_ptype_mapping_update_parsed,
16422 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16424 (void *)&cmd_ptype_mapping_update_ptype,
16425 (void *)&cmd_ptype_mapping_update_mapping,
16426 (void *)&cmd_ptype_mapping_update_update,
16427 (void *)&cmd_ptype_mapping_update_port_id,
16428 (void *)&cmd_ptype_mapping_update_hw_ptype,
16429 (void *)&cmd_ptype_mapping_update_sw_ptype,
16434 /* Common result structure for file commands */
16435 struct cmd_cmdfile_result {
16436 cmdline_fixed_string_t load;
16437 cmdline_fixed_string_t filename;
16440 /* Common CLI fields for file commands */
16441 cmdline_parse_token_string_t cmd_load_cmdfile =
16442 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16443 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16444 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16447 cmd_load_from_file_parsed(
16448 void *parsed_result,
16449 __attribute__((unused)) struct cmdline *cl,
16450 __attribute__((unused)) void *data)
16452 struct cmd_cmdfile_result *res = parsed_result;
16454 cmdline_read_from_file(res->filename);
16457 cmdline_parse_inst_t cmd_load_from_file = {
16458 .f = cmd_load_from_file_parsed,
16460 .help_str = "load <filename>",
16462 (void *)&cmd_load_cmdfile,
16463 (void *)&cmd_load_cmdfile_filename,
16468 /* Get Rx offloads capabilities */
16469 struct cmd_rx_offload_get_capa_result {
16470 cmdline_fixed_string_t show;
16471 cmdline_fixed_string_t port;
16473 cmdline_fixed_string_t rx_offload;
16474 cmdline_fixed_string_t capabilities;
16477 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16478 TOKEN_STRING_INITIALIZER
16479 (struct cmd_rx_offload_get_capa_result,
16481 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16482 TOKEN_STRING_INITIALIZER
16483 (struct cmd_rx_offload_get_capa_result,
16485 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16486 TOKEN_NUM_INITIALIZER
16487 (struct cmd_rx_offload_get_capa_result,
16489 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16490 TOKEN_STRING_INITIALIZER
16491 (struct cmd_rx_offload_get_capa_result,
16492 rx_offload, "rx_offload");
16493 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16494 TOKEN_STRING_INITIALIZER
16495 (struct cmd_rx_offload_get_capa_result,
16496 capabilities, "capabilities");
16499 print_rx_offloads(uint64_t offloads)
16501 uint64_t single_offload;
16509 begin = __builtin_ctzll(offloads);
16510 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16512 single_offload = 1 << begin;
16513 for (bit = begin; bit < end; bit++) {
16514 if (offloads & single_offload)
16516 rte_eth_dev_rx_offload_name(single_offload));
16517 single_offload <<= 1;
16522 cmd_rx_offload_get_capa_parsed(
16523 void *parsed_result,
16524 __attribute__((unused)) struct cmdline *cl,
16525 __attribute__((unused)) void *data)
16527 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16528 struct rte_eth_dev_info dev_info;
16529 portid_t port_id = res->port_id;
16530 uint64_t queue_offloads;
16531 uint64_t port_offloads;
16533 rte_eth_dev_info_get(port_id, &dev_info);
16534 queue_offloads = dev_info.rx_queue_offload_capa;
16535 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16537 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16538 printf(" Per Queue :");
16539 print_rx_offloads(queue_offloads);
16542 printf(" Per Port :");
16543 print_rx_offloads(port_offloads);
16547 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16548 .f = cmd_rx_offload_get_capa_parsed,
16550 .help_str = "show port <port_id> rx_offload capabilities",
16552 (void *)&cmd_rx_offload_get_capa_show,
16553 (void *)&cmd_rx_offload_get_capa_port,
16554 (void *)&cmd_rx_offload_get_capa_port_id,
16555 (void *)&cmd_rx_offload_get_capa_rx_offload,
16556 (void *)&cmd_rx_offload_get_capa_capabilities,
16561 /* Get Rx offloads configuration */
16562 struct cmd_rx_offload_get_configuration_result {
16563 cmdline_fixed_string_t show;
16564 cmdline_fixed_string_t port;
16566 cmdline_fixed_string_t rx_offload;
16567 cmdline_fixed_string_t configuration;
16570 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16571 TOKEN_STRING_INITIALIZER
16572 (struct cmd_rx_offload_get_configuration_result,
16574 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16575 TOKEN_STRING_INITIALIZER
16576 (struct cmd_rx_offload_get_configuration_result,
16578 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16579 TOKEN_NUM_INITIALIZER
16580 (struct cmd_rx_offload_get_configuration_result,
16582 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16583 TOKEN_STRING_INITIALIZER
16584 (struct cmd_rx_offload_get_configuration_result,
16585 rx_offload, "rx_offload");
16586 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16587 TOKEN_STRING_INITIALIZER
16588 (struct cmd_rx_offload_get_configuration_result,
16589 configuration, "configuration");
16592 cmd_rx_offload_get_configuration_parsed(
16593 void *parsed_result,
16594 __attribute__((unused)) struct cmdline *cl,
16595 __attribute__((unused)) void *data)
16597 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16598 struct rte_eth_dev_info dev_info;
16599 portid_t port_id = res->port_id;
16600 struct rte_port *port = &ports[port_id];
16601 uint64_t port_offloads;
16602 uint64_t queue_offloads;
16603 uint16_t nb_rx_queues;
16606 printf("Rx Offloading Configuration of port %d :\n", port_id);
16608 port_offloads = port->dev_conf.rxmode.offloads;
16610 print_rx_offloads(port_offloads);
16613 rte_eth_dev_info_get(port_id, &dev_info);
16614 nb_rx_queues = dev_info.nb_rx_queues;
16615 for (q = 0; q < nb_rx_queues; q++) {
16616 queue_offloads = port->rx_conf[q].offloads;
16617 printf(" Queue[%2d] :", q);
16618 print_rx_offloads(queue_offloads);
16624 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16625 .f = cmd_rx_offload_get_configuration_parsed,
16627 .help_str = "show port <port_id> rx_offload configuration",
16629 (void *)&cmd_rx_offload_get_configuration_show,
16630 (void *)&cmd_rx_offload_get_configuration_port,
16631 (void *)&cmd_rx_offload_get_configuration_port_id,
16632 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16633 (void *)&cmd_rx_offload_get_configuration_configuration,
16638 /* Enable/Disable a per port offloading */
16639 struct cmd_config_per_port_rx_offload_result {
16640 cmdline_fixed_string_t port;
16641 cmdline_fixed_string_t config;
16643 cmdline_fixed_string_t rx_offload;
16644 cmdline_fixed_string_t offload;
16645 cmdline_fixed_string_t on_off;
16648 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16649 TOKEN_STRING_INITIALIZER
16650 (struct cmd_config_per_port_rx_offload_result,
16652 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16653 TOKEN_STRING_INITIALIZER
16654 (struct cmd_config_per_port_rx_offload_result,
16656 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16657 TOKEN_NUM_INITIALIZER
16658 (struct cmd_config_per_port_rx_offload_result,
16660 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16661 TOKEN_STRING_INITIALIZER
16662 (struct cmd_config_per_port_rx_offload_result,
16663 rx_offload, "rx_offload");
16664 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16665 TOKEN_STRING_INITIALIZER
16666 (struct cmd_config_per_port_rx_offload_result,
16667 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16668 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16669 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16670 "crc_strip#scatter#timestamp#security");
16671 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16672 TOKEN_STRING_INITIALIZER
16673 (struct cmd_config_per_port_rx_offload_result,
16677 search_rx_offload(const char *name)
16679 uint64_t single_offload;
16680 const char *single_name;
16684 single_offload = 1;
16685 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16686 single_name = rte_eth_dev_rx_offload_name(single_offload);
16687 if (!strcasecmp(single_name, name)) {
16690 } else if (!strcasecmp(single_name, "UNKNOWN"))
16692 else if (single_name == NULL)
16694 single_offload <<= 1;
16698 return single_offload;
16704 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16705 __attribute__((unused)) struct cmdline *cl,
16706 __attribute__((unused)) void *data)
16708 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16709 portid_t port_id = res->port_id;
16710 struct rte_eth_dev_info dev_info;
16711 struct rte_port *port = &ports[port_id];
16712 uint64_t single_offload;
16713 uint16_t nb_rx_queues;
16716 if (port->port_status != RTE_PORT_STOPPED) {
16717 printf("Error: Can't config offload when Port %d "
16718 "is not stopped\n", port_id);
16722 single_offload = search_rx_offload(res->offload);
16723 if (single_offload == 0) {
16724 printf("Unknown offload name: %s\n", res->offload);
16728 rte_eth_dev_info_get(port_id, &dev_info);
16729 nb_rx_queues = dev_info.nb_rx_queues;
16730 if (!strcmp(res->on_off, "on")) {
16731 port->dev_conf.rxmode.offloads |= single_offload;
16732 for (q = 0; q < nb_rx_queues; q++)
16733 port->rx_conf[q].offloads |= single_offload;
16735 port->dev_conf.rxmode.offloads &= ~single_offload;
16736 for (q = 0; q < nb_rx_queues; q++)
16737 port->rx_conf[q].offloads &= ~single_offload;
16740 cmd_reconfig_device_queue(port_id, 1, 1);
16743 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16744 .f = cmd_config_per_port_rx_offload_parsed,
16746 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16747 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16748 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16749 "jumbo_frame|crc_strip|scatter|timestamp|security "
16752 (void *)&cmd_config_per_port_rx_offload_result_port,
16753 (void *)&cmd_config_per_port_rx_offload_result_config,
16754 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16755 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16756 (void *)&cmd_config_per_port_rx_offload_result_offload,
16757 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16762 /* Enable/Disable a per queue offloading */
16763 struct cmd_config_per_queue_rx_offload_result {
16764 cmdline_fixed_string_t port;
16766 cmdline_fixed_string_t rxq;
16768 cmdline_fixed_string_t rx_offload;
16769 cmdline_fixed_string_t offload;
16770 cmdline_fixed_string_t on_off;
16773 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16774 TOKEN_STRING_INITIALIZER
16775 (struct cmd_config_per_queue_rx_offload_result,
16777 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16778 TOKEN_NUM_INITIALIZER
16779 (struct cmd_config_per_queue_rx_offload_result,
16781 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16782 TOKEN_STRING_INITIALIZER
16783 (struct cmd_config_per_queue_rx_offload_result,
16785 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16786 TOKEN_NUM_INITIALIZER
16787 (struct cmd_config_per_queue_rx_offload_result,
16789 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16790 TOKEN_STRING_INITIALIZER
16791 (struct cmd_config_per_queue_rx_offload_result,
16792 rx_offload, "rx_offload");
16793 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16794 TOKEN_STRING_INITIALIZER
16795 (struct cmd_config_per_queue_rx_offload_result,
16796 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16797 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16798 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16799 "crc_strip#scatter#timestamp#security");
16800 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16801 TOKEN_STRING_INITIALIZER
16802 (struct cmd_config_per_queue_rx_offload_result,
16806 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16807 __attribute__((unused)) struct cmdline *cl,
16808 __attribute__((unused)) void *data)
16810 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16811 struct rte_eth_dev_info dev_info;
16812 portid_t port_id = res->port_id;
16813 uint16_t queue_id = res->queue_id;
16814 struct rte_port *port = &ports[port_id];
16815 uint64_t single_offload;
16817 if (port->port_status != RTE_PORT_STOPPED) {
16818 printf("Error: Can't config offload when Port %d "
16819 "is not stopped\n", port_id);
16823 rte_eth_dev_info_get(port_id, &dev_info);
16824 if (queue_id >= dev_info.nb_rx_queues) {
16825 printf("Error: input queue_id should be 0 ... "
16826 "%d\n", dev_info.nb_rx_queues - 1);
16830 single_offload = search_rx_offload(res->offload);
16831 if (single_offload == 0) {
16832 printf("Unknown offload name: %s\n", res->offload);
16836 if (!strcmp(res->on_off, "on"))
16837 port->rx_conf[queue_id].offloads |= single_offload;
16839 port->rx_conf[queue_id].offloads &= ~single_offload;
16841 cmd_reconfig_device_queue(port_id, 1, 1);
16844 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16845 .f = cmd_config_per_queue_rx_offload_parsed,
16847 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16848 "vlan_strip|ipv4_cksum|"
16849 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16850 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16851 "jumbo_frame|crc_strip|scatter|timestamp|security "
16854 (void *)&cmd_config_per_queue_rx_offload_result_port,
16855 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16856 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16857 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16858 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16859 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16860 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16865 /* Get Tx offloads capabilities */
16866 struct cmd_tx_offload_get_capa_result {
16867 cmdline_fixed_string_t show;
16868 cmdline_fixed_string_t port;
16870 cmdline_fixed_string_t tx_offload;
16871 cmdline_fixed_string_t capabilities;
16874 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16875 TOKEN_STRING_INITIALIZER
16876 (struct cmd_tx_offload_get_capa_result,
16878 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16879 TOKEN_STRING_INITIALIZER
16880 (struct cmd_tx_offload_get_capa_result,
16882 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16883 TOKEN_NUM_INITIALIZER
16884 (struct cmd_tx_offload_get_capa_result,
16886 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16887 TOKEN_STRING_INITIALIZER
16888 (struct cmd_tx_offload_get_capa_result,
16889 tx_offload, "tx_offload");
16890 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16891 TOKEN_STRING_INITIALIZER
16892 (struct cmd_tx_offload_get_capa_result,
16893 capabilities, "capabilities");
16896 print_tx_offloads(uint64_t offloads)
16898 uint64_t single_offload;
16906 begin = __builtin_ctzll(offloads);
16907 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16909 single_offload = 1 << begin;
16910 for (bit = begin; bit < end; bit++) {
16911 if (offloads & single_offload)
16913 rte_eth_dev_tx_offload_name(single_offload));
16914 single_offload <<= 1;
16919 cmd_tx_offload_get_capa_parsed(
16920 void *parsed_result,
16921 __attribute__((unused)) struct cmdline *cl,
16922 __attribute__((unused)) void *data)
16924 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16925 struct rte_eth_dev_info dev_info;
16926 portid_t port_id = res->port_id;
16927 uint64_t queue_offloads;
16928 uint64_t port_offloads;
16930 rte_eth_dev_info_get(port_id, &dev_info);
16931 queue_offloads = dev_info.tx_queue_offload_capa;
16932 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16934 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16935 printf(" Per Queue :");
16936 print_tx_offloads(queue_offloads);
16939 printf(" Per Port :");
16940 print_tx_offloads(port_offloads);
16944 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16945 .f = cmd_tx_offload_get_capa_parsed,
16947 .help_str = "show port <port_id> tx_offload capabilities",
16949 (void *)&cmd_tx_offload_get_capa_show,
16950 (void *)&cmd_tx_offload_get_capa_port,
16951 (void *)&cmd_tx_offload_get_capa_port_id,
16952 (void *)&cmd_tx_offload_get_capa_tx_offload,
16953 (void *)&cmd_tx_offload_get_capa_capabilities,
16958 /* Get Tx offloads configuration */
16959 struct cmd_tx_offload_get_configuration_result {
16960 cmdline_fixed_string_t show;
16961 cmdline_fixed_string_t port;
16963 cmdline_fixed_string_t tx_offload;
16964 cmdline_fixed_string_t configuration;
16967 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16968 TOKEN_STRING_INITIALIZER
16969 (struct cmd_tx_offload_get_configuration_result,
16971 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16972 TOKEN_STRING_INITIALIZER
16973 (struct cmd_tx_offload_get_configuration_result,
16975 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16976 TOKEN_NUM_INITIALIZER
16977 (struct cmd_tx_offload_get_configuration_result,
16979 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16980 TOKEN_STRING_INITIALIZER
16981 (struct cmd_tx_offload_get_configuration_result,
16982 tx_offload, "tx_offload");
16983 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16984 TOKEN_STRING_INITIALIZER
16985 (struct cmd_tx_offload_get_configuration_result,
16986 configuration, "configuration");
16989 cmd_tx_offload_get_configuration_parsed(
16990 void *parsed_result,
16991 __attribute__((unused)) struct cmdline *cl,
16992 __attribute__((unused)) void *data)
16994 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16995 struct rte_eth_dev_info dev_info;
16996 portid_t port_id = res->port_id;
16997 struct rte_port *port = &ports[port_id];
16998 uint64_t port_offloads;
16999 uint64_t queue_offloads;
17000 uint16_t nb_tx_queues;
17003 printf("Tx Offloading Configuration of port %d :\n", port_id);
17005 port_offloads = port->dev_conf.txmode.offloads;
17007 print_tx_offloads(port_offloads);
17010 rte_eth_dev_info_get(port_id, &dev_info);
17011 nb_tx_queues = dev_info.nb_tx_queues;
17012 for (q = 0; q < nb_tx_queues; q++) {
17013 queue_offloads = port->tx_conf[q].offloads;
17014 printf(" Queue[%2d] :", q);
17015 print_tx_offloads(queue_offloads);
17021 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17022 .f = cmd_tx_offload_get_configuration_parsed,
17024 .help_str = "show port <port_id> tx_offload configuration",
17026 (void *)&cmd_tx_offload_get_configuration_show,
17027 (void *)&cmd_tx_offload_get_configuration_port,
17028 (void *)&cmd_tx_offload_get_configuration_port_id,
17029 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17030 (void *)&cmd_tx_offload_get_configuration_configuration,
17035 /* Enable/Disable a per port offloading */
17036 struct cmd_config_per_port_tx_offload_result {
17037 cmdline_fixed_string_t port;
17038 cmdline_fixed_string_t config;
17040 cmdline_fixed_string_t tx_offload;
17041 cmdline_fixed_string_t offload;
17042 cmdline_fixed_string_t on_off;
17045 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17046 TOKEN_STRING_INITIALIZER
17047 (struct cmd_config_per_port_tx_offload_result,
17049 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17050 TOKEN_STRING_INITIALIZER
17051 (struct cmd_config_per_port_tx_offload_result,
17053 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17054 TOKEN_NUM_INITIALIZER
17055 (struct cmd_config_per_port_tx_offload_result,
17057 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17058 TOKEN_STRING_INITIALIZER
17059 (struct cmd_config_per_port_tx_offload_result,
17060 tx_offload, "tx_offload");
17061 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17062 TOKEN_STRING_INITIALIZER
17063 (struct cmd_config_per_port_tx_offload_result,
17064 offload, "vlan_insert#ipv4_cksum#udp_cksum#udp_cksum#"
17065 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17066 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17067 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17068 "mt_lockfree#multi_segs#fast_free#security");
17069 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17070 TOKEN_STRING_INITIALIZER
17071 (struct cmd_config_per_port_tx_offload_result,
17075 search_tx_offload(const char *name)
17077 uint64_t single_offload;
17078 const char *single_name;
17082 single_offload = 1;
17083 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17084 single_name = rte_eth_dev_tx_offload_name(single_offload);
17085 if (!strcasecmp(single_name, name)) {
17088 } else if (!strcasecmp(single_name, "UNKNOWN"))
17090 else if (single_name == NULL)
17092 single_offload <<= 1;
17096 return single_offload;
17102 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17103 __attribute__((unused)) struct cmdline *cl,
17104 __attribute__((unused)) void *data)
17106 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17107 portid_t port_id = res->port_id;
17108 struct rte_eth_dev_info dev_info;
17109 struct rte_port *port = &ports[port_id];
17110 uint64_t single_offload;
17111 uint16_t nb_tx_queues;
17114 if (port->port_status != RTE_PORT_STOPPED) {
17115 printf("Error: Can't config offload when Port %d "
17116 "is not stopped\n", port_id);
17120 single_offload = search_tx_offload(res->offload);
17121 if (single_offload == 0) {
17122 printf("Unknown offload name: %s\n", res->offload);
17126 rte_eth_dev_info_get(port_id, &dev_info);
17127 nb_tx_queues = dev_info.nb_tx_queues;
17128 if (!strcmp(res->on_off, "on")) {
17129 port->dev_conf.txmode.offloads |= single_offload;
17130 for (q = 0; q < nb_tx_queues; q++)
17131 port->tx_conf[q].offloads |= single_offload;
17133 port->dev_conf.txmode.offloads &= ~single_offload;
17134 for (q = 0; q < nb_tx_queues; q++)
17135 port->tx_conf[q].offloads &= ~single_offload;
17138 cmd_reconfig_device_queue(port_id, 1, 1);
17141 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17142 .f = cmd_config_per_port_tx_offload_parsed,
17144 .help_str = "port config <port_id> tx_offload "
17145 "vlan_insert|ipv4_cksum|udp_cksum|udp_cksum|"
17146 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17147 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17148 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17149 "mt_lockfree|multi_segs|fast_free|security "
17152 (void *)&cmd_config_per_port_tx_offload_result_port,
17153 (void *)&cmd_config_per_port_tx_offload_result_config,
17154 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17155 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17156 (void *)&cmd_config_per_port_tx_offload_result_offload,
17157 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17162 /* Enable/Disable a per queue offloading */
17163 struct cmd_config_per_queue_tx_offload_result {
17164 cmdline_fixed_string_t port;
17166 cmdline_fixed_string_t txq;
17168 cmdline_fixed_string_t tx_offload;
17169 cmdline_fixed_string_t offload;
17170 cmdline_fixed_string_t on_off;
17173 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17174 TOKEN_STRING_INITIALIZER
17175 (struct cmd_config_per_queue_tx_offload_result,
17177 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17178 TOKEN_NUM_INITIALIZER
17179 (struct cmd_config_per_queue_tx_offload_result,
17181 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17182 TOKEN_STRING_INITIALIZER
17183 (struct cmd_config_per_queue_tx_offload_result,
17185 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17186 TOKEN_NUM_INITIALIZER
17187 (struct cmd_config_per_queue_tx_offload_result,
17189 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17190 TOKEN_STRING_INITIALIZER
17191 (struct cmd_config_per_queue_tx_offload_result,
17192 tx_offload, "tx_offload");
17193 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17194 TOKEN_STRING_INITIALIZER
17195 (struct cmd_config_per_queue_tx_offload_result,
17196 offload, "vlan_insert#ipv4_cksum#udp_cksum#udp_cksum#"
17197 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17198 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17199 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17200 "mt_lockfree#multi_segs#fast_free#security");
17201 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17202 TOKEN_STRING_INITIALIZER
17203 (struct cmd_config_per_queue_tx_offload_result,
17207 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17208 __attribute__((unused)) struct cmdline *cl,
17209 __attribute__((unused)) void *data)
17211 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17212 struct rte_eth_dev_info dev_info;
17213 portid_t port_id = res->port_id;
17214 uint16_t queue_id = res->queue_id;
17215 struct rte_port *port = &ports[port_id];
17216 uint64_t single_offload;
17218 if (port->port_status != RTE_PORT_STOPPED) {
17219 printf("Error: Can't config offload when Port %d "
17220 "is not stopped\n", port_id);
17224 rte_eth_dev_info_get(port_id, &dev_info);
17225 if (queue_id >= dev_info.nb_tx_queues) {
17226 printf("Error: input queue_id should be 0 ... "
17227 "%d\n", dev_info.nb_tx_queues - 1);
17231 single_offload = search_tx_offload(res->offload);
17232 if (single_offload == 0) {
17233 printf("Unknown offload name: %s\n", res->offload);
17237 if (!strcmp(res->on_off, "on"))
17238 port->tx_conf[queue_id].offloads |= single_offload;
17240 port->tx_conf[queue_id].offloads &= ~single_offload;
17242 cmd_reconfig_device_queue(port_id, 1, 1);
17245 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17246 .f = cmd_config_per_queue_tx_offload_parsed,
17248 .help_str = "port <port_id> txq <queue_id> tx_offload "
17249 "vlan_insert|ipv4_cksum|udp_cksum|udp_cksum|"
17250 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17251 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17252 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17253 "mt_lockfree|multi_segs|fast_free|security "
17256 (void *)&cmd_config_per_queue_tx_offload_result_port,
17257 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17258 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17259 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17260 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17261 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17262 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17267 /* ******************************************************************************** */
17269 /* list of instructions */
17270 cmdline_parse_ctx_t main_ctx[] = {
17271 (cmdline_parse_inst_t *)&cmd_help_brief,
17272 (cmdline_parse_inst_t *)&cmd_help_long,
17273 (cmdline_parse_inst_t *)&cmd_quit,
17274 (cmdline_parse_inst_t *)&cmd_load_from_file,
17275 (cmdline_parse_inst_t *)&cmd_showport,
17276 (cmdline_parse_inst_t *)&cmd_showqueue,
17277 (cmdline_parse_inst_t *)&cmd_showportall,
17278 (cmdline_parse_inst_t *)&cmd_showcfg,
17279 (cmdline_parse_inst_t *)&cmd_start,
17280 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17281 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17282 (cmdline_parse_inst_t *)&cmd_set_link_up,
17283 (cmdline_parse_inst_t *)&cmd_set_link_down,
17284 (cmdline_parse_inst_t *)&cmd_reset,
17285 (cmdline_parse_inst_t *)&cmd_set_numbers,
17286 (cmdline_parse_inst_t *)&cmd_set_log,
17287 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17288 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17289 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17290 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17291 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17292 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17293 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17294 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17295 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17296 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17297 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17298 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17299 (cmdline_parse_inst_t *)&cmd_set_link_check,
17300 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17301 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17302 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17303 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17304 #ifdef RTE_LIBRTE_PMD_BOND
17305 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17306 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17307 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17308 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17309 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17310 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17311 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17312 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17313 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17314 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17315 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17317 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17318 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17319 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17320 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17321 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17322 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17323 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17324 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17325 (cmdline_parse_inst_t *)&cmd_csum_set,
17326 (cmdline_parse_inst_t *)&cmd_csum_show,
17327 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17328 (cmdline_parse_inst_t *)&cmd_tso_set,
17329 (cmdline_parse_inst_t *)&cmd_tso_show,
17330 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17331 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17332 (cmdline_parse_inst_t *)&cmd_gro_enable,
17333 (cmdline_parse_inst_t *)&cmd_gro_flush,
17334 (cmdline_parse_inst_t *)&cmd_gro_show,
17335 (cmdline_parse_inst_t *)&cmd_gso_enable,
17336 (cmdline_parse_inst_t *)&cmd_gso_size,
17337 (cmdline_parse_inst_t *)&cmd_gso_show,
17338 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17339 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17340 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17341 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17342 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17343 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17344 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17345 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17346 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17347 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17348 (cmdline_parse_inst_t *)&cmd_config_dcb,
17349 (cmdline_parse_inst_t *)&cmd_read_reg,
17350 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17351 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17352 (cmdline_parse_inst_t *)&cmd_write_reg,
17353 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17354 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17355 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17356 (cmdline_parse_inst_t *)&cmd_stop,
17357 (cmdline_parse_inst_t *)&cmd_mac_addr,
17358 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17359 (cmdline_parse_inst_t *)&cmd_set_qmap,
17360 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17361 (cmdline_parse_inst_t *)&cmd_operate_port,
17362 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17363 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17364 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17365 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17366 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17367 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17368 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17369 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17370 (cmdline_parse_inst_t *)&cmd_config_mtu,
17371 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17372 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17373 (cmdline_parse_inst_t *)&cmd_config_rss,
17374 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17375 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17376 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17377 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17378 (cmdline_parse_inst_t *)&cmd_showport_reta,
17379 (cmdline_parse_inst_t *)&cmd_config_burst,
17380 (cmdline_parse_inst_t *)&cmd_config_thresh,
17381 (cmdline_parse_inst_t *)&cmd_config_threshold,
17382 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17383 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17384 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17385 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
17386 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17387 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
17388 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17389 (cmdline_parse_inst_t *)&cmd_global_config,
17390 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17391 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17392 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17393 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17394 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17395 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17396 (cmdline_parse_inst_t *)&cmd_dump,
17397 (cmdline_parse_inst_t *)&cmd_dump_one,
17398 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
17399 (cmdline_parse_inst_t *)&cmd_syn_filter,
17400 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
17401 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
17402 (cmdline_parse_inst_t *)&cmd_flex_filter,
17403 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
17404 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
17405 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
17406 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
17407 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
17408 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
17409 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17410 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
17411 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17412 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17413 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17414 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
17415 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17416 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
17417 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
17418 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
17419 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
17420 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
17421 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
17422 (cmdline_parse_inst_t *)&cmd_flow,
17423 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17424 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17425 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17426 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17427 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17428 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17429 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17430 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17431 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17432 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17433 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17434 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17435 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17436 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17437 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
17438 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
17439 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17440 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17441 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17442 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17443 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17444 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17445 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
17446 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
17447 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17448 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17449 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17450 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17451 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17452 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17453 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17454 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17455 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17456 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17457 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17458 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17459 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17460 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17461 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17462 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17463 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17464 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17465 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17466 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17467 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17468 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17469 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17470 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17471 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17472 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
17473 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
17475 (cmdline_parse_inst_t *)&cmd_ddp_add,
17476 (cmdline_parse_inst_t *)&cmd_ddp_del,
17477 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17478 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17479 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17480 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17481 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17482 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17483 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17484 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17485 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17486 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17488 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17489 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17490 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17491 (cmdline_parse_inst_t *)&cmd_queue_region,
17492 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17493 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17494 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17495 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17496 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17497 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17498 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17499 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17500 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17501 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17502 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17503 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17504 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17505 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17506 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17507 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17508 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17509 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17510 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17511 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17512 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17513 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17514 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17515 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17516 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17517 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17518 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17519 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17520 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17521 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17522 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17523 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17524 #ifdef RTE_LIBRTE_BPF
17525 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17526 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17531 /* read cmdline commands from file */
17533 cmdline_read_from_file(const char *filename)
17535 struct cmdline *cl;
17537 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17539 printf("Failed to create file based cmdline context: %s\n",
17544 cmdline_interact(cl);
17549 printf("Read CLI commands from %s\n", filename);
17552 /* prompt function, called from main on MASTER lcore */
17556 /* initialize non-constant commands */
17557 cmd_set_fwd_mode_init();
17558 cmd_set_fwd_retry_mode_init();
17560 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17561 if (testpmd_cl == NULL)
17563 cmdline_interact(testpmd_cl);
17564 cmdline_stdin_exit(testpmd_cl);
17570 if (testpmd_cl != NULL)
17571 cmdline_quit(testpmd_cl);
17575 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17577 if (id == (portid_t)RTE_PORT_ALL) {
17580 RTE_ETH_FOREACH_DEV(pid) {
17581 /* check if need_reconfig has been set to 1 */
17582 if (ports[pid].need_reconfig == 0)
17583 ports[pid].need_reconfig = dev;
17584 /* check if need_reconfig_queues has been set to 1 */
17585 if (ports[pid].need_reconfig_queues == 0)
17586 ports[pid].need_reconfig_queues = queue;
17588 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17589 /* check if need_reconfig has been set to 1 */
17590 if (ports[id].need_reconfig == 0)
17591 ports[id].need_reconfig = dev;
17592 /* check if need_reconfig_queues has been set to 1 */
17593 if (ports[id].need_reconfig_queues == 0)
17594 ports[id].need_reconfig_queues = queue;