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) {
2062 rte_eth_dev_info_get(i, &dev_info);
2063 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2065 diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
2068 printf("Configuration of RSS hash at ethernet port %d "
2069 "failed with error (%d): %s.\n",
2070 i, -diag, strerror(-diag));
2073 if (all_updated && !use_default)
2074 rss_hf = rss_conf.rss_hf;
2077 cmdline_parse_token_string_t cmd_config_rss_port =
2078 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2079 cmdline_parse_token_string_t cmd_config_rss_keyword =
2080 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2081 cmdline_parse_token_string_t cmd_config_rss_all =
2082 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2083 cmdline_parse_token_string_t cmd_config_rss_name =
2084 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2085 cmdline_parse_token_string_t cmd_config_rss_value =
2086 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2088 cmdline_parse_inst_t cmd_config_rss = {
2089 .f = cmd_config_rss_parsed,
2091 .help_str = "port config all rss "
2092 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2094 (void *)&cmd_config_rss_port,
2095 (void *)&cmd_config_rss_keyword,
2096 (void *)&cmd_config_rss_all,
2097 (void *)&cmd_config_rss_name,
2098 (void *)&cmd_config_rss_value,
2103 /* *** configure rss hash key *** */
2104 struct cmd_config_rss_hash_key {
2105 cmdline_fixed_string_t port;
2106 cmdline_fixed_string_t config;
2108 cmdline_fixed_string_t rss_hash_key;
2109 cmdline_fixed_string_t rss_type;
2110 cmdline_fixed_string_t key;
2114 hexa_digit_to_value(char hexa_digit)
2116 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2117 return (uint8_t) (hexa_digit - '0');
2118 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2119 return (uint8_t) ((hexa_digit - 'a') + 10);
2120 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2121 return (uint8_t) ((hexa_digit - 'A') + 10);
2122 /* Invalid hexa digit */
2127 parse_and_check_key_hexa_digit(char *key, int idx)
2131 hexa_v = hexa_digit_to_value(key[idx]);
2133 printf("invalid key: character %c at position %d is not a "
2134 "valid hexa digit\n", key[idx], idx);
2139 cmd_config_rss_hash_key_parsed(void *parsed_result,
2140 __attribute__((unused)) struct cmdline *cl,
2141 __attribute__((unused)) void *data)
2143 struct cmd_config_rss_hash_key *res = parsed_result;
2144 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2148 struct rte_eth_dev_info dev_info;
2149 uint8_t hash_key_size;
2152 memset(&dev_info, 0, sizeof(dev_info));
2153 rte_eth_dev_info_get(res->port_id, &dev_info);
2154 if (dev_info.hash_key_size > 0 &&
2155 dev_info.hash_key_size <= sizeof(hash_key))
2156 hash_key_size = dev_info.hash_key_size;
2158 printf("dev_info did not provide a valid hash key size\n");
2161 /* Check the length of the RSS hash key */
2162 key_len = strlen(res->key);
2163 if (key_len != (hash_key_size * 2)) {
2164 printf("key length: %d invalid - key must be a string of %d"
2165 " hexa-decimal numbers\n",
2166 (int) key_len, hash_key_size * 2);
2169 /* Translate RSS hash key into binary representation */
2170 for (i = 0; i < hash_key_size; i++) {
2171 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2174 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2177 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2179 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2183 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2184 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2185 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2186 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2188 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2189 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2190 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2191 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2192 rss_hash_key, "rss-hash-key");
2193 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2194 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2195 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2196 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2197 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2198 "ipv6-tcp-ex#ipv6-udp-ex");
2199 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2200 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2202 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2203 .f = cmd_config_rss_hash_key_parsed,
2205 .help_str = "port config <port_id> rss-hash-key "
2206 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2207 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2208 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2209 "<string of hex digits (variable length, NIC dependent)>",
2211 (void *)&cmd_config_rss_hash_key_port,
2212 (void *)&cmd_config_rss_hash_key_config,
2213 (void *)&cmd_config_rss_hash_key_port_id,
2214 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2215 (void *)&cmd_config_rss_hash_key_rss_type,
2216 (void *)&cmd_config_rss_hash_key_value,
2221 /* *** configure port rxq/txq ring size *** */
2222 struct cmd_config_rxtx_ring_size {
2223 cmdline_fixed_string_t port;
2224 cmdline_fixed_string_t config;
2226 cmdline_fixed_string_t rxtxq;
2228 cmdline_fixed_string_t rsize;
2233 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2234 __attribute__((unused)) struct cmdline *cl,
2235 __attribute__((unused)) void *data)
2237 struct cmd_config_rxtx_ring_size *res = parsed_result;
2238 struct rte_port *port;
2241 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2244 if (res->portid == (portid_t)RTE_PORT_ALL) {
2245 printf("Invalid port id\n");
2249 port = &ports[res->portid];
2251 if (!strcmp(res->rxtxq, "rxq"))
2253 else if (!strcmp(res->rxtxq, "txq"))
2256 printf("Unknown parameter\n");
2260 if (isrx && rx_queue_id_is_invalid(res->qid))
2262 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2265 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2266 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2272 port->nb_rx_desc[res->qid] = res->size;
2274 port->nb_tx_desc[res->qid] = res->size;
2276 cmd_reconfig_device_queue(res->portid, 0, 1);
2279 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2280 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2282 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2283 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2285 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2286 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2288 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2289 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2291 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2292 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2294 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2295 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2296 rsize, "ring_size");
2297 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2298 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2301 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2302 .f = cmd_config_rxtx_ring_size_parsed,
2304 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2306 (void *)&cmd_config_rxtx_ring_size_port,
2307 (void *)&cmd_config_rxtx_ring_size_config,
2308 (void *)&cmd_config_rxtx_ring_size_portid,
2309 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2310 (void *)&cmd_config_rxtx_ring_size_qid,
2311 (void *)&cmd_config_rxtx_ring_size_rsize,
2312 (void *)&cmd_config_rxtx_ring_size_size,
2317 /* *** configure port rxq/txq start/stop *** */
2318 struct cmd_config_rxtx_queue {
2319 cmdline_fixed_string_t port;
2321 cmdline_fixed_string_t rxtxq;
2323 cmdline_fixed_string_t opname;
2327 cmd_config_rxtx_queue_parsed(void *parsed_result,
2328 __attribute__((unused)) struct cmdline *cl,
2329 __attribute__((unused)) void *data)
2331 struct cmd_config_rxtx_queue *res = parsed_result;
2336 if (test_done == 0) {
2337 printf("Please stop forwarding first\n");
2341 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2344 if (port_is_started(res->portid) != 1) {
2345 printf("Please start port %u first\n", res->portid);
2349 if (!strcmp(res->rxtxq, "rxq"))
2351 else if (!strcmp(res->rxtxq, "txq"))
2354 printf("Unknown parameter\n");
2358 if (isrx && rx_queue_id_is_invalid(res->qid))
2360 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2363 if (!strcmp(res->opname, "start"))
2365 else if (!strcmp(res->opname, "stop"))
2368 printf("Unknown parameter\n");
2372 if (isstart && isrx)
2373 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2374 else if (!isstart && isrx)
2375 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2376 else if (isstart && !isrx)
2377 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2379 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2381 if (ret == -ENOTSUP)
2382 printf("Function not supported in PMD driver\n");
2385 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2386 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2387 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2388 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2389 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2390 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2391 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2392 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2393 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2394 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2397 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2398 .f = cmd_config_rxtx_queue_parsed,
2400 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2402 (void *)&cmd_config_rxtx_queue_port,
2403 (void *)&cmd_config_rxtx_queue_portid,
2404 (void *)&cmd_config_rxtx_queue_rxtxq,
2405 (void *)&cmd_config_rxtx_queue_qid,
2406 (void *)&cmd_config_rxtx_queue_opname,
2411 /* *** configure port rxq/txq setup *** */
2412 struct cmd_setup_rxtx_queue {
2413 cmdline_fixed_string_t port;
2415 cmdline_fixed_string_t rxtxq;
2417 cmdline_fixed_string_t setup;
2420 /* Common CLI fields for queue setup */
2421 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2422 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2423 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2424 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2425 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2426 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2427 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2428 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2429 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2430 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2433 cmd_setup_rxtx_queue_parsed(
2434 void *parsed_result,
2435 __attribute__((unused)) struct cmdline *cl,
2436 __attribute__((unused)) void *data)
2438 struct cmd_setup_rxtx_queue *res = parsed_result;
2439 struct rte_port *port;
2440 struct rte_mempool *mp;
2441 unsigned int socket_id;
2445 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2448 if (res->portid == (portid_t)RTE_PORT_ALL) {
2449 printf("Invalid port id\n");
2453 if (!strcmp(res->rxtxq, "rxq"))
2455 else if (!strcmp(res->rxtxq, "txq"))
2458 printf("Unknown parameter\n");
2462 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2463 printf("Invalid rx queue\n");
2465 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2466 printf("Invalid tx queue\n");
2470 port = &ports[res->portid];
2472 socket_id = rxring_numa[res->portid];
2473 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2474 socket_id = port->socket_id;
2476 mp = mbuf_pool_find(socket_id);
2478 printf("Failed to setup RX queue: "
2479 "No mempool allocation"
2480 " on the socket %d\n",
2481 rxring_numa[res->portid]);
2484 ret = rte_eth_rx_queue_setup(res->portid,
2486 port->nb_rx_desc[res->qid],
2488 &port->rx_conf[res->qid],
2491 printf("Failed to setup RX queue\n");
2493 socket_id = txring_numa[res->portid];
2494 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2495 socket_id = port->socket_id;
2497 ret = rte_eth_tx_queue_setup(res->portid,
2499 port->nb_tx_desc[res->qid],
2501 &port->tx_conf[res->qid]);
2503 printf("Failed to setup TX queue\n");
2507 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2508 .f = cmd_setup_rxtx_queue_parsed,
2510 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2512 (void *)&cmd_setup_rxtx_queue_port,
2513 (void *)&cmd_setup_rxtx_queue_portid,
2514 (void *)&cmd_setup_rxtx_queue_rxtxq,
2515 (void *)&cmd_setup_rxtx_queue_qid,
2516 (void *)&cmd_setup_rxtx_queue_setup,
2522 /* *** Configure RSS RETA *** */
2523 struct cmd_config_rss_reta {
2524 cmdline_fixed_string_t port;
2525 cmdline_fixed_string_t keyword;
2527 cmdline_fixed_string_t name;
2528 cmdline_fixed_string_t list_name;
2529 cmdline_fixed_string_t list_of_items;
2533 parse_reta_config(const char *str,
2534 struct rte_eth_rss_reta_entry64 *reta_conf,
2535 uint16_t nb_entries)
2539 uint16_t hash_index, idx, shift;
2542 const char *p, *p0 = str;
2549 unsigned long int_fld[_NUM_FLD];
2550 char *str_fld[_NUM_FLD];
2552 while ((p = strchr(p0,'(')) != NULL) {
2554 if((p0 = strchr(p,')')) == NULL)
2558 if(size >= sizeof(s))
2561 snprintf(s, sizeof(s), "%.*s", size, p);
2562 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2564 for (i = 0; i < _NUM_FLD; i++) {
2566 int_fld[i] = strtoul(str_fld[i], &end, 0);
2567 if (errno != 0 || end == str_fld[i] ||
2572 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2573 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2575 if (hash_index >= nb_entries) {
2576 printf("Invalid RETA hash index=%d\n", hash_index);
2580 idx = hash_index / RTE_RETA_GROUP_SIZE;
2581 shift = hash_index % RTE_RETA_GROUP_SIZE;
2582 reta_conf[idx].mask |= (1ULL << shift);
2583 reta_conf[idx].reta[shift] = nb_queue;
2590 cmd_set_rss_reta_parsed(void *parsed_result,
2591 __attribute__((unused)) struct cmdline *cl,
2592 __attribute__((unused)) void *data)
2595 struct rte_eth_dev_info dev_info;
2596 struct rte_eth_rss_reta_entry64 reta_conf[8];
2597 struct cmd_config_rss_reta *res = parsed_result;
2599 memset(&dev_info, 0, sizeof(dev_info));
2600 rte_eth_dev_info_get(res->port_id, &dev_info);
2601 if (dev_info.reta_size == 0) {
2602 printf("Redirection table size is 0 which is "
2603 "invalid for RSS\n");
2606 printf("The reta size of port %d is %u\n",
2607 res->port_id, dev_info.reta_size);
2608 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2609 printf("Currently do not support more than %u entries of "
2610 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2614 memset(reta_conf, 0, sizeof(reta_conf));
2615 if (!strcmp(res->list_name, "reta")) {
2616 if (parse_reta_config(res->list_of_items, reta_conf,
2617 dev_info.reta_size)) {
2618 printf("Invalid RSS Redirection Table "
2619 "config entered\n");
2622 ret = rte_eth_dev_rss_reta_update(res->port_id,
2623 reta_conf, dev_info.reta_size);
2625 printf("Bad redirection table parameter, "
2626 "return code = %d \n", ret);
2630 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2631 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2632 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2633 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2634 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2635 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2636 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2637 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2638 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2639 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2640 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2641 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2643 cmdline_parse_inst_t cmd_config_rss_reta = {
2644 .f = cmd_set_rss_reta_parsed,
2646 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2648 (void *)&cmd_config_rss_reta_port,
2649 (void *)&cmd_config_rss_reta_keyword,
2650 (void *)&cmd_config_rss_reta_port_id,
2651 (void *)&cmd_config_rss_reta_name,
2652 (void *)&cmd_config_rss_reta_list_name,
2653 (void *)&cmd_config_rss_reta_list_of_items,
2658 /* *** SHOW PORT RETA INFO *** */
2659 struct cmd_showport_reta {
2660 cmdline_fixed_string_t show;
2661 cmdline_fixed_string_t port;
2663 cmdline_fixed_string_t rss;
2664 cmdline_fixed_string_t reta;
2666 cmdline_fixed_string_t list_of_items;
2670 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2671 uint16_t nb_entries,
2675 const char *p, *p0 = str;
2680 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2681 RTE_RETA_GROUP_SIZE;
2684 p = strchr(p0, '(');
2688 p0 = strchr(p, ')');
2692 if (size >= sizeof(s)) {
2693 printf("The string size exceeds the internal buffer size\n");
2696 snprintf(s, sizeof(s), "%.*s", size, p);
2697 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2698 if (ret <= 0 || ret != num) {
2699 printf("The bits of masks do not match the number of "
2700 "reta entries: %u\n", num);
2703 for (i = 0; i < ret; i++)
2704 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2710 cmd_showport_reta_parsed(void *parsed_result,
2711 __attribute__((unused)) struct cmdline *cl,
2712 __attribute__((unused)) void *data)
2714 struct cmd_showport_reta *res = parsed_result;
2715 struct rte_eth_rss_reta_entry64 reta_conf[8];
2716 struct rte_eth_dev_info dev_info;
2717 uint16_t max_reta_size;
2719 memset(&dev_info, 0, sizeof(dev_info));
2720 rte_eth_dev_info_get(res->port_id, &dev_info);
2721 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2722 if (res->size == 0 || res->size > max_reta_size) {
2723 printf("Invalid redirection table size: %u (1-%u)\n",
2724 res->size, max_reta_size);
2728 memset(reta_conf, 0, sizeof(reta_conf));
2729 if (showport_parse_reta_config(reta_conf, res->size,
2730 res->list_of_items) < 0) {
2731 printf("Invalid string: %s for reta masks\n",
2732 res->list_of_items);
2735 port_rss_reta_info(res->port_id, reta_conf, res->size);
2738 cmdline_parse_token_string_t cmd_showport_reta_show =
2739 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2740 cmdline_parse_token_string_t cmd_showport_reta_port =
2741 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2742 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2743 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2744 cmdline_parse_token_string_t cmd_showport_reta_rss =
2745 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2746 cmdline_parse_token_string_t cmd_showport_reta_reta =
2747 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2748 cmdline_parse_token_num_t cmd_showport_reta_size =
2749 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2750 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2751 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2752 list_of_items, NULL);
2754 cmdline_parse_inst_t cmd_showport_reta = {
2755 .f = cmd_showport_reta_parsed,
2757 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2759 (void *)&cmd_showport_reta_show,
2760 (void *)&cmd_showport_reta_port,
2761 (void *)&cmd_showport_reta_port_id,
2762 (void *)&cmd_showport_reta_rss,
2763 (void *)&cmd_showport_reta_reta,
2764 (void *)&cmd_showport_reta_size,
2765 (void *)&cmd_showport_reta_list_of_items,
2770 /* *** Show RSS hash configuration *** */
2771 struct cmd_showport_rss_hash {
2772 cmdline_fixed_string_t show;
2773 cmdline_fixed_string_t port;
2775 cmdline_fixed_string_t rss_hash;
2776 cmdline_fixed_string_t rss_type;
2777 cmdline_fixed_string_t key; /* optional argument */
2780 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2781 __attribute__((unused)) struct cmdline *cl,
2784 struct cmd_showport_rss_hash *res = parsed_result;
2786 port_rss_hash_conf_show(res->port_id, res->rss_type,
2787 show_rss_key != NULL);
2790 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2791 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2792 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2793 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2794 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2795 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2796 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2797 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2799 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2800 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2801 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2802 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2803 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2804 "ipv6-tcp-ex#ipv6-udp-ex");
2805 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2806 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2808 cmdline_parse_inst_t cmd_showport_rss_hash = {
2809 .f = cmd_showport_rss_hash_parsed,
2811 .help_str = "show port <port_id> rss-hash "
2812 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2813 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2814 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2816 (void *)&cmd_showport_rss_hash_show,
2817 (void *)&cmd_showport_rss_hash_port,
2818 (void *)&cmd_showport_rss_hash_port_id,
2819 (void *)&cmd_showport_rss_hash_rss_hash,
2820 (void *)&cmd_showport_rss_hash_rss_hash_info,
2825 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2826 .f = cmd_showport_rss_hash_parsed,
2828 .help_str = "show port <port_id> rss-hash "
2829 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2830 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2831 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2833 (void *)&cmd_showport_rss_hash_show,
2834 (void *)&cmd_showport_rss_hash_port,
2835 (void *)&cmd_showport_rss_hash_port_id,
2836 (void *)&cmd_showport_rss_hash_rss_hash,
2837 (void *)&cmd_showport_rss_hash_rss_hash_info,
2838 (void *)&cmd_showport_rss_hash_rss_key,
2843 /* *** Configure DCB *** */
2844 struct cmd_config_dcb {
2845 cmdline_fixed_string_t port;
2846 cmdline_fixed_string_t config;
2848 cmdline_fixed_string_t dcb;
2849 cmdline_fixed_string_t vt;
2850 cmdline_fixed_string_t vt_en;
2852 cmdline_fixed_string_t pfc;
2853 cmdline_fixed_string_t pfc_en;
2857 cmd_config_dcb_parsed(void *parsed_result,
2858 __attribute__((unused)) struct cmdline *cl,
2859 __attribute__((unused)) void *data)
2861 struct cmd_config_dcb *res = parsed_result;
2862 portid_t port_id = res->port_id;
2863 struct rte_port *port;
2867 port = &ports[port_id];
2868 /** Check if the port is not started **/
2869 if (port->port_status != RTE_PORT_STOPPED) {
2870 printf("Please stop port %d first\n", port_id);
2874 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2875 printf("The invalid number of traffic class,"
2876 " only 4 or 8 allowed.\n");
2880 if (nb_fwd_lcores < res->num_tcs) {
2881 printf("nb_cores shouldn't be less than number of TCs.\n");
2884 if (!strncmp(res->pfc_en, "on", 2))
2889 /* DCB in VT mode */
2890 if (!strncmp(res->vt_en, "on", 2))
2891 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2892 (enum rte_eth_nb_tcs)res->num_tcs,
2895 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2896 (enum rte_eth_nb_tcs)res->num_tcs,
2901 printf("Cannot initialize network ports.\n");
2905 cmd_reconfig_device_queue(port_id, 1, 1);
2908 cmdline_parse_token_string_t cmd_config_dcb_port =
2909 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2910 cmdline_parse_token_string_t cmd_config_dcb_config =
2911 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2912 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2913 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2914 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2915 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2916 cmdline_parse_token_string_t cmd_config_dcb_vt =
2917 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2918 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2919 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2920 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2921 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2922 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2923 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2924 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2925 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2927 cmdline_parse_inst_t cmd_config_dcb = {
2928 .f = cmd_config_dcb_parsed,
2930 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2932 (void *)&cmd_config_dcb_port,
2933 (void *)&cmd_config_dcb_config,
2934 (void *)&cmd_config_dcb_port_id,
2935 (void *)&cmd_config_dcb_dcb,
2936 (void *)&cmd_config_dcb_vt,
2937 (void *)&cmd_config_dcb_vt_en,
2938 (void *)&cmd_config_dcb_num_tcs,
2939 (void *)&cmd_config_dcb_pfc,
2940 (void *)&cmd_config_dcb_pfc_en,
2945 /* *** configure number of packets per burst *** */
2946 struct cmd_config_burst {
2947 cmdline_fixed_string_t port;
2948 cmdline_fixed_string_t keyword;
2949 cmdline_fixed_string_t all;
2950 cmdline_fixed_string_t name;
2955 cmd_config_burst_parsed(void *parsed_result,
2956 __attribute__((unused)) struct cmdline *cl,
2957 __attribute__((unused)) void *data)
2959 struct cmd_config_burst *res = parsed_result;
2960 struct rte_eth_dev_info dev_info;
2961 uint16_t rec_nb_pkts;
2963 if (!all_ports_stopped()) {
2964 printf("Please stop all ports first\n");
2968 if (!strcmp(res->name, "burst")) {
2969 if (res->value == 0) {
2970 /* If user gives a value of zero, query the PMD for
2971 * its recommended Rx burst size. Testpmd uses a single
2972 * size for all ports, so assume all ports are the same
2973 * NIC model and use the values from Port 0.
2975 rte_eth_dev_info_get(0, &dev_info);
2976 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
2978 if (rec_nb_pkts == 0) {
2979 printf("PMD does not recommend a burst size.\n"
2980 "User provided value must be between"
2981 " 1 and %d\n", MAX_PKT_BURST);
2983 } else if (rec_nb_pkts > MAX_PKT_BURST) {
2984 printf("PMD recommended burst size of %d"
2985 " exceeds maximum value of %d\n",
2986 rec_nb_pkts, MAX_PKT_BURST);
2989 printf("Using PMD-provided burst value of %d\n",
2991 nb_pkt_per_burst = rec_nb_pkts;
2992 } else if (res->value > MAX_PKT_BURST) {
2993 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
2996 nb_pkt_per_burst = res->value;
2998 printf("Unknown parameter\n");
3004 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3007 cmdline_parse_token_string_t cmd_config_burst_port =
3008 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3009 cmdline_parse_token_string_t cmd_config_burst_keyword =
3010 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3011 cmdline_parse_token_string_t cmd_config_burst_all =
3012 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3013 cmdline_parse_token_string_t cmd_config_burst_name =
3014 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3015 cmdline_parse_token_num_t cmd_config_burst_value =
3016 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3018 cmdline_parse_inst_t cmd_config_burst = {
3019 .f = cmd_config_burst_parsed,
3021 .help_str = "port config all burst <value>",
3023 (void *)&cmd_config_burst_port,
3024 (void *)&cmd_config_burst_keyword,
3025 (void *)&cmd_config_burst_all,
3026 (void *)&cmd_config_burst_name,
3027 (void *)&cmd_config_burst_value,
3032 /* *** configure rx/tx queues *** */
3033 struct cmd_config_thresh {
3034 cmdline_fixed_string_t port;
3035 cmdline_fixed_string_t keyword;
3036 cmdline_fixed_string_t all;
3037 cmdline_fixed_string_t name;
3042 cmd_config_thresh_parsed(void *parsed_result,
3043 __attribute__((unused)) struct cmdline *cl,
3044 __attribute__((unused)) void *data)
3046 struct cmd_config_thresh *res = parsed_result;
3048 if (!all_ports_stopped()) {
3049 printf("Please stop all ports first\n");
3053 if (!strcmp(res->name, "txpt"))
3054 tx_pthresh = res->value;
3055 else if(!strcmp(res->name, "txht"))
3056 tx_hthresh = res->value;
3057 else if(!strcmp(res->name, "txwt"))
3058 tx_wthresh = res->value;
3059 else if(!strcmp(res->name, "rxpt"))
3060 rx_pthresh = res->value;
3061 else if(!strcmp(res->name, "rxht"))
3062 rx_hthresh = res->value;
3063 else if(!strcmp(res->name, "rxwt"))
3064 rx_wthresh = res->value;
3066 printf("Unknown parameter\n");
3072 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3075 cmdline_parse_token_string_t cmd_config_thresh_port =
3076 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3077 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3078 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3079 cmdline_parse_token_string_t cmd_config_thresh_all =
3080 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3081 cmdline_parse_token_string_t cmd_config_thresh_name =
3082 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3083 "txpt#txht#txwt#rxpt#rxht#rxwt");
3084 cmdline_parse_token_num_t cmd_config_thresh_value =
3085 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3087 cmdline_parse_inst_t cmd_config_thresh = {
3088 .f = cmd_config_thresh_parsed,
3090 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3092 (void *)&cmd_config_thresh_port,
3093 (void *)&cmd_config_thresh_keyword,
3094 (void *)&cmd_config_thresh_all,
3095 (void *)&cmd_config_thresh_name,
3096 (void *)&cmd_config_thresh_value,
3101 /* *** configure free/rs threshold *** */
3102 struct cmd_config_threshold {
3103 cmdline_fixed_string_t port;
3104 cmdline_fixed_string_t keyword;
3105 cmdline_fixed_string_t all;
3106 cmdline_fixed_string_t name;
3111 cmd_config_threshold_parsed(void *parsed_result,
3112 __attribute__((unused)) struct cmdline *cl,
3113 __attribute__((unused)) void *data)
3115 struct cmd_config_threshold *res = parsed_result;
3117 if (!all_ports_stopped()) {
3118 printf("Please stop all ports first\n");
3122 if (!strcmp(res->name, "txfreet"))
3123 tx_free_thresh = res->value;
3124 else if (!strcmp(res->name, "txrst"))
3125 tx_rs_thresh = res->value;
3126 else if (!strcmp(res->name, "rxfreet"))
3127 rx_free_thresh = res->value;
3129 printf("Unknown parameter\n");
3135 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3138 cmdline_parse_token_string_t cmd_config_threshold_port =
3139 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3140 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3141 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3143 cmdline_parse_token_string_t cmd_config_threshold_all =
3144 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3145 cmdline_parse_token_string_t cmd_config_threshold_name =
3146 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3147 "txfreet#txrst#rxfreet");
3148 cmdline_parse_token_num_t cmd_config_threshold_value =
3149 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3151 cmdline_parse_inst_t cmd_config_threshold = {
3152 .f = cmd_config_threshold_parsed,
3154 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3156 (void *)&cmd_config_threshold_port,
3157 (void *)&cmd_config_threshold_keyword,
3158 (void *)&cmd_config_threshold_all,
3159 (void *)&cmd_config_threshold_name,
3160 (void *)&cmd_config_threshold_value,
3166 struct cmd_stop_result {
3167 cmdline_fixed_string_t stop;
3170 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3171 __attribute__((unused)) struct cmdline *cl,
3172 __attribute__((unused)) void *data)
3174 stop_packet_forwarding();
3177 cmdline_parse_token_string_t cmd_stop_stop =
3178 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3180 cmdline_parse_inst_t cmd_stop = {
3181 .f = cmd_stop_parsed,
3183 .help_str = "stop: Stop packet forwarding",
3185 (void *)&cmd_stop_stop,
3190 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3193 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3194 unsigned int *parsed_items, int check_unique_values)
3196 unsigned int nb_item;
3204 * First parse all items in the list and store their value.
3209 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3211 if ((c >= '0') && (c <= '9')) {
3212 value = (unsigned int) (value * 10 + (c - '0'));
3217 printf("character %c is not a decimal digit\n", c);
3221 printf("No valid value before comma\n");
3224 if (nb_item < max_items) {
3225 parsed_items[nb_item] = value;
3231 if (nb_item >= max_items) {
3232 printf("Number of %s = %u > %u (maximum items)\n",
3233 item_name, nb_item + 1, max_items);
3236 parsed_items[nb_item++] = value;
3237 if (! check_unique_values)
3241 * Then, check that all values in the list are differents.
3242 * No optimization here...
3244 for (i = 0; i < nb_item; i++) {
3245 for (j = i + 1; j < nb_item; j++) {
3246 if (parsed_items[j] == parsed_items[i]) {
3247 printf("duplicated %s %u at index %u and %u\n",
3248 item_name, parsed_items[i], i, j);
3256 struct cmd_set_list_result {
3257 cmdline_fixed_string_t cmd_keyword;
3258 cmdline_fixed_string_t list_name;
3259 cmdline_fixed_string_t list_of_items;
3262 static void cmd_set_list_parsed(void *parsed_result,
3263 __attribute__((unused)) struct cmdline *cl,
3264 __attribute__((unused)) void *data)
3266 struct cmd_set_list_result *res;
3268 unsigned int lcorelist[RTE_MAX_LCORE];
3269 unsigned int portlist[RTE_MAX_ETHPORTS];
3271 unsigned int nb_item;
3273 if (test_done == 0) {
3274 printf("Please stop forwarding first\n");
3278 res = parsed_result;
3279 if (!strcmp(res->list_name, "corelist")) {
3280 nb_item = parse_item_list(res->list_of_items, "core",
3282 parsed_items.lcorelist, 1);
3284 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3289 if (!strcmp(res->list_name, "portlist")) {
3290 nb_item = parse_item_list(res->list_of_items, "port",
3292 parsed_items.portlist, 1);
3294 set_fwd_ports_list(parsed_items.portlist, nb_item);
3300 cmdline_parse_token_string_t cmd_set_list_keyword =
3301 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3303 cmdline_parse_token_string_t cmd_set_list_name =
3304 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3305 "corelist#portlist");
3306 cmdline_parse_token_string_t cmd_set_list_of_items =
3307 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3310 cmdline_parse_inst_t cmd_set_fwd_list = {
3311 .f = cmd_set_list_parsed,
3313 .help_str = "set corelist|portlist <list0[,list1]*>",
3315 (void *)&cmd_set_list_keyword,
3316 (void *)&cmd_set_list_name,
3317 (void *)&cmd_set_list_of_items,
3322 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3324 struct cmd_setmask_result {
3325 cmdline_fixed_string_t set;
3326 cmdline_fixed_string_t mask;
3330 static void cmd_set_mask_parsed(void *parsed_result,
3331 __attribute__((unused)) struct cmdline *cl,
3332 __attribute__((unused)) void *data)
3334 struct cmd_setmask_result *res = parsed_result;
3336 if (test_done == 0) {
3337 printf("Please stop forwarding first\n");
3340 if (!strcmp(res->mask, "coremask")) {
3341 set_fwd_lcores_mask(res->hexavalue);
3343 } else if (!strcmp(res->mask, "portmask")) {
3344 set_fwd_ports_mask(res->hexavalue);
3349 cmdline_parse_token_string_t cmd_setmask_set =
3350 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3351 cmdline_parse_token_string_t cmd_setmask_mask =
3352 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3353 "coremask#portmask");
3354 cmdline_parse_token_num_t cmd_setmask_value =
3355 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3357 cmdline_parse_inst_t cmd_set_fwd_mask = {
3358 .f = cmd_set_mask_parsed,
3360 .help_str = "set coremask|portmask <hexadecimal value>",
3362 (void *)&cmd_setmask_set,
3363 (void *)&cmd_setmask_mask,
3364 (void *)&cmd_setmask_value,
3370 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3372 struct cmd_set_result {
3373 cmdline_fixed_string_t set;
3374 cmdline_fixed_string_t what;
3378 static void cmd_set_parsed(void *parsed_result,
3379 __attribute__((unused)) struct cmdline *cl,
3380 __attribute__((unused)) void *data)
3382 struct cmd_set_result *res = parsed_result;
3383 if (!strcmp(res->what, "nbport")) {
3384 set_fwd_ports_number(res->value);
3386 } else if (!strcmp(res->what, "nbcore")) {
3387 set_fwd_lcores_number(res->value);
3389 } else if (!strcmp(res->what, "burst"))
3390 set_nb_pkt_per_burst(res->value);
3391 else if (!strcmp(res->what, "verbose"))
3392 set_verbose_level(res->value);
3395 cmdline_parse_token_string_t cmd_set_set =
3396 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3397 cmdline_parse_token_string_t cmd_set_what =
3398 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3399 "nbport#nbcore#burst#verbose");
3400 cmdline_parse_token_num_t cmd_set_value =
3401 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3403 cmdline_parse_inst_t cmd_set_numbers = {
3404 .f = cmd_set_parsed,
3406 .help_str = "set nbport|nbcore|burst|verbose <value>",
3408 (void *)&cmd_set_set,
3409 (void *)&cmd_set_what,
3410 (void *)&cmd_set_value,
3415 /* *** SET LOG LEVEL CONFIGURATION *** */
3417 struct cmd_set_log_result {
3418 cmdline_fixed_string_t set;
3419 cmdline_fixed_string_t log;
3420 cmdline_fixed_string_t type;
3425 cmd_set_log_parsed(void *parsed_result,
3426 __attribute__((unused)) struct cmdline *cl,
3427 __attribute__((unused)) void *data)
3429 struct cmd_set_log_result *res;
3432 res = parsed_result;
3433 if (!strcmp(res->type, "global"))
3434 rte_log_set_global_level(res->level);
3436 ret = rte_log_set_level_regexp(res->type, res->level);
3438 printf("Unable to set log level\n");
3442 cmdline_parse_token_string_t cmd_set_log_set =
3443 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3444 cmdline_parse_token_string_t cmd_set_log_log =
3445 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3446 cmdline_parse_token_string_t cmd_set_log_type =
3447 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3448 cmdline_parse_token_num_t cmd_set_log_level =
3449 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3451 cmdline_parse_inst_t cmd_set_log = {
3452 .f = cmd_set_log_parsed,
3454 .help_str = "set log global|<type> <level>",
3456 (void *)&cmd_set_log_set,
3457 (void *)&cmd_set_log_log,
3458 (void *)&cmd_set_log_type,
3459 (void *)&cmd_set_log_level,
3464 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3466 struct cmd_set_txpkts_result {
3467 cmdline_fixed_string_t cmd_keyword;
3468 cmdline_fixed_string_t txpkts;
3469 cmdline_fixed_string_t seg_lengths;
3473 cmd_set_txpkts_parsed(void *parsed_result,
3474 __attribute__((unused)) struct cmdline *cl,
3475 __attribute__((unused)) void *data)
3477 struct cmd_set_txpkts_result *res;
3478 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3479 unsigned int nb_segs;
3481 res = parsed_result;
3482 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3483 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3485 set_tx_pkt_segments(seg_lengths, nb_segs);
3488 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3489 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3490 cmd_keyword, "set");
3491 cmdline_parse_token_string_t cmd_set_txpkts_name =
3492 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3494 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3495 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3498 cmdline_parse_inst_t cmd_set_txpkts = {
3499 .f = cmd_set_txpkts_parsed,
3501 .help_str = "set txpkts <len0[,len1]*>",
3503 (void *)&cmd_set_txpkts_keyword,
3504 (void *)&cmd_set_txpkts_name,
3505 (void *)&cmd_set_txpkts_lengths,
3510 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3512 struct cmd_set_txsplit_result {
3513 cmdline_fixed_string_t cmd_keyword;
3514 cmdline_fixed_string_t txsplit;
3515 cmdline_fixed_string_t mode;
3519 cmd_set_txsplit_parsed(void *parsed_result,
3520 __attribute__((unused)) struct cmdline *cl,
3521 __attribute__((unused)) void *data)
3523 struct cmd_set_txsplit_result *res;
3525 res = parsed_result;
3526 set_tx_pkt_split(res->mode);
3529 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3530 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3531 cmd_keyword, "set");
3532 cmdline_parse_token_string_t cmd_set_txsplit_name =
3533 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3534 txsplit, "txsplit");
3535 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3536 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3539 cmdline_parse_inst_t cmd_set_txsplit = {
3540 .f = cmd_set_txsplit_parsed,
3542 .help_str = "set txsplit on|off|rand",
3544 (void *)&cmd_set_txsplit_keyword,
3545 (void *)&cmd_set_txsplit_name,
3546 (void *)&cmd_set_txsplit_mode,
3551 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3552 struct cmd_rx_vlan_filter_all_result {
3553 cmdline_fixed_string_t rx_vlan;
3554 cmdline_fixed_string_t what;
3555 cmdline_fixed_string_t all;
3560 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3561 __attribute__((unused)) struct cmdline *cl,
3562 __attribute__((unused)) void *data)
3564 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3566 if (!strcmp(res->what, "add"))
3567 rx_vlan_all_filter_set(res->port_id, 1);
3569 rx_vlan_all_filter_set(res->port_id, 0);
3572 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3573 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3574 rx_vlan, "rx_vlan");
3575 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3576 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3578 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3579 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3581 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3582 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3585 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3586 .f = cmd_rx_vlan_filter_all_parsed,
3588 .help_str = "rx_vlan add|rm all <port_id>: "
3589 "Add/Remove all identifiers to/from the set of VLAN "
3590 "identifiers filtered by a port",
3592 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3593 (void *)&cmd_rx_vlan_filter_all_what,
3594 (void *)&cmd_rx_vlan_filter_all_all,
3595 (void *)&cmd_rx_vlan_filter_all_portid,
3600 /* *** VLAN OFFLOAD SET ON A PORT *** */
3601 struct cmd_vlan_offload_result {
3602 cmdline_fixed_string_t vlan;
3603 cmdline_fixed_string_t set;
3604 cmdline_fixed_string_t vlan_type;
3605 cmdline_fixed_string_t what;
3606 cmdline_fixed_string_t on;
3607 cmdline_fixed_string_t port_id;
3611 cmd_vlan_offload_parsed(void *parsed_result,
3612 __attribute__((unused)) struct cmdline *cl,
3613 __attribute__((unused)) void *data)
3616 struct cmd_vlan_offload_result *res = parsed_result;
3619 portid_t port_id = 0;
3623 len = strnlen(str, STR_TOKEN_SIZE);
3625 /* Get port_id first */
3633 tmp = strtoul(str, NULL, 0);
3634 /* If port_id greater that what portid_t can represent, return */
3635 if(tmp >= RTE_MAX_ETHPORTS)
3637 port_id = (portid_t)tmp;
3639 if (!strcmp(res->on, "on"))
3644 if (!strcmp(res->what, "strip"))
3645 rx_vlan_strip_set(port_id, on);
3646 else if(!strcmp(res->what, "stripq")){
3647 uint16_t queue_id = 0;
3649 /* No queue_id, return */
3651 printf("must specify (port,queue_id)\n");
3654 tmp = strtoul(str + i + 1, NULL, 0);
3655 /* If queue_id greater that what 16-bits can represent, return */
3659 queue_id = (uint16_t)tmp;
3660 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3662 else if (!strcmp(res->what, "filter"))
3663 rx_vlan_filter_set(port_id, on);
3665 vlan_extend_set(port_id, on);
3670 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3671 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3673 cmdline_parse_token_string_t cmd_vlan_offload_set =
3674 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3676 cmdline_parse_token_string_t cmd_vlan_offload_what =
3677 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3678 what, "strip#filter#qinq#stripq");
3679 cmdline_parse_token_string_t cmd_vlan_offload_on =
3680 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3682 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3683 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3686 cmdline_parse_inst_t cmd_vlan_offload = {
3687 .f = cmd_vlan_offload_parsed,
3689 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3690 "<port_id[,queue_id]>: "
3691 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3693 (void *)&cmd_vlan_offload_vlan,
3694 (void *)&cmd_vlan_offload_set,
3695 (void *)&cmd_vlan_offload_what,
3696 (void *)&cmd_vlan_offload_on,
3697 (void *)&cmd_vlan_offload_portid,
3702 /* *** VLAN TPID SET ON A PORT *** */
3703 struct cmd_vlan_tpid_result {
3704 cmdline_fixed_string_t vlan;
3705 cmdline_fixed_string_t set;
3706 cmdline_fixed_string_t vlan_type;
3707 cmdline_fixed_string_t what;
3713 cmd_vlan_tpid_parsed(void *parsed_result,
3714 __attribute__((unused)) struct cmdline *cl,
3715 __attribute__((unused)) void *data)
3717 struct cmd_vlan_tpid_result *res = parsed_result;
3718 enum rte_vlan_type vlan_type;
3720 if (!strcmp(res->vlan_type, "inner"))
3721 vlan_type = ETH_VLAN_TYPE_INNER;
3722 else if (!strcmp(res->vlan_type, "outer"))
3723 vlan_type = ETH_VLAN_TYPE_OUTER;
3725 printf("Unknown vlan type\n");
3728 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3731 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3732 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3734 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3735 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3737 cmdline_parse_token_string_t cmd_vlan_type =
3738 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3739 vlan_type, "inner#outer");
3740 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3741 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3743 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3744 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3746 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3747 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3750 cmdline_parse_inst_t cmd_vlan_tpid = {
3751 .f = cmd_vlan_tpid_parsed,
3753 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3754 "Set the VLAN Ether type",
3756 (void *)&cmd_vlan_tpid_vlan,
3757 (void *)&cmd_vlan_tpid_set,
3758 (void *)&cmd_vlan_type,
3759 (void *)&cmd_vlan_tpid_what,
3760 (void *)&cmd_vlan_tpid_tpid,
3761 (void *)&cmd_vlan_tpid_portid,
3766 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3767 struct cmd_rx_vlan_filter_result {
3768 cmdline_fixed_string_t rx_vlan;
3769 cmdline_fixed_string_t what;
3775 cmd_rx_vlan_filter_parsed(void *parsed_result,
3776 __attribute__((unused)) struct cmdline *cl,
3777 __attribute__((unused)) void *data)
3779 struct cmd_rx_vlan_filter_result *res = parsed_result;
3781 if (!strcmp(res->what, "add"))
3782 rx_vft_set(res->port_id, res->vlan_id, 1);
3784 rx_vft_set(res->port_id, res->vlan_id, 0);
3787 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3788 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3789 rx_vlan, "rx_vlan");
3790 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3791 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3793 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3794 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3796 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3797 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3800 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3801 .f = cmd_rx_vlan_filter_parsed,
3803 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3804 "Add/Remove a VLAN identifier to/from the set of VLAN "
3805 "identifiers filtered by a port",
3807 (void *)&cmd_rx_vlan_filter_rx_vlan,
3808 (void *)&cmd_rx_vlan_filter_what,
3809 (void *)&cmd_rx_vlan_filter_vlanid,
3810 (void *)&cmd_rx_vlan_filter_portid,
3815 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3816 struct cmd_tx_vlan_set_result {
3817 cmdline_fixed_string_t tx_vlan;
3818 cmdline_fixed_string_t set;
3824 cmd_tx_vlan_set_parsed(void *parsed_result,
3825 __attribute__((unused)) struct cmdline *cl,
3826 __attribute__((unused)) void *data)
3828 struct cmd_tx_vlan_set_result *res = parsed_result;
3830 if (!port_is_stopped(res->port_id)) {
3831 printf("Please stop port %d first\n", res->port_id);
3835 tx_vlan_set(res->port_id, res->vlan_id);
3837 cmd_reconfig_device_queue(res->port_id, 1, 1);
3840 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3841 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3842 tx_vlan, "tx_vlan");
3843 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3844 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3846 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3847 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3849 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3850 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3853 cmdline_parse_inst_t cmd_tx_vlan_set = {
3854 .f = cmd_tx_vlan_set_parsed,
3856 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3857 "Enable hardware insertion of a single VLAN header "
3858 "with a given TAG Identifier in packets sent on a port",
3860 (void *)&cmd_tx_vlan_set_tx_vlan,
3861 (void *)&cmd_tx_vlan_set_set,
3862 (void *)&cmd_tx_vlan_set_portid,
3863 (void *)&cmd_tx_vlan_set_vlanid,
3868 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3869 struct cmd_tx_vlan_set_qinq_result {
3870 cmdline_fixed_string_t tx_vlan;
3871 cmdline_fixed_string_t set;
3874 uint16_t vlan_id_outer;
3878 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3879 __attribute__((unused)) struct cmdline *cl,
3880 __attribute__((unused)) void *data)
3882 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3884 if (!port_is_stopped(res->port_id)) {
3885 printf("Please stop port %d first\n", res->port_id);
3889 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3891 cmd_reconfig_device_queue(res->port_id, 1, 1);
3894 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3895 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3896 tx_vlan, "tx_vlan");
3897 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3898 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3900 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3901 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3903 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3904 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3906 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3907 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3908 vlan_id_outer, UINT16);
3910 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3911 .f = cmd_tx_vlan_set_qinq_parsed,
3913 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3914 "Enable hardware insertion of double VLAN header "
3915 "with given TAG Identifiers in packets sent on a port",
3917 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3918 (void *)&cmd_tx_vlan_set_qinq_set,
3919 (void *)&cmd_tx_vlan_set_qinq_portid,
3920 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3921 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3926 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3927 struct cmd_tx_vlan_set_pvid_result {
3928 cmdline_fixed_string_t tx_vlan;
3929 cmdline_fixed_string_t set;
3930 cmdline_fixed_string_t pvid;
3933 cmdline_fixed_string_t mode;
3937 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3938 __attribute__((unused)) struct cmdline *cl,
3939 __attribute__((unused)) void *data)
3941 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3943 if (strcmp(res->mode, "on") == 0)
3944 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3946 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3949 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3950 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3951 tx_vlan, "tx_vlan");
3952 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3953 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3955 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3956 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3958 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3959 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3961 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3962 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3964 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3965 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3968 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
3969 .f = cmd_tx_vlan_set_pvid_parsed,
3971 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
3973 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
3974 (void *)&cmd_tx_vlan_set_pvid_set,
3975 (void *)&cmd_tx_vlan_set_pvid_pvid,
3976 (void *)&cmd_tx_vlan_set_pvid_port_id,
3977 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
3978 (void *)&cmd_tx_vlan_set_pvid_mode,
3983 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3984 struct cmd_tx_vlan_reset_result {
3985 cmdline_fixed_string_t tx_vlan;
3986 cmdline_fixed_string_t reset;
3991 cmd_tx_vlan_reset_parsed(void *parsed_result,
3992 __attribute__((unused)) struct cmdline *cl,
3993 __attribute__((unused)) void *data)
3995 struct cmd_tx_vlan_reset_result *res = parsed_result;
3997 if (!port_is_stopped(res->port_id)) {
3998 printf("Please stop port %d first\n", res->port_id);
4002 tx_vlan_reset(res->port_id);
4004 cmd_reconfig_device_queue(res->port_id, 1, 1);
4007 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4008 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4009 tx_vlan, "tx_vlan");
4010 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4011 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4013 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4014 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4017 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4018 .f = cmd_tx_vlan_reset_parsed,
4020 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4021 "VLAN header in packets sent on a port",
4023 (void *)&cmd_tx_vlan_reset_tx_vlan,
4024 (void *)&cmd_tx_vlan_reset_reset,
4025 (void *)&cmd_tx_vlan_reset_portid,
4031 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4032 struct cmd_csum_result {
4033 cmdline_fixed_string_t csum;
4034 cmdline_fixed_string_t mode;
4035 cmdline_fixed_string_t proto;
4036 cmdline_fixed_string_t hwsw;
4041 csum_show(int port_id)
4043 struct rte_eth_dev_info dev_info;
4044 uint64_t tx_offloads;
4046 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4047 printf("Parse tunnel is %s\n",
4048 (ports[port_id].parse_tunnel) ? "on" : "off");
4049 printf("IP checksum offload is %s\n",
4050 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4051 printf("UDP checksum offload is %s\n",
4052 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4053 printf("TCP checksum offload is %s\n",
4054 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4055 printf("SCTP checksum offload is %s\n",
4056 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4057 printf("Outer-Ip checksum offload is %s\n",
4058 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4060 /* display warnings if configuration is not supported by the NIC */
4061 rte_eth_dev_info_get(port_id, &dev_info);
4062 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4063 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4064 printf("Warning: hardware IP checksum enabled but not "
4065 "supported by port %d\n", port_id);
4067 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4068 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4069 printf("Warning: hardware UDP checksum enabled but not "
4070 "supported by port %d\n", port_id);
4072 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4073 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4074 printf("Warning: hardware TCP checksum enabled but not "
4075 "supported by port %d\n", port_id);
4077 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4078 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4079 printf("Warning: hardware SCTP checksum enabled but not "
4080 "supported by port %d\n", port_id);
4082 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4083 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4084 printf("Warning: hardware outer IP checksum enabled but not "
4085 "supported by port %d\n", port_id);
4090 cmd_csum_parsed(void *parsed_result,
4091 __attribute__((unused)) struct cmdline *cl,
4092 __attribute__((unused)) void *data)
4094 struct cmd_csum_result *res = parsed_result;
4096 uint64_t csum_offloads = 0;
4097 struct rte_eth_dev_info dev_info;
4099 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4100 printf("invalid port %d\n", res->port_id);
4103 if (!port_is_stopped(res->port_id)) {
4104 printf("Please stop port %d first\n", res->port_id);
4108 rte_eth_dev_info_get(res->port_id, &dev_info);
4109 if (!strcmp(res->mode, "set")) {
4111 if (!strcmp(res->hwsw, "hw"))
4114 if (!strcmp(res->proto, "ip")) {
4115 if (hw == 0 || (dev_info.tx_offload_capa &
4116 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4117 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4119 printf("IP checksum offload is not supported "
4120 "by port %u\n", res->port_id);
4122 } else if (!strcmp(res->proto, "udp")) {
4123 if (hw == 0 || (dev_info.tx_offload_capa &
4124 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4125 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4127 printf("UDP checksum offload is not supported "
4128 "by port %u\n", res->port_id);
4130 } else if (!strcmp(res->proto, "tcp")) {
4131 if (hw == 0 || (dev_info.tx_offload_capa &
4132 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4133 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4135 printf("TCP checksum offload is not supported "
4136 "by port %u\n", res->port_id);
4138 } else if (!strcmp(res->proto, "sctp")) {
4139 if (hw == 0 || (dev_info.tx_offload_capa &
4140 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4141 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4143 printf("SCTP checksum offload is not supported "
4144 "by port %u\n", res->port_id);
4146 } else if (!strcmp(res->proto, "outer-ip")) {
4147 if (hw == 0 || (dev_info.tx_offload_capa &
4148 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4150 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4152 printf("Outer IP checksum offload is not "
4153 "supported by port %u\n", res->port_id);
4158 ports[res->port_id].dev_conf.txmode.offloads |=
4161 ports[res->port_id].dev_conf.txmode.offloads &=
4165 csum_show(res->port_id);
4167 cmd_reconfig_device_queue(res->port_id, 1, 1);
4170 cmdline_parse_token_string_t cmd_csum_csum =
4171 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4173 cmdline_parse_token_string_t cmd_csum_mode =
4174 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4176 cmdline_parse_token_string_t cmd_csum_proto =
4177 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4178 proto, "ip#tcp#udp#sctp#outer-ip");
4179 cmdline_parse_token_string_t cmd_csum_hwsw =
4180 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4182 cmdline_parse_token_num_t cmd_csum_portid =
4183 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4186 cmdline_parse_inst_t cmd_csum_set = {
4187 .f = cmd_csum_parsed,
4189 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4190 "Enable/Disable hardware calculation of L3/L4 checksum when "
4191 "using csum forward engine",
4193 (void *)&cmd_csum_csum,
4194 (void *)&cmd_csum_mode,
4195 (void *)&cmd_csum_proto,
4196 (void *)&cmd_csum_hwsw,
4197 (void *)&cmd_csum_portid,
4202 cmdline_parse_token_string_t cmd_csum_mode_show =
4203 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4206 cmdline_parse_inst_t cmd_csum_show = {
4207 .f = cmd_csum_parsed,
4209 .help_str = "csum show <port_id>: Show checksum offload configuration",
4211 (void *)&cmd_csum_csum,
4212 (void *)&cmd_csum_mode_show,
4213 (void *)&cmd_csum_portid,
4218 /* Enable/disable tunnel parsing */
4219 struct cmd_csum_tunnel_result {
4220 cmdline_fixed_string_t csum;
4221 cmdline_fixed_string_t parse;
4222 cmdline_fixed_string_t onoff;
4227 cmd_csum_tunnel_parsed(void *parsed_result,
4228 __attribute__((unused)) struct cmdline *cl,
4229 __attribute__((unused)) void *data)
4231 struct cmd_csum_tunnel_result *res = parsed_result;
4233 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4236 if (!strcmp(res->onoff, "on"))
4237 ports[res->port_id].parse_tunnel = 1;
4239 ports[res->port_id].parse_tunnel = 0;
4241 csum_show(res->port_id);
4244 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4245 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4247 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4248 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4249 parse, "parse_tunnel");
4250 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4251 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4253 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4254 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4257 cmdline_parse_inst_t cmd_csum_tunnel = {
4258 .f = cmd_csum_tunnel_parsed,
4260 .help_str = "csum parse_tunnel on|off <port_id>: "
4261 "Enable/Disable parsing of tunnels for csum engine",
4263 (void *)&cmd_csum_tunnel_csum,
4264 (void *)&cmd_csum_tunnel_parse,
4265 (void *)&cmd_csum_tunnel_onoff,
4266 (void *)&cmd_csum_tunnel_portid,
4271 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4272 struct cmd_tso_set_result {
4273 cmdline_fixed_string_t tso;
4274 cmdline_fixed_string_t mode;
4280 cmd_tso_set_parsed(void *parsed_result,
4281 __attribute__((unused)) struct cmdline *cl,
4282 __attribute__((unused)) void *data)
4284 struct cmd_tso_set_result *res = parsed_result;
4285 struct rte_eth_dev_info dev_info;
4287 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4289 if (!port_is_stopped(res->port_id)) {
4290 printf("Please stop port %d first\n", res->port_id);
4294 if (!strcmp(res->mode, "set"))
4295 ports[res->port_id].tso_segsz = res->tso_segsz;
4297 rte_eth_dev_info_get(res->port_id, &dev_info);
4298 if ((ports[res->port_id].tso_segsz != 0) &&
4299 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4300 printf("Error: TSO is not supported by port %d\n",
4305 if (ports[res->port_id].tso_segsz == 0) {
4306 ports[res->port_id].dev_conf.txmode.offloads &=
4307 ~DEV_TX_OFFLOAD_TCP_TSO;
4308 printf("TSO for non-tunneled packets is disabled\n");
4310 ports[res->port_id].dev_conf.txmode.offloads |=
4311 DEV_TX_OFFLOAD_TCP_TSO;
4312 printf("TSO segment size for non-tunneled packets is %d\n",
4313 ports[res->port_id].tso_segsz);
4316 /* display warnings if configuration is not supported by the NIC */
4317 rte_eth_dev_info_get(res->port_id, &dev_info);
4318 if ((ports[res->port_id].tso_segsz != 0) &&
4319 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4320 printf("Warning: TSO enabled but not "
4321 "supported by port %d\n", res->port_id);
4324 cmd_reconfig_device_queue(res->port_id, 1, 1);
4327 cmdline_parse_token_string_t cmd_tso_set_tso =
4328 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4330 cmdline_parse_token_string_t cmd_tso_set_mode =
4331 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4333 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4334 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4336 cmdline_parse_token_num_t cmd_tso_set_portid =
4337 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4340 cmdline_parse_inst_t cmd_tso_set = {
4341 .f = cmd_tso_set_parsed,
4343 .help_str = "tso set <tso_segsz> <port_id>: "
4344 "Set TSO segment size of non-tunneled packets for csum engine "
4347 (void *)&cmd_tso_set_tso,
4348 (void *)&cmd_tso_set_mode,
4349 (void *)&cmd_tso_set_tso_segsz,
4350 (void *)&cmd_tso_set_portid,
4355 cmdline_parse_token_string_t cmd_tso_show_mode =
4356 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4360 cmdline_parse_inst_t cmd_tso_show = {
4361 .f = cmd_tso_set_parsed,
4363 .help_str = "tso show <port_id>: "
4364 "Show TSO segment size of non-tunneled packets for csum engine",
4366 (void *)&cmd_tso_set_tso,
4367 (void *)&cmd_tso_show_mode,
4368 (void *)&cmd_tso_set_portid,
4373 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4374 struct cmd_tunnel_tso_set_result {
4375 cmdline_fixed_string_t tso;
4376 cmdline_fixed_string_t mode;
4381 static struct rte_eth_dev_info
4382 check_tunnel_tso_nic_support(portid_t port_id)
4384 struct rte_eth_dev_info dev_info;
4386 rte_eth_dev_info_get(port_id, &dev_info);
4387 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4388 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4389 "not enabled for port %d\n", port_id);
4390 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4391 printf("Warning: GRE TUNNEL TSO not supported therefore "
4392 "not enabled for port %d\n", port_id);
4393 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4394 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4395 "not enabled for port %d\n", port_id);
4396 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4397 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4398 "not enabled for port %d\n", port_id);
4399 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4400 printf("Warning: IP TUNNEL TSO not supported therefore "
4401 "not enabled for port %d\n", port_id);
4402 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4403 printf("Warning: UDP TUNNEL TSO not supported therefore "
4404 "not enabled for port %d\n", port_id);
4409 cmd_tunnel_tso_set_parsed(void *parsed_result,
4410 __attribute__((unused)) struct cmdline *cl,
4411 __attribute__((unused)) void *data)
4413 struct cmd_tunnel_tso_set_result *res = parsed_result;
4414 struct rte_eth_dev_info dev_info;
4416 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4418 if (!port_is_stopped(res->port_id)) {
4419 printf("Please stop port %d first\n", res->port_id);
4423 if (!strcmp(res->mode, "set"))
4424 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4426 dev_info = check_tunnel_tso_nic_support(res->port_id);
4427 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4428 ports[res->port_id].dev_conf.txmode.offloads &=
4429 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4430 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4431 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4432 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4433 DEV_TX_OFFLOAD_IP_TNL_TSO |
4434 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4435 printf("TSO for tunneled packets is disabled\n");
4437 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4438 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4439 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4440 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4441 DEV_TX_OFFLOAD_IP_TNL_TSO |
4442 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4444 ports[res->port_id].dev_conf.txmode.offloads |=
4445 (tso_offloads & dev_info.tx_offload_capa);
4446 printf("TSO segment size for tunneled packets is %d\n",
4447 ports[res->port_id].tunnel_tso_segsz);
4449 /* Below conditions are needed to make it work:
4450 * (1) tunnel TSO is supported by the NIC;
4451 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4453 * (3) for tunneled pkts with outer L3 of IPv4,
4454 * "csum set outer-ip" must be set to hw, because after tso,
4455 * total_len of outer IP header is changed, and the checksum
4456 * of outer IP header calculated by sw should be wrong; that
4457 * is not necessary for IPv6 tunneled pkts because there's no
4458 * checksum in IP header anymore.
4461 if (!ports[res->port_id].parse_tunnel)
4462 printf("Warning: csum parse_tunnel must be set "
4463 "so that tunneled packets are recognized\n");
4464 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4465 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4466 printf("Warning: csum set outer-ip must be set to hw "
4467 "if outer L3 is IPv4; not necessary for IPv6\n");
4470 cmd_reconfig_device_queue(res->port_id, 1, 1);
4473 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4474 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4476 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4477 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4479 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4480 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4482 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4483 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4486 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4487 .f = cmd_tunnel_tso_set_parsed,
4489 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4490 "Set TSO segment size of tunneled packets for csum engine "
4493 (void *)&cmd_tunnel_tso_set_tso,
4494 (void *)&cmd_tunnel_tso_set_mode,
4495 (void *)&cmd_tunnel_tso_set_tso_segsz,
4496 (void *)&cmd_tunnel_tso_set_portid,
4501 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4502 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4506 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4507 .f = cmd_tunnel_tso_set_parsed,
4509 .help_str = "tunnel_tso show <port_id> "
4510 "Show TSO segment size of tunneled packets for csum engine",
4512 (void *)&cmd_tunnel_tso_set_tso,
4513 (void *)&cmd_tunnel_tso_show_mode,
4514 (void *)&cmd_tunnel_tso_set_portid,
4519 /* *** SET GRO FOR A PORT *** */
4520 struct cmd_gro_enable_result {
4521 cmdline_fixed_string_t cmd_set;
4522 cmdline_fixed_string_t cmd_port;
4523 cmdline_fixed_string_t cmd_keyword;
4524 cmdline_fixed_string_t cmd_onoff;
4529 cmd_gro_enable_parsed(void *parsed_result,
4530 __attribute__((unused)) struct cmdline *cl,
4531 __attribute__((unused)) void *data)
4533 struct cmd_gro_enable_result *res;
4535 res = parsed_result;
4536 if (!strcmp(res->cmd_keyword, "gro"))
4537 setup_gro(res->cmd_onoff, res->cmd_pid);
4540 cmdline_parse_token_string_t cmd_gro_enable_set =
4541 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4543 cmdline_parse_token_string_t cmd_gro_enable_port =
4544 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4545 cmd_keyword, "port");
4546 cmdline_parse_token_num_t cmd_gro_enable_pid =
4547 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4549 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4550 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4551 cmd_keyword, "gro");
4552 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4553 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4554 cmd_onoff, "on#off");
4556 cmdline_parse_inst_t cmd_gro_enable = {
4557 .f = cmd_gro_enable_parsed,
4559 .help_str = "set port <port_id> gro on|off",
4561 (void *)&cmd_gro_enable_set,
4562 (void *)&cmd_gro_enable_port,
4563 (void *)&cmd_gro_enable_pid,
4564 (void *)&cmd_gro_enable_keyword,
4565 (void *)&cmd_gro_enable_onoff,
4570 /* *** DISPLAY GRO CONFIGURATION *** */
4571 struct cmd_gro_show_result {
4572 cmdline_fixed_string_t cmd_show;
4573 cmdline_fixed_string_t cmd_port;
4574 cmdline_fixed_string_t cmd_keyword;
4579 cmd_gro_show_parsed(void *parsed_result,
4580 __attribute__((unused)) struct cmdline *cl,
4581 __attribute__((unused)) void *data)
4583 struct cmd_gro_show_result *res;
4585 res = parsed_result;
4586 if (!strcmp(res->cmd_keyword, "gro"))
4587 show_gro(res->cmd_pid);
4590 cmdline_parse_token_string_t cmd_gro_show_show =
4591 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4593 cmdline_parse_token_string_t cmd_gro_show_port =
4594 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4596 cmdline_parse_token_num_t cmd_gro_show_pid =
4597 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4599 cmdline_parse_token_string_t cmd_gro_show_keyword =
4600 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4601 cmd_keyword, "gro");
4603 cmdline_parse_inst_t cmd_gro_show = {
4604 .f = cmd_gro_show_parsed,
4606 .help_str = "show port <port_id> gro",
4608 (void *)&cmd_gro_show_show,
4609 (void *)&cmd_gro_show_port,
4610 (void *)&cmd_gro_show_pid,
4611 (void *)&cmd_gro_show_keyword,
4616 /* *** SET FLUSH CYCLES FOR GRO *** */
4617 struct cmd_gro_flush_result {
4618 cmdline_fixed_string_t cmd_set;
4619 cmdline_fixed_string_t cmd_keyword;
4620 cmdline_fixed_string_t cmd_flush;
4625 cmd_gro_flush_parsed(void *parsed_result,
4626 __attribute__((unused)) struct cmdline *cl,
4627 __attribute__((unused)) void *data)
4629 struct cmd_gro_flush_result *res;
4631 res = parsed_result;
4632 if ((!strcmp(res->cmd_keyword, "gro")) &&
4633 (!strcmp(res->cmd_flush, "flush")))
4634 setup_gro_flush_cycles(res->cmd_cycles);
4637 cmdline_parse_token_string_t cmd_gro_flush_set =
4638 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4640 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4641 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4642 cmd_keyword, "gro");
4643 cmdline_parse_token_string_t cmd_gro_flush_flush =
4644 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4645 cmd_flush, "flush");
4646 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4647 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4650 cmdline_parse_inst_t cmd_gro_flush = {
4651 .f = cmd_gro_flush_parsed,
4653 .help_str = "set gro flush <cycles>",
4655 (void *)&cmd_gro_flush_set,
4656 (void *)&cmd_gro_flush_keyword,
4657 (void *)&cmd_gro_flush_flush,
4658 (void *)&cmd_gro_flush_cycles,
4663 /* *** ENABLE/DISABLE GSO *** */
4664 struct cmd_gso_enable_result {
4665 cmdline_fixed_string_t cmd_set;
4666 cmdline_fixed_string_t cmd_port;
4667 cmdline_fixed_string_t cmd_keyword;
4668 cmdline_fixed_string_t cmd_mode;
4673 cmd_gso_enable_parsed(void *parsed_result,
4674 __attribute__((unused)) struct cmdline *cl,
4675 __attribute__((unused)) void *data)
4677 struct cmd_gso_enable_result *res;
4679 res = parsed_result;
4680 if (!strcmp(res->cmd_keyword, "gso"))
4681 setup_gso(res->cmd_mode, res->cmd_pid);
4684 cmdline_parse_token_string_t cmd_gso_enable_set =
4685 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4687 cmdline_parse_token_string_t cmd_gso_enable_port =
4688 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4690 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4691 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4692 cmd_keyword, "gso");
4693 cmdline_parse_token_string_t cmd_gso_enable_mode =
4694 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4695 cmd_mode, "on#off");
4696 cmdline_parse_token_num_t cmd_gso_enable_pid =
4697 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4700 cmdline_parse_inst_t cmd_gso_enable = {
4701 .f = cmd_gso_enable_parsed,
4703 .help_str = "set port <port_id> gso on|off",
4705 (void *)&cmd_gso_enable_set,
4706 (void *)&cmd_gso_enable_port,
4707 (void *)&cmd_gso_enable_pid,
4708 (void *)&cmd_gso_enable_keyword,
4709 (void *)&cmd_gso_enable_mode,
4714 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4715 struct cmd_gso_size_result {
4716 cmdline_fixed_string_t cmd_set;
4717 cmdline_fixed_string_t cmd_keyword;
4718 cmdline_fixed_string_t cmd_segsz;
4723 cmd_gso_size_parsed(void *parsed_result,
4724 __attribute__((unused)) struct cmdline *cl,
4725 __attribute__((unused)) void *data)
4727 struct cmd_gso_size_result *res = parsed_result;
4729 if (test_done == 0) {
4730 printf("Before setting GSO segsz, please first"
4731 " stop fowarding\n");
4735 if (!strcmp(res->cmd_keyword, "gso") &&
4736 !strcmp(res->cmd_segsz, "segsz")) {
4737 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4738 printf("gso_size should be larger than %zu."
4739 " Please input a legal value\n",
4740 RTE_GSO_SEG_SIZE_MIN);
4742 gso_max_segment_size = res->cmd_size;
4746 cmdline_parse_token_string_t cmd_gso_size_set =
4747 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4749 cmdline_parse_token_string_t cmd_gso_size_keyword =
4750 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4751 cmd_keyword, "gso");
4752 cmdline_parse_token_string_t cmd_gso_size_segsz =
4753 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4754 cmd_segsz, "segsz");
4755 cmdline_parse_token_num_t cmd_gso_size_size =
4756 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4759 cmdline_parse_inst_t cmd_gso_size = {
4760 .f = cmd_gso_size_parsed,
4762 .help_str = "set gso segsz <length>",
4764 (void *)&cmd_gso_size_set,
4765 (void *)&cmd_gso_size_keyword,
4766 (void *)&cmd_gso_size_segsz,
4767 (void *)&cmd_gso_size_size,
4772 /* *** SHOW GSO CONFIGURATION *** */
4773 struct cmd_gso_show_result {
4774 cmdline_fixed_string_t cmd_show;
4775 cmdline_fixed_string_t cmd_port;
4776 cmdline_fixed_string_t cmd_keyword;
4781 cmd_gso_show_parsed(void *parsed_result,
4782 __attribute__((unused)) struct cmdline *cl,
4783 __attribute__((unused)) void *data)
4785 struct cmd_gso_show_result *res = parsed_result;
4787 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4788 printf("invalid port id %u\n", res->cmd_pid);
4791 if (!strcmp(res->cmd_keyword, "gso")) {
4792 if (gso_ports[res->cmd_pid].enable) {
4793 printf("Max GSO'd packet size: %uB\n"
4794 "Supported GSO types: TCP/IPv4, "
4795 "VxLAN with inner TCP/IPv4 packet, "
4796 "GRE with inner TCP/IPv4 packet\n",
4797 gso_max_segment_size);
4799 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4803 cmdline_parse_token_string_t cmd_gso_show_show =
4804 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4806 cmdline_parse_token_string_t cmd_gso_show_port =
4807 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4809 cmdline_parse_token_string_t cmd_gso_show_keyword =
4810 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4811 cmd_keyword, "gso");
4812 cmdline_parse_token_num_t cmd_gso_show_pid =
4813 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4816 cmdline_parse_inst_t cmd_gso_show = {
4817 .f = cmd_gso_show_parsed,
4819 .help_str = "show port <port_id> gso",
4821 (void *)&cmd_gso_show_show,
4822 (void *)&cmd_gso_show_port,
4823 (void *)&cmd_gso_show_pid,
4824 (void *)&cmd_gso_show_keyword,
4829 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4830 struct cmd_set_flush_rx {
4831 cmdline_fixed_string_t set;
4832 cmdline_fixed_string_t flush_rx;
4833 cmdline_fixed_string_t mode;
4837 cmd_set_flush_rx_parsed(void *parsed_result,
4838 __attribute__((unused)) struct cmdline *cl,
4839 __attribute__((unused)) void *data)
4841 struct cmd_set_flush_rx *res = parsed_result;
4842 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4845 cmdline_parse_token_string_t cmd_setflushrx_set =
4846 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4848 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4849 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4850 flush_rx, "flush_rx");
4851 cmdline_parse_token_string_t cmd_setflushrx_mode =
4852 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4856 cmdline_parse_inst_t cmd_set_flush_rx = {
4857 .f = cmd_set_flush_rx_parsed,
4858 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4861 (void *)&cmd_setflushrx_set,
4862 (void *)&cmd_setflushrx_flush_rx,
4863 (void *)&cmd_setflushrx_mode,
4868 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4869 struct cmd_set_link_check {
4870 cmdline_fixed_string_t set;
4871 cmdline_fixed_string_t link_check;
4872 cmdline_fixed_string_t mode;
4876 cmd_set_link_check_parsed(void *parsed_result,
4877 __attribute__((unused)) struct cmdline *cl,
4878 __attribute__((unused)) void *data)
4880 struct cmd_set_link_check *res = parsed_result;
4881 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4884 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4885 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4887 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4888 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4889 link_check, "link_check");
4890 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4891 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4895 cmdline_parse_inst_t cmd_set_link_check = {
4896 .f = cmd_set_link_check_parsed,
4897 .help_str = "set link_check on|off: Enable/Disable link status check "
4898 "when starting/stopping a port",
4901 (void *)&cmd_setlinkcheck_set,
4902 (void *)&cmd_setlinkcheck_link_check,
4903 (void *)&cmd_setlinkcheck_mode,
4908 /* *** SET NIC BYPASS MODE *** */
4909 struct cmd_set_bypass_mode_result {
4910 cmdline_fixed_string_t set;
4911 cmdline_fixed_string_t bypass;
4912 cmdline_fixed_string_t mode;
4913 cmdline_fixed_string_t value;
4918 cmd_set_bypass_mode_parsed(void *parsed_result,
4919 __attribute__((unused)) struct cmdline *cl,
4920 __attribute__((unused)) void *data)
4922 struct cmd_set_bypass_mode_result *res = parsed_result;
4923 portid_t port_id = res->port_id;
4924 int32_t rc = -EINVAL;
4926 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4927 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4929 if (!strcmp(res->value, "bypass"))
4930 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4931 else if (!strcmp(res->value, "isolate"))
4932 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4934 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4936 /* Set the bypass mode for the relevant port. */
4937 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4940 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4943 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4944 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4946 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4947 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4949 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4950 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4952 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4953 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4954 value, "normal#bypass#isolate");
4955 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4956 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4959 cmdline_parse_inst_t cmd_set_bypass_mode = {
4960 .f = cmd_set_bypass_mode_parsed,
4961 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4962 "Set the NIC bypass mode for port_id",
4965 (void *)&cmd_setbypass_mode_set,
4966 (void *)&cmd_setbypass_mode_bypass,
4967 (void *)&cmd_setbypass_mode_mode,
4968 (void *)&cmd_setbypass_mode_value,
4969 (void *)&cmd_setbypass_mode_port,
4974 /* *** SET NIC BYPASS EVENT *** */
4975 struct cmd_set_bypass_event_result {
4976 cmdline_fixed_string_t set;
4977 cmdline_fixed_string_t bypass;
4978 cmdline_fixed_string_t event;
4979 cmdline_fixed_string_t event_value;
4980 cmdline_fixed_string_t mode;
4981 cmdline_fixed_string_t mode_value;
4986 cmd_set_bypass_event_parsed(void *parsed_result,
4987 __attribute__((unused)) struct cmdline *cl,
4988 __attribute__((unused)) void *data)
4990 int32_t rc = -EINVAL;
4991 struct cmd_set_bypass_event_result *res = parsed_result;
4992 portid_t port_id = res->port_id;
4994 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4995 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
4996 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4998 if (!strcmp(res->event_value, "timeout"))
4999 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5000 else if (!strcmp(res->event_value, "os_on"))
5001 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5002 else if (!strcmp(res->event_value, "os_off"))
5003 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5004 else if (!strcmp(res->event_value, "power_on"))
5005 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5006 else if (!strcmp(res->event_value, "power_off"))
5007 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5009 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5011 if (!strcmp(res->mode_value, "bypass"))
5012 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5013 else if (!strcmp(res->mode_value, "isolate"))
5014 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5016 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5018 /* Set the watchdog timeout. */
5019 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5022 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5023 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5027 printf("Failed to set timeout value %u "
5028 "for port %d, errto code: %d.\n",
5029 bypass_timeout, port_id, rc);
5033 /* Set the bypass event to transition to bypass mode. */
5034 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5039 printf("\t Failed to set bypass event for port = %d.\n",
5043 cmdline_parse_token_string_t cmd_setbypass_event_set =
5044 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5046 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5047 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5049 cmdline_parse_token_string_t cmd_setbypass_event_event =
5050 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5052 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5053 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5054 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5055 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5056 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5058 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5059 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5060 mode_value, "normal#bypass#isolate");
5061 cmdline_parse_token_num_t cmd_setbypass_event_port =
5062 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5065 cmdline_parse_inst_t cmd_set_bypass_event = {
5066 .f = cmd_set_bypass_event_parsed,
5067 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5068 "power_off mode normal|bypass|isolate <port_id>: "
5069 "Set the NIC bypass event mode for port_id",
5072 (void *)&cmd_setbypass_event_set,
5073 (void *)&cmd_setbypass_event_bypass,
5074 (void *)&cmd_setbypass_event_event,
5075 (void *)&cmd_setbypass_event_event_value,
5076 (void *)&cmd_setbypass_event_mode,
5077 (void *)&cmd_setbypass_event_mode_value,
5078 (void *)&cmd_setbypass_event_port,
5084 /* *** SET NIC BYPASS TIMEOUT *** */
5085 struct cmd_set_bypass_timeout_result {
5086 cmdline_fixed_string_t set;
5087 cmdline_fixed_string_t bypass;
5088 cmdline_fixed_string_t timeout;
5089 cmdline_fixed_string_t value;
5093 cmd_set_bypass_timeout_parsed(void *parsed_result,
5094 __attribute__((unused)) struct cmdline *cl,
5095 __attribute__((unused)) void *data)
5097 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5099 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5100 if (!strcmp(res->value, "1.5"))
5101 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5102 else if (!strcmp(res->value, "2"))
5103 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5104 else if (!strcmp(res->value, "3"))
5105 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5106 else if (!strcmp(res->value, "4"))
5107 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5108 else if (!strcmp(res->value, "8"))
5109 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5110 else if (!strcmp(res->value, "16"))
5111 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5112 else if (!strcmp(res->value, "32"))
5113 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5115 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5119 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5120 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5122 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5123 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5125 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5126 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5127 timeout, "timeout");
5128 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5129 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5130 value, "0#1.5#2#3#4#8#16#32");
5132 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5133 .f = cmd_set_bypass_timeout_parsed,
5134 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5135 "Set the NIC bypass watchdog timeout in seconds",
5138 (void *)&cmd_setbypass_timeout_set,
5139 (void *)&cmd_setbypass_timeout_bypass,
5140 (void *)&cmd_setbypass_timeout_timeout,
5141 (void *)&cmd_setbypass_timeout_value,
5146 /* *** SHOW NIC BYPASS MODE *** */
5147 struct cmd_show_bypass_config_result {
5148 cmdline_fixed_string_t show;
5149 cmdline_fixed_string_t bypass;
5150 cmdline_fixed_string_t config;
5155 cmd_show_bypass_config_parsed(void *parsed_result,
5156 __attribute__((unused)) struct cmdline *cl,
5157 __attribute__((unused)) void *data)
5159 struct cmd_show_bypass_config_result *res = parsed_result;
5160 portid_t port_id = res->port_id;
5162 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5163 uint32_t event_mode;
5164 uint32_t bypass_mode;
5165 uint32_t timeout = bypass_timeout;
5168 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5169 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5170 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5171 {"UNKNOWN", "normal", "bypass", "isolate"};
5172 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5179 int num_events = (sizeof events) / (sizeof events[0]);
5181 /* Display the bypass mode.*/
5182 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5183 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5187 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5188 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5190 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5193 /* Display the bypass timeout.*/
5194 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5195 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5197 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5199 /* Display the bypass events and associated modes. */
5200 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5202 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5203 printf("\tFailed to get bypass mode for event = %s\n",
5206 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5207 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5209 printf("\tbypass event: %-16s = %s\n", events[i],
5215 printf("\tFailed to get bypass configuration for port = %d\n",
5219 cmdline_parse_token_string_t cmd_showbypass_config_show =
5220 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5222 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5223 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5225 cmdline_parse_token_string_t cmd_showbypass_config_config =
5226 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5228 cmdline_parse_token_num_t cmd_showbypass_config_port =
5229 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5232 cmdline_parse_inst_t cmd_show_bypass_config = {
5233 .f = cmd_show_bypass_config_parsed,
5234 .help_str = "show bypass config <port_id>: "
5235 "Show the NIC bypass config for port_id",
5238 (void *)&cmd_showbypass_config_show,
5239 (void *)&cmd_showbypass_config_bypass,
5240 (void *)&cmd_showbypass_config_config,
5241 (void *)&cmd_showbypass_config_port,
5246 #ifdef RTE_LIBRTE_PMD_BOND
5247 /* *** SET BONDING MODE *** */
5248 struct cmd_set_bonding_mode_result {
5249 cmdline_fixed_string_t set;
5250 cmdline_fixed_string_t bonding;
5251 cmdline_fixed_string_t mode;
5256 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5257 __attribute__((unused)) struct cmdline *cl,
5258 __attribute__((unused)) void *data)
5260 struct cmd_set_bonding_mode_result *res = parsed_result;
5261 portid_t port_id = res->port_id;
5263 /* Set the bonding mode for the relevant port. */
5264 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5265 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5268 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5269 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5271 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5272 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5273 bonding, "bonding");
5274 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5275 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5277 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5278 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5280 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5281 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5284 cmdline_parse_inst_t cmd_set_bonding_mode = {
5285 .f = cmd_set_bonding_mode_parsed,
5286 .help_str = "set bonding mode <mode_value> <port_id>: "
5287 "Set the bonding mode for port_id",
5290 (void *) &cmd_setbonding_mode_set,
5291 (void *) &cmd_setbonding_mode_bonding,
5292 (void *) &cmd_setbonding_mode_mode,
5293 (void *) &cmd_setbonding_mode_value,
5294 (void *) &cmd_setbonding_mode_port,
5299 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5300 struct cmd_set_bonding_lacp_dedicated_queues_result {
5301 cmdline_fixed_string_t set;
5302 cmdline_fixed_string_t bonding;
5303 cmdline_fixed_string_t lacp;
5304 cmdline_fixed_string_t dedicated_queues;
5306 cmdline_fixed_string_t mode;
5309 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5310 __attribute__((unused)) struct cmdline *cl,
5311 __attribute__((unused)) void *data)
5313 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5314 portid_t port_id = res->port_id;
5315 struct rte_port *port;
5317 port = &ports[port_id];
5319 /** Check if the port is not started **/
5320 if (port->port_status != RTE_PORT_STOPPED) {
5321 printf("Please stop port %d first\n", port_id);
5325 if (!strcmp(res->mode, "enable")) {
5326 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5327 printf("Dedicate queues for LACP control packets"
5330 printf("Enabling dedicate queues for LACP control "
5331 "packets on port %d failed\n", port_id);
5332 } else if (!strcmp(res->mode, "disable")) {
5333 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5334 printf("Dedicated queues for LACP control packets "
5337 printf("Disabling dedicated queues for LACP control "
5338 "traffic on port %d failed\n", port_id);
5342 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5343 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5345 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5346 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5347 bonding, "bonding");
5348 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5349 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5351 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5352 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5353 dedicated_queues, "dedicated_queues");
5354 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5355 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5357 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5358 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5359 mode, "enable#disable");
5361 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5362 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5363 .help_str = "set bonding lacp dedicated_queues <port_id> "
5365 "Enable/disable dedicated queues for LACP control traffic for port_id",
5368 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5369 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5370 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5371 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5372 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5373 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5378 /* *** SET BALANCE XMIT POLICY *** */
5379 struct cmd_set_bonding_balance_xmit_policy_result {
5380 cmdline_fixed_string_t set;
5381 cmdline_fixed_string_t bonding;
5382 cmdline_fixed_string_t balance_xmit_policy;
5384 cmdline_fixed_string_t policy;
5387 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5388 __attribute__((unused)) struct cmdline *cl,
5389 __attribute__((unused)) void *data)
5391 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5392 portid_t port_id = res->port_id;
5395 if (!strcmp(res->policy, "l2")) {
5396 policy = BALANCE_XMIT_POLICY_LAYER2;
5397 } else if (!strcmp(res->policy, "l23")) {
5398 policy = BALANCE_XMIT_POLICY_LAYER23;
5399 } else if (!strcmp(res->policy, "l34")) {
5400 policy = BALANCE_XMIT_POLICY_LAYER34;
5402 printf("\t Invalid xmit policy selection");
5406 /* Set the bonding mode for the relevant port. */
5407 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5408 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5413 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5414 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5416 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5417 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5418 bonding, "bonding");
5419 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5420 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5421 balance_xmit_policy, "balance_xmit_policy");
5422 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5423 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5425 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5426 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5427 policy, "l2#l23#l34");
5429 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5430 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5431 .help_str = "set bonding balance_xmit_policy <port_id> "
5433 "Set the bonding balance_xmit_policy for port_id",
5436 (void *)&cmd_setbonding_balance_xmit_policy_set,
5437 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5438 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5439 (void *)&cmd_setbonding_balance_xmit_policy_port,
5440 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5445 /* *** SHOW NIC BONDING CONFIGURATION *** */
5446 struct cmd_show_bonding_config_result {
5447 cmdline_fixed_string_t show;
5448 cmdline_fixed_string_t bonding;
5449 cmdline_fixed_string_t config;
5453 static void cmd_show_bonding_config_parsed(void *parsed_result,
5454 __attribute__((unused)) struct cmdline *cl,
5455 __attribute__((unused)) void *data)
5457 struct cmd_show_bonding_config_result *res = parsed_result;
5458 int bonding_mode, agg_mode;
5459 portid_t slaves[RTE_MAX_ETHPORTS];
5460 int num_slaves, num_active_slaves;
5463 portid_t port_id = res->port_id;
5465 /* Display the bonding mode.*/
5466 bonding_mode = rte_eth_bond_mode_get(port_id);
5467 if (bonding_mode < 0) {
5468 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5471 printf("\tBonding mode: %d\n", bonding_mode);
5473 if (bonding_mode == BONDING_MODE_BALANCE) {
5474 int balance_xmit_policy;
5476 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5477 if (balance_xmit_policy < 0) {
5478 printf("\tFailed to get balance xmit policy for port = %d\n",
5482 printf("\tBalance Xmit Policy: ");
5484 switch (balance_xmit_policy) {
5485 case BALANCE_XMIT_POLICY_LAYER2:
5486 printf("BALANCE_XMIT_POLICY_LAYER2");
5488 case BALANCE_XMIT_POLICY_LAYER23:
5489 printf("BALANCE_XMIT_POLICY_LAYER23");
5491 case BALANCE_XMIT_POLICY_LAYER34:
5492 printf("BALANCE_XMIT_POLICY_LAYER34");
5499 if (bonding_mode == BONDING_MODE_8023AD) {
5500 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5501 printf("\tIEEE802.3AD Aggregator Mode: ");
5504 printf("bandwidth");
5516 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5518 if (num_slaves < 0) {
5519 printf("\tFailed to get slave list for port = %d\n", port_id);
5522 if (num_slaves > 0) {
5523 printf("\tSlaves (%d): [", num_slaves);
5524 for (i = 0; i < num_slaves - 1; i++)
5525 printf("%d ", slaves[i]);
5527 printf("%d]\n", slaves[num_slaves - 1]);
5529 printf("\tSlaves: []\n");
5533 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5536 if (num_active_slaves < 0) {
5537 printf("\tFailed to get active slave list for port = %d\n", port_id);
5540 if (num_active_slaves > 0) {
5541 printf("\tActive Slaves (%d): [", num_active_slaves);
5542 for (i = 0; i < num_active_slaves - 1; i++)
5543 printf("%d ", slaves[i]);
5545 printf("%d]\n", slaves[num_active_slaves - 1]);
5548 printf("\tActive Slaves: []\n");
5552 primary_id = rte_eth_bond_primary_get(port_id);
5553 if (primary_id < 0) {
5554 printf("\tFailed to get primary slave for port = %d\n", port_id);
5557 printf("\tPrimary: [%d]\n", primary_id);
5561 cmdline_parse_token_string_t cmd_showbonding_config_show =
5562 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5564 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5565 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5566 bonding, "bonding");
5567 cmdline_parse_token_string_t cmd_showbonding_config_config =
5568 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5570 cmdline_parse_token_num_t cmd_showbonding_config_port =
5571 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5574 cmdline_parse_inst_t cmd_show_bonding_config = {
5575 .f = cmd_show_bonding_config_parsed,
5576 .help_str = "show bonding config <port_id>: "
5577 "Show the bonding config for port_id",
5580 (void *)&cmd_showbonding_config_show,
5581 (void *)&cmd_showbonding_config_bonding,
5582 (void *)&cmd_showbonding_config_config,
5583 (void *)&cmd_showbonding_config_port,
5588 /* *** SET BONDING PRIMARY *** */
5589 struct cmd_set_bonding_primary_result {
5590 cmdline_fixed_string_t set;
5591 cmdline_fixed_string_t bonding;
5592 cmdline_fixed_string_t primary;
5597 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5598 __attribute__((unused)) struct cmdline *cl,
5599 __attribute__((unused)) void *data)
5601 struct cmd_set_bonding_primary_result *res = parsed_result;
5602 portid_t master_port_id = res->port_id;
5603 portid_t slave_port_id = res->slave_id;
5605 /* Set the primary slave for a bonded device. */
5606 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5607 printf("\t Failed to set primary slave for port = %d.\n",
5614 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5615 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5617 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5618 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5619 bonding, "bonding");
5620 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5621 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5622 primary, "primary");
5623 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5624 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5626 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5627 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5630 cmdline_parse_inst_t cmd_set_bonding_primary = {
5631 .f = cmd_set_bonding_primary_parsed,
5632 .help_str = "set bonding primary <slave_id> <port_id>: "
5633 "Set the primary slave for port_id",
5636 (void *)&cmd_setbonding_primary_set,
5637 (void *)&cmd_setbonding_primary_bonding,
5638 (void *)&cmd_setbonding_primary_primary,
5639 (void *)&cmd_setbonding_primary_slave,
5640 (void *)&cmd_setbonding_primary_port,
5645 /* *** ADD SLAVE *** */
5646 struct cmd_add_bonding_slave_result {
5647 cmdline_fixed_string_t add;
5648 cmdline_fixed_string_t bonding;
5649 cmdline_fixed_string_t slave;
5654 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5655 __attribute__((unused)) struct cmdline *cl,
5656 __attribute__((unused)) void *data)
5658 struct cmd_add_bonding_slave_result *res = parsed_result;
5659 portid_t master_port_id = res->port_id;
5660 portid_t slave_port_id = res->slave_id;
5662 /* add the slave for a bonded device. */
5663 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5664 printf("\t Failed to add slave %d to master port = %d.\n",
5665 slave_port_id, master_port_id);
5669 set_port_slave_flag(slave_port_id);
5672 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5673 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5675 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5676 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5677 bonding, "bonding");
5678 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5679 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5681 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5682 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5684 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5685 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5688 cmdline_parse_inst_t cmd_add_bonding_slave = {
5689 .f = cmd_add_bonding_slave_parsed,
5690 .help_str = "add bonding slave <slave_id> <port_id>: "
5691 "Add a slave device to a bonded device",
5694 (void *)&cmd_addbonding_slave_add,
5695 (void *)&cmd_addbonding_slave_bonding,
5696 (void *)&cmd_addbonding_slave_slave,
5697 (void *)&cmd_addbonding_slave_slaveid,
5698 (void *)&cmd_addbonding_slave_port,
5703 /* *** REMOVE SLAVE *** */
5704 struct cmd_remove_bonding_slave_result {
5705 cmdline_fixed_string_t remove;
5706 cmdline_fixed_string_t bonding;
5707 cmdline_fixed_string_t slave;
5712 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5713 __attribute__((unused)) struct cmdline *cl,
5714 __attribute__((unused)) void *data)
5716 struct cmd_remove_bonding_slave_result *res = parsed_result;
5717 portid_t master_port_id = res->port_id;
5718 portid_t slave_port_id = res->slave_id;
5720 /* remove the slave from a bonded device. */
5721 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5722 printf("\t Failed to remove slave %d from master port = %d.\n",
5723 slave_port_id, master_port_id);
5727 clear_port_slave_flag(slave_port_id);
5730 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5731 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5733 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5734 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5735 bonding, "bonding");
5736 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5737 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5739 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5740 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5742 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5743 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5746 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5747 .f = cmd_remove_bonding_slave_parsed,
5748 .help_str = "remove bonding slave <slave_id> <port_id>: "
5749 "Remove a slave device from a bonded device",
5752 (void *)&cmd_removebonding_slave_remove,
5753 (void *)&cmd_removebonding_slave_bonding,
5754 (void *)&cmd_removebonding_slave_slave,
5755 (void *)&cmd_removebonding_slave_slaveid,
5756 (void *)&cmd_removebonding_slave_port,
5761 /* *** CREATE BONDED DEVICE *** */
5762 struct cmd_create_bonded_device_result {
5763 cmdline_fixed_string_t create;
5764 cmdline_fixed_string_t bonded;
5765 cmdline_fixed_string_t device;
5770 static int bond_dev_num = 0;
5772 static void cmd_create_bonded_device_parsed(void *parsed_result,
5773 __attribute__((unused)) struct cmdline *cl,
5774 __attribute__((unused)) void *data)
5776 struct cmd_create_bonded_device_result *res = parsed_result;
5777 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5780 if (test_done == 0) {
5781 printf("Please stop forwarding first\n");
5785 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5788 /* Create a new bonded device. */
5789 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5791 printf("\t Failed to create bonded device.\n");
5794 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5797 /* Update number of ports */
5798 nb_ports = rte_eth_dev_count_avail();
5799 reconfig(port_id, res->socket);
5800 rte_eth_promiscuous_enable(port_id);
5805 cmdline_parse_token_string_t cmd_createbonded_device_create =
5806 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5808 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5809 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5811 cmdline_parse_token_string_t cmd_createbonded_device_device =
5812 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5814 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5815 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5817 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5818 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5821 cmdline_parse_inst_t cmd_create_bonded_device = {
5822 .f = cmd_create_bonded_device_parsed,
5823 .help_str = "create bonded device <mode> <socket>: "
5824 "Create a new bonded device with specific bonding mode and socket",
5827 (void *)&cmd_createbonded_device_create,
5828 (void *)&cmd_createbonded_device_bonded,
5829 (void *)&cmd_createbonded_device_device,
5830 (void *)&cmd_createbonded_device_mode,
5831 (void *)&cmd_createbonded_device_socket,
5836 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5837 struct cmd_set_bond_mac_addr_result {
5838 cmdline_fixed_string_t set;
5839 cmdline_fixed_string_t bonding;
5840 cmdline_fixed_string_t mac_addr;
5842 struct ether_addr address;
5845 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5846 __attribute__((unused)) struct cmdline *cl,
5847 __attribute__((unused)) void *data)
5849 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5852 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5855 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5857 /* check the return value and print it if is < 0 */
5859 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5862 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5863 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5864 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5865 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5867 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5868 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5870 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5871 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5873 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5874 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5876 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5877 .f = cmd_set_bond_mac_addr_parsed,
5879 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5881 (void *)&cmd_set_bond_mac_addr_set,
5882 (void *)&cmd_set_bond_mac_addr_bonding,
5883 (void *)&cmd_set_bond_mac_addr_mac,
5884 (void *)&cmd_set_bond_mac_addr_portnum,
5885 (void *)&cmd_set_bond_mac_addr_addr,
5891 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5892 struct cmd_set_bond_mon_period_result {
5893 cmdline_fixed_string_t set;
5894 cmdline_fixed_string_t bonding;
5895 cmdline_fixed_string_t mon_period;
5900 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5901 __attribute__((unused)) struct cmdline *cl,
5902 __attribute__((unused)) void *data)
5904 struct cmd_set_bond_mon_period_result *res = parsed_result;
5907 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5909 /* check the return value and print it if is < 0 */
5911 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5914 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5915 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5917 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5918 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5919 bonding, "bonding");
5920 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5921 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5922 mon_period, "mon_period");
5923 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5924 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5926 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5927 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5930 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5931 .f = cmd_set_bond_mon_period_parsed,
5933 .help_str = "set bonding mon_period <port_id> <period_ms>",
5935 (void *)&cmd_set_bond_mon_period_set,
5936 (void *)&cmd_set_bond_mon_period_bonding,
5937 (void *)&cmd_set_bond_mon_period_mon_period,
5938 (void *)&cmd_set_bond_mon_period_portnum,
5939 (void *)&cmd_set_bond_mon_period_period_ms,
5946 struct cmd_set_bonding_agg_mode_policy_result {
5947 cmdline_fixed_string_t set;
5948 cmdline_fixed_string_t bonding;
5949 cmdline_fixed_string_t agg_mode;
5951 cmdline_fixed_string_t policy;
5956 cmd_set_bonding_agg_mode(void *parsed_result,
5957 __attribute__((unused)) struct cmdline *cl,
5958 __attribute__((unused)) void *data)
5960 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5961 uint8_t policy = AGG_BANDWIDTH;
5963 if (!strcmp(res->policy, "bandwidth"))
5964 policy = AGG_BANDWIDTH;
5965 else if (!strcmp(res->policy, "stable"))
5966 policy = AGG_STABLE;
5967 else if (!strcmp(res->policy, "count"))
5970 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
5974 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
5975 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5977 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
5978 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5979 bonding, "bonding");
5981 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
5982 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5983 agg_mode, "agg_mode");
5985 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
5986 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
5989 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
5990 TOKEN_STRING_INITIALIZER(
5991 struct cmd_set_bonding_balance_xmit_policy_result,
5992 policy, "stable#bandwidth#count");
5994 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
5995 .f = cmd_set_bonding_agg_mode,
5997 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
5999 (void *)&cmd_set_bonding_agg_mode_set,
6000 (void *)&cmd_set_bonding_agg_mode_bonding,
6001 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6002 (void *)&cmd_set_bonding_agg_mode_portnum,
6003 (void *)&cmd_set_bonding_agg_mode_policy_string,
6009 #endif /* RTE_LIBRTE_PMD_BOND */
6011 /* *** SET FORWARDING MODE *** */
6012 struct cmd_set_fwd_mode_result {
6013 cmdline_fixed_string_t set;
6014 cmdline_fixed_string_t fwd;
6015 cmdline_fixed_string_t mode;
6018 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6019 __attribute__((unused)) struct cmdline *cl,
6020 __attribute__((unused)) void *data)
6022 struct cmd_set_fwd_mode_result *res = parsed_result;
6025 set_pkt_forwarding_mode(res->mode);
6028 cmdline_parse_token_string_t cmd_setfwd_set =
6029 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6030 cmdline_parse_token_string_t cmd_setfwd_fwd =
6031 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6032 cmdline_parse_token_string_t cmd_setfwd_mode =
6033 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6034 "" /* defined at init */);
6036 cmdline_parse_inst_t cmd_set_fwd_mode = {
6037 .f = cmd_set_fwd_mode_parsed,
6039 .help_str = NULL, /* defined at init */
6041 (void *)&cmd_setfwd_set,
6042 (void *)&cmd_setfwd_fwd,
6043 (void *)&cmd_setfwd_mode,
6048 static void cmd_set_fwd_mode_init(void)
6051 static char token[128];
6052 static char help[256];
6053 cmdline_parse_token_string_t *token_struct;
6055 modes = list_pkt_forwarding_modes();
6056 snprintf(help, sizeof(help), "set fwd %s: "
6057 "Set packet forwarding mode", modes);
6058 cmd_set_fwd_mode.help_str = help;
6060 /* string token separator is # */
6061 for (c = token; *modes != '\0'; modes++)
6066 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6067 token_struct->string_data.str = token;
6070 /* *** SET RETRY FORWARDING MODE *** */
6071 struct cmd_set_fwd_retry_mode_result {
6072 cmdline_fixed_string_t set;
6073 cmdline_fixed_string_t fwd;
6074 cmdline_fixed_string_t mode;
6075 cmdline_fixed_string_t retry;
6078 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6079 __attribute__((unused)) struct cmdline *cl,
6080 __attribute__((unused)) void *data)
6082 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6085 set_pkt_forwarding_mode(res->mode);
6088 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6089 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6091 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6092 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6094 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6095 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6097 "" /* defined at init */);
6098 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6099 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6102 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6103 .f = cmd_set_fwd_retry_mode_parsed,
6105 .help_str = NULL, /* defined at init */
6107 (void *)&cmd_setfwd_retry_set,
6108 (void *)&cmd_setfwd_retry_fwd,
6109 (void *)&cmd_setfwd_retry_mode,
6110 (void *)&cmd_setfwd_retry_retry,
6115 static void cmd_set_fwd_retry_mode_init(void)
6118 static char token[128];
6119 static char help[256];
6120 cmdline_parse_token_string_t *token_struct;
6122 modes = list_pkt_forwarding_retry_modes();
6123 snprintf(help, sizeof(help), "set fwd %s retry: "
6124 "Set packet forwarding mode with retry", modes);
6125 cmd_set_fwd_retry_mode.help_str = help;
6127 /* string token separator is # */
6128 for (c = token; *modes != '\0'; modes++)
6133 token_struct = (cmdline_parse_token_string_t *)
6134 cmd_set_fwd_retry_mode.tokens[2];
6135 token_struct->string_data.str = token;
6138 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6139 struct cmd_set_burst_tx_retry_result {
6140 cmdline_fixed_string_t set;
6141 cmdline_fixed_string_t burst;
6142 cmdline_fixed_string_t tx;
6143 cmdline_fixed_string_t delay;
6145 cmdline_fixed_string_t retry;
6149 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6150 __attribute__((unused)) struct cmdline *cl,
6151 __attribute__((unused)) void *data)
6153 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6155 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6156 && !strcmp(res->tx, "tx")) {
6157 if (!strcmp(res->delay, "delay"))
6158 burst_tx_delay_time = res->time;
6159 if (!strcmp(res->retry, "retry"))
6160 burst_tx_retry_num = res->retry_num;
6165 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6166 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6167 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6168 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6170 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6171 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6172 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6173 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6174 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6175 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6176 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6177 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6178 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6179 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6181 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6182 .f = cmd_set_burst_tx_retry_parsed,
6183 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6185 (void *)&cmd_set_burst_tx_retry_set,
6186 (void *)&cmd_set_burst_tx_retry_burst,
6187 (void *)&cmd_set_burst_tx_retry_tx,
6188 (void *)&cmd_set_burst_tx_retry_delay,
6189 (void *)&cmd_set_burst_tx_retry_time,
6190 (void *)&cmd_set_burst_tx_retry_retry,
6191 (void *)&cmd_set_burst_tx_retry_retry_num,
6196 /* *** SET PROMISC MODE *** */
6197 struct cmd_set_promisc_mode_result {
6198 cmdline_fixed_string_t set;
6199 cmdline_fixed_string_t promisc;
6200 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6201 uint16_t port_num; /* valid if "allports" argument == 0 */
6202 cmdline_fixed_string_t mode;
6205 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6206 __attribute__((unused)) struct cmdline *cl,
6209 struct cmd_set_promisc_mode_result *res = parsed_result;
6213 if (!strcmp(res->mode, "on"))
6220 RTE_ETH_FOREACH_DEV(i) {
6222 rte_eth_promiscuous_enable(i);
6224 rte_eth_promiscuous_disable(i);
6229 rte_eth_promiscuous_enable(res->port_num);
6231 rte_eth_promiscuous_disable(res->port_num);
6235 cmdline_parse_token_string_t cmd_setpromisc_set =
6236 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6237 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6238 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6240 cmdline_parse_token_string_t cmd_setpromisc_portall =
6241 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6243 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6244 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6246 cmdline_parse_token_string_t cmd_setpromisc_mode =
6247 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6250 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6251 .f = cmd_set_promisc_mode_parsed,
6253 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6255 (void *)&cmd_setpromisc_set,
6256 (void *)&cmd_setpromisc_promisc,
6257 (void *)&cmd_setpromisc_portall,
6258 (void *)&cmd_setpromisc_mode,
6263 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6264 .f = cmd_set_promisc_mode_parsed,
6266 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6268 (void *)&cmd_setpromisc_set,
6269 (void *)&cmd_setpromisc_promisc,
6270 (void *)&cmd_setpromisc_portnum,
6271 (void *)&cmd_setpromisc_mode,
6276 /* *** SET ALLMULTI MODE *** */
6277 struct cmd_set_allmulti_mode_result {
6278 cmdline_fixed_string_t set;
6279 cmdline_fixed_string_t allmulti;
6280 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6281 uint16_t port_num; /* valid if "allports" argument == 0 */
6282 cmdline_fixed_string_t mode;
6285 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6286 __attribute__((unused)) struct cmdline *cl,
6289 struct cmd_set_allmulti_mode_result *res = parsed_result;
6293 if (!strcmp(res->mode, "on"))
6300 RTE_ETH_FOREACH_DEV(i) {
6302 rte_eth_allmulticast_enable(i);
6304 rte_eth_allmulticast_disable(i);
6309 rte_eth_allmulticast_enable(res->port_num);
6311 rte_eth_allmulticast_disable(res->port_num);
6315 cmdline_parse_token_string_t cmd_setallmulti_set =
6316 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6317 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6318 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6320 cmdline_parse_token_string_t cmd_setallmulti_portall =
6321 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6323 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6324 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6326 cmdline_parse_token_string_t cmd_setallmulti_mode =
6327 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6330 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6331 .f = cmd_set_allmulti_mode_parsed,
6333 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6335 (void *)&cmd_setallmulti_set,
6336 (void *)&cmd_setallmulti_allmulti,
6337 (void *)&cmd_setallmulti_portall,
6338 (void *)&cmd_setallmulti_mode,
6343 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6344 .f = cmd_set_allmulti_mode_parsed,
6346 .help_str = "set allmulti <port_id> on|off: "
6347 "Set allmulti mode on port_id",
6349 (void *)&cmd_setallmulti_set,
6350 (void *)&cmd_setallmulti_allmulti,
6351 (void *)&cmd_setallmulti_portnum,
6352 (void *)&cmd_setallmulti_mode,
6357 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6358 struct cmd_link_flow_ctrl_set_result {
6359 cmdline_fixed_string_t set;
6360 cmdline_fixed_string_t flow_ctrl;
6361 cmdline_fixed_string_t rx;
6362 cmdline_fixed_string_t rx_lfc_mode;
6363 cmdline_fixed_string_t tx;
6364 cmdline_fixed_string_t tx_lfc_mode;
6365 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6366 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6367 cmdline_fixed_string_t autoneg_str;
6368 cmdline_fixed_string_t autoneg;
6369 cmdline_fixed_string_t hw_str;
6370 uint32_t high_water;
6371 cmdline_fixed_string_t lw_str;
6373 cmdline_fixed_string_t pt_str;
6374 uint16_t pause_time;
6375 cmdline_fixed_string_t xon_str;
6380 cmdline_parse_token_string_t cmd_lfc_set_set =
6381 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6383 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6384 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6385 flow_ctrl, "flow_ctrl");
6386 cmdline_parse_token_string_t cmd_lfc_set_rx =
6387 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6389 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6390 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6391 rx_lfc_mode, "on#off");
6392 cmdline_parse_token_string_t cmd_lfc_set_tx =
6393 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6395 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6396 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6397 tx_lfc_mode, "on#off");
6398 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6399 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6400 hw_str, "high_water");
6401 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6402 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6403 high_water, UINT32);
6404 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6405 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6406 lw_str, "low_water");
6407 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6408 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6410 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6411 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6412 pt_str, "pause_time");
6413 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6414 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6415 pause_time, UINT16);
6416 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6417 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6418 xon_str, "send_xon");
6419 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6420 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6422 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6423 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6424 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6425 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6426 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6427 mac_ctrl_frame_fwd_mode, "on#off");
6428 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6429 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6430 autoneg_str, "autoneg");
6431 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6432 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6434 cmdline_parse_token_num_t cmd_lfc_set_portid =
6435 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6438 /* forward declaration */
6440 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6443 cmdline_parse_inst_t cmd_link_flow_control_set = {
6444 .f = cmd_link_flow_ctrl_set_parsed,
6446 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6447 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6448 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6450 (void *)&cmd_lfc_set_set,
6451 (void *)&cmd_lfc_set_flow_ctrl,
6452 (void *)&cmd_lfc_set_rx,
6453 (void *)&cmd_lfc_set_rx_mode,
6454 (void *)&cmd_lfc_set_tx,
6455 (void *)&cmd_lfc_set_tx_mode,
6456 (void *)&cmd_lfc_set_high_water,
6457 (void *)&cmd_lfc_set_low_water,
6458 (void *)&cmd_lfc_set_pause_time,
6459 (void *)&cmd_lfc_set_send_xon,
6460 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6461 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6462 (void *)&cmd_lfc_set_autoneg_str,
6463 (void *)&cmd_lfc_set_autoneg,
6464 (void *)&cmd_lfc_set_portid,
6469 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6470 .f = cmd_link_flow_ctrl_set_parsed,
6471 .data = (void *)&cmd_link_flow_control_set_rx,
6472 .help_str = "set flow_ctrl rx on|off <port_id>: "
6473 "Change rx flow control parameter",
6475 (void *)&cmd_lfc_set_set,
6476 (void *)&cmd_lfc_set_flow_ctrl,
6477 (void *)&cmd_lfc_set_rx,
6478 (void *)&cmd_lfc_set_rx_mode,
6479 (void *)&cmd_lfc_set_portid,
6484 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6485 .f = cmd_link_flow_ctrl_set_parsed,
6486 .data = (void *)&cmd_link_flow_control_set_tx,
6487 .help_str = "set flow_ctrl tx on|off <port_id>: "
6488 "Change tx flow control parameter",
6490 (void *)&cmd_lfc_set_set,
6491 (void *)&cmd_lfc_set_flow_ctrl,
6492 (void *)&cmd_lfc_set_tx,
6493 (void *)&cmd_lfc_set_tx_mode,
6494 (void *)&cmd_lfc_set_portid,
6499 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6500 .f = cmd_link_flow_ctrl_set_parsed,
6501 .data = (void *)&cmd_link_flow_control_set_hw,
6502 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6503 "Change high water flow control parameter",
6505 (void *)&cmd_lfc_set_set,
6506 (void *)&cmd_lfc_set_flow_ctrl,
6507 (void *)&cmd_lfc_set_high_water_str,
6508 (void *)&cmd_lfc_set_high_water,
6509 (void *)&cmd_lfc_set_portid,
6514 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6515 .f = cmd_link_flow_ctrl_set_parsed,
6516 .data = (void *)&cmd_link_flow_control_set_lw,
6517 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6518 "Change low water flow control parameter",
6520 (void *)&cmd_lfc_set_set,
6521 (void *)&cmd_lfc_set_flow_ctrl,
6522 (void *)&cmd_lfc_set_low_water_str,
6523 (void *)&cmd_lfc_set_low_water,
6524 (void *)&cmd_lfc_set_portid,
6529 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6530 .f = cmd_link_flow_ctrl_set_parsed,
6531 .data = (void *)&cmd_link_flow_control_set_pt,
6532 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6533 "Change pause time flow control parameter",
6535 (void *)&cmd_lfc_set_set,
6536 (void *)&cmd_lfc_set_flow_ctrl,
6537 (void *)&cmd_lfc_set_pause_time_str,
6538 (void *)&cmd_lfc_set_pause_time,
6539 (void *)&cmd_lfc_set_portid,
6544 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6545 .f = cmd_link_flow_ctrl_set_parsed,
6546 .data = (void *)&cmd_link_flow_control_set_xon,
6547 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6548 "Change send_xon flow control parameter",
6550 (void *)&cmd_lfc_set_set,
6551 (void *)&cmd_lfc_set_flow_ctrl,
6552 (void *)&cmd_lfc_set_send_xon_str,
6553 (void *)&cmd_lfc_set_send_xon,
6554 (void *)&cmd_lfc_set_portid,
6559 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6560 .f = cmd_link_flow_ctrl_set_parsed,
6561 .data = (void *)&cmd_link_flow_control_set_macfwd,
6562 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6563 "Change mac ctrl fwd flow control parameter",
6565 (void *)&cmd_lfc_set_set,
6566 (void *)&cmd_lfc_set_flow_ctrl,
6567 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6568 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6569 (void *)&cmd_lfc_set_portid,
6574 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6575 .f = cmd_link_flow_ctrl_set_parsed,
6576 .data = (void *)&cmd_link_flow_control_set_autoneg,
6577 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6578 "Change autoneg flow control parameter",
6580 (void *)&cmd_lfc_set_set,
6581 (void *)&cmd_lfc_set_flow_ctrl,
6582 (void *)&cmd_lfc_set_autoneg_str,
6583 (void *)&cmd_lfc_set_autoneg,
6584 (void *)&cmd_lfc_set_portid,
6590 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6591 __attribute__((unused)) struct cmdline *cl,
6594 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6595 cmdline_parse_inst_t *cmd = data;
6596 struct rte_eth_fc_conf fc_conf;
6602 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6603 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6604 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6605 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6607 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6608 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6611 /* Partial command line, retrieve current configuration */
6613 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6615 printf("cannot get current flow ctrl parameters, return"
6616 "code = %d\n", ret);
6620 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6621 (fc_conf.mode == RTE_FC_FULL))
6623 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6624 (fc_conf.mode == RTE_FC_FULL))
6628 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6629 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6631 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6632 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6634 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6636 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6637 fc_conf.high_water = res->high_water;
6639 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6640 fc_conf.low_water = res->low_water;
6642 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6643 fc_conf.pause_time = res->pause_time;
6645 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6646 fc_conf.send_xon = res->send_xon;
6648 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6649 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6650 fc_conf.mac_ctrl_frame_fwd = 1;
6652 fc_conf.mac_ctrl_frame_fwd = 0;
6655 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6656 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6658 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6660 printf("bad flow contrl parameter, return code = %d \n", ret);
6663 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6664 struct cmd_priority_flow_ctrl_set_result {
6665 cmdline_fixed_string_t set;
6666 cmdline_fixed_string_t pfc_ctrl;
6667 cmdline_fixed_string_t rx;
6668 cmdline_fixed_string_t rx_pfc_mode;
6669 cmdline_fixed_string_t tx;
6670 cmdline_fixed_string_t tx_pfc_mode;
6671 uint32_t high_water;
6673 uint16_t pause_time;
6679 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6680 __attribute__((unused)) struct cmdline *cl,
6681 __attribute__((unused)) void *data)
6683 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6684 struct rte_eth_pfc_conf pfc_conf;
6685 int rx_fc_enable, tx_fc_enable;
6689 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6690 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6691 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6692 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6694 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6695 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6698 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6699 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6700 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6701 pfc_conf.fc.high_water = res->high_water;
6702 pfc_conf.fc.low_water = res->low_water;
6703 pfc_conf.fc.pause_time = res->pause_time;
6704 pfc_conf.priority = res->priority;
6706 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6708 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6711 cmdline_parse_token_string_t cmd_pfc_set_set =
6712 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6714 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6715 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6716 pfc_ctrl, "pfc_ctrl");
6717 cmdline_parse_token_string_t cmd_pfc_set_rx =
6718 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6720 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6721 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6722 rx_pfc_mode, "on#off");
6723 cmdline_parse_token_string_t cmd_pfc_set_tx =
6724 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6726 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6727 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6728 tx_pfc_mode, "on#off");
6729 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6730 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6731 high_water, UINT32);
6732 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6733 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6735 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6736 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6737 pause_time, UINT16);
6738 cmdline_parse_token_num_t cmd_pfc_set_priority =
6739 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6741 cmdline_parse_token_num_t cmd_pfc_set_portid =
6742 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6745 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6746 .f = cmd_priority_flow_ctrl_set_parsed,
6748 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6749 "<pause_time> <priority> <port_id>: "
6750 "Configure the Ethernet priority flow control",
6752 (void *)&cmd_pfc_set_set,
6753 (void *)&cmd_pfc_set_flow_ctrl,
6754 (void *)&cmd_pfc_set_rx,
6755 (void *)&cmd_pfc_set_rx_mode,
6756 (void *)&cmd_pfc_set_tx,
6757 (void *)&cmd_pfc_set_tx_mode,
6758 (void *)&cmd_pfc_set_high_water,
6759 (void *)&cmd_pfc_set_low_water,
6760 (void *)&cmd_pfc_set_pause_time,
6761 (void *)&cmd_pfc_set_priority,
6762 (void *)&cmd_pfc_set_portid,
6767 /* *** RESET CONFIGURATION *** */
6768 struct cmd_reset_result {
6769 cmdline_fixed_string_t reset;
6770 cmdline_fixed_string_t def;
6773 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6775 __attribute__((unused)) void *data)
6777 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6778 set_def_fwd_config();
6781 cmdline_parse_token_string_t cmd_reset_set =
6782 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6783 cmdline_parse_token_string_t cmd_reset_def =
6784 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6787 cmdline_parse_inst_t cmd_reset = {
6788 .f = cmd_reset_parsed,
6790 .help_str = "set default: Reset default forwarding configuration",
6792 (void *)&cmd_reset_set,
6793 (void *)&cmd_reset_def,
6798 /* *** START FORWARDING *** */
6799 struct cmd_start_result {
6800 cmdline_fixed_string_t start;
6803 cmdline_parse_token_string_t cmd_start_start =
6804 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6806 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6807 __attribute__((unused)) struct cmdline *cl,
6808 __attribute__((unused)) void *data)
6810 start_packet_forwarding(0);
6813 cmdline_parse_inst_t cmd_start = {
6814 .f = cmd_start_parsed,
6816 .help_str = "start: Start packet forwarding",
6818 (void *)&cmd_start_start,
6823 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6824 struct cmd_start_tx_first_result {
6825 cmdline_fixed_string_t start;
6826 cmdline_fixed_string_t tx_first;
6830 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6831 __attribute__((unused)) struct cmdline *cl,
6832 __attribute__((unused)) void *data)
6834 start_packet_forwarding(1);
6837 cmdline_parse_token_string_t cmd_start_tx_first_start =
6838 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6840 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6841 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6842 tx_first, "tx_first");
6844 cmdline_parse_inst_t cmd_start_tx_first = {
6845 .f = cmd_start_tx_first_parsed,
6847 .help_str = "start tx_first: Start packet forwarding, "
6848 "after sending 1 burst of packets",
6850 (void *)&cmd_start_tx_first_start,
6851 (void *)&cmd_start_tx_first_tx_first,
6856 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6857 struct cmd_start_tx_first_n_result {
6858 cmdline_fixed_string_t start;
6859 cmdline_fixed_string_t tx_first;
6864 cmd_start_tx_first_n_parsed(void *parsed_result,
6865 __attribute__((unused)) struct cmdline *cl,
6866 __attribute__((unused)) void *data)
6868 struct cmd_start_tx_first_n_result *res = parsed_result;
6870 start_packet_forwarding(res->tx_num);
6873 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6874 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6876 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6877 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6878 tx_first, "tx_first");
6879 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6880 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6883 cmdline_parse_inst_t cmd_start_tx_first_n = {
6884 .f = cmd_start_tx_first_n_parsed,
6886 .help_str = "start tx_first <num>: "
6887 "packet forwarding, after sending <num> bursts of packets",
6889 (void *)&cmd_start_tx_first_n_start,
6890 (void *)&cmd_start_tx_first_n_tx_first,
6891 (void *)&cmd_start_tx_first_n_tx_num,
6896 /* *** SET LINK UP *** */
6897 struct cmd_set_link_up_result {
6898 cmdline_fixed_string_t set;
6899 cmdline_fixed_string_t link_up;
6900 cmdline_fixed_string_t port;
6904 cmdline_parse_token_string_t cmd_set_link_up_set =
6905 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6906 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6907 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6909 cmdline_parse_token_string_t cmd_set_link_up_port =
6910 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6911 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6912 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6914 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6915 __attribute__((unused)) struct cmdline *cl,
6916 __attribute__((unused)) void *data)
6918 struct cmd_set_link_up_result *res = parsed_result;
6919 dev_set_link_up(res->port_id);
6922 cmdline_parse_inst_t cmd_set_link_up = {
6923 .f = cmd_set_link_up_parsed,
6925 .help_str = "set link-up port <port id>",
6927 (void *)&cmd_set_link_up_set,
6928 (void *)&cmd_set_link_up_link_up,
6929 (void *)&cmd_set_link_up_port,
6930 (void *)&cmd_set_link_up_port_id,
6935 /* *** SET LINK DOWN *** */
6936 struct cmd_set_link_down_result {
6937 cmdline_fixed_string_t set;
6938 cmdline_fixed_string_t link_down;
6939 cmdline_fixed_string_t port;
6943 cmdline_parse_token_string_t cmd_set_link_down_set =
6944 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6945 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6946 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6948 cmdline_parse_token_string_t cmd_set_link_down_port =
6949 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6950 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6951 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6953 static void cmd_set_link_down_parsed(
6954 __attribute__((unused)) void *parsed_result,
6955 __attribute__((unused)) struct cmdline *cl,
6956 __attribute__((unused)) void *data)
6958 struct cmd_set_link_down_result *res = parsed_result;
6959 dev_set_link_down(res->port_id);
6962 cmdline_parse_inst_t cmd_set_link_down = {
6963 .f = cmd_set_link_down_parsed,
6965 .help_str = "set link-down port <port id>",
6967 (void *)&cmd_set_link_down_set,
6968 (void *)&cmd_set_link_down_link_down,
6969 (void *)&cmd_set_link_down_port,
6970 (void *)&cmd_set_link_down_port_id,
6975 /* *** SHOW CFG *** */
6976 struct cmd_showcfg_result {
6977 cmdline_fixed_string_t show;
6978 cmdline_fixed_string_t cfg;
6979 cmdline_fixed_string_t what;
6982 static void cmd_showcfg_parsed(void *parsed_result,
6983 __attribute__((unused)) struct cmdline *cl,
6984 __attribute__((unused)) void *data)
6986 struct cmd_showcfg_result *res = parsed_result;
6987 if (!strcmp(res->what, "rxtx"))
6988 rxtx_config_display();
6989 else if (!strcmp(res->what, "cores"))
6990 fwd_lcores_config_display();
6991 else if (!strcmp(res->what, "fwd"))
6992 pkt_fwd_config_display(&cur_fwd_config);
6993 else if (!strcmp(res->what, "txpkts"))
6994 show_tx_pkt_segments();
6997 cmdline_parse_token_string_t cmd_showcfg_show =
6998 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6999 cmdline_parse_token_string_t cmd_showcfg_port =
7000 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7001 cmdline_parse_token_string_t cmd_showcfg_what =
7002 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7003 "rxtx#cores#fwd#txpkts");
7005 cmdline_parse_inst_t cmd_showcfg = {
7006 .f = cmd_showcfg_parsed,
7008 .help_str = "show config rxtx|cores|fwd|txpkts",
7010 (void *)&cmd_showcfg_show,
7011 (void *)&cmd_showcfg_port,
7012 (void *)&cmd_showcfg_what,
7017 /* *** SHOW ALL PORT INFO *** */
7018 struct cmd_showportall_result {
7019 cmdline_fixed_string_t show;
7020 cmdline_fixed_string_t port;
7021 cmdline_fixed_string_t what;
7022 cmdline_fixed_string_t all;
7025 static void cmd_showportall_parsed(void *parsed_result,
7026 __attribute__((unused)) struct cmdline *cl,
7027 __attribute__((unused)) void *data)
7031 struct cmd_showportall_result *res = parsed_result;
7032 if (!strcmp(res->show, "clear")) {
7033 if (!strcmp(res->what, "stats"))
7034 RTE_ETH_FOREACH_DEV(i)
7036 else if (!strcmp(res->what, "xstats"))
7037 RTE_ETH_FOREACH_DEV(i)
7038 nic_xstats_clear(i);
7039 } else if (!strcmp(res->what, "info"))
7040 RTE_ETH_FOREACH_DEV(i)
7041 port_infos_display(i);
7042 else if (!strcmp(res->what, "stats"))
7043 RTE_ETH_FOREACH_DEV(i)
7044 nic_stats_display(i);
7045 else if (!strcmp(res->what, "xstats"))
7046 RTE_ETH_FOREACH_DEV(i)
7047 nic_xstats_display(i);
7048 else if (!strcmp(res->what, "fdir"))
7049 RTE_ETH_FOREACH_DEV(i)
7051 else if (!strcmp(res->what, "stat_qmap"))
7052 RTE_ETH_FOREACH_DEV(i)
7053 nic_stats_mapping_display(i);
7054 else if (!strcmp(res->what, "dcb_tc"))
7055 RTE_ETH_FOREACH_DEV(i)
7056 port_dcb_info_display(i);
7057 else if (!strcmp(res->what, "cap"))
7058 RTE_ETH_FOREACH_DEV(i)
7059 port_offload_cap_display(i);
7062 cmdline_parse_token_string_t cmd_showportall_show =
7063 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7065 cmdline_parse_token_string_t cmd_showportall_port =
7066 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7067 cmdline_parse_token_string_t cmd_showportall_what =
7068 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7069 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7070 cmdline_parse_token_string_t cmd_showportall_all =
7071 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7072 cmdline_parse_inst_t cmd_showportall = {
7073 .f = cmd_showportall_parsed,
7075 .help_str = "show|clear port "
7076 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7078 (void *)&cmd_showportall_show,
7079 (void *)&cmd_showportall_port,
7080 (void *)&cmd_showportall_what,
7081 (void *)&cmd_showportall_all,
7086 /* *** SHOW PORT INFO *** */
7087 struct cmd_showport_result {
7088 cmdline_fixed_string_t show;
7089 cmdline_fixed_string_t port;
7090 cmdline_fixed_string_t what;
7094 static void cmd_showport_parsed(void *parsed_result,
7095 __attribute__((unused)) struct cmdline *cl,
7096 __attribute__((unused)) void *data)
7098 struct cmd_showport_result *res = parsed_result;
7099 if (!strcmp(res->show, "clear")) {
7100 if (!strcmp(res->what, "stats"))
7101 nic_stats_clear(res->portnum);
7102 else if (!strcmp(res->what, "xstats"))
7103 nic_xstats_clear(res->portnum);
7104 } else if (!strcmp(res->what, "info"))
7105 port_infos_display(res->portnum);
7106 else if (!strcmp(res->what, "stats"))
7107 nic_stats_display(res->portnum);
7108 else if (!strcmp(res->what, "xstats"))
7109 nic_xstats_display(res->portnum);
7110 else if (!strcmp(res->what, "fdir"))
7111 fdir_get_infos(res->portnum);
7112 else if (!strcmp(res->what, "stat_qmap"))
7113 nic_stats_mapping_display(res->portnum);
7114 else if (!strcmp(res->what, "dcb_tc"))
7115 port_dcb_info_display(res->portnum);
7116 else if (!strcmp(res->what, "cap"))
7117 port_offload_cap_display(res->portnum);
7120 cmdline_parse_token_string_t cmd_showport_show =
7121 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7123 cmdline_parse_token_string_t cmd_showport_port =
7124 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7125 cmdline_parse_token_string_t cmd_showport_what =
7126 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7127 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7128 cmdline_parse_token_num_t cmd_showport_portnum =
7129 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7131 cmdline_parse_inst_t cmd_showport = {
7132 .f = cmd_showport_parsed,
7134 .help_str = "show|clear port "
7135 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7138 (void *)&cmd_showport_show,
7139 (void *)&cmd_showport_port,
7140 (void *)&cmd_showport_what,
7141 (void *)&cmd_showport_portnum,
7146 /* *** SHOW QUEUE INFO *** */
7147 struct cmd_showqueue_result {
7148 cmdline_fixed_string_t show;
7149 cmdline_fixed_string_t type;
7150 cmdline_fixed_string_t what;
7156 cmd_showqueue_parsed(void *parsed_result,
7157 __attribute__((unused)) struct cmdline *cl,
7158 __attribute__((unused)) void *data)
7160 struct cmd_showqueue_result *res = parsed_result;
7162 if (!strcmp(res->type, "rxq"))
7163 rx_queue_infos_display(res->portnum, res->queuenum);
7164 else if (!strcmp(res->type, "txq"))
7165 tx_queue_infos_display(res->portnum, res->queuenum);
7168 cmdline_parse_token_string_t cmd_showqueue_show =
7169 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7170 cmdline_parse_token_string_t cmd_showqueue_type =
7171 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7172 cmdline_parse_token_string_t cmd_showqueue_what =
7173 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7174 cmdline_parse_token_num_t cmd_showqueue_portnum =
7175 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7176 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7177 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7179 cmdline_parse_inst_t cmd_showqueue = {
7180 .f = cmd_showqueue_parsed,
7182 .help_str = "show rxq|txq info <port_id> <queue_id>",
7184 (void *)&cmd_showqueue_show,
7185 (void *)&cmd_showqueue_type,
7186 (void *)&cmd_showqueue_what,
7187 (void *)&cmd_showqueue_portnum,
7188 (void *)&cmd_showqueue_queuenum,
7193 /* *** READ PORT REGISTER *** */
7194 struct cmd_read_reg_result {
7195 cmdline_fixed_string_t read;
7196 cmdline_fixed_string_t reg;
7202 cmd_read_reg_parsed(void *parsed_result,
7203 __attribute__((unused)) struct cmdline *cl,
7204 __attribute__((unused)) void *data)
7206 struct cmd_read_reg_result *res = parsed_result;
7207 port_reg_display(res->port_id, res->reg_off);
7210 cmdline_parse_token_string_t cmd_read_reg_read =
7211 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7212 cmdline_parse_token_string_t cmd_read_reg_reg =
7213 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7214 cmdline_parse_token_num_t cmd_read_reg_port_id =
7215 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7216 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7217 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7219 cmdline_parse_inst_t cmd_read_reg = {
7220 .f = cmd_read_reg_parsed,
7222 .help_str = "read reg <port_id> <reg_off>",
7224 (void *)&cmd_read_reg_read,
7225 (void *)&cmd_read_reg_reg,
7226 (void *)&cmd_read_reg_port_id,
7227 (void *)&cmd_read_reg_reg_off,
7232 /* *** READ PORT REGISTER BIT FIELD *** */
7233 struct cmd_read_reg_bit_field_result {
7234 cmdline_fixed_string_t read;
7235 cmdline_fixed_string_t regfield;
7243 cmd_read_reg_bit_field_parsed(void *parsed_result,
7244 __attribute__((unused)) struct cmdline *cl,
7245 __attribute__((unused)) void *data)
7247 struct cmd_read_reg_bit_field_result *res = parsed_result;
7248 port_reg_bit_field_display(res->port_id, res->reg_off,
7249 res->bit1_pos, res->bit2_pos);
7252 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7253 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7255 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7256 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7257 regfield, "regfield");
7258 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7259 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7261 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7262 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7264 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7265 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7267 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7268 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7271 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7272 .f = cmd_read_reg_bit_field_parsed,
7274 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7275 "Read register bit field between bit_x and bit_y included",
7277 (void *)&cmd_read_reg_bit_field_read,
7278 (void *)&cmd_read_reg_bit_field_regfield,
7279 (void *)&cmd_read_reg_bit_field_port_id,
7280 (void *)&cmd_read_reg_bit_field_reg_off,
7281 (void *)&cmd_read_reg_bit_field_bit1_pos,
7282 (void *)&cmd_read_reg_bit_field_bit2_pos,
7287 /* *** READ PORT REGISTER BIT *** */
7288 struct cmd_read_reg_bit_result {
7289 cmdline_fixed_string_t read;
7290 cmdline_fixed_string_t regbit;
7297 cmd_read_reg_bit_parsed(void *parsed_result,
7298 __attribute__((unused)) struct cmdline *cl,
7299 __attribute__((unused)) void *data)
7301 struct cmd_read_reg_bit_result *res = parsed_result;
7302 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7305 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7306 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7307 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7308 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7310 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7311 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7312 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7313 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7314 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7315 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7317 cmdline_parse_inst_t cmd_read_reg_bit = {
7318 .f = cmd_read_reg_bit_parsed,
7320 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7322 (void *)&cmd_read_reg_bit_read,
7323 (void *)&cmd_read_reg_bit_regbit,
7324 (void *)&cmd_read_reg_bit_port_id,
7325 (void *)&cmd_read_reg_bit_reg_off,
7326 (void *)&cmd_read_reg_bit_bit_pos,
7331 /* *** WRITE PORT REGISTER *** */
7332 struct cmd_write_reg_result {
7333 cmdline_fixed_string_t write;
7334 cmdline_fixed_string_t reg;
7341 cmd_write_reg_parsed(void *parsed_result,
7342 __attribute__((unused)) struct cmdline *cl,
7343 __attribute__((unused)) void *data)
7345 struct cmd_write_reg_result *res = parsed_result;
7346 port_reg_set(res->port_id, res->reg_off, res->value);
7349 cmdline_parse_token_string_t cmd_write_reg_write =
7350 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7351 cmdline_parse_token_string_t cmd_write_reg_reg =
7352 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7353 cmdline_parse_token_num_t cmd_write_reg_port_id =
7354 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7355 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7356 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7357 cmdline_parse_token_num_t cmd_write_reg_value =
7358 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7360 cmdline_parse_inst_t cmd_write_reg = {
7361 .f = cmd_write_reg_parsed,
7363 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7365 (void *)&cmd_write_reg_write,
7366 (void *)&cmd_write_reg_reg,
7367 (void *)&cmd_write_reg_port_id,
7368 (void *)&cmd_write_reg_reg_off,
7369 (void *)&cmd_write_reg_value,
7374 /* *** WRITE PORT REGISTER BIT FIELD *** */
7375 struct cmd_write_reg_bit_field_result {
7376 cmdline_fixed_string_t write;
7377 cmdline_fixed_string_t regfield;
7386 cmd_write_reg_bit_field_parsed(void *parsed_result,
7387 __attribute__((unused)) struct cmdline *cl,
7388 __attribute__((unused)) void *data)
7390 struct cmd_write_reg_bit_field_result *res = parsed_result;
7391 port_reg_bit_field_set(res->port_id, res->reg_off,
7392 res->bit1_pos, res->bit2_pos, res->value);
7395 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7396 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7398 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7399 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7400 regfield, "regfield");
7401 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7402 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7404 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7405 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7407 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7408 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7410 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7411 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7413 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7414 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7417 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7418 .f = cmd_write_reg_bit_field_parsed,
7420 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7422 "Set register bit field between bit_x and bit_y included",
7424 (void *)&cmd_write_reg_bit_field_write,
7425 (void *)&cmd_write_reg_bit_field_regfield,
7426 (void *)&cmd_write_reg_bit_field_port_id,
7427 (void *)&cmd_write_reg_bit_field_reg_off,
7428 (void *)&cmd_write_reg_bit_field_bit1_pos,
7429 (void *)&cmd_write_reg_bit_field_bit2_pos,
7430 (void *)&cmd_write_reg_bit_field_value,
7435 /* *** WRITE PORT REGISTER BIT *** */
7436 struct cmd_write_reg_bit_result {
7437 cmdline_fixed_string_t write;
7438 cmdline_fixed_string_t regbit;
7446 cmd_write_reg_bit_parsed(void *parsed_result,
7447 __attribute__((unused)) struct cmdline *cl,
7448 __attribute__((unused)) void *data)
7450 struct cmd_write_reg_bit_result *res = parsed_result;
7451 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7454 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7455 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7457 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7458 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7460 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7461 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7462 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7463 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7464 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7465 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7466 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7467 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7469 cmdline_parse_inst_t cmd_write_reg_bit = {
7470 .f = cmd_write_reg_bit_parsed,
7472 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7475 (void *)&cmd_write_reg_bit_write,
7476 (void *)&cmd_write_reg_bit_regbit,
7477 (void *)&cmd_write_reg_bit_port_id,
7478 (void *)&cmd_write_reg_bit_reg_off,
7479 (void *)&cmd_write_reg_bit_bit_pos,
7480 (void *)&cmd_write_reg_bit_value,
7485 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7486 struct cmd_read_rxd_txd_result {
7487 cmdline_fixed_string_t read;
7488 cmdline_fixed_string_t rxd_txd;
7495 cmd_read_rxd_txd_parsed(void *parsed_result,
7496 __attribute__((unused)) struct cmdline *cl,
7497 __attribute__((unused)) void *data)
7499 struct cmd_read_rxd_txd_result *res = parsed_result;
7501 if (!strcmp(res->rxd_txd, "rxd"))
7502 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7503 else if (!strcmp(res->rxd_txd, "txd"))
7504 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7507 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7508 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7509 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7510 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7512 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7513 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7514 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7515 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7516 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7517 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7519 cmdline_parse_inst_t cmd_read_rxd_txd = {
7520 .f = cmd_read_rxd_txd_parsed,
7522 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7524 (void *)&cmd_read_rxd_txd_read,
7525 (void *)&cmd_read_rxd_txd_rxd_txd,
7526 (void *)&cmd_read_rxd_txd_port_id,
7527 (void *)&cmd_read_rxd_txd_queue_id,
7528 (void *)&cmd_read_rxd_txd_desc_id,
7534 struct cmd_quit_result {
7535 cmdline_fixed_string_t quit;
7538 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7540 __attribute__((unused)) void *data)
7546 cmdline_parse_token_string_t cmd_quit_quit =
7547 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7549 cmdline_parse_inst_t cmd_quit = {
7550 .f = cmd_quit_parsed,
7552 .help_str = "quit: Exit application",
7554 (void *)&cmd_quit_quit,
7559 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7560 struct cmd_mac_addr_result {
7561 cmdline_fixed_string_t mac_addr_cmd;
7562 cmdline_fixed_string_t what;
7564 struct ether_addr address;
7567 static void cmd_mac_addr_parsed(void *parsed_result,
7568 __attribute__((unused)) struct cmdline *cl,
7569 __attribute__((unused)) void *data)
7571 struct cmd_mac_addr_result *res = parsed_result;
7574 if (strcmp(res->what, "add") == 0)
7575 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7576 else if (strcmp(res->what, "set") == 0)
7577 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7580 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7582 /* check the return value and print it if is < 0 */
7584 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7588 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7589 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7591 cmdline_parse_token_string_t cmd_mac_addr_what =
7592 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7594 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7595 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7597 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7598 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7600 cmdline_parse_inst_t cmd_mac_addr = {
7601 .f = cmd_mac_addr_parsed,
7603 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7604 "Add/Remove/Set MAC address on port_id",
7606 (void *)&cmd_mac_addr_cmd,
7607 (void *)&cmd_mac_addr_what,
7608 (void *)&cmd_mac_addr_portnum,
7609 (void *)&cmd_mac_addr_addr,
7614 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7615 struct cmd_eth_peer_result {
7616 cmdline_fixed_string_t set;
7617 cmdline_fixed_string_t eth_peer;
7619 cmdline_fixed_string_t peer_addr;
7622 static void cmd_set_eth_peer_parsed(void *parsed_result,
7623 __attribute__((unused)) struct cmdline *cl,
7624 __attribute__((unused)) void *data)
7626 struct cmd_eth_peer_result *res = parsed_result;
7628 if (test_done == 0) {
7629 printf("Please stop forwarding first\n");
7632 if (!strcmp(res->eth_peer, "eth-peer")) {
7633 set_fwd_eth_peer(res->port_id, res->peer_addr);
7637 cmdline_parse_token_string_t cmd_eth_peer_set =
7638 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7639 cmdline_parse_token_string_t cmd_eth_peer =
7640 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7641 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7642 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7643 cmdline_parse_token_string_t cmd_eth_peer_addr =
7644 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7646 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7647 .f = cmd_set_eth_peer_parsed,
7649 .help_str = "set eth-peer <port_id> <peer_mac>",
7651 (void *)&cmd_eth_peer_set,
7652 (void *)&cmd_eth_peer,
7653 (void *)&cmd_eth_peer_port_id,
7654 (void *)&cmd_eth_peer_addr,
7659 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7660 struct cmd_set_qmap_result {
7661 cmdline_fixed_string_t set;
7662 cmdline_fixed_string_t qmap;
7663 cmdline_fixed_string_t what;
7670 cmd_set_qmap_parsed(void *parsed_result,
7671 __attribute__((unused)) struct cmdline *cl,
7672 __attribute__((unused)) void *data)
7674 struct cmd_set_qmap_result *res = parsed_result;
7675 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7677 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7680 cmdline_parse_token_string_t cmd_setqmap_set =
7681 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7683 cmdline_parse_token_string_t cmd_setqmap_qmap =
7684 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7686 cmdline_parse_token_string_t cmd_setqmap_what =
7687 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7689 cmdline_parse_token_num_t cmd_setqmap_portid =
7690 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7692 cmdline_parse_token_num_t cmd_setqmap_queueid =
7693 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7695 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7696 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7699 cmdline_parse_inst_t cmd_set_qmap = {
7700 .f = cmd_set_qmap_parsed,
7702 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7703 "Set statistics mapping value on tx|rx queue_id of port_id",
7705 (void *)&cmd_setqmap_set,
7706 (void *)&cmd_setqmap_qmap,
7707 (void *)&cmd_setqmap_what,
7708 (void *)&cmd_setqmap_portid,
7709 (void *)&cmd_setqmap_queueid,
7710 (void *)&cmd_setqmap_mapvalue,
7715 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7716 struct cmd_set_xstats_hide_zero_result {
7717 cmdline_fixed_string_t keyword;
7718 cmdline_fixed_string_t name;
7719 cmdline_fixed_string_t on_off;
7723 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7724 __attribute__((unused)) struct cmdline *cl,
7725 __attribute__((unused)) void *data)
7727 struct cmd_set_xstats_hide_zero_result *res;
7728 uint16_t on_off = 0;
7730 res = parsed_result;
7731 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7732 set_xstats_hide_zero(on_off);
7735 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7736 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7738 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7739 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7740 name, "xstats-hide-zero");
7741 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7742 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7745 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7746 .f = cmd_set_xstats_hide_zero_parsed,
7748 .help_str = "set xstats-hide-zero on|off",
7750 (void *)&cmd_set_xstats_hide_zero_keyword,
7751 (void *)&cmd_set_xstats_hide_zero_name,
7752 (void *)&cmd_set_xstats_hide_zero_on_off,
7757 /* *** CONFIGURE UNICAST HASH TABLE *** */
7758 struct cmd_set_uc_hash_table {
7759 cmdline_fixed_string_t set;
7760 cmdline_fixed_string_t port;
7762 cmdline_fixed_string_t what;
7763 struct ether_addr address;
7764 cmdline_fixed_string_t mode;
7768 cmd_set_uc_hash_parsed(void *parsed_result,
7769 __attribute__((unused)) struct cmdline *cl,
7770 __attribute__((unused)) void *data)
7773 struct cmd_set_uc_hash_table *res = parsed_result;
7775 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7777 if (strcmp(res->what, "uta") == 0)
7778 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7779 &res->address,(uint8_t)is_on);
7781 printf("bad unicast hash table parameter, return code = %d \n", ret);
7785 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7786 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7788 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7789 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7791 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7792 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7794 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7795 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7797 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7798 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7800 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7801 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7804 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7805 .f = cmd_set_uc_hash_parsed,
7807 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7809 (void *)&cmd_set_uc_hash_set,
7810 (void *)&cmd_set_uc_hash_port,
7811 (void *)&cmd_set_uc_hash_portid,
7812 (void *)&cmd_set_uc_hash_what,
7813 (void *)&cmd_set_uc_hash_mac,
7814 (void *)&cmd_set_uc_hash_mode,
7819 struct cmd_set_uc_all_hash_table {
7820 cmdline_fixed_string_t set;
7821 cmdline_fixed_string_t port;
7823 cmdline_fixed_string_t what;
7824 cmdline_fixed_string_t value;
7825 cmdline_fixed_string_t mode;
7829 cmd_set_uc_all_hash_parsed(void *parsed_result,
7830 __attribute__((unused)) struct cmdline *cl,
7831 __attribute__((unused)) void *data)
7834 struct cmd_set_uc_all_hash_table *res = parsed_result;
7836 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7838 if ((strcmp(res->what, "uta") == 0) &&
7839 (strcmp(res->value, "all") == 0))
7840 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7842 printf("bad unicast hash table parameter,"
7843 "return code = %d \n", ret);
7846 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7847 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7849 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7850 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7852 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7853 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7855 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7856 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7858 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7859 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7861 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7862 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7865 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7866 .f = cmd_set_uc_all_hash_parsed,
7868 .help_str = "set port <port_id> uta all on|off",
7870 (void *)&cmd_set_uc_all_hash_set,
7871 (void *)&cmd_set_uc_all_hash_port,
7872 (void *)&cmd_set_uc_all_hash_portid,
7873 (void *)&cmd_set_uc_all_hash_what,
7874 (void *)&cmd_set_uc_all_hash_value,
7875 (void *)&cmd_set_uc_all_hash_mode,
7880 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7881 struct cmd_set_vf_macvlan_filter {
7882 cmdline_fixed_string_t set;
7883 cmdline_fixed_string_t port;
7885 cmdline_fixed_string_t vf;
7887 struct ether_addr address;
7888 cmdline_fixed_string_t filter_type;
7889 cmdline_fixed_string_t mode;
7893 cmd_set_vf_macvlan_parsed(void *parsed_result,
7894 __attribute__((unused)) struct cmdline *cl,
7895 __attribute__((unused)) void *data)
7898 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7899 struct rte_eth_mac_filter filter;
7901 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7903 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7905 /* set VF MAC filter */
7909 filter.dst_id = res->vf_id;
7911 if (!strcmp(res->filter_type, "exact-mac"))
7912 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7913 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7914 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7915 else if (!strcmp(res->filter_type, "hashmac"))
7916 filter.filter_type = RTE_MAC_HASH_MATCH;
7917 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7918 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7920 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7923 ret = rte_eth_dev_filter_ctrl(res->port_id,
7924 RTE_ETH_FILTER_MACVLAN,
7928 ret = rte_eth_dev_filter_ctrl(res->port_id,
7929 RTE_ETH_FILTER_MACVLAN,
7930 RTE_ETH_FILTER_DELETE,
7934 printf("bad set MAC hash parameter, return code = %d\n", ret);
7938 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7939 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7941 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7942 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7944 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7945 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7947 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7948 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7950 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7951 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7953 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7954 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7956 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7957 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7958 filter_type, "exact-mac#exact-mac-vlan"
7959 "#hashmac#hashmac-vlan");
7960 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7961 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7964 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7965 .f = cmd_set_vf_macvlan_parsed,
7967 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
7968 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
7969 "Exact match rule: exact match of MAC or MAC and VLAN; "
7970 "hash match rule: hash match of MAC and exact match of VLAN",
7972 (void *)&cmd_set_vf_macvlan_set,
7973 (void *)&cmd_set_vf_macvlan_port,
7974 (void *)&cmd_set_vf_macvlan_portid,
7975 (void *)&cmd_set_vf_macvlan_vf,
7976 (void *)&cmd_set_vf_macvlan_vf_id,
7977 (void *)&cmd_set_vf_macvlan_mac,
7978 (void *)&cmd_set_vf_macvlan_filter_type,
7979 (void *)&cmd_set_vf_macvlan_mode,
7984 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7985 struct cmd_set_vf_traffic {
7986 cmdline_fixed_string_t set;
7987 cmdline_fixed_string_t port;
7989 cmdline_fixed_string_t vf;
7991 cmdline_fixed_string_t what;
7992 cmdline_fixed_string_t mode;
7996 cmd_set_vf_traffic_parsed(void *parsed_result,
7997 __attribute__((unused)) struct cmdline *cl,
7998 __attribute__((unused)) void *data)
8000 struct cmd_set_vf_traffic *res = parsed_result;
8001 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8002 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8004 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8007 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8008 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8010 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8011 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8013 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8014 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8016 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8017 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8019 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8020 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8022 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8023 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8025 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8026 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8029 cmdline_parse_inst_t cmd_set_vf_traffic = {
8030 .f = cmd_set_vf_traffic_parsed,
8032 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8034 (void *)&cmd_setvf_traffic_set,
8035 (void *)&cmd_setvf_traffic_port,
8036 (void *)&cmd_setvf_traffic_portid,
8037 (void *)&cmd_setvf_traffic_vf,
8038 (void *)&cmd_setvf_traffic_vfid,
8039 (void *)&cmd_setvf_traffic_what,
8040 (void *)&cmd_setvf_traffic_mode,
8045 /* *** CONFIGURE VF RECEIVE MODE *** */
8046 struct cmd_set_vf_rxmode {
8047 cmdline_fixed_string_t set;
8048 cmdline_fixed_string_t port;
8050 cmdline_fixed_string_t vf;
8052 cmdline_fixed_string_t what;
8053 cmdline_fixed_string_t mode;
8054 cmdline_fixed_string_t on;
8058 cmd_set_vf_rxmode_parsed(void *parsed_result,
8059 __attribute__((unused)) struct cmdline *cl,
8060 __attribute__((unused)) void *data)
8063 uint16_t rx_mode = 0;
8064 struct cmd_set_vf_rxmode *res = parsed_result;
8066 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8067 if (!strcmp(res->what,"rxmode")) {
8068 if (!strcmp(res->mode, "AUPE"))
8069 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8070 else if (!strcmp(res->mode, "ROPE"))
8071 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8072 else if (!strcmp(res->mode, "BAM"))
8073 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8074 else if (!strncmp(res->mode, "MPE",3))
8075 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8078 RTE_SET_USED(is_on);
8080 #ifdef RTE_LIBRTE_IXGBE_PMD
8081 if (ret == -ENOTSUP)
8082 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8083 rx_mode, (uint8_t)is_on);
8085 #ifdef RTE_LIBRTE_BNXT_PMD
8086 if (ret == -ENOTSUP)
8087 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8088 rx_mode, (uint8_t)is_on);
8091 printf("bad VF receive mode parameter, return code = %d \n",
8095 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8096 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8098 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8099 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8101 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8102 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8104 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8105 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8107 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8108 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8110 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8111 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8113 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8114 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8115 mode, "AUPE#ROPE#BAM#MPE");
8116 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8117 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8120 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8121 .f = cmd_set_vf_rxmode_parsed,
8123 .help_str = "set port <port_id> vf <vf_id> rxmode "
8124 "AUPE|ROPE|BAM|MPE on|off",
8126 (void *)&cmd_set_vf_rxmode_set,
8127 (void *)&cmd_set_vf_rxmode_port,
8128 (void *)&cmd_set_vf_rxmode_portid,
8129 (void *)&cmd_set_vf_rxmode_vf,
8130 (void *)&cmd_set_vf_rxmode_vfid,
8131 (void *)&cmd_set_vf_rxmode_what,
8132 (void *)&cmd_set_vf_rxmode_mode,
8133 (void *)&cmd_set_vf_rxmode_on,
8138 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8139 struct cmd_vf_mac_addr_result {
8140 cmdline_fixed_string_t mac_addr_cmd;
8141 cmdline_fixed_string_t what;
8142 cmdline_fixed_string_t port;
8144 cmdline_fixed_string_t vf;
8146 struct ether_addr address;
8149 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8150 __attribute__((unused)) struct cmdline *cl,
8151 __attribute__((unused)) void *data)
8153 struct cmd_vf_mac_addr_result *res = parsed_result;
8156 if (strcmp(res->what, "add") != 0)
8159 #ifdef RTE_LIBRTE_I40E_PMD
8160 if (ret == -ENOTSUP)
8161 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8164 #ifdef RTE_LIBRTE_BNXT_PMD
8165 if (ret == -ENOTSUP)
8166 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8171 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8175 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8176 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8177 mac_addr_cmd,"mac_addr");
8178 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8179 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8181 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8182 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8184 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8185 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8187 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8188 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8190 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8191 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8193 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8194 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8197 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8198 .f = cmd_vf_mac_addr_parsed,
8200 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8201 "Add MAC address filtering for a VF on port_id",
8203 (void *)&cmd_vf_mac_addr_cmd,
8204 (void *)&cmd_vf_mac_addr_what,
8205 (void *)&cmd_vf_mac_addr_port,
8206 (void *)&cmd_vf_mac_addr_portnum,
8207 (void *)&cmd_vf_mac_addr_vf,
8208 (void *)&cmd_vf_mac_addr_vfnum,
8209 (void *)&cmd_vf_mac_addr_addr,
8214 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8215 struct cmd_vf_rx_vlan_filter {
8216 cmdline_fixed_string_t rx_vlan;
8217 cmdline_fixed_string_t what;
8219 cmdline_fixed_string_t port;
8221 cmdline_fixed_string_t vf;
8226 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8227 __attribute__((unused)) struct cmdline *cl,
8228 __attribute__((unused)) void *data)
8230 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8233 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8235 #ifdef RTE_LIBRTE_IXGBE_PMD
8236 if (ret == -ENOTSUP)
8237 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8238 res->vlan_id, res->vf_mask, is_add);
8240 #ifdef RTE_LIBRTE_I40E_PMD
8241 if (ret == -ENOTSUP)
8242 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8243 res->vlan_id, res->vf_mask, is_add);
8245 #ifdef RTE_LIBRTE_BNXT_PMD
8246 if (ret == -ENOTSUP)
8247 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8248 res->vlan_id, res->vf_mask, is_add);
8255 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8256 res->vlan_id, res->vf_mask);
8259 printf("invalid port_id %d\n", res->port_id);
8262 printf("function not implemented or supported\n");
8265 printf("programming error: (%s)\n", strerror(-ret));
8269 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8270 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8271 rx_vlan, "rx_vlan");
8272 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8273 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8275 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8276 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8278 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8279 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8281 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8282 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8284 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8285 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8287 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8288 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8291 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8292 .f = cmd_vf_rx_vlan_filter_parsed,
8294 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8295 "(vf_mask = hexadecimal VF mask)",
8297 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8298 (void *)&cmd_vf_rx_vlan_filter_what,
8299 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8300 (void *)&cmd_vf_rx_vlan_filter_port,
8301 (void *)&cmd_vf_rx_vlan_filter_portid,
8302 (void *)&cmd_vf_rx_vlan_filter_vf,
8303 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8308 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8309 struct cmd_queue_rate_limit_result {
8310 cmdline_fixed_string_t set;
8311 cmdline_fixed_string_t port;
8313 cmdline_fixed_string_t queue;
8315 cmdline_fixed_string_t rate;
8319 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8320 __attribute__((unused)) struct cmdline *cl,
8321 __attribute__((unused)) void *data)
8323 struct cmd_queue_rate_limit_result *res = parsed_result;
8326 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8327 && (strcmp(res->queue, "queue") == 0)
8328 && (strcmp(res->rate, "rate") == 0))
8329 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8332 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8336 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8337 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8339 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8340 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8342 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8343 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8345 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8346 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8348 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8349 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8351 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8352 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8354 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8355 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8358 cmdline_parse_inst_t cmd_queue_rate_limit = {
8359 .f = cmd_queue_rate_limit_parsed,
8361 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8362 "Set rate limit for a queue on port_id",
8364 (void *)&cmd_queue_rate_limit_set,
8365 (void *)&cmd_queue_rate_limit_port,
8366 (void *)&cmd_queue_rate_limit_portnum,
8367 (void *)&cmd_queue_rate_limit_queue,
8368 (void *)&cmd_queue_rate_limit_queuenum,
8369 (void *)&cmd_queue_rate_limit_rate,
8370 (void *)&cmd_queue_rate_limit_ratenum,
8375 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8376 struct cmd_vf_rate_limit_result {
8377 cmdline_fixed_string_t set;
8378 cmdline_fixed_string_t port;
8380 cmdline_fixed_string_t vf;
8382 cmdline_fixed_string_t rate;
8384 cmdline_fixed_string_t q_msk;
8388 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8389 __attribute__((unused)) struct cmdline *cl,
8390 __attribute__((unused)) void *data)
8392 struct cmd_vf_rate_limit_result *res = parsed_result;
8395 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8396 && (strcmp(res->vf, "vf") == 0)
8397 && (strcmp(res->rate, "rate") == 0)
8398 && (strcmp(res->q_msk, "queue_mask") == 0))
8399 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8400 res->rate_num, res->q_msk_val);
8402 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8406 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8407 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8409 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8410 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8412 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8413 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8415 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8416 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8418 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8419 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8421 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8422 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8424 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8425 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8427 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8428 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8429 q_msk, "queue_mask");
8430 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8431 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8434 cmdline_parse_inst_t cmd_vf_rate_limit = {
8435 .f = cmd_vf_rate_limit_parsed,
8437 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8438 "queue_mask <queue_mask_value>: "
8439 "Set rate limit for queues of VF on port_id",
8441 (void *)&cmd_vf_rate_limit_set,
8442 (void *)&cmd_vf_rate_limit_port,
8443 (void *)&cmd_vf_rate_limit_portnum,
8444 (void *)&cmd_vf_rate_limit_vf,
8445 (void *)&cmd_vf_rate_limit_vfnum,
8446 (void *)&cmd_vf_rate_limit_rate,
8447 (void *)&cmd_vf_rate_limit_ratenum,
8448 (void *)&cmd_vf_rate_limit_q_msk,
8449 (void *)&cmd_vf_rate_limit_q_msk_val,
8454 /* *** ADD TUNNEL FILTER OF A PORT *** */
8455 struct cmd_tunnel_filter_result {
8456 cmdline_fixed_string_t cmd;
8457 cmdline_fixed_string_t what;
8459 struct ether_addr outer_mac;
8460 struct ether_addr inner_mac;
8461 cmdline_ipaddr_t ip_value;
8462 uint16_t inner_vlan;
8463 cmdline_fixed_string_t tunnel_type;
8464 cmdline_fixed_string_t filter_type;
8470 cmd_tunnel_filter_parsed(void *parsed_result,
8471 __attribute__((unused)) struct cmdline *cl,
8472 __attribute__((unused)) void *data)
8474 struct cmd_tunnel_filter_result *res = parsed_result;
8475 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8478 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8480 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8481 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8482 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8484 if (res->ip_value.family == AF_INET) {
8485 tunnel_filter_conf.ip_addr.ipv4_addr =
8486 res->ip_value.addr.ipv4.s_addr;
8487 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8489 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8490 &(res->ip_value.addr.ipv6),
8491 sizeof(struct in6_addr));
8492 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8495 if (!strcmp(res->filter_type, "imac-ivlan"))
8496 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8497 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8498 tunnel_filter_conf.filter_type =
8499 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8500 else if (!strcmp(res->filter_type, "imac-tenid"))
8501 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8502 else if (!strcmp(res->filter_type, "imac"))
8503 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8504 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8505 tunnel_filter_conf.filter_type =
8506 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8507 else if (!strcmp(res->filter_type, "oip"))
8508 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8509 else if (!strcmp(res->filter_type, "iip"))
8510 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8512 printf("The filter type is not supported");
8516 if (!strcmp(res->tunnel_type, "vxlan"))
8517 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8518 else if (!strcmp(res->tunnel_type, "nvgre"))
8519 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8520 else if (!strcmp(res->tunnel_type, "ipingre"))
8521 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8523 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8527 tunnel_filter_conf.tenant_id = res->tenant_id;
8528 tunnel_filter_conf.queue_id = res->queue_num;
8529 if (!strcmp(res->what, "add"))
8530 ret = rte_eth_dev_filter_ctrl(res->port_id,
8531 RTE_ETH_FILTER_TUNNEL,
8533 &tunnel_filter_conf);
8535 ret = rte_eth_dev_filter_ctrl(res->port_id,
8536 RTE_ETH_FILTER_TUNNEL,
8537 RTE_ETH_FILTER_DELETE,
8538 &tunnel_filter_conf);
8540 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8544 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8545 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8546 cmd, "tunnel_filter");
8547 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8548 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8550 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8551 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8553 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8554 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8556 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8557 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8559 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8560 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8561 inner_vlan, UINT16);
8562 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8563 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8565 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8566 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8567 tunnel_type, "vxlan#nvgre#ipingre");
8569 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8570 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8571 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8572 "imac#omac-imac-tenid");
8573 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8574 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8576 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8577 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8580 cmdline_parse_inst_t cmd_tunnel_filter = {
8581 .f = cmd_tunnel_filter_parsed,
8583 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8584 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8585 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8586 "<queue_id>: Add/Rm tunnel filter of a port",
8588 (void *)&cmd_tunnel_filter_cmd,
8589 (void *)&cmd_tunnel_filter_what,
8590 (void *)&cmd_tunnel_filter_port_id,
8591 (void *)&cmd_tunnel_filter_outer_mac,
8592 (void *)&cmd_tunnel_filter_inner_mac,
8593 (void *)&cmd_tunnel_filter_ip_value,
8594 (void *)&cmd_tunnel_filter_innner_vlan,
8595 (void *)&cmd_tunnel_filter_tunnel_type,
8596 (void *)&cmd_tunnel_filter_filter_type,
8597 (void *)&cmd_tunnel_filter_tenant_id,
8598 (void *)&cmd_tunnel_filter_queue_num,
8603 /* *** CONFIGURE TUNNEL UDP PORT *** */
8604 struct cmd_tunnel_udp_config {
8605 cmdline_fixed_string_t cmd;
8606 cmdline_fixed_string_t what;
8612 cmd_tunnel_udp_config_parsed(void *parsed_result,
8613 __attribute__((unused)) struct cmdline *cl,
8614 __attribute__((unused)) void *data)
8616 struct cmd_tunnel_udp_config *res = parsed_result;
8617 struct rte_eth_udp_tunnel tunnel_udp;
8620 tunnel_udp.udp_port = res->udp_port;
8622 if (!strcmp(res->cmd, "rx_vxlan_port"))
8623 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8625 if (!strcmp(res->what, "add"))
8626 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8629 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8633 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8636 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8637 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8638 cmd, "rx_vxlan_port");
8639 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8640 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8642 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8643 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8645 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8646 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8649 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8650 .f = cmd_tunnel_udp_config_parsed,
8652 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8653 "Add/Remove a tunneling UDP port filter",
8655 (void *)&cmd_tunnel_udp_config_cmd,
8656 (void *)&cmd_tunnel_udp_config_what,
8657 (void *)&cmd_tunnel_udp_config_udp_port,
8658 (void *)&cmd_tunnel_udp_config_port_id,
8663 struct cmd_config_tunnel_udp_port {
8664 cmdline_fixed_string_t port;
8665 cmdline_fixed_string_t config;
8667 cmdline_fixed_string_t udp_tunnel_port;
8668 cmdline_fixed_string_t action;
8669 cmdline_fixed_string_t tunnel_type;
8674 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8675 __attribute__((unused)) struct cmdline *cl,
8676 __attribute__((unused)) void *data)
8678 struct cmd_config_tunnel_udp_port *res = parsed_result;
8679 struct rte_eth_udp_tunnel tunnel_udp;
8682 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8685 tunnel_udp.udp_port = res->udp_port;
8687 if (!strcmp(res->tunnel_type, "vxlan")) {
8688 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8689 } else if (!strcmp(res->tunnel_type, "geneve")) {
8690 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8692 printf("Invalid tunnel type\n");
8696 if (!strcmp(res->action, "add"))
8697 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8700 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8704 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8707 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8708 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8710 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8711 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8713 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8714 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8716 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8717 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8720 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8721 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8723 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8724 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8726 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8727 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8730 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8731 .f = cmd_cfg_tunnel_udp_port_parsed,
8733 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8735 (void *)&cmd_config_tunnel_udp_port_port,
8736 (void *)&cmd_config_tunnel_udp_port_config,
8737 (void *)&cmd_config_tunnel_udp_port_port_id,
8738 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8739 (void *)&cmd_config_tunnel_udp_port_action,
8740 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8741 (void *)&cmd_config_tunnel_udp_port_value,
8746 /* *** GLOBAL CONFIG *** */
8747 struct cmd_global_config_result {
8748 cmdline_fixed_string_t cmd;
8750 cmdline_fixed_string_t cfg_type;
8755 cmd_global_config_parsed(void *parsed_result,
8756 __attribute__((unused)) struct cmdline *cl,
8757 __attribute__((unused)) void *data)
8759 struct cmd_global_config_result *res = parsed_result;
8760 struct rte_eth_global_cfg conf;
8763 memset(&conf, 0, sizeof(conf));
8764 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8765 conf.cfg.gre_key_len = res->len;
8766 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8767 RTE_ETH_FILTER_SET, &conf);
8769 printf("Global config error\n");
8772 cmdline_parse_token_string_t cmd_global_config_cmd =
8773 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8775 cmdline_parse_token_num_t cmd_global_config_port_id =
8776 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8778 cmdline_parse_token_string_t cmd_global_config_type =
8779 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8780 cfg_type, "gre-key-len");
8781 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8782 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8785 cmdline_parse_inst_t cmd_global_config = {
8786 .f = cmd_global_config_parsed,
8787 .data = (void *)NULL,
8788 .help_str = "global_config <port_id> gre-key-len <key_len>",
8790 (void *)&cmd_global_config_cmd,
8791 (void *)&cmd_global_config_port_id,
8792 (void *)&cmd_global_config_type,
8793 (void *)&cmd_global_config_gre_key_len,
8798 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8799 struct cmd_set_mirror_mask_result {
8800 cmdline_fixed_string_t set;
8801 cmdline_fixed_string_t port;
8803 cmdline_fixed_string_t mirror;
8805 cmdline_fixed_string_t what;
8806 cmdline_fixed_string_t value;
8807 cmdline_fixed_string_t dstpool;
8809 cmdline_fixed_string_t on;
8812 cmdline_parse_token_string_t cmd_mirror_mask_set =
8813 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8815 cmdline_parse_token_string_t cmd_mirror_mask_port =
8816 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8818 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8819 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8821 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8822 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8823 mirror, "mirror-rule");
8824 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8825 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8827 cmdline_parse_token_string_t cmd_mirror_mask_what =
8828 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8829 what, "pool-mirror-up#pool-mirror-down"
8831 cmdline_parse_token_string_t cmd_mirror_mask_value =
8832 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8834 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8835 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8836 dstpool, "dst-pool");
8837 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8838 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8840 cmdline_parse_token_string_t cmd_mirror_mask_on =
8841 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8845 cmd_set_mirror_mask_parsed(void *parsed_result,
8846 __attribute__((unused)) struct cmdline *cl,
8847 __attribute__((unused)) void *data)
8850 struct cmd_set_mirror_mask_result *res = parsed_result;
8851 struct rte_eth_mirror_conf mr_conf;
8853 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8855 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8857 mr_conf.dst_pool = res->dstpool_id;
8859 if (!strcmp(res->what, "pool-mirror-up")) {
8860 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8861 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8862 } else if (!strcmp(res->what, "pool-mirror-down")) {
8863 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8864 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8865 } else if (!strcmp(res->what, "vlan-mirror")) {
8866 mr_conf.rule_type = ETH_MIRROR_VLAN;
8867 nb_item = parse_item_list(res->value, "vlan",
8868 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8872 for (i = 0; i < nb_item; i++) {
8873 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8874 printf("Invalid vlan_id: must be < 4096\n");
8878 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8879 mr_conf.vlan.vlan_mask |= 1ULL << i;
8883 if (!strcmp(res->on, "on"))
8884 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8887 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8890 printf("mirror rule add error: (%s)\n", strerror(-ret));
8893 cmdline_parse_inst_t cmd_set_mirror_mask = {
8894 .f = cmd_set_mirror_mask_parsed,
8896 .help_str = "set port <port_id> mirror-rule <rule_id> "
8897 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8898 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8900 (void *)&cmd_mirror_mask_set,
8901 (void *)&cmd_mirror_mask_port,
8902 (void *)&cmd_mirror_mask_portid,
8903 (void *)&cmd_mirror_mask_mirror,
8904 (void *)&cmd_mirror_mask_ruleid,
8905 (void *)&cmd_mirror_mask_what,
8906 (void *)&cmd_mirror_mask_value,
8907 (void *)&cmd_mirror_mask_dstpool,
8908 (void *)&cmd_mirror_mask_poolid,
8909 (void *)&cmd_mirror_mask_on,
8914 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8915 struct cmd_set_mirror_link_result {
8916 cmdline_fixed_string_t set;
8917 cmdline_fixed_string_t port;
8919 cmdline_fixed_string_t mirror;
8921 cmdline_fixed_string_t what;
8922 cmdline_fixed_string_t dstpool;
8924 cmdline_fixed_string_t on;
8927 cmdline_parse_token_string_t cmd_mirror_link_set =
8928 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8930 cmdline_parse_token_string_t cmd_mirror_link_port =
8931 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8933 cmdline_parse_token_num_t cmd_mirror_link_portid =
8934 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8936 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8937 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8938 mirror, "mirror-rule");
8939 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8940 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8942 cmdline_parse_token_string_t cmd_mirror_link_what =
8943 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8944 what, "uplink-mirror#downlink-mirror");
8945 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8946 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8947 dstpool, "dst-pool");
8948 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8949 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8951 cmdline_parse_token_string_t cmd_mirror_link_on =
8952 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8956 cmd_set_mirror_link_parsed(void *parsed_result,
8957 __attribute__((unused)) struct cmdline *cl,
8958 __attribute__((unused)) void *data)
8961 struct cmd_set_mirror_link_result *res = parsed_result;
8962 struct rte_eth_mirror_conf mr_conf;
8964 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8965 if (!strcmp(res->what, "uplink-mirror"))
8966 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
8968 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
8970 mr_conf.dst_pool = res->dstpool_id;
8972 if (!strcmp(res->on, "on"))
8973 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8976 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8979 /* check the return value and print it if is < 0 */
8981 printf("mirror rule add error: (%s)\n", strerror(-ret));
8985 cmdline_parse_inst_t cmd_set_mirror_link = {
8986 .f = cmd_set_mirror_link_parsed,
8988 .help_str = "set port <port_id> mirror-rule <rule_id> "
8989 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
8991 (void *)&cmd_mirror_link_set,
8992 (void *)&cmd_mirror_link_port,
8993 (void *)&cmd_mirror_link_portid,
8994 (void *)&cmd_mirror_link_mirror,
8995 (void *)&cmd_mirror_link_ruleid,
8996 (void *)&cmd_mirror_link_what,
8997 (void *)&cmd_mirror_link_dstpool,
8998 (void *)&cmd_mirror_link_poolid,
8999 (void *)&cmd_mirror_link_on,
9004 /* *** RESET VM MIRROR RULE *** */
9005 struct cmd_rm_mirror_rule_result {
9006 cmdline_fixed_string_t reset;
9007 cmdline_fixed_string_t port;
9009 cmdline_fixed_string_t mirror;
9013 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9014 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9016 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9017 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9019 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9020 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9022 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9023 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9024 mirror, "mirror-rule");
9025 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9026 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9030 cmd_reset_mirror_rule_parsed(void *parsed_result,
9031 __attribute__((unused)) struct cmdline *cl,
9032 __attribute__((unused)) void *data)
9035 struct cmd_set_mirror_link_result *res = parsed_result;
9037 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9039 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9042 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9043 .f = cmd_reset_mirror_rule_parsed,
9045 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9047 (void *)&cmd_rm_mirror_rule_reset,
9048 (void *)&cmd_rm_mirror_rule_port,
9049 (void *)&cmd_rm_mirror_rule_portid,
9050 (void *)&cmd_rm_mirror_rule_mirror,
9051 (void *)&cmd_rm_mirror_rule_ruleid,
9056 /* ******************************************************************************** */
9058 struct cmd_dump_result {
9059 cmdline_fixed_string_t dump;
9063 dump_struct_sizes(void)
9065 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9066 DUMP_SIZE(struct rte_mbuf);
9067 DUMP_SIZE(struct rte_mempool);
9068 DUMP_SIZE(struct rte_ring);
9072 static void cmd_dump_parsed(void *parsed_result,
9073 __attribute__((unused)) struct cmdline *cl,
9074 __attribute__((unused)) void *data)
9076 struct cmd_dump_result *res = parsed_result;
9078 if (!strcmp(res->dump, "dump_physmem"))
9079 rte_dump_physmem_layout(stdout);
9080 else if (!strcmp(res->dump, "dump_memzone"))
9081 rte_memzone_dump(stdout);
9082 else if (!strcmp(res->dump, "dump_struct_sizes"))
9083 dump_struct_sizes();
9084 else if (!strcmp(res->dump, "dump_ring"))
9085 rte_ring_list_dump(stdout);
9086 else if (!strcmp(res->dump, "dump_mempool"))
9087 rte_mempool_list_dump(stdout);
9088 else if (!strcmp(res->dump, "dump_devargs"))
9089 rte_devargs_dump(stdout);
9090 else if (!strcmp(res->dump, "dump_log_types"))
9091 rte_log_dump(stdout);
9094 cmdline_parse_token_string_t cmd_dump_dump =
9095 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9098 "dump_struct_sizes#"
9104 cmdline_parse_inst_t cmd_dump = {
9105 .f = cmd_dump_parsed, /* function to call */
9106 .data = NULL, /* 2nd arg of func */
9107 .help_str = "Dump status",
9108 .tokens = { /* token list, NULL terminated */
9109 (void *)&cmd_dump_dump,
9114 /* ******************************************************************************** */
9116 struct cmd_dump_one_result {
9117 cmdline_fixed_string_t dump;
9118 cmdline_fixed_string_t name;
9121 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9122 __attribute__((unused)) void *data)
9124 struct cmd_dump_one_result *res = parsed_result;
9126 if (!strcmp(res->dump, "dump_ring")) {
9128 r = rte_ring_lookup(res->name);
9130 cmdline_printf(cl, "Cannot find ring\n");
9133 rte_ring_dump(stdout, r);
9134 } else if (!strcmp(res->dump, "dump_mempool")) {
9135 struct rte_mempool *mp;
9136 mp = rte_mempool_lookup(res->name);
9138 cmdline_printf(cl, "Cannot find mempool\n");
9141 rte_mempool_dump(stdout, mp);
9145 cmdline_parse_token_string_t cmd_dump_one_dump =
9146 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9147 "dump_ring#dump_mempool");
9149 cmdline_parse_token_string_t cmd_dump_one_name =
9150 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9152 cmdline_parse_inst_t cmd_dump_one = {
9153 .f = cmd_dump_one_parsed, /* function to call */
9154 .data = NULL, /* 2nd arg of func */
9155 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9156 .tokens = { /* token list, NULL terminated */
9157 (void *)&cmd_dump_one_dump,
9158 (void *)&cmd_dump_one_name,
9163 /* *** Add/Del syn filter *** */
9164 struct cmd_syn_filter_result {
9165 cmdline_fixed_string_t filter;
9167 cmdline_fixed_string_t ops;
9168 cmdline_fixed_string_t priority;
9169 cmdline_fixed_string_t high;
9170 cmdline_fixed_string_t queue;
9175 cmd_syn_filter_parsed(void *parsed_result,
9176 __attribute__((unused)) struct cmdline *cl,
9177 __attribute__((unused)) void *data)
9179 struct cmd_syn_filter_result *res = parsed_result;
9180 struct rte_eth_syn_filter syn_filter;
9183 ret = rte_eth_dev_filter_supported(res->port_id,
9184 RTE_ETH_FILTER_SYN);
9186 printf("syn filter is not supported on port %u.\n",
9191 memset(&syn_filter, 0, sizeof(syn_filter));
9193 if (!strcmp(res->ops, "add")) {
9194 if (!strcmp(res->high, "high"))
9195 syn_filter.hig_pri = 1;
9197 syn_filter.hig_pri = 0;
9199 syn_filter.queue = res->queue_id;
9200 ret = rte_eth_dev_filter_ctrl(res->port_id,
9205 ret = rte_eth_dev_filter_ctrl(res->port_id,
9207 RTE_ETH_FILTER_DELETE,
9211 printf("syn filter programming error: (%s)\n",
9215 cmdline_parse_token_string_t cmd_syn_filter_filter =
9216 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9217 filter, "syn_filter");
9218 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9219 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9221 cmdline_parse_token_string_t cmd_syn_filter_ops =
9222 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9224 cmdline_parse_token_string_t cmd_syn_filter_priority =
9225 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9226 priority, "priority");
9227 cmdline_parse_token_string_t cmd_syn_filter_high =
9228 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9230 cmdline_parse_token_string_t cmd_syn_filter_queue =
9231 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9233 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9234 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9237 cmdline_parse_inst_t cmd_syn_filter = {
9238 .f = cmd_syn_filter_parsed,
9240 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9241 "<queue_id>: Add/Delete syn filter",
9243 (void *)&cmd_syn_filter_filter,
9244 (void *)&cmd_syn_filter_port_id,
9245 (void *)&cmd_syn_filter_ops,
9246 (void *)&cmd_syn_filter_priority,
9247 (void *)&cmd_syn_filter_high,
9248 (void *)&cmd_syn_filter_queue,
9249 (void *)&cmd_syn_filter_queue_id,
9254 /* *** queue region set *** */
9255 struct cmd_queue_region_result {
9256 cmdline_fixed_string_t set;
9257 cmdline_fixed_string_t port;
9259 cmdline_fixed_string_t cmd;
9260 cmdline_fixed_string_t region;
9262 cmdline_fixed_string_t queue_start_index;
9264 cmdline_fixed_string_t queue_num;
9265 uint8_t queue_num_value;
9269 cmd_queue_region_parsed(void *parsed_result,
9270 __attribute__((unused)) struct cmdline *cl,
9271 __attribute__((unused)) void *data)
9273 struct cmd_queue_region_result *res = parsed_result;
9275 #ifdef RTE_LIBRTE_I40E_PMD
9276 struct rte_pmd_i40e_queue_region_conf region_conf;
9277 enum rte_pmd_i40e_queue_region_op op_type;
9280 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9283 #ifdef RTE_LIBRTE_I40E_PMD
9284 memset(®ion_conf, 0, sizeof(region_conf));
9285 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9286 region_conf.region_id = res->region_id;
9287 region_conf.queue_num = res->queue_num_value;
9288 region_conf.queue_start_index = res->queue_id;
9290 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9291 op_type, ®ion_conf);
9298 printf("function not implemented or supported\n");
9301 printf("queue region config error: (%s)\n", strerror(-ret));
9305 cmdline_parse_token_string_t cmd_queue_region_set =
9306 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9308 cmdline_parse_token_string_t cmd_queue_region_port =
9309 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9310 cmdline_parse_token_num_t cmd_queue_region_port_id =
9311 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9313 cmdline_parse_token_string_t cmd_queue_region_cmd =
9314 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9315 cmd, "queue-region");
9316 cmdline_parse_token_string_t cmd_queue_region_id =
9317 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9318 region, "region_id");
9319 cmdline_parse_token_num_t cmd_queue_region_index =
9320 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9322 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9323 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9324 queue_start_index, "queue_start_index");
9325 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9326 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9328 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9329 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9330 queue_num, "queue_num");
9331 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9332 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9333 queue_num_value, UINT8);
9335 cmdline_parse_inst_t cmd_queue_region = {
9336 .f = cmd_queue_region_parsed,
9338 .help_str = "set port <port_id> queue-region region_id <value> "
9339 "queue_start_index <value> queue_num <value>: Set a queue region",
9341 (void *)&cmd_queue_region_set,
9342 (void *)&cmd_queue_region_port,
9343 (void *)&cmd_queue_region_port_id,
9344 (void *)&cmd_queue_region_cmd,
9345 (void *)&cmd_queue_region_id,
9346 (void *)&cmd_queue_region_index,
9347 (void *)&cmd_queue_region_queue_start_index,
9348 (void *)&cmd_queue_region_queue_id,
9349 (void *)&cmd_queue_region_queue_num,
9350 (void *)&cmd_queue_region_queue_num_value,
9355 /* *** queue region and flowtype set *** */
9356 struct cmd_region_flowtype_result {
9357 cmdline_fixed_string_t set;
9358 cmdline_fixed_string_t port;
9360 cmdline_fixed_string_t cmd;
9361 cmdline_fixed_string_t region;
9363 cmdline_fixed_string_t flowtype;
9364 uint8_t flowtype_id;
9368 cmd_region_flowtype_parsed(void *parsed_result,
9369 __attribute__((unused)) struct cmdline *cl,
9370 __attribute__((unused)) void *data)
9372 struct cmd_region_flowtype_result *res = parsed_result;
9374 #ifdef RTE_LIBRTE_I40E_PMD
9375 struct rte_pmd_i40e_queue_region_conf region_conf;
9376 enum rte_pmd_i40e_queue_region_op op_type;
9379 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9382 #ifdef RTE_LIBRTE_I40E_PMD
9383 memset(®ion_conf, 0, sizeof(region_conf));
9385 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9386 region_conf.region_id = res->region_id;
9387 region_conf.hw_flowtype = res->flowtype_id;
9389 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9390 op_type, ®ion_conf);
9397 printf("function not implemented or supported\n");
9400 printf("region flowtype config error: (%s)\n", strerror(-ret));
9404 cmdline_parse_token_string_t cmd_region_flowtype_set =
9405 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9407 cmdline_parse_token_string_t cmd_region_flowtype_port =
9408 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9410 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9411 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9413 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9414 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9415 cmd, "queue-region");
9416 cmdline_parse_token_string_t cmd_region_flowtype_index =
9417 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9418 region, "region_id");
9419 cmdline_parse_token_num_t cmd_region_flowtype_id =
9420 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9422 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9423 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9424 flowtype, "flowtype");
9425 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9426 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9427 flowtype_id, UINT8);
9428 cmdline_parse_inst_t cmd_region_flowtype = {
9429 .f = cmd_region_flowtype_parsed,
9431 .help_str = "set port <port_id> queue-region region_id <value> "
9432 "flowtype <value>: Set a flowtype region index",
9434 (void *)&cmd_region_flowtype_set,
9435 (void *)&cmd_region_flowtype_port,
9436 (void *)&cmd_region_flowtype_port_index,
9437 (void *)&cmd_region_flowtype_cmd,
9438 (void *)&cmd_region_flowtype_index,
9439 (void *)&cmd_region_flowtype_id,
9440 (void *)&cmd_region_flowtype_flow_index,
9441 (void *)&cmd_region_flowtype_flow_id,
9446 /* *** User Priority (UP) to queue region (region_id) set *** */
9447 struct cmd_user_priority_region_result {
9448 cmdline_fixed_string_t set;
9449 cmdline_fixed_string_t port;
9451 cmdline_fixed_string_t cmd;
9452 cmdline_fixed_string_t user_priority;
9453 uint8_t user_priority_id;
9454 cmdline_fixed_string_t region;
9459 cmd_user_priority_region_parsed(void *parsed_result,
9460 __attribute__((unused)) struct cmdline *cl,
9461 __attribute__((unused)) void *data)
9463 struct cmd_user_priority_region_result *res = parsed_result;
9465 #ifdef RTE_LIBRTE_I40E_PMD
9466 struct rte_pmd_i40e_queue_region_conf region_conf;
9467 enum rte_pmd_i40e_queue_region_op op_type;
9470 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9473 #ifdef RTE_LIBRTE_I40E_PMD
9474 memset(®ion_conf, 0, sizeof(region_conf));
9475 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9476 region_conf.user_priority = res->user_priority_id;
9477 region_conf.region_id = res->region_id;
9479 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9480 op_type, ®ion_conf);
9487 printf("function not implemented or supported\n");
9490 printf("user_priority region config error: (%s)\n",
9495 cmdline_parse_token_string_t cmd_user_priority_region_set =
9496 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9498 cmdline_parse_token_string_t cmd_user_priority_region_port =
9499 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9501 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9502 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9504 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9505 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9506 cmd, "queue-region");
9507 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9508 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9509 user_priority, "UP");
9510 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9511 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9512 user_priority_id, UINT8);
9513 cmdline_parse_token_string_t cmd_user_priority_region_region =
9514 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9515 region, "region_id");
9516 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9517 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9520 cmdline_parse_inst_t cmd_user_priority_region = {
9521 .f = cmd_user_priority_region_parsed,
9523 .help_str = "set port <port_id> queue-region UP <value> "
9524 "region_id <value>: Set the mapping of User Priority (UP) "
9525 "to queue region (region_id) ",
9527 (void *)&cmd_user_priority_region_set,
9528 (void *)&cmd_user_priority_region_port,
9529 (void *)&cmd_user_priority_region_port_index,
9530 (void *)&cmd_user_priority_region_cmd,
9531 (void *)&cmd_user_priority_region_UP,
9532 (void *)&cmd_user_priority_region_UP_id,
9533 (void *)&cmd_user_priority_region_region,
9534 (void *)&cmd_user_priority_region_region_id,
9539 /* *** flush all queue region related configuration *** */
9540 struct cmd_flush_queue_region_result {
9541 cmdline_fixed_string_t set;
9542 cmdline_fixed_string_t port;
9544 cmdline_fixed_string_t cmd;
9545 cmdline_fixed_string_t flush;
9546 cmdline_fixed_string_t what;
9550 cmd_flush_queue_region_parsed(void *parsed_result,
9551 __attribute__((unused)) struct cmdline *cl,
9552 __attribute__((unused)) void *data)
9554 struct cmd_flush_queue_region_result *res = parsed_result;
9556 #ifdef RTE_LIBRTE_I40E_PMD
9557 struct rte_pmd_i40e_queue_region_conf region_conf;
9558 enum rte_pmd_i40e_queue_region_op op_type;
9561 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9564 #ifdef RTE_LIBRTE_I40E_PMD
9565 memset(®ion_conf, 0, sizeof(region_conf));
9567 if (strcmp(res->what, "on") == 0)
9568 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9570 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9572 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9573 op_type, ®ion_conf);
9580 printf("function not implemented or supported\n");
9583 printf("queue region config flush error: (%s)\n",
9588 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9589 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9591 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9592 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9594 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9595 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9597 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9598 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9599 cmd, "queue-region");
9600 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9601 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9603 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9604 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9607 cmdline_parse_inst_t cmd_flush_queue_region = {
9608 .f = cmd_flush_queue_region_parsed,
9610 .help_str = "set port <port_id> queue-region flush on|off"
9611 ": flush all queue region related configuration",
9613 (void *)&cmd_flush_queue_region_set,
9614 (void *)&cmd_flush_queue_region_port,
9615 (void *)&cmd_flush_queue_region_port_index,
9616 (void *)&cmd_flush_queue_region_cmd,
9617 (void *)&cmd_flush_queue_region_flush,
9618 (void *)&cmd_flush_queue_region_what,
9623 /* *** get all queue region related configuration info *** */
9624 struct cmd_show_queue_region_info {
9625 cmdline_fixed_string_t show;
9626 cmdline_fixed_string_t port;
9628 cmdline_fixed_string_t cmd;
9632 cmd_show_queue_region_info_parsed(void *parsed_result,
9633 __attribute__((unused)) struct cmdline *cl,
9634 __attribute__((unused)) void *data)
9636 struct cmd_show_queue_region_info *res = parsed_result;
9638 #ifdef RTE_LIBRTE_I40E_PMD
9639 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9640 enum rte_pmd_i40e_queue_region_op op_type;
9643 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9646 #ifdef RTE_LIBRTE_I40E_PMD
9647 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9649 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9651 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9652 op_type, &rte_pmd_regions);
9654 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9661 printf("function not implemented or supported\n");
9664 printf("queue region config info show error: (%s)\n",
9669 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9670 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9672 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9673 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9675 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9676 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9678 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9679 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9680 cmd, "queue-region");
9682 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9683 .f = cmd_show_queue_region_info_parsed,
9685 .help_str = "show port <port_id> queue-region"
9686 ": show all queue region related configuration info",
9688 (void *)&cmd_show_queue_region_info_get,
9689 (void *)&cmd_show_queue_region_info_port,
9690 (void *)&cmd_show_queue_region_info_port_index,
9691 (void *)&cmd_show_queue_region_info_cmd,
9696 /* *** ADD/REMOVE A 2tuple FILTER *** */
9697 struct cmd_2tuple_filter_result {
9698 cmdline_fixed_string_t filter;
9700 cmdline_fixed_string_t ops;
9701 cmdline_fixed_string_t dst_port;
9702 uint16_t dst_port_value;
9703 cmdline_fixed_string_t protocol;
9704 uint8_t protocol_value;
9705 cmdline_fixed_string_t mask;
9707 cmdline_fixed_string_t tcp_flags;
9708 uint8_t tcp_flags_value;
9709 cmdline_fixed_string_t priority;
9710 uint8_t priority_value;
9711 cmdline_fixed_string_t queue;
9716 cmd_2tuple_filter_parsed(void *parsed_result,
9717 __attribute__((unused)) struct cmdline *cl,
9718 __attribute__((unused)) void *data)
9720 struct rte_eth_ntuple_filter filter;
9721 struct cmd_2tuple_filter_result *res = parsed_result;
9724 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9726 printf("ntuple filter is not supported on port %u.\n",
9731 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9733 filter.flags = RTE_2TUPLE_FLAGS;
9734 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9735 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9736 filter.proto = res->protocol_value;
9737 filter.priority = res->priority_value;
9738 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9739 printf("nonzero tcp_flags is only meaningful"
9740 " when protocol is TCP.\n");
9743 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9744 printf("invalid TCP flags.\n");
9748 if (res->tcp_flags_value != 0) {
9749 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9750 filter.tcp_flags = res->tcp_flags_value;
9753 /* need convert to big endian. */
9754 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9755 filter.queue = res->queue_id;
9757 if (!strcmp(res->ops, "add"))
9758 ret = rte_eth_dev_filter_ctrl(res->port_id,
9759 RTE_ETH_FILTER_NTUPLE,
9763 ret = rte_eth_dev_filter_ctrl(res->port_id,
9764 RTE_ETH_FILTER_NTUPLE,
9765 RTE_ETH_FILTER_DELETE,
9768 printf("2tuple filter programming error: (%s)\n",
9773 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9774 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9775 filter, "2tuple_filter");
9776 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9777 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9779 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9780 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9782 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9783 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9784 dst_port, "dst_port");
9785 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9786 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9787 dst_port_value, UINT16);
9788 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9789 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9790 protocol, "protocol");
9791 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9792 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9793 protocol_value, UINT8);
9794 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9795 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9797 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9798 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9800 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9801 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9802 tcp_flags, "tcp_flags");
9803 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9804 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9805 tcp_flags_value, UINT8);
9806 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9807 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9808 priority, "priority");
9809 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9810 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9811 priority_value, UINT8);
9812 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9813 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9815 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9816 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9819 cmdline_parse_inst_t cmd_2tuple_filter = {
9820 .f = cmd_2tuple_filter_parsed,
9822 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9823 "<value> mask <value> tcp_flags <value> priority <value> queue "
9824 "<queue_id>: Add a 2tuple filter",
9826 (void *)&cmd_2tuple_filter_filter,
9827 (void *)&cmd_2tuple_filter_port_id,
9828 (void *)&cmd_2tuple_filter_ops,
9829 (void *)&cmd_2tuple_filter_dst_port,
9830 (void *)&cmd_2tuple_filter_dst_port_value,
9831 (void *)&cmd_2tuple_filter_protocol,
9832 (void *)&cmd_2tuple_filter_protocol_value,
9833 (void *)&cmd_2tuple_filter_mask,
9834 (void *)&cmd_2tuple_filter_mask_value,
9835 (void *)&cmd_2tuple_filter_tcp_flags,
9836 (void *)&cmd_2tuple_filter_tcp_flags_value,
9837 (void *)&cmd_2tuple_filter_priority,
9838 (void *)&cmd_2tuple_filter_priority_value,
9839 (void *)&cmd_2tuple_filter_queue,
9840 (void *)&cmd_2tuple_filter_queue_id,
9845 /* *** ADD/REMOVE A 5tuple FILTER *** */
9846 struct cmd_5tuple_filter_result {
9847 cmdline_fixed_string_t filter;
9849 cmdline_fixed_string_t ops;
9850 cmdline_fixed_string_t dst_ip;
9851 cmdline_ipaddr_t dst_ip_value;
9852 cmdline_fixed_string_t src_ip;
9853 cmdline_ipaddr_t src_ip_value;
9854 cmdline_fixed_string_t dst_port;
9855 uint16_t dst_port_value;
9856 cmdline_fixed_string_t src_port;
9857 uint16_t src_port_value;
9858 cmdline_fixed_string_t protocol;
9859 uint8_t protocol_value;
9860 cmdline_fixed_string_t mask;
9862 cmdline_fixed_string_t tcp_flags;
9863 uint8_t tcp_flags_value;
9864 cmdline_fixed_string_t priority;
9865 uint8_t priority_value;
9866 cmdline_fixed_string_t queue;
9871 cmd_5tuple_filter_parsed(void *parsed_result,
9872 __attribute__((unused)) struct cmdline *cl,
9873 __attribute__((unused)) void *data)
9875 struct rte_eth_ntuple_filter filter;
9876 struct cmd_5tuple_filter_result *res = parsed_result;
9879 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9881 printf("ntuple filter is not supported on port %u.\n",
9886 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9888 filter.flags = RTE_5TUPLE_FLAGS;
9889 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9890 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9891 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9892 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9893 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9894 filter.proto = res->protocol_value;
9895 filter.priority = res->priority_value;
9896 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9897 printf("nonzero tcp_flags is only meaningful"
9898 " when protocol is TCP.\n");
9901 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9902 printf("invalid TCP flags.\n");
9906 if (res->tcp_flags_value != 0) {
9907 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9908 filter.tcp_flags = res->tcp_flags_value;
9911 if (res->dst_ip_value.family == AF_INET)
9912 /* no need to convert, already big endian. */
9913 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9915 if (filter.dst_ip_mask == 0) {
9916 printf("can not support ipv6 involved compare.\n");
9922 if (res->src_ip_value.family == AF_INET)
9923 /* no need to convert, already big endian. */
9924 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9926 if (filter.src_ip_mask == 0) {
9927 printf("can not support ipv6 involved compare.\n");
9932 /* need convert to big endian. */
9933 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9934 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9935 filter.queue = res->queue_id;
9937 if (!strcmp(res->ops, "add"))
9938 ret = rte_eth_dev_filter_ctrl(res->port_id,
9939 RTE_ETH_FILTER_NTUPLE,
9943 ret = rte_eth_dev_filter_ctrl(res->port_id,
9944 RTE_ETH_FILTER_NTUPLE,
9945 RTE_ETH_FILTER_DELETE,
9948 printf("5tuple filter programming error: (%s)\n",
9952 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9953 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9954 filter, "5tuple_filter");
9955 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9956 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9958 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9959 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9961 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9962 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9964 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9965 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9967 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
9968 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9970 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
9971 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
9973 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
9974 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9975 dst_port, "dst_port");
9976 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
9977 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9978 dst_port_value, UINT16);
9979 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
9980 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9981 src_port, "src_port");
9982 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
9983 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9984 src_port_value, UINT16);
9985 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
9986 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9987 protocol, "protocol");
9988 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
9989 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9990 protocol_value, UINT8);
9991 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
9992 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9994 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
9995 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9997 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
9998 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9999 tcp_flags, "tcp_flags");
10000 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10001 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10002 tcp_flags_value, UINT8);
10003 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10004 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10005 priority, "priority");
10006 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10007 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10008 priority_value, UINT8);
10009 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10010 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10012 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10013 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10016 cmdline_parse_inst_t cmd_5tuple_filter = {
10017 .f = cmd_5tuple_filter_parsed,
10019 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10020 "src_ip <value> dst_port <value> src_port <value> "
10021 "protocol <value> mask <value> tcp_flags <value> "
10022 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10024 (void *)&cmd_5tuple_filter_filter,
10025 (void *)&cmd_5tuple_filter_port_id,
10026 (void *)&cmd_5tuple_filter_ops,
10027 (void *)&cmd_5tuple_filter_dst_ip,
10028 (void *)&cmd_5tuple_filter_dst_ip_value,
10029 (void *)&cmd_5tuple_filter_src_ip,
10030 (void *)&cmd_5tuple_filter_src_ip_value,
10031 (void *)&cmd_5tuple_filter_dst_port,
10032 (void *)&cmd_5tuple_filter_dst_port_value,
10033 (void *)&cmd_5tuple_filter_src_port,
10034 (void *)&cmd_5tuple_filter_src_port_value,
10035 (void *)&cmd_5tuple_filter_protocol,
10036 (void *)&cmd_5tuple_filter_protocol_value,
10037 (void *)&cmd_5tuple_filter_mask,
10038 (void *)&cmd_5tuple_filter_mask_value,
10039 (void *)&cmd_5tuple_filter_tcp_flags,
10040 (void *)&cmd_5tuple_filter_tcp_flags_value,
10041 (void *)&cmd_5tuple_filter_priority,
10042 (void *)&cmd_5tuple_filter_priority_value,
10043 (void *)&cmd_5tuple_filter_queue,
10044 (void *)&cmd_5tuple_filter_queue_id,
10049 /* *** ADD/REMOVE A flex FILTER *** */
10050 struct cmd_flex_filter_result {
10051 cmdline_fixed_string_t filter;
10052 cmdline_fixed_string_t ops;
10054 cmdline_fixed_string_t len;
10056 cmdline_fixed_string_t bytes;
10057 cmdline_fixed_string_t bytes_value;
10058 cmdline_fixed_string_t mask;
10059 cmdline_fixed_string_t mask_value;
10060 cmdline_fixed_string_t priority;
10061 uint8_t priority_value;
10062 cmdline_fixed_string_t queue;
10066 static int xdigit2val(unsigned char c)
10071 else if (isupper(c))
10072 val = c - 'A' + 10;
10074 val = c - 'a' + 10;
10079 cmd_flex_filter_parsed(void *parsed_result,
10080 __attribute__((unused)) struct cmdline *cl,
10081 __attribute__((unused)) void *data)
10084 struct rte_eth_flex_filter filter;
10085 struct cmd_flex_filter_result *res = parsed_result;
10086 char *bytes_ptr, *mask_ptr;
10087 uint16_t len, i, j = 0;
10092 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10093 printf("the len exceed the max length 128\n");
10096 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10097 filter.len = res->len_value;
10098 filter.priority = res->priority_value;
10099 filter.queue = res->queue_id;
10100 bytes_ptr = res->bytes_value;
10101 mask_ptr = res->mask_value;
10103 /* translate bytes string to array. */
10104 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10105 (bytes_ptr[1] == 'X')))
10107 len = strnlen(bytes_ptr, res->len_value * 2);
10108 if (len == 0 || (len % 8 != 0)) {
10109 printf("please check len and bytes input\n");
10112 for (i = 0; i < len; i++) {
10114 if (isxdigit(c) == 0) {
10115 /* invalid characters. */
10116 printf("invalid input\n");
10119 val = xdigit2val(c);
10122 filter.bytes[j] = byte;
10123 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10130 /* translate mask string to uint8_t array. */
10131 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10132 (mask_ptr[1] == 'X')))
10134 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10136 printf("invalid input\n");
10141 for (i = 0; i < len; i++) {
10143 if (isxdigit(c) == 0) {
10144 /* invalid characters. */
10145 printf("invalid input\n");
10148 val = xdigit2val(c);
10151 filter.mask[j] = byte;
10152 printf("mask[%d]:%02x ", j, filter.mask[j]);
10160 if (!strcmp(res->ops, "add"))
10161 ret = rte_eth_dev_filter_ctrl(res->port_id,
10162 RTE_ETH_FILTER_FLEXIBLE,
10163 RTE_ETH_FILTER_ADD,
10166 ret = rte_eth_dev_filter_ctrl(res->port_id,
10167 RTE_ETH_FILTER_FLEXIBLE,
10168 RTE_ETH_FILTER_DELETE,
10172 printf("flex filter setting error: (%s)\n", strerror(-ret));
10175 cmdline_parse_token_string_t cmd_flex_filter_filter =
10176 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10177 filter, "flex_filter");
10178 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10179 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10181 cmdline_parse_token_string_t cmd_flex_filter_ops =
10182 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10184 cmdline_parse_token_string_t cmd_flex_filter_len =
10185 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10187 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10188 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10190 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10191 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10193 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10194 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10195 bytes_value, NULL);
10196 cmdline_parse_token_string_t cmd_flex_filter_mask =
10197 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10199 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10200 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10202 cmdline_parse_token_string_t cmd_flex_filter_priority =
10203 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10204 priority, "priority");
10205 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10206 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10207 priority_value, UINT8);
10208 cmdline_parse_token_string_t cmd_flex_filter_queue =
10209 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10211 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10212 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10214 cmdline_parse_inst_t cmd_flex_filter = {
10215 .f = cmd_flex_filter_parsed,
10217 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10218 "<value> mask <value> priority <value> queue <queue_id>: "
10219 "Add/Del a flex filter",
10221 (void *)&cmd_flex_filter_filter,
10222 (void *)&cmd_flex_filter_port_id,
10223 (void *)&cmd_flex_filter_ops,
10224 (void *)&cmd_flex_filter_len,
10225 (void *)&cmd_flex_filter_len_value,
10226 (void *)&cmd_flex_filter_bytes,
10227 (void *)&cmd_flex_filter_bytes_value,
10228 (void *)&cmd_flex_filter_mask,
10229 (void *)&cmd_flex_filter_mask_value,
10230 (void *)&cmd_flex_filter_priority,
10231 (void *)&cmd_flex_filter_priority_value,
10232 (void *)&cmd_flex_filter_queue,
10233 (void *)&cmd_flex_filter_queue_id,
10238 /* *** Filters Control *** */
10240 /* *** deal with ethertype filter *** */
10241 struct cmd_ethertype_filter_result {
10242 cmdline_fixed_string_t filter;
10244 cmdline_fixed_string_t ops;
10245 cmdline_fixed_string_t mac;
10246 struct ether_addr mac_addr;
10247 cmdline_fixed_string_t ethertype;
10248 uint16_t ethertype_value;
10249 cmdline_fixed_string_t drop;
10250 cmdline_fixed_string_t queue;
10254 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10255 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10256 filter, "ethertype_filter");
10257 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10258 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10260 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10261 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10263 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10264 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10265 mac, "mac_addr#mac_ignr");
10266 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10267 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10269 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10270 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10271 ethertype, "ethertype");
10272 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10273 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10274 ethertype_value, UINT16);
10275 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10276 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10278 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10279 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10281 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10282 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10286 cmd_ethertype_filter_parsed(void *parsed_result,
10287 __attribute__((unused)) struct cmdline *cl,
10288 __attribute__((unused)) void *data)
10290 struct cmd_ethertype_filter_result *res = parsed_result;
10291 struct rte_eth_ethertype_filter filter;
10294 ret = rte_eth_dev_filter_supported(res->port_id,
10295 RTE_ETH_FILTER_ETHERTYPE);
10297 printf("ethertype filter is not supported on port %u.\n",
10302 memset(&filter, 0, sizeof(filter));
10303 if (!strcmp(res->mac, "mac_addr")) {
10304 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10305 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10306 sizeof(struct ether_addr));
10308 if (!strcmp(res->drop, "drop"))
10309 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10310 filter.ether_type = res->ethertype_value;
10311 filter.queue = res->queue_id;
10313 if (!strcmp(res->ops, "add"))
10314 ret = rte_eth_dev_filter_ctrl(res->port_id,
10315 RTE_ETH_FILTER_ETHERTYPE,
10316 RTE_ETH_FILTER_ADD,
10319 ret = rte_eth_dev_filter_ctrl(res->port_id,
10320 RTE_ETH_FILTER_ETHERTYPE,
10321 RTE_ETH_FILTER_DELETE,
10324 printf("ethertype filter programming error: (%s)\n",
10328 cmdline_parse_inst_t cmd_ethertype_filter = {
10329 .f = cmd_ethertype_filter_parsed,
10331 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10332 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10333 "Add or delete an ethertype filter entry",
10335 (void *)&cmd_ethertype_filter_filter,
10336 (void *)&cmd_ethertype_filter_port_id,
10337 (void *)&cmd_ethertype_filter_ops,
10338 (void *)&cmd_ethertype_filter_mac,
10339 (void *)&cmd_ethertype_filter_mac_addr,
10340 (void *)&cmd_ethertype_filter_ethertype,
10341 (void *)&cmd_ethertype_filter_ethertype_value,
10342 (void *)&cmd_ethertype_filter_drop,
10343 (void *)&cmd_ethertype_filter_queue,
10344 (void *)&cmd_ethertype_filter_queue_id,
10349 /* *** deal with flow director filter *** */
10350 struct cmd_flow_director_result {
10351 cmdline_fixed_string_t flow_director_filter;
10353 cmdline_fixed_string_t mode;
10354 cmdline_fixed_string_t mode_value;
10355 cmdline_fixed_string_t ops;
10356 cmdline_fixed_string_t flow;
10357 cmdline_fixed_string_t flow_type;
10358 cmdline_fixed_string_t ether;
10359 uint16_t ether_type;
10360 cmdline_fixed_string_t src;
10361 cmdline_ipaddr_t ip_src;
10363 cmdline_fixed_string_t dst;
10364 cmdline_ipaddr_t ip_dst;
10366 cmdline_fixed_string_t verify_tag;
10367 uint32_t verify_tag_value;
10368 cmdline_fixed_string_t tos;
10370 cmdline_fixed_string_t proto;
10371 uint8_t proto_value;
10372 cmdline_fixed_string_t ttl;
10374 cmdline_fixed_string_t vlan;
10375 uint16_t vlan_value;
10376 cmdline_fixed_string_t flexbytes;
10377 cmdline_fixed_string_t flexbytes_value;
10378 cmdline_fixed_string_t pf_vf;
10379 cmdline_fixed_string_t drop;
10380 cmdline_fixed_string_t queue;
10382 cmdline_fixed_string_t fd_id;
10383 uint32_t fd_id_value;
10384 cmdline_fixed_string_t mac;
10385 struct ether_addr mac_addr;
10386 cmdline_fixed_string_t tunnel;
10387 cmdline_fixed_string_t tunnel_type;
10388 cmdline_fixed_string_t tunnel_id;
10389 uint32_t tunnel_id_value;
10390 cmdline_fixed_string_t packet;
10395 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10398 const char *p, *p0 = q_arg;
10400 unsigned long int_fld;
10401 char *str_fld[max_num];
10406 p = strchr(p0, '(');
10410 p0 = strchr(p, ')');
10415 if (size >= sizeof(s))
10418 snprintf(s, sizeof(s), "%.*s", size, p);
10419 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10420 if (ret < 0 || ret > max_num)
10422 for (i = 0; i < ret; i++) {
10424 int_fld = strtoul(str_fld[i], &end, 0);
10425 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10427 flexbytes[i] = (uint8_t)int_fld;
10433 str2flowtype(char *string)
10436 static const struct {
10439 } flowtype_str[] = {
10440 {"raw", RTE_ETH_FLOW_RAW},
10441 {"ipv4", RTE_ETH_FLOW_IPV4},
10442 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10443 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10444 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10445 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10446 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10447 {"ipv6", RTE_ETH_FLOW_IPV6},
10448 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10449 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10450 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10451 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10452 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10453 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10456 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10457 if (!strcmp(flowtype_str[i].str, string))
10458 return flowtype_str[i].type;
10461 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10462 return (uint16_t)atoi(string);
10464 return RTE_ETH_FLOW_UNKNOWN;
10467 static enum rte_eth_fdir_tunnel_type
10468 str2fdir_tunneltype(char *string)
10472 static const struct {
10474 enum rte_eth_fdir_tunnel_type type;
10475 } tunneltype_str[] = {
10476 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10477 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10480 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10481 if (!strcmp(tunneltype_str[i].str, string))
10482 return tunneltype_str[i].type;
10484 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10487 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10489 if ((ip_addr).family == AF_INET) \
10490 (ip) = (ip_addr).addr.ipv4.s_addr; \
10492 printf("invalid parameter.\n"); \
10497 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10499 if ((ip_addr).family == AF_INET6) \
10500 rte_memcpy(&(ip), \
10501 &((ip_addr).addr.ipv6), \
10502 sizeof(struct in6_addr)); \
10504 printf("invalid parameter.\n"); \
10510 cmd_flow_director_filter_parsed(void *parsed_result,
10511 __attribute__((unused)) struct cmdline *cl,
10512 __attribute__((unused)) void *data)
10514 struct cmd_flow_director_result *res = parsed_result;
10515 struct rte_eth_fdir_filter entry;
10516 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10518 unsigned long vf_id;
10521 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10523 printf("flow director is not supported on port %u.\n",
10527 memset(flexbytes, 0, sizeof(flexbytes));
10528 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10530 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10531 if (strcmp(res->mode_value, "MAC-VLAN")) {
10532 printf("Please set mode to MAC-VLAN.\n");
10535 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10536 if (strcmp(res->mode_value, "Tunnel")) {
10537 printf("Please set mode to Tunnel.\n");
10541 if (!strcmp(res->mode_value, "raw")) {
10542 #ifdef RTE_LIBRTE_I40E_PMD
10543 struct rte_pmd_i40e_flow_type_mapping
10544 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10545 struct rte_pmd_i40e_pkt_template_conf conf;
10546 uint16_t flow_type = str2flowtype(res->flow_type);
10547 uint16_t i, port = res->port_id;
10550 memset(&conf, 0, sizeof(conf));
10552 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10553 printf("Invalid flow type specified.\n");
10556 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10560 if (mapping[flow_type].pctype == 0ULL) {
10561 printf("Invalid flow type specified.\n");
10564 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10565 if (mapping[flow_type].pctype & (1ULL << i)) {
10566 conf.input.pctype = i;
10571 conf.input.packet = open_file(res->filepath,
10572 &conf.input.length);
10573 if (!conf.input.packet)
10575 if (!strcmp(res->drop, "drop"))
10576 conf.action.behavior =
10577 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10579 conf.action.behavior =
10580 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10581 conf.action.report_status =
10582 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10583 conf.action.rx_queue = res->queue_id;
10584 conf.soft_id = res->fd_id_value;
10585 add = strcmp(res->ops, "del") ? 1 : 0;
10586 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10590 printf("flow director config error: (%s)\n",
10592 close_file(conf.input.packet);
10595 } else if (strcmp(res->mode_value, "IP")) {
10596 printf("Please set mode to IP or raw.\n");
10599 entry.input.flow_type = str2flowtype(res->flow_type);
10602 ret = parse_flexbytes(res->flexbytes_value,
10604 RTE_ETH_FDIR_MAX_FLEXLEN);
10606 printf("error: Cannot parse flexbytes input.\n");
10610 switch (entry.input.flow_type) {
10611 case RTE_ETH_FLOW_FRAG_IPV4:
10612 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10613 entry.input.flow.ip4_flow.proto = res->proto_value;
10615 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10616 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10617 IPV4_ADDR_TO_UINT(res->ip_dst,
10618 entry.input.flow.ip4_flow.dst_ip);
10619 IPV4_ADDR_TO_UINT(res->ip_src,
10620 entry.input.flow.ip4_flow.src_ip);
10621 entry.input.flow.ip4_flow.tos = res->tos_value;
10622 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10623 /* need convert to big endian. */
10624 entry.input.flow.udp4_flow.dst_port =
10625 rte_cpu_to_be_16(res->port_dst);
10626 entry.input.flow.udp4_flow.src_port =
10627 rte_cpu_to_be_16(res->port_src);
10629 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10630 IPV4_ADDR_TO_UINT(res->ip_dst,
10631 entry.input.flow.sctp4_flow.ip.dst_ip);
10632 IPV4_ADDR_TO_UINT(res->ip_src,
10633 entry.input.flow.sctp4_flow.ip.src_ip);
10634 entry.input.flow.ip4_flow.tos = res->tos_value;
10635 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10636 /* need convert to big endian. */
10637 entry.input.flow.sctp4_flow.dst_port =
10638 rte_cpu_to_be_16(res->port_dst);
10639 entry.input.flow.sctp4_flow.src_port =
10640 rte_cpu_to_be_16(res->port_src);
10641 entry.input.flow.sctp4_flow.verify_tag =
10642 rte_cpu_to_be_32(res->verify_tag_value);
10644 case RTE_ETH_FLOW_FRAG_IPV6:
10645 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10646 entry.input.flow.ipv6_flow.proto = res->proto_value;
10648 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10649 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10650 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10651 entry.input.flow.ipv6_flow.dst_ip);
10652 IPV6_ADDR_TO_ARRAY(res->ip_src,
10653 entry.input.flow.ipv6_flow.src_ip);
10654 entry.input.flow.ipv6_flow.tc = res->tos_value;
10655 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10656 /* need convert to big endian. */
10657 entry.input.flow.udp6_flow.dst_port =
10658 rte_cpu_to_be_16(res->port_dst);
10659 entry.input.flow.udp6_flow.src_port =
10660 rte_cpu_to_be_16(res->port_src);
10662 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10663 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10664 entry.input.flow.sctp6_flow.ip.dst_ip);
10665 IPV6_ADDR_TO_ARRAY(res->ip_src,
10666 entry.input.flow.sctp6_flow.ip.src_ip);
10667 entry.input.flow.ipv6_flow.tc = res->tos_value;
10668 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10669 /* need convert to big endian. */
10670 entry.input.flow.sctp6_flow.dst_port =
10671 rte_cpu_to_be_16(res->port_dst);
10672 entry.input.flow.sctp6_flow.src_port =
10673 rte_cpu_to_be_16(res->port_src);
10674 entry.input.flow.sctp6_flow.verify_tag =
10675 rte_cpu_to_be_32(res->verify_tag_value);
10677 case RTE_ETH_FLOW_L2_PAYLOAD:
10678 entry.input.flow.l2_flow.ether_type =
10679 rte_cpu_to_be_16(res->ether_type);
10685 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10686 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10688 sizeof(struct ether_addr));
10690 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10691 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10693 sizeof(struct ether_addr));
10694 entry.input.flow.tunnel_flow.tunnel_type =
10695 str2fdir_tunneltype(res->tunnel_type);
10696 entry.input.flow.tunnel_flow.tunnel_id =
10697 rte_cpu_to_be_32(res->tunnel_id_value);
10700 rte_memcpy(entry.input.flow_ext.flexbytes,
10702 RTE_ETH_FDIR_MAX_FLEXLEN);
10704 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10706 entry.action.flex_off = 0; /*use 0 by default */
10707 if (!strcmp(res->drop, "drop"))
10708 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10710 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10712 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10713 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10714 if (!strcmp(res->pf_vf, "pf"))
10715 entry.input.flow_ext.is_vf = 0;
10716 else if (!strncmp(res->pf_vf, "vf", 2)) {
10717 struct rte_eth_dev_info dev_info;
10719 memset(&dev_info, 0, sizeof(dev_info));
10720 rte_eth_dev_info_get(res->port_id, &dev_info);
10722 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10723 if (errno != 0 || *end != '\0' ||
10724 vf_id >= dev_info.max_vfs) {
10725 printf("invalid parameter %s.\n", res->pf_vf);
10728 entry.input.flow_ext.is_vf = 1;
10729 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10731 printf("invalid parameter %s.\n", res->pf_vf);
10736 /* set to report FD ID by default */
10737 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10738 entry.action.rx_queue = res->queue_id;
10739 entry.soft_id = res->fd_id_value;
10740 if (!strcmp(res->ops, "add"))
10741 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10742 RTE_ETH_FILTER_ADD, &entry);
10743 else if (!strcmp(res->ops, "del"))
10744 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10745 RTE_ETH_FILTER_DELETE, &entry);
10747 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10748 RTE_ETH_FILTER_UPDATE, &entry);
10750 printf("flow director programming error: (%s)\n",
10754 cmdline_parse_token_string_t cmd_flow_director_filter =
10755 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10756 flow_director_filter, "flow_director_filter");
10757 cmdline_parse_token_num_t cmd_flow_director_port_id =
10758 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10760 cmdline_parse_token_string_t cmd_flow_director_ops =
10761 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10762 ops, "add#del#update");
10763 cmdline_parse_token_string_t cmd_flow_director_flow =
10764 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10766 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10767 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10769 cmdline_parse_token_string_t cmd_flow_director_ether =
10770 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10772 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10773 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10774 ether_type, UINT16);
10775 cmdline_parse_token_string_t cmd_flow_director_src =
10776 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10778 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10779 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10781 cmdline_parse_token_num_t cmd_flow_director_port_src =
10782 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10784 cmdline_parse_token_string_t cmd_flow_director_dst =
10785 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10787 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10788 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10790 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10791 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10793 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10794 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10795 verify_tag, "verify_tag");
10796 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10797 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10798 verify_tag_value, UINT32);
10799 cmdline_parse_token_string_t cmd_flow_director_tos =
10800 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10802 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10803 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10805 cmdline_parse_token_string_t cmd_flow_director_proto =
10806 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10808 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10809 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10810 proto_value, UINT8);
10811 cmdline_parse_token_string_t cmd_flow_director_ttl =
10812 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10814 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10815 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10817 cmdline_parse_token_string_t cmd_flow_director_vlan =
10818 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10820 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10821 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10822 vlan_value, UINT16);
10823 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10824 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10825 flexbytes, "flexbytes");
10826 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10827 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10828 flexbytes_value, NULL);
10829 cmdline_parse_token_string_t cmd_flow_director_drop =
10830 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10832 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10833 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10835 cmdline_parse_token_string_t cmd_flow_director_queue =
10836 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10838 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10839 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10841 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10842 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10844 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10845 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10846 fd_id_value, UINT32);
10848 cmdline_parse_token_string_t cmd_flow_director_mode =
10849 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10851 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10854 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10855 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10856 mode_value, "MAC-VLAN");
10857 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10859 mode_value, "Tunnel");
10860 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10862 mode_value, "raw");
10863 cmdline_parse_token_string_t cmd_flow_director_mac =
10864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10866 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10867 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10869 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10872 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10873 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10874 tunnel_type, "NVGRE#VxLAN");
10875 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10877 tunnel_id, "tunnel-id");
10878 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10879 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10880 tunnel_id_value, UINT32);
10881 cmdline_parse_token_string_t cmd_flow_director_packet =
10882 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10884 cmdline_parse_token_string_t cmd_flow_director_filepath =
10885 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10888 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10889 .f = cmd_flow_director_filter_parsed,
10891 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10892 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10893 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10894 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10895 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10896 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10897 "fd_id <fd_id_value>: "
10898 "Add or delete an ip flow director entry on NIC",
10900 (void *)&cmd_flow_director_filter,
10901 (void *)&cmd_flow_director_port_id,
10902 (void *)&cmd_flow_director_mode,
10903 (void *)&cmd_flow_director_mode_ip,
10904 (void *)&cmd_flow_director_ops,
10905 (void *)&cmd_flow_director_flow,
10906 (void *)&cmd_flow_director_flow_type,
10907 (void *)&cmd_flow_director_src,
10908 (void *)&cmd_flow_director_ip_src,
10909 (void *)&cmd_flow_director_dst,
10910 (void *)&cmd_flow_director_ip_dst,
10911 (void *)&cmd_flow_director_tos,
10912 (void *)&cmd_flow_director_tos_value,
10913 (void *)&cmd_flow_director_proto,
10914 (void *)&cmd_flow_director_proto_value,
10915 (void *)&cmd_flow_director_ttl,
10916 (void *)&cmd_flow_director_ttl_value,
10917 (void *)&cmd_flow_director_vlan,
10918 (void *)&cmd_flow_director_vlan_value,
10919 (void *)&cmd_flow_director_flexbytes,
10920 (void *)&cmd_flow_director_flexbytes_value,
10921 (void *)&cmd_flow_director_drop,
10922 (void *)&cmd_flow_director_pf_vf,
10923 (void *)&cmd_flow_director_queue,
10924 (void *)&cmd_flow_director_queue_id,
10925 (void *)&cmd_flow_director_fd_id,
10926 (void *)&cmd_flow_director_fd_id_value,
10931 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10932 .f = cmd_flow_director_filter_parsed,
10934 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10935 "director entry on NIC",
10937 (void *)&cmd_flow_director_filter,
10938 (void *)&cmd_flow_director_port_id,
10939 (void *)&cmd_flow_director_mode,
10940 (void *)&cmd_flow_director_mode_ip,
10941 (void *)&cmd_flow_director_ops,
10942 (void *)&cmd_flow_director_flow,
10943 (void *)&cmd_flow_director_flow_type,
10944 (void *)&cmd_flow_director_src,
10945 (void *)&cmd_flow_director_ip_src,
10946 (void *)&cmd_flow_director_port_src,
10947 (void *)&cmd_flow_director_dst,
10948 (void *)&cmd_flow_director_ip_dst,
10949 (void *)&cmd_flow_director_port_dst,
10950 (void *)&cmd_flow_director_tos,
10951 (void *)&cmd_flow_director_tos_value,
10952 (void *)&cmd_flow_director_ttl,
10953 (void *)&cmd_flow_director_ttl_value,
10954 (void *)&cmd_flow_director_vlan,
10955 (void *)&cmd_flow_director_vlan_value,
10956 (void *)&cmd_flow_director_flexbytes,
10957 (void *)&cmd_flow_director_flexbytes_value,
10958 (void *)&cmd_flow_director_drop,
10959 (void *)&cmd_flow_director_pf_vf,
10960 (void *)&cmd_flow_director_queue,
10961 (void *)&cmd_flow_director_queue_id,
10962 (void *)&cmd_flow_director_fd_id,
10963 (void *)&cmd_flow_director_fd_id_value,
10968 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
10969 .f = cmd_flow_director_filter_parsed,
10971 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
10972 "director entry on NIC",
10974 (void *)&cmd_flow_director_filter,
10975 (void *)&cmd_flow_director_port_id,
10976 (void *)&cmd_flow_director_mode,
10977 (void *)&cmd_flow_director_mode_ip,
10978 (void *)&cmd_flow_director_ops,
10979 (void *)&cmd_flow_director_flow,
10980 (void *)&cmd_flow_director_flow_type,
10981 (void *)&cmd_flow_director_src,
10982 (void *)&cmd_flow_director_ip_src,
10983 (void *)&cmd_flow_director_port_src,
10984 (void *)&cmd_flow_director_dst,
10985 (void *)&cmd_flow_director_ip_dst,
10986 (void *)&cmd_flow_director_port_dst,
10987 (void *)&cmd_flow_director_verify_tag,
10988 (void *)&cmd_flow_director_verify_tag_value,
10989 (void *)&cmd_flow_director_tos,
10990 (void *)&cmd_flow_director_tos_value,
10991 (void *)&cmd_flow_director_ttl,
10992 (void *)&cmd_flow_director_ttl_value,
10993 (void *)&cmd_flow_director_vlan,
10994 (void *)&cmd_flow_director_vlan_value,
10995 (void *)&cmd_flow_director_flexbytes,
10996 (void *)&cmd_flow_director_flexbytes_value,
10997 (void *)&cmd_flow_director_drop,
10998 (void *)&cmd_flow_director_pf_vf,
10999 (void *)&cmd_flow_director_queue,
11000 (void *)&cmd_flow_director_queue_id,
11001 (void *)&cmd_flow_director_fd_id,
11002 (void *)&cmd_flow_director_fd_id_value,
11007 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11008 .f = cmd_flow_director_filter_parsed,
11010 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11011 "director entry on NIC",
11013 (void *)&cmd_flow_director_filter,
11014 (void *)&cmd_flow_director_port_id,
11015 (void *)&cmd_flow_director_mode,
11016 (void *)&cmd_flow_director_mode_ip,
11017 (void *)&cmd_flow_director_ops,
11018 (void *)&cmd_flow_director_flow,
11019 (void *)&cmd_flow_director_flow_type,
11020 (void *)&cmd_flow_director_ether,
11021 (void *)&cmd_flow_director_ether_type,
11022 (void *)&cmd_flow_director_flexbytes,
11023 (void *)&cmd_flow_director_flexbytes_value,
11024 (void *)&cmd_flow_director_drop,
11025 (void *)&cmd_flow_director_pf_vf,
11026 (void *)&cmd_flow_director_queue,
11027 (void *)&cmd_flow_director_queue_id,
11028 (void *)&cmd_flow_director_fd_id,
11029 (void *)&cmd_flow_director_fd_id_value,
11034 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11035 .f = cmd_flow_director_filter_parsed,
11037 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11038 "director entry on NIC",
11040 (void *)&cmd_flow_director_filter,
11041 (void *)&cmd_flow_director_port_id,
11042 (void *)&cmd_flow_director_mode,
11043 (void *)&cmd_flow_director_mode_mac_vlan,
11044 (void *)&cmd_flow_director_ops,
11045 (void *)&cmd_flow_director_mac,
11046 (void *)&cmd_flow_director_mac_addr,
11047 (void *)&cmd_flow_director_vlan,
11048 (void *)&cmd_flow_director_vlan_value,
11049 (void *)&cmd_flow_director_flexbytes,
11050 (void *)&cmd_flow_director_flexbytes_value,
11051 (void *)&cmd_flow_director_drop,
11052 (void *)&cmd_flow_director_queue,
11053 (void *)&cmd_flow_director_queue_id,
11054 (void *)&cmd_flow_director_fd_id,
11055 (void *)&cmd_flow_director_fd_id_value,
11060 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11061 .f = cmd_flow_director_filter_parsed,
11063 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11064 "director entry on NIC",
11066 (void *)&cmd_flow_director_filter,
11067 (void *)&cmd_flow_director_port_id,
11068 (void *)&cmd_flow_director_mode,
11069 (void *)&cmd_flow_director_mode_tunnel,
11070 (void *)&cmd_flow_director_ops,
11071 (void *)&cmd_flow_director_mac,
11072 (void *)&cmd_flow_director_mac_addr,
11073 (void *)&cmd_flow_director_vlan,
11074 (void *)&cmd_flow_director_vlan_value,
11075 (void *)&cmd_flow_director_tunnel,
11076 (void *)&cmd_flow_director_tunnel_type,
11077 (void *)&cmd_flow_director_tunnel_id,
11078 (void *)&cmd_flow_director_tunnel_id_value,
11079 (void *)&cmd_flow_director_flexbytes,
11080 (void *)&cmd_flow_director_flexbytes_value,
11081 (void *)&cmd_flow_director_drop,
11082 (void *)&cmd_flow_director_queue,
11083 (void *)&cmd_flow_director_queue_id,
11084 (void *)&cmd_flow_director_fd_id,
11085 (void *)&cmd_flow_director_fd_id_value,
11090 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11091 .f = cmd_flow_director_filter_parsed,
11093 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11094 "director entry on NIC",
11096 (void *)&cmd_flow_director_filter,
11097 (void *)&cmd_flow_director_port_id,
11098 (void *)&cmd_flow_director_mode,
11099 (void *)&cmd_flow_director_mode_raw,
11100 (void *)&cmd_flow_director_ops,
11101 (void *)&cmd_flow_director_flow,
11102 (void *)&cmd_flow_director_flow_type,
11103 (void *)&cmd_flow_director_drop,
11104 (void *)&cmd_flow_director_queue,
11105 (void *)&cmd_flow_director_queue_id,
11106 (void *)&cmd_flow_director_fd_id,
11107 (void *)&cmd_flow_director_fd_id_value,
11108 (void *)&cmd_flow_director_packet,
11109 (void *)&cmd_flow_director_filepath,
11114 struct cmd_flush_flow_director_result {
11115 cmdline_fixed_string_t flush_flow_director;
11119 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11120 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11121 flush_flow_director, "flush_flow_director");
11122 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11123 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11127 cmd_flush_flow_director_parsed(void *parsed_result,
11128 __attribute__((unused)) struct cmdline *cl,
11129 __attribute__((unused)) void *data)
11131 struct cmd_flow_director_result *res = parsed_result;
11134 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11136 printf("flow director is not supported on port %u.\n",
11141 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11142 RTE_ETH_FILTER_FLUSH, NULL);
11144 printf("flow director table flushing error: (%s)\n",
11148 cmdline_parse_inst_t cmd_flush_flow_director = {
11149 .f = cmd_flush_flow_director_parsed,
11151 .help_str = "flush_flow_director <port_id>: "
11152 "Flush all flow director entries of a device on NIC",
11154 (void *)&cmd_flush_flow_director_flush,
11155 (void *)&cmd_flush_flow_director_port_id,
11160 /* *** deal with flow director mask *** */
11161 struct cmd_flow_director_mask_result {
11162 cmdline_fixed_string_t flow_director_mask;
11164 cmdline_fixed_string_t mode;
11165 cmdline_fixed_string_t mode_value;
11166 cmdline_fixed_string_t vlan;
11167 uint16_t vlan_mask;
11168 cmdline_fixed_string_t src_mask;
11169 cmdline_ipaddr_t ipv4_src;
11170 cmdline_ipaddr_t ipv6_src;
11172 cmdline_fixed_string_t dst_mask;
11173 cmdline_ipaddr_t ipv4_dst;
11174 cmdline_ipaddr_t ipv6_dst;
11176 cmdline_fixed_string_t mac;
11177 uint8_t mac_addr_byte_mask;
11178 cmdline_fixed_string_t tunnel_id;
11179 uint32_t tunnel_id_mask;
11180 cmdline_fixed_string_t tunnel_type;
11181 uint8_t tunnel_type_mask;
11185 cmd_flow_director_mask_parsed(void *parsed_result,
11186 __attribute__((unused)) struct cmdline *cl,
11187 __attribute__((unused)) void *data)
11189 struct cmd_flow_director_mask_result *res = parsed_result;
11190 struct rte_eth_fdir_masks *mask;
11191 struct rte_port *port;
11193 port = &ports[res->port_id];
11194 /** Check if the port is not started **/
11195 if (port->port_status != RTE_PORT_STOPPED) {
11196 printf("Please stop port %d first\n", res->port_id);
11200 mask = &port->dev_conf.fdir_conf.mask;
11202 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11203 if (strcmp(res->mode_value, "MAC-VLAN")) {
11204 printf("Please set mode to MAC-VLAN.\n");
11208 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11209 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11210 if (strcmp(res->mode_value, "Tunnel")) {
11211 printf("Please set mode to Tunnel.\n");
11215 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11216 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11217 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11218 mask->tunnel_type_mask = res->tunnel_type_mask;
11220 if (strcmp(res->mode_value, "IP")) {
11221 printf("Please set mode to IP.\n");
11225 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11226 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11227 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11228 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11229 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11230 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11231 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11234 cmd_reconfig_device_queue(res->port_id, 1, 1);
11237 cmdline_parse_token_string_t cmd_flow_director_mask =
11238 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11239 flow_director_mask, "flow_director_mask");
11240 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11241 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11243 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11244 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11246 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11247 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11248 vlan_mask, UINT16);
11249 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11250 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11251 src_mask, "src_mask");
11252 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11253 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11255 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11256 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11258 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11259 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11261 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11262 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11263 dst_mask, "dst_mask");
11264 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11265 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11267 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11268 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11270 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11271 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11274 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11275 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11277 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11278 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11280 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11281 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11282 mode_value, "MAC-VLAN");
11283 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11285 mode_value, "Tunnel");
11286 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11287 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11289 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11290 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11291 mac_addr_byte_mask, UINT8);
11292 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11293 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11294 tunnel_type, "tunnel-type");
11295 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11296 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11297 tunnel_type_mask, UINT8);
11298 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11299 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11300 tunnel_id, "tunnel-id");
11301 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11302 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11303 tunnel_id_mask, UINT32);
11305 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11306 .f = cmd_flow_director_mask_parsed,
11308 .help_str = "flow_director_mask ... : "
11309 "Set IP mode flow director's mask on NIC",
11311 (void *)&cmd_flow_director_mask,
11312 (void *)&cmd_flow_director_mask_port_id,
11313 (void *)&cmd_flow_director_mask_mode,
11314 (void *)&cmd_flow_director_mask_mode_ip,
11315 (void *)&cmd_flow_director_mask_vlan,
11316 (void *)&cmd_flow_director_mask_vlan_value,
11317 (void *)&cmd_flow_director_mask_src,
11318 (void *)&cmd_flow_director_mask_ipv4_src,
11319 (void *)&cmd_flow_director_mask_ipv6_src,
11320 (void *)&cmd_flow_director_mask_port_src,
11321 (void *)&cmd_flow_director_mask_dst,
11322 (void *)&cmd_flow_director_mask_ipv4_dst,
11323 (void *)&cmd_flow_director_mask_ipv6_dst,
11324 (void *)&cmd_flow_director_mask_port_dst,
11329 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11330 .f = cmd_flow_director_mask_parsed,
11332 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11333 "flow director's mask on NIC",
11335 (void *)&cmd_flow_director_mask,
11336 (void *)&cmd_flow_director_mask_port_id,
11337 (void *)&cmd_flow_director_mask_mode,
11338 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11339 (void *)&cmd_flow_director_mask_vlan,
11340 (void *)&cmd_flow_director_mask_vlan_value,
11345 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11346 .f = cmd_flow_director_mask_parsed,
11348 .help_str = "flow_director_mask ... : Set tunnel mode "
11349 "flow director's mask on NIC",
11351 (void *)&cmd_flow_director_mask,
11352 (void *)&cmd_flow_director_mask_port_id,
11353 (void *)&cmd_flow_director_mask_mode,
11354 (void *)&cmd_flow_director_mask_mode_tunnel,
11355 (void *)&cmd_flow_director_mask_vlan,
11356 (void *)&cmd_flow_director_mask_vlan_value,
11357 (void *)&cmd_flow_director_mask_mac,
11358 (void *)&cmd_flow_director_mask_mac_value,
11359 (void *)&cmd_flow_director_mask_tunnel_type,
11360 (void *)&cmd_flow_director_mask_tunnel_type_value,
11361 (void *)&cmd_flow_director_mask_tunnel_id,
11362 (void *)&cmd_flow_director_mask_tunnel_id_value,
11367 /* *** deal with flow director mask on flexible payload *** */
11368 struct cmd_flow_director_flex_mask_result {
11369 cmdline_fixed_string_t flow_director_flexmask;
11371 cmdline_fixed_string_t flow;
11372 cmdline_fixed_string_t flow_type;
11373 cmdline_fixed_string_t mask;
11377 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11378 __attribute__((unused)) struct cmdline *cl,
11379 __attribute__((unused)) void *data)
11381 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11382 struct rte_eth_fdir_info fdir_info;
11383 struct rte_eth_fdir_flex_mask flex_mask;
11384 struct rte_port *port;
11385 uint64_t flow_type_mask;
11389 port = &ports[res->port_id];
11390 /** Check if the port is not started **/
11391 if (port->port_status != RTE_PORT_STOPPED) {
11392 printf("Please stop port %d first\n", res->port_id);
11396 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11397 ret = parse_flexbytes(res->mask,
11399 RTE_ETH_FDIR_MAX_FLEXLEN);
11401 printf("error: Cannot parse mask input.\n");
11405 memset(&fdir_info, 0, sizeof(fdir_info));
11406 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11407 RTE_ETH_FILTER_INFO, &fdir_info);
11409 printf("Cannot get FDir filter info\n");
11413 if (!strcmp(res->flow_type, "none")) {
11414 /* means don't specify the flow type */
11415 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11416 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11417 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11418 0, sizeof(struct rte_eth_fdir_flex_mask));
11419 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11420 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11422 sizeof(struct rte_eth_fdir_flex_mask));
11423 cmd_reconfig_device_queue(res->port_id, 1, 1);
11426 flow_type_mask = fdir_info.flow_types_mask[0];
11427 if (!strcmp(res->flow_type, "all")) {
11428 if (!flow_type_mask) {
11429 printf("No flow type supported\n");
11432 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11433 if (flow_type_mask & (1ULL << i)) {
11434 flex_mask.flow_type = i;
11435 fdir_set_flex_mask(res->port_id, &flex_mask);
11438 cmd_reconfig_device_queue(res->port_id, 1, 1);
11441 flex_mask.flow_type = str2flowtype(res->flow_type);
11442 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11443 printf("Flow type %s not supported on port %d\n",
11444 res->flow_type, res->port_id);
11447 fdir_set_flex_mask(res->port_id, &flex_mask);
11448 cmd_reconfig_device_queue(res->port_id, 1, 1);
11451 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11452 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11453 flow_director_flexmask,
11454 "flow_director_flex_mask");
11455 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11456 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11458 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11459 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11461 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11462 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11463 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11464 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11465 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11466 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11469 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11470 .f = cmd_flow_director_flex_mask_parsed,
11472 .help_str = "flow_director_flex_mask ... : "
11473 "Set flow director's flex mask on NIC",
11475 (void *)&cmd_flow_director_flexmask,
11476 (void *)&cmd_flow_director_flexmask_port_id,
11477 (void *)&cmd_flow_director_flexmask_flow,
11478 (void *)&cmd_flow_director_flexmask_flow_type,
11479 (void *)&cmd_flow_director_flexmask_mask,
11484 /* *** deal with flow director flexible payload configuration *** */
11485 struct cmd_flow_director_flexpayload_result {
11486 cmdline_fixed_string_t flow_director_flexpayload;
11488 cmdline_fixed_string_t payload_layer;
11489 cmdline_fixed_string_t payload_cfg;
11493 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11496 const char *p, *p0 = q_arg;
11498 unsigned long int_fld;
11499 char *str_fld[max_num];
11504 p = strchr(p0, '(');
11508 p0 = strchr(p, ')');
11513 if (size >= sizeof(s))
11516 snprintf(s, sizeof(s), "%.*s", size, p);
11517 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11518 if (ret < 0 || ret > max_num)
11520 for (i = 0; i < ret; i++) {
11522 int_fld = strtoul(str_fld[i], &end, 0);
11523 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11525 offsets[i] = (uint16_t)int_fld;
11531 cmd_flow_director_flxpld_parsed(void *parsed_result,
11532 __attribute__((unused)) struct cmdline *cl,
11533 __attribute__((unused)) void *data)
11535 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11536 struct rte_eth_flex_payload_cfg flex_cfg;
11537 struct rte_port *port;
11540 port = &ports[res->port_id];
11541 /** Check if the port is not started **/
11542 if (port->port_status != RTE_PORT_STOPPED) {
11543 printf("Please stop port %d first\n", res->port_id);
11547 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11549 if (!strcmp(res->payload_layer, "raw"))
11550 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11551 else if (!strcmp(res->payload_layer, "l2"))
11552 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11553 else if (!strcmp(res->payload_layer, "l3"))
11554 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11555 else if (!strcmp(res->payload_layer, "l4"))
11556 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11558 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11559 RTE_ETH_FDIR_MAX_FLEXLEN);
11561 printf("error: Cannot parse flex payload input.\n");
11565 fdir_set_flex_payload(res->port_id, &flex_cfg);
11566 cmd_reconfig_device_queue(res->port_id, 1, 1);
11569 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11570 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11571 flow_director_flexpayload,
11572 "flow_director_flex_payload");
11573 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11574 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11576 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11577 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11578 payload_layer, "raw#l2#l3#l4");
11579 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11580 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11581 payload_cfg, NULL);
11583 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11584 .f = cmd_flow_director_flxpld_parsed,
11586 .help_str = "flow_director_flexpayload ... : "
11587 "Set flow director's flex payload on NIC",
11589 (void *)&cmd_flow_director_flexpayload,
11590 (void *)&cmd_flow_director_flexpayload_port_id,
11591 (void *)&cmd_flow_director_flexpayload_payload_layer,
11592 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11597 /* Generic flow interface command. */
11598 extern cmdline_parse_inst_t cmd_flow;
11600 /* *** Classification Filters Control *** */
11601 /* *** Get symmetric hash enable per port *** */
11602 struct cmd_get_sym_hash_ena_per_port_result {
11603 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11608 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11609 __rte_unused struct cmdline *cl,
11610 __rte_unused void *data)
11612 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11613 struct rte_eth_hash_filter_info info;
11616 if (rte_eth_dev_filter_supported(res->port_id,
11617 RTE_ETH_FILTER_HASH) < 0) {
11618 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11623 memset(&info, 0, sizeof(info));
11624 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11625 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11626 RTE_ETH_FILTER_GET, &info);
11629 printf("Cannot get symmetric hash enable per port "
11630 "on port %u\n", res->port_id);
11634 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11635 "enabled" : "disabled", res->port_id);
11638 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11639 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11640 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11641 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11642 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11645 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11646 .f = cmd_get_sym_hash_per_port_parsed,
11648 .help_str = "get_sym_hash_ena_per_port <port_id>",
11650 (void *)&cmd_get_sym_hash_ena_per_port_all,
11651 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11656 /* *** Set symmetric hash enable per port *** */
11657 struct cmd_set_sym_hash_ena_per_port_result {
11658 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11659 cmdline_fixed_string_t enable;
11664 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11665 __rte_unused struct cmdline *cl,
11666 __rte_unused void *data)
11668 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11669 struct rte_eth_hash_filter_info info;
11672 if (rte_eth_dev_filter_supported(res->port_id,
11673 RTE_ETH_FILTER_HASH) < 0) {
11674 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11679 memset(&info, 0, sizeof(info));
11680 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11681 if (!strcmp(res->enable, "enable"))
11682 info.info.enable = 1;
11683 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11684 RTE_ETH_FILTER_SET, &info);
11686 printf("Cannot set symmetric hash enable per port on "
11687 "port %u\n", res->port_id);
11690 printf("Symmetric hash has been set to %s on port %u\n",
11691 res->enable, res->port_id);
11694 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11695 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11696 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11697 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11698 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11700 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11701 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11702 enable, "enable#disable");
11704 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11705 .f = cmd_set_sym_hash_per_port_parsed,
11707 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11709 (void *)&cmd_set_sym_hash_ena_per_port_all,
11710 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11711 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11716 /* Get global config of hash function */
11717 struct cmd_get_hash_global_config_result {
11718 cmdline_fixed_string_t get_hash_global_config;
11723 flowtype_to_str(uint16_t ftype)
11729 } ftype_table[] = {
11730 {"ipv4", RTE_ETH_FLOW_IPV4},
11731 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11732 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11733 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11734 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11735 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11736 {"ipv6", RTE_ETH_FLOW_IPV6},
11737 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11738 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11739 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11740 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11741 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11742 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11743 {"port", RTE_ETH_FLOW_PORT},
11744 {"vxlan", RTE_ETH_FLOW_VXLAN},
11745 {"geneve", RTE_ETH_FLOW_GENEVE},
11746 {"nvgre", RTE_ETH_FLOW_NVGRE},
11749 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11750 if (ftype_table[i].ftype == ftype)
11751 return ftype_table[i].str;
11758 cmd_get_hash_global_config_parsed(void *parsed_result,
11759 __rte_unused struct cmdline *cl,
11760 __rte_unused void *data)
11762 struct cmd_get_hash_global_config_result *res = parsed_result;
11763 struct rte_eth_hash_filter_info info;
11764 uint32_t idx, offset;
11769 if (rte_eth_dev_filter_supported(res->port_id,
11770 RTE_ETH_FILTER_HASH) < 0) {
11771 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11776 memset(&info, 0, sizeof(info));
11777 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11778 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11779 RTE_ETH_FILTER_GET, &info);
11781 printf("Cannot get hash global configurations by port %d\n",
11786 switch (info.info.global_conf.hash_func) {
11787 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11788 printf("Hash function is Toeplitz\n");
11790 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11791 printf("Hash function is Simple XOR\n");
11794 printf("Unknown hash function\n");
11798 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11799 idx = i / UINT64_BIT;
11800 offset = i % UINT64_BIT;
11801 if (!(info.info.global_conf.valid_bit_mask[idx] &
11804 str = flowtype_to_str(i);
11807 printf("Symmetric hash is %s globally for flow type %s "
11809 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11810 (1ULL << offset)) ? "enabled" : "disabled"), str,
11815 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11816 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11817 get_hash_global_config, "get_hash_global_config");
11818 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11819 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11822 cmdline_parse_inst_t cmd_get_hash_global_config = {
11823 .f = cmd_get_hash_global_config_parsed,
11825 .help_str = "get_hash_global_config <port_id>",
11827 (void *)&cmd_get_hash_global_config_all,
11828 (void *)&cmd_get_hash_global_config_port_id,
11833 /* Set global config of hash function */
11834 struct cmd_set_hash_global_config_result {
11835 cmdline_fixed_string_t set_hash_global_config;
11837 cmdline_fixed_string_t hash_func;
11838 cmdline_fixed_string_t flow_type;
11839 cmdline_fixed_string_t enable;
11843 cmd_set_hash_global_config_parsed(void *parsed_result,
11844 __rte_unused struct cmdline *cl,
11845 __rte_unused void *data)
11847 struct cmd_set_hash_global_config_result *res = parsed_result;
11848 struct rte_eth_hash_filter_info info;
11849 uint32_t ftype, idx, offset;
11852 if (rte_eth_dev_filter_supported(res->port_id,
11853 RTE_ETH_FILTER_HASH) < 0) {
11854 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11858 memset(&info, 0, sizeof(info));
11859 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11860 if (!strcmp(res->hash_func, "toeplitz"))
11861 info.info.global_conf.hash_func =
11862 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11863 else if (!strcmp(res->hash_func, "simple_xor"))
11864 info.info.global_conf.hash_func =
11865 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11866 else if (!strcmp(res->hash_func, "default"))
11867 info.info.global_conf.hash_func =
11868 RTE_ETH_HASH_FUNCTION_DEFAULT;
11870 ftype = str2flowtype(res->flow_type);
11871 idx = ftype / UINT64_BIT;
11872 offset = ftype % UINT64_BIT;
11873 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11874 if (!strcmp(res->enable, "enable"))
11875 info.info.global_conf.sym_hash_enable_mask[idx] |=
11877 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11878 RTE_ETH_FILTER_SET, &info);
11880 printf("Cannot set global hash configurations by port %d\n",
11883 printf("Global hash configurations have been set "
11884 "succcessfully by port %d\n", res->port_id);
11887 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11888 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11889 set_hash_global_config, "set_hash_global_config");
11890 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11891 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11893 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11894 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11895 hash_func, "toeplitz#simple_xor#default");
11896 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11897 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11899 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11900 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11901 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11902 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11903 enable, "enable#disable");
11905 cmdline_parse_inst_t cmd_set_hash_global_config = {
11906 .f = cmd_set_hash_global_config_parsed,
11908 .help_str = "set_hash_global_config <port_id> "
11909 "toeplitz|simple_xor|default "
11910 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11911 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11912 "l2_payload enable|disable",
11914 (void *)&cmd_set_hash_global_config_all,
11915 (void *)&cmd_set_hash_global_config_port_id,
11916 (void *)&cmd_set_hash_global_config_hash_func,
11917 (void *)&cmd_set_hash_global_config_flow_type,
11918 (void *)&cmd_set_hash_global_config_enable,
11923 /* Set hash input set */
11924 struct cmd_set_hash_input_set_result {
11925 cmdline_fixed_string_t set_hash_input_set;
11927 cmdline_fixed_string_t flow_type;
11928 cmdline_fixed_string_t inset_field;
11929 cmdline_fixed_string_t select;
11932 static enum rte_eth_input_set_field
11933 str2inset(char *string)
11937 static const struct {
11939 enum rte_eth_input_set_field inset;
11940 } inset_table[] = {
11941 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11942 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11943 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11944 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11945 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11946 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11947 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11948 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11949 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11950 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11951 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11952 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11953 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11954 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11955 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11956 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11957 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11958 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11959 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11960 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11961 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11962 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11963 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11964 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11965 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
11966 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
11967 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
11968 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
11969 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
11970 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
11971 {"none", RTE_ETH_INPUT_SET_NONE},
11974 for (i = 0; i < RTE_DIM(inset_table); i++) {
11975 if (!strcmp(string, inset_table[i].str))
11976 return inset_table[i].inset;
11979 return RTE_ETH_INPUT_SET_UNKNOWN;
11983 cmd_set_hash_input_set_parsed(void *parsed_result,
11984 __rte_unused struct cmdline *cl,
11985 __rte_unused void *data)
11987 struct cmd_set_hash_input_set_result *res = parsed_result;
11988 struct rte_eth_hash_filter_info info;
11990 memset(&info, 0, sizeof(info));
11991 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
11992 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
11993 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
11994 info.info.input_set_conf.inset_size = 1;
11995 if (!strcmp(res->select, "select"))
11996 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
11997 else if (!strcmp(res->select, "add"))
11998 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
11999 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12000 RTE_ETH_FILTER_SET, &info);
12003 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12004 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12005 set_hash_input_set, "set_hash_input_set");
12006 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12007 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12009 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12010 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12012 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12013 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12015 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12016 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12017 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12018 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12019 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12021 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12022 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12023 select, "select#add");
12025 cmdline_parse_inst_t cmd_set_hash_input_set = {
12026 .f = cmd_set_hash_input_set_parsed,
12028 .help_str = "set_hash_input_set <port_id> "
12029 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12030 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12031 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12032 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12033 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12034 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12035 "fld-7th|fld-8th|none select|add",
12037 (void *)&cmd_set_hash_input_set_cmd,
12038 (void *)&cmd_set_hash_input_set_port_id,
12039 (void *)&cmd_set_hash_input_set_flow_type,
12040 (void *)&cmd_set_hash_input_set_field,
12041 (void *)&cmd_set_hash_input_set_select,
12046 /* Set flow director input set */
12047 struct cmd_set_fdir_input_set_result {
12048 cmdline_fixed_string_t set_fdir_input_set;
12050 cmdline_fixed_string_t flow_type;
12051 cmdline_fixed_string_t inset_field;
12052 cmdline_fixed_string_t select;
12056 cmd_set_fdir_input_set_parsed(void *parsed_result,
12057 __rte_unused struct cmdline *cl,
12058 __rte_unused void *data)
12060 struct cmd_set_fdir_input_set_result *res = parsed_result;
12061 struct rte_eth_fdir_filter_info info;
12063 memset(&info, 0, sizeof(info));
12064 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12065 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12066 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12067 info.info.input_set_conf.inset_size = 1;
12068 if (!strcmp(res->select, "select"))
12069 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12070 else if (!strcmp(res->select, "add"))
12071 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12072 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12073 RTE_ETH_FILTER_SET, &info);
12076 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12077 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12078 set_fdir_input_set, "set_fdir_input_set");
12079 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12080 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12082 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12083 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12085 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12086 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12087 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12088 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12090 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12091 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12092 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12093 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12094 "sctp-veri-tag#none");
12095 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12096 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12097 select, "select#add");
12099 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12100 .f = cmd_set_fdir_input_set_parsed,
12102 .help_str = "set_fdir_input_set <port_id> "
12103 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12104 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12105 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12106 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12107 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12108 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12109 "sctp-veri-tag|none select|add",
12111 (void *)&cmd_set_fdir_input_set_cmd,
12112 (void *)&cmd_set_fdir_input_set_port_id,
12113 (void *)&cmd_set_fdir_input_set_flow_type,
12114 (void *)&cmd_set_fdir_input_set_field,
12115 (void *)&cmd_set_fdir_input_set_select,
12120 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12121 struct cmd_mcast_addr_result {
12122 cmdline_fixed_string_t mcast_addr_cmd;
12123 cmdline_fixed_string_t what;
12125 struct ether_addr mc_addr;
12128 static void cmd_mcast_addr_parsed(void *parsed_result,
12129 __attribute__((unused)) struct cmdline *cl,
12130 __attribute__((unused)) void *data)
12132 struct cmd_mcast_addr_result *res = parsed_result;
12134 if (!is_multicast_ether_addr(&res->mc_addr)) {
12135 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12136 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12137 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12138 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12141 if (strcmp(res->what, "add") == 0)
12142 mcast_addr_add(res->port_num, &res->mc_addr);
12144 mcast_addr_remove(res->port_num, &res->mc_addr);
12147 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12148 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12149 mcast_addr_cmd, "mcast_addr");
12150 cmdline_parse_token_string_t cmd_mcast_addr_what =
12151 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12153 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12154 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12155 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12156 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12158 cmdline_parse_inst_t cmd_mcast_addr = {
12159 .f = cmd_mcast_addr_parsed,
12161 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12162 "Add/Remove multicast MAC address on port_id",
12164 (void *)&cmd_mcast_addr_cmd,
12165 (void *)&cmd_mcast_addr_what,
12166 (void *)&cmd_mcast_addr_portnum,
12167 (void *)&cmd_mcast_addr_addr,
12172 /* l2 tunnel config
12173 * only support E-tag now.
12176 /* Ether type config */
12177 struct cmd_config_l2_tunnel_eth_type_result {
12178 cmdline_fixed_string_t port;
12179 cmdline_fixed_string_t config;
12180 cmdline_fixed_string_t all;
12182 cmdline_fixed_string_t l2_tunnel;
12183 cmdline_fixed_string_t l2_tunnel_type;
12184 cmdline_fixed_string_t eth_type;
12185 uint16_t eth_type_val;
12188 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12189 TOKEN_STRING_INITIALIZER
12190 (struct cmd_config_l2_tunnel_eth_type_result,
12192 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12193 TOKEN_STRING_INITIALIZER
12194 (struct cmd_config_l2_tunnel_eth_type_result,
12196 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12197 TOKEN_STRING_INITIALIZER
12198 (struct cmd_config_l2_tunnel_eth_type_result,
12200 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12201 TOKEN_NUM_INITIALIZER
12202 (struct cmd_config_l2_tunnel_eth_type_result,
12204 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12205 TOKEN_STRING_INITIALIZER
12206 (struct cmd_config_l2_tunnel_eth_type_result,
12207 l2_tunnel, "l2-tunnel");
12208 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12209 TOKEN_STRING_INITIALIZER
12210 (struct cmd_config_l2_tunnel_eth_type_result,
12211 l2_tunnel_type, "E-tag");
12212 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12213 TOKEN_STRING_INITIALIZER
12214 (struct cmd_config_l2_tunnel_eth_type_result,
12215 eth_type, "ether-type");
12216 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12217 TOKEN_NUM_INITIALIZER
12218 (struct cmd_config_l2_tunnel_eth_type_result,
12219 eth_type_val, UINT16);
12221 static enum rte_eth_tunnel_type
12222 str2fdir_l2_tunnel_type(char *string)
12226 static const struct {
12228 enum rte_eth_tunnel_type type;
12229 } l2_tunnel_type_str[] = {
12230 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12233 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12234 if (!strcmp(l2_tunnel_type_str[i].str, string))
12235 return l2_tunnel_type_str[i].type;
12237 return RTE_TUNNEL_TYPE_NONE;
12240 /* ether type config for all ports */
12242 cmd_config_l2_tunnel_eth_type_all_parsed
12243 (void *parsed_result,
12244 __attribute__((unused)) struct cmdline *cl,
12245 __attribute__((unused)) void *data)
12247 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12248 struct rte_eth_l2_tunnel_conf entry;
12251 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12252 entry.ether_type = res->eth_type_val;
12254 RTE_ETH_FOREACH_DEV(pid) {
12255 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12259 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12260 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12262 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12264 (void *)&cmd_config_l2_tunnel_eth_type_port,
12265 (void *)&cmd_config_l2_tunnel_eth_type_config,
12266 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12267 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12268 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12269 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12270 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12275 /* ether type config for a specific port */
12277 cmd_config_l2_tunnel_eth_type_specific_parsed(
12278 void *parsed_result,
12279 __attribute__((unused)) struct cmdline *cl,
12280 __attribute__((unused)) void *data)
12282 struct cmd_config_l2_tunnel_eth_type_result *res =
12284 struct rte_eth_l2_tunnel_conf entry;
12286 if (port_id_is_invalid(res->id, ENABLED_WARN))
12289 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12290 entry.ether_type = res->eth_type_val;
12292 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12295 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12296 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12298 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12300 (void *)&cmd_config_l2_tunnel_eth_type_port,
12301 (void *)&cmd_config_l2_tunnel_eth_type_config,
12302 (void *)&cmd_config_l2_tunnel_eth_type_id,
12303 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12304 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12305 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12306 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12311 /* Enable/disable l2 tunnel */
12312 struct cmd_config_l2_tunnel_en_dis_result {
12313 cmdline_fixed_string_t port;
12314 cmdline_fixed_string_t config;
12315 cmdline_fixed_string_t all;
12317 cmdline_fixed_string_t l2_tunnel;
12318 cmdline_fixed_string_t l2_tunnel_type;
12319 cmdline_fixed_string_t en_dis;
12322 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12323 TOKEN_STRING_INITIALIZER
12324 (struct cmd_config_l2_tunnel_en_dis_result,
12326 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12327 TOKEN_STRING_INITIALIZER
12328 (struct cmd_config_l2_tunnel_en_dis_result,
12330 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12331 TOKEN_STRING_INITIALIZER
12332 (struct cmd_config_l2_tunnel_en_dis_result,
12334 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12335 TOKEN_NUM_INITIALIZER
12336 (struct cmd_config_l2_tunnel_en_dis_result,
12338 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12339 TOKEN_STRING_INITIALIZER
12340 (struct cmd_config_l2_tunnel_en_dis_result,
12341 l2_tunnel, "l2-tunnel");
12342 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12343 TOKEN_STRING_INITIALIZER
12344 (struct cmd_config_l2_tunnel_en_dis_result,
12345 l2_tunnel_type, "E-tag");
12346 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12347 TOKEN_STRING_INITIALIZER
12348 (struct cmd_config_l2_tunnel_en_dis_result,
12349 en_dis, "enable#disable");
12351 /* enable/disable l2 tunnel for all ports */
12353 cmd_config_l2_tunnel_en_dis_all_parsed(
12354 void *parsed_result,
12355 __attribute__((unused)) struct cmdline *cl,
12356 __attribute__((unused)) void *data)
12358 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12359 struct rte_eth_l2_tunnel_conf entry;
12363 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12365 if (!strcmp("enable", res->en_dis))
12370 RTE_ETH_FOREACH_DEV(pid) {
12371 rte_eth_dev_l2_tunnel_offload_set(pid,
12373 ETH_L2_TUNNEL_ENABLE_MASK,
12378 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12379 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12381 .help_str = "port config all l2-tunnel E-tag enable|disable",
12383 (void *)&cmd_config_l2_tunnel_en_dis_port,
12384 (void *)&cmd_config_l2_tunnel_en_dis_config,
12385 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12386 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12387 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12388 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12393 /* enable/disable l2 tunnel for a port */
12395 cmd_config_l2_tunnel_en_dis_specific_parsed(
12396 void *parsed_result,
12397 __attribute__((unused)) struct cmdline *cl,
12398 __attribute__((unused)) void *data)
12400 struct cmd_config_l2_tunnel_en_dis_result *res =
12402 struct rte_eth_l2_tunnel_conf entry;
12404 if (port_id_is_invalid(res->id, ENABLED_WARN))
12407 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12409 if (!strcmp("enable", res->en_dis))
12410 rte_eth_dev_l2_tunnel_offload_set(res->id,
12412 ETH_L2_TUNNEL_ENABLE_MASK,
12415 rte_eth_dev_l2_tunnel_offload_set(res->id,
12417 ETH_L2_TUNNEL_ENABLE_MASK,
12421 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12422 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12424 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12426 (void *)&cmd_config_l2_tunnel_en_dis_port,
12427 (void *)&cmd_config_l2_tunnel_en_dis_config,
12428 (void *)&cmd_config_l2_tunnel_en_dis_id,
12429 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12430 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12431 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12436 /* E-tag configuration */
12438 /* Common result structure for all E-tag configuration */
12439 struct cmd_config_e_tag_result {
12440 cmdline_fixed_string_t e_tag;
12441 cmdline_fixed_string_t set;
12442 cmdline_fixed_string_t insertion;
12443 cmdline_fixed_string_t stripping;
12444 cmdline_fixed_string_t forwarding;
12445 cmdline_fixed_string_t filter;
12446 cmdline_fixed_string_t add;
12447 cmdline_fixed_string_t del;
12448 cmdline_fixed_string_t on;
12449 cmdline_fixed_string_t off;
12450 cmdline_fixed_string_t on_off;
12451 cmdline_fixed_string_t port_tag_id;
12452 uint32_t port_tag_id_val;
12453 cmdline_fixed_string_t e_tag_id;
12454 uint16_t e_tag_id_val;
12455 cmdline_fixed_string_t dst_pool;
12456 uint8_t dst_pool_val;
12457 cmdline_fixed_string_t port;
12459 cmdline_fixed_string_t vf;
12463 /* Common CLI fields for all E-tag configuration */
12464 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12465 TOKEN_STRING_INITIALIZER
12466 (struct cmd_config_e_tag_result,
12468 cmdline_parse_token_string_t cmd_config_e_tag_set =
12469 TOKEN_STRING_INITIALIZER
12470 (struct cmd_config_e_tag_result,
12472 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12473 TOKEN_STRING_INITIALIZER
12474 (struct cmd_config_e_tag_result,
12475 insertion, "insertion");
12476 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12477 TOKEN_STRING_INITIALIZER
12478 (struct cmd_config_e_tag_result,
12479 stripping, "stripping");
12480 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12481 TOKEN_STRING_INITIALIZER
12482 (struct cmd_config_e_tag_result,
12483 forwarding, "forwarding");
12484 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12485 TOKEN_STRING_INITIALIZER
12486 (struct cmd_config_e_tag_result,
12488 cmdline_parse_token_string_t cmd_config_e_tag_add =
12489 TOKEN_STRING_INITIALIZER
12490 (struct cmd_config_e_tag_result,
12492 cmdline_parse_token_string_t cmd_config_e_tag_del =
12493 TOKEN_STRING_INITIALIZER
12494 (struct cmd_config_e_tag_result,
12496 cmdline_parse_token_string_t cmd_config_e_tag_on =
12497 TOKEN_STRING_INITIALIZER
12498 (struct cmd_config_e_tag_result,
12500 cmdline_parse_token_string_t cmd_config_e_tag_off =
12501 TOKEN_STRING_INITIALIZER
12502 (struct cmd_config_e_tag_result,
12504 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12505 TOKEN_STRING_INITIALIZER
12506 (struct cmd_config_e_tag_result,
12508 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12509 TOKEN_STRING_INITIALIZER
12510 (struct cmd_config_e_tag_result,
12511 port_tag_id, "port-tag-id");
12512 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12513 TOKEN_NUM_INITIALIZER
12514 (struct cmd_config_e_tag_result,
12515 port_tag_id_val, UINT32);
12516 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12517 TOKEN_STRING_INITIALIZER
12518 (struct cmd_config_e_tag_result,
12519 e_tag_id, "e-tag-id");
12520 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12521 TOKEN_NUM_INITIALIZER
12522 (struct cmd_config_e_tag_result,
12523 e_tag_id_val, UINT16);
12524 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12525 TOKEN_STRING_INITIALIZER
12526 (struct cmd_config_e_tag_result,
12527 dst_pool, "dst-pool");
12528 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12529 TOKEN_NUM_INITIALIZER
12530 (struct cmd_config_e_tag_result,
12531 dst_pool_val, UINT8);
12532 cmdline_parse_token_string_t cmd_config_e_tag_port =
12533 TOKEN_STRING_INITIALIZER
12534 (struct cmd_config_e_tag_result,
12536 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12537 TOKEN_NUM_INITIALIZER
12538 (struct cmd_config_e_tag_result,
12540 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12541 TOKEN_STRING_INITIALIZER
12542 (struct cmd_config_e_tag_result,
12544 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12545 TOKEN_NUM_INITIALIZER
12546 (struct cmd_config_e_tag_result,
12549 /* E-tag insertion configuration */
12551 cmd_config_e_tag_insertion_en_parsed(
12552 void *parsed_result,
12553 __attribute__((unused)) struct cmdline *cl,
12554 __attribute__((unused)) void *data)
12556 struct cmd_config_e_tag_result *res =
12558 struct rte_eth_l2_tunnel_conf entry;
12560 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12563 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12564 entry.tunnel_id = res->port_tag_id_val;
12565 entry.vf_id = res->vf_id;
12566 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12568 ETH_L2_TUNNEL_INSERTION_MASK,
12573 cmd_config_e_tag_insertion_dis_parsed(
12574 void *parsed_result,
12575 __attribute__((unused)) struct cmdline *cl,
12576 __attribute__((unused)) void *data)
12578 struct cmd_config_e_tag_result *res =
12580 struct rte_eth_l2_tunnel_conf entry;
12582 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12585 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12586 entry.vf_id = res->vf_id;
12588 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12590 ETH_L2_TUNNEL_INSERTION_MASK,
12594 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12595 .f = cmd_config_e_tag_insertion_en_parsed,
12597 .help_str = "E-tag ... : E-tag insertion enable",
12599 (void *)&cmd_config_e_tag_e_tag,
12600 (void *)&cmd_config_e_tag_set,
12601 (void *)&cmd_config_e_tag_insertion,
12602 (void *)&cmd_config_e_tag_on,
12603 (void *)&cmd_config_e_tag_port_tag_id,
12604 (void *)&cmd_config_e_tag_port_tag_id_val,
12605 (void *)&cmd_config_e_tag_port,
12606 (void *)&cmd_config_e_tag_port_id,
12607 (void *)&cmd_config_e_tag_vf,
12608 (void *)&cmd_config_e_tag_vf_id,
12613 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12614 .f = cmd_config_e_tag_insertion_dis_parsed,
12616 .help_str = "E-tag ... : E-tag insertion disable",
12618 (void *)&cmd_config_e_tag_e_tag,
12619 (void *)&cmd_config_e_tag_set,
12620 (void *)&cmd_config_e_tag_insertion,
12621 (void *)&cmd_config_e_tag_off,
12622 (void *)&cmd_config_e_tag_port,
12623 (void *)&cmd_config_e_tag_port_id,
12624 (void *)&cmd_config_e_tag_vf,
12625 (void *)&cmd_config_e_tag_vf_id,
12630 /* E-tag stripping configuration */
12632 cmd_config_e_tag_stripping_parsed(
12633 void *parsed_result,
12634 __attribute__((unused)) struct cmdline *cl,
12635 __attribute__((unused)) void *data)
12637 struct cmd_config_e_tag_result *res =
12639 struct rte_eth_l2_tunnel_conf entry;
12641 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12644 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12646 if (!strcmp(res->on_off, "on"))
12647 rte_eth_dev_l2_tunnel_offload_set
12650 ETH_L2_TUNNEL_STRIPPING_MASK,
12653 rte_eth_dev_l2_tunnel_offload_set
12656 ETH_L2_TUNNEL_STRIPPING_MASK,
12660 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12661 .f = cmd_config_e_tag_stripping_parsed,
12663 .help_str = "E-tag ... : E-tag stripping enable/disable",
12665 (void *)&cmd_config_e_tag_e_tag,
12666 (void *)&cmd_config_e_tag_set,
12667 (void *)&cmd_config_e_tag_stripping,
12668 (void *)&cmd_config_e_tag_on_off,
12669 (void *)&cmd_config_e_tag_port,
12670 (void *)&cmd_config_e_tag_port_id,
12675 /* E-tag forwarding configuration */
12677 cmd_config_e_tag_forwarding_parsed(
12678 void *parsed_result,
12679 __attribute__((unused)) struct cmdline *cl,
12680 __attribute__((unused)) void *data)
12682 struct cmd_config_e_tag_result *res = parsed_result;
12683 struct rte_eth_l2_tunnel_conf entry;
12685 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12688 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12690 if (!strcmp(res->on_off, "on"))
12691 rte_eth_dev_l2_tunnel_offload_set
12694 ETH_L2_TUNNEL_FORWARDING_MASK,
12697 rte_eth_dev_l2_tunnel_offload_set
12700 ETH_L2_TUNNEL_FORWARDING_MASK,
12704 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12705 .f = cmd_config_e_tag_forwarding_parsed,
12707 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12709 (void *)&cmd_config_e_tag_e_tag,
12710 (void *)&cmd_config_e_tag_set,
12711 (void *)&cmd_config_e_tag_forwarding,
12712 (void *)&cmd_config_e_tag_on_off,
12713 (void *)&cmd_config_e_tag_port,
12714 (void *)&cmd_config_e_tag_port_id,
12719 /* E-tag filter configuration */
12721 cmd_config_e_tag_filter_add_parsed(
12722 void *parsed_result,
12723 __attribute__((unused)) struct cmdline *cl,
12724 __attribute__((unused)) void *data)
12726 struct cmd_config_e_tag_result *res = parsed_result;
12727 struct rte_eth_l2_tunnel_conf entry;
12730 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12733 if (res->e_tag_id_val > 0x3fff) {
12734 printf("e-tag-id must be equal or less than 0x3fff.\n");
12738 ret = rte_eth_dev_filter_supported(res->port_id,
12739 RTE_ETH_FILTER_L2_TUNNEL);
12741 printf("E-tag filter is not supported on port %u.\n",
12746 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12747 entry.tunnel_id = res->e_tag_id_val;
12748 entry.pool = res->dst_pool_val;
12750 ret = rte_eth_dev_filter_ctrl(res->port_id,
12751 RTE_ETH_FILTER_L2_TUNNEL,
12752 RTE_ETH_FILTER_ADD,
12755 printf("E-tag filter programming error: (%s)\n",
12759 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12760 .f = cmd_config_e_tag_filter_add_parsed,
12762 .help_str = "E-tag ... : E-tag filter add",
12764 (void *)&cmd_config_e_tag_e_tag,
12765 (void *)&cmd_config_e_tag_set,
12766 (void *)&cmd_config_e_tag_filter,
12767 (void *)&cmd_config_e_tag_add,
12768 (void *)&cmd_config_e_tag_e_tag_id,
12769 (void *)&cmd_config_e_tag_e_tag_id_val,
12770 (void *)&cmd_config_e_tag_dst_pool,
12771 (void *)&cmd_config_e_tag_dst_pool_val,
12772 (void *)&cmd_config_e_tag_port,
12773 (void *)&cmd_config_e_tag_port_id,
12779 cmd_config_e_tag_filter_del_parsed(
12780 void *parsed_result,
12781 __attribute__((unused)) struct cmdline *cl,
12782 __attribute__((unused)) void *data)
12784 struct cmd_config_e_tag_result *res = parsed_result;
12785 struct rte_eth_l2_tunnel_conf entry;
12788 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12791 if (res->e_tag_id_val > 0x3fff) {
12792 printf("e-tag-id must be less than 0x3fff.\n");
12796 ret = rte_eth_dev_filter_supported(res->port_id,
12797 RTE_ETH_FILTER_L2_TUNNEL);
12799 printf("E-tag filter is not supported on port %u.\n",
12804 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12805 entry.tunnel_id = res->e_tag_id_val;
12807 ret = rte_eth_dev_filter_ctrl(res->port_id,
12808 RTE_ETH_FILTER_L2_TUNNEL,
12809 RTE_ETH_FILTER_DELETE,
12812 printf("E-tag filter programming error: (%s)\n",
12816 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12817 .f = cmd_config_e_tag_filter_del_parsed,
12819 .help_str = "E-tag ... : E-tag filter delete",
12821 (void *)&cmd_config_e_tag_e_tag,
12822 (void *)&cmd_config_e_tag_set,
12823 (void *)&cmd_config_e_tag_filter,
12824 (void *)&cmd_config_e_tag_del,
12825 (void *)&cmd_config_e_tag_e_tag_id,
12826 (void *)&cmd_config_e_tag_e_tag_id_val,
12827 (void *)&cmd_config_e_tag_port,
12828 (void *)&cmd_config_e_tag_port_id,
12833 /* vf vlan anti spoof configuration */
12835 /* Common result structure for vf vlan anti spoof */
12836 struct cmd_vf_vlan_anti_spoof_result {
12837 cmdline_fixed_string_t set;
12838 cmdline_fixed_string_t vf;
12839 cmdline_fixed_string_t vlan;
12840 cmdline_fixed_string_t antispoof;
12843 cmdline_fixed_string_t on_off;
12846 /* Common CLI fields for vf vlan anti spoof enable disable */
12847 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12848 TOKEN_STRING_INITIALIZER
12849 (struct cmd_vf_vlan_anti_spoof_result,
12851 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12852 TOKEN_STRING_INITIALIZER
12853 (struct cmd_vf_vlan_anti_spoof_result,
12855 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12856 TOKEN_STRING_INITIALIZER
12857 (struct cmd_vf_vlan_anti_spoof_result,
12859 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12860 TOKEN_STRING_INITIALIZER
12861 (struct cmd_vf_vlan_anti_spoof_result,
12862 antispoof, "antispoof");
12863 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12864 TOKEN_NUM_INITIALIZER
12865 (struct cmd_vf_vlan_anti_spoof_result,
12867 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12868 TOKEN_NUM_INITIALIZER
12869 (struct cmd_vf_vlan_anti_spoof_result,
12871 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12872 TOKEN_STRING_INITIALIZER
12873 (struct cmd_vf_vlan_anti_spoof_result,
12877 cmd_set_vf_vlan_anti_spoof_parsed(
12878 void *parsed_result,
12879 __attribute__((unused)) struct cmdline *cl,
12880 __attribute__((unused)) void *data)
12882 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12883 int ret = -ENOTSUP;
12885 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12887 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12890 #ifdef RTE_LIBRTE_IXGBE_PMD
12891 if (ret == -ENOTSUP)
12892 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12893 res->vf_id, is_on);
12895 #ifdef RTE_LIBRTE_I40E_PMD
12896 if (ret == -ENOTSUP)
12897 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12898 res->vf_id, is_on);
12900 #ifdef RTE_LIBRTE_BNXT_PMD
12901 if (ret == -ENOTSUP)
12902 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12903 res->vf_id, is_on);
12910 printf("invalid vf_id %d\n", res->vf_id);
12913 printf("invalid port_id %d\n", res->port_id);
12916 printf("function not implemented\n");
12919 printf("programming error: (%s)\n", strerror(-ret));
12923 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12924 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12926 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12928 (void *)&cmd_vf_vlan_anti_spoof_set,
12929 (void *)&cmd_vf_vlan_anti_spoof_vf,
12930 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12931 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12932 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12933 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12934 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12939 /* vf mac anti spoof configuration */
12941 /* Common result structure for vf mac anti spoof */
12942 struct cmd_vf_mac_anti_spoof_result {
12943 cmdline_fixed_string_t set;
12944 cmdline_fixed_string_t vf;
12945 cmdline_fixed_string_t mac;
12946 cmdline_fixed_string_t antispoof;
12949 cmdline_fixed_string_t on_off;
12952 /* Common CLI fields for vf mac anti spoof enable disable */
12953 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12954 TOKEN_STRING_INITIALIZER
12955 (struct cmd_vf_mac_anti_spoof_result,
12957 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12958 TOKEN_STRING_INITIALIZER
12959 (struct cmd_vf_mac_anti_spoof_result,
12961 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12962 TOKEN_STRING_INITIALIZER
12963 (struct cmd_vf_mac_anti_spoof_result,
12965 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
12966 TOKEN_STRING_INITIALIZER
12967 (struct cmd_vf_mac_anti_spoof_result,
12968 antispoof, "antispoof");
12969 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
12970 TOKEN_NUM_INITIALIZER
12971 (struct cmd_vf_mac_anti_spoof_result,
12973 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
12974 TOKEN_NUM_INITIALIZER
12975 (struct cmd_vf_mac_anti_spoof_result,
12977 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
12978 TOKEN_STRING_INITIALIZER
12979 (struct cmd_vf_mac_anti_spoof_result,
12983 cmd_set_vf_mac_anti_spoof_parsed(
12984 void *parsed_result,
12985 __attribute__((unused)) struct cmdline *cl,
12986 __attribute__((unused)) void *data)
12988 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
12989 int ret = -ENOTSUP;
12991 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12993 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12996 #ifdef RTE_LIBRTE_IXGBE_PMD
12997 if (ret == -ENOTSUP)
12998 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
12999 res->vf_id, is_on);
13001 #ifdef RTE_LIBRTE_I40E_PMD
13002 if (ret == -ENOTSUP)
13003 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13004 res->vf_id, is_on);
13006 #ifdef RTE_LIBRTE_BNXT_PMD
13007 if (ret == -ENOTSUP)
13008 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13009 res->vf_id, is_on);
13016 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13019 printf("invalid port_id %d\n", res->port_id);
13022 printf("function not implemented\n");
13025 printf("programming error: (%s)\n", strerror(-ret));
13029 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13030 .f = cmd_set_vf_mac_anti_spoof_parsed,
13032 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13034 (void *)&cmd_vf_mac_anti_spoof_set,
13035 (void *)&cmd_vf_mac_anti_spoof_vf,
13036 (void *)&cmd_vf_mac_anti_spoof_mac,
13037 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13038 (void *)&cmd_vf_mac_anti_spoof_port_id,
13039 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13040 (void *)&cmd_vf_mac_anti_spoof_on_off,
13045 /* vf vlan strip queue configuration */
13047 /* Common result structure for vf mac anti spoof */
13048 struct cmd_vf_vlan_stripq_result {
13049 cmdline_fixed_string_t set;
13050 cmdline_fixed_string_t vf;
13051 cmdline_fixed_string_t vlan;
13052 cmdline_fixed_string_t stripq;
13055 cmdline_fixed_string_t on_off;
13058 /* Common CLI fields for vf vlan strip enable disable */
13059 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13060 TOKEN_STRING_INITIALIZER
13061 (struct cmd_vf_vlan_stripq_result,
13063 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13064 TOKEN_STRING_INITIALIZER
13065 (struct cmd_vf_vlan_stripq_result,
13067 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13068 TOKEN_STRING_INITIALIZER
13069 (struct cmd_vf_vlan_stripq_result,
13071 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13072 TOKEN_STRING_INITIALIZER
13073 (struct cmd_vf_vlan_stripq_result,
13075 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13076 TOKEN_NUM_INITIALIZER
13077 (struct cmd_vf_vlan_stripq_result,
13079 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13080 TOKEN_NUM_INITIALIZER
13081 (struct cmd_vf_vlan_stripq_result,
13083 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13084 TOKEN_STRING_INITIALIZER
13085 (struct cmd_vf_vlan_stripq_result,
13089 cmd_set_vf_vlan_stripq_parsed(
13090 void *parsed_result,
13091 __attribute__((unused)) struct cmdline *cl,
13092 __attribute__((unused)) void *data)
13094 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13095 int ret = -ENOTSUP;
13097 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13099 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13102 #ifdef RTE_LIBRTE_IXGBE_PMD
13103 if (ret == -ENOTSUP)
13104 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13105 res->vf_id, is_on);
13107 #ifdef RTE_LIBRTE_I40E_PMD
13108 if (ret == -ENOTSUP)
13109 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13110 res->vf_id, is_on);
13112 #ifdef RTE_LIBRTE_BNXT_PMD
13113 if (ret == -ENOTSUP)
13114 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13115 res->vf_id, is_on);
13122 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13125 printf("invalid port_id %d\n", res->port_id);
13128 printf("function not implemented\n");
13131 printf("programming error: (%s)\n", strerror(-ret));
13135 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13136 .f = cmd_set_vf_vlan_stripq_parsed,
13138 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13140 (void *)&cmd_vf_vlan_stripq_set,
13141 (void *)&cmd_vf_vlan_stripq_vf,
13142 (void *)&cmd_vf_vlan_stripq_vlan,
13143 (void *)&cmd_vf_vlan_stripq_stripq,
13144 (void *)&cmd_vf_vlan_stripq_port_id,
13145 (void *)&cmd_vf_vlan_stripq_vf_id,
13146 (void *)&cmd_vf_vlan_stripq_on_off,
13151 /* vf vlan insert configuration */
13153 /* Common result structure for vf vlan insert */
13154 struct cmd_vf_vlan_insert_result {
13155 cmdline_fixed_string_t set;
13156 cmdline_fixed_string_t vf;
13157 cmdline_fixed_string_t vlan;
13158 cmdline_fixed_string_t insert;
13164 /* Common CLI fields for vf vlan insert enable disable */
13165 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13166 TOKEN_STRING_INITIALIZER
13167 (struct cmd_vf_vlan_insert_result,
13169 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13170 TOKEN_STRING_INITIALIZER
13171 (struct cmd_vf_vlan_insert_result,
13173 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13174 TOKEN_STRING_INITIALIZER
13175 (struct cmd_vf_vlan_insert_result,
13177 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13178 TOKEN_STRING_INITIALIZER
13179 (struct cmd_vf_vlan_insert_result,
13181 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13182 TOKEN_NUM_INITIALIZER
13183 (struct cmd_vf_vlan_insert_result,
13185 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13186 TOKEN_NUM_INITIALIZER
13187 (struct cmd_vf_vlan_insert_result,
13189 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13190 TOKEN_NUM_INITIALIZER
13191 (struct cmd_vf_vlan_insert_result,
13195 cmd_set_vf_vlan_insert_parsed(
13196 void *parsed_result,
13197 __attribute__((unused)) struct cmdline *cl,
13198 __attribute__((unused)) void *data)
13200 struct cmd_vf_vlan_insert_result *res = parsed_result;
13201 int ret = -ENOTSUP;
13203 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13206 #ifdef RTE_LIBRTE_IXGBE_PMD
13207 if (ret == -ENOTSUP)
13208 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13211 #ifdef RTE_LIBRTE_I40E_PMD
13212 if (ret == -ENOTSUP)
13213 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13216 #ifdef RTE_LIBRTE_BNXT_PMD
13217 if (ret == -ENOTSUP)
13218 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13226 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13229 printf("invalid port_id %d\n", res->port_id);
13232 printf("function not implemented\n");
13235 printf("programming error: (%s)\n", strerror(-ret));
13239 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13240 .f = cmd_set_vf_vlan_insert_parsed,
13242 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13244 (void *)&cmd_vf_vlan_insert_set,
13245 (void *)&cmd_vf_vlan_insert_vf,
13246 (void *)&cmd_vf_vlan_insert_vlan,
13247 (void *)&cmd_vf_vlan_insert_insert,
13248 (void *)&cmd_vf_vlan_insert_port_id,
13249 (void *)&cmd_vf_vlan_insert_vf_id,
13250 (void *)&cmd_vf_vlan_insert_vlan_id,
13255 /* tx loopback configuration */
13257 /* Common result structure for tx loopback */
13258 struct cmd_tx_loopback_result {
13259 cmdline_fixed_string_t set;
13260 cmdline_fixed_string_t tx;
13261 cmdline_fixed_string_t loopback;
13263 cmdline_fixed_string_t on_off;
13266 /* Common CLI fields for tx loopback enable disable */
13267 cmdline_parse_token_string_t cmd_tx_loopback_set =
13268 TOKEN_STRING_INITIALIZER
13269 (struct cmd_tx_loopback_result,
13271 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13272 TOKEN_STRING_INITIALIZER
13273 (struct cmd_tx_loopback_result,
13275 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13276 TOKEN_STRING_INITIALIZER
13277 (struct cmd_tx_loopback_result,
13278 loopback, "loopback");
13279 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13280 TOKEN_NUM_INITIALIZER
13281 (struct cmd_tx_loopback_result,
13283 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13284 TOKEN_STRING_INITIALIZER
13285 (struct cmd_tx_loopback_result,
13289 cmd_set_tx_loopback_parsed(
13290 void *parsed_result,
13291 __attribute__((unused)) struct cmdline *cl,
13292 __attribute__((unused)) void *data)
13294 struct cmd_tx_loopback_result *res = parsed_result;
13295 int ret = -ENOTSUP;
13297 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13299 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13302 #ifdef RTE_LIBRTE_IXGBE_PMD
13303 if (ret == -ENOTSUP)
13304 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13306 #ifdef RTE_LIBRTE_I40E_PMD
13307 if (ret == -ENOTSUP)
13308 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13310 #ifdef RTE_LIBRTE_BNXT_PMD
13311 if (ret == -ENOTSUP)
13312 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13314 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13315 if (ret == -ENOTSUP)
13316 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13323 printf("invalid is_on %d\n", is_on);
13326 printf("invalid port_id %d\n", res->port_id);
13329 printf("function not implemented\n");
13332 printf("programming error: (%s)\n", strerror(-ret));
13336 cmdline_parse_inst_t cmd_set_tx_loopback = {
13337 .f = cmd_set_tx_loopback_parsed,
13339 .help_str = "set tx loopback <port_id> on|off",
13341 (void *)&cmd_tx_loopback_set,
13342 (void *)&cmd_tx_loopback_tx,
13343 (void *)&cmd_tx_loopback_loopback,
13344 (void *)&cmd_tx_loopback_port_id,
13345 (void *)&cmd_tx_loopback_on_off,
13350 /* all queues drop enable configuration */
13352 /* Common result structure for all queues drop enable */
13353 struct cmd_all_queues_drop_en_result {
13354 cmdline_fixed_string_t set;
13355 cmdline_fixed_string_t all;
13356 cmdline_fixed_string_t queues;
13357 cmdline_fixed_string_t drop;
13359 cmdline_fixed_string_t on_off;
13362 /* Common CLI fields for tx loopback enable disable */
13363 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13364 TOKEN_STRING_INITIALIZER
13365 (struct cmd_all_queues_drop_en_result,
13367 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13368 TOKEN_STRING_INITIALIZER
13369 (struct cmd_all_queues_drop_en_result,
13371 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13372 TOKEN_STRING_INITIALIZER
13373 (struct cmd_all_queues_drop_en_result,
13375 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13376 TOKEN_STRING_INITIALIZER
13377 (struct cmd_all_queues_drop_en_result,
13379 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13380 TOKEN_NUM_INITIALIZER
13381 (struct cmd_all_queues_drop_en_result,
13383 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13384 TOKEN_STRING_INITIALIZER
13385 (struct cmd_all_queues_drop_en_result,
13389 cmd_set_all_queues_drop_en_parsed(
13390 void *parsed_result,
13391 __attribute__((unused)) struct cmdline *cl,
13392 __attribute__((unused)) void *data)
13394 struct cmd_all_queues_drop_en_result *res = parsed_result;
13395 int ret = -ENOTSUP;
13396 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13398 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13401 #ifdef RTE_LIBRTE_IXGBE_PMD
13402 if (ret == -ENOTSUP)
13403 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13405 #ifdef RTE_LIBRTE_BNXT_PMD
13406 if (ret == -ENOTSUP)
13407 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13413 printf("invalid is_on %d\n", is_on);
13416 printf("invalid port_id %d\n", res->port_id);
13419 printf("function not implemented\n");
13422 printf("programming error: (%s)\n", strerror(-ret));
13426 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13427 .f = cmd_set_all_queues_drop_en_parsed,
13429 .help_str = "set all queues drop <port_id> on|off",
13431 (void *)&cmd_all_queues_drop_en_set,
13432 (void *)&cmd_all_queues_drop_en_all,
13433 (void *)&cmd_all_queues_drop_en_queues,
13434 (void *)&cmd_all_queues_drop_en_drop,
13435 (void *)&cmd_all_queues_drop_en_port_id,
13436 (void *)&cmd_all_queues_drop_en_on_off,
13441 /* vf split drop enable configuration */
13443 /* Common result structure for vf split drop enable */
13444 struct cmd_vf_split_drop_en_result {
13445 cmdline_fixed_string_t set;
13446 cmdline_fixed_string_t vf;
13447 cmdline_fixed_string_t split;
13448 cmdline_fixed_string_t drop;
13451 cmdline_fixed_string_t on_off;
13454 /* Common CLI fields for vf split drop enable disable */
13455 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13456 TOKEN_STRING_INITIALIZER
13457 (struct cmd_vf_split_drop_en_result,
13459 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13460 TOKEN_STRING_INITIALIZER
13461 (struct cmd_vf_split_drop_en_result,
13463 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13464 TOKEN_STRING_INITIALIZER
13465 (struct cmd_vf_split_drop_en_result,
13467 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13468 TOKEN_STRING_INITIALIZER
13469 (struct cmd_vf_split_drop_en_result,
13471 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13472 TOKEN_NUM_INITIALIZER
13473 (struct cmd_vf_split_drop_en_result,
13475 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13476 TOKEN_NUM_INITIALIZER
13477 (struct cmd_vf_split_drop_en_result,
13479 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13480 TOKEN_STRING_INITIALIZER
13481 (struct cmd_vf_split_drop_en_result,
13485 cmd_set_vf_split_drop_en_parsed(
13486 void *parsed_result,
13487 __attribute__((unused)) struct cmdline *cl,
13488 __attribute__((unused)) void *data)
13490 struct cmd_vf_split_drop_en_result *res = parsed_result;
13491 int ret = -ENOTSUP;
13492 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13494 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13497 #ifdef RTE_LIBRTE_IXGBE_PMD
13498 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13505 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13508 printf("invalid port_id %d\n", res->port_id);
13511 printf("not supported on port %d\n", res->port_id);
13514 printf("programming error: (%s)\n", strerror(-ret));
13518 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13519 .f = cmd_set_vf_split_drop_en_parsed,
13521 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13523 (void *)&cmd_vf_split_drop_en_set,
13524 (void *)&cmd_vf_split_drop_en_vf,
13525 (void *)&cmd_vf_split_drop_en_split,
13526 (void *)&cmd_vf_split_drop_en_drop,
13527 (void *)&cmd_vf_split_drop_en_port_id,
13528 (void *)&cmd_vf_split_drop_en_vf_id,
13529 (void *)&cmd_vf_split_drop_en_on_off,
13534 /* vf mac address configuration */
13536 /* Common result structure for vf mac address */
13537 struct cmd_set_vf_mac_addr_result {
13538 cmdline_fixed_string_t set;
13539 cmdline_fixed_string_t vf;
13540 cmdline_fixed_string_t mac;
13541 cmdline_fixed_string_t addr;
13544 struct ether_addr mac_addr;
13548 /* Common CLI fields for vf split drop enable disable */
13549 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13550 TOKEN_STRING_INITIALIZER
13551 (struct cmd_set_vf_mac_addr_result,
13553 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13554 TOKEN_STRING_INITIALIZER
13555 (struct cmd_set_vf_mac_addr_result,
13557 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13558 TOKEN_STRING_INITIALIZER
13559 (struct cmd_set_vf_mac_addr_result,
13561 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13562 TOKEN_STRING_INITIALIZER
13563 (struct cmd_set_vf_mac_addr_result,
13565 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13566 TOKEN_NUM_INITIALIZER
13567 (struct cmd_set_vf_mac_addr_result,
13569 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13570 TOKEN_NUM_INITIALIZER
13571 (struct cmd_set_vf_mac_addr_result,
13573 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13574 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13578 cmd_set_vf_mac_addr_parsed(
13579 void *parsed_result,
13580 __attribute__((unused)) struct cmdline *cl,
13581 __attribute__((unused)) void *data)
13583 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13584 int ret = -ENOTSUP;
13586 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13589 #ifdef RTE_LIBRTE_IXGBE_PMD
13590 if (ret == -ENOTSUP)
13591 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13594 #ifdef RTE_LIBRTE_I40E_PMD
13595 if (ret == -ENOTSUP)
13596 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13599 #ifdef RTE_LIBRTE_BNXT_PMD
13600 if (ret == -ENOTSUP)
13601 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13609 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13612 printf("invalid port_id %d\n", res->port_id);
13615 printf("function not implemented\n");
13618 printf("programming error: (%s)\n", strerror(-ret));
13622 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13623 .f = cmd_set_vf_mac_addr_parsed,
13625 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13627 (void *)&cmd_set_vf_mac_addr_set,
13628 (void *)&cmd_set_vf_mac_addr_vf,
13629 (void *)&cmd_set_vf_mac_addr_mac,
13630 (void *)&cmd_set_vf_mac_addr_addr,
13631 (void *)&cmd_set_vf_mac_addr_port_id,
13632 (void *)&cmd_set_vf_mac_addr_vf_id,
13633 (void *)&cmd_set_vf_mac_addr_mac_addr,
13638 /* MACsec configuration */
13640 /* Common result structure for MACsec offload enable */
13641 struct cmd_macsec_offload_on_result {
13642 cmdline_fixed_string_t set;
13643 cmdline_fixed_string_t macsec;
13644 cmdline_fixed_string_t offload;
13646 cmdline_fixed_string_t on;
13647 cmdline_fixed_string_t encrypt;
13648 cmdline_fixed_string_t en_on_off;
13649 cmdline_fixed_string_t replay_protect;
13650 cmdline_fixed_string_t rp_on_off;
13653 /* Common CLI fields for MACsec offload disable */
13654 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13655 TOKEN_STRING_INITIALIZER
13656 (struct cmd_macsec_offload_on_result,
13658 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13659 TOKEN_STRING_INITIALIZER
13660 (struct cmd_macsec_offload_on_result,
13662 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13663 TOKEN_STRING_INITIALIZER
13664 (struct cmd_macsec_offload_on_result,
13665 offload, "offload");
13666 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13667 TOKEN_NUM_INITIALIZER
13668 (struct cmd_macsec_offload_on_result,
13670 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13671 TOKEN_STRING_INITIALIZER
13672 (struct cmd_macsec_offload_on_result,
13674 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13675 TOKEN_STRING_INITIALIZER
13676 (struct cmd_macsec_offload_on_result,
13677 encrypt, "encrypt");
13678 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13679 TOKEN_STRING_INITIALIZER
13680 (struct cmd_macsec_offload_on_result,
13681 en_on_off, "on#off");
13682 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13683 TOKEN_STRING_INITIALIZER
13684 (struct cmd_macsec_offload_on_result,
13685 replay_protect, "replay-protect");
13686 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13687 TOKEN_STRING_INITIALIZER
13688 (struct cmd_macsec_offload_on_result,
13689 rp_on_off, "on#off");
13692 cmd_set_macsec_offload_on_parsed(
13693 void *parsed_result,
13694 __attribute__((unused)) struct cmdline *cl,
13695 __attribute__((unused)) void *data)
13697 struct cmd_macsec_offload_on_result *res = parsed_result;
13698 int ret = -ENOTSUP;
13699 portid_t port_id = res->port_id;
13700 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13701 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13702 struct rte_eth_dev_info dev_info;
13704 if (port_id_is_invalid(port_id, ENABLED_WARN))
13706 if (!port_is_stopped(port_id)) {
13707 printf("Please stop port %d first\n", port_id);
13711 rte_eth_dev_info_get(port_id, &dev_info);
13712 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13713 #ifdef RTE_LIBRTE_IXGBE_PMD
13714 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13722 ports[port_id].dev_conf.txmode.offloads |=
13723 DEV_TX_OFFLOAD_MACSEC_INSERT;
13724 cmd_reconfig_device_queue(port_id, 1, 1);
13727 printf("invalid port_id %d\n", port_id);
13730 printf("not supported on port %d\n", port_id);
13733 printf("programming error: (%s)\n", strerror(-ret));
13737 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13738 .f = cmd_set_macsec_offload_on_parsed,
13740 .help_str = "set macsec offload <port_id> on "
13741 "encrypt on|off replay-protect on|off",
13743 (void *)&cmd_macsec_offload_on_set,
13744 (void *)&cmd_macsec_offload_on_macsec,
13745 (void *)&cmd_macsec_offload_on_offload,
13746 (void *)&cmd_macsec_offload_on_port_id,
13747 (void *)&cmd_macsec_offload_on_on,
13748 (void *)&cmd_macsec_offload_on_encrypt,
13749 (void *)&cmd_macsec_offload_on_en_on_off,
13750 (void *)&cmd_macsec_offload_on_replay_protect,
13751 (void *)&cmd_macsec_offload_on_rp_on_off,
13756 /* Common result structure for MACsec offload disable */
13757 struct cmd_macsec_offload_off_result {
13758 cmdline_fixed_string_t set;
13759 cmdline_fixed_string_t macsec;
13760 cmdline_fixed_string_t offload;
13762 cmdline_fixed_string_t off;
13765 /* Common CLI fields for MACsec offload disable */
13766 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13767 TOKEN_STRING_INITIALIZER
13768 (struct cmd_macsec_offload_off_result,
13770 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13771 TOKEN_STRING_INITIALIZER
13772 (struct cmd_macsec_offload_off_result,
13774 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13775 TOKEN_STRING_INITIALIZER
13776 (struct cmd_macsec_offload_off_result,
13777 offload, "offload");
13778 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13779 TOKEN_NUM_INITIALIZER
13780 (struct cmd_macsec_offload_off_result,
13782 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13783 TOKEN_STRING_INITIALIZER
13784 (struct cmd_macsec_offload_off_result,
13788 cmd_set_macsec_offload_off_parsed(
13789 void *parsed_result,
13790 __attribute__((unused)) struct cmdline *cl,
13791 __attribute__((unused)) void *data)
13793 struct cmd_macsec_offload_off_result *res = parsed_result;
13794 int ret = -ENOTSUP;
13795 struct rte_eth_dev_info dev_info;
13796 portid_t port_id = res->port_id;
13798 if (port_id_is_invalid(port_id, ENABLED_WARN))
13800 if (!port_is_stopped(port_id)) {
13801 printf("Please stop port %d first\n", port_id);
13805 rte_eth_dev_info_get(port_id, &dev_info);
13806 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13807 #ifdef RTE_LIBRTE_IXGBE_PMD
13808 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13813 ports[port_id].dev_conf.txmode.offloads &=
13814 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13815 cmd_reconfig_device_queue(port_id, 1, 1);
13818 printf("invalid port_id %d\n", port_id);
13821 printf("not supported on port %d\n", port_id);
13824 printf("programming error: (%s)\n", strerror(-ret));
13828 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13829 .f = cmd_set_macsec_offload_off_parsed,
13831 .help_str = "set macsec offload <port_id> off",
13833 (void *)&cmd_macsec_offload_off_set,
13834 (void *)&cmd_macsec_offload_off_macsec,
13835 (void *)&cmd_macsec_offload_off_offload,
13836 (void *)&cmd_macsec_offload_off_port_id,
13837 (void *)&cmd_macsec_offload_off_off,
13842 /* Common result structure for MACsec secure connection configure */
13843 struct cmd_macsec_sc_result {
13844 cmdline_fixed_string_t set;
13845 cmdline_fixed_string_t macsec;
13846 cmdline_fixed_string_t sc;
13847 cmdline_fixed_string_t tx_rx;
13849 struct ether_addr mac;
13853 /* Common CLI fields for MACsec secure connection configure */
13854 cmdline_parse_token_string_t cmd_macsec_sc_set =
13855 TOKEN_STRING_INITIALIZER
13856 (struct cmd_macsec_sc_result,
13858 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13859 TOKEN_STRING_INITIALIZER
13860 (struct cmd_macsec_sc_result,
13862 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13863 TOKEN_STRING_INITIALIZER
13864 (struct cmd_macsec_sc_result,
13866 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13867 TOKEN_STRING_INITIALIZER
13868 (struct cmd_macsec_sc_result,
13870 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13871 TOKEN_NUM_INITIALIZER
13872 (struct cmd_macsec_sc_result,
13874 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13875 TOKEN_ETHERADDR_INITIALIZER
13876 (struct cmd_macsec_sc_result,
13878 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13879 TOKEN_NUM_INITIALIZER
13880 (struct cmd_macsec_sc_result,
13884 cmd_set_macsec_sc_parsed(
13885 void *parsed_result,
13886 __attribute__((unused)) struct cmdline *cl,
13887 __attribute__((unused)) void *data)
13889 struct cmd_macsec_sc_result *res = parsed_result;
13890 int ret = -ENOTSUP;
13891 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13893 #ifdef RTE_LIBRTE_IXGBE_PMD
13895 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13896 res->mac.addr_bytes) :
13897 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13898 res->mac.addr_bytes, res->pi);
13900 RTE_SET_USED(is_tx);
13906 printf("invalid port_id %d\n", res->port_id);
13909 printf("not supported on port %d\n", res->port_id);
13912 printf("programming error: (%s)\n", strerror(-ret));
13916 cmdline_parse_inst_t cmd_set_macsec_sc = {
13917 .f = cmd_set_macsec_sc_parsed,
13919 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13921 (void *)&cmd_macsec_sc_set,
13922 (void *)&cmd_macsec_sc_macsec,
13923 (void *)&cmd_macsec_sc_sc,
13924 (void *)&cmd_macsec_sc_tx_rx,
13925 (void *)&cmd_macsec_sc_port_id,
13926 (void *)&cmd_macsec_sc_mac,
13927 (void *)&cmd_macsec_sc_pi,
13932 /* Common result structure for MACsec secure connection configure */
13933 struct cmd_macsec_sa_result {
13934 cmdline_fixed_string_t set;
13935 cmdline_fixed_string_t macsec;
13936 cmdline_fixed_string_t sa;
13937 cmdline_fixed_string_t tx_rx;
13942 cmdline_fixed_string_t key;
13945 /* Common CLI fields for MACsec secure connection configure */
13946 cmdline_parse_token_string_t cmd_macsec_sa_set =
13947 TOKEN_STRING_INITIALIZER
13948 (struct cmd_macsec_sa_result,
13950 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13951 TOKEN_STRING_INITIALIZER
13952 (struct cmd_macsec_sa_result,
13954 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13955 TOKEN_STRING_INITIALIZER
13956 (struct cmd_macsec_sa_result,
13958 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13959 TOKEN_STRING_INITIALIZER
13960 (struct cmd_macsec_sa_result,
13962 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13963 TOKEN_NUM_INITIALIZER
13964 (struct cmd_macsec_sa_result,
13966 cmdline_parse_token_num_t cmd_macsec_sa_idx =
13967 TOKEN_NUM_INITIALIZER
13968 (struct cmd_macsec_sa_result,
13970 cmdline_parse_token_num_t cmd_macsec_sa_an =
13971 TOKEN_NUM_INITIALIZER
13972 (struct cmd_macsec_sa_result,
13974 cmdline_parse_token_num_t cmd_macsec_sa_pn =
13975 TOKEN_NUM_INITIALIZER
13976 (struct cmd_macsec_sa_result,
13978 cmdline_parse_token_string_t cmd_macsec_sa_key =
13979 TOKEN_STRING_INITIALIZER
13980 (struct cmd_macsec_sa_result,
13984 cmd_set_macsec_sa_parsed(
13985 void *parsed_result,
13986 __attribute__((unused)) struct cmdline *cl,
13987 __attribute__((unused)) void *data)
13989 struct cmd_macsec_sa_result *res = parsed_result;
13990 int ret = -ENOTSUP;
13991 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13992 uint8_t key[16] = { 0 };
13998 key_len = strlen(res->key) / 2;
14002 for (i = 0; i < key_len; i++) {
14003 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14006 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14009 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14012 #ifdef RTE_LIBRTE_IXGBE_PMD
14014 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14015 res->idx, res->an, res->pn, key) :
14016 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14017 res->idx, res->an, res->pn, key);
14019 RTE_SET_USED(is_tx);
14026 printf("invalid idx %d or an %d\n", res->idx, res->an);
14029 printf("invalid port_id %d\n", res->port_id);
14032 printf("not supported on port %d\n", res->port_id);
14035 printf("programming error: (%s)\n", strerror(-ret));
14039 cmdline_parse_inst_t cmd_set_macsec_sa = {
14040 .f = cmd_set_macsec_sa_parsed,
14042 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14044 (void *)&cmd_macsec_sa_set,
14045 (void *)&cmd_macsec_sa_macsec,
14046 (void *)&cmd_macsec_sa_sa,
14047 (void *)&cmd_macsec_sa_tx_rx,
14048 (void *)&cmd_macsec_sa_port_id,
14049 (void *)&cmd_macsec_sa_idx,
14050 (void *)&cmd_macsec_sa_an,
14051 (void *)&cmd_macsec_sa_pn,
14052 (void *)&cmd_macsec_sa_key,
14057 /* VF unicast promiscuous mode configuration */
14059 /* Common result structure for VF unicast promiscuous mode */
14060 struct cmd_vf_promisc_result {
14061 cmdline_fixed_string_t set;
14062 cmdline_fixed_string_t vf;
14063 cmdline_fixed_string_t promisc;
14066 cmdline_fixed_string_t on_off;
14069 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14070 cmdline_parse_token_string_t cmd_vf_promisc_set =
14071 TOKEN_STRING_INITIALIZER
14072 (struct cmd_vf_promisc_result,
14074 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14075 TOKEN_STRING_INITIALIZER
14076 (struct cmd_vf_promisc_result,
14078 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14079 TOKEN_STRING_INITIALIZER
14080 (struct cmd_vf_promisc_result,
14081 promisc, "promisc");
14082 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14083 TOKEN_NUM_INITIALIZER
14084 (struct cmd_vf_promisc_result,
14086 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14087 TOKEN_NUM_INITIALIZER
14088 (struct cmd_vf_promisc_result,
14090 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14091 TOKEN_STRING_INITIALIZER
14092 (struct cmd_vf_promisc_result,
14096 cmd_set_vf_promisc_parsed(
14097 void *parsed_result,
14098 __attribute__((unused)) struct cmdline *cl,
14099 __attribute__((unused)) void *data)
14101 struct cmd_vf_promisc_result *res = parsed_result;
14102 int ret = -ENOTSUP;
14104 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14106 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14109 #ifdef RTE_LIBRTE_I40E_PMD
14110 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14111 res->vf_id, is_on);
14118 printf("invalid vf_id %d\n", res->vf_id);
14121 printf("invalid port_id %d\n", res->port_id);
14124 printf("function not implemented\n");
14127 printf("programming error: (%s)\n", strerror(-ret));
14131 cmdline_parse_inst_t cmd_set_vf_promisc = {
14132 .f = cmd_set_vf_promisc_parsed,
14134 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14135 "Set unicast promiscuous mode for a VF from the PF",
14137 (void *)&cmd_vf_promisc_set,
14138 (void *)&cmd_vf_promisc_vf,
14139 (void *)&cmd_vf_promisc_promisc,
14140 (void *)&cmd_vf_promisc_port_id,
14141 (void *)&cmd_vf_promisc_vf_id,
14142 (void *)&cmd_vf_promisc_on_off,
14147 /* VF multicast promiscuous mode configuration */
14149 /* Common result structure for VF multicast promiscuous mode */
14150 struct cmd_vf_allmulti_result {
14151 cmdline_fixed_string_t set;
14152 cmdline_fixed_string_t vf;
14153 cmdline_fixed_string_t allmulti;
14156 cmdline_fixed_string_t on_off;
14159 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14160 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14161 TOKEN_STRING_INITIALIZER
14162 (struct cmd_vf_allmulti_result,
14164 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14165 TOKEN_STRING_INITIALIZER
14166 (struct cmd_vf_allmulti_result,
14168 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14169 TOKEN_STRING_INITIALIZER
14170 (struct cmd_vf_allmulti_result,
14171 allmulti, "allmulti");
14172 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14173 TOKEN_NUM_INITIALIZER
14174 (struct cmd_vf_allmulti_result,
14176 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14177 TOKEN_NUM_INITIALIZER
14178 (struct cmd_vf_allmulti_result,
14180 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14181 TOKEN_STRING_INITIALIZER
14182 (struct cmd_vf_allmulti_result,
14186 cmd_set_vf_allmulti_parsed(
14187 void *parsed_result,
14188 __attribute__((unused)) struct cmdline *cl,
14189 __attribute__((unused)) void *data)
14191 struct cmd_vf_allmulti_result *res = parsed_result;
14192 int ret = -ENOTSUP;
14194 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14196 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14199 #ifdef RTE_LIBRTE_I40E_PMD
14200 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14201 res->vf_id, is_on);
14208 printf("invalid vf_id %d\n", res->vf_id);
14211 printf("invalid port_id %d\n", res->port_id);
14214 printf("function not implemented\n");
14217 printf("programming error: (%s)\n", strerror(-ret));
14221 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14222 .f = cmd_set_vf_allmulti_parsed,
14224 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14225 "Set multicast promiscuous mode for a VF from the PF",
14227 (void *)&cmd_vf_allmulti_set,
14228 (void *)&cmd_vf_allmulti_vf,
14229 (void *)&cmd_vf_allmulti_allmulti,
14230 (void *)&cmd_vf_allmulti_port_id,
14231 (void *)&cmd_vf_allmulti_vf_id,
14232 (void *)&cmd_vf_allmulti_on_off,
14237 /* vf broadcast mode configuration */
14239 /* Common result structure for vf broadcast */
14240 struct cmd_set_vf_broadcast_result {
14241 cmdline_fixed_string_t set;
14242 cmdline_fixed_string_t vf;
14243 cmdline_fixed_string_t broadcast;
14246 cmdline_fixed_string_t on_off;
14249 /* Common CLI fields for vf broadcast enable disable */
14250 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14251 TOKEN_STRING_INITIALIZER
14252 (struct cmd_set_vf_broadcast_result,
14254 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14255 TOKEN_STRING_INITIALIZER
14256 (struct cmd_set_vf_broadcast_result,
14258 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14259 TOKEN_STRING_INITIALIZER
14260 (struct cmd_set_vf_broadcast_result,
14261 broadcast, "broadcast");
14262 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14263 TOKEN_NUM_INITIALIZER
14264 (struct cmd_set_vf_broadcast_result,
14266 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14267 TOKEN_NUM_INITIALIZER
14268 (struct cmd_set_vf_broadcast_result,
14270 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14271 TOKEN_STRING_INITIALIZER
14272 (struct cmd_set_vf_broadcast_result,
14276 cmd_set_vf_broadcast_parsed(
14277 void *parsed_result,
14278 __attribute__((unused)) struct cmdline *cl,
14279 __attribute__((unused)) void *data)
14281 struct cmd_set_vf_broadcast_result *res = parsed_result;
14282 int ret = -ENOTSUP;
14284 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14286 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14289 #ifdef RTE_LIBRTE_I40E_PMD
14290 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14291 res->vf_id, is_on);
14298 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14301 printf("invalid port_id %d\n", res->port_id);
14304 printf("function not implemented\n");
14307 printf("programming error: (%s)\n", strerror(-ret));
14311 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14312 .f = cmd_set_vf_broadcast_parsed,
14314 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14316 (void *)&cmd_set_vf_broadcast_set,
14317 (void *)&cmd_set_vf_broadcast_vf,
14318 (void *)&cmd_set_vf_broadcast_broadcast,
14319 (void *)&cmd_set_vf_broadcast_port_id,
14320 (void *)&cmd_set_vf_broadcast_vf_id,
14321 (void *)&cmd_set_vf_broadcast_on_off,
14326 /* vf vlan tag configuration */
14328 /* Common result structure for vf vlan tag */
14329 struct cmd_set_vf_vlan_tag_result {
14330 cmdline_fixed_string_t set;
14331 cmdline_fixed_string_t vf;
14332 cmdline_fixed_string_t vlan;
14333 cmdline_fixed_string_t tag;
14336 cmdline_fixed_string_t on_off;
14339 /* Common CLI fields for vf vlan tag enable disable */
14340 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14341 TOKEN_STRING_INITIALIZER
14342 (struct cmd_set_vf_vlan_tag_result,
14344 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14345 TOKEN_STRING_INITIALIZER
14346 (struct cmd_set_vf_vlan_tag_result,
14348 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14349 TOKEN_STRING_INITIALIZER
14350 (struct cmd_set_vf_vlan_tag_result,
14352 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14353 TOKEN_STRING_INITIALIZER
14354 (struct cmd_set_vf_vlan_tag_result,
14356 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14357 TOKEN_NUM_INITIALIZER
14358 (struct cmd_set_vf_vlan_tag_result,
14360 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14361 TOKEN_NUM_INITIALIZER
14362 (struct cmd_set_vf_vlan_tag_result,
14364 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14365 TOKEN_STRING_INITIALIZER
14366 (struct cmd_set_vf_vlan_tag_result,
14370 cmd_set_vf_vlan_tag_parsed(
14371 void *parsed_result,
14372 __attribute__((unused)) struct cmdline *cl,
14373 __attribute__((unused)) void *data)
14375 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14376 int ret = -ENOTSUP;
14378 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14380 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14383 #ifdef RTE_LIBRTE_I40E_PMD
14384 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14385 res->vf_id, is_on);
14392 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14395 printf("invalid port_id %d\n", res->port_id);
14398 printf("function not implemented\n");
14401 printf("programming error: (%s)\n", strerror(-ret));
14405 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14406 .f = cmd_set_vf_vlan_tag_parsed,
14408 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14410 (void *)&cmd_set_vf_vlan_tag_set,
14411 (void *)&cmd_set_vf_vlan_tag_vf,
14412 (void *)&cmd_set_vf_vlan_tag_vlan,
14413 (void *)&cmd_set_vf_vlan_tag_tag,
14414 (void *)&cmd_set_vf_vlan_tag_port_id,
14415 (void *)&cmd_set_vf_vlan_tag_vf_id,
14416 (void *)&cmd_set_vf_vlan_tag_on_off,
14421 /* Common definition of VF and TC TX bandwidth configuration */
14422 struct cmd_vf_tc_bw_result {
14423 cmdline_fixed_string_t set;
14424 cmdline_fixed_string_t vf;
14425 cmdline_fixed_string_t tc;
14426 cmdline_fixed_string_t tx;
14427 cmdline_fixed_string_t min_bw;
14428 cmdline_fixed_string_t max_bw;
14429 cmdline_fixed_string_t strict_link_prio;
14434 cmdline_fixed_string_t bw_list;
14438 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14439 TOKEN_STRING_INITIALIZER
14440 (struct cmd_vf_tc_bw_result,
14442 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14443 TOKEN_STRING_INITIALIZER
14444 (struct cmd_vf_tc_bw_result,
14446 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14447 TOKEN_STRING_INITIALIZER
14448 (struct cmd_vf_tc_bw_result,
14450 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14451 TOKEN_STRING_INITIALIZER
14452 (struct cmd_vf_tc_bw_result,
14454 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14455 TOKEN_STRING_INITIALIZER
14456 (struct cmd_vf_tc_bw_result,
14457 strict_link_prio, "strict-link-priority");
14458 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14459 TOKEN_STRING_INITIALIZER
14460 (struct cmd_vf_tc_bw_result,
14461 min_bw, "min-bandwidth");
14462 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14463 TOKEN_STRING_INITIALIZER
14464 (struct cmd_vf_tc_bw_result,
14465 max_bw, "max-bandwidth");
14466 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14467 TOKEN_NUM_INITIALIZER
14468 (struct cmd_vf_tc_bw_result,
14470 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14471 TOKEN_NUM_INITIALIZER
14472 (struct cmd_vf_tc_bw_result,
14474 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14475 TOKEN_NUM_INITIALIZER
14476 (struct cmd_vf_tc_bw_result,
14478 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14479 TOKEN_NUM_INITIALIZER
14480 (struct cmd_vf_tc_bw_result,
14482 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14483 TOKEN_STRING_INITIALIZER
14484 (struct cmd_vf_tc_bw_result,
14486 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14487 TOKEN_NUM_INITIALIZER
14488 (struct cmd_vf_tc_bw_result,
14491 /* VF max bandwidth setting */
14493 cmd_vf_max_bw_parsed(
14494 void *parsed_result,
14495 __attribute__((unused)) struct cmdline *cl,
14496 __attribute__((unused)) void *data)
14498 struct cmd_vf_tc_bw_result *res = parsed_result;
14499 int ret = -ENOTSUP;
14501 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14504 #ifdef RTE_LIBRTE_I40E_PMD
14505 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14506 res->vf_id, res->bw);
14513 printf("invalid vf_id %d or bandwidth %d\n",
14514 res->vf_id, res->bw);
14517 printf("invalid port_id %d\n", res->port_id);
14520 printf("function not implemented\n");
14523 printf("programming error: (%s)\n", strerror(-ret));
14527 cmdline_parse_inst_t cmd_vf_max_bw = {
14528 .f = cmd_vf_max_bw_parsed,
14530 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14532 (void *)&cmd_vf_tc_bw_set,
14533 (void *)&cmd_vf_tc_bw_vf,
14534 (void *)&cmd_vf_tc_bw_tx,
14535 (void *)&cmd_vf_tc_bw_max_bw,
14536 (void *)&cmd_vf_tc_bw_port_id,
14537 (void *)&cmd_vf_tc_bw_vf_id,
14538 (void *)&cmd_vf_tc_bw_bw,
14544 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14549 const char *p, *p0 = str;
14556 p = strchr(p0, '(');
14558 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14562 p0 = strchr(p, ')');
14564 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14568 if (size >= sizeof(s)) {
14569 printf("The string size exceeds the internal buffer size\n");
14572 snprintf(s, sizeof(s), "%.*s", size, p);
14573 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14575 printf("Failed to get the bandwidth list. ");
14579 for (i = 0; i < ret; i++)
14580 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14585 /* TC min bandwidth setting */
14587 cmd_vf_tc_min_bw_parsed(
14588 void *parsed_result,
14589 __attribute__((unused)) struct cmdline *cl,
14590 __attribute__((unused)) void *data)
14592 struct cmd_vf_tc_bw_result *res = parsed_result;
14595 int ret = -ENOTSUP;
14597 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14600 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14604 #ifdef RTE_LIBRTE_I40E_PMD
14605 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14613 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14616 printf("invalid port_id %d\n", res->port_id);
14619 printf("function not implemented\n");
14622 printf("programming error: (%s)\n", strerror(-ret));
14626 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14627 .f = cmd_vf_tc_min_bw_parsed,
14629 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14630 " <bw1, bw2, ...>",
14632 (void *)&cmd_vf_tc_bw_set,
14633 (void *)&cmd_vf_tc_bw_vf,
14634 (void *)&cmd_vf_tc_bw_tc,
14635 (void *)&cmd_vf_tc_bw_tx,
14636 (void *)&cmd_vf_tc_bw_min_bw,
14637 (void *)&cmd_vf_tc_bw_port_id,
14638 (void *)&cmd_vf_tc_bw_vf_id,
14639 (void *)&cmd_vf_tc_bw_bw_list,
14645 cmd_tc_min_bw_parsed(
14646 void *parsed_result,
14647 __attribute__((unused)) struct cmdline *cl,
14648 __attribute__((unused)) void *data)
14650 struct cmd_vf_tc_bw_result *res = parsed_result;
14651 struct rte_port *port;
14654 int ret = -ENOTSUP;
14656 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14659 port = &ports[res->port_id];
14660 /** Check if the port is not started **/
14661 if (port->port_status != RTE_PORT_STOPPED) {
14662 printf("Please stop port %d first\n", res->port_id);
14666 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14670 #ifdef RTE_LIBRTE_IXGBE_PMD
14671 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14678 printf("invalid bandwidth\n");
14681 printf("invalid port_id %d\n", res->port_id);
14684 printf("function not implemented\n");
14687 printf("programming error: (%s)\n", strerror(-ret));
14691 cmdline_parse_inst_t cmd_tc_min_bw = {
14692 .f = cmd_tc_min_bw_parsed,
14694 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14696 (void *)&cmd_vf_tc_bw_set,
14697 (void *)&cmd_vf_tc_bw_tc,
14698 (void *)&cmd_vf_tc_bw_tx,
14699 (void *)&cmd_vf_tc_bw_min_bw,
14700 (void *)&cmd_vf_tc_bw_port_id,
14701 (void *)&cmd_vf_tc_bw_bw_list,
14706 /* TC max bandwidth setting */
14708 cmd_vf_tc_max_bw_parsed(
14709 void *parsed_result,
14710 __attribute__((unused)) struct cmdline *cl,
14711 __attribute__((unused)) void *data)
14713 struct cmd_vf_tc_bw_result *res = parsed_result;
14714 int ret = -ENOTSUP;
14716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14719 #ifdef RTE_LIBRTE_I40E_PMD
14720 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14721 res->tc_no, res->bw);
14728 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14729 res->vf_id, res->tc_no, res->bw);
14732 printf("invalid port_id %d\n", res->port_id);
14735 printf("function not implemented\n");
14738 printf("programming error: (%s)\n", strerror(-ret));
14742 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14743 .f = cmd_vf_tc_max_bw_parsed,
14745 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14748 (void *)&cmd_vf_tc_bw_set,
14749 (void *)&cmd_vf_tc_bw_vf,
14750 (void *)&cmd_vf_tc_bw_tc,
14751 (void *)&cmd_vf_tc_bw_tx,
14752 (void *)&cmd_vf_tc_bw_max_bw,
14753 (void *)&cmd_vf_tc_bw_port_id,
14754 (void *)&cmd_vf_tc_bw_vf_id,
14755 (void *)&cmd_vf_tc_bw_tc_no,
14756 (void *)&cmd_vf_tc_bw_bw,
14762 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14764 /* *** Set Port default Traffic Management Hierarchy *** */
14765 struct cmd_set_port_tm_hierarchy_default_result {
14766 cmdline_fixed_string_t set;
14767 cmdline_fixed_string_t port;
14768 cmdline_fixed_string_t tm;
14769 cmdline_fixed_string_t hierarchy;
14770 cmdline_fixed_string_t def;
14774 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14775 TOKEN_STRING_INITIALIZER(
14776 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14777 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14778 TOKEN_STRING_INITIALIZER(
14779 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14780 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14781 TOKEN_STRING_INITIALIZER(
14782 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14783 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14784 TOKEN_STRING_INITIALIZER(
14785 struct cmd_set_port_tm_hierarchy_default_result,
14786 hierarchy, "hierarchy");
14787 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14788 TOKEN_STRING_INITIALIZER(
14789 struct cmd_set_port_tm_hierarchy_default_result,
14791 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14792 TOKEN_NUM_INITIALIZER(
14793 struct cmd_set_port_tm_hierarchy_default_result,
14796 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14797 __attribute__((unused)) struct cmdline *cl,
14798 __attribute__((unused)) void *data)
14800 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14801 struct rte_port *p;
14802 portid_t port_id = res->port_id;
14804 if (port_id_is_invalid(port_id, ENABLED_WARN))
14807 p = &ports[port_id];
14810 if (p->softport.tm_flag == 0) {
14811 printf(" tm not enabled on port %u (error)\n", port_id);
14815 /* Forward mode: tm */
14816 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) {
14817 printf(" tm mode not enabled(error)\n");
14821 /* Set the default tm hierarchy */
14822 p->softport.tm.default_hierarchy_enable = 1;
14825 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14826 .f = cmd_set_port_tm_hierarchy_default_parsed,
14828 .help_str = "set port tm hierarchy default <port_id>",
14830 (void *)&cmd_set_port_tm_hierarchy_default_set,
14831 (void *)&cmd_set_port_tm_hierarchy_default_port,
14832 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14833 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14834 (void *)&cmd_set_port_tm_hierarchy_default_default,
14835 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14841 /* Strict link priority scheduling mode setting */
14843 cmd_strict_link_prio_parsed(
14844 void *parsed_result,
14845 __attribute__((unused)) struct cmdline *cl,
14846 __attribute__((unused)) void *data)
14848 struct cmd_vf_tc_bw_result *res = parsed_result;
14849 int ret = -ENOTSUP;
14851 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14854 #ifdef RTE_LIBRTE_I40E_PMD
14855 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
14862 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
14865 printf("invalid port_id %d\n", res->port_id);
14868 printf("function not implemented\n");
14871 printf("programming error: (%s)\n", strerror(-ret));
14875 cmdline_parse_inst_t cmd_strict_link_prio = {
14876 .f = cmd_strict_link_prio_parsed,
14878 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
14880 (void *)&cmd_vf_tc_bw_set,
14881 (void *)&cmd_vf_tc_bw_tx,
14882 (void *)&cmd_vf_tc_bw_strict_link_prio,
14883 (void *)&cmd_vf_tc_bw_port_id,
14884 (void *)&cmd_vf_tc_bw_tc_map,
14889 /* Load dynamic device personalization*/
14890 struct cmd_ddp_add_result {
14891 cmdline_fixed_string_t ddp;
14892 cmdline_fixed_string_t add;
14897 cmdline_parse_token_string_t cmd_ddp_add_ddp =
14898 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
14899 cmdline_parse_token_string_t cmd_ddp_add_add =
14900 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
14901 cmdline_parse_token_num_t cmd_ddp_add_port_id =
14902 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
14903 cmdline_parse_token_string_t cmd_ddp_add_filepath =
14904 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
14907 cmd_ddp_add_parsed(
14908 void *parsed_result,
14909 __attribute__((unused)) struct cmdline *cl,
14910 __attribute__((unused)) void *data)
14912 struct cmd_ddp_add_result *res = parsed_result;
14918 int ret = -ENOTSUP;
14920 if (!all_ports_stopped()) {
14921 printf("Please stop all ports first\n");
14925 filepath = strdup(res->filepath);
14926 if (filepath == NULL) {
14927 printf("Failed to allocate memory\n");
14930 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
14932 buff = open_file(file_fld[0], &size);
14934 free((void *)filepath);
14938 #ifdef RTE_LIBRTE_I40E_PMD
14939 if (ret == -ENOTSUP)
14940 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
14942 RTE_PMD_I40E_PKG_OP_WR_ADD);
14945 if (ret == -EEXIST)
14946 printf("Profile has already existed.\n");
14948 printf("Failed to load profile.\n");
14949 else if (file_num == 2)
14950 save_file(file_fld[1], buff, size);
14953 free((void *)filepath);
14956 cmdline_parse_inst_t cmd_ddp_add = {
14957 .f = cmd_ddp_add_parsed,
14959 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
14961 (void *)&cmd_ddp_add_ddp,
14962 (void *)&cmd_ddp_add_add,
14963 (void *)&cmd_ddp_add_port_id,
14964 (void *)&cmd_ddp_add_filepath,
14969 /* Delete dynamic device personalization*/
14970 struct cmd_ddp_del_result {
14971 cmdline_fixed_string_t ddp;
14972 cmdline_fixed_string_t del;
14977 cmdline_parse_token_string_t cmd_ddp_del_ddp =
14978 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
14979 cmdline_parse_token_string_t cmd_ddp_del_del =
14980 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
14981 cmdline_parse_token_num_t cmd_ddp_del_port_id =
14982 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
14983 cmdline_parse_token_string_t cmd_ddp_del_filepath =
14984 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
14987 cmd_ddp_del_parsed(
14988 void *parsed_result,
14989 __attribute__((unused)) struct cmdline *cl,
14990 __attribute__((unused)) void *data)
14992 struct cmd_ddp_del_result *res = parsed_result;
14995 int ret = -ENOTSUP;
14997 if (!all_ports_stopped()) {
14998 printf("Please stop all ports first\n");
15002 buff = open_file(res->filepath, &size);
15006 #ifdef RTE_LIBRTE_I40E_PMD
15007 if (ret == -ENOTSUP)
15008 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15010 RTE_PMD_I40E_PKG_OP_WR_DEL);
15013 if (ret == -EACCES)
15014 printf("Profile does not exist.\n");
15016 printf("Failed to delete profile.\n");
15021 cmdline_parse_inst_t cmd_ddp_del = {
15022 .f = cmd_ddp_del_parsed,
15024 .help_str = "ddp del <port_id> <backup_profile_path>",
15026 (void *)&cmd_ddp_del_ddp,
15027 (void *)&cmd_ddp_del_del,
15028 (void *)&cmd_ddp_del_port_id,
15029 (void *)&cmd_ddp_del_filepath,
15034 /* Get dynamic device personalization profile info */
15035 struct cmd_ddp_info_result {
15036 cmdline_fixed_string_t ddp;
15037 cmdline_fixed_string_t get;
15038 cmdline_fixed_string_t info;
15042 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15043 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15044 cmdline_parse_token_string_t cmd_ddp_info_get =
15045 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15046 cmdline_parse_token_string_t cmd_ddp_info_info =
15047 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15048 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15049 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15052 cmd_ddp_info_parsed(
15053 void *parsed_result,
15054 __attribute__((unused)) struct cmdline *cl,
15055 __attribute__((unused)) void *data)
15057 struct cmd_ddp_info_result *res = parsed_result;
15060 int ret = -ENOTSUP;
15061 #ifdef RTE_LIBRTE_I40E_PMD
15064 uint32_t buff_size = 0;
15065 struct rte_pmd_i40e_profile_info info;
15066 uint32_t dev_num = 0;
15067 struct rte_pmd_i40e_ddp_device_id *devs;
15068 uint32_t proto_num = 0;
15069 struct rte_pmd_i40e_proto_info *proto = NULL;
15070 uint32_t pctype_num = 0;
15071 struct rte_pmd_i40e_ptype_info *pctype;
15072 uint32_t ptype_num = 0;
15073 struct rte_pmd_i40e_ptype_info *ptype;
15078 pkg = open_file(res->filepath, &pkg_size);
15082 #ifdef RTE_LIBRTE_I40E_PMD
15083 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15084 (uint8_t *)&info, sizeof(info),
15085 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15087 printf("Global Track id: 0x%x\n", info.track_id);
15088 printf("Global Version: %d.%d.%d.%d\n",
15089 info.version.major,
15090 info.version.minor,
15091 info.version.update,
15092 info.version.draft);
15093 printf("Global Package name: %s\n\n", info.name);
15096 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15097 (uint8_t *)&info, sizeof(info),
15098 RTE_PMD_I40E_PKG_INFO_HEADER);
15100 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15101 printf("i40e Profile Version: %d.%d.%d.%d\n",
15102 info.version.major,
15103 info.version.minor,
15104 info.version.update,
15105 info.version.draft);
15106 printf("i40e Profile name: %s\n\n", info.name);
15109 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15110 (uint8_t *)&buff_size, sizeof(buff_size),
15111 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15112 if (!ret && buff_size) {
15113 buff = (uint8_t *)malloc(buff_size);
15115 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15117 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15119 printf("Package Notes:\n%s\n\n", buff);
15124 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15125 (uint8_t *)&dev_num, sizeof(dev_num),
15126 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15127 if (!ret && dev_num) {
15128 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15129 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15131 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15132 (uint8_t *)devs, buff_size,
15133 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15135 printf("List of supported devices:\n");
15136 for (i = 0; i < dev_num; i++) {
15137 printf(" %04X:%04X %04X:%04X\n",
15138 devs[i].vendor_dev_id >> 16,
15139 devs[i].vendor_dev_id & 0xFFFF,
15140 devs[i].sub_vendor_dev_id >> 16,
15141 devs[i].sub_vendor_dev_id & 0xFFFF);
15149 /* get information about protocols and packet types */
15150 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15151 (uint8_t *)&proto_num, sizeof(proto_num),
15152 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15153 if (ret || !proto_num)
15154 goto no_print_return;
15156 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15157 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15159 goto no_print_return;
15161 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15163 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15165 printf("List of used protocols:\n");
15166 for (i = 0; i < proto_num; i++)
15167 printf(" %2u: %s\n", proto[i].proto_id,
15171 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15172 (uint8_t *)&pctype_num, sizeof(pctype_num),
15173 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15174 if (ret || !pctype_num)
15175 goto no_print_pctypes;
15177 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15178 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15180 goto no_print_pctypes;
15182 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15184 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15187 goto no_print_pctypes;
15190 printf("List of defined packet classification types:\n");
15191 for (i = 0; i < pctype_num; i++) {
15192 printf(" %2u:", pctype[i].ptype_id);
15193 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15194 proto_id = pctype[i].protocols[j];
15195 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15196 for (n = 0; n < proto_num; n++) {
15197 if (proto[n].proto_id == proto_id) {
15198 printf(" %s", proto[n].name);
15211 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15213 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15214 if (ret || !ptype_num)
15215 goto no_print_return;
15217 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15218 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15220 goto no_print_return;
15222 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15224 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15227 goto no_print_return;
15229 printf("List of defined packet types:\n");
15230 for (i = 0; i < ptype_num; i++) {
15231 printf(" %2u:", ptype[i].ptype_id);
15232 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15233 proto_id = ptype[i].protocols[j];
15234 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15235 for (n = 0; n < proto_num; n++) {
15236 if (proto[n].proto_id == proto_id) {
15237 printf(" %s", proto[n].name);
15253 if (ret == -ENOTSUP)
15254 printf("Function not supported in PMD driver\n");
15258 cmdline_parse_inst_t cmd_ddp_get_info = {
15259 .f = cmd_ddp_info_parsed,
15261 .help_str = "ddp get info <profile_path>",
15263 (void *)&cmd_ddp_info_ddp,
15264 (void *)&cmd_ddp_info_get,
15265 (void *)&cmd_ddp_info_info,
15266 (void *)&cmd_ddp_info_filepath,
15271 /* Get dynamic device personalization profile info list*/
15272 #define PROFILE_INFO_SIZE 48
15273 #define MAX_PROFILE_NUM 16
15275 struct cmd_ddp_get_list_result {
15276 cmdline_fixed_string_t ddp;
15277 cmdline_fixed_string_t get;
15278 cmdline_fixed_string_t list;
15282 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15283 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15284 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15285 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15286 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15287 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15288 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15289 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15292 cmd_ddp_get_list_parsed(
15293 __attribute__((unused)) void *parsed_result,
15294 __attribute__((unused)) struct cmdline *cl,
15295 __attribute__((unused)) void *data)
15297 #ifdef RTE_LIBRTE_I40E_PMD
15298 struct cmd_ddp_get_list_result *res = parsed_result;
15299 struct rte_pmd_i40e_profile_list *p_list;
15300 struct rte_pmd_i40e_profile_info *p_info;
15305 int ret = -ENOTSUP;
15307 #ifdef RTE_LIBRTE_I40E_PMD
15308 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15309 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15311 printf("%s: Failed to malloc buffer\n", __func__);
15313 if (ret == -ENOTSUP)
15314 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15315 (uint8_t *)p_list, size);
15318 p_num = p_list->p_count;
15319 printf("Profile number is: %d\n\n", p_num);
15321 for (i = 0; i < p_num; i++) {
15322 p_info = &p_list->p_info[i];
15323 printf("Profile %d:\n", i);
15324 printf("Track id: 0x%x\n", p_info->track_id);
15325 printf("Version: %d.%d.%d.%d\n",
15326 p_info->version.major,
15327 p_info->version.minor,
15328 p_info->version.update,
15329 p_info->version.draft);
15330 printf("Profile name: %s\n\n", p_info->name);
15338 printf("Failed to get ddp list\n");
15341 cmdline_parse_inst_t cmd_ddp_get_list = {
15342 .f = cmd_ddp_get_list_parsed,
15344 .help_str = "ddp get list <port_id>",
15346 (void *)&cmd_ddp_get_list_ddp,
15347 (void *)&cmd_ddp_get_list_get,
15348 (void *)&cmd_ddp_get_list_list,
15349 (void *)&cmd_ddp_get_list_port_id,
15354 /* Configure input set */
15355 struct cmd_cfg_input_set_result {
15356 cmdline_fixed_string_t port;
15357 cmdline_fixed_string_t cfg;
15359 cmdline_fixed_string_t pctype;
15361 cmdline_fixed_string_t inset_type;
15362 cmdline_fixed_string_t opt;
15363 cmdline_fixed_string_t field;
15368 cmd_cfg_input_set_parsed(
15369 __attribute__((unused)) void *parsed_result,
15370 __attribute__((unused)) struct cmdline *cl,
15371 __attribute__((unused)) void *data)
15373 #ifdef RTE_LIBRTE_I40E_PMD
15374 struct cmd_cfg_input_set_result *res = parsed_result;
15375 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15376 struct rte_pmd_i40e_inset inset;
15378 int ret = -ENOTSUP;
15380 if (!all_ports_stopped()) {
15381 printf("Please stop all ports first\n");
15385 #ifdef RTE_LIBRTE_I40E_PMD
15386 if (!strcmp(res->inset_type, "hash_inset"))
15387 inset_type = INSET_HASH;
15388 else if (!strcmp(res->inset_type, "fdir_inset"))
15389 inset_type = INSET_FDIR;
15390 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15391 inset_type = INSET_FDIR_FLX;
15392 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15393 &inset, inset_type);
15395 printf("Failed to get input set.\n");
15399 if (!strcmp(res->opt, "get")) {
15400 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15403 printf("Field index %d is enabled.\n", res->field_idx);
15405 printf("Field index %d is disabled.\n", res->field_idx);
15407 } else if (!strcmp(res->opt, "set"))
15408 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15410 else if (!strcmp(res->opt, "clear"))
15411 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15414 printf("Failed to configure input set field.\n");
15418 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15419 &inset, inset_type);
15421 printf("Failed to set input set.\n");
15426 if (ret == -ENOTSUP)
15427 printf("Function not supported\n");
15430 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15431 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15433 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15434 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15436 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15437 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15439 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15440 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15442 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15443 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15445 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15446 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15448 "hash_inset#fdir_inset#fdir_flx_inset");
15449 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15450 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15451 opt, "get#set#clear");
15452 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15453 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15455 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15456 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15459 cmdline_parse_inst_t cmd_cfg_input_set = {
15460 .f = cmd_cfg_input_set_parsed,
15462 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15463 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15465 (void *)&cmd_cfg_input_set_port,
15466 (void *)&cmd_cfg_input_set_cfg,
15467 (void *)&cmd_cfg_input_set_port_id,
15468 (void *)&cmd_cfg_input_set_pctype,
15469 (void *)&cmd_cfg_input_set_pctype_id,
15470 (void *)&cmd_cfg_input_set_inset_type,
15471 (void *)&cmd_cfg_input_set_opt,
15472 (void *)&cmd_cfg_input_set_field,
15473 (void *)&cmd_cfg_input_set_field_idx,
15478 /* Clear input set */
15479 struct cmd_clear_input_set_result {
15480 cmdline_fixed_string_t port;
15481 cmdline_fixed_string_t cfg;
15483 cmdline_fixed_string_t pctype;
15485 cmdline_fixed_string_t inset_type;
15486 cmdline_fixed_string_t clear;
15487 cmdline_fixed_string_t all;
15491 cmd_clear_input_set_parsed(
15492 __attribute__((unused)) void *parsed_result,
15493 __attribute__((unused)) struct cmdline *cl,
15494 __attribute__((unused)) void *data)
15496 #ifdef RTE_LIBRTE_I40E_PMD
15497 struct cmd_clear_input_set_result *res = parsed_result;
15498 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15499 struct rte_pmd_i40e_inset inset;
15501 int ret = -ENOTSUP;
15503 if (!all_ports_stopped()) {
15504 printf("Please stop all ports first\n");
15508 #ifdef RTE_LIBRTE_I40E_PMD
15509 if (!strcmp(res->inset_type, "hash_inset"))
15510 inset_type = INSET_HASH;
15511 else if (!strcmp(res->inset_type, "fdir_inset"))
15512 inset_type = INSET_FDIR;
15513 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15514 inset_type = INSET_FDIR_FLX;
15516 memset(&inset, 0, sizeof(inset));
15518 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15519 &inset, inset_type);
15521 printf("Failed to clear input set.\n");
15527 if (ret == -ENOTSUP)
15528 printf("Function not supported\n");
15531 cmdline_parse_token_string_t cmd_clear_input_set_port =
15532 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15534 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15535 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15537 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15538 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15540 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15541 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15543 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15544 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15546 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15547 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15549 "hash_inset#fdir_inset#fdir_flx_inset");
15550 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15551 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15553 cmdline_parse_token_string_t cmd_clear_input_set_all =
15554 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15557 cmdline_parse_inst_t cmd_clear_input_set = {
15558 .f = cmd_clear_input_set_parsed,
15560 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15561 "fdir_inset|fdir_flx_inset clear all",
15563 (void *)&cmd_clear_input_set_port,
15564 (void *)&cmd_clear_input_set_cfg,
15565 (void *)&cmd_clear_input_set_port_id,
15566 (void *)&cmd_clear_input_set_pctype,
15567 (void *)&cmd_clear_input_set_pctype_id,
15568 (void *)&cmd_clear_input_set_inset_type,
15569 (void *)&cmd_clear_input_set_clear,
15570 (void *)&cmd_clear_input_set_all,
15575 /* show vf stats */
15577 /* Common result structure for show vf stats */
15578 struct cmd_show_vf_stats_result {
15579 cmdline_fixed_string_t show;
15580 cmdline_fixed_string_t vf;
15581 cmdline_fixed_string_t stats;
15586 /* Common CLI fields show vf stats*/
15587 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15588 TOKEN_STRING_INITIALIZER
15589 (struct cmd_show_vf_stats_result,
15591 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15592 TOKEN_STRING_INITIALIZER
15593 (struct cmd_show_vf_stats_result,
15595 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15596 TOKEN_STRING_INITIALIZER
15597 (struct cmd_show_vf_stats_result,
15599 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15600 TOKEN_NUM_INITIALIZER
15601 (struct cmd_show_vf_stats_result,
15603 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15604 TOKEN_NUM_INITIALIZER
15605 (struct cmd_show_vf_stats_result,
15609 cmd_show_vf_stats_parsed(
15610 void *parsed_result,
15611 __attribute__((unused)) struct cmdline *cl,
15612 __attribute__((unused)) void *data)
15614 struct cmd_show_vf_stats_result *res = parsed_result;
15615 struct rte_eth_stats stats;
15616 int ret = -ENOTSUP;
15617 static const char *nic_stats_border = "########################";
15619 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15622 memset(&stats, 0, sizeof(stats));
15624 #ifdef RTE_LIBRTE_I40E_PMD
15625 if (ret == -ENOTSUP)
15626 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15630 #ifdef RTE_LIBRTE_BNXT_PMD
15631 if (ret == -ENOTSUP)
15632 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15641 printf("invalid vf_id %d\n", res->vf_id);
15644 printf("invalid port_id %d\n", res->port_id);
15647 printf("function not implemented\n");
15650 printf("programming error: (%s)\n", strerror(-ret));
15653 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
15654 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
15656 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
15658 stats.ipackets, stats.imissed, stats.ibytes);
15659 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
15660 printf(" RX-nombuf: %-10"PRIu64"\n",
15662 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
15664 stats.opackets, stats.oerrors, stats.obytes);
15666 printf(" %s############################%s\n",
15667 nic_stats_border, nic_stats_border);
15670 cmdline_parse_inst_t cmd_show_vf_stats = {
15671 .f = cmd_show_vf_stats_parsed,
15673 .help_str = "show vf stats <port_id> <vf_id>",
15675 (void *)&cmd_show_vf_stats_show,
15676 (void *)&cmd_show_vf_stats_vf,
15677 (void *)&cmd_show_vf_stats_stats,
15678 (void *)&cmd_show_vf_stats_port_id,
15679 (void *)&cmd_show_vf_stats_vf_id,
15684 /* clear vf stats */
15686 /* Common result structure for clear vf stats */
15687 struct cmd_clear_vf_stats_result {
15688 cmdline_fixed_string_t clear;
15689 cmdline_fixed_string_t vf;
15690 cmdline_fixed_string_t stats;
15695 /* Common CLI fields clear vf stats*/
15696 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
15697 TOKEN_STRING_INITIALIZER
15698 (struct cmd_clear_vf_stats_result,
15700 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
15701 TOKEN_STRING_INITIALIZER
15702 (struct cmd_clear_vf_stats_result,
15704 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
15705 TOKEN_STRING_INITIALIZER
15706 (struct cmd_clear_vf_stats_result,
15708 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
15709 TOKEN_NUM_INITIALIZER
15710 (struct cmd_clear_vf_stats_result,
15712 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
15713 TOKEN_NUM_INITIALIZER
15714 (struct cmd_clear_vf_stats_result,
15718 cmd_clear_vf_stats_parsed(
15719 void *parsed_result,
15720 __attribute__((unused)) struct cmdline *cl,
15721 __attribute__((unused)) void *data)
15723 struct cmd_clear_vf_stats_result *res = parsed_result;
15724 int ret = -ENOTSUP;
15726 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15729 #ifdef RTE_LIBRTE_I40E_PMD
15730 if (ret == -ENOTSUP)
15731 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
15734 #ifdef RTE_LIBRTE_BNXT_PMD
15735 if (ret == -ENOTSUP)
15736 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
15744 printf("invalid vf_id %d\n", res->vf_id);
15747 printf("invalid port_id %d\n", res->port_id);
15750 printf("function not implemented\n");
15753 printf("programming error: (%s)\n", strerror(-ret));
15757 cmdline_parse_inst_t cmd_clear_vf_stats = {
15758 .f = cmd_clear_vf_stats_parsed,
15760 .help_str = "clear vf stats <port_id> <vf_id>",
15762 (void *)&cmd_clear_vf_stats_clear,
15763 (void *)&cmd_clear_vf_stats_vf,
15764 (void *)&cmd_clear_vf_stats_stats,
15765 (void *)&cmd_clear_vf_stats_port_id,
15766 (void *)&cmd_clear_vf_stats_vf_id,
15771 /* port config pctype mapping reset */
15773 /* Common result structure for port config pctype mapping reset */
15774 struct cmd_pctype_mapping_reset_result {
15775 cmdline_fixed_string_t port;
15776 cmdline_fixed_string_t config;
15778 cmdline_fixed_string_t pctype;
15779 cmdline_fixed_string_t mapping;
15780 cmdline_fixed_string_t reset;
15783 /* Common CLI fields for port config pctype mapping reset*/
15784 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
15785 TOKEN_STRING_INITIALIZER
15786 (struct cmd_pctype_mapping_reset_result,
15788 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
15789 TOKEN_STRING_INITIALIZER
15790 (struct cmd_pctype_mapping_reset_result,
15792 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
15793 TOKEN_NUM_INITIALIZER
15794 (struct cmd_pctype_mapping_reset_result,
15796 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
15797 TOKEN_STRING_INITIALIZER
15798 (struct cmd_pctype_mapping_reset_result,
15800 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
15801 TOKEN_STRING_INITIALIZER
15802 (struct cmd_pctype_mapping_reset_result,
15803 mapping, "mapping");
15804 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
15805 TOKEN_STRING_INITIALIZER
15806 (struct cmd_pctype_mapping_reset_result,
15810 cmd_pctype_mapping_reset_parsed(
15811 void *parsed_result,
15812 __attribute__((unused)) struct cmdline *cl,
15813 __attribute__((unused)) void *data)
15815 struct cmd_pctype_mapping_reset_result *res = parsed_result;
15816 int ret = -ENOTSUP;
15818 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15821 #ifdef RTE_LIBRTE_I40E_PMD
15822 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
15829 printf("invalid port_id %d\n", res->port_id);
15832 printf("function not implemented\n");
15835 printf("programming error: (%s)\n", strerror(-ret));
15839 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
15840 .f = cmd_pctype_mapping_reset_parsed,
15842 .help_str = "port config <port_id> pctype mapping reset",
15844 (void *)&cmd_pctype_mapping_reset_port,
15845 (void *)&cmd_pctype_mapping_reset_config,
15846 (void *)&cmd_pctype_mapping_reset_port_id,
15847 (void *)&cmd_pctype_mapping_reset_pctype,
15848 (void *)&cmd_pctype_mapping_reset_mapping,
15849 (void *)&cmd_pctype_mapping_reset_reset,
15854 /* show port pctype mapping */
15856 /* Common result structure for show port pctype mapping */
15857 struct cmd_pctype_mapping_get_result {
15858 cmdline_fixed_string_t show;
15859 cmdline_fixed_string_t port;
15861 cmdline_fixed_string_t pctype;
15862 cmdline_fixed_string_t mapping;
15865 /* Common CLI fields for pctype mapping get */
15866 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
15867 TOKEN_STRING_INITIALIZER
15868 (struct cmd_pctype_mapping_get_result,
15870 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
15871 TOKEN_STRING_INITIALIZER
15872 (struct cmd_pctype_mapping_get_result,
15874 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
15875 TOKEN_NUM_INITIALIZER
15876 (struct cmd_pctype_mapping_get_result,
15878 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
15879 TOKEN_STRING_INITIALIZER
15880 (struct cmd_pctype_mapping_get_result,
15882 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
15883 TOKEN_STRING_INITIALIZER
15884 (struct cmd_pctype_mapping_get_result,
15885 mapping, "mapping");
15888 cmd_pctype_mapping_get_parsed(
15889 void *parsed_result,
15890 __attribute__((unused)) struct cmdline *cl,
15891 __attribute__((unused)) void *data)
15893 struct cmd_pctype_mapping_get_result *res = parsed_result;
15894 int ret = -ENOTSUP;
15895 #ifdef RTE_LIBRTE_I40E_PMD
15896 struct rte_pmd_i40e_flow_type_mapping
15897 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
15898 int i, j, first_pctype;
15901 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15904 #ifdef RTE_LIBRTE_I40E_PMD
15905 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
15912 printf("invalid port_id %d\n", res->port_id);
15915 printf("function not implemented\n");
15918 printf("programming error: (%s)\n", strerror(-ret));
15922 #ifdef RTE_LIBRTE_I40E_PMD
15923 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
15924 if (mapping[i].pctype != 0ULL) {
15927 printf("pctype: ");
15928 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
15929 if (mapping[i].pctype & (1ULL << j)) {
15930 printf(first_pctype ?
15931 "%02d" : ",%02d", j);
15935 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
15941 cmdline_parse_inst_t cmd_pctype_mapping_get = {
15942 .f = cmd_pctype_mapping_get_parsed,
15944 .help_str = "show port <port_id> pctype mapping",
15946 (void *)&cmd_pctype_mapping_get_show,
15947 (void *)&cmd_pctype_mapping_get_port,
15948 (void *)&cmd_pctype_mapping_get_port_id,
15949 (void *)&cmd_pctype_mapping_get_pctype,
15950 (void *)&cmd_pctype_mapping_get_mapping,
15955 /* port config pctype mapping update */
15957 /* Common result structure for port config pctype mapping update */
15958 struct cmd_pctype_mapping_update_result {
15959 cmdline_fixed_string_t port;
15960 cmdline_fixed_string_t config;
15962 cmdline_fixed_string_t pctype;
15963 cmdline_fixed_string_t mapping;
15964 cmdline_fixed_string_t update;
15965 cmdline_fixed_string_t pctype_list;
15966 uint16_t flow_type;
15969 /* Common CLI fields for pctype mapping update*/
15970 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
15971 TOKEN_STRING_INITIALIZER
15972 (struct cmd_pctype_mapping_update_result,
15974 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
15975 TOKEN_STRING_INITIALIZER
15976 (struct cmd_pctype_mapping_update_result,
15978 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
15979 TOKEN_NUM_INITIALIZER
15980 (struct cmd_pctype_mapping_update_result,
15982 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
15983 TOKEN_STRING_INITIALIZER
15984 (struct cmd_pctype_mapping_update_result,
15986 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
15987 TOKEN_STRING_INITIALIZER
15988 (struct cmd_pctype_mapping_update_result,
15989 mapping, "mapping");
15990 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
15991 TOKEN_STRING_INITIALIZER
15992 (struct cmd_pctype_mapping_update_result,
15994 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
15995 TOKEN_STRING_INITIALIZER
15996 (struct cmd_pctype_mapping_update_result,
15997 pctype_list, NULL);
15998 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
15999 TOKEN_NUM_INITIALIZER
16000 (struct cmd_pctype_mapping_update_result,
16001 flow_type, UINT16);
16004 cmd_pctype_mapping_update_parsed(
16005 void *parsed_result,
16006 __attribute__((unused)) struct cmdline *cl,
16007 __attribute__((unused)) void *data)
16009 struct cmd_pctype_mapping_update_result *res = parsed_result;
16010 int ret = -ENOTSUP;
16011 #ifdef RTE_LIBRTE_I40E_PMD
16012 struct rte_pmd_i40e_flow_type_mapping mapping;
16014 unsigned int nb_item;
16015 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16018 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16021 #ifdef RTE_LIBRTE_I40E_PMD
16022 nb_item = parse_item_list(res->pctype_list, "pctypes",
16023 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16024 mapping.flow_type = res->flow_type;
16025 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16026 mapping.pctype |= (1ULL << pctype_list[i]);
16027 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16037 printf("invalid pctype or flow type\n");
16040 printf("invalid port_id %d\n", res->port_id);
16043 printf("function not implemented\n");
16046 printf("programming error: (%s)\n", strerror(-ret));
16050 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16051 .f = cmd_pctype_mapping_update_parsed,
16053 .help_str = "port config <port_id> pctype mapping update"
16054 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16056 (void *)&cmd_pctype_mapping_update_port,
16057 (void *)&cmd_pctype_mapping_update_config,
16058 (void *)&cmd_pctype_mapping_update_port_id,
16059 (void *)&cmd_pctype_mapping_update_pctype,
16060 (void *)&cmd_pctype_mapping_update_mapping,
16061 (void *)&cmd_pctype_mapping_update_update,
16062 (void *)&cmd_pctype_mapping_update_pc_type,
16063 (void *)&cmd_pctype_mapping_update_flow_type,
16068 /* ptype mapping get */
16070 /* Common result structure for ptype mapping get */
16071 struct cmd_ptype_mapping_get_result {
16072 cmdline_fixed_string_t ptype;
16073 cmdline_fixed_string_t mapping;
16074 cmdline_fixed_string_t get;
16076 uint8_t valid_only;
16079 /* Common CLI fields for ptype mapping get */
16080 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16081 TOKEN_STRING_INITIALIZER
16082 (struct cmd_ptype_mapping_get_result,
16084 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16085 TOKEN_STRING_INITIALIZER
16086 (struct cmd_ptype_mapping_get_result,
16087 mapping, "mapping");
16088 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16089 TOKEN_STRING_INITIALIZER
16090 (struct cmd_ptype_mapping_get_result,
16092 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16093 TOKEN_NUM_INITIALIZER
16094 (struct cmd_ptype_mapping_get_result,
16096 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16097 TOKEN_NUM_INITIALIZER
16098 (struct cmd_ptype_mapping_get_result,
16099 valid_only, UINT8);
16102 cmd_ptype_mapping_get_parsed(
16103 void *parsed_result,
16104 __attribute__((unused)) struct cmdline *cl,
16105 __attribute__((unused)) void *data)
16107 struct cmd_ptype_mapping_get_result *res = parsed_result;
16108 int ret = -ENOTSUP;
16109 #ifdef RTE_LIBRTE_I40E_PMD
16110 int max_ptype_num = 256;
16111 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16116 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16119 #ifdef RTE_LIBRTE_I40E_PMD
16120 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16131 printf("invalid port_id %d\n", res->port_id);
16134 printf("function not implemented\n");
16137 printf("programming error: (%s)\n", strerror(-ret));
16140 #ifdef RTE_LIBRTE_I40E_PMD
16142 for (i = 0; i < count; i++)
16143 printf("%3d\t0x%08x\n",
16144 mapping[i].hw_ptype, mapping[i].sw_ptype);
16149 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16150 .f = cmd_ptype_mapping_get_parsed,
16152 .help_str = "ptype mapping get <port_id> <valid_only>",
16154 (void *)&cmd_ptype_mapping_get_ptype,
16155 (void *)&cmd_ptype_mapping_get_mapping,
16156 (void *)&cmd_ptype_mapping_get_get,
16157 (void *)&cmd_ptype_mapping_get_port_id,
16158 (void *)&cmd_ptype_mapping_get_valid_only,
16163 /* ptype mapping replace */
16165 /* Common result structure for ptype mapping replace */
16166 struct cmd_ptype_mapping_replace_result {
16167 cmdline_fixed_string_t ptype;
16168 cmdline_fixed_string_t mapping;
16169 cmdline_fixed_string_t replace;
16176 /* Common CLI fields for ptype mapping replace */
16177 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16178 TOKEN_STRING_INITIALIZER
16179 (struct cmd_ptype_mapping_replace_result,
16181 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16182 TOKEN_STRING_INITIALIZER
16183 (struct cmd_ptype_mapping_replace_result,
16184 mapping, "mapping");
16185 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16186 TOKEN_STRING_INITIALIZER
16187 (struct cmd_ptype_mapping_replace_result,
16188 replace, "replace");
16189 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16190 TOKEN_NUM_INITIALIZER
16191 (struct cmd_ptype_mapping_replace_result,
16193 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16194 TOKEN_NUM_INITIALIZER
16195 (struct cmd_ptype_mapping_replace_result,
16197 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16198 TOKEN_NUM_INITIALIZER
16199 (struct cmd_ptype_mapping_replace_result,
16201 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16202 TOKEN_NUM_INITIALIZER
16203 (struct cmd_ptype_mapping_replace_result,
16207 cmd_ptype_mapping_replace_parsed(
16208 void *parsed_result,
16209 __attribute__((unused)) struct cmdline *cl,
16210 __attribute__((unused)) void *data)
16212 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16213 int ret = -ENOTSUP;
16215 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16218 #ifdef RTE_LIBRTE_I40E_PMD
16219 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16229 printf("invalid ptype 0x%8x or 0x%8x\n",
16230 res->target, res->pkt_type);
16233 printf("invalid port_id %d\n", res->port_id);
16236 printf("function not implemented\n");
16239 printf("programming error: (%s)\n", strerror(-ret));
16243 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16244 .f = cmd_ptype_mapping_replace_parsed,
16247 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16249 (void *)&cmd_ptype_mapping_replace_ptype,
16250 (void *)&cmd_ptype_mapping_replace_mapping,
16251 (void *)&cmd_ptype_mapping_replace_replace,
16252 (void *)&cmd_ptype_mapping_replace_port_id,
16253 (void *)&cmd_ptype_mapping_replace_target,
16254 (void *)&cmd_ptype_mapping_replace_mask,
16255 (void *)&cmd_ptype_mapping_replace_pkt_type,
16260 /* ptype mapping reset */
16262 /* Common result structure for ptype mapping reset */
16263 struct cmd_ptype_mapping_reset_result {
16264 cmdline_fixed_string_t ptype;
16265 cmdline_fixed_string_t mapping;
16266 cmdline_fixed_string_t reset;
16270 /* Common CLI fields for ptype mapping reset*/
16271 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16272 TOKEN_STRING_INITIALIZER
16273 (struct cmd_ptype_mapping_reset_result,
16275 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16276 TOKEN_STRING_INITIALIZER
16277 (struct cmd_ptype_mapping_reset_result,
16278 mapping, "mapping");
16279 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16280 TOKEN_STRING_INITIALIZER
16281 (struct cmd_ptype_mapping_reset_result,
16283 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16284 TOKEN_NUM_INITIALIZER
16285 (struct cmd_ptype_mapping_reset_result,
16289 cmd_ptype_mapping_reset_parsed(
16290 void *parsed_result,
16291 __attribute__((unused)) struct cmdline *cl,
16292 __attribute__((unused)) void *data)
16294 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16295 int ret = -ENOTSUP;
16297 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16300 #ifdef RTE_LIBRTE_I40E_PMD
16301 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16308 printf("invalid port_id %d\n", res->port_id);
16311 printf("function not implemented\n");
16314 printf("programming error: (%s)\n", strerror(-ret));
16318 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16319 .f = cmd_ptype_mapping_reset_parsed,
16321 .help_str = "ptype mapping reset <port_id>",
16323 (void *)&cmd_ptype_mapping_reset_ptype,
16324 (void *)&cmd_ptype_mapping_reset_mapping,
16325 (void *)&cmd_ptype_mapping_reset_reset,
16326 (void *)&cmd_ptype_mapping_reset_port_id,
16331 /* ptype mapping update */
16333 /* Common result structure for ptype mapping update */
16334 struct cmd_ptype_mapping_update_result {
16335 cmdline_fixed_string_t ptype;
16336 cmdline_fixed_string_t mapping;
16337 cmdline_fixed_string_t reset;
16343 /* Common CLI fields for ptype mapping update*/
16344 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16345 TOKEN_STRING_INITIALIZER
16346 (struct cmd_ptype_mapping_update_result,
16348 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16349 TOKEN_STRING_INITIALIZER
16350 (struct cmd_ptype_mapping_update_result,
16351 mapping, "mapping");
16352 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16353 TOKEN_STRING_INITIALIZER
16354 (struct cmd_ptype_mapping_update_result,
16356 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16357 TOKEN_NUM_INITIALIZER
16358 (struct cmd_ptype_mapping_update_result,
16360 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16361 TOKEN_NUM_INITIALIZER
16362 (struct cmd_ptype_mapping_update_result,
16364 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16365 TOKEN_NUM_INITIALIZER
16366 (struct cmd_ptype_mapping_update_result,
16370 cmd_ptype_mapping_update_parsed(
16371 void *parsed_result,
16372 __attribute__((unused)) struct cmdline *cl,
16373 __attribute__((unused)) void *data)
16375 struct cmd_ptype_mapping_update_result *res = parsed_result;
16376 int ret = -ENOTSUP;
16377 #ifdef RTE_LIBRTE_I40E_PMD
16378 struct rte_pmd_i40e_ptype_mapping mapping;
16380 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16383 #ifdef RTE_LIBRTE_I40E_PMD
16384 mapping.hw_ptype = res->hw_ptype;
16385 mapping.sw_ptype = res->sw_ptype;
16386 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16396 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16399 printf("invalid port_id %d\n", res->port_id);
16402 printf("function not implemented\n");
16405 printf("programming error: (%s)\n", strerror(-ret));
16409 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16410 .f = cmd_ptype_mapping_update_parsed,
16412 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16414 (void *)&cmd_ptype_mapping_update_ptype,
16415 (void *)&cmd_ptype_mapping_update_mapping,
16416 (void *)&cmd_ptype_mapping_update_update,
16417 (void *)&cmd_ptype_mapping_update_port_id,
16418 (void *)&cmd_ptype_mapping_update_hw_ptype,
16419 (void *)&cmd_ptype_mapping_update_sw_ptype,
16424 /* Common result structure for file commands */
16425 struct cmd_cmdfile_result {
16426 cmdline_fixed_string_t load;
16427 cmdline_fixed_string_t filename;
16430 /* Common CLI fields for file commands */
16431 cmdline_parse_token_string_t cmd_load_cmdfile =
16432 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16433 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16434 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16437 cmd_load_from_file_parsed(
16438 void *parsed_result,
16439 __attribute__((unused)) struct cmdline *cl,
16440 __attribute__((unused)) void *data)
16442 struct cmd_cmdfile_result *res = parsed_result;
16444 cmdline_read_from_file(res->filename);
16447 cmdline_parse_inst_t cmd_load_from_file = {
16448 .f = cmd_load_from_file_parsed,
16450 .help_str = "load <filename>",
16452 (void *)&cmd_load_cmdfile,
16453 (void *)&cmd_load_cmdfile_filename,
16458 /* Get Rx offloads capabilities */
16459 struct cmd_rx_offload_get_capa_result {
16460 cmdline_fixed_string_t show;
16461 cmdline_fixed_string_t port;
16463 cmdline_fixed_string_t rx_offload;
16464 cmdline_fixed_string_t capabilities;
16467 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16468 TOKEN_STRING_INITIALIZER
16469 (struct cmd_rx_offload_get_capa_result,
16471 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16472 TOKEN_STRING_INITIALIZER
16473 (struct cmd_rx_offload_get_capa_result,
16475 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16476 TOKEN_NUM_INITIALIZER
16477 (struct cmd_rx_offload_get_capa_result,
16479 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16480 TOKEN_STRING_INITIALIZER
16481 (struct cmd_rx_offload_get_capa_result,
16482 rx_offload, "rx_offload");
16483 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16484 TOKEN_STRING_INITIALIZER
16485 (struct cmd_rx_offload_get_capa_result,
16486 capabilities, "capabilities");
16489 print_rx_offloads(uint64_t offloads)
16491 uint64_t single_offload;
16499 begin = __builtin_ctzll(offloads);
16500 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16502 single_offload = 1 << begin;
16503 for (bit = begin; bit < end; bit++) {
16504 if (offloads & single_offload)
16506 rte_eth_dev_rx_offload_name(single_offload));
16507 single_offload <<= 1;
16512 cmd_rx_offload_get_capa_parsed(
16513 void *parsed_result,
16514 __attribute__((unused)) struct cmdline *cl,
16515 __attribute__((unused)) void *data)
16517 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16518 struct rte_eth_dev_info dev_info;
16519 portid_t port_id = res->port_id;
16520 uint64_t queue_offloads;
16521 uint64_t port_offloads;
16523 rte_eth_dev_info_get(port_id, &dev_info);
16524 queue_offloads = dev_info.rx_queue_offload_capa;
16525 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16527 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16528 printf(" Per Queue :");
16529 print_rx_offloads(queue_offloads);
16532 printf(" Per Port :");
16533 print_rx_offloads(port_offloads);
16537 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16538 .f = cmd_rx_offload_get_capa_parsed,
16540 .help_str = "show port <port_id> rx_offload capabilities",
16542 (void *)&cmd_rx_offload_get_capa_show,
16543 (void *)&cmd_rx_offload_get_capa_port,
16544 (void *)&cmd_rx_offload_get_capa_port_id,
16545 (void *)&cmd_rx_offload_get_capa_rx_offload,
16546 (void *)&cmd_rx_offload_get_capa_capabilities,
16551 /* Get Rx offloads configuration */
16552 struct cmd_rx_offload_get_configuration_result {
16553 cmdline_fixed_string_t show;
16554 cmdline_fixed_string_t port;
16556 cmdline_fixed_string_t rx_offload;
16557 cmdline_fixed_string_t configuration;
16560 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16561 TOKEN_STRING_INITIALIZER
16562 (struct cmd_rx_offload_get_configuration_result,
16564 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16565 TOKEN_STRING_INITIALIZER
16566 (struct cmd_rx_offload_get_configuration_result,
16568 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16569 TOKEN_NUM_INITIALIZER
16570 (struct cmd_rx_offload_get_configuration_result,
16572 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16573 TOKEN_STRING_INITIALIZER
16574 (struct cmd_rx_offload_get_configuration_result,
16575 rx_offload, "rx_offload");
16576 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16577 TOKEN_STRING_INITIALIZER
16578 (struct cmd_rx_offload_get_configuration_result,
16579 configuration, "configuration");
16582 cmd_rx_offload_get_configuration_parsed(
16583 void *parsed_result,
16584 __attribute__((unused)) struct cmdline *cl,
16585 __attribute__((unused)) void *data)
16587 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16588 struct rte_eth_dev_info dev_info;
16589 portid_t port_id = res->port_id;
16590 struct rte_port *port = &ports[port_id];
16591 uint64_t port_offloads;
16592 uint64_t queue_offloads;
16593 uint16_t nb_rx_queues;
16596 printf("Rx Offloading Configuration of port %d :\n", port_id);
16598 port_offloads = port->dev_conf.rxmode.offloads;
16600 print_rx_offloads(port_offloads);
16603 rte_eth_dev_info_get(port_id, &dev_info);
16604 nb_rx_queues = dev_info.nb_rx_queues;
16605 for (q = 0; q < nb_rx_queues; q++) {
16606 queue_offloads = port->rx_conf[q].offloads;
16607 printf(" Queue[%2d] :", q);
16608 print_rx_offloads(queue_offloads);
16614 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16615 .f = cmd_rx_offload_get_configuration_parsed,
16617 .help_str = "show port <port_id> rx_offload configuration",
16619 (void *)&cmd_rx_offload_get_configuration_show,
16620 (void *)&cmd_rx_offload_get_configuration_port,
16621 (void *)&cmd_rx_offload_get_configuration_port_id,
16622 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16623 (void *)&cmd_rx_offload_get_configuration_configuration,
16628 /* Enable/Disable a per port offloading */
16629 struct cmd_config_per_port_rx_offload_result {
16630 cmdline_fixed_string_t port;
16631 cmdline_fixed_string_t config;
16633 cmdline_fixed_string_t rx_offload;
16634 cmdline_fixed_string_t offload;
16635 cmdline_fixed_string_t on_off;
16638 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16639 TOKEN_STRING_INITIALIZER
16640 (struct cmd_config_per_port_rx_offload_result,
16642 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16643 TOKEN_STRING_INITIALIZER
16644 (struct cmd_config_per_port_rx_offload_result,
16646 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16647 TOKEN_NUM_INITIALIZER
16648 (struct cmd_config_per_port_rx_offload_result,
16650 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16651 TOKEN_STRING_INITIALIZER
16652 (struct cmd_config_per_port_rx_offload_result,
16653 rx_offload, "rx_offload");
16654 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
16655 TOKEN_STRING_INITIALIZER
16656 (struct cmd_config_per_port_rx_offload_result,
16657 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16658 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16659 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16660 "crc_strip#scatter#timestamp#security");
16661 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
16662 TOKEN_STRING_INITIALIZER
16663 (struct cmd_config_per_port_rx_offload_result,
16667 search_rx_offload(const char *name)
16669 uint64_t single_offload;
16670 const char *single_name;
16674 single_offload = 1;
16675 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
16676 single_name = rte_eth_dev_rx_offload_name(single_offload);
16677 if (!strcasecmp(single_name, name)) {
16680 } else if (!strcasecmp(single_name, "UNKNOWN"))
16682 else if (single_name == NULL)
16684 single_offload <<= 1;
16688 return single_offload;
16694 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
16695 __attribute__((unused)) struct cmdline *cl,
16696 __attribute__((unused)) void *data)
16698 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
16699 portid_t port_id = res->port_id;
16700 struct rte_eth_dev_info dev_info;
16701 struct rte_port *port = &ports[port_id];
16702 uint64_t single_offload;
16703 uint16_t nb_rx_queues;
16706 if (port->port_status != RTE_PORT_STOPPED) {
16707 printf("Error: Can't config offload when Port %d "
16708 "is not stopped\n", port_id);
16712 single_offload = search_rx_offload(res->offload);
16713 if (single_offload == 0) {
16714 printf("Unknown offload name: %s\n", res->offload);
16718 rte_eth_dev_info_get(port_id, &dev_info);
16719 nb_rx_queues = dev_info.nb_rx_queues;
16720 if (!strcmp(res->on_off, "on")) {
16721 port->dev_conf.rxmode.offloads |= single_offload;
16722 for (q = 0; q < nb_rx_queues; q++)
16723 port->rx_conf[q].offloads |= single_offload;
16725 port->dev_conf.rxmode.offloads &= ~single_offload;
16726 for (q = 0; q < nb_rx_queues; q++)
16727 port->rx_conf[q].offloads &= ~single_offload;
16730 cmd_reconfig_device_queue(port_id, 1, 1);
16733 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
16734 .f = cmd_config_per_port_rx_offload_parsed,
16736 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
16737 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16738 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16739 "jumbo_frame|crc_strip|scatter|timestamp|security "
16742 (void *)&cmd_config_per_port_rx_offload_result_port,
16743 (void *)&cmd_config_per_port_rx_offload_result_config,
16744 (void *)&cmd_config_per_port_rx_offload_result_port_id,
16745 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
16746 (void *)&cmd_config_per_port_rx_offload_result_offload,
16747 (void *)&cmd_config_per_port_rx_offload_result_on_off,
16752 /* Enable/Disable a per queue offloading */
16753 struct cmd_config_per_queue_rx_offload_result {
16754 cmdline_fixed_string_t port;
16756 cmdline_fixed_string_t rxq;
16758 cmdline_fixed_string_t rx_offload;
16759 cmdline_fixed_string_t offload;
16760 cmdline_fixed_string_t on_off;
16763 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
16764 TOKEN_STRING_INITIALIZER
16765 (struct cmd_config_per_queue_rx_offload_result,
16767 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
16768 TOKEN_NUM_INITIALIZER
16769 (struct cmd_config_per_queue_rx_offload_result,
16771 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
16772 TOKEN_STRING_INITIALIZER
16773 (struct cmd_config_per_queue_rx_offload_result,
16775 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
16776 TOKEN_NUM_INITIALIZER
16777 (struct cmd_config_per_queue_rx_offload_result,
16779 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
16780 TOKEN_STRING_INITIALIZER
16781 (struct cmd_config_per_queue_rx_offload_result,
16782 rx_offload, "rx_offload");
16783 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
16784 TOKEN_STRING_INITIALIZER
16785 (struct cmd_config_per_queue_rx_offload_result,
16786 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
16787 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
16788 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
16789 "crc_strip#scatter#timestamp#security");
16790 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
16791 TOKEN_STRING_INITIALIZER
16792 (struct cmd_config_per_queue_rx_offload_result,
16796 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
16797 __attribute__((unused)) struct cmdline *cl,
16798 __attribute__((unused)) void *data)
16800 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
16801 struct rte_eth_dev_info dev_info;
16802 portid_t port_id = res->port_id;
16803 uint16_t queue_id = res->queue_id;
16804 struct rte_port *port = &ports[port_id];
16805 uint64_t single_offload;
16807 if (port->port_status != RTE_PORT_STOPPED) {
16808 printf("Error: Can't config offload when Port %d "
16809 "is not stopped\n", port_id);
16813 rte_eth_dev_info_get(port_id, &dev_info);
16814 if (queue_id >= dev_info.nb_rx_queues) {
16815 printf("Error: input queue_id should be 0 ... "
16816 "%d\n", dev_info.nb_rx_queues - 1);
16820 single_offload = search_rx_offload(res->offload);
16821 if (single_offload == 0) {
16822 printf("Unknown offload name: %s\n", res->offload);
16826 if (!strcmp(res->on_off, "on"))
16827 port->rx_conf[queue_id].offloads |= single_offload;
16829 port->rx_conf[queue_id].offloads &= ~single_offload;
16831 cmd_reconfig_device_queue(port_id, 1, 1);
16834 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
16835 .f = cmd_config_per_queue_rx_offload_parsed,
16837 .help_str = "port <port_id> rxq <queue_id> rx_offload "
16838 "vlan_strip|ipv4_cksum|"
16839 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
16840 "macsec_strip|header_split|vlan_filter|vlan_extend|"
16841 "jumbo_frame|crc_strip|scatter|timestamp|security "
16844 (void *)&cmd_config_per_queue_rx_offload_result_port,
16845 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
16846 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
16847 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
16848 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
16849 (void *)&cmd_config_per_queue_rx_offload_result_offload,
16850 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
16855 /* Get Tx offloads capabilities */
16856 struct cmd_tx_offload_get_capa_result {
16857 cmdline_fixed_string_t show;
16858 cmdline_fixed_string_t port;
16860 cmdline_fixed_string_t tx_offload;
16861 cmdline_fixed_string_t capabilities;
16864 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
16865 TOKEN_STRING_INITIALIZER
16866 (struct cmd_tx_offload_get_capa_result,
16868 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
16869 TOKEN_STRING_INITIALIZER
16870 (struct cmd_tx_offload_get_capa_result,
16872 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
16873 TOKEN_NUM_INITIALIZER
16874 (struct cmd_tx_offload_get_capa_result,
16876 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
16877 TOKEN_STRING_INITIALIZER
16878 (struct cmd_tx_offload_get_capa_result,
16879 tx_offload, "tx_offload");
16880 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
16881 TOKEN_STRING_INITIALIZER
16882 (struct cmd_tx_offload_get_capa_result,
16883 capabilities, "capabilities");
16886 print_tx_offloads(uint64_t offloads)
16888 uint64_t single_offload;
16896 begin = __builtin_ctzll(offloads);
16897 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16899 single_offload = 1 << begin;
16900 for (bit = begin; bit < end; bit++) {
16901 if (offloads & single_offload)
16903 rte_eth_dev_tx_offload_name(single_offload));
16904 single_offload <<= 1;
16909 cmd_tx_offload_get_capa_parsed(
16910 void *parsed_result,
16911 __attribute__((unused)) struct cmdline *cl,
16912 __attribute__((unused)) void *data)
16914 struct cmd_tx_offload_get_capa_result *res = parsed_result;
16915 struct rte_eth_dev_info dev_info;
16916 portid_t port_id = res->port_id;
16917 uint64_t queue_offloads;
16918 uint64_t port_offloads;
16920 rte_eth_dev_info_get(port_id, &dev_info);
16921 queue_offloads = dev_info.tx_queue_offload_capa;
16922 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
16924 printf("Tx Offloading Capabilities of port %d :\n", port_id);
16925 printf(" Per Queue :");
16926 print_tx_offloads(queue_offloads);
16929 printf(" Per Port :");
16930 print_tx_offloads(port_offloads);
16934 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
16935 .f = cmd_tx_offload_get_capa_parsed,
16937 .help_str = "show port <port_id> tx_offload capabilities",
16939 (void *)&cmd_tx_offload_get_capa_show,
16940 (void *)&cmd_tx_offload_get_capa_port,
16941 (void *)&cmd_tx_offload_get_capa_port_id,
16942 (void *)&cmd_tx_offload_get_capa_tx_offload,
16943 (void *)&cmd_tx_offload_get_capa_capabilities,
16948 /* Get Tx offloads configuration */
16949 struct cmd_tx_offload_get_configuration_result {
16950 cmdline_fixed_string_t show;
16951 cmdline_fixed_string_t port;
16953 cmdline_fixed_string_t tx_offload;
16954 cmdline_fixed_string_t configuration;
16957 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
16958 TOKEN_STRING_INITIALIZER
16959 (struct cmd_tx_offload_get_configuration_result,
16961 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
16962 TOKEN_STRING_INITIALIZER
16963 (struct cmd_tx_offload_get_configuration_result,
16965 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
16966 TOKEN_NUM_INITIALIZER
16967 (struct cmd_tx_offload_get_configuration_result,
16969 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
16970 TOKEN_STRING_INITIALIZER
16971 (struct cmd_tx_offload_get_configuration_result,
16972 tx_offload, "tx_offload");
16973 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
16974 TOKEN_STRING_INITIALIZER
16975 (struct cmd_tx_offload_get_configuration_result,
16976 configuration, "configuration");
16979 cmd_tx_offload_get_configuration_parsed(
16980 void *parsed_result,
16981 __attribute__((unused)) struct cmdline *cl,
16982 __attribute__((unused)) void *data)
16984 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
16985 struct rte_eth_dev_info dev_info;
16986 portid_t port_id = res->port_id;
16987 struct rte_port *port = &ports[port_id];
16988 uint64_t port_offloads;
16989 uint64_t queue_offloads;
16990 uint16_t nb_tx_queues;
16993 printf("Tx Offloading Configuration of port %d :\n", port_id);
16995 port_offloads = port->dev_conf.txmode.offloads;
16997 print_tx_offloads(port_offloads);
17000 rte_eth_dev_info_get(port_id, &dev_info);
17001 nb_tx_queues = dev_info.nb_tx_queues;
17002 for (q = 0; q < nb_tx_queues; q++) {
17003 queue_offloads = port->tx_conf[q].offloads;
17004 printf(" Queue[%2d] :", q);
17005 print_tx_offloads(queue_offloads);
17011 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17012 .f = cmd_tx_offload_get_configuration_parsed,
17014 .help_str = "show port <port_id> tx_offload configuration",
17016 (void *)&cmd_tx_offload_get_configuration_show,
17017 (void *)&cmd_tx_offload_get_configuration_port,
17018 (void *)&cmd_tx_offload_get_configuration_port_id,
17019 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17020 (void *)&cmd_tx_offload_get_configuration_configuration,
17025 /* Enable/Disable a per port offloading */
17026 struct cmd_config_per_port_tx_offload_result {
17027 cmdline_fixed_string_t port;
17028 cmdline_fixed_string_t config;
17030 cmdline_fixed_string_t tx_offload;
17031 cmdline_fixed_string_t offload;
17032 cmdline_fixed_string_t on_off;
17035 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17036 TOKEN_STRING_INITIALIZER
17037 (struct cmd_config_per_port_tx_offload_result,
17039 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17040 TOKEN_STRING_INITIALIZER
17041 (struct cmd_config_per_port_tx_offload_result,
17043 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17044 TOKEN_NUM_INITIALIZER
17045 (struct cmd_config_per_port_tx_offload_result,
17047 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17048 TOKEN_STRING_INITIALIZER
17049 (struct cmd_config_per_port_tx_offload_result,
17050 tx_offload, "tx_offload");
17051 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17052 TOKEN_STRING_INITIALIZER
17053 (struct cmd_config_per_port_tx_offload_result,
17054 offload, "vlan_insert#ipv4_cksum#udp_cksum#udp_cksum#"
17055 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17056 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17057 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17058 "mt_lockfree#multi_segs#fast_free#security");
17059 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17060 TOKEN_STRING_INITIALIZER
17061 (struct cmd_config_per_port_tx_offload_result,
17065 search_tx_offload(const char *name)
17067 uint64_t single_offload;
17068 const char *single_name;
17072 single_offload = 1;
17073 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17074 single_name = rte_eth_dev_tx_offload_name(single_offload);
17075 if (!strcasecmp(single_name, name)) {
17078 } else if (!strcasecmp(single_name, "UNKNOWN"))
17080 else if (single_name == NULL)
17082 single_offload <<= 1;
17086 return single_offload;
17092 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17093 __attribute__((unused)) struct cmdline *cl,
17094 __attribute__((unused)) void *data)
17096 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17097 portid_t port_id = res->port_id;
17098 struct rte_eth_dev_info dev_info;
17099 struct rte_port *port = &ports[port_id];
17100 uint64_t single_offload;
17101 uint16_t nb_tx_queues;
17104 if (port->port_status != RTE_PORT_STOPPED) {
17105 printf("Error: Can't config offload when Port %d "
17106 "is not stopped\n", port_id);
17110 single_offload = search_tx_offload(res->offload);
17111 if (single_offload == 0) {
17112 printf("Unknown offload name: %s\n", res->offload);
17116 rte_eth_dev_info_get(port_id, &dev_info);
17117 nb_tx_queues = dev_info.nb_tx_queues;
17118 if (!strcmp(res->on_off, "on")) {
17119 port->dev_conf.txmode.offloads |= single_offload;
17120 for (q = 0; q < nb_tx_queues; q++)
17121 port->tx_conf[q].offloads |= single_offload;
17123 port->dev_conf.txmode.offloads &= ~single_offload;
17124 for (q = 0; q < nb_tx_queues; q++)
17125 port->tx_conf[q].offloads &= ~single_offload;
17128 cmd_reconfig_device_queue(port_id, 1, 1);
17131 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17132 .f = cmd_config_per_port_tx_offload_parsed,
17134 .help_str = "port config <port_id> tx_offload "
17135 "vlan_insert|ipv4_cksum|udp_cksum|udp_cksum|"
17136 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17137 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17138 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17139 "mt_lockfree|multi_segs|fast_free|security "
17142 (void *)&cmd_config_per_port_tx_offload_result_port,
17143 (void *)&cmd_config_per_port_tx_offload_result_config,
17144 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17145 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17146 (void *)&cmd_config_per_port_tx_offload_result_offload,
17147 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17152 /* Enable/Disable a per queue offloading */
17153 struct cmd_config_per_queue_tx_offload_result {
17154 cmdline_fixed_string_t port;
17156 cmdline_fixed_string_t txq;
17158 cmdline_fixed_string_t tx_offload;
17159 cmdline_fixed_string_t offload;
17160 cmdline_fixed_string_t on_off;
17163 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17164 TOKEN_STRING_INITIALIZER
17165 (struct cmd_config_per_queue_tx_offload_result,
17167 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17168 TOKEN_NUM_INITIALIZER
17169 (struct cmd_config_per_queue_tx_offload_result,
17171 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17172 TOKEN_STRING_INITIALIZER
17173 (struct cmd_config_per_queue_tx_offload_result,
17175 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17176 TOKEN_NUM_INITIALIZER
17177 (struct cmd_config_per_queue_tx_offload_result,
17179 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17180 TOKEN_STRING_INITIALIZER
17181 (struct cmd_config_per_queue_tx_offload_result,
17182 tx_offload, "tx_offload");
17183 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17184 TOKEN_STRING_INITIALIZER
17185 (struct cmd_config_per_queue_tx_offload_result,
17186 offload, "vlan_insert#ipv4_cksum#udp_cksum#udp_cksum#"
17187 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17188 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17189 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17190 "mt_lockfree#multi_segs#fast_free#security");
17191 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17192 TOKEN_STRING_INITIALIZER
17193 (struct cmd_config_per_queue_tx_offload_result,
17197 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17198 __attribute__((unused)) struct cmdline *cl,
17199 __attribute__((unused)) void *data)
17201 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17202 struct rte_eth_dev_info dev_info;
17203 portid_t port_id = res->port_id;
17204 uint16_t queue_id = res->queue_id;
17205 struct rte_port *port = &ports[port_id];
17206 uint64_t single_offload;
17208 if (port->port_status != RTE_PORT_STOPPED) {
17209 printf("Error: Can't config offload when Port %d "
17210 "is not stopped\n", port_id);
17214 rte_eth_dev_info_get(port_id, &dev_info);
17215 if (queue_id >= dev_info.nb_tx_queues) {
17216 printf("Error: input queue_id should be 0 ... "
17217 "%d\n", dev_info.nb_tx_queues - 1);
17221 single_offload = search_tx_offload(res->offload);
17222 if (single_offload == 0) {
17223 printf("Unknown offload name: %s\n", res->offload);
17227 if (!strcmp(res->on_off, "on"))
17228 port->tx_conf[queue_id].offloads |= single_offload;
17230 port->tx_conf[queue_id].offloads &= ~single_offload;
17232 cmd_reconfig_device_queue(port_id, 1, 1);
17235 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17236 .f = cmd_config_per_queue_tx_offload_parsed,
17238 .help_str = "port <port_id> txq <queue_id> tx_offload "
17239 "vlan_insert|ipv4_cksum|udp_cksum|udp_cksum|"
17240 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17241 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17242 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17243 "mt_lockfree|multi_segs|fast_free|security "
17246 (void *)&cmd_config_per_queue_tx_offload_result_port,
17247 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17248 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17249 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17250 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17251 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17252 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17257 /* ******************************************************************************** */
17259 /* list of instructions */
17260 cmdline_parse_ctx_t main_ctx[] = {
17261 (cmdline_parse_inst_t *)&cmd_help_brief,
17262 (cmdline_parse_inst_t *)&cmd_help_long,
17263 (cmdline_parse_inst_t *)&cmd_quit,
17264 (cmdline_parse_inst_t *)&cmd_load_from_file,
17265 (cmdline_parse_inst_t *)&cmd_showport,
17266 (cmdline_parse_inst_t *)&cmd_showqueue,
17267 (cmdline_parse_inst_t *)&cmd_showportall,
17268 (cmdline_parse_inst_t *)&cmd_showcfg,
17269 (cmdline_parse_inst_t *)&cmd_start,
17270 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17271 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17272 (cmdline_parse_inst_t *)&cmd_set_link_up,
17273 (cmdline_parse_inst_t *)&cmd_set_link_down,
17274 (cmdline_parse_inst_t *)&cmd_reset,
17275 (cmdline_parse_inst_t *)&cmd_set_numbers,
17276 (cmdline_parse_inst_t *)&cmd_set_log,
17277 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17278 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17279 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17280 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17281 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17282 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17283 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17284 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17285 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17286 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17287 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17288 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17289 (cmdline_parse_inst_t *)&cmd_set_link_check,
17290 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17291 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17292 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17293 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17294 #ifdef RTE_LIBRTE_PMD_BOND
17295 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17296 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17297 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17298 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17299 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17300 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17301 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17302 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17303 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17304 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17305 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17307 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17308 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17309 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17310 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17311 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17312 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17313 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17314 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17315 (cmdline_parse_inst_t *)&cmd_csum_set,
17316 (cmdline_parse_inst_t *)&cmd_csum_show,
17317 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17318 (cmdline_parse_inst_t *)&cmd_tso_set,
17319 (cmdline_parse_inst_t *)&cmd_tso_show,
17320 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17321 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17322 (cmdline_parse_inst_t *)&cmd_gro_enable,
17323 (cmdline_parse_inst_t *)&cmd_gro_flush,
17324 (cmdline_parse_inst_t *)&cmd_gro_show,
17325 (cmdline_parse_inst_t *)&cmd_gso_enable,
17326 (cmdline_parse_inst_t *)&cmd_gso_size,
17327 (cmdline_parse_inst_t *)&cmd_gso_show,
17328 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17329 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17330 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17331 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17332 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17333 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17334 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17335 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17336 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17337 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17338 (cmdline_parse_inst_t *)&cmd_config_dcb,
17339 (cmdline_parse_inst_t *)&cmd_read_reg,
17340 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17341 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17342 (cmdline_parse_inst_t *)&cmd_write_reg,
17343 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17344 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17345 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17346 (cmdline_parse_inst_t *)&cmd_stop,
17347 (cmdline_parse_inst_t *)&cmd_mac_addr,
17348 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17349 (cmdline_parse_inst_t *)&cmd_set_qmap,
17350 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17351 (cmdline_parse_inst_t *)&cmd_operate_port,
17352 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17353 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17354 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17355 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17356 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17357 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17358 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17359 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17360 (cmdline_parse_inst_t *)&cmd_config_mtu,
17361 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17362 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17363 (cmdline_parse_inst_t *)&cmd_config_rss,
17364 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17365 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17366 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17367 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17368 (cmdline_parse_inst_t *)&cmd_showport_reta,
17369 (cmdline_parse_inst_t *)&cmd_config_burst,
17370 (cmdline_parse_inst_t *)&cmd_config_thresh,
17371 (cmdline_parse_inst_t *)&cmd_config_threshold,
17372 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17373 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17374 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17375 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
17376 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17377 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
17378 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17379 (cmdline_parse_inst_t *)&cmd_global_config,
17380 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17381 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17382 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17383 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17384 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17385 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17386 (cmdline_parse_inst_t *)&cmd_dump,
17387 (cmdline_parse_inst_t *)&cmd_dump_one,
17388 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
17389 (cmdline_parse_inst_t *)&cmd_syn_filter,
17390 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
17391 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
17392 (cmdline_parse_inst_t *)&cmd_flex_filter,
17393 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
17394 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
17395 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
17396 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
17397 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
17398 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
17399 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17400 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
17401 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17402 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17403 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17404 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
17405 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17406 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
17407 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
17408 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
17409 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
17410 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
17411 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
17412 (cmdline_parse_inst_t *)&cmd_flow,
17413 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17414 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17415 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17416 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17417 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17418 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17419 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17420 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17421 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17422 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17423 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17424 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17425 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17426 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17427 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
17428 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
17429 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17430 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17431 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17432 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17433 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17434 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17435 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
17436 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
17437 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17438 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17439 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17440 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17441 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17442 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17443 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17444 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17445 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17446 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17447 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17448 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17449 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17450 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17451 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17452 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17453 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17454 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17455 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17456 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17457 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17458 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17459 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17460 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17461 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17462 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
17463 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
17465 (cmdline_parse_inst_t *)&cmd_ddp_add,
17466 (cmdline_parse_inst_t *)&cmd_ddp_del,
17467 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17468 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17469 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17470 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17471 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17472 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17473 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17474 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17475 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17476 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17478 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17479 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17480 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17481 (cmdline_parse_inst_t *)&cmd_queue_region,
17482 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17483 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17484 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17485 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17486 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17487 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17488 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17489 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17490 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17491 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17492 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17493 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17494 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17495 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17496 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17497 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17498 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17499 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17500 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17501 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17502 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17503 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17504 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17505 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17506 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17507 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17508 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17509 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17510 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17511 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17512 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17513 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17514 #ifdef RTE_LIBRTE_BPF
17515 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17516 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17521 /* read cmdline commands from file */
17523 cmdline_read_from_file(const char *filename)
17525 struct cmdline *cl;
17527 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17529 printf("Failed to create file based cmdline context: %s\n",
17534 cmdline_interact(cl);
17539 printf("Read CLI commands from %s\n", filename);
17542 /* prompt function, called from main on MASTER lcore */
17546 /* initialize non-constant commands */
17547 cmd_set_fwd_mode_init();
17548 cmd_set_fwd_retry_mode_init();
17550 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17551 if (testpmd_cl == NULL)
17553 cmdline_interact(testpmd_cl);
17554 cmdline_stdin_exit(testpmd_cl);
17560 if (testpmd_cl != NULL)
17561 cmdline_quit(testpmd_cl);
17565 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17567 if (id == (portid_t)RTE_PORT_ALL) {
17570 RTE_ETH_FOREACH_DEV(pid) {
17571 /* check if need_reconfig has been set to 1 */
17572 if (ports[pid].need_reconfig == 0)
17573 ports[pid].need_reconfig = dev;
17574 /* check if need_reconfig_queues has been set to 1 */
17575 if (ports[pid].need_reconfig_queues == 0)
17576 ports[pid].need_reconfig_queues = queue;
17578 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17579 /* check if need_reconfig has been set to 1 */
17580 if (ports[id].need_reconfig == 0)
17581 ports[id].need_reconfig = dev;
17582 /* check if need_reconfig_queues has been set to 1 */
17583 if (ports[id].need_reconfig_queues == 0)
17584 ports[id].need_reconfig_queues = queue;