1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
16 #include <net/socket.h>
18 #include <sys/socket.h>
21 #include <netinet/in.h>
23 #include <sys/queue.h>
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
28 #include <rte_debug.h>
29 #include <rte_cycles.h>
30 #include <rte_memory.h>
31 #include <rte_memzone.h>
32 #include <rte_malloc.h>
33 #include <rte_launch.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
43 #include <rte_ether.h>
44 #include <rte_ethdev.h>
45 #include <rte_string_fns.h>
46 #include <rte_devargs.h>
47 #include <rte_eth_ctrl.h>
51 #include <cmdline_rdline.h>
52 #include <cmdline_parse.h>
53 #include <cmdline_parse_num.h>
54 #include <cmdline_parse_string.h>
55 #include <cmdline_parse_ipaddr.h>
56 #include <cmdline_parse_etheraddr.h>
57 #include <cmdline_socket.h>
59 #ifdef RTE_LIBRTE_PMD_BOND
60 #include <rte_eth_bond.h>
61 #include <rte_eth_bond_8023ad.h>
63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
64 #include <rte_pmd_dpaa.h>
66 #ifdef RTE_LIBRTE_IXGBE_PMD
67 #include <rte_pmd_ixgbe.h>
69 #ifdef RTE_LIBRTE_I40E_PMD
70 #include <rte_pmd_i40e.h>
72 #ifdef RTE_LIBRTE_BNXT_PMD
73 #include <rte_pmd_bnxt.h>
76 #include "cmdline_mtr.h"
77 #include "cmdline_tm.h"
80 static struct cmdline *testpmd_cl;
82 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
84 /* *** Help command with introduction. *** */
85 struct cmd_help_brief_result {
86 cmdline_fixed_string_t help;
89 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
91 __attribute__((unused)) void *data)
96 "Help is available for the following sections:\n\n"
97 " help control : Start and stop forwarding.\n"
98 " help display : Displaying port, stats and config "
100 " help config : Configuration information.\n"
101 " help ports : Configuring ports.\n"
102 " help registers : Reading and setting port registers.\n"
103 " help filters : Filters configuration help.\n"
104 " help all : All of the above sections.\n\n"
109 cmdline_parse_token_string_t cmd_help_brief_help =
110 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
112 cmdline_parse_inst_t cmd_help_brief = {
113 .f = cmd_help_brief_parsed,
115 .help_str = "help: Show help",
117 (void *)&cmd_help_brief_help,
122 /* *** Help command with help sections. *** */
123 struct cmd_help_long_result {
124 cmdline_fixed_string_t help;
125 cmdline_fixed_string_t section;
128 static void cmd_help_long_parsed(void *parsed_result,
130 __attribute__((unused)) void *data)
133 struct cmd_help_long_result *res = parsed_result;
135 if (!strcmp(res->section, "all"))
138 if (show_all || !strcmp(res->section, "control")) {
143 "Control forwarding:\n"
144 "-------------------\n\n"
147 " Start packet forwarding with current configuration.\n\n"
150 " Start packet forwarding with current config"
151 " after sending one burst of packets.\n\n"
154 " Stop packet forwarding, and display accumulated"
158 " Quit to prompt.\n\n"
162 if (show_all || !strcmp(res->section, "display")) {
170 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n"
171 " Display information for port_id, or all.\n\n"
173 "show port X rss reta (size) (mask0,mask1,...)\n"
174 " Display the rss redirection table entry indicated"
175 " by masks on port X. size is used to indicate the"
176 " hardware supported reta size\n\n"
178 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|"
179 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
180 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n"
181 " Display the RSS hash functions and RSS hash key"
184 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
185 " Clear information for port_id, or all.\n\n"
187 "show (rxq|txq) info (port_id) (queue_id)\n"
188 " Display information for configured RX/TX queue.\n\n"
190 "show config (rxtx|cores|fwd|txpkts)\n"
191 " Display the given configuration.\n\n"
193 "read rxd (port_id) (queue_id) (rxd_id)\n"
194 " Display an RX descriptor of a port RX queue.\n\n"
196 "read txd (port_id) (queue_id) (txd_id)\n"
197 " Display a TX descriptor of a port TX queue.\n\n"
199 "ddp get list (port_id)\n"
200 " Get ddp profile info list\n\n"
202 "ddp get info (profile_path)\n"
203 " Get ddp profile information.\n\n"
205 "show vf stats (port_id) (vf_id)\n"
206 " Display a VF's statistics.\n\n"
208 "clear vf stats (port_id) (vf_id)\n"
209 " Reset a VF's statistics.\n\n"
211 "show port (port_id) pctype mapping\n"
212 " Get flow ptype to pctype mapping on a port\n\n"
214 "show port meter stats (port_id) (meter_id) (clear)\n"
215 " Get meter stats on a port\n\n"
216 "show port tm cap (port_id)\n"
217 " Display the port TM capability.\n\n"
219 "show port tm level cap (port_id) (level_id)\n"
220 " Display the port TM hierarchical level capability.\n\n"
222 "show port tm node cap (port_id) (node_id)\n"
223 " Display the port TM node capability.\n\n"
225 "show port tm node type (port_id) (node_id)\n"
226 " Display the port TM node type.\n\n"
228 "show port tm node stats (port_id) (node_id) (clear)\n"
229 " Display the port TM node stats.\n\n"
234 if (show_all || !strcmp(res->section, "config")) {
240 "Configuration changes only become active when"
241 " forwarding is started/restarted.\n\n"
244 " Reset forwarding to the default configuration.\n\n"
246 "set verbose (level)\n"
247 " Set the debug verbosity level X.\n\n"
249 "set log global|(type) (level)\n"
250 " Set the log level.\n\n"
253 " Set number of ports.\n\n"
256 " Set number of cores.\n\n"
258 "set coremask (mask)\n"
259 " Set the forwarding cores hexadecimal mask.\n\n"
261 "set portmask (mask)\n"
262 " Set the forwarding ports hexadecimal mask.\n\n"
265 " Set number of packets per burst.\n\n"
267 "set burst tx delay (microseconds) retry (num)\n"
268 " Set the transmit delay time and number of retries,"
269 " effective when retry is enabled.\n\n"
271 "set txpkts (x[,y]*)\n"
272 " Set the length of each segment of TXONLY"
273 " and optionally CSUM packets.\n\n"
275 "set txsplit (off|on|rand)\n"
276 " Set the split policy for the TX packets."
277 " Right now only applicable for CSUM and TXONLY"
280 "set corelist (x[,y]*)\n"
281 " Set the list of forwarding cores.\n\n"
283 "set portlist (x[,y]*)\n"
284 " Set the list of forwarding ports.\n\n"
286 "set tx loopback (port_id) (on|off)\n"
287 " Enable or disable tx loopback.\n\n"
289 "set all queues drop (port_id) (on|off)\n"
290 " Set drop enable bit for all queues.\n\n"
292 "set vf split drop (port_id) (vf_id) (on|off)\n"
293 " Set split drop enable bit for a VF from the PF.\n\n"
295 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
296 " Set MAC antispoof for a VF from the PF.\n\n"
298 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
299 " Enable MACsec offload.\n\n"
301 "set macsec offload (port_id) off\n"
302 " Disable MACsec offload.\n\n"
304 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
305 " Configure MACsec secure connection (SC).\n\n"
307 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
308 " Configure MACsec secure association (SA).\n\n"
310 "set vf broadcast (port_id) (vf_id) (on|off)\n"
311 " Set VF broadcast for a VF from the PF.\n\n"
313 "vlan set strip (on|off) (port_id)\n"
314 " Set the VLAN strip on a port.\n\n"
316 "vlan set stripq (on|off) (port_id,queue_id)\n"
317 " Set the VLAN strip for a queue on a port.\n\n"
319 "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
320 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
322 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
323 " Set VLAN insert for a VF from the PF.\n\n"
325 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
326 " Set VLAN antispoof for a VF from the PF.\n\n"
328 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
329 " Set VLAN tag for a VF from the PF.\n\n"
331 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
332 " Set a VF's max bandwidth(Mbps).\n\n"
334 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n"
335 " Set all TCs' min bandwidth(%%) on a VF.\n\n"
337 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n"
338 " Set a TC's max bandwidth(Mbps) on a VF.\n\n"
340 "set tx strict-link-priority (port_id) (tc_bitmap)\n"
341 " Set some TCs' strict link priority mode on a physical port.\n\n"
343 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
344 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
346 "vlan set filter (on|off) (port_id)\n"
347 " Set the VLAN filter on a port.\n\n"
349 "vlan set qinq (on|off) (port_id)\n"
350 " Set the VLAN QinQ (extended queue in queue)"
353 "vlan set (inner|outer) tpid (value) (port_id)\n"
354 " Set the VLAN TPID for Packet Filtering on"
357 "rx_vlan add (vlan_id|all) (port_id)\n"
358 " Add a vlan_id, or all identifiers, to the set"
359 " of VLAN identifiers filtered by port_id.\n\n"
361 "rx_vlan rm (vlan_id|all) (port_id)\n"
362 " Remove a vlan_id, or all identifiers, from the set"
363 " of VLAN identifiers filtered by port_id.\n\n"
365 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
366 " Add a vlan_id, to the set of VLAN identifiers"
367 "filtered for VF(s) from port_id.\n\n"
369 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
370 " Remove a vlan_id, to the set of VLAN identifiers"
371 "filtered for VF(s) from port_id.\n\n"
373 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) "
374 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
375 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
376 " add a tunnel filter of a port.\n\n"
378 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) "
379 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|"
380 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n"
381 " remove a tunnel filter of a port.\n\n"
383 "rx_vxlan_port add (udp_port) (port_id)\n"
384 " Add an UDP port for VXLAN packet filter on a port\n\n"
386 "rx_vxlan_port rm (udp_port) (port_id)\n"
387 " Remove an UDP port for VXLAN packet filter on a port\n\n"
389 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
390 " Set hardware insertion of VLAN IDs (single or double VLAN "
391 "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
393 "tx_vlan set pvid port_id vlan_id (on|off)\n"
394 " Set port based TX VLAN insertion.\n\n"
396 "tx_vlan reset (port_id)\n"
397 " Disable hardware insertion of a VLAN header in"
398 " packets sent on a port.\n\n"
400 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n"
401 " Select hardware or software calculation of the"
402 " checksum when transmitting a packet using the"
403 " csum forward engine.\n"
404 " ip|udp|tcp|sctp always concern the inner layer.\n"
405 " outer-ip concerns the outer IP layer in"
406 " case the packet is recognized as a tunnel packet by"
407 " the forward engine (vxlan, gre and ipip are supported)\n"
408 " Please check the NIC datasheet for HW limits.\n\n"
410 "csum parse-tunnel (on|off) (tx_port_id)\n"
411 " If disabled, treat tunnel packets as non-tunneled"
412 " packets (treat inner headers as payload). The port\n"
413 " argument is the port used for TX in csum forward"
416 "csum show (port_id)\n"
417 " Display tx checksum offload configuration\n\n"
419 "tso set (segsize) (portid)\n"
420 " Enable TCP Segmentation Offload in csum forward"
422 " Please check the NIC datasheet for HW limits.\n\n"
425 " Display the status of TCP Segmentation Offload.\n\n"
427 "set port (port_id) gro on|off\n"
428 " Enable or disable Generic Receive Offload in"
429 " csum forwarding engine.\n\n"
431 "show port (port_id) gro\n"
432 " Display GRO configuration.\n\n"
434 "set gro flush (cycles)\n"
435 " Set the cycle to flush GROed packets from"
436 " reassembly tables.\n\n"
438 "set port (port_id) gso (on|off)"
439 " Enable or disable Generic Segmentation Offload in"
440 " csum forwarding engine.\n\n"
442 "set gso segsz (length)\n"
443 " Set max packet length for output GSO segments,"
444 " including packet header and payload.\n\n"
446 "show port (port_id) gso\n"
447 " Show GSO configuration.\n\n"
450 " Set packet forwarding mode.\n\n"
452 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
453 " Add a MAC address on port_id.\n\n"
455 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
456 " Remove a MAC address from port_id.\n\n"
458 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
459 " Set the default MAC address for port_id.\n\n"
461 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
462 " Add a MAC address for a VF on the port.\n\n"
464 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
465 " Set the MAC address for a VF from the PF.\n\n"
467 "set eth-peer (port_id) (peer_addr)\n"
468 " set the peer address for certain port.\n\n"
470 "set port (port_id) uta (mac_address|all) (on|off)\n"
471 " Add/Remove a or all unicast hash filter(s)"
474 "set promisc (port_id|all) (on|off)\n"
475 " Set the promiscuous mode on port_id, or all.\n\n"
477 "set allmulti (port_id|all) (on|off)\n"
478 " Set the allmulti mode on port_id, or all.\n\n"
480 "set vf promisc (port_id) (vf_id) (on|off)\n"
481 " Set unicast promiscuous mode for a VF from the PF.\n\n"
483 "set vf allmulti (port_id) (vf_id) (on|off)\n"
484 " Set multicast promiscuous mode for a VF from the PF.\n\n"
486 "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
487 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
488 " (on|off) autoneg (on|off) (port_id)\n"
489 "set flow_ctrl rx (on|off) (portid)\n"
490 "set flow_ctrl tx (on|off) (portid)\n"
491 "set flow_ctrl high_water (high_water) (portid)\n"
492 "set flow_ctrl low_water (low_water) (portid)\n"
493 "set flow_ctrl pause_time (pause_time) (portid)\n"
494 "set flow_ctrl send_xon (send_xon) (portid)\n"
495 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
496 "set flow_ctrl autoneg (on|off) (port_id)\n"
497 " Set the link flow control parameter on a port.\n\n"
499 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
500 " (low_water) (pause_time) (priority) (port_id)\n"
501 " Set the priority flow control parameter on a"
504 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
505 " Set statistics mapping (qmapping 0..15) for RX/TX"
507 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
508 " on port 0 to mapping 5.\n\n"
510 "set xstats-hide-zero on|off\n"
511 " Set the option to hide the zero values"
512 " for xstats display.\n"
514 "set port (port_id) vf (vf_id) rx|tx on|off\n"
515 " Enable/Disable a VF receive/tranmit from a port\n\n"
517 "set port (port_id) vf (vf_id) (mac_addr)"
518 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n"
519 " Add/Remove unicast or multicast MAC addr filter"
522 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
524 " AUPE:accepts untagged VLAN;"
525 "ROPE:accept unicast hash\n\n"
526 " BAM:accepts broadcast packets;"
527 "MPE:accepts all multicast packets\n\n"
528 " Enable/Disable a VF receive mode of a port\n\n"
530 "set port (port_id) queue (queue_id) rate (rate_num)\n"
531 " Set rate limit for a queue of a port\n\n"
533 "set port (port_id) vf (vf_id) rate (rate_num) "
534 "queue_mask (queue_mask_value)\n"
535 " Set rate limit for queues in VF of a port\n\n"
537 "set port (port_id) mirror-rule (rule_id)"
538 " (pool-mirror-up|pool-mirror-down|vlan-mirror)"
539 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n"
540 " Set pool or vlan type mirror rule on a port.\n"
541 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1"
542 " dst-pool 0 on' enable mirror traffic with vlan 0,1"
545 "set port (port_id) mirror-rule (rule_id)"
546 " (uplink-mirror|downlink-mirror) dst-pool"
547 " (pool_id) (on|off)\n"
548 " Set uplink or downlink type mirror rule on a port.\n"
549 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool"
550 " 0 on' enable mirror income traffic to pool 0.\n\n"
552 "reset port (port_id) mirror-rule (rule_id)\n"
553 " Reset a mirror rule.\n\n"
555 "set flush_rx (on|off)\n"
556 " Flush (default) or don't flush RX streams before"
557 " forwarding. Mainly used with PCAP drivers.\n\n"
559 "set bypass mode (normal|bypass|isolate) (port_id)\n"
560 " Set the bypass mode for the lowest port on bypass enabled"
563 "set bypass event (timeout|os_on|os_off|power_on|power_off) "
564 "mode (normal|bypass|isolate) (port_id)\n"
565 " Set the event required to initiate specified bypass mode for"
566 " the lowest port on a bypass enabled NIC where:\n"
567 " timeout = enable bypass after watchdog timeout.\n"
568 " os_on = enable bypass when OS/board is powered on.\n"
569 " os_off = enable bypass when OS/board is powered off.\n"
570 " power_on = enable bypass when power supply is turned on.\n"
571 " power_off = enable bypass when power supply is turned off."
574 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n"
575 " Set the bypass watchdog timeout to 'n' seconds"
576 " where 0 = instant.\n\n"
578 "show bypass config (port_id)\n"
579 " Show the bypass configuration for a bypass enabled NIC"
580 " using the lowest port on the NIC.\n\n"
582 #ifdef RTE_LIBRTE_PMD_BOND
583 "create bonded device (mode) (socket)\n"
584 " Create a new bonded device with specific bonding mode and socket.\n\n"
586 "add bonding slave (slave_id) (port_id)\n"
587 " Add a slave device to a bonded device.\n\n"
589 "remove bonding slave (slave_id) (port_id)\n"
590 " Remove a slave device from a bonded device.\n\n"
592 "set bonding mode (value) (port_id)\n"
593 " Set the bonding mode on a bonded device.\n\n"
595 "set bonding primary (slave_id) (port_id)\n"
596 " Set the primary slave for a bonded device.\n\n"
598 "show bonding config (port_id)\n"
599 " Show the bonding config for port_id.\n\n"
601 "set bonding mac_addr (port_id) (address)\n"
602 " Set the MAC address of a bonded device.\n\n"
604 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
605 " Set Aggregation mode for IEEE802.3AD (mode 4)"
607 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n"
608 " Set the transmit balance policy for bonded device running in balance mode.\n\n"
610 "set bonding mon_period (port_id) (value)\n"
611 " Set the bonding link status monitoring polling period in ms.\n\n"
613 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
614 " Enable/disable dedicated queues for LACP control traffic.\n\n"
617 "set link-up port (port_id)\n"
618 " Set link up for a port.\n\n"
620 "set link-down port (port_id)\n"
621 " Set link down for a port.\n\n"
623 "E-tag set insertion on port-tag-id (value)"
624 " port (port_id) vf (vf_id)\n"
625 " Enable E-tag insertion for a VF on a port\n\n"
627 "E-tag set insertion off port (port_id) vf (vf_id)\n"
628 " Disable E-tag insertion for a VF on a port\n\n"
630 "E-tag set stripping (on|off) port (port_id)\n"
631 " Enable/disable E-tag stripping on a port\n\n"
633 "E-tag set forwarding (on|off) port (port_id)\n"
634 " Enable/disable E-tag based forwarding"
637 "E-tag set filter add e-tag-id (value) dst-pool"
638 " (pool_id) port (port_id)\n"
639 " Add an E-tag forwarding filter on a port\n\n"
641 "E-tag set filter del e-tag-id (value) port (port_id)\n"
642 " Delete an E-tag forwarding filter on a port\n\n"
644 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
645 "set port tm hierarchy default (port_id)\n"
646 " Set default traffic Management hierarchy on a port\n\n"
649 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
650 " Load a profile package on a port\n\n"
652 "ddp del (port_id) (backup_profile_path)\n"
653 " Delete a profile package from a port\n\n"
655 "ptype mapping get (port_id) (valid_only)\n"
656 " Get ptype mapping on a port\n\n"
658 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
659 " Replace target with the pkt_type in ptype mapping\n\n"
661 "ptype mapping reset (port_id)\n"
662 " Reset ptype mapping on a port\n\n"
664 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
665 " Update a ptype mapping item on a port\n\n"
667 "set port (port_id) queue-region region_id (value) "
668 "queue_start_index (value) queue_num (value)\n"
669 " Set a queue region on a port\n\n"
671 "set port (port_id) queue-region region_id (value) "
673 " Set a flowtype region index on a port\n\n"
675 "set port (port_id) queue-region UP (value) region_id (value)\n"
676 " Set the mapping of User Priority to "
677 "queue region on a port\n\n"
679 "set port (port_id) queue-region flush (on|off)\n"
680 " flush all queue region related configuration\n\n"
682 "show port meter cap (port_id)\n"
683 " Show port meter capability information\n\n"
685 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
686 " meter profile add - srtcm rfc 2697\n\n"
688 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n"
689 " meter profile add - trtcm rfc 2698\n\n"
691 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n"
692 " meter profile add - trtcm rfc 4115\n\n"
694 "del port meter profile (port_id) (profile_id)\n"
695 " meter profile delete\n\n"
697 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n"
698 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n"
699 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
700 "(dscp_tbl_entry63)]\n"
703 "enable port meter (port_id) (mtr_id)\n"
706 "disable port meter (port_id) (mtr_id)\n"
709 "del port meter (port_id) (mtr_id)\n"
712 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
713 " meter update meter profile\n\n"
715 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
716 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
717 " update meter dscp table entries\n\n"
719 "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
720 "(action0) [(action1) (action2)]\n"
721 " meter update policer action\n\n"
723 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
724 " meter update stats\n\n"
726 "show port (port_id) queue-region\n"
727 " show all queue region related configuration info\n\n"
729 "add port tm node shaper profile (port_id) (shaper_profile_id)"
730 " (tb_rate) (tb_size) (packet_length_adjust)\n"
731 " Add port tm node private shaper profile.\n\n"
733 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
734 " Delete port tm node private shaper profile.\n\n"
736 "add port tm node shared shaper (port_id) (shared_shaper_id)"
737 " (shaper_profile_id)\n"
738 " Add/update port tm node shared shaper.\n\n"
740 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
741 " Delete port tm node shared shaper.\n\n"
743 "set port tm node shaper profile (port_id) (node_id)"
744 " (shaper_profile_id)\n"
745 " Set port tm node shaper profile.\n\n"
747 "add port tm node wred profile (port_id) (wred_profile_id)"
748 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
749 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
750 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
751 " Add port tm node wred profile.\n\n"
753 "del port tm node wred profile (port_id) (wred_profile_id)\n"
754 " Delete port tm node wred profile.\n\n"
756 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
757 " (priority) (weight) (level_id) (shaper_profile_id)"
758 " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
759 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
760 " Add port tm nonleaf node.\n\n"
762 "add port tm leaf node (port_id) (node_id) (parent_node_id)"
763 " (priority) (weight) (level_id) (shaper_profile_id)"
764 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
765 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
766 " Add port tm leaf node.\n\n"
768 "del port tm node (port_id) (node_id)\n"
769 " Delete port tm node.\n\n"
771 "set port tm node parent (port_id) (node_id) (parent_node_id)"
772 " (priority) (weight)\n"
773 " Set port tm node parent.\n\n"
775 "suspend port tm node (port_id) (node_id)"
776 " Suspend tm node.\n\n"
778 "resume port tm node (port_id) (node_id)"
779 " Resume tm node.\n\n"
781 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
782 " Commit tm hierarchy.\n\n"
784 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
785 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
786 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
787 " Configure the VXLAN encapsulation for flows.\n\n"
789 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
790 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
791 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
792 " eth-dst (eth-dst)\n"
793 " Configure the VXLAN encapsulation for flows.\n\n"
795 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
796 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
798 " Configure the NVGRE encapsulation for flows.\n\n"
800 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
801 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
802 " eth-src (eth-src) eth-dst (eth-dst)\n"
803 " Configure the NVGRE encapsulation for flows.\n\n"
805 , list_pkt_forwarding_modes()
809 if (show_all || !strcmp(res->section, "ports")) {
815 "----------------\n\n"
817 "port start (port_id|all)\n"
818 " Start all ports or port_id.\n\n"
820 "port stop (port_id|all)\n"
821 " Stop all ports or port_id.\n\n"
823 "port close (port_id|all)\n"
824 " Close all ports or port_id.\n\n"
826 "port attach (ident)\n"
827 " Attach physical or virtual dev by pci address or virtual device name\n\n"
829 "port detach (port_id)\n"
830 " Detach physical or virtual dev by port_id\n\n"
832 "port config (port_id|all)"
833 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)"
834 " duplex (half|full|auto)\n"
835 " Set speed and duplex for all ports or port_id\n\n"
837 "port config (port_id|all) loopback (mode)\n"
838 " Set loopback mode for all ports or port_id\n\n"
840 "port config all (rxq|txq|rxd|txd) (value)\n"
841 " Set number for rxq/txq/rxd/txd.\n\n"
843 "port config all max-pkt-len (value)\n"
844 " Set the max packet length.\n\n"
846 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|"
847 "hw-vlan-strip|hw-vlan-extend|drop-en)"
849 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
852 "port config all rss (all|default|ip|tcp|udp|sctp|"
853 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n"
854 " Set the RSS mode.\n\n"
856 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
857 " Set the RSS redirection table.\n\n"
859 "port config (port_id) dcb vt (on|off) (traffic_class)"
861 " Set the DCB mode.\n\n"
863 "port config all burst (value)\n"
864 " Set the number of packets per burst.\n\n"
866 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
868 " Set the ring prefetch/host/writeback threshold"
869 " for tx/rx queue.\n\n"
871 "port config all (txfreet|txrst|rxfreet) (value)\n"
872 " Set free threshold for rx/tx, or set"
873 " tx rs bit threshold.\n\n"
874 "port config mtu X value\n"
875 " Set the MTU of port X to a given value\n\n"
877 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
878 " Set a rx/tx queue's ring size configuration, the new"
879 " value will take effect after command that (re-)start the port"
880 " or command that setup the specific queue\n\n"
882 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
883 " Start/stop a rx/tx queue of port X. Only take effect"
884 " when port X is started\n\n"
886 "port (port_id) (rxq|txq) (queue_id) setup\n"
887 " Setup a rx/tx queue of port X.\n\n"
889 "port config (port_id|all) l2-tunnel E-tag ether-type"
891 " Set the value of E-tag ether-type.\n\n"
893 "port config (port_id|all) l2-tunnel E-tag"
894 " (enable|disable)\n"
895 " Enable/disable the E-tag support.\n\n"
897 "port config (port_id) pctype mapping reset\n"
898 " Reset flow type to pctype mapping on a port\n\n"
900 "port config (port_id) pctype mapping update"
901 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n"
902 " Update a flow type to pctype mapping item on a port\n\n"
904 "port config (port_id) pctype (pctype_id) hash_inset|"
905 "fdir_inset|fdir_flx_inset get|set|clear field\n"
907 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
909 "port config (port_id) pctype (pctype_id) hash_inset|"
910 "fdir_inset|fdir_flx_inset clear all"
911 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n"
913 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n"
914 " Add/remove UDP tunnel port for tunneling offload\n\n"
918 if (show_all || !strcmp(res->section, "registers")) {
926 "read reg (port_id) (address)\n"
927 " Display value of a port register.\n\n"
929 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
930 " Display a port register bit field.\n\n"
932 "read regbit (port_id) (address) (bit_x)\n"
933 " Display a single port register bit.\n\n"
935 "write reg (port_id) (address) (value)\n"
936 " Set value of a port register.\n\n"
938 "write regfield (port_id) (address) (bit_x) (bit_y)"
940 " Set bit field of a port register.\n\n"
942 "write regbit (port_id) (address) (bit_x) (value)\n"
943 " Set single bit value of a port register.\n\n"
946 if (show_all || !strcmp(res->section, "filters")) {
954 "ethertype_filter (port_id) (add|del)"
955 " (mac_addr|mac_ignr) (mac_address) ethertype"
956 " (ether_type) (drop|fwd) queue (queue_id)\n"
957 " Add/Del an ethertype filter.\n\n"
959 "2tuple_filter (port_id) (add|del)"
960 " dst_port (dst_port_value) protocol (protocol_value)"
961 " mask (mask_value) tcp_flags (tcp_flags_value)"
962 " priority (prio_value) queue (queue_id)\n"
963 " Add/Del a 2tuple filter.\n\n"
965 "5tuple_filter (port_id) (add|del)"
966 " dst_ip (dst_address) src_ip (src_address)"
967 " dst_port (dst_port_value) src_port (src_port_value)"
968 " protocol (protocol_value)"
969 " mask (mask_value) tcp_flags (tcp_flags_value)"
970 " priority (prio_value) queue (queue_id)\n"
971 " Add/Del a 5tuple filter.\n\n"
973 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
974 " Add/Del syn filter.\n\n"
976 "flex_filter (port_id) (add|del) len (len_value)"
977 " bytes (bytes_value) mask (mask_value)"
978 " priority (prio_value) queue (queue_id)\n"
979 " Add/Del a flex filter.\n\n"
981 "flow_director_filter (port_id) mode IP (add|del|update)"
982 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)"
983 " src (src_ip_address) dst (dst_ip_address)"
984 " tos (tos_value) proto (proto_value) ttl (ttl_value)"
985 " vlan (vlan_value) flexbytes (flexbytes_value)"
986 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
987 " fd_id (fd_id_value)\n"
988 " Add/Del an IP type flow director filter.\n\n"
990 "flow_director_filter (port_id) mode IP (add|del|update)"
991 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)"
992 " src (src_ip_address) (src_port)"
993 " dst (dst_ip_address) (dst_port)"
994 " tos (tos_value) ttl (ttl_value)"
995 " vlan (vlan_value) flexbytes (flexbytes_value)"
996 " (drop|fwd) pf|vf(vf_id) queue (queue_id)"
997 " fd_id (fd_id_value)\n"
998 " Add/Del an UDP/TCP type flow director filter.\n\n"
1000 "flow_director_filter (port_id) mode IP (add|del|update)"
1001 " flow (ipv4-sctp|ipv6-sctp)"
1002 " src (src_ip_address) (src_port)"
1003 " dst (dst_ip_address) (dst_port)"
1004 " tag (verification_tag) "
1005 " tos (tos_value) ttl (ttl_value)"
1006 " vlan (vlan_value)"
1007 " flexbytes (flexbytes_value) (drop|fwd)"
1008 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1009 " Add/Del a SCTP type flow director filter.\n\n"
1011 "flow_director_filter (port_id) mode IP (add|del|update)"
1012 " flow l2_payload ether (ethertype)"
1013 " flexbytes (flexbytes_value) (drop|fwd)"
1014 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n"
1015 " Add/Del a l2 payload type flow director filter.\n\n"
1017 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)"
1018 " mac (mac_address) vlan (vlan_value)"
1019 " flexbytes (flexbytes_value) (drop|fwd)"
1020 " queue (queue_id) fd_id (fd_id_value)\n"
1021 " Add/Del a MAC-VLAN flow director filter.\n\n"
1023 "flow_director_filter (port_id) mode Tunnel (add|del|update)"
1024 " mac (mac_address) vlan (vlan_value)"
1025 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)"
1026 " flexbytes (flexbytes_value) (drop|fwd)"
1027 " queue (queue_id) fd_id (fd_id_value)\n"
1028 " Add/Del a Tunnel flow director filter.\n\n"
1030 "flow_director_filter (port_id) mode raw (add|del|update)"
1031 " flow (flow_id) (drop|fwd) queue (queue_id)"
1032 " fd_id (fd_id_value) packet (packet file name)\n"
1033 " Add/Del a raw type flow director filter.\n\n"
1035 "flush_flow_director (port_id)\n"
1036 " Flush all flow director entries of a device.\n\n"
1038 "flow_director_mask (port_id) mode IP vlan (vlan_value)"
1039 " src_mask (ipv4_src) (ipv6_src) (src_port)"
1040 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n"
1041 " Set flow director IP mask.\n\n"
1043 "flow_director_mask (port_id) mode MAC-VLAN"
1044 " vlan (vlan_value)\n"
1045 " Set flow director MAC-VLAN mask.\n\n"
1047 "flow_director_mask (port_id) mode Tunnel"
1048 " vlan (vlan_value) mac (mac_value)"
1049 " tunnel-type (tunnel_type_value)"
1050 " tunnel-id (tunnel_id_value)\n"
1051 " Set flow director Tunnel mask.\n\n"
1053 "flow_director_flex_mask (port_id)"
1054 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
1055 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)"
1057 " Configure mask of flex payload.\n\n"
1059 "flow_director_flex_payload (port_id)"
1060 " (raw|l2|l3|l4) (config)\n"
1061 " Configure flex payload selection.\n\n"
1063 "get_sym_hash_ena_per_port (port_id)\n"
1064 " get symmetric hash enable configuration per port.\n\n"
1066 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n"
1067 " set symmetric hash enable configuration per port"
1068 " to enable or disable.\n\n"
1070 "get_hash_global_config (port_id)\n"
1071 " Get the global configurations of hash filters.\n\n"
1073 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)"
1074 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1075 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
1076 " (enable|disable)\n"
1077 " Set the global configurations of hash filters.\n\n"
1079 "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
1080 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
1081 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1082 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|"
1083 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
1084 "ipv6-next-header|udp-src-port|udp-dst-port|"
1085 "tcp-src-port|tcp-dst-port|sctp-src-port|"
1086 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
1087 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
1088 "fld-8th|none) (select|add)\n"
1089 " Set the input set for hash.\n\n"
1091 "set_fdir_input_set (port_id) "
1092 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
1093 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
1094 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|"
1095 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|"
1096 "ipv6-next-header|ipv6-hop-limits|udp-src-port|"
1097 "udp-dst-port|tcp-src-port|tcp-dst-port|"
1098 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)"
1100 " Set the input set for FDir.\n\n"
1102 "flow validate {port_id}"
1103 " [group {group_id}] [priority {level}]"
1104 " [ingress] [egress]"
1105 " pattern {item} [/ {item} [...]] / end"
1106 " actions {action} [/ {action} [...]] / end\n"
1107 " Check whether a flow rule can be created.\n\n"
1109 "flow create {port_id}"
1110 " [group {group_id}] [priority {level}]"
1111 " [ingress] [egress]"
1112 " pattern {item} [/ {item} [...]] / end"
1113 " actions {action} [/ {action} [...]] / end\n"
1114 " Create a flow rule.\n\n"
1116 "flow destroy {port_id} rule {rule_id} [...]\n"
1117 " Destroy specific flow rules.\n\n"
1119 "flow flush {port_id}\n"
1120 " Destroy all flow rules.\n\n"
1122 "flow query {port_id} {rule_id} {action}\n"
1123 " Query an existing flow rule.\n\n"
1125 "flow list {port_id} [group {group_id}] [...]\n"
1126 " List existing flow rules sorted by priority,"
1127 " filtered by group identifiers.\n\n"
1129 "flow isolate {port_id} {boolean}\n"
1130 " Restrict ingress traffic to the defined"
1136 cmdline_parse_token_string_t cmd_help_long_help =
1137 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1139 cmdline_parse_token_string_t cmd_help_long_section =
1140 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1141 "all#control#display#config#"
1142 "ports#registers#filters");
1144 cmdline_parse_inst_t cmd_help_long = {
1145 .f = cmd_help_long_parsed,
1147 .help_str = "help all|control|display|config|ports|register|filters: "
1150 (void *)&cmd_help_long_help,
1151 (void *)&cmd_help_long_section,
1157 /* *** start/stop/close all ports *** */
1158 struct cmd_operate_port_result {
1159 cmdline_fixed_string_t keyword;
1160 cmdline_fixed_string_t name;
1161 cmdline_fixed_string_t value;
1164 static void cmd_operate_port_parsed(void *parsed_result,
1165 __attribute__((unused)) struct cmdline *cl,
1166 __attribute__((unused)) void *data)
1168 struct cmd_operate_port_result *res = parsed_result;
1170 if (!strcmp(res->name, "start"))
1171 start_port(RTE_PORT_ALL);
1172 else if (!strcmp(res->name, "stop"))
1173 stop_port(RTE_PORT_ALL);
1174 else if (!strcmp(res->name, "close"))
1175 close_port(RTE_PORT_ALL);
1176 else if (!strcmp(res->name, "reset"))
1177 reset_port(RTE_PORT_ALL);
1179 printf("Unknown parameter\n");
1182 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1183 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1185 cmdline_parse_token_string_t cmd_operate_port_all_port =
1186 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1187 "start#stop#close#reset");
1188 cmdline_parse_token_string_t cmd_operate_port_all_all =
1189 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1191 cmdline_parse_inst_t cmd_operate_port = {
1192 .f = cmd_operate_port_parsed,
1194 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1196 (void *)&cmd_operate_port_all_cmd,
1197 (void *)&cmd_operate_port_all_port,
1198 (void *)&cmd_operate_port_all_all,
1203 /* *** start/stop/close specific port *** */
1204 struct cmd_operate_specific_port_result {
1205 cmdline_fixed_string_t keyword;
1206 cmdline_fixed_string_t name;
1210 static void cmd_operate_specific_port_parsed(void *parsed_result,
1211 __attribute__((unused)) struct cmdline *cl,
1212 __attribute__((unused)) void *data)
1214 struct cmd_operate_specific_port_result *res = parsed_result;
1216 if (!strcmp(res->name, "start"))
1217 start_port(res->value);
1218 else if (!strcmp(res->name, "stop"))
1219 stop_port(res->value);
1220 else if (!strcmp(res->name, "close"))
1221 close_port(res->value);
1222 else if (!strcmp(res->name, "reset"))
1223 reset_port(res->value);
1225 printf("Unknown parameter\n");
1228 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1229 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1231 cmdline_parse_token_string_t cmd_operate_specific_port_port =
1232 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1233 name, "start#stop#close#reset");
1234 cmdline_parse_token_num_t cmd_operate_specific_port_id =
1235 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1238 cmdline_parse_inst_t cmd_operate_specific_port = {
1239 .f = cmd_operate_specific_port_parsed,
1241 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1243 (void *)&cmd_operate_specific_port_cmd,
1244 (void *)&cmd_operate_specific_port_port,
1245 (void *)&cmd_operate_specific_port_id,
1250 /* *** attach a specified port *** */
1251 struct cmd_operate_attach_port_result {
1252 cmdline_fixed_string_t port;
1253 cmdline_fixed_string_t keyword;
1254 cmdline_fixed_string_t identifier;
1257 static void cmd_operate_attach_port_parsed(void *parsed_result,
1258 __attribute__((unused)) struct cmdline *cl,
1259 __attribute__((unused)) void *data)
1261 struct cmd_operate_attach_port_result *res = parsed_result;
1263 if (!strcmp(res->keyword, "attach"))
1264 attach_port(res->identifier);
1266 printf("Unknown parameter\n");
1269 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1270 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1272 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1273 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1275 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1279 cmdline_parse_inst_t cmd_operate_attach_port = {
1280 .f = cmd_operate_attach_port_parsed,
1282 .help_str = "port attach <identifier>: "
1283 "(identifier: pci address or virtual dev name)",
1285 (void *)&cmd_operate_attach_port_port,
1286 (void *)&cmd_operate_attach_port_keyword,
1287 (void *)&cmd_operate_attach_port_identifier,
1292 /* *** detach a specified port *** */
1293 struct cmd_operate_detach_port_result {
1294 cmdline_fixed_string_t port;
1295 cmdline_fixed_string_t keyword;
1299 static void cmd_operate_detach_port_parsed(void *parsed_result,
1300 __attribute__((unused)) struct cmdline *cl,
1301 __attribute__((unused)) void *data)
1303 struct cmd_operate_detach_port_result *res = parsed_result;
1305 if (!strcmp(res->keyword, "detach"))
1306 detach_port(res->port_id);
1308 printf("Unknown parameter\n");
1311 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1312 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1314 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1317 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1318 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1321 cmdline_parse_inst_t cmd_operate_detach_port = {
1322 .f = cmd_operate_detach_port_parsed,
1324 .help_str = "port detach <port_id>",
1326 (void *)&cmd_operate_detach_port_port,
1327 (void *)&cmd_operate_detach_port_keyword,
1328 (void *)&cmd_operate_detach_port_port_id,
1333 /* *** configure speed for all ports *** */
1334 struct cmd_config_speed_all {
1335 cmdline_fixed_string_t port;
1336 cmdline_fixed_string_t keyword;
1337 cmdline_fixed_string_t all;
1338 cmdline_fixed_string_t item1;
1339 cmdline_fixed_string_t item2;
1340 cmdline_fixed_string_t value1;
1341 cmdline_fixed_string_t value2;
1345 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1350 if (!strcmp(duplexstr, "half")) {
1351 duplex = ETH_LINK_HALF_DUPLEX;
1352 } else if (!strcmp(duplexstr, "full")) {
1353 duplex = ETH_LINK_FULL_DUPLEX;
1354 } else if (!strcmp(duplexstr, "auto")) {
1355 duplex = ETH_LINK_FULL_DUPLEX;
1357 printf("Unknown duplex parameter\n");
1361 if (!strcmp(speedstr, "10")) {
1362 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1363 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M;
1364 } else if (!strcmp(speedstr, "100")) {
1365 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ?
1366 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M;
1368 if (duplex != ETH_LINK_FULL_DUPLEX) {
1369 printf("Invalid speed/duplex parameters\n");
1372 if (!strcmp(speedstr, "1000")) {
1373 *speed = ETH_LINK_SPEED_1G;
1374 } else if (!strcmp(speedstr, "10000")) {
1375 *speed = ETH_LINK_SPEED_10G;
1376 } else if (!strcmp(speedstr, "25000")) {
1377 *speed = ETH_LINK_SPEED_25G;
1378 } else if (!strcmp(speedstr, "40000")) {
1379 *speed = ETH_LINK_SPEED_40G;
1380 } else if (!strcmp(speedstr, "50000")) {
1381 *speed = ETH_LINK_SPEED_50G;
1382 } else if (!strcmp(speedstr, "100000")) {
1383 *speed = ETH_LINK_SPEED_100G;
1384 } else if (!strcmp(speedstr, "auto")) {
1385 *speed = ETH_LINK_SPEED_AUTONEG;
1387 printf("Unknown speed parameter\n");
1396 cmd_config_speed_all_parsed(void *parsed_result,
1397 __attribute__((unused)) struct cmdline *cl,
1398 __attribute__((unused)) void *data)
1400 struct cmd_config_speed_all *res = parsed_result;
1401 uint32_t link_speed;
1404 if (!all_ports_stopped()) {
1405 printf("Please stop all ports first\n");
1409 if (parse_and_check_speed_duplex(res->value1, res->value2,
1413 RTE_ETH_FOREACH_DEV(pid) {
1414 ports[pid].dev_conf.link_speeds = link_speed;
1417 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1420 cmdline_parse_token_string_t cmd_config_speed_all_port =
1421 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1422 cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1423 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1425 cmdline_parse_token_string_t cmd_config_speed_all_all =
1426 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1427 cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1428 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1429 cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1430 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1431 "10#100#1000#10000#25000#40000#50000#100000#auto");
1432 cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1433 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1434 cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1435 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1438 cmdline_parse_inst_t cmd_config_speed_all = {
1439 .f = cmd_config_speed_all_parsed,
1441 .help_str = "port config all speed "
1442 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1445 (void *)&cmd_config_speed_all_port,
1446 (void *)&cmd_config_speed_all_keyword,
1447 (void *)&cmd_config_speed_all_all,
1448 (void *)&cmd_config_speed_all_item1,
1449 (void *)&cmd_config_speed_all_value1,
1450 (void *)&cmd_config_speed_all_item2,
1451 (void *)&cmd_config_speed_all_value2,
1456 /* *** configure speed for specific port *** */
1457 struct cmd_config_speed_specific {
1458 cmdline_fixed_string_t port;
1459 cmdline_fixed_string_t keyword;
1461 cmdline_fixed_string_t item1;
1462 cmdline_fixed_string_t item2;
1463 cmdline_fixed_string_t value1;
1464 cmdline_fixed_string_t value2;
1468 cmd_config_speed_specific_parsed(void *parsed_result,
1469 __attribute__((unused)) struct cmdline *cl,
1470 __attribute__((unused)) void *data)
1472 struct cmd_config_speed_specific *res = parsed_result;
1473 uint32_t link_speed;
1475 if (!all_ports_stopped()) {
1476 printf("Please stop all ports first\n");
1480 if (port_id_is_invalid(res->id, ENABLED_WARN))
1483 if (parse_and_check_speed_duplex(res->value1, res->value2,
1487 ports[res->id].dev_conf.link_speeds = link_speed;
1489 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1493 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1496 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1497 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1499 cmdline_parse_token_num_t cmd_config_speed_specific_id =
1500 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16);
1501 cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1502 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1504 cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1505 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1506 "10#100#1000#10000#25000#40000#50000#100000#auto");
1507 cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1508 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1510 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1511 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1514 cmdline_parse_inst_t cmd_config_speed_specific = {
1515 .f = cmd_config_speed_specific_parsed,
1517 .help_str = "port config <port_id> speed "
1518 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1521 (void *)&cmd_config_speed_specific_port,
1522 (void *)&cmd_config_speed_specific_keyword,
1523 (void *)&cmd_config_speed_specific_id,
1524 (void *)&cmd_config_speed_specific_item1,
1525 (void *)&cmd_config_speed_specific_value1,
1526 (void *)&cmd_config_speed_specific_item2,
1527 (void *)&cmd_config_speed_specific_value2,
1532 /* *** configure loopback for all ports *** */
1533 struct cmd_config_loopback_all {
1534 cmdline_fixed_string_t port;
1535 cmdline_fixed_string_t keyword;
1536 cmdline_fixed_string_t all;
1537 cmdline_fixed_string_t item;
1542 cmd_config_loopback_all_parsed(void *parsed_result,
1543 __attribute__((unused)) struct cmdline *cl,
1544 __attribute__((unused)) void *data)
1546 struct cmd_config_loopback_all *res = parsed_result;
1549 if (!all_ports_stopped()) {
1550 printf("Please stop all ports first\n");
1554 RTE_ETH_FOREACH_DEV(pid) {
1555 ports[pid].dev_conf.lpbk_mode = res->mode;
1558 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1561 cmdline_parse_token_string_t cmd_config_loopback_all_port =
1562 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1563 cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1564 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1566 cmdline_parse_token_string_t cmd_config_loopback_all_all =
1567 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1568 cmdline_parse_token_string_t cmd_config_loopback_all_item =
1569 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1571 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1572 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1574 cmdline_parse_inst_t cmd_config_loopback_all = {
1575 .f = cmd_config_loopback_all_parsed,
1577 .help_str = "port config all loopback <mode>",
1579 (void *)&cmd_config_loopback_all_port,
1580 (void *)&cmd_config_loopback_all_keyword,
1581 (void *)&cmd_config_loopback_all_all,
1582 (void *)&cmd_config_loopback_all_item,
1583 (void *)&cmd_config_loopback_all_mode,
1588 /* *** configure loopback for specific port *** */
1589 struct cmd_config_loopback_specific {
1590 cmdline_fixed_string_t port;
1591 cmdline_fixed_string_t keyword;
1593 cmdline_fixed_string_t item;
1598 cmd_config_loopback_specific_parsed(void *parsed_result,
1599 __attribute__((unused)) struct cmdline *cl,
1600 __attribute__((unused)) void *data)
1602 struct cmd_config_loopback_specific *res = parsed_result;
1604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1607 if (!port_is_stopped(res->port_id)) {
1608 printf("Please stop port %u first\n", res->port_id);
1612 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1614 cmd_reconfig_device_queue(res->port_id, 1, 1);
1618 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1619 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1621 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1624 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1625 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1627 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1630 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1631 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1634 cmdline_parse_inst_t cmd_config_loopback_specific = {
1635 .f = cmd_config_loopback_specific_parsed,
1637 .help_str = "port config <port_id> loopback <mode>",
1639 (void *)&cmd_config_loopback_specific_port,
1640 (void *)&cmd_config_loopback_specific_keyword,
1641 (void *)&cmd_config_loopback_specific_id,
1642 (void *)&cmd_config_loopback_specific_item,
1643 (void *)&cmd_config_loopback_specific_mode,
1648 /* *** configure txq/rxq, txd/rxd *** */
1649 struct cmd_config_rx_tx {
1650 cmdline_fixed_string_t port;
1651 cmdline_fixed_string_t keyword;
1652 cmdline_fixed_string_t all;
1653 cmdline_fixed_string_t name;
1658 cmd_config_rx_tx_parsed(void *parsed_result,
1659 __attribute__((unused)) struct cmdline *cl,
1660 __attribute__((unused)) void *data)
1662 struct cmd_config_rx_tx *res = parsed_result;
1664 if (!all_ports_stopped()) {
1665 printf("Please stop all ports first\n");
1668 if (!strcmp(res->name, "rxq")) {
1669 if (!res->value && !nb_txq) {
1670 printf("Warning: Either rx or tx queues should be non zero\n");
1673 if (check_nb_rxq(res->value) != 0)
1675 nb_rxq = res->value;
1677 else if (!strcmp(res->name, "txq")) {
1678 if (!res->value && !nb_rxq) {
1679 printf("Warning: Either rx or tx queues should be non zero\n");
1682 if (check_nb_txq(res->value) != 0)
1684 nb_txq = res->value;
1686 else if (!strcmp(res->name, "rxd")) {
1687 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) {
1688 printf("rxd %d invalid - must be > 0 && <= %d\n",
1689 res->value, RTE_TEST_RX_DESC_MAX);
1692 nb_rxd = res->value;
1693 } else if (!strcmp(res->name, "txd")) {
1694 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) {
1695 printf("txd %d invalid - must be > 0 && <= %d\n",
1696 res->value, RTE_TEST_TX_DESC_MAX);
1699 nb_txd = res->value;
1701 printf("Unknown parameter\n");
1709 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1712 cmdline_parse_token_string_t cmd_config_rx_tx_port =
1713 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1714 cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1715 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1716 cmdline_parse_token_string_t cmd_config_rx_tx_all =
1717 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1718 cmdline_parse_token_string_t cmd_config_rx_tx_name =
1719 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1721 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1722 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1724 cmdline_parse_inst_t cmd_config_rx_tx = {
1725 .f = cmd_config_rx_tx_parsed,
1727 .help_str = "port config all rxq|txq|rxd|txd <value>",
1729 (void *)&cmd_config_rx_tx_port,
1730 (void *)&cmd_config_rx_tx_keyword,
1731 (void *)&cmd_config_rx_tx_all,
1732 (void *)&cmd_config_rx_tx_name,
1733 (void *)&cmd_config_rx_tx_value,
1738 /* *** config max packet length *** */
1739 struct cmd_config_max_pkt_len_result {
1740 cmdline_fixed_string_t port;
1741 cmdline_fixed_string_t keyword;
1742 cmdline_fixed_string_t all;
1743 cmdline_fixed_string_t name;
1748 cmd_config_max_pkt_len_parsed(void *parsed_result,
1749 __attribute__((unused)) struct cmdline *cl,
1750 __attribute__((unused)) void *data)
1752 struct cmd_config_max_pkt_len_result *res = parsed_result;
1755 if (!all_ports_stopped()) {
1756 printf("Please stop all ports first\n");
1760 RTE_ETH_FOREACH_DEV(pid) {
1761 struct rte_port *port = &ports[pid];
1762 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1764 if (!strcmp(res->name, "max-pkt-len")) {
1765 if (res->value < ETHER_MIN_LEN) {
1766 printf("max-pkt-len can not be less than %d\n",
1770 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1773 port->dev_conf.rxmode.max_rx_pkt_len = res->value;
1774 if (res->value > ETHER_MAX_LEN)
1775 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
1777 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1778 port->dev_conf.rxmode.offloads = rx_offloads;
1780 printf("Unknown parameter\n");
1787 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1790 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1793 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1794 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1796 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1799 cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1800 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1802 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1803 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1806 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1807 .f = cmd_config_max_pkt_len_parsed,
1809 .help_str = "port config all max-pkt-len <value>",
1811 (void *)&cmd_config_max_pkt_len_port,
1812 (void *)&cmd_config_max_pkt_len_keyword,
1813 (void *)&cmd_config_max_pkt_len_all,
1814 (void *)&cmd_config_max_pkt_len_name,
1815 (void *)&cmd_config_max_pkt_len_value,
1820 /* *** configure port MTU *** */
1821 struct cmd_config_mtu_result {
1822 cmdline_fixed_string_t port;
1823 cmdline_fixed_string_t keyword;
1824 cmdline_fixed_string_t mtu;
1830 cmd_config_mtu_parsed(void *parsed_result,
1831 __attribute__((unused)) struct cmdline *cl,
1832 __attribute__((unused)) void *data)
1834 struct cmd_config_mtu_result *res = parsed_result;
1836 if (res->value < ETHER_MIN_LEN) {
1837 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1840 port_mtu_set(res->port_id, res->value);
1843 cmdline_parse_token_string_t cmd_config_mtu_port =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1846 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1849 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1852 cmdline_parse_token_num_t cmd_config_mtu_port_id =
1853 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16);
1854 cmdline_parse_token_num_t cmd_config_mtu_value =
1855 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
1857 cmdline_parse_inst_t cmd_config_mtu = {
1858 .f = cmd_config_mtu_parsed,
1860 .help_str = "port config mtu <port_id> <value>",
1862 (void *)&cmd_config_mtu_port,
1863 (void *)&cmd_config_mtu_keyword,
1864 (void *)&cmd_config_mtu_mtu,
1865 (void *)&cmd_config_mtu_port_id,
1866 (void *)&cmd_config_mtu_value,
1871 /* *** configure rx mode *** */
1872 struct cmd_config_rx_mode_flag {
1873 cmdline_fixed_string_t port;
1874 cmdline_fixed_string_t keyword;
1875 cmdline_fixed_string_t all;
1876 cmdline_fixed_string_t name;
1877 cmdline_fixed_string_t value;
1881 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1882 __attribute__((unused)) struct cmdline *cl,
1883 __attribute__((unused)) void *data)
1885 struct cmd_config_rx_mode_flag *res = parsed_result;
1888 if (!all_ports_stopped()) {
1889 printf("Please stop all ports first\n");
1893 RTE_ETH_FOREACH_DEV(pid) {
1894 struct rte_port *port;
1895 uint64_t rx_offloads;
1898 rx_offloads = port->dev_conf.rxmode.offloads;
1899 if (!strcmp(res->name, "crc-strip")) {
1900 if (!strcmp(res->value, "on")) {
1901 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
1902 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
1903 } else if (!strcmp(res->value, "off")) {
1904 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
1905 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP;
1907 printf("Unknown parameter\n");
1910 } else if (!strcmp(res->name, "scatter")) {
1911 if (!strcmp(res->value, "on")) {
1912 rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
1913 } else if (!strcmp(res->value, "off")) {
1914 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER;
1916 printf("Unknown parameter\n");
1919 } else if (!strcmp(res->name, "rx-cksum")) {
1920 if (!strcmp(res->value, "on"))
1921 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM;
1922 else if (!strcmp(res->value, "off"))
1923 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM;
1925 printf("Unknown parameter\n");
1928 } else if (!strcmp(res->name, "rx-timestamp")) {
1929 if (!strcmp(res->value, "on"))
1930 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP;
1931 else if (!strcmp(res->value, "off"))
1932 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP;
1934 printf("Unknown parameter\n");
1937 } else if (!strcmp(res->name, "hw-vlan")) {
1938 if (!strcmp(res->value, "on")) {
1939 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER |
1940 DEV_RX_OFFLOAD_VLAN_STRIP);
1941 } else if (!strcmp(res->value, "off")) {
1942 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER |
1943 DEV_RX_OFFLOAD_VLAN_STRIP);
1945 printf("Unknown parameter\n");
1948 } else if (!strcmp(res->name, "hw-vlan-filter")) {
1949 if (!strcmp(res->value, "on"))
1950 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER;
1951 else if (!strcmp(res->value, "off"))
1952 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER;
1954 printf("Unknown parameter\n");
1957 } else if (!strcmp(res->name, "hw-vlan-strip")) {
1958 if (!strcmp(res->value, "on"))
1959 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
1960 else if (!strcmp(res->value, "off"))
1961 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
1963 printf("Unknown parameter\n");
1966 } else if (!strcmp(res->name, "hw-vlan-extend")) {
1967 if (!strcmp(res->value, "on"))
1968 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND;
1969 else if (!strcmp(res->value, "off"))
1970 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND;
1972 printf("Unknown parameter\n");
1975 } else if (!strcmp(res->name, "drop-en")) {
1976 if (!strcmp(res->value, "on"))
1978 else if (!strcmp(res->value, "off"))
1981 printf("Unknown parameter\n");
1985 printf("Unknown parameter\n");
1988 port->dev_conf.rxmode.offloads = rx_offloads;
1993 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1996 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
1997 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
1998 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
1999 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2001 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2002 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2003 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2004 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2005 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#"
2006 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend");
2007 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2008 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2011 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2012 .f = cmd_config_rx_mode_flag_parsed,
2014 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|"
2015 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off",
2017 (void *)&cmd_config_rx_mode_flag_port,
2018 (void *)&cmd_config_rx_mode_flag_keyword,
2019 (void *)&cmd_config_rx_mode_flag_all,
2020 (void *)&cmd_config_rx_mode_flag_name,
2021 (void *)&cmd_config_rx_mode_flag_value,
2026 /* *** configure rss *** */
2027 struct cmd_config_rss {
2028 cmdline_fixed_string_t port;
2029 cmdline_fixed_string_t keyword;
2030 cmdline_fixed_string_t all;
2031 cmdline_fixed_string_t name;
2032 cmdline_fixed_string_t value;
2036 cmd_config_rss_parsed(void *parsed_result,
2037 __attribute__((unused)) struct cmdline *cl,
2038 __attribute__((unused)) void *data)
2040 struct cmd_config_rss *res = parsed_result;
2041 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2042 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2043 int use_default = 0;
2044 int all_updated = 1;
2048 if (!strcmp(res->value, "all"))
2049 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2050 ETH_RSS_UDP | ETH_RSS_SCTP |
2052 else if (!strcmp(res->value, "ip"))
2053 rss_conf.rss_hf = ETH_RSS_IP;
2054 else if (!strcmp(res->value, "udp"))
2055 rss_conf.rss_hf = ETH_RSS_UDP;
2056 else if (!strcmp(res->value, "tcp"))
2057 rss_conf.rss_hf = ETH_RSS_TCP;
2058 else if (!strcmp(res->value, "sctp"))
2059 rss_conf.rss_hf = ETH_RSS_SCTP;
2060 else if (!strcmp(res->value, "ether"))
2061 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD;
2062 else if (!strcmp(res->value, "port"))
2063 rss_conf.rss_hf = ETH_RSS_PORT;
2064 else if (!strcmp(res->value, "vxlan"))
2065 rss_conf.rss_hf = ETH_RSS_VXLAN;
2066 else if (!strcmp(res->value, "geneve"))
2067 rss_conf.rss_hf = ETH_RSS_GENEVE;
2068 else if (!strcmp(res->value, "nvgre"))
2069 rss_conf.rss_hf = ETH_RSS_NVGRE;
2070 else if (!strcmp(res->value, "none"))
2071 rss_conf.rss_hf = 0;
2072 else if (!strcmp(res->value, "default"))
2074 else if (isdigit(res->value[0]) && atoi(res->value) > 0 &&
2075 atoi(res->value) < 64)
2076 rss_conf.rss_hf = 1ULL << atoi(res->value);
2078 printf("Unknown parameter\n");
2081 rss_conf.rss_key = NULL;
2082 /* Update global configuration for RSS types. */
2083 RTE_ETH_FOREACH_DEV(i) {
2084 struct rte_eth_rss_conf local_rss_conf;
2086 rte_eth_dev_info_get(i, &dev_info);
2088 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2090 local_rss_conf = rss_conf;
2091 local_rss_conf.rss_hf = rss_conf.rss_hf &
2092 dev_info.flow_type_rss_offloads;
2093 if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2094 printf("Port %u modified RSS hash function based on hardware support,"
2095 "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2096 i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2098 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2101 printf("Configuration of RSS hash at ethernet port %d "
2102 "failed with error (%d): %s.\n",
2103 i, -diag, strerror(-diag));
2106 if (all_updated && !use_default)
2107 rss_hf = rss_conf.rss_hf;
2110 cmdline_parse_token_string_t cmd_config_rss_port =
2111 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2112 cmdline_parse_token_string_t cmd_config_rss_keyword =
2113 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2114 cmdline_parse_token_string_t cmd_config_rss_all =
2115 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2116 cmdline_parse_token_string_t cmd_config_rss_name =
2117 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2118 cmdline_parse_token_string_t cmd_config_rss_value =
2119 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2121 cmdline_parse_inst_t cmd_config_rss = {
2122 .f = cmd_config_rss_parsed,
2124 .help_str = "port config all rss "
2125 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2127 (void *)&cmd_config_rss_port,
2128 (void *)&cmd_config_rss_keyword,
2129 (void *)&cmd_config_rss_all,
2130 (void *)&cmd_config_rss_name,
2131 (void *)&cmd_config_rss_value,
2136 /* *** configure rss hash key *** */
2137 struct cmd_config_rss_hash_key {
2138 cmdline_fixed_string_t port;
2139 cmdline_fixed_string_t config;
2141 cmdline_fixed_string_t rss_hash_key;
2142 cmdline_fixed_string_t rss_type;
2143 cmdline_fixed_string_t key;
2147 hexa_digit_to_value(char hexa_digit)
2149 if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2150 return (uint8_t) (hexa_digit - '0');
2151 if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2152 return (uint8_t) ((hexa_digit - 'a') + 10);
2153 if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2154 return (uint8_t) ((hexa_digit - 'A') + 10);
2155 /* Invalid hexa digit */
2160 parse_and_check_key_hexa_digit(char *key, int idx)
2164 hexa_v = hexa_digit_to_value(key[idx]);
2166 printf("invalid key: character %c at position %d is not a "
2167 "valid hexa digit\n", key[idx], idx);
2172 cmd_config_rss_hash_key_parsed(void *parsed_result,
2173 __attribute__((unused)) struct cmdline *cl,
2174 __attribute__((unused)) void *data)
2176 struct cmd_config_rss_hash_key *res = parsed_result;
2177 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2181 struct rte_eth_dev_info dev_info;
2182 uint8_t hash_key_size;
2185 memset(&dev_info, 0, sizeof(dev_info));
2186 rte_eth_dev_info_get(res->port_id, &dev_info);
2187 if (dev_info.hash_key_size > 0 &&
2188 dev_info.hash_key_size <= sizeof(hash_key))
2189 hash_key_size = dev_info.hash_key_size;
2191 printf("dev_info did not provide a valid hash key size\n");
2194 /* Check the length of the RSS hash key */
2195 key_len = strlen(res->key);
2196 if (key_len != (hash_key_size * 2)) {
2197 printf("key length: %d invalid - key must be a string of %d"
2198 " hexa-decimal numbers\n",
2199 (int) key_len, hash_key_size * 2);
2202 /* Translate RSS hash key into binary representation */
2203 for (i = 0; i < hash_key_size; i++) {
2204 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2207 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2210 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2212 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2216 cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2217 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2218 cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2219 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2221 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2222 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16);
2223 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2224 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2225 rss_hash_key, "rss-hash-key");
2226 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2227 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2228 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2229 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2230 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2231 "ipv6-tcp-ex#ipv6-udp-ex");
2232 cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2233 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2235 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2236 .f = cmd_config_rss_hash_key_parsed,
2238 .help_str = "port config <port_id> rss-hash-key "
2239 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2240 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2241 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex "
2242 "<string of hex digits (variable length, NIC dependent)>",
2244 (void *)&cmd_config_rss_hash_key_port,
2245 (void *)&cmd_config_rss_hash_key_config,
2246 (void *)&cmd_config_rss_hash_key_port_id,
2247 (void *)&cmd_config_rss_hash_key_rss_hash_key,
2248 (void *)&cmd_config_rss_hash_key_rss_type,
2249 (void *)&cmd_config_rss_hash_key_value,
2254 /* *** configure port rxq/txq ring size *** */
2255 struct cmd_config_rxtx_ring_size {
2256 cmdline_fixed_string_t port;
2257 cmdline_fixed_string_t config;
2259 cmdline_fixed_string_t rxtxq;
2261 cmdline_fixed_string_t rsize;
2266 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2267 __attribute__((unused)) struct cmdline *cl,
2268 __attribute__((unused)) void *data)
2270 struct cmd_config_rxtx_ring_size *res = parsed_result;
2271 struct rte_port *port;
2274 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2277 if (res->portid == (portid_t)RTE_PORT_ALL) {
2278 printf("Invalid port id\n");
2282 port = &ports[res->portid];
2284 if (!strcmp(res->rxtxq, "rxq"))
2286 else if (!strcmp(res->rxtxq, "txq"))
2289 printf("Unknown parameter\n");
2293 if (isrx && rx_queue_id_is_invalid(res->qid))
2295 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2298 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2299 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2305 port->nb_rx_desc[res->qid] = res->size;
2307 port->nb_tx_desc[res->qid] = res->size;
2309 cmd_reconfig_device_queue(res->portid, 0, 1);
2312 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2313 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2315 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2318 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2319 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2321 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2322 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2324 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2325 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2327 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2328 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2329 rsize, "ring_size");
2330 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2331 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2334 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2335 .f = cmd_config_rxtx_ring_size_parsed,
2337 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2339 (void *)&cmd_config_rxtx_ring_size_port,
2340 (void *)&cmd_config_rxtx_ring_size_config,
2341 (void *)&cmd_config_rxtx_ring_size_portid,
2342 (void *)&cmd_config_rxtx_ring_size_rxtxq,
2343 (void *)&cmd_config_rxtx_ring_size_qid,
2344 (void *)&cmd_config_rxtx_ring_size_rsize,
2345 (void *)&cmd_config_rxtx_ring_size_size,
2350 /* *** configure port rxq/txq start/stop *** */
2351 struct cmd_config_rxtx_queue {
2352 cmdline_fixed_string_t port;
2354 cmdline_fixed_string_t rxtxq;
2356 cmdline_fixed_string_t opname;
2360 cmd_config_rxtx_queue_parsed(void *parsed_result,
2361 __attribute__((unused)) struct cmdline *cl,
2362 __attribute__((unused)) void *data)
2364 struct cmd_config_rxtx_queue *res = parsed_result;
2369 if (test_done == 0) {
2370 printf("Please stop forwarding first\n");
2374 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2377 if (port_is_started(res->portid) != 1) {
2378 printf("Please start port %u first\n", res->portid);
2382 if (!strcmp(res->rxtxq, "rxq"))
2384 else if (!strcmp(res->rxtxq, "txq"))
2387 printf("Unknown parameter\n");
2391 if (isrx && rx_queue_id_is_invalid(res->qid))
2393 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2396 if (!strcmp(res->opname, "start"))
2398 else if (!strcmp(res->opname, "stop"))
2401 printf("Unknown parameter\n");
2405 if (isstart && isrx)
2406 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2407 else if (!isstart && isrx)
2408 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2409 else if (isstart && !isrx)
2410 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2412 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2414 if (ret == -ENOTSUP)
2415 printf("Function not supported in PMD driver\n");
2418 cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2419 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2420 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2421 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16);
2422 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2423 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2424 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2425 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16);
2426 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2427 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2430 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2431 .f = cmd_config_rxtx_queue_parsed,
2433 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2435 (void *)&cmd_config_rxtx_queue_port,
2436 (void *)&cmd_config_rxtx_queue_portid,
2437 (void *)&cmd_config_rxtx_queue_rxtxq,
2438 (void *)&cmd_config_rxtx_queue_qid,
2439 (void *)&cmd_config_rxtx_queue_opname,
2444 /* *** configure port rxq/txq setup *** */
2445 struct cmd_setup_rxtx_queue {
2446 cmdline_fixed_string_t port;
2448 cmdline_fixed_string_t rxtxq;
2450 cmdline_fixed_string_t setup;
2453 /* Common CLI fields for queue setup */
2454 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2455 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2456 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2457 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16);
2458 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2459 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2460 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2461 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16);
2462 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2463 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2466 cmd_setup_rxtx_queue_parsed(
2467 void *parsed_result,
2468 __attribute__((unused)) struct cmdline *cl,
2469 __attribute__((unused)) void *data)
2471 struct cmd_setup_rxtx_queue *res = parsed_result;
2472 struct rte_port *port;
2473 struct rte_mempool *mp;
2474 unsigned int socket_id;
2478 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2481 if (res->portid == (portid_t)RTE_PORT_ALL) {
2482 printf("Invalid port id\n");
2486 if (!strcmp(res->rxtxq, "rxq"))
2488 else if (!strcmp(res->rxtxq, "txq"))
2491 printf("Unknown parameter\n");
2495 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2496 printf("Invalid rx queue\n");
2498 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2499 printf("Invalid tx queue\n");
2503 port = &ports[res->portid];
2505 socket_id = rxring_numa[res->portid];
2506 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2507 socket_id = port->socket_id;
2509 mp = mbuf_pool_find(socket_id);
2511 printf("Failed to setup RX queue: "
2512 "No mempool allocation"
2513 " on the socket %d\n",
2514 rxring_numa[res->portid]);
2517 ret = rte_eth_rx_queue_setup(res->portid,
2519 port->nb_rx_desc[res->qid],
2521 &port->rx_conf[res->qid],
2524 printf("Failed to setup RX queue\n");
2526 socket_id = txring_numa[res->portid];
2527 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2528 socket_id = port->socket_id;
2530 ret = rte_eth_tx_queue_setup(res->portid,
2532 port->nb_tx_desc[res->qid],
2534 &port->tx_conf[res->qid]);
2536 printf("Failed to setup TX queue\n");
2540 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2541 .f = cmd_setup_rxtx_queue_parsed,
2543 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2545 (void *)&cmd_setup_rxtx_queue_port,
2546 (void *)&cmd_setup_rxtx_queue_portid,
2547 (void *)&cmd_setup_rxtx_queue_rxtxq,
2548 (void *)&cmd_setup_rxtx_queue_qid,
2549 (void *)&cmd_setup_rxtx_queue_setup,
2555 /* *** Configure RSS RETA *** */
2556 struct cmd_config_rss_reta {
2557 cmdline_fixed_string_t port;
2558 cmdline_fixed_string_t keyword;
2560 cmdline_fixed_string_t name;
2561 cmdline_fixed_string_t list_name;
2562 cmdline_fixed_string_t list_of_items;
2566 parse_reta_config(const char *str,
2567 struct rte_eth_rss_reta_entry64 *reta_conf,
2568 uint16_t nb_entries)
2572 uint16_t hash_index, idx, shift;
2575 const char *p, *p0 = str;
2582 unsigned long int_fld[_NUM_FLD];
2583 char *str_fld[_NUM_FLD];
2585 while ((p = strchr(p0,'(')) != NULL) {
2587 if((p0 = strchr(p,')')) == NULL)
2591 if(size >= sizeof(s))
2594 snprintf(s, sizeof(s), "%.*s", size, p);
2595 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2597 for (i = 0; i < _NUM_FLD; i++) {
2599 int_fld[i] = strtoul(str_fld[i], &end, 0);
2600 if (errno != 0 || end == str_fld[i] ||
2605 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2606 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2608 if (hash_index >= nb_entries) {
2609 printf("Invalid RETA hash index=%d\n", hash_index);
2613 idx = hash_index / RTE_RETA_GROUP_SIZE;
2614 shift = hash_index % RTE_RETA_GROUP_SIZE;
2615 reta_conf[idx].mask |= (1ULL << shift);
2616 reta_conf[idx].reta[shift] = nb_queue;
2623 cmd_set_rss_reta_parsed(void *parsed_result,
2624 __attribute__((unused)) struct cmdline *cl,
2625 __attribute__((unused)) void *data)
2628 struct rte_eth_dev_info dev_info;
2629 struct rte_eth_rss_reta_entry64 reta_conf[8];
2630 struct cmd_config_rss_reta *res = parsed_result;
2632 memset(&dev_info, 0, sizeof(dev_info));
2633 rte_eth_dev_info_get(res->port_id, &dev_info);
2634 if (dev_info.reta_size == 0) {
2635 printf("Redirection table size is 0 which is "
2636 "invalid for RSS\n");
2639 printf("The reta size of port %d is %u\n",
2640 res->port_id, dev_info.reta_size);
2641 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) {
2642 printf("Currently do not support more than %u entries of "
2643 "redirection table\n", ETH_RSS_RETA_SIZE_512);
2647 memset(reta_conf, 0, sizeof(reta_conf));
2648 if (!strcmp(res->list_name, "reta")) {
2649 if (parse_reta_config(res->list_of_items, reta_conf,
2650 dev_info.reta_size)) {
2651 printf("Invalid RSS Redirection Table "
2652 "config entered\n");
2655 ret = rte_eth_dev_rss_reta_update(res->port_id,
2656 reta_conf, dev_info.reta_size);
2658 printf("Bad redirection table parameter, "
2659 "return code = %d \n", ret);
2663 cmdline_parse_token_string_t cmd_config_rss_reta_port =
2664 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2665 cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2666 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2667 cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2668 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16);
2669 cmdline_parse_token_string_t cmd_config_rss_reta_name =
2670 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2671 cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2672 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2673 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2674 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2676 cmdline_parse_inst_t cmd_config_rss_reta = {
2677 .f = cmd_set_rss_reta_parsed,
2679 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2681 (void *)&cmd_config_rss_reta_port,
2682 (void *)&cmd_config_rss_reta_keyword,
2683 (void *)&cmd_config_rss_reta_port_id,
2684 (void *)&cmd_config_rss_reta_name,
2685 (void *)&cmd_config_rss_reta_list_name,
2686 (void *)&cmd_config_rss_reta_list_of_items,
2691 /* *** SHOW PORT RETA INFO *** */
2692 struct cmd_showport_reta {
2693 cmdline_fixed_string_t show;
2694 cmdline_fixed_string_t port;
2696 cmdline_fixed_string_t rss;
2697 cmdline_fixed_string_t reta;
2699 cmdline_fixed_string_t list_of_items;
2703 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2704 uint16_t nb_entries,
2708 const char *p, *p0 = str;
2713 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2714 RTE_RETA_GROUP_SIZE;
2717 p = strchr(p0, '(');
2721 p0 = strchr(p, ')');
2725 if (size >= sizeof(s)) {
2726 printf("The string size exceeds the internal buffer size\n");
2729 snprintf(s, sizeof(s), "%.*s", size, p);
2730 ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
2731 if (ret <= 0 || ret != num) {
2732 printf("The bits of masks do not match the number of "
2733 "reta entries: %u\n", num);
2736 for (i = 0; i < ret; i++)
2737 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2743 cmd_showport_reta_parsed(void *parsed_result,
2744 __attribute__((unused)) struct cmdline *cl,
2745 __attribute__((unused)) void *data)
2747 struct cmd_showport_reta *res = parsed_result;
2748 struct rte_eth_rss_reta_entry64 reta_conf[8];
2749 struct rte_eth_dev_info dev_info;
2750 uint16_t max_reta_size;
2752 memset(&dev_info, 0, sizeof(dev_info));
2753 rte_eth_dev_info_get(res->port_id, &dev_info);
2754 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512);
2755 if (res->size == 0 || res->size > max_reta_size) {
2756 printf("Invalid redirection table size: %u (1-%u)\n",
2757 res->size, max_reta_size);
2761 memset(reta_conf, 0, sizeof(reta_conf));
2762 if (showport_parse_reta_config(reta_conf, res->size,
2763 res->list_of_items) < 0) {
2764 printf("Invalid string: %s for reta masks\n",
2765 res->list_of_items);
2768 port_rss_reta_info(res->port_id, reta_conf, res->size);
2771 cmdline_parse_token_string_t cmd_showport_reta_show =
2772 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
2773 cmdline_parse_token_string_t cmd_showport_reta_port =
2774 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
2775 cmdline_parse_token_num_t cmd_showport_reta_port_id =
2776 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16);
2777 cmdline_parse_token_string_t cmd_showport_reta_rss =
2778 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
2779 cmdline_parse_token_string_t cmd_showport_reta_reta =
2780 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
2781 cmdline_parse_token_num_t cmd_showport_reta_size =
2782 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16);
2783 cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
2784 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
2785 list_of_items, NULL);
2787 cmdline_parse_inst_t cmd_showport_reta = {
2788 .f = cmd_showport_reta_parsed,
2790 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2792 (void *)&cmd_showport_reta_show,
2793 (void *)&cmd_showport_reta_port,
2794 (void *)&cmd_showport_reta_port_id,
2795 (void *)&cmd_showport_reta_rss,
2796 (void *)&cmd_showport_reta_reta,
2797 (void *)&cmd_showport_reta_size,
2798 (void *)&cmd_showport_reta_list_of_items,
2803 /* *** Show RSS hash configuration *** */
2804 struct cmd_showport_rss_hash {
2805 cmdline_fixed_string_t show;
2806 cmdline_fixed_string_t port;
2808 cmdline_fixed_string_t rss_hash;
2809 cmdline_fixed_string_t rss_type;
2810 cmdline_fixed_string_t key; /* optional argument */
2813 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2814 __attribute__((unused)) struct cmdline *cl,
2817 struct cmd_showport_rss_hash *res = parsed_result;
2819 port_rss_hash_conf_show(res->port_id, res->rss_type,
2820 show_rss_key != NULL);
2823 cmdline_parse_token_string_t cmd_showport_rss_hash_show =
2824 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
2825 cmdline_parse_token_string_t cmd_showport_rss_hash_port =
2826 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
2827 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
2828 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16);
2829 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
2830 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
2832 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info =
2833 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type,
2834 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2835 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2836 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2837 "ipv6-tcp-ex#ipv6-udp-ex");
2838 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
2839 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
2841 cmdline_parse_inst_t cmd_showport_rss_hash = {
2842 .f = cmd_showport_rss_hash_parsed,
2844 .help_str = "show port <port_id> rss-hash "
2845 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2846 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2847 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex",
2849 (void *)&cmd_showport_rss_hash_show,
2850 (void *)&cmd_showport_rss_hash_port,
2851 (void *)&cmd_showport_rss_hash_port_id,
2852 (void *)&cmd_showport_rss_hash_rss_hash,
2853 (void *)&cmd_showport_rss_hash_rss_hash_info,
2858 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2859 .f = cmd_showport_rss_hash_parsed,
2861 .help_str = "show port <port_id> rss-hash "
2862 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2863 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2864 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key",
2866 (void *)&cmd_showport_rss_hash_show,
2867 (void *)&cmd_showport_rss_hash_port,
2868 (void *)&cmd_showport_rss_hash_port_id,
2869 (void *)&cmd_showport_rss_hash_rss_hash,
2870 (void *)&cmd_showport_rss_hash_rss_hash_info,
2871 (void *)&cmd_showport_rss_hash_rss_key,
2876 /* *** Configure DCB *** */
2877 struct cmd_config_dcb {
2878 cmdline_fixed_string_t port;
2879 cmdline_fixed_string_t config;
2881 cmdline_fixed_string_t dcb;
2882 cmdline_fixed_string_t vt;
2883 cmdline_fixed_string_t vt_en;
2885 cmdline_fixed_string_t pfc;
2886 cmdline_fixed_string_t pfc_en;
2890 cmd_config_dcb_parsed(void *parsed_result,
2891 __attribute__((unused)) struct cmdline *cl,
2892 __attribute__((unused)) void *data)
2894 struct cmd_config_dcb *res = parsed_result;
2895 portid_t port_id = res->port_id;
2896 struct rte_port *port;
2900 port = &ports[port_id];
2901 /** Check if the port is not started **/
2902 if (port->port_status != RTE_PORT_STOPPED) {
2903 printf("Please stop port %d first\n", port_id);
2907 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
2908 printf("The invalid number of traffic class,"
2909 " only 4 or 8 allowed.\n");
2913 if (nb_fwd_lcores < res->num_tcs) {
2914 printf("nb_cores shouldn't be less than number of TCs.\n");
2917 if (!strncmp(res->pfc_en, "on", 2))
2922 /* DCB in VT mode */
2923 if (!strncmp(res->vt_en, "on", 2))
2924 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
2925 (enum rte_eth_nb_tcs)res->num_tcs,
2928 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2929 (enum rte_eth_nb_tcs)res->num_tcs,
2934 printf("Cannot initialize network ports.\n");
2938 cmd_reconfig_device_queue(port_id, 1, 1);
2941 cmdline_parse_token_string_t cmd_config_dcb_port =
2942 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
2943 cmdline_parse_token_string_t cmd_config_dcb_config =
2944 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
2945 cmdline_parse_token_num_t cmd_config_dcb_port_id =
2946 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16);
2947 cmdline_parse_token_string_t cmd_config_dcb_dcb =
2948 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
2949 cmdline_parse_token_string_t cmd_config_dcb_vt =
2950 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
2951 cmdline_parse_token_string_t cmd_config_dcb_vt_en =
2952 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
2953 cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
2954 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8);
2955 cmdline_parse_token_string_t cmd_config_dcb_pfc=
2956 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
2957 cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
2958 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
2960 cmdline_parse_inst_t cmd_config_dcb = {
2961 .f = cmd_config_dcb_parsed,
2963 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2965 (void *)&cmd_config_dcb_port,
2966 (void *)&cmd_config_dcb_config,
2967 (void *)&cmd_config_dcb_port_id,
2968 (void *)&cmd_config_dcb_dcb,
2969 (void *)&cmd_config_dcb_vt,
2970 (void *)&cmd_config_dcb_vt_en,
2971 (void *)&cmd_config_dcb_num_tcs,
2972 (void *)&cmd_config_dcb_pfc,
2973 (void *)&cmd_config_dcb_pfc_en,
2978 /* *** configure number of packets per burst *** */
2979 struct cmd_config_burst {
2980 cmdline_fixed_string_t port;
2981 cmdline_fixed_string_t keyword;
2982 cmdline_fixed_string_t all;
2983 cmdline_fixed_string_t name;
2988 cmd_config_burst_parsed(void *parsed_result,
2989 __attribute__((unused)) struct cmdline *cl,
2990 __attribute__((unused)) void *data)
2992 struct cmd_config_burst *res = parsed_result;
2993 struct rte_eth_dev_info dev_info;
2994 uint16_t rec_nb_pkts;
2996 if (!all_ports_stopped()) {
2997 printf("Please stop all ports first\n");
3001 if (!strcmp(res->name, "burst")) {
3002 if (res->value == 0) {
3003 /* If user gives a value of zero, query the PMD for
3004 * its recommended Rx burst size. Testpmd uses a single
3005 * size for all ports, so assume all ports are the same
3006 * NIC model and use the values from Port 0.
3008 rte_eth_dev_info_get(0, &dev_info);
3009 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3011 if (rec_nb_pkts == 0) {
3012 printf("PMD does not recommend a burst size.\n"
3013 "User provided value must be between"
3014 " 1 and %d\n", MAX_PKT_BURST);
3016 } else if (rec_nb_pkts > MAX_PKT_BURST) {
3017 printf("PMD recommended burst size of %d"
3018 " exceeds maximum value of %d\n",
3019 rec_nb_pkts, MAX_PKT_BURST);
3022 printf("Using PMD-provided burst value of %d\n",
3024 nb_pkt_per_burst = rec_nb_pkts;
3025 } else if (res->value > MAX_PKT_BURST) {
3026 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST);
3029 nb_pkt_per_burst = res->value;
3031 printf("Unknown parameter\n");
3037 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3040 cmdline_parse_token_string_t cmd_config_burst_port =
3041 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3042 cmdline_parse_token_string_t cmd_config_burst_keyword =
3043 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3044 cmdline_parse_token_string_t cmd_config_burst_all =
3045 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3046 cmdline_parse_token_string_t cmd_config_burst_name =
3047 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3048 cmdline_parse_token_num_t cmd_config_burst_value =
3049 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16);
3051 cmdline_parse_inst_t cmd_config_burst = {
3052 .f = cmd_config_burst_parsed,
3054 .help_str = "port config all burst <value>",
3056 (void *)&cmd_config_burst_port,
3057 (void *)&cmd_config_burst_keyword,
3058 (void *)&cmd_config_burst_all,
3059 (void *)&cmd_config_burst_name,
3060 (void *)&cmd_config_burst_value,
3065 /* *** configure rx/tx queues *** */
3066 struct cmd_config_thresh {
3067 cmdline_fixed_string_t port;
3068 cmdline_fixed_string_t keyword;
3069 cmdline_fixed_string_t all;
3070 cmdline_fixed_string_t name;
3075 cmd_config_thresh_parsed(void *parsed_result,
3076 __attribute__((unused)) struct cmdline *cl,
3077 __attribute__((unused)) void *data)
3079 struct cmd_config_thresh *res = parsed_result;
3081 if (!all_ports_stopped()) {
3082 printf("Please stop all ports first\n");
3086 if (!strcmp(res->name, "txpt"))
3087 tx_pthresh = res->value;
3088 else if(!strcmp(res->name, "txht"))
3089 tx_hthresh = res->value;
3090 else if(!strcmp(res->name, "txwt"))
3091 tx_wthresh = res->value;
3092 else if(!strcmp(res->name, "rxpt"))
3093 rx_pthresh = res->value;
3094 else if(!strcmp(res->name, "rxht"))
3095 rx_hthresh = res->value;
3096 else if(!strcmp(res->name, "rxwt"))
3097 rx_wthresh = res->value;
3099 printf("Unknown parameter\n");
3105 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3108 cmdline_parse_token_string_t cmd_config_thresh_port =
3109 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3110 cmdline_parse_token_string_t cmd_config_thresh_keyword =
3111 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3112 cmdline_parse_token_string_t cmd_config_thresh_all =
3113 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3114 cmdline_parse_token_string_t cmd_config_thresh_name =
3115 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3116 "txpt#txht#txwt#rxpt#rxht#rxwt");
3117 cmdline_parse_token_num_t cmd_config_thresh_value =
3118 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8);
3120 cmdline_parse_inst_t cmd_config_thresh = {
3121 .f = cmd_config_thresh_parsed,
3123 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3125 (void *)&cmd_config_thresh_port,
3126 (void *)&cmd_config_thresh_keyword,
3127 (void *)&cmd_config_thresh_all,
3128 (void *)&cmd_config_thresh_name,
3129 (void *)&cmd_config_thresh_value,
3134 /* *** configure free/rs threshold *** */
3135 struct cmd_config_threshold {
3136 cmdline_fixed_string_t port;
3137 cmdline_fixed_string_t keyword;
3138 cmdline_fixed_string_t all;
3139 cmdline_fixed_string_t name;
3144 cmd_config_threshold_parsed(void *parsed_result,
3145 __attribute__((unused)) struct cmdline *cl,
3146 __attribute__((unused)) void *data)
3148 struct cmd_config_threshold *res = parsed_result;
3150 if (!all_ports_stopped()) {
3151 printf("Please stop all ports first\n");
3155 if (!strcmp(res->name, "txfreet"))
3156 tx_free_thresh = res->value;
3157 else if (!strcmp(res->name, "txrst"))
3158 tx_rs_thresh = res->value;
3159 else if (!strcmp(res->name, "rxfreet"))
3160 rx_free_thresh = res->value;
3162 printf("Unknown parameter\n");
3168 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3171 cmdline_parse_token_string_t cmd_config_threshold_port =
3172 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3173 cmdline_parse_token_string_t cmd_config_threshold_keyword =
3174 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3176 cmdline_parse_token_string_t cmd_config_threshold_all =
3177 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3178 cmdline_parse_token_string_t cmd_config_threshold_name =
3179 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3180 "txfreet#txrst#rxfreet");
3181 cmdline_parse_token_num_t cmd_config_threshold_value =
3182 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16);
3184 cmdline_parse_inst_t cmd_config_threshold = {
3185 .f = cmd_config_threshold_parsed,
3187 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3189 (void *)&cmd_config_threshold_port,
3190 (void *)&cmd_config_threshold_keyword,
3191 (void *)&cmd_config_threshold_all,
3192 (void *)&cmd_config_threshold_name,
3193 (void *)&cmd_config_threshold_value,
3199 struct cmd_stop_result {
3200 cmdline_fixed_string_t stop;
3203 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3204 __attribute__((unused)) struct cmdline *cl,
3205 __attribute__((unused)) void *data)
3207 stop_packet_forwarding();
3210 cmdline_parse_token_string_t cmd_stop_stop =
3211 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3213 cmdline_parse_inst_t cmd_stop = {
3214 .f = cmd_stop_parsed,
3216 .help_str = "stop: Stop packet forwarding",
3218 (void *)&cmd_stop_stop,
3223 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3226 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3227 unsigned int *parsed_items, int check_unique_values)
3229 unsigned int nb_item;
3237 * First parse all items in the list and store their value.
3242 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3244 if ((c >= '0') && (c <= '9')) {
3245 value = (unsigned int) (value * 10 + (c - '0'));
3250 printf("character %c is not a decimal digit\n", c);
3254 printf("No valid value before comma\n");
3257 if (nb_item < max_items) {
3258 parsed_items[nb_item] = value;
3264 if (nb_item >= max_items) {
3265 printf("Number of %s = %u > %u (maximum items)\n",
3266 item_name, nb_item + 1, max_items);
3269 parsed_items[nb_item++] = value;
3270 if (! check_unique_values)
3274 * Then, check that all values in the list are differents.
3275 * No optimization here...
3277 for (i = 0; i < nb_item; i++) {
3278 for (j = i + 1; j < nb_item; j++) {
3279 if (parsed_items[j] == parsed_items[i]) {
3280 printf("duplicated %s %u at index %u and %u\n",
3281 item_name, parsed_items[i], i, j);
3289 struct cmd_set_list_result {
3290 cmdline_fixed_string_t cmd_keyword;
3291 cmdline_fixed_string_t list_name;
3292 cmdline_fixed_string_t list_of_items;
3295 static void cmd_set_list_parsed(void *parsed_result,
3296 __attribute__((unused)) struct cmdline *cl,
3297 __attribute__((unused)) void *data)
3299 struct cmd_set_list_result *res;
3301 unsigned int lcorelist[RTE_MAX_LCORE];
3302 unsigned int portlist[RTE_MAX_ETHPORTS];
3304 unsigned int nb_item;
3306 if (test_done == 0) {
3307 printf("Please stop forwarding first\n");
3311 res = parsed_result;
3312 if (!strcmp(res->list_name, "corelist")) {
3313 nb_item = parse_item_list(res->list_of_items, "core",
3315 parsed_items.lcorelist, 1);
3317 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3322 if (!strcmp(res->list_name, "portlist")) {
3323 nb_item = parse_item_list(res->list_of_items, "port",
3325 parsed_items.portlist, 1);
3327 set_fwd_ports_list(parsed_items.portlist, nb_item);
3333 cmdline_parse_token_string_t cmd_set_list_keyword =
3334 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3336 cmdline_parse_token_string_t cmd_set_list_name =
3337 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3338 "corelist#portlist");
3339 cmdline_parse_token_string_t cmd_set_list_of_items =
3340 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3343 cmdline_parse_inst_t cmd_set_fwd_list = {
3344 .f = cmd_set_list_parsed,
3346 .help_str = "set corelist|portlist <list0[,list1]*>",
3348 (void *)&cmd_set_list_keyword,
3349 (void *)&cmd_set_list_name,
3350 (void *)&cmd_set_list_of_items,
3355 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3357 struct cmd_setmask_result {
3358 cmdline_fixed_string_t set;
3359 cmdline_fixed_string_t mask;
3363 static void cmd_set_mask_parsed(void *parsed_result,
3364 __attribute__((unused)) struct cmdline *cl,
3365 __attribute__((unused)) void *data)
3367 struct cmd_setmask_result *res = parsed_result;
3369 if (test_done == 0) {
3370 printf("Please stop forwarding first\n");
3373 if (!strcmp(res->mask, "coremask")) {
3374 set_fwd_lcores_mask(res->hexavalue);
3376 } else if (!strcmp(res->mask, "portmask")) {
3377 set_fwd_ports_mask(res->hexavalue);
3382 cmdline_parse_token_string_t cmd_setmask_set =
3383 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3384 cmdline_parse_token_string_t cmd_setmask_mask =
3385 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3386 "coremask#portmask");
3387 cmdline_parse_token_num_t cmd_setmask_value =
3388 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64);
3390 cmdline_parse_inst_t cmd_set_fwd_mask = {
3391 .f = cmd_set_mask_parsed,
3393 .help_str = "set coremask|portmask <hexadecimal value>",
3395 (void *)&cmd_setmask_set,
3396 (void *)&cmd_setmask_mask,
3397 (void *)&cmd_setmask_value,
3403 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3405 struct cmd_set_result {
3406 cmdline_fixed_string_t set;
3407 cmdline_fixed_string_t what;
3411 static void cmd_set_parsed(void *parsed_result,
3412 __attribute__((unused)) struct cmdline *cl,
3413 __attribute__((unused)) void *data)
3415 struct cmd_set_result *res = parsed_result;
3416 if (!strcmp(res->what, "nbport")) {
3417 set_fwd_ports_number(res->value);
3419 } else if (!strcmp(res->what, "nbcore")) {
3420 set_fwd_lcores_number(res->value);
3422 } else if (!strcmp(res->what, "burst"))
3423 set_nb_pkt_per_burst(res->value);
3424 else if (!strcmp(res->what, "verbose"))
3425 set_verbose_level(res->value);
3428 cmdline_parse_token_string_t cmd_set_set =
3429 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3430 cmdline_parse_token_string_t cmd_set_what =
3431 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3432 "nbport#nbcore#burst#verbose");
3433 cmdline_parse_token_num_t cmd_set_value =
3434 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16);
3436 cmdline_parse_inst_t cmd_set_numbers = {
3437 .f = cmd_set_parsed,
3439 .help_str = "set nbport|nbcore|burst|verbose <value>",
3441 (void *)&cmd_set_set,
3442 (void *)&cmd_set_what,
3443 (void *)&cmd_set_value,
3448 /* *** SET LOG LEVEL CONFIGURATION *** */
3450 struct cmd_set_log_result {
3451 cmdline_fixed_string_t set;
3452 cmdline_fixed_string_t log;
3453 cmdline_fixed_string_t type;
3458 cmd_set_log_parsed(void *parsed_result,
3459 __attribute__((unused)) struct cmdline *cl,
3460 __attribute__((unused)) void *data)
3462 struct cmd_set_log_result *res;
3465 res = parsed_result;
3466 if (!strcmp(res->type, "global"))
3467 rte_log_set_global_level(res->level);
3469 ret = rte_log_set_level_regexp(res->type, res->level);
3471 printf("Unable to set log level\n");
3475 cmdline_parse_token_string_t cmd_set_log_set =
3476 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3477 cmdline_parse_token_string_t cmd_set_log_log =
3478 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3479 cmdline_parse_token_string_t cmd_set_log_type =
3480 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3481 cmdline_parse_token_num_t cmd_set_log_level =
3482 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32);
3484 cmdline_parse_inst_t cmd_set_log = {
3485 .f = cmd_set_log_parsed,
3487 .help_str = "set log global|<type> <level>",
3489 (void *)&cmd_set_log_set,
3490 (void *)&cmd_set_log_log,
3491 (void *)&cmd_set_log_type,
3492 (void *)&cmd_set_log_level,
3497 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3499 struct cmd_set_txpkts_result {
3500 cmdline_fixed_string_t cmd_keyword;
3501 cmdline_fixed_string_t txpkts;
3502 cmdline_fixed_string_t seg_lengths;
3506 cmd_set_txpkts_parsed(void *parsed_result,
3507 __attribute__((unused)) struct cmdline *cl,
3508 __attribute__((unused)) void *data)
3510 struct cmd_set_txpkts_result *res;
3511 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3512 unsigned int nb_segs;
3514 res = parsed_result;
3515 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3516 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3518 set_tx_pkt_segments(seg_lengths, nb_segs);
3521 cmdline_parse_token_string_t cmd_set_txpkts_keyword =
3522 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3523 cmd_keyword, "set");
3524 cmdline_parse_token_string_t cmd_set_txpkts_name =
3525 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3527 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3528 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3531 cmdline_parse_inst_t cmd_set_txpkts = {
3532 .f = cmd_set_txpkts_parsed,
3534 .help_str = "set txpkts <len0[,len1]*>",
3536 (void *)&cmd_set_txpkts_keyword,
3537 (void *)&cmd_set_txpkts_name,
3538 (void *)&cmd_set_txpkts_lengths,
3543 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3545 struct cmd_set_txsplit_result {
3546 cmdline_fixed_string_t cmd_keyword;
3547 cmdline_fixed_string_t txsplit;
3548 cmdline_fixed_string_t mode;
3552 cmd_set_txsplit_parsed(void *parsed_result,
3553 __attribute__((unused)) struct cmdline *cl,
3554 __attribute__((unused)) void *data)
3556 struct cmd_set_txsplit_result *res;
3558 res = parsed_result;
3559 set_tx_pkt_split(res->mode);
3562 cmdline_parse_token_string_t cmd_set_txsplit_keyword =
3563 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3564 cmd_keyword, "set");
3565 cmdline_parse_token_string_t cmd_set_txsplit_name =
3566 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3567 txsplit, "txsplit");
3568 cmdline_parse_token_string_t cmd_set_txsplit_mode =
3569 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
3572 cmdline_parse_inst_t cmd_set_txsplit = {
3573 .f = cmd_set_txsplit_parsed,
3575 .help_str = "set txsplit on|off|rand",
3577 (void *)&cmd_set_txsplit_keyword,
3578 (void *)&cmd_set_txsplit_name,
3579 (void *)&cmd_set_txsplit_mode,
3584 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
3585 struct cmd_rx_vlan_filter_all_result {
3586 cmdline_fixed_string_t rx_vlan;
3587 cmdline_fixed_string_t what;
3588 cmdline_fixed_string_t all;
3593 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3594 __attribute__((unused)) struct cmdline *cl,
3595 __attribute__((unused)) void *data)
3597 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3599 if (!strcmp(res->what, "add"))
3600 rx_vlan_all_filter_set(res->port_id, 1);
3602 rx_vlan_all_filter_set(res->port_id, 0);
3605 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
3606 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3607 rx_vlan, "rx_vlan");
3608 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
3609 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3611 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3612 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3614 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3615 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3618 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3619 .f = cmd_rx_vlan_filter_all_parsed,
3621 .help_str = "rx_vlan add|rm all <port_id>: "
3622 "Add/Remove all identifiers to/from the set of VLAN "
3623 "identifiers filtered by a port",
3625 (void *)&cmd_rx_vlan_filter_all_rx_vlan,
3626 (void *)&cmd_rx_vlan_filter_all_what,
3627 (void *)&cmd_rx_vlan_filter_all_all,
3628 (void *)&cmd_rx_vlan_filter_all_portid,
3633 /* *** VLAN OFFLOAD SET ON A PORT *** */
3634 struct cmd_vlan_offload_result {
3635 cmdline_fixed_string_t vlan;
3636 cmdline_fixed_string_t set;
3637 cmdline_fixed_string_t vlan_type;
3638 cmdline_fixed_string_t what;
3639 cmdline_fixed_string_t on;
3640 cmdline_fixed_string_t port_id;
3644 cmd_vlan_offload_parsed(void *parsed_result,
3645 __attribute__((unused)) struct cmdline *cl,
3646 __attribute__((unused)) void *data)
3649 struct cmd_vlan_offload_result *res = parsed_result;
3652 portid_t port_id = 0;
3656 len = strnlen(str, STR_TOKEN_SIZE);
3658 /* Get port_id first */
3666 tmp = strtoul(str, NULL, 0);
3667 /* If port_id greater that what portid_t can represent, return */
3668 if(tmp >= RTE_MAX_ETHPORTS)
3670 port_id = (portid_t)tmp;
3672 if (!strcmp(res->on, "on"))
3677 if (!strcmp(res->what, "strip"))
3678 rx_vlan_strip_set(port_id, on);
3679 else if(!strcmp(res->what, "stripq")){
3680 uint16_t queue_id = 0;
3682 /* No queue_id, return */
3684 printf("must specify (port,queue_id)\n");
3687 tmp = strtoul(str + i + 1, NULL, 0);
3688 /* If queue_id greater that what 16-bits can represent, return */
3692 queue_id = (uint16_t)tmp;
3693 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3695 else if (!strcmp(res->what, "filter"))
3696 rx_vlan_filter_set(port_id, on);
3698 vlan_extend_set(port_id, on);
3703 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3704 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3706 cmdline_parse_token_string_t cmd_vlan_offload_set =
3707 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3709 cmdline_parse_token_string_t cmd_vlan_offload_what =
3710 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3711 what, "strip#filter#qinq#stripq");
3712 cmdline_parse_token_string_t cmd_vlan_offload_on =
3713 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3715 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3716 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3719 cmdline_parse_inst_t cmd_vlan_offload = {
3720 .f = cmd_vlan_offload_parsed,
3722 .help_str = "vlan set strip|filter|qinq|stripq on|off "
3723 "<port_id[,queue_id]>: "
3724 "Filter/Strip for rx side qinq(extended) for both rx/tx sides",
3726 (void *)&cmd_vlan_offload_vlan,
3727 (void *)&cmd_vlan_offload_set,
3728 (void *)&cmd_vlan_offload_what,
3729 (void *)&cmd_vlan_offload_on,
3730 (void *)&cmd_vlan_offload_portid,
3735 /* *** VLAN TPID SET ON A PORT *** */
3736 struct cmd_vlan_tpid_result {
3737 cmdline_fixed_string_t vlan;
3738 cmdline_fixed_string_t set;
3739 cmdline_fixed_string_t vlan_type;
3740 cmdline_fixed_string_t what;
3746 cmd_vlan_tpid_parsed(void *parsed_result,
3747 __attribute__((unused)) struct cmdline *cl,
3748 __attribute__((unused)) void *data)
3750 struct cmd_vlan_tpid_result *res = parsed_result;
3751 enum rte_vlan_type vlan_type;
3753 if (!strcmp(res->vlan_type, "inner"))
3754 vlan_type = ETH_VLAN_TYPE_INNER;
3755 else if (!strcmp(res->vlan_type, "outer"))
3756 vlan_type = ETH_VLAN_TYPE_OUTER;
3758 printf("Unknown vlan type\n");
3761 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3764 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3765 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3767 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3768 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3770 cmdline_parse_token_string_t cmd_vlan_type =
3771 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3772 vlan_type, "inner#outer");
3773 cmdline_parse_token_string_t cmd_vlan_tpid_what =
3774 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3776 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3777 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3779 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3780 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3783 cmdline_parse_inst_t cmd_vlan_tpid = {
3784 .f = cmd_vlan_tpid_parsed,
3786 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3787 "Set the VLAN Ether type",
3789 (void *)&cmd_vlan_tpid_vlan,
3790 (void *)&cmd_vlan_tpid_set,
3791 (void *)&cmd_vlan_type,
3792 (void *)&cmd_vlan_tpid_what,
3793 (void *)&cmd_vlan_tpid_tpid,
3794 (void *)&cmd_vlan_tpid_portid,
3799 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
3800 struct cmd_rx_vlan_filter_result {
3801 cmdline_fixed_string_t rx_vlan;
3802 cmdline_fixed_string_t what;
3808 cmd_rx_vlan_filter_parsed(void *parsed_result,
3809 __attribute__((unused)) struct cmdline *cl,
3810 __attribute__((unused)) void *data)
3812 struct cmd_rx_vlan_filter_result *res = parsed_result;
3814 if (!strcmp(res->what, "add"))
3815 rx_vft_set(res->port_id, res->vlan_id, 1);
3817 rx_vft_set(res->port_id, res->vlan_id, 0);
3820 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
3821 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3822 rx_vlan, "rx_vlan");
3823 cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
3824 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
3826 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3827 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3829 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3830 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3833 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3834 .f = cmd_rx_vlan_filter_parsed,
3836 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
3837 "Add/Remove a VLAN identifier to/from the set of VLAN "
3838 "identifiers filtered by a port",
3840 (void *)&cmd_rx_vlan_filter_rx_vlan,
3841 (void *)&cmd_rx_vlan_filter_what,
3842 (void *)&cmd_rx_vlan_filter_vlanid,
3843 (void *)&cmd_rx_vlan_filter_portid,
3848 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
3849 struct cmd_tx_vlan_set_result {
3850 cmdline_fixed_string_t tx_vlan;
3851 cmdline_fixed_string_t set;
3857 cmd_tx_vlan_set_parsed(void *parsed_result,
3858 __attribute__((unused)) struct cmdline *cl,
3859 __attribute__((unused)) void *data)
3861 struct cmd_tx_vlan_set_result *res = parsed_result;
3863 if (!port_is_stopped(res->port_id)) {
3864 printf("Please stop port %d first\n", res->port_id);
3868 tx_vlan_set(res->port_id, res->vlan_id);
3870 cmd_reconfig_device_queue(res->port_id, 1, 1);
3873 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
3874 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3875 tx_vlan, "tx_vlan");
3876 cmdline_parse_token_string_t cmd_tx_vlan_set_set =
3877 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
3879 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3880 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3882 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3883 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3886 cmdline_parse_inst_t cmd_tx_vlan_set = {
3887 .f = cmd_tx_vlan_set_parsed,
3889 .help_str = "tx_vlan set <port_id> <vlan_id>: "
3890 "Enable hardware insertion of a single VLAN header "
3891 "with a given TAG Identifier in packets sent on a port",
3893 (void *)&cmd_tx_vlan_set_tx_vlan,
3894 (void *)&cmd_tx_vlan_set_set,
3895 (void *)&cmd_tx_vlan_set_portid,
3896 (void *)&cmd_tx_vlan_set_vlanid,
3901 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
3902 struct cmd_tx_vlan_set_qinq_result {
3903 cmdline_fixed_string_t tx_vlan;
3904 cmdline_fixed_string_t set;
3907 uint16_t vlan_id_outer;
3911 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3912 __attribute__((unused)) struct cmdline *cl,
3913 __attribute__((unused)) void *data)
3915 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3917 if (!port_is_stopped(res->port_id)) {
3918 printf("Please stop port %d first\n", res->port_id);
3922 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3924 cmd_reconfig_device_queue(res->port_id, 1, 1);
3927 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
3928 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3929 tx_vlan, "tx_vlan");
3930 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
3931 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3933 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3934 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3936 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3937 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3939 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
3940 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3941 vlan_id_outer, UINT16);
3943 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3944 .f = cmd_tx_vlan_set_qinq_parsed,
3946 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
3947 "Enable hardware insertion of double VLAN header "
3948 "with given TAG Identifiers in packets sent on a port",
3950 (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
3951 (void *)&cmd_tx_vlan_set_qinq_set,
3952 (void *)&cmd_tx_vlan_set_qinq_portid,
3953 (void *)&cmd_tx_vlan_set_qinq_vlanid,
3954 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
3959 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
3960 struct cmd_tx_vlan_set_pvid_result {
3961 cmdline_fixed_string_t tx_vlan;
3962 cmdline_fixed_string_t set;
3963 cmdline_fixed_string_t pvid;
3966 cmdline_fixed_string_t mode;
3970 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3971 __attribute__((unused)) struct cmdline *cl,
3972 __attribute__((unused)) void *data)
3974 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3976 if (strcmp(res->mode, "on") == 0)
3977 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3979 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3982 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
3983 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3984 tx_vlan, "tx_vlan");
3985 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
3986 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3988 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3989 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3991 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3992 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3994 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3995 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3997 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3998 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4001 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4002 .f = cmd_tx_vlan_set_pvid_parsed,
4004 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4006 (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4007 (void *)&cmd_tx_vlan_set_pvid_set,
4008 (void *)&cmd_tx_vlan_set_pvid_pvid,
4009 (void *)&cmd_tx_vlan_set_pvid_port_id,
4010 (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4011 (void *)&cmd_tx_vlan_set_pvid_mode,
4016 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4017 struct cmd_tx_vlan_reset_result {
4018 cmdline_fixed_string_t tx_vlan;
4019 cmdline_fixed_string_t reset;
4024 cmd_tx_vlan_reset_parsed(void *parsed_result,
4025 __attribute__((unused)) struct cmdline *cl,
4026 __attribute__((unused)) void *data)
4028 struct cmd_tx_vlan_reset_result *res = parsed_result;
4030 if (!port_is_stopped(res->port_id)) {
4031 printf("Please stop port %d first\n", res->port_id);
4035 tx_vlan_reset(res->port_id);
4037 cmd_reconfig_device_queue(res->port_id, 1, 1);
4040 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4041 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4042 tx_vlan, "tx_vlan");
4043 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4044 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4046 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4047 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4050 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4051 .f = cmd_tx_vlan_reset_parsed,
4053 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4054 "VLAN header in packets sent on a port",
4056 (void *)&cmd_tx_vlan_reset_tx_vlan,
4057 (void *)&cmd_tx_vlan_reset_reset,
4058 (void *)&cmd_tx_vlan_reset_portid,
4064 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4065 struct cmd_csum_result {
4066 cmdline_fixed_string_t csum;
4067 cmdline_fixed_string_t mode;
4068 cmdline_fixed_string_t proto;
4069 cmdline_fixed_string_t hwsw;
4074 csum_show(int port_id)
4076 struct rte_eth_dev_info dev_info;
4077 uint64_t tx_offloads;
4079 tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4080 printf("Parse tunnel is %s\n",
4081 (ports[port_id].parse_tunnel) ? "on" : "off");
4082 printf("IP checksum offload is %s\n",
4083 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4084 printf("UDP checksum offload is %s\n",
4085 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4086 printf("TCP checksum offload is %s\n",
4087 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4088 printf("SCTP checksum offload is %s\n",
4089 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4090 printf("Outer-Ip checksum offload is %s\n",
4091 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4093 /* display warnings if configuration is not supported by the NIC */
4094 rte_eth_dev_info_get(port_id, &dev_info);
4095 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) &&
4096 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4097 printf("Warning: hardware IP checksum enabled but not "
4098 "supported by port %d\n", port_id);
4100 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) &&
4101 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) {
4102 printf("Warning: hardware UDP checksum enabled but not "
4103 "supported by port %d\n", port_id);
4105 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) &&
4106 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) {
4107 printf("Warning: hardware TCP checksum enabled but not "
4108 "supported by port %d\n", port_id);
4110 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) &&
4111 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4112 printf("Warning: hardware SCTP checksum enabled but not "
4113 "supported by port %d\n", port_id);
4115 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4116 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4117 printf("Warning: hardware outer IP checksum enabled but not "
4118 "supported by port %d\n", port_id);
4123 cmd_csum_parsed(void *parsed_result,
4124 __attribute__((unused)) struct cmdline *cl,
4125 __attribute__((unused)) void *data)
4127 struct cmd_csum_result *res = parsed_result;
4129 uint64_t csum_offloads = 0;
4130 struct rte_eth_dev_info dev_info;
4132 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4133 printf("invalid port %d\n", res->port_id);
4136 if (!port_is_stopped(res->port_id)) {
4137 printf("Please stop port %d first\n", res->port_id);
4141 rte_eth_dev_info_get(res->port_id, &dev_info);
4142 if (!strcmp(res->mode, "set")) {
4144 if (!strcmp(res->hwsw, "hw"))
4147 if (!strcmp(res->proto, "ip")) {
4148 if (hw == 0 || (dev_info.tx_offload_capa &
4149 DEV_TX_OFFLOAD_IPV4_CKSUM)) {
4150 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM;
4152 printf("IP checksum offload is not supported "
4153 "by port %u\n", res->port_id);
4155 } else if (!strcmp(res->proto, "udp")) {
4156 if (hw == 0 || (dev_info.tx_offload_capa &
4157 DEV_TX_OFFLOAD_UDP_CKSUM)) {
4158 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM;
4160 printf("UDP checksum offload is not supported "
4161 "by port %u\n", res->port_id);
4163 } else if (!strcmp(res->proto, "tcp")) {
4164 if (hw == 0 || (dev_info.tx_offload_capa &
4165 DEV_TX_OFFLOAD_TCP_CKSUM)) {
4166 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM;
4168 printf("TCP checksum offload is not supported "
4169 "by port %u\n", res->port_id);
4171 } else if (!strcmp(res->proto, "sctp")) {
4172 if (hw == 0 || (dev_info.tx_offload_capa &
4173 DEV_TX_OFFLOAD_SCTP_CKSUM)) {
4174 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM;
4176 printf("SCTP checksum offload is not supported "
4177 "by port %u\n", res->port_id);
4179 } else if (!strcmp(res->proto, "outer-ip")) {
4180 if (hw == 0 || (dev_info.tx_offload_capa &
4181 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4183 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4185 printf("Outer IP checksum offload is not "
4186 "supported by port %u\n", res->port_id);
4191 ports[res->port_id].dev_conf.txmode.offloads |=
4194 ports[res->port_id].dev_conf.txmode.offloads &=
4198 csum_show(res->port_id);
4200 cmd_reconfig_device_queue(res->port_id, 1, 1);
4203 cmdline_parse_token_string_t cmd_csum_csum =
4204 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4206 cmdline_parse_token_string_t cmd_csum_mode =
4207 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4209 cmdline_parse_token_string_t cmd_csum_proto =
4210 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4211 proto, "ip#tcp#udp#sctp#outer-ip");
4212 cmdline_parse_token_string_t cmd_csum_hwsw =
4213 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4215 cmdline_parse_token_num_t cmd_csum_portid =
4216 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4219 cmdline_parse_inst_t cmd_csum_set = {
4220 .f = cmd_csum_parsed,
4222 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: "
4223 "Enable/Disable hardware calculation of L3/L4 checksum when "
4224 "using csum forward engine",
4226 (void *)&cmd_csum_csum,
4227 (void *)&cmd_csum_mode,
4228 (void *)&cmd_csum_proto,
4229 (void *)&cmd_csum_hwsw,
4230 (void *)&cmd_csum_portid,
4235 cmdline_parse_token_string_t cmd_csum_mode_show =
4236 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4239 cmdline_parse_inst_t cmd_csum_show = {
4240 .f = cmd_csum_parsed,
4242 .help_str = "csum show <port_id>: Show checksum offload configuration",
4244 (void *)&cmd_csum_csum,
4245 (void *)&cmd_csum_mode_show,
4246 (void *)&cmd_csum_portid,
4251 /* Enable/disable tunnel parsing */
4252 struct cmd_csum_tunnel_result {
4253 cmdline_fixed_string_t csum;
4254 cmdline_fixed_string_t parse;
4255 cmdline_fixed_string_t onoff;
4260 cmd_csum_tunnel_parsed(void *parsed_result,
4261 __attribute__((unused)) struct cmdline *cl,
4262 __attribute__((unused)) void *data)
4264 struct cmd_csum_tunnel_result *res = parsed_result;
4266 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4269 if (!strcmp(res->onoff, "on"))
4270 ports[res->port_id].parse_tunnel = 1;
4272 ports[res->port_id].parse_tunnel = 0;
4274 csum_show(res->port_id);
4277 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4278 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4280 cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4281 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4282 parse, "parse_tunnel");
4283 cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4284 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4286 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4287 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4290 cmdline_parse_inst_t cmd_csum_tunnel = {
4291 .f = cmd_csum_tunnel_parsed,
4293 .help_str = "csum parse_tunnel on|off <port_id>: "
4294 "Enable/Disable parsing of tunnels for csum engine",
4296 (void *)&cmd_csum_tunnel_csum,
4297 (void *)&cmd_csum_tunnel_parse,
4298 (void *)&cmd_csum_tunnel_onoff,
4299 (void *)&cmd_csum_tunnel_portid,
4304 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
4305 struct cmd_tso_set_result {
4306 cmdline_fixed_string_t tso;
4307 cmdline_fixed_string_t mode;
4313 cmd_tso_set_parsed(void *parsed_result,
4314 __attribute__((unused)) struct cmdline *cl,
4315 __attribute__((unused)) void *data)
4317 struct cmd_tso_set_result *res = parsed_result;
4318 struct rte_eth_dev_info dev_info;
4320 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4322 if (!port_is_stopped(res->port_id)) {
4323 printf("Please stop port %d first\n", res->port_id);
4327 if (!strcmp(res->mode, "set"))
4328 ports[res->port_id].tso_segsz = res->tso_segsz;
4330 rte_eth_dev_info_get(res->port_id, &dev_info);
4331 if ((ports[res->port_id].tso_segsz != 0) &&
4332 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4333 printf("Error: TSO is not supported by port %d\n",
4338 if (ports[res->port_id].tso_segsz == 0) {
4339 ports[res->port_id].dev_conf.txmode.offloads &=
4340 ~DEV_TX_OFFLOAD_TCP_TSO;
4341 printf("TSO for non-tunneled packets is disabled\n");
4343 ports[res->port_id].dev_conf.txmode.offloads |=
4344 DEV_TX_OFFLOAD_TCP_TSO;
4345 printf("TSO segment size for non-tunneled packets is %d\n",
4346 ports[res->port_id].tso_segsz);
4349 /* display warnings if configuration is not supported by the NIC */
4350 rte_eth_dev_info_get(res->port_id, &dev_info);
4351 if ((ports[res->port_id].tso_segsz != 0) &&
4352 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) {
4353 printf("Warning: TSO enabled but not "
4354 "supported by port %d\n", res->port_id);
4357 cmd_reconfig_device_queue(res->port_id, 1, 1);
4360 cmdline_parse_token_string_t cmd_tso_set_tso =
4361 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4363 cmdline_parse_token_string_t cmd_tso_set_mode =
4364 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4366 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4367 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4369 cmdline_parse_token_num_t cmd_tso_set_portid =
4370 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4373 cmdline_parse_inst_t cmd_tso_set = {
4374 .f = cmd_tso_set_parsed,
4376 .help_str = "tso set <tso_segsz> <port_id>: "
4377 "Set TSO segment size of non-tunneled packets for csum engine "
4380 (void *)&cmd_tso_set_tso,
4381 (void *)&cmd_tso_set_mode,
4382 (void *)&cmd_tso_set_tso_segsz,
4383 (void *)&cmd_tso_set_portid,
4388 cmdline_parse_token_string_t cmd_tso_show_mode =
4389 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4393 cmdline_parse_inst_t cmd_tso_show = {
4394 .f = cmd_tso_set_parsed,
4396 .help_str = "tso show <port_id>: "
4397 "Show TSO segment size of non-tunneled packets for csum engine",
4399 (void *)&cmd_tso_set_tso,
4400 (void *)&cmd_tso_show_mode,
4401 (void *)&cmd_tso_set_portid,
4406 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
4407 struct cmd_tunnel_tso_set_result {
4408 cmdline_fixed_string_t tso;
4409 cmdline_fixed_string_t mode;
4414 static struct rte_eth_dev_info
4415 check_tunnel_tso_nic_support(portid_t port_id)
4417 struct rte_eth_dev_info dev_info;
4419 rte_eth_dev_info_get(port_id, &dev_info);
4420 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO))
4421 printf("Warning: VXLAN TUNNEL TSO not supported therefore "
4422 "not enabled for port %d\n", port_id);
4423 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO))
4424 printf("Warning: GRE TUNNEL TSO not supported therefore "
4425 "not enabled for port %d\n", port_id);
4426 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO))
4427 printf("Warning: IPIP TUNNEL TSO not supported therefore "
4428 "not enabled for port %d\n", port_id);
4429 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO))
4430 printf("Warning: GENEVE TUNNEL TSO not supported therefore "
4431 "not enabled for port %d\n", port_id);
4432 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO))
4433 printf("Warning: IP TUNNEL TSO not supported therefore "
4434 "not enabled for port %d\n", port_id);
4435 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO))
4436 printf("Warning: UDP TUNNEL TSO not supported therefore "
4437 "not enabled for port %d\n", port_id);
4442 cmd_tunnel_tso_set_parsed(void *parsed_result,
4443 __attribute__((unused)) struct cmdline *cl,
4444 __attribute__((unused)) void *data)
4446 struct cmd_tunnel_tso_set_result *res = parsed_result;
4447 struct rte_eth_dev_info dev_info;
4449 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4451 if (!port_is_stopped(res->port_id)) {
4452 printf("Please stop port %d first\n", res->port_id);
4456 if (!strcmp(res->mode, "set"))
4457 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4459 dev_info = check_tunnel_tso_nic_support(res->port_id);
4460 if (ports[res->port_id].tunnel_tso_segsz == 0) {
4461 ports[res->port_id].dev_conf.txmode.offloads &=
4462 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4463 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4464 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4465 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4466 DEV_TX_OFFLOAD_IP_TNL_TSO |
4467 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4468 printf("TSO for tunneled packets is disabled\n");
4470 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO |
4471 DEV_TX_OFFLOAD_GRE_TNL_TSO |
4472 DEV_TX_OFFLOAD_IPIP_TNL_TSO |
4473 DEV_TX_OFFLOAD_GENEVE_TNL_TSO |
4474 DEV_TX_OFFLOAD_IP_TNL_TSO |
4475 DEV_TX_OFFLOAD_UDP_TNL_TSO);
4477 ports[res->port_id].dev_conf.txmode.offloads |=
4478 (tso_offloads & dev_info.tx_offload_capa);
4479 printf("TSO segment size for tunneled packets is %d\n",
4480 ports[res->port_id].tunnel_tso_segsz);
4482 /* Below conditions are needed to make it work:
4483 * (1) tunnel TSO is supported by the NIC;
4484 * (2) "csum parse_tunnel" must be set so that tunneled pkts
4486 * (3) for tunneled pkts with outer L3 of IPv4,
4487 * "csum set outer-ip" must be set to hw, because after tso,
4488 * total_len of outer IP header is changed, and the checksum
4489 * of outer IP header calculated by sw should be wrong; that
4490 * is not necessary for IPv6 tunneled pkts because there's no
4491 * checksum in IP header anymore.
4494 if (!ports[res->port_id].parse_tunnel)
4495 printf("Warning: csum parse_tunnel must be set "
4496 "so that tunneled packets are recognized\n");
4497 if (!(ports[res->port_id].dev_conf.txmode.offloads &
4498 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
4499 printf("Warning: csum set outer-ip must be set to hw "
4500 "if outer L3 is IPv4; not necessary for IPv6\n");
4503 cmd_reconfig_device_queue(res->port_id, 1, 1);
4506 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4507 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4509 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4510 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4512 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4513 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4515 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4516 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4519 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4520 .f = cmd_tunnel_tso_set_parsed,
4522 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4523 "Set TSO segment size of tunneled packets for csum engine "
4526 (void *)&cmd_tunnel_tso_set_tso,
4527 (void *)&cmd_tunnel_tso_set_mode,
4528 (void *)&cmd_tunnel_tso_set_tso_segsz,
4529 (void *)&cmd_tunnel_tso_set_portid,
4534 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4535 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4539 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4540 .f = cmd_tunnel_tso_set_parsed,
4542 .help_str = "tunnel_tso show <port_id> "
4543 "Show TSO segment size of tunneled packets for csum engine",
4545 (void *)&cmd_tunnel_tso_set_tso,
4546 (void *)&cmd_tunnel_tso_show_mode,
4547 (void *)&cmd_tunnel_tso_set_portid,
4552 /* *** SET GRO FOR A PORT *** */
4553 struct cmd_gro_enable_result {
4554 cmdline_fixed_string_t cmd_set;
4555 cmdline_fixed_string_t cmd_port;
4556 cmdline_fixed_string_t cmd_keyword;
4557 cmdline_fixed_string_t cmd_onoff;
4562 cmd_gro_enable_parsed(void *parsed_result,
4563 __attribute__((unused)) struct cmdline *cl,
4564 __attribute__((unused)) void *data)
4566 struct cmd_gro_enable_result *res;
4568 res = parsed_result;
4569 if (!strcmp(res->cmd_keyword, "gro"))
4570 setup_gro(res->cmd_onoff, res->cmd_pid);
4573 cmdline_parse_token_string_t cmd_gro_enable_set =
4574 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4576 cmdline_parse_token_string_t cmd_gro_enable_port =
4577 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4578 cmd_keyword, "port");
4579 cmdline_parse_token_num_t cmd_gro_enable_pid =
4580 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
4582 cmdline_parse_token_string_t cmd_gro_enable_keyword =
4583 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4584 cmd_keyword, "gro");
4585 cmdline_parse_token_string_t cmd_gro_enable_onoff =
4586 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4587 cmd_onoff, "on#off");
4589 cmdline_parse_inst_t cmd_gro_enable = {
4590 .f = cmd_gro_enable_parsed,
4592 .help_str = "set port <port_id> gro on|off",
4594 (void *)&cmd_gro_enable_set,
4595 (void *)&cmd_gro_enable_port,
4596 (void *)&cmd_gro_enable_pid,
4597 (void *)&cmd_gro_enable_keyword,
4598 (void *)&cmd_gro_enable_onoff,
4603 /* *** DISPLAY GRO CONFIGURATION *** */
4604 struct cmd_gro_show_result {
4605 cmdline_fixed_string_t cmd_show;
4606 cmdline_fixed_string_t cmd_port;
4607 cmdline_fixed_string_t cmd_keyword;
4612 cmd_gro_show_parsed(void *parsed_result,
4613 __attribute__((unused)) struct cmdline *cl,
4614 __attribute__((unused)) void *data)
4616 struct cmd_gro_show_result *res;
4618 res = parsed_result;
4619 if (!strcmp(res->cmd_keyword, "gro"))
4620 show_gro(res->cmd_pid);
4623 cmdline_parse_token_string_t cmd_gro_show_show =
4624 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4626 cmdline_parse_token_string_t cmd_gro_show_port =
4627 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4629 cmdline_parse_token_num_t cmd_gro_show_pid =
4630 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4632 cmdline_parse_token_string_t cmd_gro_show_keyword =
4633 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4634 cmd_keyword, "gro");
4636 cmdline_parse_inst_t cmd_gro_show = {
4637 .f = cmd_gro_show_parsed,
4639 .help_str = "show port <port_id> gro",
4641 (void *)&cmd_gro_show_show,
4642 (void *)&cmd_gro_show_port,
4643 (void *)&cmd_gro_show_pid,
4644 (void *)&cmd_gro_show_keyword,
4649 /* *** SET FLUSH CYCLES FOR GRO *** */
4650 struct cmd_gro_flush_result {
4651 cmdline_fixed_string_t cmd_set;
4652 cmdline_fixed_string_t cmd_keyword;
4653 cmdline_fixed_string_t cmd_flush;
4658 cmd_gro_flush_parsed(void *parsed_result,
4659 __attribute__((unused)) struct cmdline *cl,
4660 __attribute__((unused)) void *data)
4662 struct cmd_gro_flush_result *res;
4664 res = parsed_result;
4665 if ((!strcmp(res->cmd_keyword, "gro")) &&
4666 (!strcmp(res->cmd_flush, "flush")))
4667 setup_gro_flush_cycles(res->cmd_cycles);
4670 cmdline_parse_token_string_t cmd_gro_flush_set =
4671 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4673 cmdline_parse_token_string_t cmd_gro_flush_keyword =
4674 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4675 cmd_keyword, "gro");
4676 cmdline_parse_token_string_t cmd_gro_flush_flush =
4677 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4678 cmd_flush, "flush");
4679 cmdline_parse_token_num_t cmd_gro_flush_cycles =
4680 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
4683 cmdline_parse_inst_t cmd_gro_flush = {
4684 .f = cmd_gro_flush_parsed,
4686 .help_str = "set gro flush <cycles>",
4688 (void *)&cmd_gro_flush_set,
4689 (void *)&cmd_gro_flush_keyword,
4690 (void *)&cmd_gro_flush_flush,
4691 (void *)&cmd_gro_flush_cycles,
4696 /* *** ENABLE/DISABLE GSO *** */
4697 struct cmd_gso_enable_result {
4698 cmdline_fixed_string_t cmd_set;
4699 cmdline_fixed_string_t cmd_port;
4700 cmdline_fixed_string_t cmd_keyword;
4701 cmdline_fixed_string_t cmd_mode;
4706 cmd_gso_enable_parsed(void *parsed_result,
4707 __attribute__((unused)) struct cmdline *cl,
4708 __attribute__((unused)) void *data)
4710 struct cmd_gso_enable_result *res;
4712 res = parsed_result;
4713 if (!strcmp(res->cmd_keyword, "gso"))
4714 setup_gso(res->cmd_mode, res->cmd_pid);
4717 cmdline_parse_token_string_t cmd_gso_enable_set =
4718 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4720 cmdline_parse_token_string_t cmd_gso_enable_port =
4721 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4723 cmdline_parse_token_string_t cmd_gso_enable_keyword =
4724 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4725 cmd_keyword, "gso");
4726 cmdline_parse_token_string_t cmd_gso_enable_mode =
4727 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4728 cmd_mode, "on#off");
4729 cmdline_parse_token_num_t cmd_gso_enable_pid =
4730 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
4733 cmdline_parse_inst_t cmd_gso_enable = {
4734 .f = cmd_gso_enable_parsed,
4736 .help_str = "set port <port_id> gso on|off",
4738 (void *)&cmd_gso_enable_set,
4739 (void *)&cmd_gso_enable_port,
4740 (void *)&cmd_gso_enable_pid,
4741 (void *)&cmd_gso_enable_keyword,
4742 (void *)&cmd_gso_enable_mode,
4747 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
4748 struct cmd_gso_size_result {
4749 cmdline_fixed_string_t cmd_set;
4750 cmdline_fixed_string_t cmd_keyword;
4751 cmdline_fixed_string_t cmd_segsz;
4756 cmd_gso_size_parsed(void *parsed_result,
4757 __attribute__((unused)) struct cmdline *cl,
4758 __attribute__((unused)) void *data)
4760 struct cmd_gso_size_result *res = parsed_result;
4762 if (test_done == 0) {
4763 printf("Before setting GSO segsz, please first"
4764 " stop fowarding\n");
4768 if (!strcmp(res->cmd_keyword, "gso") &&
4769 !strcmp(res->cmd_segsz, "segsz")) {
4770 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
4771 printf("gso_size should be larger than %zu."
4772 " Please input a legal value\n",
4773 RTE_GSO_SEG_SIZE_MIN);
4775 gso_max_segment_size = res->cmd_size;
4779 cmdline_parse_token_string_t cmd_gso_size_set =
4780 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4782 cmdline_parse_token_string_t cmd_gso_size_keyword =
4783 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4784 cmd_keyword, "gso");
4785 cmdline_parse_token_string_t cmd_gso_size_segsz =
4786 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4787 cmd_segsz, "segsz");
4788 cmdline_parse_token_num_t cmd_gso_size_size =
4789 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
4792 cmdline_parse_inst_t cmd_gso_size = {
4793 .f = cmd_gso_size_parsed,
4795 .help_str = "set gso segsz <length>",
4797 (void *)&cmd_gso_size_set,
4798 (void *)&cmd_gso_size_keyword,
4799 (void *)&cmd_gso_size_segsz,
4800 (void *)&cmd_gso_size_size,
4805 /* *** SHOW GSO CONFIGURATION *** */
4806 struct cmd_gso_show_result {
4807 cmdline_fixed_string_t cmd_show;
4808 cmdline_fixed_string_t cmd_port;
4809 cmdline_fixed_string_t cmd_keyword;
4814 cmd_gso_show_parsed(void *parsed_result,
4815 __attribute__((unused)) struct cmdline *cl,
4816 __attribute__((unused)) void *data)
4818 struct cmd_gso_show_result *res = parsed_result;
4820 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4821 printf("invalid port id %u\n", res->cmd_pid);
4824 if (!strcmp(res->cmd_keyword, "gso")) {
4825 if (gso_ports[res->cmd_pid].enable) {
4826 printf("Max GSO'd packet size: %uB\n"
4827 "Supported GSO types: TCP/IPv4, "
4828 "UDP/IPv4, VxLAN with inner "
4829 "TCP/IPv4 packet, GRE with inner "
4830 "TCP/IPv4 packet\n",
4831 gso_max_segment_size);
4833 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4837 cmdline_parse_token_string_t cmd_gso_show_show =
4838 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4840 cmdline_parse_token_string_t cmd_gso_show_port =
4841 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4843 cmdline_parse_token_string_t cmd_gso_show_keyword =
4844 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4845 cmd_keyword, "gso");
4846 cmdline_parse_token_num_t cmd_gso_show_pid =
4847 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
4850 cmdline_parse_inst_t cmd_gso_show = {
4851 .f = cmd_gso_show_parsed,
4853 .help_str = "show port <port_id> gso",
4855 (void *)&cmd_gso_show_show,
4856 (void *)&cmd_gso_show_port,
4857 (void *)&cmd_gso_show_pid,
4858 (void *)&cmd_gso_show_keyword,
4863 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
4864 struct cmd_set_flush_rx {
4865 cmdline_fixed_string_t set;
4866 cmdline_fixed_string_t flush_rx;
4867 cmdline_fixed_string_t mode;
4871 cmd_set_flush_rx_parsed(void *parsed_result,
4872 __attribute__((unused)) struct cmdline *cl,
4873 __attribute__((unused)) void *data)
4875 struct cmd_set_flush_rx *res = parsed_result;
4876 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4879 cmdline_parse_token_string_t cmd_setflushrx_set =
4880 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4882 cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
4883 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4884 flush_rx, "flush_rx");
4885 cmdline_parse_token_string_t cmd_setflushrx_mode =
4886 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4890 cmdline_parse_inst_t cmd_set_flush_rx = {
4891 .f = cmd_set_flush_rx_parsed,
4892 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
4895 (void *)&cmd_setflushrx_set,
4896 (void *)&cmd_setflushrx_flush_rx,
4897 (void *)&cmd_setflushrx_mode,
4902 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
4903 struct cmd_set_link_check {
4904 cmdline_fixed_string_t set;
4905 cmdline_fixed_string_t link_check;
4906 cmdline_fixed_string_t mode;
4910 cmd_set_link_check_parsed(void *parsed_result,
4911 __attribute__((unused)) struct cmdline *cl,
4912 __attribute__((unused)) void *data)
4914 struct cmd_set_link_check *res = parsed_result;
4915 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4918 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4919 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4921 cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
4922 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4923 link_check, "link_check");
4924 cmdline_parse_token_string_t cmd_setlinkcheck_mode =
4925 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4929 cmdline_parse_inst_t cmd_set_link_check = {
4930 .f = cmd_set_link_check_parsed,
4931 .help_str = "set link_check on|off: Enable/Disable link status check "
4932 "when starting/stopping a port",
4935 (void *)&cmd_setlinkcheck_set,
4936 (void *)&cmd_setlinkcheck_link_check,
4937 (void *)&cmd_setlinkcheck_mode,
4942 /* *** SET NIC BYPASS MODE *** */
4943 struct cmd_set_bypass_mode_result {
4944 cmdline_fixed_string_t set;
4945 cmdline_fixed_string_t bypass;
4946 cmdline_fixed_string_t mode;
4947 cmdline_fixed_string_t value;
4952 cmd_set_bypass_mode_parsed(void *parsed_result,
4953 __attribute__((unused)) struct cmdline *cl,
4954 __attribute__((unused)) void *data)
4956 struct cmd_set_bypass_mode_result *res = parsed_result;
4957 portid_t port_id = res->port_id;
4958 int32_t rc = -EINVAL;
4960 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4961 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4963 if (!strcmp(res->value, "bypass"))
4964 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
4965 else if (!strcmp(res->value, "isolate"))
4966 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
4968 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4970 /* Set the bypass mode for the relevant port. */
4971 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4974 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4977 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4978 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4980 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4981 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4983 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4984 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4986 cmdline_parse_token_string_t cmd_setbypass_mode_value =
4987 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4988 value, "normal#bypass#isolate");
4989 cmdline_parse_token_num_t cmd_setbypass_mode_port =
4990 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result,
4993 cmdline_parse_inst_t cmd_set_bypass_mode = {
4994 .f = cmd_set_bypass_mode_parsed,
4995 .help_str = "set bypass mode normal|bypass|isolate <port_id>: "
4996 "Set the NIC bypass mode for port_id",
4999 (void *)&cmd_setbypass_mode_set,
5000 (void *)&cmd_setbypass_mode_bypass,
5001 (void *)&cmd_setbypass_mode_mode,
5002 (void *)&cmd_setbypass_mode_value,
5003 (void *)&cmd_setbypass_mode_port,
5008 /* *** SET NIC BYPASS EVENT *** */
5009 struct cmd_set_bypass_event_result {
5010 cmdline_fixed_string_t set;
5011 cmdline_fixed_string_t bypass;
5012 cmdline_fixed_string_t event;
5013 cmdline_fixed_string_t event_value;
5014 cmdline_fixed_string_t mode;
5015 cmdline_fixed_string_t mode_value;
5020 cmd_set_bypass_event_parsed(void *parsed_result,
5021 __attribute__((unused)) struct cmdline *cl,
5022 __attribute__((unused)) void *data)
5024 int32_t rc = -EINVAL;
5025 struct cmd_set_bypass_event_result *res = parsed_result;
5026 portid_t port_id = res->port_id;
5028 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5029 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5030 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5032 if (!strcmp(res->event_value, "timeout"))
5033 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT;
5034 else if (!strcmp(res->event_value, "os_on"))
5035 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON;
5036 else if (!strcmp(res->event_value, "os_off"))
5037 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF;
5038 else if (!strcmp(res->event_value, "power_on"))
5039 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON;
5040 else if (!strcmp(res->event_value, "power_off"))
5041 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF;
5043 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5045 if (!strcmp(res->mode_value, "bypass"))
5046 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS;
5047 else if (!strcmp(res->mode_value, "isolate"))
5048 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE;
5050 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5052 /* Set the watchdog timeout. */
5053 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5056 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5057 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5061 printf("Failed to set timeout value %u "
5062 "for port %d, errto code: %d.\n",
5063 bypass_timeout, port_id, rc);
5067 /* Set the bypass event to transition to bypass mode. */
5068 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5073 printf("\t Failed to set bypass event for port = %d.\n",
5077 cmdline_parse_token_string_t cmd_setbypass_event_set =
5078 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5080 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5081 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5083 cmdline_parse_token_string_t cmd_setbypass_event_event =
5084 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5086 cmdline_parse_token_string_t cmd_setbypass_event_event_value =
5087 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5088 event_value, "none#timeout#os_off#os_on#power_on#power_off");
5089 cmdline_parse_token_string_t cmd_setbypass_event_mode =
5090 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5092 cmdline_parse_token_string_t cmd_setbypass_event_mode_value =
5093 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5094 mode_value, "normal#bypass#isolate");
5095 cmdline_parse_token_num_t cmd_setbypass_event_port =
5096 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result,
5099 cmdline_parse_inst_t cmd_set_bypass_event = {
5100 .f = cmd_set_bypass_event_parsed,
5101 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|"
5102 "power_off mode normal|bypass|isolate <port_id>: "
5103 "Set the NIC bypass event mode for port_id",
5106 (void *)&cmd_setbypass_event_set,
5107 (void *)&cmd_setbypass_event_bypass,
5108 (void *)&cmd_setbypass_event_event,
5109 (void *)&cmd_setbypass_event_event_value,
5110 (void *)&cmd_setbypass_event_mode,
5111 (void *)&cmd_setbypass_event_mode_value,
5112 (void *)&cmd_setbypass_event_port,
5118 /* *** SET NIC BYPASS TIMEOUT *** */
5119 struct cmd_set_bypass_timeout_result {
5120 cmdline_fixed_string_t set;
5121 cmdline_fixed_string_t bypass;
5122 cmdline_fixed_string_t timeout;
5123 cmdline_fixed_string_t value;
5127 cmd_set_bypass_timeout_parsed(void *parsed_result,
5128 __attribute__((unused)) struct cmdline *cl,
5129 __attribute__((unused)) void *data)
5131 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5133 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5134 if (!strcmp(res->value, "1.5"))
5135 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC;
5136 else if (!strcmp(res->value, "2"))
5137 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC;
5138 else if (!strcmp(res->value, "3"))
5139 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC;
5140 else if (!strcmp(res->value, "4"))
5141 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC;
5142 else if (!strcmp(res->value, "8"))
5143 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC;
5144 else if (!strcmp(res->value, "16"))
5145 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC;
5146 else if (!strcmp(res->value, "32"))
5147 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC;
5149 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5153 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5154 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5156 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5157 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5159 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout =
5160 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5161 timeout, "timeout");
5162 cmdline_parse_token_string_t cmd_setbypass_timeout_value =
5163 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5164 value, "0#1.5#2#3#4#8#16#32");
5166 cmdline_parse_inst_t cmd_set_bypass_timeout = {
5167 .f = cmd_set_bypass_timeout_parsed,
5168 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: "
5169 "Set the NIC bypass watchdog timeout in seconds",
5172 (void *)&cmd_setbypass_timeout_set,
5173 (void *)&cmd_setbypass_timeout_bypass,
5174 (void *)&cmd_setbypass_timeout_timeout,
5175 (void *)&cmd_setbypass_timeout_value,
5180 /* *** SHOW NIC BYPASS MODE *** */
5181 struct cmd_show_bypass_config_result {
5182 cmdline_fixed_string_t show;
5183 cmdline_fixed_string_t bypass;
5184 cmdline_fixed_string_t config;
5189 cmd_show_bypass_config_parsed(void *parsed_result,
5190 __attribute__((unused)) struct cmdline *cl,
5191 __attribute__((unused)) void *data)
5193 struct cmd_show_bypass_config_result *res = parsed_result;
5194 portid_t port_id = res->port_id;
5196 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
5197 uint32_t event_mode;
5198 uint32_t bypass_mode;
5199 uint32_t timeout = bypass_timeout;
5202 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] =
5203 {"off", "1.5", "2", "3", "4", "8", "16", "32"};
5204 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] =
5205 {"UNKNOWN", "normal", "bypass", "isolate"};
5206 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = {
5213 int num_events = (sizeof events) / (sizeof events[0]);
5215 /* Display the bypass mode.*/
5216 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) {
5217 printf("\tFailed to get bypass mode for port = %d\n", port_id);
5221 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5222 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5224 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5227 /* Display the bypass timeout.*/
5228 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5229 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5231 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5233 /* Display the bypass events and associated modes. */
5234 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5236 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5237 printf("\tFailed to get bypass mode for event = %s\n",
5240 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5241 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5243 printf("\tbypass event: %-16s = %s\n", events[i],
5249 printf("\tFailed to get bypass configuration for port = %d\n",
5253 cmdline_parse_token_string_t cmd_showbypass_config_show =
5254 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5256 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5257 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5259 cmdline_parse_token_string_t cmd_showbypass_config_config =
5260 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5262 cmdline_parse_token_num_t cmd_showbypass_config_port =
5263 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5266 cmdline_parse_inst_t cmd_show_bypass_config = {
5267 .f = cmd_show_bypass_config_parsed,
5268 .help_str = "show bypass config <port_id>: "
5269 "Show the NIC bypass config for port_id",
5272 (void *)&cmd_showbypass_config_show,
5273 (void *)&cmd_showbypass_config_bypass,
5274 (void *)&cmd_showbypass_config_config,
5275 (void *)&cmd_showbypass_config_port,
5280 #ifdef RTE_LIBRTE_PMD_BOND
5281 /* *** SET BONDING MODE *** */
5282 struct cmd_set_bonding_mode_result {
5283 cmdline_fixed_string_t set;
5284 cmdline_fixed_string_t bonding;
5285 cmdline_fixed_string_t mode;
5290 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5291 __attribute__((unused)) struct cmdline *cl,
5292 __attribute__((unused)) void *data)
5294 struct cmd_set_bonding_mode_result *res = parsed_result;
5295 portid_t port_id = res->port_id;
5297 /* Set the bonding mode for the relevant port. */
5298 if (0 != rte_eth_bond_mode_set(port_id, res->value))
5299 printf("\t Failed to set bonding mode for port = %d.\n", port_id);
5302 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5303 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5305 cmdline_parse_token_string_t cmd_setbonding_mode_bonding =
5306 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5307 bonding, "bonding");
5308 cmdline_parse_token_string_t cmd_setbonding_mode_mode =
5309 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5311 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5312 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5314 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5315 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5318 cmdline_parse_inst_t cmd_set_bonding_mode = {
5319 .f = cmd_set_bonding_mode_parsed,
5320 .help_str = "set bonding mode <mode_value> <port_id>: "
5321 "Set the bonding mode for port_id",
5324 (void *) &cmd_setbonding_mode_set,
5325 (void *) &cmd_setbonding_mode_bonding,
5326 (void *) &cmd_setbonding_mode_mode,
5327 (void *) &cmd_setbonding_mode_value,
5328 (void *) &cmd_setbonding_mode_port,
5333 /* *** SET BONDING SLOW_QUEUE SW/HW *** */
5334 struct cmd_set_bonding_lacp_dedicated_queues_result {
5335 cmdline_fixed_string_t set;
5336 cmdline_fixed_string_t bonding;
5337 cmdline_fixed_string_t lacp;
5338 cmdline_fixed_string_t dedicated_queues;
5340 cmdline_fixed_string_t mode;
5343 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5344 __attribute__((unused)) struct cmdline *cl,
5345 __attribute__((unused)) void *data)
5347 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result;
5348 portid_t port_id = res->port_id;
5349 struct rte_port *port;
5351 port = &ports[port_id];
5353 /** Check if the port is not started **/
5354 if (port->port_status != RTE_PORT_STOPPED) {
5355 printf("Please stop port %d first\n", port_id);
5359 if (!strcmp(res->mode, "enable")) {
5360 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0)
5361 printf("Dedicate queues for LACP control packets"
5364 printf("Enabling dedicate queues for LACP control "
5365 "packets on port %d failed\n", port_id);
5366 } else if (!strcmp(res->mode, "disable")) {
5367 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0)
5368 printf("Dedicated queues for LACP control packets "
5371 printf("Disabling dedicated queues for LACP control "
5372 "traffic on port %d failed\n", port_id);
5376 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5377 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5379 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding =
5380 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5381 bonding, "bonding");
5382 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp =
5383 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5385 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues =
5386 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5387 dedicated_queues, "dedicated_queues");
5388 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id =
5389 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5391 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode =
5392 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5393 mode, "enable#disable");
5395 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = {
5396 .f = cmd_set_bonding_lacp_dedicated_queues_parsed,
5397 .help_str = "set bonding lacp dedicated_queues <port_id> "
5399 "Enable/disable dedicated queues for LACP control traffic for port_id",
5402 (void *)&cmd_setbonding_lacp_dedicated_queues_set,
5403 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding,
5404 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp,
5405 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues,
5406 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id,
5407 (void *)&cmd_setbonding_lacp_dedicated_queues_mode,
5412 /* *** SET BALANCE XMIT POLICY *** */
5413 struct cmd_set_bonding_balance_xmit_policy_result {
5414 cmdline_fixed_string_t set;
5415 cmdline_fixed_string_t bonding;
5416 cmdline_fixed_string_t balance_xmit_policy;
5418 cmdline_fixed_string_t policy;
5421 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5422 __attribute__((unused)) struct cmdline *cl,
5423 __attribute__((unused)) void *data)
5425 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5426 portid_t port_id = res->port_id;
5429 if (!strcmp(res->policy, "l2")) {
5430 policy = BALANCE_XMIT_POLICY_LAYER2;
5431 } else if (!strcmp(res->policy, "l23")) {
5432 policy = BALANCE_XMIT_POLICY_LAYER23;
5433 } else if (!strcmp(res->policy, "l34")) {
5434 policy = BALANCE_XMIT_POLICY_LAYER34;
5436 printf("\t Invalid xmit policy selection");
5440 /* Set the bonding mode for the relevant port. */
5441 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) {
5442 printf("\t Failed to set bonding balance xmit policy for port = %d.\n",
5447 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5448 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5450 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding =
5451 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5452 bonding, "bonding");
5453 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy =
5454 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5455 balance_xmit_policy, "balance_xmit_policy");
5456 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port =
5457 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5459 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy =
5460 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5461 policy, "l2#l23#l34");
5463 cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
5464 .f = cmd_set_bonding_balance_xmit_policy_parsed,
5465 .help_str = "set bonding balance_xmit_policy <port_id> "
5467 "Set the bonding balance_xmit_policy for port_id",
5470 (void *)&cmd_setbonding_balance_xmit_policy_set,
5471 (void *)&cmd_setbonding_balance_xmit_policy_bonding,
5472 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy,
5473 (void *)&cmd_setbonding_balance_xmit_policy_port,
5474 (void *)&cmd_setbonding_balance_xmit_policy_policy,
5479 /* *** SHOW NIC BONDING CONFIGURATION *** */
5480 struct cmd_show_bonding_config_result {
5481 cmdline_fixed_string_t show;
5482 cmdline_fixed_string_t bonding;
5483 cmdline_fixed_string_t config;
5487 static void cmd_show_bonding_config_parsed(void *parsed_result,
5488 __attribute__((unused)) struct cmdline *cl,
5489 __attribute__((unused)) void *data)
5491 struct cmd_show_bonding_config_result *res = parsed_result;
5492 int bonding_mode, agg_mode;
5493 portid_t slaves[RTE_MAX_ETHPORTS];
5494 int num_slaves, num_active_slaves;
5497 portid_t port_id = res->port_id;
5499 /* Display the bonding mode.*/
5500 bonding_mode = rte_eth_bond_mode_get(port_id);
5501 if (bonding_mode < 0) {
5502 printf("\tFailed to get bonding mode for port = %d\n", port_id);
5505 printf("\tBonding mode: %d\n", bonding_mode);
5507 if (bonding_mode == BONDING_MODE_BALANCE) {
5508 int balance_xmit_policy;
5510 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
5511 if (balance_xmit_policy < 0) {
5512 printf("\tFailed to get balance xmit policy for port = %d\n",
5516 printf("\tBalance Xmit Policy: ");
5518 switch (balance_xmit_policy) {
5519 case BALANCE_XMIT_POLICY_LAYER2:
5520 printf("BALANCE_XMIT_POLICY_LAYER2");
5522 case BALANCE_XMIT_POLICY_LAYER23:
5523 printf("BALANCE_XMIT_POLICY_LAYER23");
5525 case BALANCE_XMIT_POLICY_LAYER34:
5526 printf("BALANCE_XMIT_POLICY_LAYER34");
5533 if (bonding_mode == BONDING_MODE_8023AD) {
5534 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
5535 printf("\tIEEE802.3AD Aggregator Mode: ");
5538 printf("bandwidth");
5550 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5552 if (num_slaves < 0) {
5553 printf("\tFailed to get slave list for port = %d\n", port_id);
5556 if (num_slaves > 0) {
5557 printf("\tSlaves (%d): [", num_slaves);
5558 for (i = 0; i < num_slaves - 1; i++)
5559 printf("%d ", slaves[i]);
5561 printf("%d]\n", slaves[num_slaves - 1]);
5563 printf("\tSlaves: []\n");
5567 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5570 if (num_active_slaves < 0) {
5571 printf("\tFailed to get active slave list for port = %d\n", port_id);
5574 if (num_active_slaves > 0) {
5575 printf("\tActive Slaves (%d): [", num_active_slaves);
5576 for (i = 0; i < num_active_slaves - 1; i++)
5577 printf("%d ", slaves[i]);
5579 printf("%d]\n", slaves[num_active_slaves - 1]);
5582 printf("\tActive Slaves: []\n");
5586 primary_id = rte_eth_bond_primary_get(port_id);
5587 if (primary_id < 0) {
5588 printf("\tFailed to get primary slave for port = %d\n", port_id);
5591 printf("\tPrimary: [%d]\n", primary_id);
5595 cmdline_parse_token_string_t cmd_showbonding_config_show =
5596 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5598 cmdline_parse_token_string_t cmd_showbonding_config_bonding =
5599 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5600 bonding, "bonding");
5601 cmdline_parse_token_string_t cmd_showbonding_config_config =
5602 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5604 cmdline_parse_token_num_t cmd_showbonding_config_port =
5605 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5608 cmdline_parse_inst_t cmd_show_bonding_config = {
5609 .f = cmd_show_bonding_config_parsed,
5610 .help_str = "show bonding config <port_id>: "
5611 "Show the bonding config for port_id",
5614 (void *)&cmd_showbonding_config_show,
5615 (void *)&cmd_showbonding_config_bonding,
5616 (void *)&cmd_showbonding_config_config,
5617 (void *)&cmd_showbonding_config_port,
5622 /* *** SET BONDING PRIMARY *** */
5623 struct cmd_set_bonding_primary_result {
5624 cmdline_fixed_string_t set;
5625 cmdline_fixed_string_t bonding;
5626 cmdline_fixed_string_t primary;
5631 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5632 __attribute__((unused)) struct cmdline *cl,
5633 __attribute__((unused)) void *data)
5635 struct cmd_set_bonding_primary_result *res = parsed_result;
5636 portid_t master_port_id = res->port_id;
5637 portid_t slave_port_id = res->slave_id;
5639 /* Set the primary slave for a bonded device. */
5640 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) {
5641 printf("\t Failed to set primary slave for port = %d.\n",
5648 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5649 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5651 cmdline_parse_token_string_t cmd_setbonding_primary_bonding =
5652 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5653 bonding, "bonding");
5654 cmdline_parse_token_string_t cmd_setbonding_primary_primary =
5655 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5656 primary, "primary");
5657 cmdline_parse_token_num_t cmd_setbonding_primary_slave =
5658 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5660 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5661 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5664 cmdline_parse_inst_t cmd_set_bonding_primary = {
5665 .f = cmd_set_bonding_primary_parsed,
5666 .help_str = "set bonding primary <slave_id> <port_id>: "
5667 "Set the primary slave for port_id",
5670 (void *)&cmd_setbonding_primary_set,
5671 (void *)&cmd_setbonding_primary_bonding,
5672 (void *)&cmd_setbonding_primary_primary,
5673 (void *)&cmd_setbonding_primary_slave,
5674 (void *)&cmd_setbonding_primary_port,
5679 /* *** ADD SLAVE *** */
5680 struct cmd_add_bonding_slave_result {
5681 cmdline_fixed_string_t add;
5682 cmdline_fixed_string_t bonding;
5683 cmdline_fixed_string_t slave;
5688 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5689 __attribute__((unused)) struct cmdline *cl,
5690 __attribute__((unused)) void *data)
5692 struct cmd_add_bonding_slave_result *res = parsed_result;
5693 portid_t master_port_id = res->port_id;
5694 portid_t slave_port_id = res->slave_id;
5696 /* add the slave for a bonded device. */
5697 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) {
5698 printf("\t Failed to add slave %d to master port = %d.\n",
5699 slave_port_id, master_port_id);
5703 set_port_slave_flag(slave_port_id);
5706 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5707 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5709 cmdline_parse_token_string_t cmd_addbonding_slave_bonding =
5710 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5711 bonding, "bonding");
5712 cmdline_parse_token_string_t cmd_addbonding_slave_slave =
5713 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5715 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5716 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5718 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5719 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5722 cmdline_parse_inst_t cmd_add_bonding_slave = {
5723 .f = cmd_add_bonding_slave_parsed,
5724 .help_str = "add bonding slave <slave_id> <port_id>: "
5725 "Add a slave device to a bonded device",
5728 (void *)&cmd_addbonding_slave_add,
5729 (void *)&cmd_addbonding_slave_bonding,
5730 (void *)&cmd_addbonding_slave_slave,
5731 (void *)&cmd_addbonding_slave_slaveid,
5732 (void *)&cmd_addbonding_slave_port,
5737 /* *** REMOVE SLAVE *** */
5738 struct cmd_remove_bonding_slave_result {
5739 cmdline_fixed_string_t remove;
5740 cmdline_fixed_string_t bonding;
5741 cmdline_fixed_string_t slave;
5746 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5747 __attribute__((unused)) struct cmdline *cl,
5748 __attribute__((unused)) void *data)
5750 struct cmd_remove_bonding_slave_result *res = parsed_result;
5751 portid_t master_port_id = res->port_id;
5752 portid_t slave_port_id = res->slave_id;
5754 /* remove the slave from a bonded device. */
5755 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) {
5756 printf("\t Failed to remove slave %d from master port = %d.\n",
5757 slave_port_id, master_port_id);
5761 clear_port_slave_flag(slave_port_id);
5764 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5765 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5767 cmdline_parse_token_string_t cmd_removebonding_slave_bonding =
5768 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5769 bonding, "bonding");
5770 cmdline_parse_token_string_t cmd_removebonding_slave_slave =
5771 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5773 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5774 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5776 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5777 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5780 cmdline_parse_inst_t cmd_remove_bonding_slave = {
5781 .f = cmd_remove_bonding_slave_parsed,
5782 .help_str = "remove bonding slave <slave_id> <port_id>: "
5783 "Remove a slave device from a bonded device",
5786 (void *)&cmd_removebonding_slave_remove,
5787 (void *)&cmd_removebonding_slave_bonding,
5788 (void *)&cmd_removebonding_slave_slave,
5789 (void *)&cmd_removebonding_slave_slaveid,
5790 (void *)&cmd_removebonding_slave_port,
5795 /* *** CREATE BONDED DEVICE *** */
5796 struct cmd_create_bonded_device_result {
5797 cmdline_fixed_string_t create;
5798 cmdline_fixed_string_t bonded;
5799 cmdline_fixed_string_t device;
5804 static int bond_dev_num = 0;
5806 static void cmd_create_bonded_device_parsed(void *parsed_result,
5807 __attribute__((unused)) struct cmdline *cl,
5808 __attribute__((unused)) void *data)
5810 struct cmd_create_bonded_device_result *res = parsed_result;
5811 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5814 if (test_done == 0) {
5815 printf("Please stop forwarding first\n");
5819 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5822 /* Create a new bonded device. */
5823 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5825 printf("\t Failed to create bonded device.\n");
5828 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5831 /* Update number of ports */
5832 nb_ports = rte_eth_dev_count_avail();
5833 reconfig(port_id, res->socket);
5834 rte_eth_promiscuous_enable(port_id);
5839 cmdline_parse_token_string_t cmd_createbonded_device_create =
5840 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5842 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5843 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5845 cmdline_parse_token_string_t cmd_createbonded_device_device =
5846 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5848 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5849 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5851 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5852 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5855 cmdline_parse_inst_t cmd_create_bonded_device = {
5856 .f = cmd_create_bonded_device_parsed,
5857 .help_str = "create bonded device <mode> <socket>: "
5858 "Create a new bonded device with specific bonding mode and socket",
5861 (void *)&cmd_createbonded_device_create,
5862 (void *)&cmd_createbonded_device_bonded,
5863 (void *)&cmd_createbonded_device_device,
5864 (void *)&cmd_createbonded_device_mode,
5865 (void *)&cmd_createbonded_device_socket,
5870 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */
5871 struct cmd_set_bond_mac_addr_result {
5872 cmdline_fixed_string_t set;
5873 cmdline_fixed_string_t bonding;
5874 cmdline_fixed_string_t mac_addr;
5876 struct ether_addr address;
5879 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5880 __attribute__((unused)) struct cmdline *cl,
5881 __attribute__((unused)) void *data)
5883 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5886 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5889 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5891 /* check the return value and print it if is < 0 */
5893 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5896 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set =
5897 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set");
5898 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding =
5899 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding,
5901 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac =
5902 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr,
5904 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum =
5905 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result,
5907 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5908 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5910 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5911 .f = cmd_set_bond_mac_addr_parsed,
5913 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5915 (void *)&cmd_set_bond_mac_addr_set,
5916 (void *)&cmd_set_bond_mac_addr_bonding,
5917 (void *)&cmd_set_bond_mac_addr_mac,
5918 (void *)&cmd_set_bond_mac_addr_portnum,
5919 (void *)&cmd_set_bond_mac_addr_addr,
5925 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */
5926 struct cmd_set_bond_mon_period_result {
5927 cmdline_fixed_string_t set;
5928 cmdline_fixed_string_t bonding;
5929 cmdline_fixed_string_t mon_period;
5934 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5935 __attribute__((unused)) struct cmdline *cl,
5936 __attribute__((unused)) void *data)
5938 struct cmd_set_bond_mon_period_result *res = parsed_result;
5941 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5943 /* check the return value and print it if is < 0 */
5945 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5948 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5949 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5951 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding =
5952 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5953 bonding, "bonding");
5954 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period =
5955 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5956 mon_period, "mon_period");
5957 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum =
5958 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5960 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5961 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5964 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5965 .f = cmd_set_bond_mon_period_parsed,
5967 .help_str = "set bonding mon_period <port_id> <period_ms>",
5969 (void *)&cmd_set_bond_mon_period_set,
5970 (void *)&cmd_set_bond_mon_period_bonding,
5971 (void *)&cmd_set_bond_mon_period_mon_period,
5972 (void *)&cmd_set_bond_mon_period_portnum,
5973 (void *)&cmd_set_bond_mon_period_period_ms,
5980 struct cmd_set_bonding_agg_mode_policy_result {
5981 cmdline_fixed_string_t set;
5982 cmdline_fixed_string_t bonding;
5983 cmdline_fixed_string_t agg_mode;
5985 cmdline_fixed_string_t policy;
5990 cmd_set_bonding_agg_mode(void *parsed_result,
5991 __attribute__((unused)) struct cmdline *cl,
5992 __attribute__((unused)) void *data)
5994 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5995 uint8_t policy = AGG_BANDWIDTH;
5997 if (!strcmp(res->policy, "bandwidth"))
5998 policy = AGG_BANDWIDTH;
5999 else if (!strcmp(res->policy, "stable"))
6000 policy = AGG_STABLE;
6001 else if (!strcmp(res->policy, "count"))
6004 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6008 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6009 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6011 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding =
6012 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6013 bonding, "bonding");
6015 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode =
6016 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6017 agg_mode, "agg_mode");
6019 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6020 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6023 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string =
6024 TOKEN_STRING_INITIALIZER(
6025 struct cmd_set_bonding_balance_xmit_policy_result,
6026 policy, "stable#bandwidth#count");
6028 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6029 .f = cmd_set_bonding_agg_mode,
6031 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6033 (void *)&cmd_set_bonding_agg_mode_set,
6034 (void *)&cmd_set_bonding_agg_mode_bonding,
6035 (void *)&cmd_set_bonding_agg_mode_agg_mode,
6036 (void *)&cmd_set_bonding_agg_mode_portnum,
6037 (void *)&cmd_set_bonding_agg_mode_policy_string,
6043 #endif /* RTE_LIBRTE_PMD_BOND */
6045 /* *** SET FORWARDING MODE *** */
6046 struct cmd_set_fwd_mode_result {
6047 cmdline_fixed_string_t set;
6048 cmdline_fixed_string_t fwd;
6049 cmdline_fixed_string_t mode;
6052 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6053 __attribute__((unused)) struct cmdline *cl,
6054 __attribute__((unused)) void *data)
6056 struct cmd_set_fwd_mode_result *res = parsed_result;
6059 set_pkt_forwarding_mode(res->mode);
6062 cmdline_parse_token_string_t cmd_setfwd_set =
6063 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6064 cmdline_parse_token_string_t cmd_setfwd_fwd =
6065 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6066 cmdline_parse_token_string_t cmd_setfwd_mode =
6067 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6068 "" /* defined at init */);
6070 cmdline_parse_inst_t cmd_set_fwd_mode = {
6071 .f = cmd_set_fwd_mode_parsed,
6073 .help_str = NULL, /* defined at init */
6075 (void *)&cmd_setfwd_set,
6076 (void *)&cmd_setfwd_fwd,
6077 (void *)&cmd_setfwd_mode,
6082 static void cmd_set_fwd_mode_init(void)
6085 static char token[128];
6086 static char help[256];
6087 cmdline_parse_token_string_t *token_struct;
6089 modes = list_pkt_forwarding_modes();
6090 snprintf(help, sizeof(help), "set fwd %s: "
6091 "Set packet forwarding mode", modes);
6092 cmd_set_fwd_mode.help_str = help;
6094 /* string token separator is # */
6095 for (c = token; *modes != '\0'; modes++)
6100 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6101 token_struct->string_data.str = token;
6104 /* *** SET RETRY FORWARDING MODE *** */
6105 struct cmd_set_fwd_retry_mode_result {
6106 cmdline_fixed_string_t set;
6107 cmdline_fixed_string_t fwd;
6108 cmdline_fixed_string_t mode;
6109 cmdline_fixed_string_t retry;
6112 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6113 __attribute__((unused)) struct cmdline *cl,
6114 __attribute__((unused)) void *data)
6116 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6119 set_pkt_forwarding_mode(res->mode);
6122 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6123 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6125 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6126 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6128 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6129 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6131 "" /* defined at init */);
6132 cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6133 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6136 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6137 .f = cmd_set_fwd_retry_mode_parsed,
6139 .help_str = NULL, /* defined at init */
6141 (void *)&cmd_setfwd_retry_set,
6142 (void *)&cmd_setfwd_retry_fwd,
6143 (void *)&cmd_setfwd_retry_mode,
6144 (void *)&cmd_setfwd_retry_retry,
6149 static void cmd_set_fwd_retry_mode_init(void)
6152 static char token[128];
6153 static char help[256];
6154 cmdline_parse_token_string_t *token_struct;
6156 modes = list_pkt_forwarding_retry_modes();
6157 snprintf(help, sizeof(help), "set fwd %s retry: "
6158 "Set packet forwarding mode with retry", modes);
6159 cmd_set_fwd_retry_mode.help_str = help;
6161 /* string token separator is # */
6162 for (c = token; *modes != '\0'; modes++)
6167 token_struct = (cmdline_parse_token_string_t *)
6168 cmd_set_fwd_retry_mode.tokens[2];
6169 token_struct->string_data.str = token;
6172 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6173 struct cmd_set_burst_tx_retry_result {
6174 cmdline_fixed_string_t set;
6175 cmdline_fixed_string_t burst;
6176 cmdline_fixed_string_t tx;
6177 cmdline_fixed_string_t delay;
6179 cmdline_fixed_string_t retry;
6183 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6184 __attribute__((unused)) struct cmdline *cl,
6185 __attribute__((unused)) void *data)
6187 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6189 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6190 && !strcmp(res->tx, "tx")) {
6191 if (!strcmp(res->delay, "delay"))
6192 burst_tx_delay_time = res->time;
6193 if (!strcmp(res->retry, "retry"))
6194 burst_tx_retry_num = res->retry_num;
6199 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6200 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6201 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6202 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6204 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6205 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6206 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6207 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6208 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6209 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32);
6210 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6211 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6212 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6213 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32);
6215 cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6216 .f = cmd_set_burst_tx_retry_parsed,
6217 .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6219 (void *)&cmd_set_burst_tx_retry_set,
6220 (void *)&cmd_set_burst_tx_retry_burst,
6221 (void *)&cmd_set_burst_tx_retry_tx,
6222 (void *)&cmd_set_burst_tx_retry_delay,
6223 (void *)&cmd_set_burst_tx_retry_time,
6224 (void *)&cmd_set_burst_tx_retry_retry,
6225 (void *)&cmd_set_burst_tx_retry_retry_num,
6230 /* *** SET PROMISC MODE *** */
6231 struct cmd_set_promisc_mode_result {
6232 cmdline_fixed_string_t set;
6233 cmdline_fixed_string_t promisc;
6234 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6235 uint16_t port_num; /* valid if "allports" argument == 0 */
6236 cmdline_fixed_string_t mode;
6239 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6240 __attribute__((unused)) struct cmdline *cl,
6243 struct cmd_set_promisc_mode_result *res = parsed_result;
6247 if (!strcmp(res->mode, "on"))
6254 RTE_ETH_FOREACH_DEV(i) {
6256 rte_eth_promiscuous_enable(i);
6258 rte_eth_promiscuous_disable(i);
6263 rte_eth_promiscuous_enable(res->port_num);
6265 rte_eth_promiscuous_disable(res->port_num);
6269 cmdline_parse_token_string_t cmd_setpromisc_set =
6270 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6271 cmdline_parse_token_string_t cmd_setpromisc_promisc =
6272 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6274 cmdline_parse_token_string_t cmd_setpromisc_portall =
6275 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6277 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6278 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6280 cmdline_parse_token_string_t cmd_setpromisc_mode =
6281 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6284 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6285 .f = cmd_set_promisc_mode_parsed,
6287 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6289 (void *)&cmd_setpromisc_set,
6290 (void *)&cmd_setpromisc_promisc,
6291 (void *)&cmd_setpromisc_portall,
6292 (void *)&cmd_setpromisc_mode,
6297 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6298 .f = cmd_set_promisc_mode_parsed,
6300 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6302 (void *)&cmd_setpromisc_set,
6303 (void *)&cmd_setpromisc_promisc,
6304 (void *)&cmd_setpromisc_portnum,
6305 (void *)&cmd_setpromisc_mode,
6310 /* *** SET ALLMULTI MODE *** */
6311 struct cmd_set_allmulti_mode_result {
6312 cmdline_fixed_string_t set;
6313 cmdline_fixed_string_t allmulti;
6314 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6315 uint16_t port_num; /* valid if "allports" argument == 0 */
6316 cmdline_fixed_string_t mode;
6319 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6320 __attribute__((unused)) struct cmdline *cl,
6323 struct cmd_set_allmulti_mode_result *res = parsed_result;
6327 if (!strcmp(res->mode, "on"))
6334 RTE_ETH_FOREACH_DEV(i) {
6336 rte_eth_allmulticast_enable(i);
6338 rte_eth_allmulticast_disable(i);
6343 rte_eth_allmulticast_enable(res->port_num);
6345 rte_eth_allmulticast_disable(res->port_num);
6349 cmdline_parse_token_string_t cmd_setallmulti_set =
6350 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6351 cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6352 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6354 cmdline_parse_token_string_t cmd_setallmulti_portall =
6355 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6357 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6358 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6360 cmdline_parse_token_string_t cmd_setallmulti_mode =
6361 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6364 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6365 .f = cmd_set_allmulti_mode_parsed,
6367 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6369 (void *)&cmd_setallmulti_set,
6370 (void *)&cmd_setallmulti_allmulti,
6371 (void *)&cmd_setallmulti_portall,
6372 (void *)&cmd_setallmulti_mode,
6377 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6378 .f = cmd_set_allmulti_mode_parsed,
6380 .help_str = "set allmulti <port_id> on|off: "
6381 "Set allmulti mode on port_id",
6383 (void *)&cmd_setallmulti_set,
6384 (void *)&cmd_setallmulti_allmulti,
6385 (void *)&cmd_setallmulti_portnum,
6386 (void *)&cmd_setallmulti_mode,
6391 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6392 struct cmd_link_flow_ctrl_set_result {
6393 cmdline_fixed_string_t set;
6394 cmdline_fixed_string_t flow_ctrl;
6395 cmdline_fixed_string_t rx;
6396 cmdline_fixed_string_t rx_lfc_mode;
6397 cmdline_fixed_string_t tx;
6398 cmdline_fixed_string_t tx_lfc_mode;
6399 cmdline_fixed_string_t mac_ctrl_frame_fwd;
6400 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6401 cmdline_fixed_string_t autoneg_str;
6402 cmdline_fixed_string_t autoneg;
6403 cmdline_fixed_string_t hw_str;
6404 uint32_t high_water;
6405 cmdline_fixed_string_t lw_str;
6407 cmdline_fixed_string_t pt_str;
6408 uint16_t pause_time;
6409 cmdline_fixed_string_t xon_str;
6414 cmdline_parse_token_string_t cmd_lfc_set_set =
6415 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6417 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6418 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6419 flow_ctrl, "flow_ctrl");
6420 cmdline_parse_token_string_t cmd_lfc_set_rx =
6421 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6423 cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6424 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6425 rx_lfc_mode, "on#off");
6426 cmdline_parse_token_string_t cmd_lfc_set_tx =
6427 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6429 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6430 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6431 tx_lfc_mode, "on#off");
6432 cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6433 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6434 hw_str, "high_water");
6435 cmdline_parse_token_num_t cmd_lfc_set_high_water =
6436 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6437 high_water, UINT32);
6438 cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6439 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6440 lw_str, "low_water");
6441 cmdline_parse_token_num_t cmd_lfc_set_low_water =
6442 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6444 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6445 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6446 pt_str, "pause_time");
6447 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6448 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6449 pause_time, UINT16);
6450 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6451 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6452 xon_str, "send_xon");
6453 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6454 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6456 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6457 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6458 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6459 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6460 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6461 mac_ctrl_frame_fwd_mode, "on#off");
6462 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6463 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6464 autoneg_str, "autoneg");
6465 cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6466 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6468 cmdline_parse_token_num_t cmd_lfc_set_portid =
6469 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6472 /* forward declaration */
6474 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6477 cmdline_parse_inst_t cmd_link_flow_control_set = {
6478 .f = cmd_link_flow_ctrl_set_parsed,
6480 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6481 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6482 "autoneg on|off <port_id>: Configure the Ethernet flow control",
6484 (void *)&cmd_lfc_set_set,
6485 (void *)&cmd_lfc_set_flow_ctrl,
6486 (void *)&cmd_lfc_set_rx,
6487 (void *)&cmd_lfc_set_rx_mode,
6488 (void *)&cmd_lfc_set_tx,
6489 (void *)&cmd_lfc_set_tx_mode,
6490 (void *)&cmd_lfc_set_high_water,
6491 (void *)&cmd_lfc_set_low_water,
6492 (void *)&cmd_lfc_set_pause_time,
6493 (void *)&cmd_lfc_set_send_xon,
6494 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6495 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6496 (void *)&cmd_lfc_set_autoneg_str,
6497 (void *)&cmd_lfc_set_autoneg,
6498 (void *)&cmd_lfc_set_portid,
6503 cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6504 .f = cmd_link_flow_ctrl_set_parsed,
6505 .data = (void *)&cmd_link_flow_control_set_rx,
6506 .help_str = "set flow_ctrl rx on|off <port_id>: "
6507 "Change rx flow control parameter",
6509 (void *)&cmd_lfc_set_set,
6510 (void *)&cmd_lfc_set_flow_ctrl,
6511 (void *)&cmd_lfc_set_rx,
6512 (void *)&cmd_lfc_set_rx_mode,
6513 (void *)&cmd_lfc_set_portid,
6518 cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6519 .f = cmd_link_flow_ctrl_set_parsed,
6520 .data = (void *)&cmd_link_flow_control_set_tx,
6521 .help_str = "set flow_ctrl tx on|off <port_id>: "
6522 "Change tx flow control parameter",
6524 (void *)&cmd_lfc_set_set,
6525 (void *)&cmd_lfc_set_flow_ctrl,
6526 (void *)&cmd_lfc_set_tx,
6527 (void *)&cmd_lfc_set_tx_mode,
6528 (void *)&cmd_lfc_set_portid,
6533 cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6534 .f = cmd_link_flow_ctrl_set_parsed,
6535 .data = (void *)&cmd_link_flow_control_set_hw,
6536 .help_str = "set flow_ctrl high_water <value> <port_id>: "
6537 "Change high water flow control parameter",
6539 (void *)&cmd_lfc_set_set,
6540 (void *)&cmd_lfc_set_flow_ctrl,
6541 (void *)&cmd_lfc_set_high_water_str,
6542 (void *)&cmd_lfc_set_high_water,
6543 (void *)&cmd_lfc_set_portid,
6548 cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6549 .f = cmd_link_flow_ctrl_set_parsed,
6550 .data = (void *)&cmd_link_flow_control_set_lw,
6551 .help_str = "set flow_ctrl low_water <value> <port_id>: "
6552 "Change low water flow control parameter",
6554 (void *)&cmd_lfc_set_set,
6555 (void *)&cmd_lfc_set_flow_ctrl,
6556 (void *)&cmd_lfc_set_low_water_str,
6557 (void *)&cmd_lfc_set_low_water,
6558 (void *)&cmd_lfc_set_portid,
6563 cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6564 .f = cmd_link_flow_ctrl_set_parsed,
6565 .data = (void *)&cmd_link_flow_control_set_pt,
6566 .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6567 "Change pause time flow control parameter",
6569 (void *)&cmd_lfc_set_set,
6570 (void *)&cmd_lfc_set_flow_ctrl,
6571 (void *)&cmd_lfc_set_pause_time_str,
6572 (void *)&cmd_lfc_set_pause_time,
6573 (void *)&cmd_lfc_set_portid,
6578 cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6579 .f = cmd_link_flow_ctrl_set_parsed,
6580 .data = (void *)&cmd_link_flow_control_set_xon,
6581 .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6582 "Change send_xon flow control parameter",
6584 (void *)&cmd_lfc_set_set,
6585 (void *)&cmd_lfc_set_flow_ctrl,
6586 (void *)&cmd_lfc_set_send_xon_str,
6587 (void *)&cmd_lfc_set_send_xon,
6588 (void *)&cmd_lfc_set_portid,
6593 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6594 .f = cmd_link_flow_ctrl_set_parsed,
6595 .data = (void *)&cmd_link_flow_control_set_macfwd,
6596 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6597 "Change mac ctrl fwd flow control parameter",
6599 (void *)&cmd_lfc_set_set,
6600 (void *)&cmd_lfc_set_flow_ctrl,
6601 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6602 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6603 (void *)&cmd_lfc_set_portid,
6608 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6609 .f = cmd_link_flow_ctrl_set_parsed,
6610 .data = (void *)&cmd_link_flow_control_set_autoneg,
6611 .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6612 "Change autoneg flow control parameter",
6614 (void *)&cmd_lfc_set_set,
6615 (void *)&cmd_lfc_set_flow_ctrl,
6616 (void *)&cmd_lfc_set_autoneg_str,
6617 (void *)&cmd_lfc_set_autoneg,
6618 (void *)&cmd_lfc_set_portid,
6624 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6625 __attribute__((unused)) struct cmdline *cl,
6628 struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6629 cmdline_parse_inst_t *cmd = data;
6630 struct rte_eth_fc_conf fc_conf;
6636 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6637 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6638 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6639 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6641 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6642 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
6645 /* Partial command line, retrieve current configuration */
6647 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6649 printf("cannot get current flow ctrl parameters, return"
6650 "code = %d\n", ret);
6654 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6655 (fc_conf.mode == RTE_FC_FULL))
6657 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6658 (fc_conf.mode == RTE_FC_FULL))
6662 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6663 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6665 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6666 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6668 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6670 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6671 fc_conf.high_water = res->high_water;
6673 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6674 fc_conf.low_water = res->low_water;
6676 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6677 fc_conf.pause_time = res->pause_time;
6679 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6680 fc_conf.send_xon = res->send_xon;
6682 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6683 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6684 fc_conf.mac_ctrl_frame_fwd = 1;
6686 fc_conf.mac_ctrl_frame_fwd = 0;
6689 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6690 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6692 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6694 printf("bad flow contrl parameter, return code = %d \n", ret);
6697 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6698 struct cmd_priority_flow_ctrl_set_result {
6699 cmdline_fixed_string_t set;
6700 cmdline_fixed_string_t pfc_ctrl;
6701 cmdline_fixed_string_t rx;
6702 cmdline_fixed_string_t rx_pfc_mode;
6703 cmdline_fixed_string_t tx;
6704 cmdline_fixed_string_t tx_pfc_mode;
6705 uint32_t high_water;
6707 uint16_t pause_time;
6713 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6714 __attribute__((unused)) struct cmdline *cl,
6715 __attribute__((unused)) void *data)
6717 struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6718 struct rte_eth_pfc_conf pfc_conf;
6719 int rx_fc_enable, tx_fc_enable;
6723 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6724 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6725 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6726 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6728 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6729 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL}
6732 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6733 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6734 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6735 pfc_conf.fc.high_water = res->high_water;
6736 pfc_conf.fc.low_water = res->low_water;
6737 pfc_conf.fc.pause_time = res->pause_time;
6738 pfc_conf.priority = res->priority;
6740 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6742 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6745 cmdline_parse_token_string_t cmd_pfc_set_set =
6746 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6748 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6749 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6750 pfc_ctrl, "pfc_ctrl");
6751 cmdline_parse_token_string_t cmd_pfc_set_rx =
6752 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6754 cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6755 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6756 rx_pfc_mode, "on#off");
6757 cmdline_parse_token_string_t cmd_pfc_set_tx =
6758 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6760 cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6761 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6762 tx_pfc_mode, "on#off");
6763 cmdline_parse_token_num_t cmd_pfc_set_high_water =
6764 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6765 high_water, UINT32);
6766 cmdline_parse_token_num_t cmd_pfc_set_low_water =
6767 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6769 cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6770 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6771 pause_time, UINT16);
6772 cmdline_parse_token_num_t cmd_pfc_set_priority =
6773 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6775 cmdline_parse_token_num_t cmd_pfc_set_portid =
6776 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6779 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6780 .f = cmd_priority_flow_ctrl_set_parsed,
6782 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6783 "<pause_time> <priority> <port_id>: "
6784 "Configure the Ethernet priority flow control",
6786 (void *)&cmd_pfc_set_set,
6787 (void *)&cmd_pfc_set_flow_ctrl,
6788 (void *)&cmd_pfc_set_rx,
6789 (void *)&cmd_pfc_set_rx_mode,
6790 (void *)&cmd_pfc_set_tx,
6791 (void *)&cmd_pfc_set_tx_mode,
6792 (void *)&cmd_pfc_set_high_water,
6793 (void *)&cmd_pfc_set_low_water,
6794 (void *)&cmd_pfc_set_pause_time,
6795 (void *)&cmd_pfc_set_priority,
6796 (void *)&cmd_pfc_set_portid,
6801 /* *** RESET CONFIGURATION *** */
6802 struct cmd_reset_result {
6803 cmdline_fixed_string_t reset;
6804 cmdline_fixed_string_t def;
6807 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6809 __attribute__((unused)) void *data)
6811 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6812 set_def_fwd_config();
6815 cmdline_parse_token_string_t cmd_reset_set =
6816 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6817 cmdline_parse_token_string_t cmd_reset_def =
6818 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6821 cmdline_parse_inst_t cmd_reset = {
6822 .f = cmd_reset_parsed,
6824 .help_str = "set default: Reset default forwarding configuration",
6826 (void *)&cmd_reset_set,
6827 (void *)&cmd_reset_def,
6832 /* *** START FORWARDING *** */
6833 struct cmd_start_result {
6834 cmdline_fixed_string_t start;
6837 cmdline_parse_token_string_t cmd_start_start =
6838 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6840 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6841 __attribute__((unused)) struct cmdline *cl,
6842 __attribute__((unused)) void *data)
6844 start_packet_forwarding(0);
6847 cmdline_parse_inst_t cmd_start = {
6848 .f = cmd_start_parsed,
6850 .help_str = "start: Start packet forwarding",
6852 (void *)&cmd_start_start,
6857 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6858 struct cmd_start_tx_first_result {
6859 cmdline_fixed_string_t start;
6860 cmdline_fixed_string_t tx_first;
6864 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6865 __attribute__((unused)) struct cmdline *cl,
6866 __attribute__((unused)) void *data)
6868 start_packet_forwarding(1);
6871 cmdline_parse_token_string_t cmd_start_tx_first_start =
6872 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6874 cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6875 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6876 tx_first, "tx_first");
6878 cmdline_parse_inst_t cmd_start_tx_first = {
6879 .f = cmd_start_tx_first_parsed,
6881 .help_str = "start tx_first: Start packet forwarding, "
6882 "after sending 1 burst of packets",
6884 (void *)&cmd_start_tx_first_start,
6885 (void *)&cmd_start_tx_first_tx_first,
6890 /* *** START FORWARDING WITH N TX BURST FIRST *** */
6891 struct cmd_start_tx_first_n_result {
6892 cmdline_fixed_string_t start;
6893 cmdline_fixed_string_t tx_first;
6898 cmd_start_tx_first_n_parsed(void *parsed_result,
6899 __attribute__((unused)) struct cmdline *cl,
6900 __attribute__((unused)) void *data)
6902 struct cmd_start_tx_first_n_result *res = parsed_result;
6904 start_packet_forwarding(res->tx_num);
6907 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6908 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6910 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6911 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6912 tx_first, "tx_first");
6913 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6914 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6917 cmdline_parse_inst_t cmd_start_tx_first_n = {
6918 .f = cmd_start_tx_first_n_parsed,
6920 .help_str = "start tx_first <num>: "
6921 "packet forwarding, after sending <num> bursts of packets",
6923 (void *)&cmd_start_tx_first_n_start,
6924 (void *)&cmd_start_tx_first_n_tx_first,
6925 (void *)&cmd_start_tx_first_n_tx_num,
6930 /* *** SET LINK UP *** */
6931 struct cmd_set_link_up_result {
6932 cmdline_fixed_string_t set;
6933 cmdline_fixed_string_t link_up;
6934 cmdline_fixed_string_t port;
6938 cmdline_parse_token_string_t cmd_set_link_up_set =
6939 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6940 cmdline_parse_token_string_t cmd_set_link_up_link_up =
6941 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6943 cmdline_parse_token_string_t cmd_set_link_up_port =
6944 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6945 cmdline_parse_token_num_t cmd_set_link_up_port_id =
6946 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16);
6948 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6949 __attribute__((unused)) struct cmdline *cl,
6950 __attribute__((unused)) void *data)
6952 struct cmd_set_link_up_result *res = parsed_result;
6953 dev_set_link_up(res->port_id);
6956 cmdline_parse_inst_t cmd_set_link_up = {
6957 .f = cmd_set_link_up_parsed,
6959 .help_str = "set link-up port <port id>",
6961 (void *)&cmd_set_link_up_set,
6962 (void *)&cmd_set_link_up_link_up,
6963 (void *)&cmd_set_link_up_port,
6964 (void *)&cmd_set_link_up_port_id,
6969 /* *** SET LINK DOWN *** */
6970 struct cmd_set_link_down_result {
6971 cmdline_fixed_string_t set;
6972 cmdline_fixed_string_t link_down;
6973 cmdline_fixed_string_t port;
6977 cmdline_parse_token_string_t cmd_set_link_down_set =
6978 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6979 cmdline_parse_token_string_t cmd_set_link_down_link_down =
6980 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6982 cmdline_parse_token_string_t cmd_set_link_down_port =
6983 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6984 cmdline_parse_token_num_t cmd_set_link_down_port_id =
6985 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16);
6987 static void cmd_set_link_down_parsed(
6988 __attribute__((unused)) void *parsed_result,
6989 __attribute__((unused)) struct cmdline *cl,
6990 __attribute__((unused)) void *data)
6992 struct cmd_set_link_down_result *res = parsed_result;
6993 dev_set_link_down(res->port_id);
6996 cmdline_parse_inst_t cmd_set_link_down = {
6997 .f = cmd_set_link_down_parsed,
6999 .help_str = "set link-down port <port id>",
7001 (void *)&cmd_set_link_down_set,
7002 (void *)&cmd_set_link_down_link_down,
7003 (void *)&cmd_set_link_down_port,
7004 (void *)&cmd_set_link_down_port_id,
7009 /* *** SHOW CFG *** */
7010 struct cmd_showcfg_result {
7011 cmdline_fixed_string_t show;
7012 cmdline_fixed_string_t cfg;
7013 cmdline_fixed_string_t what;
7016 static void cmd_showcfg_parsed(void *parsed_result,
7017 __attribute__((unused)) struct cmdline *cl,
7018 __attribute__((unused)) void *data)
7020 struct cmd_showcfg_result *res = parsed_result;
7021 if (!strcmp(res->what, "rxtx"))
7022 rxtx_config_display();
7023 else if (!strcmp(res->what, "cores"))
7024 fwd_lcores_config_display();
7025 else if (!strcmp(res->what, "fwd"))
7026 pkt_fwd_config_display(&cur_fwd_config);
7027 else if (!strcmp(res->what, "txpkts"))
7028 show_tx_pkt_segments();
7031 cmdline_parse_token_string_t cmd_showcfg_show =
7032 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7033 cmdline_parse_token_string_t cmd_showcfg_port =
7034 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7035 cmdline_parse_token_string_t cmd_showcfg_what =
7036 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7037 "rxtx#cores#fwd#txpkts");
7039 cmdline_parse_inst_t cmd_showcfg = {
7040 .f = cmd_showcfg_parsed,
7042 .help_str = "show config rxtx|cores|fwd|txpkts",
7044 (void *)&cmd_showcfg_show,
7045 (void *)&cmd_showcfg_port,
7046 (void *)&cmd_showcfg_what,
7051 /* *** SHOW ALL PORT INFO *** */
7052 struct cmd_showportall_result {
7053 cmdline_fixed_string_t show;
7054 cmdline_fixed_string_t port;
7055 cmdline_fixed_string_t what;
7056 cmdline_fixed_string_t all;
7059 static void cmd_showportall_parsed(void *parsed_result,
7060 __attribute__((unused)) struct cmdline *cl,
7061 __attribute__((unused)) void *data)
7065 struct cmd_showportall_result *res = parsed_result;
7066 if (!strcmp(res->show, "clear")) {
7067 if (!strcmp(res->what, "stats"))
7068 RTE_ETH_FOREACH_DEV(i)
7070 else if (!strcmp(res->what, "xstats"))
7071 RTE_ETH_FOREACH_DEV(i)
7072 nic_xstats_clear(i);
7073 } else if (!strcmp(res->what, "info"))
7074 RTE_ETH_FOREACH_DEV(i)
7075 port_infos_display(i);
7076 else if (!strcmp(res->what, "stats"))
7077 RTE_ETH_FOREACH_DEV(i)
7078 nic_stats_display(i);
7079 else if (!strcmp(res->what, "xstats"))
7080 RTE_ETH_FOREACH_DEV(i)
7081 nic_xstats_display(i);
7082 else if (!strcmp(res->what, "fdir"))
7083 RTE_ETH_FOREACH_DEV(i)
7085 else if (!strcmp(res->what, "stat_qmap"))
7086 RTE_ETH_FOREACH_DEV(i)
7087 nic_stats_mapping_display(i);
7088 else if (!strcmp(res->what, "dcb_tc"))
7089 RTE_ETH_FOREACH_DEV(i)
7090 port_dcb_info_display(i);
7091 else if (!strcmp(res->what, "cap"))
7092 RTE_ETH_FOREACH_DEV(i)
7093 port_offload_cap_display(i);
7096 cmdline_parse_token_string_t cmd_showportall_show =
7097 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7099 cmdline_parse_token_string_t cmd_showportall_port =
7100 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7101 cmdline_parse_token_string_t cmd_showportall_what =
7102 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7103 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7104 cmdline_parse_token_string_t cmd_showportall_all =
7105 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7106 cmdline_parse_inst_t cmd_showportall = {
7107 .f = cmd_showportall_parsed,
7109 .help_str = "show|clear port "
7110 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7112 (void *)&cmd_showportall_show,
7113 (void *)&cmd_showportall_port,
7114 (void *)&cmd_showportall_what,
7115 (void *)&cmd_showportall_all,
7120 /* *** SHOW PORT INFO *** */
7121 struct cmd_showport_result {
7122 cmdline_fixed_string_t show;
7123 cmdline_fixed_string_t port;
7124 cmdline_fixed_string_t what;
7128 static void cmd_showport_parsed(void *parsed_result,
7129 __attribute__((unused)) struct cmdline *cl,
7130 __attribute__((unused)) void *data)
7132 struct cmd_showport_result *res = parsed_result;
7133 if (!strcmp(res->show, "clear")) {
7134 if (!strcmp(res->what, "stats"))
7135 nic_stats_clear(res->portnum);
7136 else if (!strcmp(res->what, "xstats"))
7137 nic_xstats_clear(res->portnum);
7138 } else if (!strcmp(res->what, "info"))
7139 port_infos_display(res->portnum);
7140 else if (!strcmp(res->what, "stats"))
7141 nic_stats_display(res->portnum);
7142 else if (!strcmp(res->what, "xstats"))
7143 nic_xstats_display(res->portnum);
7144 else if (!strcmp(res->what, "fdir"))
7145 fdir_get_infos(res->portnum);
7146 else if (!strcmp(res->what, "stat_qmap"))
7147 nic_stats_mapping_display(res->portnum);
7148 else if (!strcmp(res->what, "dcb_tc"))
7149 port_dcb_info_display(res->portnum);
7150 else if (!strcmp(res->what, "cap"))
7151 port_offload_cap_display(res->portnum);
7154 cmdline_parse_token_string_t cmd_showport_show =
7155 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7157 cmdline_parse_token_string_t cmd_showport_port =
7158 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7159 cmdline_parse_token_string_t cmd_showport_what =
7160 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7161 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap");
7162 cmdline_parse_token_num_t cmd_showport_portnum =
7163 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16);
7165 cmdline_parse_inst_t cmd_showport = {
7166 .f = cmd_showport_parsed,
7168 .help_str = "show|clear port "
7169 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7172 (void *)&cmd_showport_show,
7173 (void *)&cmd_showport_port,
7174 (void *)&cmd_showport_what,
7175 (void *)&cmd_showport_portnum,
7180 /* *** SHOW QUEUE INFO *** */
7181 struct cmd_showqueue_result {
7182 cmdline_fixed_string_t show;
7183 cmdline_fixed_string_t type;
7184 cmdline_fixed_string_t what;
7190 cmd_showqueue_parsed(void *parsed_result,
7191 __attribute__((unused)) struct cmdline *cl,
7192 __attribute__((unused)) void *data)
7194 struct cmd_showqueue_result *res = parsed_result;
7196 if (!strcmp(res->type, "rxq"))
7197 rx_queue_infos_display(res->portnum, res->queuenum);
7198 else if (!strcmp(res->type, "txq"))
7199 tx_queue_infos_display(res->portnum, res->queuenum);
7202 cmdline_parse_token_string_t cmd_showqueue_show =
7203 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7204 cmdline_parse_token_string_t cmd_showqueue_type =
7205 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7206 cmdline_parse_token_string_t cmd_showqueue_what =
7207 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7208 cmdline_parse_token_num_t cmd_showqueue_portnum =
7209 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16);
7210 cmdline_parse_token_num_t cmd_showqueue_queuenum =
7211 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16);
7213 cmdline_parse_inst_t cmd_showqueue = {
7214 .f = cmd_showqueue_parsed,
7216 .help_str = "show rxq|txq info <port_id> <queue_id>",
7218 (void *)&cmd_showqueue_show,
7219 (void *)&cmd_showqueue_type,
7220 (void *)&cmd_showqueue_what,
7221 (void *)&cmd_showqueue_portnum,
7222 (void *)&cmd_showqueue_queuenum,
7227 /* *** READ PORT REGISTER *** */
7228 struct cmd_read_reg_result {
7229 cmdline_fixed_string_t read;
7230 cmdline_fixed_string_t reg;
7236 cmd_read_reg_parsed(void *parsed_result,
7237 __attribute__((unused)) struct cmdline *cl,
7238 __attribute__((unused)) void *data)
7240 struct cmd_read_reg_result *res = parsed_result;
7241 port_reg_display(res->port_id, res->reg_off);
7244 cmdline_parse_token_string_t cmd_read_reg_read =
7245 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read");
7246 cmdline_parse_token_string_t cmd_read_reg_reg =
7247 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg");
7248 cmdline_parse_token_num_t cmd_read_reg_port_id =
7249 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16);
7250 cmdline_parse_token_num_t cmd_read_reg_reg_off =
7251 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32);
7253 cmdline_parse_inst_t cmd_read_reg = {
7254 .f = cmd_read_reg_parsed,
7256 .help_str = "read reg <port_id> <reg_off>",
7258 (void *)&cmd_read_reg_read,
7259 (void *)&cmd_read_reg_reg,
7260 (void *)&cmd_read_reg_port_id,
7261 (void *)&cmd_read_reg_reg_off,
7266 /* *** READ PORT REGISTER BIT FIELD *** */
7267 struct cmd_read_reg_bit_field_result {
7268 cmdline_fixed_string_t read;
7269 cmdline_fixed_string_t regfield;
7277 cmd_read_reg_bit_field_parsed(void *parsed_result,
7278 __attribute__((unused)) struct cmdline *cl,
7279 __attribute__((unused)) void *data)
7281 struct cmd_read_reg_bit_field_result *res = parsed_result;
7282 port_reg_bit_field_display(res->port_id, res->reg_off,
7283 res->bit1_pos, res->bit2_pos);
7286 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7287 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7289 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield =
7290 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result,
7291 regfield, "regfield");
7292 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id =
7293 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id,
7295 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off =
7296 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off,
7298 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos =
7299 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos,
7301 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos =
7302 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos,
7305 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7306 .f = cmd_read_reg_bit_field_parsed,
7308 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: "
7309 "Read register bit field between bit_x and bit_y included",
7311 (void *)&cmd_read_reg_bit_field_read,
7312 (void *)&cmd_read_reg_bit_field_regfield,
7313 (void *)&cmd_read_reg_bit_field_port_id,
7314 (void *)&cmd_read_reg_bit_field_reg_off,
7315 (void *)&cmd_read_reg_bit_field_bit1_pos,
7316 (void *)&cmd_read_reg_bit_field_bit2_pos,
7321 /* *** READ PORT REGISTER BIT *** */
7322 struct cmd_read_reg_bit_result {
7323 cmdline_fixed_string_t read;
7324 cmdline_fixed_string_t regbit;
7331 cmd_read_reg_bit_parsed(void *parsed_result,
7332 __attribute__((unused)) struct cmdline *cl,
7333 __attribute__((unused)) void *data)
7335 struct cmd_read_reg_bit_result *res = parsed_result;
7336 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7339 cmdline_parse_token_string_t cmd_read_reg_bit_read =
7340 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read");
7341 cmdline_parse_token_string_t cmd_read_reg_bit_regbit =
7342 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result,
7344 cmdline_parse_token_num_t cmd_read_reg_bit_port_id =
7345 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16);
7346 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off =
7347 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32);
7348 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos =
7349 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8);
7351 cmdline_parse_inst_t cmd_read_reg_bit = {
7352 .f = cmd_read_reg_bit_parsed,
7354 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7356 (void *)&cmd_read_reg_bit_read,
7357 (void *)&cmd_read_reg_bit_regbit,
7358 (void *)&cmd_read_reg_bit_port_id,
7359 (void *)&cmd_read_reg_bit_reg_off,
7360 (void *)&cmd_read_reg_bit_bit_pos,
7365 /* *** WRITE PORT REGISTER *** */
7366 struct cmd_write_reg_result {
7367 cmdline_fixed_string_t write;
7368 cmdline_fixed_string_t reg;
7375 cmd_write_reg_parsed(void *parsed_result,
7376 __attribute__((unused)) struct cmdline *cl,
7377 __attribute__((unused)) void *data)
7379 struct cmd_write_reg_result *res = parsed_result;
7380 port_reg_set(res->port_id, res->reg_off, res->value);
7383 cmdline_parse_token_string_t cmd_write_reg_write =
7384 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write");
7385 cmdline_parse_token_string_t cmd_write_reg_reg =
7386 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg");
7387 cmdline_parse_token_num_t cmd_write_reg_port_id =
7388 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16);
7389 cmdline_parse_token_num_t cmd_write_reg_reg_off =
7390 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32);
7391 cmdline_parse_token_num_t cmd_write_reg_value =
7392 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32);
7394 cmdline_parse_inst_t cmd_write_reg = {
7395 .f = cmd_write_reg_parsed,
7397 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7399 (void *)&cmd_write_reg_write,
7400 (void *)&cmd_write_reg_reg,
7401 (void *)&cmd_write_reg_port_id,
7402 (void *)&cmd_write_reg_reg_off,
7403 (void *)&cmd_write_reg_value,
7408 /* *** WRITE PORT REGISTER BIT FIELD *** */
7409 struct cmd_write_reg_bit_field_result {
7410 cmdline_fixed_string_t write;
7411 cmdline_fixed_string_t regfield;
7420 cmd_write_reg_bit_field_parsed(void *parsed_result,
7421 __attribute__((unused)) struct cmdline *cl,
7422 __attribute__((unused)) void *data)
7424 struct cmd_write_reg_bit_field_result *res = parsed_result;
7425 port_reg_bit_field_set(res->port_id, res->reg_off,
7426 res->bit1_pos, res->bit2_pos, res->value);
7429 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7430 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7432 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield =
7433 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result,
7434 regfield, "regfield");
7435 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id =
7436 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id,
7438 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off =
7439 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off,
7441 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos =
7442 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos,
7444 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos =
7445 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos,
7447 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7448 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7451 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7452 .f = cmd_write_reg_bit_field_parsed,
7454 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7456 "Set register bit field between bit_x and bit_y included",
7458 (void *)&cmd_write_reg_bit_field_write,
7459 (void *)&cmd_write_reg_bit_field_regfield,
7460 (void *)&cmd_write_reg_bit_field_port_id,
7461 (void *)&cmd_write_reg_bit_field_reg_off,
7462 (void *)&cmd_write_reg_bit_field_bit1_pos,
7463 (void *)&cmd_write_reg_bit_field_bit2_pos,
7464 (void *)&cmd_write_reg_bit_field_value,
7469 /* *** WRITE PORT REGISTER BIT *** */
7470 struct cmd_write_reg_bit_result {
7471 cmdline_fixed_string_t write;
7472 cmdline_fixed_string_t regbit;
7480 cmd_write_reg_bit_parsed(void *parsed_result,
7481 __attribute__((unused)) struct cmdline *cl,
7482 __attribute__((unused)) void *data)
7484 struct cmd_write_reg_bit_result *res = parsed_result;
7485 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value);
7488 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7489 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7491 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7492 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7494 cmdline_parse_token_num_t cmd_write_reg_bit_port_id =
7495 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16);
7496 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off =
7497 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32);
7498 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos =
7499 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8);
7500 cmdline_parse_token_num_t cmd_write_reg_bit_value =
7501 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8);
7503 cmdline_parse_inst_t cmd_write_reg_bit = {
7504 .f = cmd_write_reg_bit_parsed,
7506 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7509 (void *)&cmd_write_reg_bit_write,
7510 (void *)&cmd_write_reg_bit_regbit,
7511 (void *)&cmd_write_reg_bit_port_id,
7512 (void *)&cmd_write_reg_bit_reg_off,
7513 (void *)&cmd_write_reg_bit_bit_pos,
7514 (void *)&cmd_write_reg_bit_value,
7519 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7520 struct cmd_read_rxd_txd_result {
7521 cmdline_fixed_string_t read;
7522 cmdline_fixed_string_t rxd_txd;
7529 cmd_read_rxd_txd_parsed(void *parsed_result,
7530 __attribute__((unused)) struct cmdline *cl,
7531 __attribute__((unused)) void *data)
7533 struct cmd_read_rxd_txd_result *res = parsed_result;
7535 if (!strcmp(res->rxd_txd, "rxd"))
7536 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7537 else if (!strcmp(res->rxd_txd, "txd"))
7538 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7541 cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7542 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7543 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7544 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7546 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7547 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16);
7548 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7549 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16);
7550 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7551 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16);
7553 cmdline_parse_inst_t cmd_read_rxd_txd = {
7554 .f = cmd_read_rxd_txd_parsed,
7556 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7558 (void *)&cmd_read_rxd_txd_read,
7559 (void *)&cmd_read_rxd_txd_rxd_txd,
7560 (void *)&cmd_read_rxd_txd_port_id,
7561 (void *)&cmd_read_rxd_txd_queue_id,
7562 (void *)&cmd_read_rxd_txd_desc_id,
7568 struct cmd_quit_result {
7569 cmdline_fixed_string_t quit;
7572 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7574 __attribute__((unused)) void *data)
7580 cmdline_parse_token_string_t cmd_quit_quit =
7581 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7583 cmdline_parse_inst_t cmd_quit = {
7584 .f = cmd_quit_parsed,
7586 .help_str = "quit: Exit application",
7588 (void *)&cmd_quit_quit,
7593 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7594 struct cmd_mac_addr_result {
7595 cmdline_fixed_string_t mac_addr_cmd;
7596 cmdline_fixed_string_t what;
7598 struct ether_addr address;
7601 static void cmd_mac_addr_parsed(void *parsed_result,
7602 __attribute__((unused)) struct cmdline *cl,
7603 __attribute__((unused)) void *data)
7605 struct cmd_mac_addr_result *res = parsed_result;
7608 if (strcmp(res->what, "add") == 0)
7609 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7610 else if (strcmp(res->what, "set") == 0)
7611 ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7614 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7616 /* check the return value and print it if is < 0 */
7618 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7622 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7623 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7625 cmdline_parse_token_string_t cmd_mac_addr_what =
7626 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7628 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7629 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7631 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7632 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7634 cmdline_parse_inst_t cmd_mac_addr = {
7635 .f = cmd_mac_addr_parsed,
7637 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7638 "Add/Remove/Set MAC address on port_id",
7640 (void *)&cmd_mac_addr_cmd,
7641 (void *)&cmd_mac_addr_what,
7642 (void *)&cmd_mac_addr_portnum,
7643 (void *)&cmd_mac_addr_addr,
7648 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7649 struct cmd_eth_peer_result {
7650 cmdline_fixed_string_t set;
7651 cmdline_fixed_string_t eth_peer;
7653 cmdline_fixed_string_t peer_addr;
7656 static void cmd_set_eth_peer_parsed(void *parsed_result,
7657 __attribute__((unused)) struct cmdline *cl,
7658 __attribute__((unused)) void *data)
7660 struct cmd_eth_peer_result *res = parsed_result;
7662 if (test_done == 0) {
7663 printf("Please stop forwarding first\n");
7666 if (!strcmp(res->eth_peer, "eth-peer")) {
7667 set_fwd_eth_peer(res->port_id, res->peer_addr);
7671 cmdline_parse_token_string_t cmd_eth_peer_set =
7672 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7673 cmdline_parse_token_string_t cmd_eth_peer =
7674 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7675 cmdline_parse_token_num_t cmd_eth_peer_port_id =
7676 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16);
7677 cmdline_parse_token_string_t cmd_eth_peer_addr =
7678 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7680 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7681 .f = cmd_set_eth_peer_parsed,
7683 .help_str = "set eth-peer <port_id> <peer_mac>",
7685 (void *)&cmd_eth_peer_set,
7686 (void *)&cmd_eth_peer,
7687 (void *)&cmd_eth_peer_port_id,
7688 (void *)&cmd_eth_peer_addr,
7693 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7694 struct cmd_set_qmap_result {
7695 cmdline_fixed_string_t set;
7696 cmdline_fixed_string_t qmap;
7697 cmdline_fixed_string_t what;
7704 cmd_set_qmap_parsed(void *parsed_result,
7705 __attribute__((unused)) struct cmdline *cl,
7706 __attribute__((unused)) void *data)
7708 struct cmd_set_qmap_result *res = parsed_result;
7709 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7711 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7714 cmdline_parse_token_string_t cmd_setqmap_set =
7715 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7717 cmdline_parse_token_string_t cmd_setqmap_qmap =
7718 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7720 cmdline_parse_token_string_t cmd_setqmap_what =
7721 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7723 cmdline_parse_token_num_t cmd_setqmap_portid =
7724 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7726 cmdline_parse_token_num_t cmd_setqmap_queueid =
7727 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7729 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7730 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7733 cmdline_parse_inst_t cmd_set_qmap = {
7734 .f = cmd_set_qmap_parsed,
7736 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7737 "Set statistics mapping value on tx|rx queue_id of port_id",
7739 (void *)&cmd_setqmap_set,
7740 (void *)&cmd_setqmap_qmap,
7741 (void *)&cmd_setqmap_what,
7742 (void *)&cmd_setqmap_portid,
7743 (void *)&cmd_setqmap_queueid,
7744 (void *)&cmd_setqmap_mapvalue,
7749 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7750 struct cmd_set_xstats_hide_zero_result {
7751 cmdline_fixed_string_t keyword;
7752 cmdline_fixed_string_t name;
7753 cmdline_fixed_string_t on_off;
7757 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7758 __attribute__((unused)) struct cmdline *cl,
7759 __attribute__((unused)) void *data)
7761 struct cmd_set_xstats_hide_zero_result *res;
7762 uint16_t on_off = 0;
7764 res = parsed_result;
7765 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7766 set_xstats_hide_zero(on_off);
7769 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7770 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7772 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7773 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7774 name, "xstats-hide-zero");
7775 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7776 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7779 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7780 .f = cmd_set_xstats_hide_zero_parsed,
7782 .help_str = "set xstats-hide-zero on|off",
7784 (void *)&cmd_set_xstats_hide_zero_keyword,
7785 (void *)&cmd_set_xstats_hide_zero_name,
7786 (void *)&cmd_set_xstats_hide_zero_on_off,
7791 /* *** CONFIGURE UNICAST HASH TABLE *** */
7792 struct cmd_set_uc_hash_table {
7793 cmdline_fixed_string_t set;
7794 cmdline_fixed_string_t port;
7796 cmdline_fixed_string_t what;
7797 struct ether_addr address;
7798 cmdline_fixed_string_t mode;
7802 cmd_set_uc_hash_parsed(void *parsed_result,
7803 __attribute__((unused)) struct cmdline *cl,
7804 __attribute__((unused)) void *data)
7807 struct cmd_set_uc_hash_table *res = parsed_result;
7809 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7811 if (strcmp(res->what, "uta") == 0)
7812 ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7813 &res->address,(uint8_t)is_on);
7815 printf("bad unicast hash table parameter, return code = %d \n", ret);
7819 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7820 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7822 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7823 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7825 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7826 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7828 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7829 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7831 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7832 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7834 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7835 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7838 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7839 .f = cmd_set_uc_hash_parsed,
7841 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7843 (void *)&cmd_set_uc_hash_set,
7844 (void *)&cmd_set_uc_hash_port,
7845 (void *)&cmd_set_uc_hash_portid,
7846 (void *)&cmd_set_uc_hash_what,
7847 (void *)&cmd_set_uc_hash_mac,
7848 (void *)&cmd_set_uc_hash_mode,
7853 struct cmd_set_uc_all_hash_table {
7854 cmdline_fixed_string_t set;
7855 cmdline_fixed_string_t port;
7857 cmdline_fixed_string_t what;
7858 cmdline_fixed_string_t value;
7859 cmdline_fixed_string_t mode;
7863 cmd_set_uc_all_hash_parsed(void *parsed_result,
7864 __attribute__((unused)) struct cmdline *cl,
7865 __attribute__((unused)) void *data)
7868 struct cmd_set_uc_all_hash_table *res = parsed_result;
7870 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7872 if ((strcmp(res->what, "uta") == 0) &&
7873 (strcmp(res->value, "all") == 0))
7874 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7876 printf("bad unicast hash table parameter,"
7877 "return code = %d \n", ret);
7880 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7881 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7883 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7884 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7886 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7887 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7889 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7890 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7892 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7893 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7895 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7896 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7899 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7900 .f = cmd_set_uc_all_hash_parsed,
7902 .help_str = "set port <port_id> uta all on|off",
7904 (void *)&cmd_set_uc_all_hash_set,
7905 (void *)&cmd_set_uc_all_hash_port,
7906 (void *)&cmd_set_uc_all_hash_portid,
7907 (void *)&cmd_set_uc_all_hash_what,
7908 (void *)&cmd_set_uc_all_hash_value,
7909 (void *)&cmd_set_uc_all_hash_mode,
7914 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */
7915 struct cmd_set_vf_macvlan_filter {
7916 cmdline_fixed_string_t set;
7917 cmdline_fixed_string_t port;
7919 cmdline_fixed_string_t vf;
7921 struct ether_addr address;
7922 cmdline_fixed_string_t filter_type;
7923 cmdline_fixed_string_t mode;
7927 cmd_set_vf_macvlan_parsed(void *parsed_result,
7928 __attribute__((unused)) struct cmdline *cl,
7929 __attribute__((unused)) void *data)
7932 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7933 struct rte_eth_mac_filter filter;
7935 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7937 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7939 /* set VF MAC filter */
7943 filter.dst_id = res->vf_id;
7945 if (!strcmp(res->filter_type, "exact-mac"))
7946 filter.filter_type = RTE_MAC_PERFECT_MATCH;
7947 else if (!strcmp(res->filter_type, "exact-mac-vlan"))
7948 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH;
7949 else if (!strcmp(res->filter_type, "hashmac"))
7950 filter.filter_type = RTE_MAC_HASH_MATCH;
7951 else if (!strcmp(res->filter_type, "hashmac-vlan"))
7952 filter.filter_type = RTE_MACVLAN_HASH_MATCH;
7954 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7957 ret = rte_eth_dev_filter_ctrl(res->port_id,
7958 RTE_ETH_FILTER_MACVLAN,
7962 ret = rte_eth_dev_filter_ctrl(res->port_id,
7963 RTE_ETH_FILTER_MACVLAN,
7964 RTE_ETH_FILTER_DELETE,
7968 printf("bad set MAC hash parameter, return code = %d\n", ret);
7972 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7973 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7975 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7976 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7978 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7979 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7981 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7982 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7984 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7985 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7987 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7988 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7990 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type =
7991 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7992 filter_type, "exact-mac#exact-mac-vlan"
7993 "#hashmac#hashmac-vlan");
7994 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode =
7995 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7998 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7999 .f = cmd_set_vf_macvlan_parsed,
8001 .help_str = "set port <port_id> vf <vf_id> <mac_addr> "
8002 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: "
8003 "Exact match rule: exact match of MAC or MAC and VLAN; "
8004 "hash match rule: hash match of MAC and exact match of VLAN",
8006 (void *)&cmd_set_vf_macvlan_set,
8007 (void *)&cmd_set_vf_macvlan_port,
8008 (void *)&cmd_set_vf_macvlan_portid,
8009 (void *)&cmd_set_vf_macvlan_vf,
8010 (void *)&cmd_set_vf_macvlan_vf_id,
8011 (void *)&cmd_set_vf_macvlan_mac,
8012 (void *)&cmd_set_vf_macvlan_filter_type,
8013 (void *)&cmd_set_vf_macvlan_mode,
8018 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8019 struct cmd_set_vf_traffic {
8020 cmdline_fixed_string_t set;
8021 cmdline_fixed_string_t port;
8023 cmdline_fixed_string_t vf;
8025 cmdline_fixed_string_t what;
8026 cmdline_fixed_string_t mode;
8030 cmd_set_vf_traffic_parsed(void *parsed_result,
8031 __attribute__((unused)) struct cmdline *cl,
8032 __attribute__((unused)) void *data)
8034 struct cmd_set_vf_traffic *res = parsed_result;
8035 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8036 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8038 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8041 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8042 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8044 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8045 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8047 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8048 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8050 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8051 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8053 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8054 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8056 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8057 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8059 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8060 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8063 cmdline_parse_inst_t cmd_set_vf_traffic = {
8064 .f = cmd_set_vf_traffic_parsed,
8066 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8068 (void *)&cmd_setvf_traffic_set,
8069 (void *)&cmd_setvf_traffic_port,
8070 (void *)&cmd_setvf_traffic_portid,
8071 (void *)&cmd_setvf_traffic_vf,
8072 (void *)&cmd_setvf_traffic_vfid,
8073 (void *)&cmd_setvf_traffic_what,
8074 (void *)&cmd_setvf_traffic_mode,
8079 /* *** CONFIGURE VF RECEIVE MODE *** */
8080 struct cmd_set_vf_rxmode {
8081 cmdline_fixed_string_t set;
8082 cmdline_fixed_string_t port;
8084 cmdline_fixed_string_t vf;
8086 cmdline_fixed_string_t what;
8087 cmdline_fixed_string_t mode;
8088 cmdline_fixed_string_t on;
8092 cmd_set_vf_rxmode_parsed(void *parsed_result,
8093 __attribute__((unused)) struct cmdline *cl,
8094 __attribute__((unused)) void *data)
8097 uint16_t rx_mode = 0;
8098 struct cmd_set_vf_rxmode *res = parsed_result;
8100 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8101 if (!strcmp(res->what,"rxmode")) {
8102 if (!strcmp(res->mode, "AUPE"))
8103 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG;
8104 else if (!strcmp(res->mode, "ROPE"))
8105 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC;
8106 else if (!strcmp(res->mode, "BAM"))
8107 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST;
8108 else if (!strncmp(res->mode, "MPE",3))
8109 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST;
8112 RTE_SET_USED(is_on);
8114 #ifdef RTE_LIBRTE_IXGBE_PMD
8115 if (ret == -ENOTSUP)
8116 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8117 rx_mode, (uint8_t)is_on);
8119 #ifdef RTE_LIBRTE_BNXT_PMD
8120 if (ret == -ENOTSUP)
8121 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8122 rx_mode, (uint8_t)is_on);
8125 printf("bad VF receive mode parameter, return code = %d \n",
8129 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8130 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8132 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8133 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8135 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8136 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8138 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8139 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8141 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8142 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8144 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8145 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8147 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8148 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8149 mode, "AUPE#ROPE#BAM#MPE");
8150 cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8151 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8154 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8155 .f = cmd_set_vf_rxmode_parsed,
8157 .help_str = "set port <port_id> vf <vf_id> rxmode "
8158 "AUPE|ROPE|BAM|MPE on|off",
8160 (void *)&cmd_set_vf_rxmode_set,
8161 (void *)&cmd_set_vf_rxmode_port,
8162 (void *)&cmd_set_vf_rxmode_portid,
8163 (void *)&cmd_set_vf_rxmode_vf,
8164 (void *)&cmd_set_vf_rxmode_vfid,
8165 (void *)&cmd_set_vf_rxmode_what,
8166 (void *)&cmd_set_vf_rxmode_mode,
8167 (void *)&cmd_set_vf_rxmode_on,
8172 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8173 struct cmd_vf_mac_addr_result {
8174 cmdline_fixed_string_t mac_addr_cmd;
8175 cmdline_fixed_string_t what;
8176 cmdline_fixed_string_t port;
8178 cmdline_fixed_string_t vf;
8180 struct ether_addr address;
8183 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8184 __attribute__((unused)) struct cmdline *cl,
8185 __attribute__((unused)) void *data)
8187 struct cmd_vf_mac_addr_result *res = parsed_result;
8190 if (strcmp(res->what, "add") != 0)
8193 #ifdef RTE_LIBRTE_I40E_PMD
8194 if (ret == -ENOTSUP)
8195 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8198 #ifdef RTE_LIBRTE_BNXT_PMD
8199 if (ret == -ENOTSUP)
8200 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8205 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8209 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8210 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8211 mac_addr_cmd,"mac_addr");
8212 cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8213 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8215 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8216 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8218 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8219 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8221 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8222 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8224 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8225 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8227 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8228 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8231 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8232 .f = cmd_vf_mac_addr_parsed,
8234 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8235 "Add MAC address filtering for a VF on port_id",
8237 (void *)&cmd_vf_mac_addr_cmd,
8238 (void *)&cmd_vf_mac_addr_what,
8239 (void *)&cmd_vf_mac_addr_port,
8240 (void *)&cmd_vf_mac_addr_portnum,
8241 (void *)&cmd_vf_mac_addr_vf,
8242 (void *)&cmd_vf_mac_addr_vfnum,
8243 (void *)&cmd_vf_mac_addr_addr,
8248 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8249 struct cmd_vf_rx_vlan_filter {
8250 cmdline_fixed_string_t rx_vlan;
8251 cmdline_fixed_string_t what;
8253 cmdline_fixed_string_t port;
8255 cmdline_fixed_string_t vf;
8260 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8261 __attribute__((unused)) struct cmdline *cl,
8262 __attribute__((unused)) void *data)
8264 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8267 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8269 #ifdef RTE_LIBRTE_IXGBE_PMD
8270 if (ret == -ENOTSUP)
8271 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8272 res->vlan_id, res->vf_mask, is_add);
8274 #ifdef RTE_LIBRTE_I40E_PMD
8275 if (ret == -ENOTSUP)
8276 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8277 res->vlan_id, res->vf_mask, is_add);
8279 #ifdef RTE_LIBRTE_BNXT_PMD
8280 if (ret == -ENOTSUP)
8281 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8282 res->vlan_id, res->vf_mask, is_add);
8289 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8290 res->vlan_id, res->vf_mask);
8293 printf("invalid port_id %d\n", res->port_id);
8296 printf("function not implemented or supported\n");
8299 printf("programming error: (%s)\n", strerror(-ret));
8303 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8304 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8305 rx_vlan, "rx_vlan");
8306 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8307 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8309 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8310 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8312 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8313 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8315 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8316 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8318 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8319 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8321 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8322 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8325 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8326 .f = cmd_vf_rx_vlan_filter_parsed,
8328 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8329 "(vf_mask = hexadecimal VF mask)",
8331 (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8332 (void *)&cmd_vf_rx_vlan_filter_what,
8333 (void *)&cmd_vf_rx_vlan_filter_vlanid,
8334 (void *)&cmd_vf_rx_vlan_filter_port,
8335 (void *)&cmd_vf_rx_vlan_filter_portid,
8336 (void *)&cmd_vf_rx_vlan_filter_vf,
8337 (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8342 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8343 struct cmd_queue_rate_limit_result {
8344 cmdline_fixed_string_t set;
8345 cmdline_fixed_string_t port;
8347 cmdline_fixed_string_t queue;
8349 cmdline_fixed_string_t rate;
8353 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8354 __attribute__((unused)) struct cmdline *cl,
8355 __attribute__((unused)) void *data)
8357 struct cmd_queue_rate_limit_result *res = parsed_result;
8360 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8361 && (strcmp(res->queue, "queue") == 0)
8362 && (strcmp(res->rate, "rate") == 0))
8363 ret = set_queue_rate_limit(res->port_num, res->queue_num,
8366 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8370 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8371 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8373 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8374 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8376 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8377 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8379 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8380 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8382 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8383 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8385 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8386 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8388 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8389 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8392 cmdline_parse_inst_t cmd_queue_rate_limit = {
8393 .f = cmd_queue_rate_limit_parsed,
8395 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8396 "Set rate limit for a queue on port_id",
8398 (void *)&cmd_queue_rate_limit_set,
8399 (void *)&cmd_queue_rate_limit_port,
8400 (void *)&cmd_queue_rate_limit_portnum,
8401 (void *)&cmd_queue_rate_limit_queue,
8402 (void *)&cmd_queue_rate_limit_queuenum,
8403 (void *)&cmd_queue_rate_limit_rate,
8404 (void *)&cmd_queue_rate_limit_ratenum,
8409 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8410 struct cmd_vf_rate_limit_result {
8411 cmdline_fixed_string_t set;
8412 cmdline_fixed_string_t port;
8414 cmdline_fixed_string_t vf;
8416 cmdline_fixed_string_t rate;
8418 cmdline_fixed_string_t q_msk;
8422 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8423 __attribute__((unused)) struct cmdline *cl,
8424 __attribute__((unused)) void *data)
8426 struct cmd_vf_rate_limit_result *res = parsed_result;
8429 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8430 && (strcmp(res->vf, "vf") == 0)
8431 && (strcmp(res->rate, "rate") == 0)
8432 && (strcmp(res->q_msk, "queue_mask") == 0))
8433 ret = set_vf_rate_limit(res->port_num, res->vf_num,
8434 res->rate_num, res->q_msk_val);
8436 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8440 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8441 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8443 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8444 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8446 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8447 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8449 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8450 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8452 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8453 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8455 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8456 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8458 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8459 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8461 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8462 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8463 q_msk, "queue_mask");
8464 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8465 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8468 cmdline_parse_inst_t cmd_vf_rate_limit = {
8469 .f = cmd_vf_rate_limit_parsed,
8471 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8472 "queue_mask <queue_mask_value>: "
8473 "Set rate limit for queues of VF on port_id",
8475 (void *)&cmd_vf_rate_limit_set,
8476 (void *)&cmd_vf_rate_limit_port,
8477 (void *)&cmd_vf_rate_limit_portnum,
8478 (void *)&cmd_vf_rate_limit_vf,
8479 (void *)&cmd_vf_rate_limit_vfnum,
8480 (void *)&cmd_vf_rate_limit_rate,
8481 (void *)&cmd_vf_rate_limit_ratenum,
8482 (void *)&cmd_vf_rate_limit_q_msk,
8483 (void *)&cmd_vf_rate_limit_q_msk_val,
8488 /* *** ADD TUNNEL FILTER OF A PORT *** */
8489 struct cmd_tunnel_filter_result {
8490 cmdline_fixed_string_t cmd;
8491 cmdline_fixed_string_t what;
8493 struct ether_addr outer_mac;
8494 struct ether_addr inner_mac;
8495 cmdline_ipaddr_t ip_value;
8496 uint16_t inner_vlan;
8497 cmdline_fixed_string_t tunnel_type;
8498 cmdline_fixed_string_t filter_type;
8504 cmd_tunnel_filter_parsed(void *parsed_result,
8505 __attribute__((unused)) struct cmdline *cl,
8506 __attribute__((unused)) void *data)
8508 struct cmd_tunnel_filter_result *res = parsed_result;
8509 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8512 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8514 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac);
8515 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac);
8516 tunnel_filter_conf.inner_vlan = res->inner_vlan;
8518 if (res->ip_value.family == AF_INET) {
8519 tunnel_filter_conf.ip_addr.ipv4_addr =
8520 res->ip_value.addr.ipv4.s_addr;
8521 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4;
8523 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr),
8524 &(res->ip_value.addr.ipv6),
8525 sizeof(struct in6_addr));
8526 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6;
8529 if (!strcmp(res->filter_type, "imac-ivlan"))
8530 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN;
8531 else if (!strcmp(res->filter_type, "imac-ivlan-tenid"))
8532 tunnel_filter_conf.filter_type =
8533 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID;
8534 else if (!strcmp(res->filter_type, "imac-tenid"))
8535 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID;
8536 else if (!strcmp(res->filter_type, "imac"))
8537 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC;
8538 else if (!strcmp(res->filter_type, "omac-imac-tenid"))
8539 tunnel_filter_conf.filter_type =
8540 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC;
8541 else if (!strcmp(res->filter_type, "oip"))
8542 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP;
8543 else if (!strcmp(res->filter_type, "iip"))
8544 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP;
8546 printf("The filter type is not supported");
8550 if (!strcmp(res->tunnel_type, "vxlan"))
8551 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN;
8552 else if (!strcmp(res->tunnel_type, "nvgre"))
8553 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE;
8554 else if (!strcmp(res->tunnel_type, "ipingre"))
8555 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE;
8557 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8561 tunnel_filter_conf.tenant_id = res->tenant_id;
8562 tunnel_filter_conf.queue_id = res->queue_num;
8563 if (!strcmp(res->what, "add"))
8564 ret = rte_eth_dev_filter_ctrl(res->port_id,
8565 RTE_ETH_FILTER_TUNNEL,
8567 &tunnel_filter_conf);
8569 ret = rte_eth_dev_filter_ctrl(res->port_id,
8570 RTE_ETH_FILTER_TUNNEL,
8571 RTE_ETH_FILTER_DELETE,
8572 &tunnel_filter_conf);
8574 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8578 cmdline_parse_token_string_t cmd_tunnel_filter_cmd =
8579 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8580 cmd, "tunnel_filter");
8581 cmdline_parse_token_string_t cmd_tunnel_filter_what =
8582 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8584 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8585 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8587 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8588 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8590 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8591 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8593 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan =
8594 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8595 inner_vlan, UINT16);
8596 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value =
8597 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8599 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type =
8600 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8601 tunnel_type, "vxlan#nvgre#ipingre");
8603 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type =
8604 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result,
8605 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#"
8606 "imac#omac-imac-tenid");
8607 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id =
8608 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8610 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8611 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8614 cmdline_parse_inst_t cmd_tunnel_filter = {
8615 .f = cmd_tunnel_filter_parsed,
8617 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> "
8618 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|"
8619 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> "
8620 "<queue_id>: Add/Rm tunnel filter of a port",
8622 (void *)&cmd_tunnel_filter_cmd,
8623 (void *)&cmd_tunnel_filter_what,
8624 (void *)&cmd_tunnel_filter_port_id,
8625 (void *)&cmd_tunnel_filter_outer_mac,
8626 (void *)&cmd_tunnel_filter_inner_mac,
8627 (void *)&cmd_tunnel_filter_ip_value,
8628 (void *)&cmd_tunnel_filter_innner_vlan,
8629 (void *)&cmd_tunnel_filter_tunnel_type,
8630 (void *)&cmd_tunnel_filter_filter_type,
8631 (void *)&cmd_tunnel_filter_tenant_id,
8632 (void *)&cmd_tunnel_filter_queue_num,
8637 /* *** CONFIGURE TUNNEL UDP PORT *** */
8638 struct cmd_tunnel_udp_config {
8639 cmdline_fixed_string_t cmd;
8640 cmdline_fixed_string_t what;
8646 cmd_tunnel_udp_config_parsed(void *parsed_result,
8647 __attribute__((unused)) struct cmdline *cl,
8648 __attribute__((unused)) void *data)
8650 struct cmd_tunnel_udp_config *res = parsed_result;
8651 struct rte_eth_udp_tunnel tunnel_udp;
8654 tunnel_udp.udp_port = res->udp_port;
8656 if (!strcmp(res->cmd, "rx_vxlan_port"))
8657 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8659 if (!strcmp(res->what, "add"))
8660 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8663 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8667 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8670 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd =
8671 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8672 cmd, "rx_vxlan_port");
8673 cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8674 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8676 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8677 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8679 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8680 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8683 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8684 .f = cmd_tunnel_udp_config_parsed,
8686 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8687 "Add/Remove a tunneling UDP port filter",
8689 (void *)&cmd_tunnel_udp_config_cmd,
8690 (void *)&cmd_tunnel_udp_config_what,
8691 (void *)&cmd_tunnel_udp_config_udp_port,
8692 (void *)&cmd_tunnel_udp_config_port_id,
8697 struct cmd_config_tunnel_udp_port {
8698 cmdline_fixed_string_t port;
8699 cmdline_fixed_string_t config;
8701 cmdline_fixed_string_t udp_tunnel_port;
8702 cmdline_fixed_string_t action;
8703 cmdline_fixed_string_t tunnel_type;
8708 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8709 __attribute__((unused)) struct cmdline *cl,
8710 __attribute__((unused)) void *data)
8712 struct cmd_config_tunnel_udp_port *res = parsed_result;
8713 struct rte_eth_udp_tunnel tunnel_udp;
8716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8719 tunnel_udp.udp_port = res->udp_port;
8721 if (!strcmp(res->tunnel_type, "vxlan")) {
8722 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8723 } else if (!strcmp(res->tunnel_type, "geneve")) {
8724 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE;
8726 printf("Invalid tunnel type\n");
8730 if (!strcmp(res->action, "add"))
8731 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8734 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8738 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8741 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8742 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8744 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8745 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8747 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8748 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8750 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8751 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8754 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8755 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8757 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8758 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8760 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8761 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8764 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8765 .f = cmd_cfg_tunnel_udp_port_parsed,
8767 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8769 (void *)&cmd_config_tunnel_udp_port_port,
8770 (void *)&cmd_config_tunnel_udp_port_config,
8771 (void *)&cmd_config_tunnel_udp_port_port_id,
8772 (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8773 (void *)&cmd_config_tunnel_udp_port_action,
8774 (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8775 (void *)&cmd_config_tunnel_udp_port_value,
8780 /* *** GLOBAL CONFIG *** */
8781 struct cmd_global_config_result {
8782 cmdline_fixed_string_t cmd;
8784 cmdline_fixed_string_t cfg_type;
8789 cmd_global_config_parsed(void *parsed_result,
8790 __attribute__((unused)) struct cmdline *cl,
8791 __attribute__((unused)) void *data)
8793 struct cmd_global_config_result *res = parsed_result;
8794 struct rte_eth_global_cfg conf;
8797 memset(&conf, 0, sizeof(conf));
8798 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
8799 conf.cfg.gre_key_len = res->len;
8800 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
8801 RTE_ETH_FILTER_SET, &conf);
8803 printf("Global config error\n");
8806 cmdline_parse_token_string_t cmd_global_config_cmd =
8807 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8809 cmdline_parse_token_num_t cmd_global_config_port_id =
8810 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8812 cmdline_parse_token_string_t cmd_global_config_type =
8813 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
8814 cfg_type, "gre-key-len");
8815 cmdline_parse_token_num_t cmd_global_config_gre_key_len =
8816 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
8819 cmdline_parse_inst_t cmd_global_config = {
8820 .f = cmd_global_config_parsed,
8821 .data = (void *)NULL,
8822 .help_str = "global_config <port_id> gre-key-len <key_len>",
8824 (void *)&cmd_global_config_cmd,
8825 (void *)&cmd_global_config_port_id,
8826 (void *)&cmd_global_config_type,
8827 (void *)&cmd_global_config_gre_key_len,
8832 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
8833 struct cmd_set_mirror_mask_result {
8834 cmdline_fixed_string_t set;
8835 cmdline_fixed_string_t port;
8837 cmdline_fixed_string_t mirror;
8839 cmdline_fixed_string_t what;
8840 cmdline_fixed_string_t value;
8841 cmdline_fixed_string_t dstpool;
8843 cmdline_fixed_string_t on;
8846 cmdline_parse_token_string_t cmd_mirror_mask_set =
8847 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8849 cmdline_parse_token_string_t cmd_mirror_mask_port =
8850 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8852 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8853 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8855 cmdline_parse_token_string_t cmd_mirror_mask_mirror =
8856 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8857 mirror, "mirror-rule");
8858 cmdline_parse_token_num_t cmd_mirror_mask_ruleid =
8859 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8861 cmdline_parse_token_string_t cmd_mirror_mask_what =
8862 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8863 what, "pool-mirror-up#pool-mirror-down"
8865 cmdline_parse_token_string_t cmd_mirror_mask_value =
8866 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8868 cmdline_parse_token_string_t cmd_mirror_mask_dstpool =
8869 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8870 dstpool, "dst-pool");
8871 cmdline_parse_token_num_t cmd_mirror_mask_poolid =
8872 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8874 cmdline_parse_token_string_t cmd_mirror_mask_on =
8875 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8879 cmd_set_mirror_mask_parsed(void *parsed_result,
8880 __attribute__((unused)) struct cmdline *cl,
8881 __attribute__((unused)) void *data)
8884 struct cmd_set_mirror_mask_result *res = parsed_result;
8885 struct rte_eth_mirror_conf mr_conf;
8887 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8889 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8891 mr_conf.dst_pool = res->dstpool_id;
8893 if (!strcmp(res->what, "pool-mirror-up")) {
8894 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8895 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP;
8896 } else if (!strcmp(res->what, "pool-mirror-down")) {
8897 mr_conf.pool_mask = strtoull(res->value, NULL, 16);
8898 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN;
8899 } else if (!strcmp(res->what, "vlan-mirror")) {
8900 mr_conf.rule_type = ETH_MIRROR_VLAN;
8901 nb_item = parse_item_list(res->value, "vlan",
8902 ETH_MIRROR_MAX_VLANS, vlan_list, 1);
8906 for (i = 0; i < nb_item; i++) {
8907 if (vlan_list[i] > ETHER_MAX_VLAN_ID) {
8908 printf("Invalid vlan_id: must be < 4096\n");
8912 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8913 mr_conf.vlan.vlan_mask |= 1ULL << i;
8917 if (!strcmp(res->on, "on"))
8918 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8921 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8924 printf("mirror rule add error: (%s)\n", strerror(-ret));
8927 cmdline_parse_inst_t cmd_set_mirror_mask = {
8928 .f = cmd_set_mirror_mask_parsed,
8930 .help_str = "set port <port_id> mirror-rule <rule_id> "
8931 "pool-mirror-up|pool-mirror-down|vlan-mirror "
8932 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off",
8934 (void *)&cmd_mirror_mask_set,
8935 (void *)&cmd_mirror_mask_port,
8936 (void *)&cmd_mirror_mask_portid,
8937 (void *)&cmd_mirror_mask_mirror,
8938 (void *)&cmd_mirror_mask_ruleid,
8939 (void *)&cmd_mirror_mask_what,
8940 (void *)&cmd_mirror_mask_value,
8941 (void *)&cmd_mirror_mask_dstpool,
8942 (void *)&cmd_mirror_mask_poolid,
8943 (void *)&cmd_mirror_mask_on,
8948 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */
8949 struct cmd_set_mirror_link_result {
8950 cmdline_fixed_string_t set;
8951 cmdline_fixed_string_t port;
8953 cmdline_fixed_string_t mirror;
8955 cmdline_fixed_string_t what;
8956 cmdline_fixed_string_t dstpool;
8958 cmdline_fixed_string_t on;
8961 cmdline_parse_token_string_t cmd_mirror_link_set =
8962 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8964 cmdline_parse_token_string_t cmd_mirror_link_port =
8965 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8967 cmdline_parse_token_num_t cmd_mirror_link_portid =
8968 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8970 cmdline_parse_token_string_t cmd_mirror_link_mirror =
8971 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8972 mirror, "mirror-rule");
8973 cmdline_parse_token_num_t cmd_mirror_link_ruleid =
8974 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8976 cmdline_parse_token_string_t cmd_mirror_link_what =
8977 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8978 what, "uplink-mirror#downlink-mirror");
8979 cmdline_parse_token_string_t cmd_mirror_link_dstpool =
8980 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8981 dstpool, "dst-pool");
8982 cmdline_parse_token_num_t cmd_mirror_link_poolid =
8983 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8985 cmdline_parse_token_string_t cmd_mirror_link_on =
8986 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8990 cmd_set_mirror_link_parsed(void *parsed_result,
8991 __attribute__((unused)) struct cmdline *cl,
8992 __attribute__((unused)) void *data)
8995 struct cmd_set_mirror_link_result *res = parsed_result;
8996 struct rte_eth_mirror_conf mr_conf;
8998 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8999 if (!strcmp(res->what, "uplink-mirror"))
9000 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT;
9002 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9004 mr_conf.dst_pool = res->dstpool_id;
9006 if (!strcmp(res->on, "on"))
9007 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9010 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9013 /* check the return value and print it if is < 0 */
9015 printf("mirror rule add error: (%s)\n", strerror(-ret));
9019 cmdline_parse_inst_t cmd_set_mirror_link = {
9020 .f = cmd_set_mirror_link_parsed,
9022 .help_str = "set port <port_id> mirror-rule <rule_id> "
9023 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9025 (void *)&cmd_mirror_link_set,
9026 (void *)&cmd_mirror_link_port,
9027 (void *)&cmd_mirror_link_portid,
9028 (void *)&cmd_mirror_link_mirror,
9029 (void *)&cmd_mirror_link_ruleid,
9030 (void *)&cmd_mirror_link_what,
9031 (void *)&cmd_mirror_link_dstpool,
9032 (void *)&cmd_mirror_link_poolid,
9033 (void *)&cmd_mirror_link_on,
9038 /* *** RESET VM MIRROR RULE *** */
9039 struct cmd_rm_mirror_rule_result {
9040 cmdline_fixed_string_t reset;
9041 cmdline_fixed_string_t port;
9043 cmdline_fixed_string_t mirror;
9047 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9048 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9050 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9051 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9053 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9054 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9056 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror =
9057 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9058 mirror, "mirror-rule");
9059 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid =
9060 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9064 cmd_reset_mirror_rule_parsed(void *parsed_result,
9065 __attribute__((unused)) struct cmdline *cl,
9066 __attribute__((unused)) void *data)
9069 struct cmd_set_mirror_link_result *res = parsed_result;
9071 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9073 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9076 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9077 .f = cmd_reset_mirror_rule_parsed,
9079 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9081 (void *)&cmd_rm_mirror_rule_reset,
9082 (void *)&cmd_rm_mirror_rule_port,
9083 (void *)&cmd_rm_mirror_rule_portid,
9084 (void *)&cmd_rm_mirror_rule_mirror,
9085 (void *)&cmd_rm_mirror_rule_ruleid,
9090 /* ******************************************************************************** */
9092 struct cmd_dump_result {
9093 cmdline_fixed_string_t dump;
9097 dump_struct_sizes(void)
9099 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9100 DUMP_SIZE(struct rte_mbuf);
9101 DUMP_SIZE(struct rte_mempool);
9102 DUMP_SIZE(struct rte_ring);
9106 static void cmd_dump_parsed(void *parsed_result,
9107 __attribute__((unused)) struct cmdline *cl,
9108 __attribute__((unused)) void *data)
9110 struct cmd_dump_result *res = parsed_result;
9112 if (!strcmp(res->dump, "dump_physmem"))
9113 rte_dump_physmem_layout(stdout);
9114 else if (!strcmp(res->dump, "dump_memzone"))
9115 rte_memzone_dump(stdout);
9116 else if (!strcmp(res->dump, "dump_struct_sizes"))
9117 dump_struct_sizes();
9118 else if (!strcmp(res->dump, "dump_ring"))
9119 rte_ring_list_dump(stdout);
9120 else if (!strcmp(res->dump, "dump_mempool"))
9121 rte_mempool_list_dump(stdout);
9122 else if (!strcmp(res->dump, "dump_devargs"))
9123 rte_devargs_dump(stdout);
9124 else if (!strcmp(res->dump, "dump_log_types"))
9125 rte_log_dump(stdout);
9128 cmdline_parse_token_string_t cmd_dump_dump =
9129 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9132 "dump_struct_sizes#"
9138 cmdline_parse_inst_t cmd_dump = {
9139 .f = cmd_dump_parsed, /* function to call */
9140 .data = NULL, /* 2nd arg of func */
9141 .help_str = "Dump status",
9142 .tokens = { /* token list, NULL terminated */
9143 (void *)&cmd_dump_dump,
9148 /* ******************************************************************************** */
9150 struct cmd_dump_one_result {
9151 cmdline_fixed_string_t dump;
9152 cmdline_fixed_string_t name;
9155 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9156 __attribute__((unused)) void *data)
9158 struct cmd_dump_one_result *res = parsed_result;
9160 if (!strcmp(res->dump, "dump_ring")) {
9162 r = rte_ring_lookup(res->name);
9164 cmdline_printf(cl, "Cannot find ring\n");
9167 rte_ring_dump(stdout, r);
9168 } else if (!strcmp(res->dump, "dump_mempool")) {
9169 struct rte_mempool *mp;
9170 mp = rte_mempool_lookup(res->name);
9172 cmdline_printf(cl, "Cannot find mempool\n");
9175 rte_mempool_dump(stdout, mp);
9179 cmdline_parse_token_string_t cmd_dump_one_dump =
9180 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9181 "dump_ring#dump_mempool");
9183 cmdline_parse_token_string_t cmd_dump_one_name =
9184 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9186 cmdline_parse_inst_t cmd_dump_one = {
9187 .f = cmd_dump_one_parsed, /* function to call */
9188 .data = NULL, /* 2nd arg of func */
9189 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9190 .tokens = { /* token list, NULL terminated */
9191 (void *)&cmd_dump_one_dump,
9192 (void *)&cmd_dump_one_name,
9197 /* *** Add/Del syn filter *** */
9198 struct cmd_syn_filter_result {
9199 cmdline_fixed_string_t filter;
9201 cmdline_fixed_string_t ops;
9202 cmdline_fixed_string_t priority;
9203 cmdline_fixed_string_t high;
9204 cmdline_fixed_string_t queue;
9209 cmd_syn_filter_parsed(void *parsed_result,
9210 __attribute__((unused)) struct cmdline *cl,
9211 __attribute__((unused)) void *data)
9213 struct cmd_syn_filter_result *res = parsed_result;
9214 struct rte_eth_syn_filter syn_filter;
9217 ret = rte_eth_dev_filter_supported(res->port_id,
9218 RTE_ETH_FILTER_SYN);
9220 printf("syn filter is not supported on port %u.\n",
9225 memset(&syn_filter, 0, sizeof(syn_filter));
9227 if (!strcmp(res->ops, "add")) {
9228 if (!strcmp(res->high, "high"))
9229 syn_filter.hig_pri = 1;
9231 syn_filter.hig_pri = 0;
9233 syn_filter.queue = res->queue_id;
9234 ret = rte_eth_dev_filter_ctrl(res->port_id,
9239 ret = rte_eth_dev_filter_ctrl(res->port_id,
9241 RTE_ETH_FILTER_DELETE,
9245 printf("syn filter programming error: (%s)\n",
9249 cmdline_parse_token_string_t cmd_syn_filter_filter =
9250 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9251 filter, "syn_filter");
9252 cmdline_parse_token_num_t cmd_syn_filter_port_id =
9253 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9255 cmdline_parse_token_string_t cmd_syn_filter_ops =
9256 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9258 cmdline_parse_token_string_t cmd_syn_filter_priority =
9259 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9260 priority, "priority");
9261 cmdline_parse_token_string_t cmd_syn_filter_high =
9262 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9264 cmdline_parse_token_string_t cmd_syn_filter_queue =
9265 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9267 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9268 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9271 cmdline_parse_inst_t cmd_syn_filter = {
9272 .f = cmd_syn_filter_parsed,
9274 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9275 "<queue_id>: Add/Delete syn filter",
9277 (void *)&cmd_syn_filter_filter,
9278 (void *)&cmd_syn_filter_port_id,
9279 (void *)&cmd_syn_filter_ops,
9280 (void *)&cmd_syn_filter_priority,
9281 (void *)&cmd_syn_filter_high,
9282 (void *)&cmd_syn_filter_queue,
9283 (void *)&cmd_syn_filter_queue_id,
9288 /* *** queue region set *** */
9289 struct cmd_queue_region_result {
9290 cmdline_fixed_string_t set;
9291 cmdline_fixed_string_t port;
9293 cmdline_fixed_string_t cmd;
9294 cmdline_fixed_string_t region;
9296 cmdline_fixed_string_t queue_start_index;
9298 cmdline_fixed_string_t queue_num;
9299 uint8_t queue_num_value;
9303 cmd_queue_region_parsed(void *parsed_result,
9304 __attribute__((unused)) struct cmdline *cl,
9305 __attribute__((unused)) void *data)
9307 struct cmd_queue_region_result *res = parsed_result;
9309 #ifdef RTE_LIBRTE_I40E_PMD
9310 struct rte_pmd_i40e_queue_region_conf region_conf;
9311 enum rte_pmd_i40e_queue_region_op op_type;
9314 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9317 #ifdef RTE_LIBRTE_I40E_PMD
9318 memset(®ion_conf, 0, sizeof(region_conf));
9319 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET;
9320 region_conf.region_id = res->region_id;
9321 region_conf.queue_num = res->queue_num_value;
9322 region_conf.queue_start_index = res->queue_id;
9324 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9325 op_type, ®ion_conf);
9332 printf("function not implemented or supported\n");
9335 printf("queue region config error: (%s)\n", strerror(-ret));
9339 cmdline_parse_token_string_t cmd_queue_region_set =
9340 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9342 cmdline_parse_token_string_t cmd_queue_region_port =
9343 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port");
9344 cmdline_parse_token_num_t cmd_queue_region_port_id =
9345 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9347 cmdline_parse_token_string_t cmd_queue_region_cmd =
9348 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9349 cmd, "queue-region");
9350 cmdline_parse_token_string_t cmd_queue_region_id =
9351 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9352 region, "region_id");
9353 cmdline_parse_token_num_t cmd_queue_region_index =
9354 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9356 cmdline_parse_token_string_t cmd_queue_region_queue_start_index =
9357 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9358 queue_start_index, "queue_start_index");
9359 cmdline_parse_token_num_t cmd_queue_region_queue_id =
9360 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9362 cmdline_parse_token_string_t cmd_queue_region_queue_num =
9363 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9364 queue_num, "queue_num");
9365 cmdline_parse_token_num_t cmd_queue_region_queue_num_value =
9366 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result,
9367 queue_num_value, UINT8);
9369 cmdline_parse_inst_t cmd_queue_region = {
9370 .f = cmd_queue_region_parsed,
9372 .help_str = "set port <port_id> queue-region region_id <value> "
9373 "queue_start_index <value> queue_num <value>: Set a queue region",
9375 (void *)&cmd_queue_region_set,
9376 (void *)&cmd_queue_region_port,
9377 (void *)&cmd_queue_region_port_id,
9378 (void *)&cmd_queue_region_cmd,
9379 (void *)&cmd_queue_region_id,
9380 (void *)&cmd_queue_region_index,
9381 (void *)&cmd_queue_region_queue_start_index,
9382 (void *)&cmd_queue_region_queue_id,
9383 (void *)&cmd_queue_region_queue_num,
9384 (void *)&cmd_queue_region_queue_num_value,
9389 /* *** queue region and flowtype set *** */
9390 struct cmd_region_flowtype_result {
9391 cmdline_fixed_string_t set;
9392 cmdline_fixed_string_t port;
9394 cmdline_fixed_string_t cmd;
9395 cmdline_fixed_string_t region;
9397 cmdline_fixed_string_t flowtype;
9398 uint8_t flowtype_id;
9402 cmd_region_flowtype_parsed(void *parsed_result,
9403 __attribute__((unused)) struct cmdline *cl,
9404 __attribute__((unused)) void *data)
9406 struct cmd_region_flowtype_result *res = parsed_result;
9408 #ifdef RTE_LIBRTE_I40E_PMD
9409 struct rte_pmd_i40e_queue_region_conf region_conf;
9410 enum rte_pmd_i40e_queue_region_op op_type;
9413 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9416 #ifdef RTE_LIBRTE_I40E_PMD
9417 memset(®ion_conf, 0, sizeof(region_conf));
9419 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET;
9420 region_conf.region_id = res->region_id;
9421 region_conf.hw_flowtype = res->flowtype_id;
9423 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9424 op_type, ®ion_conf);
9431 printf("function not implemented or supported\n");
9434 printf("region flowtype config error: (%s)\n", strerror(-ret));
9438 cmdline_parse_token_string_t cmd_region_flowtype_set =
9439 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9441 cmdline_parse_token_string_t cmd_region_flowtype_port =
9442 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9444 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9445 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9447 cmdline_parse_token_string_t cmd_region_flowtype_cmd =
9448 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9449 cmd, "queue-region");
9450 cmdline_parse_token_string_t cmd_region_flowtype_index =
9451 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9452 region, "region_id");
9453 cmdline_parse_token_num_t cmd_region_flowtype_id =
9454 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9456 cmdline_parse_token_string_t cmd_region_flowtype_flow_index =
9457 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9458 flowtype, "flowtype");
9459 cmdline_parse_token_num_t cmd_region_flowtype_flow_id =
9460 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9461 flowtype_id, UINT8);
9462 cmdline_parse_inst_t cmd_region_flowtype = {
9463 .f = cmd_region_flowtype_parsed,
9465 .help_str = "set port <port_id> queue-region region_id <value> "
9466 "flowtype <value>: Set a flowtype region index",
9468 (void *)&cmd_region_flowtype_set,
9469 (void *)&cmd_region_flowtype_port,
9470 (void *)&cmd_region_flowtype_port_index,
9471 (void *)&cmd_region_flowtype_cmd,
9472 (void *)&cmd_region_flowtype_index,
9473 (void *)&cmd_region_flowtype_id,
9474 (void *)&cmd_region_flowtype_flow_index,
9475 (void *)&cmd_region_flowtype_flow_id,
9480 /* *** User Priority (UP) to queue region (region_id) set *** */
9481 struct cmd_user_priority_region_result {
9482 cmdline_fixed_string_t set;
9483 cmdline_fixed_string_t port;
9485 cmdline_fixed_string_t cmd;
9486 cmdline_fixed_string_t user_priority;
9487 uint8_t user_priority_id;
9488 cmdline_fixed_string_t region;
9493 cmd_user_priority_region_parsed(void *parsed_result,
9494 __attribute__((unused)) struct cmdline *cl,
9495 __attribute__((unused)) void *data)
9497 struct cmd_user_priority_region_result *res = parsed_result;
9499 #ifdef RTE_LIBRTE_I40E_PMD
9500 struct rte_pmd_i40e_queue_region_conf region_conf;
9501 enum rte_pmd_i40e_queue_region_op op_type;
9504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9507 #ifdef RTE_LIBRTE_I40E_PMD
9508 memset(®ion_conf, 0, sizeof(region_conf));
9509 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET;
9510 region_conf.user_priority = res->user_priority_id;
9511 region_conf.region_id = res->region_id;
9513 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9514 op_type, ®ion_conf);
9521 printf("function not implemented or supported\n");
9524 printf("user_priority region config error: (%s)\n",
9529 cmdline_parse_token_string_t cmd_user_priority_region_set =
9530 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9532 cmdline_parse_token_string_t cmd_user_priority_region_port =
9533 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9535 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9536 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9538 cmdline_parse_token_string_t cmd_user_priority_region_cmd =
9539 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9540 cmd, "queue-region");
9541 cmdline_parse_token_string_t cmd_user_priority_region_UP =
9542 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9543 user_priority, "UP");
9544 cmdline_parse_token_num_t cmd_user_priority_region_UP_id =
9545 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9546 user_priority_id, UINT8);
9547 cmdline_parse_token_string_t cmd_user_priority_region_region =
9548 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9549 region, "region_id");
9550 cmdline_parse_token_num_t cmd_user_priority_region_region_id =
9551 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9554 cmdline_parse_inst_t cmd_user_priority_region = {
9555 .f = cmd_user_priority_region_parsed,
9557 .help_str = "set port <port_id> queue-region UP <value> "
9558 "region_id <value>: Set the mapping of User Priority (UP) "
9559 "to queue region (region_id) ",
9561 (void *)&cmd_user_priority_region_set,
9562 (void *)&cmd_user_priority_region_port,
9563 (void *)&cmd_user_priority_region_port_index,
9564 (void *)&cmd_user_priority_region_cmd,
9565 (void *)&cmd_user_priority_region_UP,
9566 (void *)&cmd_user_priority_region_UP_id,
9567 (void *)&cmd_user_priority_region_region,
9568 (void *)&cmd_user_priority_region_region_id,
9573 /* *** flush all queue region related configuration *** */
9574 struct cmd_flush_queue_region_result {
9575 cmdline_fixed_string_t set;
9576 cmdline_fixed_string_t port;
9578 cmdline_fixed_string_t cmd;
9579 cmdline_fixed_string_t flush;
9580 cmdline_fixed_string_t what;
9584 cmd_flush_queue_region_parsed(void *parsed_result,
9585 __attribute__((unused)) struct cmdline *cl,
9586 __attribute__((unused)) void *data)
9588 struct cmd_flush_queue_region_result *res = parsed_result;
9590 #ifdef RTE_LIBRTE_I40E_PMD
9591 struct rte_pmd_i40e_queue_region_conf region_conf;
9592 enum rte_pmd_i40e_queue_region_op op_type;
9595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9598 #ifdef RTE_LIBRTE_I40E_PMD
9599 memset(®ion_conf, 0, sizeof(region_conf));
9601 if (strcmp(res->what, "on") == 0)
9602 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9604 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9606 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9607 op_type, ®ion_conf);
9614 printf("function not implemented or supported\n");
9617 printf("queue region config flush error: (%s)\n",
9622 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9623 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9625 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9626 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9628 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9629 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9631 cmdline_parse_token_string_t cmd_flush_queue_region_cmd =
9632 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9633 cmd, "queue-region");
9634 cmdline_parse_token_string_t cmd_flush_queue_region_flush =
9635 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9637 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9638 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9641 cmdline_parse_inst_t cmd_flush_queue_region = {
9642 .f = cmd_flush_queue_region_parsed,
9644 .help_str = "set port <port_id> queue-region flush on|off"
9645 ": flush all queue region related configuration",
9647 (void *)&cmd_flush_queue_region_set,
9648 (void *)&cmd_flush_queue_region_port,
9649 (void *)&cmd_flush_queue_region_port_index,
9650 (void *)&cmd_flush_queue_region_cmd,
9651 (void *)&cmd_flush_queue_region_flush,
9652 (void *)&cmd_flush_queue_region_what,
9657 /* *** get all queue region related configuration info *** */
9658 struct cmd_show_queue_region_info {
9659 cmdline_fixed_string_t show;
9660 cmdline_fixed_string_t port;
9662 cmdline_fixed_string_t cmd;
9666 cmd_show_queue_region_info_parsed(void *parsed_result,
9667 __attribute__((unused)) struct cmdline *cl,
9668 __attribute__((unused)) void *data)
9670 struct cmd_show_queue_region_info *res = parsed_result;
9672 #ifdef RTE_LIBRTE_I40E_PMD
9673 struct rte_pmd_i40e_queue_regions rte_pmd_regions;
9674 enum rte_pmd_i40e_queue_region_op op_type;
9677 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9680 #ifdef RTE_LIBRTE_I40E_PMD
9681 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9683 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9685 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9686 op_type, &rte_pmd_regions);
9688 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9695 printf("function not implemented or supported\n");
9698 printf("queue region config info show error: (%s)\n",
9703 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9704 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9706 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9707 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9709 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9710 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9712 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd =
9713 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9714 cmd, "queue-region");
9716 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9717 .f = cmd_show_queue_region_info_parsed,
9719 .help_str = "show port <port_id> queue-region"
9720 ": show all queue region related configuration info",
9722 (void *)&cmd_show_queue_region_info_get,
9723 (void *)&cmd_show_queue_region_info_port,
9724 (void *)&cmd_show_queue_region_info_port_index,
9725 (void *)&cmd_show_queue_region_info_cmd,
9730 /* *** ADD/REMOVE A 2tuple FILTER *** */
9731 struct cmd_2tuple_filter_result {
9732 cmdline_fixed_string_t filter;
9734 cmdline_fixed_string_t ops;
9735 cmdline_fixed_string_t dst_port;
9736 uint16_t dst_port_value;
9737 cmdline_fixed_string_t protocol;
9738 uint8_t protocol_value;
9739 cmdline_fixed_string_t mask;
9741 cmdline_fixed_string_t tcp_flags;
9742 uint8_t tcp_flags_value;
9743 cmdline_fixed_string_t priority;
9744 uint8_t priority_value;
9745 cmdline_fixed_string_t queue;
9750 cmd_2tuple_filter_parsed(void *parsed_result,
9751 __attribute__((unused)) struct cmdline *cl,
9752 __attribute__((unused)) void *data)
9754 struct rte_eth_ntuple_filter filter;
9755 struct cmd_2tuple_filter_result *res = parsed_result;
9758 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9760 printf("ntuple filter is not supported on port %u.\n",
9765 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9767 filter.flags = RTE_2TUPLE_FLAGS;
9768 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9769 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9770 filter.proto = res->protocol_value;
9771 filter.priority = res->priority_value;
9772 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9773 printf("nonzero tcp_flags is only meaningful"
9774 " when protocol is TCP.\n");
9777 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9778 printf("invalid TCP flags.\n");
9782 if (res->tcp_flags_value != 0) {
9783 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9784 filter.tcp_flags = res->tcp_flags_value;
9787 /* need convert to big endian. */
9788 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9789 filter.queue = res->queue_id;
9791 if (!strcmp(res->ops, "add"))
9792 ret = rte_eth_dev_filter_ctrl(res->port_id,
9793 RTE_ETH_FILTER_NTUPLE,
9797 ret = rte_eth_dev_filter_ctrl(res->port_id,
9798 RTE_ETH_FILTER_NTUPLE,
9799 RTE_ETH_FILTER_DELETE,
9802 printf("2tuple filter programming error: (%s)\n",
9807 cmdline_parse_token_string_t cmd_2tuple_filter_filter =
9808 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9809 filter, "2tuple_filter");
9810 cmdline_parse_token_num_t cmd_2tuple_filter_port_id =
9811 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9813 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9814 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9816 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port =
9817 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9818 dst_port, "dst_port");
9819 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value =
9820 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9821 dst_port_value, UINT16);
9822 cmdline_parse_token_string_t cmd_2tuple_filter_protocol =
9823 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9824 protocol, "protocol");
9825 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value =
9826 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9827 protocol_value, UINT8);
9828 cmdline_parse_token_string_t cmd_2tuple_filter_mask =
9829 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9831 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9832 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9834 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags =
9835 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9836 tcp_flags, "tcp_flags");
9837 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value =
9838 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9839 tcp_flags_value, UINT8);
9840 cmdline_parse_token_string_t cmd_2tuple_filter_priority =
9841 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9842 priority, "priority");
9843 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value =
9844 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9845 priority_value, UINT8);
9846 cmdline_parse_token_string_t cmd_2tuple_filter_queue =
9847 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9849 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9850 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9853 cmdline_parse_inst_t cmd_2tuple_filter = {
9854 .f = cmd_2tuple_filter_parsed,
9856 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol "
9857 "<value> mask <value> tcp_flags <value> priority <value> queue "
9858 "<queue_id>: Add a 2tuple filter",
9860 (void *)&cmd_2tuple_filter_filter,
9861 (void *)&cmd_2tuple_filter_port_id,
9862 (void *)&cmd_2tuple_filter_ops,
9863 (void *)&cmd_2tuple_filter_dst_port,
9864 (void *)&cmd_2tuple_filter_dst_port_value,
9865 (void *)&cmd_2tuple_filter_protocol,
9866 (void *)&cmd_2tuple_filter_protocol_value,
9867 (void *)&cmd_2tuple_filter_mask,
9868 (void *)&cmd_2tuple_filter_mask_value,
9869 (void *)&cmd_2tuple_filter_tcp_flags,
9870 (void *)&cmd_2tuple_filter_tcp_flags_value,
9871 (void *)&cmd_2tuple_filter_priority,
9872 (void *)&cmd_2tuple_filter_priority_value,
9873 (void *)&cmd_2tuple_filter_queue,
9874 (void *)&cmd_2tuple_filter_queue_id,
9879 /* *** ADD/REMOVE A 5tuple FILTER *** */
9880 struct cmd_5tuple_filter_result {
9881 cmdline_fixed_string_t filter;
9883 cmdline_fixed_string_t ops;
9884 cmdline_fixed_string_t dst_ip;
9885 cmdline_ipaddr_t dst_ip_value;
9886 cmdline_fixed_string_t src_ip;
9887 cmdline_ipaddr_t src_ip_value;
9888 cmdline_fixed_string_t dst_port;
9889 uint16_t dst_port_value;
9890 cmdline_fixed_string_t src_port;
9891 uint16_t src_port_value;
9892 cmdline_fixed_string_t protocol;
9893 uint8_t protocol_value;
9894 cmdline_fixed_string_t mask;
9896 cmdline_fixed_string_t tcp_flags;
9897 uint8_t tcp_flags_value;
9898 cmdline_fixed_string_t priority;
9899 uint8_t priority_value;
9900 cmdline_fixed_string_t queue;
9905 cmd_5tuple_filter_parsed(void *parsed_result,
9906 __attribute__((unused)) struct cmdline *cl,
9907 __attribute__((unused)) void *data)
9909 struct rte_eth_ntuple_filter filter;
9910 struct cmd_5tuple_filter_result *res = parsed_result;
9913 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9915 printf("ntuple filter is not supported on port %u.\n",
9920 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9922 filter.flags = RTE_5TUPLE_FLAGS;
9923 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0;
9924 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0;
9925 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0;
9926 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0;
9927 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0;
9928 filter.proto = res->protocol_value;
9929 filter.priority = res->priority_value;
9930 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) {
9931 printf("nonzero tcp_flags is only meaningful"
9932 " when protocol is TCP.\n");
9935 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9936 printf("invalid TCP flags.\n");
9940 if (res->tcp_flags_value != 0) {
9941 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9942 filter.tcp_flags = res->tcp_flags_value;
9945 if (res->dst_ip_value.family == AF_INET)
9946 /* no need to convert, already big endian. */
9947 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr;
9949 if (filter.dst_ip_mask == 0) {
9950 printf("can not support ipv6 involved compare.\n");
9956 if (res->src_ip_value.family == AF_INET)
9957 /* no need to convert, already big endian. */
9958 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr;
9960 if (filter.src_ip_mask == 0) {
9961 printf("can not support ipv6 involved compare.\n");
9966 /* need convert to big endian. */
9967 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value);
9968 filter.src_port = rte_cpu_to_be_16(res->src_port_value);
9969 filter.queue = res->queue_id;
9971 if (!strcmp(res->ops, "add"))
9972 ret = rte_eth_dev_filter_ctrl(res->port_id,
9973 RTE_ETH_FILTER_NTUPLE,
9977 ret = rte_eth_dev_filter_ctrl(res->port_id,
9978 RTE_ETH_FILTER_NTUPLE,
9979 RTE_ETH_FILTER_DELETE,
9982 printf("5tuple filter programming error: (%s)\n",
9986 cmdline_parse_token_string_t cmd_5tuple_filter_filter =
9987 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9988 filter, "5tuple_filter");
9989 cmdline_parse_token_num_t cmd_5tuple_filter_port_id =
9990 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
9992 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9993 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9995 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9996 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9998 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9999 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10001 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10002 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10004 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10005 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10007 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port =
10008 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10009 dst_port, "dst_port");
10010 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value =
10011 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10012 dst_port_value, UINT16);
10013 cmdline_parse_token_string_t cmd_5tuple_filter_src_port =
10014 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10015 src_port, "src_port");
10016 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value =
10017 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10018 src_port_value, UINT16);
10019 cmdline_parse_token_string_t cmd_5tuple_filter_protocol =
10020 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10021 protocol, "protocol");
10022 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value =
10023 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10024 protocol_value, UINT8);
10025 cmdline_parse_token_string_t cmd_5tuple_filter_mask =
10026 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10028 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10029 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10031 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags =
10032 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10033 tcp_flags, "tcp_flags");
10034 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value =
10035 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10036 tcp_flags_value, UINT8);
10037 cmdline_parse_token_string_t cmd_5tuple_filter_priority =
10038 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10039 priority, "priority");
10040 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value =
10041 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10042 priority_value, UINT8);
10043 cmdline_parse_token_string_t cmd_5tuple_filter_queue =
10044 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10046 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10047 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10050 cmdline_parse_inst_t cmd_5tuple_filter = {
10051 .f = cmd_5tuple_filter_parsed,
10053 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> "
10054 "src_ip <value> dst_port <value> src_port <value> "
10055 "protocol <value> mask <value> tcp_flags <value> "
10056 "priority <value> queue <queue_id>: Add/Del a 5tuple filter",
10058 (void *)&cmd_5tuple_filter_filter,
10059 (void *)&cmd_5tuple_filter_port_id,
10060 (void *)&cmd_5tuple_filter_ops,
10061 (void *)&cmd_5tuple_filter_dst_ip,
10062 (void *)&cmd_5tuple_filter_dst_ip_value,
10063 (void *)&cmd_5tuple_filter_src_ip,
10064 (void *)&cmd_5tuple_filter_src_ip_value,
10065 (void *)&cmd_5tuple_filter_dst_port,
10066 (void *)&cmd_5tuple_filter_dst_port_value,
10067 (void *)&cmd_5tuple_filter_src_port,
10068 (void *)&cmd_5tuple_filter_src_port_value,
10069 (void *)&cmd_5tuple_filter_protocol,
10070 (void *)&cmd_5tuple_filter_protocol_value,
10071 (void *)&cmd_5tuple_filter_mask,
10072 (void *)&cmd_5tuple_filter_mask_value,
10073 (void *)&cmd_5tuple_filter_tcp_flags,
10074 (void *)&cmd_5tuple_filter_tcp_flags_value,
10075 (void *)&cmd_5tuple_filter_priority,
10076 (void *)&cmd_5tuple_filter_priority_value,
10077 (void *)&cmd_5tuple_filter_queue,
10078 (void *)&cmd_5tuple_filter_queue_id,
10083 /* *** ADD/REMOVE A flex FILTER *** */
10084 struct cmd_flex_filter_result {
10085 cmdline_fixed_string_t filter;
10086 cmdline_fixed_string_t ops;
10088 cmdline_fixed_string_t len;
10090 cmdline_fixed_string_t bytes;
10091 cmdline_fixed_string_t bytes_value;
10092 cmdline_fixed_string_t mask;
10093 cmdline_fixed_string_t mask_value;
10094 cmdline_fixed_string_t priority;
10095 uint8_t priority_value;
10096 cmdline_fixed_string_t queue;
10100 static int xdigit2val(unsigned char c)
10105 else if (isupper(c))
10106 val = c - 'A' + 10;
10108 val = c - 'a' + 10;
10113 cmd_flex_filter_parsed(void *parsed_result,
10114 __attribute__((unused)) struct cmdline *cl,
10115 __attribute__((unused)) void *data)
10118 struct rte_eth_flex_filter filter;
10119 struct cmd_flex_filter_result *res = parsed_result;
10120 char *bytes_ptr, *mask_ptr;
10121 uint16_t len, i, j = 0;
10126 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10127 printf("the len exceed the max length 128\n");
10130 memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
10131 filter.len = res->len_value;
10132 filter.priority = res->priority_value;
10133 filter.queue = res->queue_id;
10134 bytes_ptr = res->bytes_value;
10135 mask_ptr = res->mask_value;
10137 /* translate bytes string to array. */
10138 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10139 (bytes_ptr[1] == 'X')))
10141 len = strnlen(bytes_ptr, res->len_value * 2);
10142 if (len == 0 || (len % 8 != 0)) {
10143 printf("please check len and bytes input\n");
10146 for (i = 0; i < len; i++) {
10148 if (isxdigit(c) == 0) {
10149 /* invalid characters. */
10150 printf("invalid input\n");
10153 val = xdigit2val(c);
10156 filter.bytes[j] = byte;
10157 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10164 /* translate mask string to uint8_t array. */
10165 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10166 (mask_ptr[1] == 'X')))
10168 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10170 printf("invalid input\n");
10175 for (i = 0; i < len; i++) {
10177 if (isxdigit(c) == 0) {
10178 /* invalid characters. */
10179 printf("invalid input\n");
10182 val = xdigit2val(c);
10185 filter.mask[j] = byte;
10186 printf("mask[%d]:%02x ", j, filter.mask[j]);
10194 if (!strcmp(res->ops, "add"))
10195 ret = rte_eth_dev_filter_ctrl(res->port_id,
10196 RTE_ETH_FILTER_FLEXIBLE,
10197 RTE_ETH_FILTER_ADD,
10200 ret = rte_eth_dev_filter_ctrl(res->port_id,
10201 RTE_ETH_FILTER_FLEXIBLE,
10202 RTE_ETH_FILTER_DELETE,
10206 printf("flex filter setting error: (%s)\n", strerror(-ret));
10209 cmdline_parse_token_string_t cmd_flex_filter_filter =
10210 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10211 filter, "flex_filter");
10212 cmdline_parse_token_num_t cmd_flex_filter_port_id =
10213 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10215 cmdline_parse_token_string_t cmd_flex_filter_ops =
10216 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10218 cmdline_parse_token_string_t cmd_flex_filter_len =
10219 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10221 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10222 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10224 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10225 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10227 cmdline_parse_token_string_t cmd_flex_filter_bytes_value =
10228 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10229 bytes_value, NULL);
10230 cmdline_parse_token_string_t cmd_flex_filter_mask =
10231 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10233 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10234 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10236 cmdline_parse_token_string_t cmd_flex_filter_priority =
10237 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10238 priority, "priority");
10239 cmdline_parse_token_num_t cmd_flex_filter_priority_value =
10240 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10241 priority_value, UINT8);
10242 cmdline_parse_token_string_t cmd_flex_filter_queue =
10243 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10245 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10246 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10248 cmdline_parse_inst_t cmd_flex_filter = {
10249 .f = cmd_flex_filter_parsed,
10251 .help_str = "flex_filter <port_id> add|del len <value> bytes "
10252 "<value> mask <value> priority <value> queue <queue_id>: "
10253 "Add/Del a flex filter",
10255 (void *)&cmd_flex_filter_filter,
10256 (void *)&cmd_flex_filter_port_id,
10257 (void *)&cmd_flex_filter_ops,
10258 (void *)&cmd_flex_filter_len,
10259 (void *)&cmd_flex_filter_len_value,
10260 (void *)&cmd_flex_filter_bytes,
10261 (void *)&cmd_flex_filter_bytes_value,
10262 (void *)&cmd_flex_filter_mask,
10263 (void *)&cmd_flex_filter_mask_value,
10264 (void *)&cmd_flex_filter_priority,
10265 (void *)&cmd_flex_filter_priority_value,
10266 (void *)&cmd_flex_filter_queue,
10267 (void *)&cmd_flex_filter_queue_id,
10272 /* *** Filters Control *** */
10274 /* *** deal with ethertype filter *** */
10275 struct cmd_ethertype_filter_result {
10276 cmdline_fixed_string_t filter;
10278 cmdline_fixed_string_t ops;
10279 cmdline_fixed_string_t mac;
10280 struct ether_addr mac_addr;
10281 cmdline_fixed_string_t ethertype;
10282 uint16_t ethertype_value;
10283 cmdline_fixed_string_t drop;
10284 cmdline_fixed_string_t queue;
10288 cmdline_parse_token_string_t cmd_ethertype_filter_filter =
10289 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10290 filter, "ethertype_filter");
10291 cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
10292 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10294 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10295 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10297 cmdline_parse_token_string_t cmd_ethertype_filter_mac =
10298 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10299 mac, "mac_addr#mac_ignr");
10300 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
10301 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
10303 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
10304 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10305 ethertype, "ethertype");
10306 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
10307 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10308 ethertype_value, UINT16);
10309 cmdline_parse_token_string_t cmd_ethertype_filter_drop =
10310 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10312 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10313 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10315 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10316 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10320 cmd_ethertype_filter_parsed(void *parsed_result,
10321 __attribute__((unused)) struct cmdline *cl,
10322 __attribute__((unused)) void *data)
10324 struct cmd_ethertype_filter_result *res = parsed_result;
10325 struct rte_eth_ethertype_filter filter;
10328 ret = rte_eth_dev_filter_supported(res->port_id,
10329 RTE_ETH_FILTER_ETHERTYPE);
10331 printf("ethertype filter is not supported on port %u.\n",
10336 memset(&filter, 0, sizeof(filter));
10337 if (!strcmp(res->mac, "mac_addr")) {
10338 filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
10339 rte_memcpy(&filter.mac_addr, &res->mac_addr,
10340 sizeof(struct ether_addr));
10342 if (!strcmp(res->drop, "drop"))
10343 filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
10344 filter.ether_type = res->ethertype_value;
10345 filter.queue = res->queue_id;
10347 if (!strcmp(res->ops, "add"))
10348 ret = rte_eth_dev_filter_ctrl(res->port_id,
10349 RTE_ETH_FILTER_ETHERTYPE,
10350 RTE_ETH_FILTER_ADD,
10353 ret = rte_eth_dev_filter_ctrl(res->port_id,
10354 RTE_ETH_FILTER_ETHERTYPE,
10355 RTE_ETH_FILTER_DELETE,
10358 printf("ethertype filter programming error: (%s)\n",
10362 cmdline_parse_inst_t cmd_ethertype_filter = {
10363 .f = cmd_ethertype_filter_parsed,
10365 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr "
10366 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: "
10367 "Add or delete an ethertype filter entry",
10369 (void *)&cmd_ethertype_filter_filter,
10370 (void *)&cmd_ethertype_filter_port_id,
10371 (void *)&cmd_ethertype_filter_ops,
10372 (void *)&cmd_ethertype_filter_mac,
10373 (void *)&cmd_ethertype_filter_mac_addr,
10374 (void *)&cmd_ethertype_filter_ethertype,
10375 (void *)&cmd_ethertype_filter_ethertype_value,
10376 (void *)&cmd_ethertype_filter_drop,
10377 (void *)&cmd_ethertype_filter_queue,
10378 (void *)&cmd_ethertype_filter_queue_id,
10383 /* *** deal with flow director filter *** */
10384 struct cmd_flow_director_result {
10385 cmdline_fixed_string_t flow_director_filter;
10387 cmdline_fixed_string_t mode;
10388 cmdline_fixed_string_t mode_value;
10389 cmdline_fixed_string_t ops;
10390 cmdline_fixed_string_t flow;
10391 cmdline_fixed_string_t flow_type;
10392 cmdline_fixed_string_t ether;
10393 uint16_t ether_type;
10394 cmdline_fixed_string_t src;
10395 cmdline_ipaddr_t ip_src;
10397 cmdline_fixed_string_t dst;
10398 cmdline_ipaddr_t ip_dst;
10400 cmdline_fixed_string_t verify_tag;
10401 uint32_t verify_tag_value;
10402 cmdline_fixed_string_t tos;
10404 cmdline_fixed_string_t proto;
10405 uint8_t proto_value;
10406 cmdline_fixed_string_t ttl;
10408 cmdline_fixed_string_t vlan;
10409 uint16_t vlan_value;
10410 cmdline_fixed_string_t flexbytes;
10411 cmdline_fixed_string_t flexbytes_value;
10412 cmdline_fixed_string_t pf_vf;
10413 cmdline_fixed_string_t drop;
10414 cmdline_fixed_string_t queue;
10416 cmdline_fixed_string_t fd_id;
10417 uint32_t fd_id_value;
10418 cmdline_fixed_string_t mac;
10419 struct ether_addr mac_addr;
10420 cmdline_fixed_string_t tunnel;
10421 cmdline_fixed_string_t tunnel_type;
10422 cmdline_fixed_string_t tunnel_id;
10423 uint32_t tunnel_id_value;
10424 cmdline_fixed_string_t packet;
10429 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10432 const char *p, *p0 = q_arg;
10434 unsigned long int_fld;
10435 char *str_fld[max_num];
10440 p = strchr(p0, '(');
10444 p0 = strchr(p, ')');
10449 if (size >= sizeof(s))
10452 snprintf(s, sizeof(s), "%.*s", size, p);
10453 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
10454 if (ret < 0 || ret > max_num)
10456 for (i = 0; i < ret; i++) {
10458 int_fld = strtoul(str_fld[i], &end, 0);
10459 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10461 flexbytes[i] = (uint8_t)int_fld;
10467 str2flowtype(char *string)
10470 static const struct {
10473 } flowtype_str[] = {
10474 {"raw", RTE_ETH_FLOW_RAW},
10475 {"ipv4", RTE_ETH_FLOW_IPV4},
10476 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
10477 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
10478 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
10479 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
10480 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
10481 {"ipv6", RTE_ETH_FLOW_IPV6},
10482 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
10483 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
10484 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
10485 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
10486 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
10487 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
10490 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10491 if (!strcmp(flowtype_str[i].str, string))
10492 return flowtype_str[i].type;
10495 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10496 return (uint16_t)atoi(string);
10498 return RTE_ETH_FLOW_UNKNOWN;
10501 static enum rte_eth_fdir_tunnel_type
10502 str2fdir_tunneltype(char *string)
10506 static const struct {
10508 enum rte_eth_fdir_tunnel_type type;
10509 } tunneltype_str[] = {
10510 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE},
10511 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN},
10514 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10515 if (!strcmp(tunneltype_str[i].str, string))
10516 return tunneltype_str[i].type;
10518 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10521 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10523 if ((ip_addr).family == AF_INET) \
10524 (ip) = (ip_addr).addr.ipv4.s_addr; \
10526 printf("invalid parameter.\n"); \
10531 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10533 if ((ip_addr).family == AF_INET6) \
10534 rte_memcpy(&(ip), \
10535 &((ip_addr).addr.ipv6), \
10536 sizeof(struct in6_addr)); \
10538 printf("invalid parameter.\n"); \
10544 cmd_flow_director_filter_parsed(void *parsed_result,
10545 __attribute__((unused)) struct cmdline *cl,
10546 __attribute__((unused)) void *data)
10548 struct cmd_flow_director_result *res = parsed_result;
10549 struct rte_eth_fdir_filter entry;
10550 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN];
10552 unsigned long vf_id;
10555 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10557 printf("flow director is not supported on port %u.\n",
10561 memset(flexbytes, 0, sizeof(flexbytes));
10562 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10564 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
10565 if (strcmp(res->mode_value, "MAC-VLAN")) {
10566 printf("Please set mode to MAC-VLAN.\n");
10569 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10570 if (strcmp(res->mode_value, "Tunnel")) {
10571 printf("Please set mode to Tunnel.\n");
10575 if (!strcmp(res->mode_value, "raw")) {
10576 #ifdef RTE_LIBRTE_I40E_PMD
10577 struct rte_pmd_i40e_flow_type_mapping
10578 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
10579 struct rte_pmd_i40e_pkt_template_conf conf;
10580 uint16_t flow_type = str2flowtype(res->flow_type);
10581 uint16_t i, port = res->port_id;
10584 memset(&conf, 0, sizeof(conf));
10586 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10587 printf("Invalid flow type specified.\n");
10590 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10594 if (mapping[flow_type].pctype == 0ULL) {
10595 printf("Invalid flow type specified.\n");
10598 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10599 if (mapping[flow_type].pctype & (1ULL << i)) {
10600 conf.input.pctype = i;
10605 conf.input.packet = open_file(res->filepath,
10606 &conf.input.length);
10607 if (!conf.input.packet)
10609 if (!strcmp(res->drop, "drop"))
10610 conf.action.behavior =
10611 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10613 conf.action.behavior =
10614 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT;
10615 conf.action.report_status =
10616 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID;
10617 conf.action.rx_queue = res->queue_id;
10618 conf.soft_id = res->fd_id_value;
10619 add = strcmp(res->ops, "del") ? 1 : 0;
10620 ret = rte_pmd_i40e_flow_add_del_packet_template(port,
10624 printf("flow director config error: (%s)\n",
10626 close_file(conf.input.packet);
10629 } else if (strcmp(res->mode_value, "IP")) {
10630 printf("Please set mode to IP or raw.\n");
10633 entry.input.flow_type = str2flowtype(res->flow_type);
10636 ret = parse_flexbytes(res->flexbytes_value,
10638 RTE_ETH_FDIR_MAX_FLEXLEN);
10640 printf("error: Cannot parse flexbytes input.\n");
10644 switch (entry.input.flow_type) {
10645 case RTE_ETH_FLOW_FRAG_IPV4:
10646 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER:
10647 entry.input.flow.ip4_flow.proto = res->proto_value;
10649 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP:
10650 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP:
10651 IPV4_ADDR_TO_UINT(res->ip_dst,
10652 entry.input.flow.ip4_flow.dst_ip);
10653 IPV4_ADDR_TO_UINT(res->ip_src,
10654 entry.input.flow.ip4_flow.src_ip);
10655 entry.input.flow.ip4_flow.tos = res->tos_value;
10656 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10657 /* need convert to big endian. */
10658 entry.input.flow.udp4_flow.dst_port =
10659 rte_cpu_to_be_16(res->port_dst);
10660 entry.input.flow.udp4_flow.src_port =
10661 rte_cpu_to_be_16(res->port_src);
10663 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP:
10664 IPV4_ADDR_TO_UINT(res->ip_dst,
10665 entry.input.flow.sctp4_flow.ip.dst_ip);
10666 IPV4_ADDR_TO_UINT(res->ip_src,
10667 entry.input.flow.sctp4_flow.ip.src_ip);
10668 entry.input.flow.ip4_flow.tos = res->tos_value;
10669 entry.input.flow.ip4_flow.ttl = res->ttl_value;
10670 /* need convert to big endian. */
10671 entry.input.flow.sctp4_flow.dst_port =
10672 rte_cpu_to_be_16(res->port_dst);
10673 entry.input.flow.sctp4_flow.src_port =
10674 rte_cpu_to_be_16(res->port_src);
10675 entry.input.flow.sctp4_flow.verify_tag =
10676 rte_cpu_to_be_32(res->verify_tag_value);
10678 case RTE_ETH_FLOW_FRAG_IPV6:
10679 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER:
10680 entry.input.flow.ipv6_flow.proto = res->proto_value;
10682 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP:
10683 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP:
10684 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10685 entry.input.flow.ipv6_flow.dst_ip);
10686 IPV6_ADDR_TO_ARRAY(res->ip_src,
10687 entry.input.flow.ipv6_flow.src_ip);
10688 entry.input.flow.ipv6_flow.tc = res->tos_value;
10689 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10690 /* need convert to big endian. */
10691 entry.input.flow.udp6_flow.dst_port =
10692 rte_cpu_to_be_16(res->port_dst);
10693 entry.input.flow.udp6_flow.src_port =
10694 rte_cpu_to_be_16(res->port_src);
10696 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP:
10697 IPV6_ADDR_TO_ARRAY(res->ip_dst,
10698 entry.input.flow.sctp6_flow.ip.dst_ip);
10699 IPV6_ADDR_TO_ARRAY(res->ip_src,
10700 entry.input.flow.sctp6_flow.ip.src_ip);
10701 entry.input.flow.ipv6_flow.tc = res->tos_value;
10702 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value;
10703 /* need convert to big endian. */
10704 entry.input.flow.sctp6_flow.dst_port =
10705 rte_cpu_to_be_16(res->port_dst);
10706 entry.input.flow.sctp6_flow.src_port =
10707 rte_cpu_to_be_16(res->port_src);
10708 entry.input.flow.sctp6_flow.verify_tag =
10709 rte_cpu_to_be_32(res->verify_tag_value);
10711 case RTE_ETH_FLOW_L2_PAYLOAD:
10712 entry.input.flow.l2_flow.ether_type =
10713 rte_cpu_to_be_16(res->ether_type);
10719 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10720 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10722 sizeof(struct ether_addr));
10724 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10725 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10727 sizeof(struct ether_addr));
10728 entry.input.flow.tunnel_flow.tunnel_type =
10729 str2fdir_tunneltype(res->tunnel_type);
10730 entry.input.flow.tunnel_flow.tunnel_id =
10731 rte_cpu_to_be_32(res->tunnel_id_value);
10734 rte_memcpy(entry.input.flow_ext.flexbytes,
10736 RTE_ETH_FDIR_MAX_FLEXLEN);
10738 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10740 entry.action.flex_off = 0; /*use 0 by default */
10741 if (!strcmp(res->drop, "drop"))
10742 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10744 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10746 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN &&
10747 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) {
10748 if (!strcmp(res->pf_vf, "pf"))
10749 entry.input.flow_ext.is_vf = 0;
10750 else if (!strncmp(res->pf_vf, "vf", 2)) {
10751 struct rte_eth_dev_info dev_info;
10753 memset(&dev_info, 0, sizeof(dev_info));
10754 rte_eth_dev_info_get(res->port_id, &dev_info);
10756 vf_id = strtoul(res->pf_vf + 2, &end, 10);
10757 if (errno != 0 || *end != '\0' ||
10758 vf_id >= dev_info.max_vfs) {
10759 printf("invalid parameter %s.\n", res->pf_vf);
10762 entry.input.flow_ext.is_vf = 1;
10763 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10765 printf("invalid parameter %s.\n", res->pf_vf);
10770 /* set to report FD ID by default */
10771 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID;
10772 entry.action.rx_queue = res->queue_id;
10773 entry.soft_id = res->fd_id_value;
10774 if (!strcmp(res->ops, "add"))
10775 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10776 RTE_ETH_FILTER_ADD, &entry);
10777 else if (!strcmp(res->ops, "del"))
10778 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10779 RTE_ETH_FILTER_DELETE, &entry);
10781 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10782 RTE_ETH_FILTER_UPDATE, &entry);
10784 printf("flow director programming error: (%s)\n",
10788 cmdline_parse_token_string_t cmd_flow_director_filter =
10789 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10790 flow_director_filter, "flow_director_filter");
10791 cmdline_parse_token_num_t cmd_flow_director_port_id =
10792 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10794 cmdline_parse_token_string_t cmd_flow_director_ops =
10795 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10796 ops, "add#del#update");
10797 cmdline_parse_token_string_t cmd_flow_director_flow =
10798 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10800 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10803 cmdline_parse_token_string_t cmd_flow_director_ether =
10804 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10806 cmdline_parse_token_num_t cmd_flow_director_ether_type =
10807 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10808 ether_type, UINT16);
10809 cmdline_parse_token_string_t cmd_flow_director_src =
10810 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10812 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10813 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10815 cmdline_parse_token_num_t cmd_flow_director_port_src =
10816 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10818 cmdline_parse_token_string_t cmd_flow_director_dst =
10819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10821 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10822 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10824 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10825 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10827 cmdline_parse_token_string_t cmd_flow_director_verify_tag =
10828 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10829 verify_tag, "verify_tag");
10830 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value =
10831 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10832 verify_tag_value, UINT32);
10833 cmdline_parse_token_string_t cmd_flow_director_tos =
10834 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10836 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10837 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10839 cmdline_parse_token_string_t cmd_flow_director_proto =
10840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10842 cmdline_parse_token_num_t cmd_flow_director_proto_value =
10843 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10844 proto_value, UINT8);
10845 cmdline_parse_token_string_t cmd_flow_director_ttl =
10846 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10848 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10849 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10851 cmdline_parse_token_string_t cmd_flow_director_vlan =
10852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10854 cmdline_parse_token_num_t cmd_flow_director_vlan_value =
10855 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10856 vlan_value, UINT16);
10857 cmdline_parse_token_string_t cmd_flow_director_flexbytes =
10858 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10859 flexbytes, "flexbytes");
10860 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value =
10861 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10862 flexbytes_value, NULL);
10863 cmdline_parse_token_string_t cmd_flow_director_drop =
10864 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10866 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10869 cmdline_parse_token_string_t cmd_flow_director_queue =
10870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10872 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10873 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10875 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10878 cmdline_parse_token_num_t cmd_flow_director_fd_id_value =
10879 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10880 fd_id_value, UINT32);
10882 cmdline_parse_token_string_t cmd_flow_director_mode =
10883 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10885 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10888 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan =
10889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10890 mode_value, "MAC-VLAN");
10891 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel =
10892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10893 mode_value, "Tunnel");
10894 cmdline_parse_token_string_t cmd_flow_director_mode_raw =
10895 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10896 mode_value, "raw");
10897 cmdline_parse_token_string_t cmd_flow_director_mac =
10898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10900 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10901 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10903 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10906 cmdline_parse_token_string_t cmd_flow_director_tunnel_type =
10907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10908 tunnel_type, "NVGRE#VxLAN");
10909 cmdline_parse_token_string_t cmd_flow_director_tunnel_id =
10910 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10911 tunnel_id, "tunnel-id");
10912 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value =
10913 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10914 tunnel_id_value, UINT32);
10915 cmdline_parse_token_string_t cmd_flow_director_packet =
10916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10918 cmdline_parse_token_string_t cmd_flow_director_filepath =
10919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10922 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10923 .f = cmd_flow_director_filter_parsed,
10925 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow"
10926 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|"
10927 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|"
10928 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> "
10929 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> "
10930 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> "
10931 "fd_id <fd_id_value>: "
10932 "Add or delete an ip flow director entry on NIC",
10934 (void *)&cmd_flow_director_filter,
10935 (void *)&cmd_flow_director_port_id,
10936 (void *)&cmd_flow_director_mode,
10937 (void *)&cmd_flow_director_mode_ip,
10938 (void *)&cmd_flow_director_ops,
10939 (void *)&cmd_flow_director_flow,
10940 (void *)&cmd_flow_director_flow_type,
10941 (void *)&cmd_flow_director_src,
10942 (void *)&cmd_flow_director_ip_src,
10943 (void *)&cmd_flow_director_dst,
10944 (void *)&cmd_flow_director_ip_dst,
10945 (void *)&cmd_flow_director_tos,
10946 (void *)&cmd_flow_director_tos_value,
10947 (void *)&cmd_flow_director_proto,
10948 (void *)&cmd_flow_director_proto_value,
10949 (void *)&cmd_flow_director_ttl,
10950 (void *)&cmd_flow_director_ttl_value,
10951 (void *)&cmd_flow_director_vlan,
10952 (void *)&cmd_flow_director_vlan_value,
10953 (void *)&cmd_flow_director_flexbytes,
10954 (void *)&cmd_flow_director_flexbytes_value,
10955 (void *)&cmd_flow_director_drop,
10956 (void *)&cmd_flow_director_pf_vf,
10957 (void *)&cmd_flow_director_queue,
10958 (void *)&cmd_flow_director_queue_id,
10959 (void *)&cmd_flow_director_fd_id,
10960 (void *)&cmd_flow_director_fd_id_value,
10965 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10966 .f = cmd_flow_director_filter_parsed,
10968 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10969 "director entry on NIC",
10971 (void *)&cmd_flow_director_filter,
10972 (void *)&cmd_flow_director_port_id,
10973 (void *)&cmd_flow_director_mode,
10974 (void *)&cmd_flow_director_mode_ip,
10975 (void *)&cmd_flow_director_ops,
10976 (void *)&cmd_flow_director_flow,
10977 (void *)&cmd_flow_director_flow_type,
10978 (void *)&cmd_flow_director_src,
10979 (void *)&cmd_flow_director_ip_src,
10980 (void *)&cmd_flow_director_port_src,
10981 (void *)&cmd_flow_director_dst,
10982 (void *)&cmd_flow_director_ip_dst,
10983 (void *)&cmd_flow_director_port_dst,
10984 (void *)&cmd_flow_director_tos,
10985 (void *)&cmd_flow_director_tos_value,
10986 (void *)&cmd_flow_director_ttl,
10987 (void *)&cmd_flow_director_ttl_value,
10988 (void *)&cmd_flow_director_vlan,
10989 (void *)&cmd_flow_director_vlan_value,
10990 (void *)&cmd_flow_director_flexbytes,
10991 (void *)&cmd_flow_director_flexbytes_value,
10992 (void *)&cmd_flow_director_drop,
10993 (void *)&cmd_flow_director_pf_vf,
10994 (void *)&cmd_flow_director_queue,
10995 (void *)&cmd_flow_director_queue_id,
10996 (void *)&cmd_flow_director_fd_id,
10997 (void *)&cmd_flow_director_fd_id_value,
11002 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11003 .f = cmd_flow_director_filter_parsed,
11005 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11006 "director entry on NIC",
11008 (void *)&cmd_flow_director_filter,
11009 (void *)&cmd_flow_director_port_id,
11010 (void *)&cmd_flow_director_mode,
11011 (void *)&cmd_flow_director_mode_ip,
11012 (void *)&cmd_flow_director_ops,
11013 (void *)&cmd_flow_director_flow,
11014 (void *)&cmd_flow_director_flow_type,
11015 (void *)&cmd_flow_director_src,
11016 (void *)&cmd_flow_director_ip_src,
11017 (void *)&cmd_flow_director_port_src,
11018 (void *)&cmd_flow_director_dst,
11019 (void *)&cmd_flow_director_ip_dst,
11020 (void *)&cmd_flow_director_port_dst,
11021 (void *)&cmd_flow_director_verify_tag,
11022 (void *)&cmd_flow_director_verify_tag_value,
11023 (void *)&cmd_flow_director_tos,
11024 (void *)&cmd_flow_director_tos_value,
11025 (void *)&cmd_flow_director_ttl,
11026 (void *)&cmd_flow_director_ttl_value,
11027 (void *)&cmd_flow_director_vlan,
11028 (void *)&cmd_flow_director_vlan_value,
11029 (void *)&cmd_flow_director_flexbytes,
11030 (void *)&cmd_flow_director_flexbytes_value,
11031 (void *)&cmd_flow_director_drop,
11032 (void *)&cmd_flow_director_pf_vf,
11033 (void *)&cmd_flow_director_queue,
11034 (void *)&cmd_flow_director_queue_id,
11035 (void *)&cmd_flow_director_fd_id,
11036 (void *)&cmd_flow_director_fd_id_value,
11041 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11042 .f = cmd_flow_director_filter_parsed,
11044 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11045 "director entry on NIC",
11047 (void *)&cmd_flow_director_filter,
11048 (void *)&cmd_flow_director_port_id,
11049 (void *)&cmd_flow_director_mode,
11050 (void *)&cmd_flow_director_mode_ip,
11051 (void *)&cmd_flow_director_ops,
11052 (void *)&cmd_flow_director_flow,
11053 (void *)&cmd_flow_director_flow_type,
11054 (void *)&cmd_flow_director_ether,
11055 (void *)&cmd_flow_director_ether_type,
11056 (void *)&cmd_flow_director_flexbytes,
11057 (void *)&cmd_flow_director_flexbytes_value,
11058 (void *)&cmd_flow_director_drop,
11059 (void *)&cmd_flow_director_pf_vf,
11060 (void *)&cmd_flow_director_queue,
11061 (void *)&cmd_flow_director_queue_id,
11062 (void *)&cmd_flow_director_fd_id,
11063 (void *)&cmd_flow_director_fd_id_value,
11068 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11069 .f = cmd_flow_director_filter_parsed,
11071 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11072 "director entry on NIC",
11074 (void *)&cmd_flow_director_filter,
11075 (void *)&cmd_flow_director_port_id,
11076 (void *)&cmd_flow_director_mode,
11077 (void *)&cmd_flow_director_mode_mac_vlan,
11078 (void *)&cmd_flow_director_ops,
11079 (void *)&cmd_flow_director_mac,
11080 (void *)&cmd_flow_director_mac_addr,
11081 (void *)&cmd_flow_director_vlan,
11082 (void *)&cmd_flow_director_vlan_value,
11083 (void *)&cmd_flow_director_flexbytes,
11084 (void *)&cmd_flow_director_flexbytes_value,
11085 (void *)&cmd_flow_director_drop,
11086 (void *)&cmd_flow_director_queue,
11087 (void *)&cmd_flow_director_queue_id,
11088 (void *)&cmd_flow_director_fd_id,
11089 (void *)&cmd_flow_director_fd_id_value,
11094 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11095 .f = cmd_flow_director_filter_parsed,
11097 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11098 "director entry on NIC",
11100 (void *)&cmd_flow_director_filter,
11101 (void *)&cmd_flow_director_port_id,
11102 (void *)&cmd_flow_director_mode,
11103 (void *)&cmd_flow_director_mode_tunnel,
11104 (void *)&cmd_flow_director_ops,
11105 (void *)&cmd_flow_director_mac,
11106 (void *)&cmd_flow_director_mac_addr,
11107 (void *)&cmd_flow_director_vlan,
11108 (void *)&cmd_flow_director_vlan_value,
11109 (void *)&cmd_flow_director_tunnel,
11110 (void *)&cmd_flow_director_tunnel_type,
11111 (void *)&cmd_flow_director_tunnel_id,
11112 (void *)&cmd_flow_director_tunnel_id_value,
11113 (void *)&cmd_flow_director_flexbytes,
11114 (void *)&cmd_flow_director_flexbytes_value,
11115 (void *)&cmd_flow_director_drop,
11116 (void *)&cmd_flow_director_queue,
11117 (void *)&cmd_flow_director_queue_id,
11118 (void *)&cmd_flow_director_fd_id,
11119 (void *)&cmd_flow_director_fd_id_value,
11124 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11125 .f = cmd_flow_director_filter_parsed,
11127 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11128 "director entry on NIC",
11130 (void *)&cmd_flow_director_filter,
11131 (void *)&cmd_flow_director_port_id,
11132 (void *)&cmd_flow_director_mode,
11133 (void *)&cmd_flow_director_mode_raw,
11134 (void *)&cmd_flow_director_ops,
11135 (void *)&cmd_flow_director_flow,
11136 (void *)&cmd_flow_director_flow_type,
11137 (void *)&cmd_flow_director_drop,
11138 (void *)&cmd_flow_director_queue,
11139 (void *)&cmd_flow_director_queue_id,
11140 (void *)&cmd_flow_director_fd_id,
11141 (void *)&cmd_flow_director_fd_id_value,
11142 (void *)&cmd_flow_director_packet,
11143 (void *)&cmd_flow_director_filepath,
11148 struct cmd_flush_flow_director_result {
11149 cmdline_fixed_string_t flush_flow_director;
11153 cmdline_parse_token_string_t cmd_flush_flow_director_flush =
11154 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result,
11155 flush_flow_director, "flush_flow_director");
11156 cmdline_parse_token_num_t cmd_flush_flow_director_port_id =
11157 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result,
11161 cmd_flush_flow_director_parsed(void *parsed_result,
11162 __attribute__((unused)) struct cmdline *cl,
11163 __attribute__((unused)) void *data)
11165 struct cmd_flow_director_result *res = parsed_result;
11168 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11170 printf("flow director is not supported on port %u.\n",
11175 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11176 RTE_ETH_FILTER_FLUSH, NULL);
11178 printf("flow director table flushing error: (%s)\n",
11182 cmdline_parse_inst_t cmd_flush_flow_director = {
11183 .f = cmd_flush_flow_director_parsed,
11185 .help_str = "flush_flow_director <port_id>: "
11186 "Flush all flow director entries of a device on NIC",
11188 (void *)&cmd_flush_flow_director_flush,
11189 (void *)&cmd_flush_flow_director_port_id,
11194 /* *** deal with flow director mask *** */
11195 struct cmd_flow_director_mask_result {
11196 cmdline_fixed_string_t flow_director_mask;
11198 cmdline_fixed_string_t mode;
11199 cmdline_fixed_string_t mode_value;
11200 cmdline_fixed_string_t vlan;
11201 uint16_t vlan_mask;
11202 cmdline_fixed_string_t src_mask;
11203 cmdline_ipaddr_t ipv4_src;
11204 cmdline_ipaddr_t ipv6_src;
11206 cmdline_fixed_string_t dst_mask;
11207 cmdline_ipaddr_t ipv4_dst;
11208 cmdline_ipaddr_t ipv6_dst;
11210 cmdline_fixed_string_t mac;
11211 uint8_t mac_addr_byte_mask;
11212 cmdline_fixed_string_t tunnel_id;
11213 uint32_t tunnel_id_mask;
11214 cmdline_fixed_string_t tunnel_type;
11215 uint8_t tunnel_type_mask;
11219 cmd_flow_director_mask_parsed(void *parsed_result,
11220 __attribute__((unused)) struct cmdline *cl,
11221 __attribute__((unused)) void *data)
11223 struct cmd_flow_director_mask_result *res = parsed_result;
11224 struct rte_eth_fdir_masks *mask;
11225 struct rte_port *port;
11227 port = &ports[res->port_id];
11228 /** Check if the port is not started **/
11229 if (port->port_status != RTE_PORT_STOPPED) {
11230 printf("Please stop port %d first\n", res->port_id);
11234 mask = &port->dev_conf.fdir_conf.mask;
11236 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
11237 if (strcmp(res->mode_value, "MAC-VLAN")) {
11238 printf("Please set mode to MAC-VLAN.\n");
11242 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11243 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
11244 if (strcmp(res->mode_value, "Tunnel")) {
11245 printf("Please set mode to Tunnel.\n");
11249 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11250 mask->mac_addr_byte_mask = res->mac_addr_byte_mask;
11251 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask);
11252 mask->tunnel_type_mask = res->tunnel_type_mask;
11254 if (strcmp(res->mode_value, "IP")) {
11255 printf("Please set mode to IP.\n");
11259 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask);
11260 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip);
11261 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip);
11262 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip);
11263 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip);
11264 mask->src_port_mask = rte_cpu_to_be_16(res->port_src);
11265 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst);
11268 cmd_reconfig_device_queue(res->port_id, 1, 1);
11271 cmdline_parse_token_string_t cmd_flow_director_mask =
11272 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11273 flow_director_mask, "flow_director_mask");
11274 cmdline_parse_token_num_t cmd_flow_director_mask_port_id =
11275 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11277 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11278 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11280 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value =
11281 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11282 vlan_mask, UINT16);
11283 cmdline_parse_token_string_t cmd_flow_director_mask_src =
11284 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11285 src_mask, "src_mask");
11286 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src =
11287 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11289 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11290 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11292 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11293 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11295 cmdline_parse_token_string_t cmd_flow_director_mask_dst =
11296 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11297 dst_mask, "dst_mask");
11298 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst =
11299 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11301 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11302 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11304 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11305 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11308 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11311 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11312 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11314 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan =
11315 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11316 mode_value, "MAC-VLAN");
11317 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel =
11318 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11319 mode_value, "Tunnel");
11320 cmdline_parse_token_string_t cmd_flow_director_mask_mac =
11321 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11323 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value =
11324 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11325 mac_addr_byte_mask, UINT8);
11326 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type =
11327 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11328 tunnel_type, "tunnel-type");
11329 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value =
11330 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11331 tunnel_type_mask, UINT8);
11332 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id =
11333 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11334 tunnel_id, "tunnel-id");
11335 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value =
11336 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11337 tunnel_id_mask, UINT32);
11339 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11340 .f = cmd_flow_director_mask_parsed,
11342 .help_str = "flow_director_mask ... : "
11343 "Set IP mode flow director's mask on NIC",
11345 (void *)&cmd_flow_director_mask,
11346 (void *)&cmd_flow_director_mask_port_id,
11347 (void *)&cmd_flow_director_mask_mode,
11348 (void *)&cmd_flow_director_mask_mode_ip,
11349 (void *)&cmd_flow_director_mask_vlan,
11350 (void *)&cmd_flow_director_mask_vlan_value,
11351 (void *)&cmd_flow_director_mask_src,
11352 (void *)&cmd_flow_director_mask_ipv4_src,
11353 (void *)&cmd_flow_director_mask_ipv6_src,
11354 (void *)&cmd_flow_director_mask_port_src,
11355 (void *)&cmd_flow_director_mask_dst,
11356 (void *)&cmd_flow_director_mask_ipv4_dst,
11357 (void *)&cmd_flow_director_mask_ipv6_dst,
11358 (void *)&cmd_flow_director_mask_port_dst,
11363 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11364 .f = cmd_flow_director_mask_parsed,
11366 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11367 "flow director's mask on NIC",
11369 (void *)&cmd_flow_director_mask,
11370 (void *)&cmd_flow_director_mask_port_id,
11371 (void *)&cmd_flow_director_mask_mode,
11372 (void *)&cmd_flow_director_mask_mode_mac_vlan,
11373 (void *)&cmd_flow_director_mask_vlan,
11374 (void *)&cmd_flow_director_mask_vlan_value,
11379 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11380 .f = cmd_flow_director_mask_parsed,
11382 .help_str = "flow_director_mask ... : Set tunnel mode "
11383 "flow director's mask on NIC",
11385 (void *)&cmd_flow_director_mask,
11386 (void *)&cmd_flow_director_mask_port_id,
11387 (void *)&cmd_flow_director_mask_mode,
11388 (void *)&cmd_flow_director_mask_mode_tunnel,
11389 (void *)&cmd_flow_director_mask_vlan,
11390 (void *)&cmd_flow_director_mask_vlan_value,
11391 (void *)&cmd_flow_director_mask_mac,
11392 (void *)&cmd_flow_director_mask_mac_value,
11393 (void *)&cmd_flow_director_mask_tunnel_type,
11394 (void *)&cmd_flow_director_mask_tunnel_type_value,
11395 (void *)&cmd_flow_director_mask_tunnel_id,
11396 (void *)&cmd_flow_director_mask_tunnel_id_value,
11401 /* *** deal with flow director mask on flexible payload *** */
11402 struct cmd_flow_director_flex_mask_result {
11403 cmdline_fixed_string_t flow_director_flexmask;
11405 cmdline_fixed_string_t flow;
11406 cmdline_fixed_string_t flow_type;
11407 cmdline_fixed_string_t mask;
11411 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11412 __attribute__((unused)) struct cmdline *cl,
11413 __attribute__((unused)) void *data)
11415 struct cmd_flow_director_flex_mask_result *res = parsed_result;
11416 struct rte_eth_fdir_info fdir_info;
11417 struct rte_eth_fdir_flex_mask flex_mask;
11418 struct rte_port *port;
11419 uint64_t flow_type_mask;
11423 port = &ports[res->port_id];
11424 /** Check if the port is not started **/
11425 if (port->port_status != RTE_PORT_STOPPED) {
11426 printf("Please stop port %d first\n", res->port_id);
11430 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11431 ret = parse_flexbytes(res->mask,
11433 RTE_ETH_FDIR_MAX_FLEXLEN);
11435 printf("error: Cannot parse mask input.\n");
11439 memset(&fdir_info, 0, sizeof(fdir_info));
11440 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11441 RTE_ETH_FILTER_INFO, &fdir_info);
11443 printf("Cannot get FDir filter info\n");
11447 if (!strcmp(res->flow_type, "none")) {
11448 /* means don't specify the flow type */
11449 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN;
11450 for (i = 0; i < RTE_ETH_FLOW_MAX; i++)
11451 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i],
11452 0, sizeof(struct rte_eth_fdir_flex_mask));
11453 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1;
11454 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0],
11456 sizeof(struct rte_eth_fdir_flex_mask));
11457 cmd_reconfig_device_queue(res->port_id, 1, 1);
11460 flow_type_mask = fdir_info.flow_types_mask[0];
11461 if (!strcmp(res->flow_type, "all")) {
11462 if (!flow_type_mask) {
11463 printf("No flow type supported\n");
11466 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) {
11467 if (flow_type_mask & (1ULL << i)) {
11468 flex_mask.flow_type = i;
11469 fdir_set_flex_mask(res->port_id, &flex_mask);
11472 cmd_reconfig_device_queue(res->port_id, 1, 1);
11475 flex_mask.flow_type = str2flowtype(res->flow_type);
11476 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) {
11477 printf("Flow type %s not supported on port %d\n",
11478 res->flow_type, res->port_id);
11481 fdir_set_flex_mask(res->port_id, &flex_mask);
11482 cmd_reconfig_device_queue(res->port_id, 1, 1);
11485 cmdline_parse_token_string_t cmd_flow_director_flexmask =
11486 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11487 flow_director_flexmask,
11488 "flow_director_flex_mask");
11489 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id =
11490 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11492 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11493 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11495 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type =
11496 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11497 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
11498 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all");
11499 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask =
11500 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11503 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11504 .f = cmd_flow_director_flex_mask_parsed,
11506 .help_str = "flow_director_flex_mask ... : "
11507 "Set flow director's flex mask on NIC",
11509 (void *)&cmd_flow_director_flexmask,
11510 (void *)&cmd_flow_director_flexmask_port_id,
11511 (void *)&cmd_flow_director_flexmask_flow,
11512 (void *)&cmd_flow_director_flexmask_flow_type,
11513 (void *)&cmd_flow_director_flexmask_mask,
11518 /* *** deal with flow director flexible payload configuration *** */
11519 struct cmd_flow_director_flexpayload_result {
11520 cmdline_fixed_string_t flow_director_flexpayload;
11522 cmdline_fixed_string_t payload_layer;
11523 cmdline_fixed_string_t payload_cfg;
11527 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11530 const char *p, *p0 = q_arg;
11532 unsigned long int_fld;
11533 char *str_fld[max_num];
11538 p = strchr(p0, '(');
11542 p0 = strchr(p, ')');
11547 if (size >= sizeof(s))
11550 snprintf(s, sizeof(s), "%.*s", size, p);
11551 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ',');
11552 if (ret < 0 || ret > max_num)
11554 for (i = 0; i < ret; i++) {
11556 int_fld = strtoul(str_fld[i], &end, 0);
11557 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11559 offsets[i] = (uint16_t)int_fld;
11565 cmd_flow_director_flxpld_parsed(void *parsed_result,
11566 __attribute__((unused)) struct cmdline *cl,
11567 __attribute__((unused)) void *data)
11569 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11570 struct rte_eth_flex_payload_cfg flex_cfg;
11571 struct rte_port *port;
11574 port = &ports[res->port_id];
11575 /** Check if the port is not started **/
11576 if (port->port_status != RTE_PORT_STOPPED) {
11577 printf("Please stop port %d first\n", res->port_id);
11581 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11583 if (!strcmp(res->payload_layer, "raw"))
11584 flex_cfg.type = RTE_ETH_RAW_PAYLOAD;
11585 else if (!strcmp(res->payload_layer, "l2"))
11586 flex_cfg.type = RTE_ETH_L2_PAYLOAD;
11587 else if (!strcmp(res->payload_layer, "l3"))
11588 flex_cfg.type = RTE_ETH_L3_PAYLOAD;
11589 else if (!strcmp(res->payload_layer, "l4"))
11590 flex_cfg.type = RTE_ETH_L4_PAYLOAD;
11592 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11593 RTE_ETH_FDIR_MAX_FLEXLEN);
11595 printf("error: Cannot parse flex payload input.\n");
11599 fdir_set_flex_payload(res->port_id, &flex_cfg);
11600 cmd_reconfig_device_queue(res->port_id, 1, 1);
11603 cmdline_parse_token_string_t cmd_flow_director_flexpayload =
11604 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11605 flow_director_flexpayload,
11606 "flow_director_flex_payload");
11607 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id =
11608 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11610 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer =
11611 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11612 payload_layer, "raw#l2#l3#l4");
11613 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg =
11614 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result,
11615 payload_cfg, NULL);
11617 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11618 .f = cmd_flow_director_flxpld_parsed,
11620 .help_str = "flow_director_flexpayload ... : "
11621 "Set flow director's flex payload on NIC",
11623 (void *)&cmd_flow_director_flexpayload,
11624 (void *)&cmd_flow_director_flexpayload_port_id,
11625 (void *)&cmd_flow_director_flexpayload_payload_layer,
11626 (void *)&cmd_flow_director_flexpayload_payload_cfg,
11631 /* Generic flow interface command. */
11632 extern cmdline_parse_inst_t cmd_flow;
11634 /* *** Classification Filters Control *** */
11635 /* *** Get symmetric hash enable per port *** */
11636 struct cmd_get_sym_hash_ena_per_port_result {
11637 cmdline_fixed_string_t get_sym_hash_ena_per_port;
11642 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11643 __rte_unused struct cmdline *cl,
11644 __rte_unused void *data)
11646 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11647 struct rte_eth_hash_filter_info info;
11650 if (rte_eth_dev_filter_supported(res->port_id,
11651 RTE_ETH_FILTER_HASH) < 0) {
11652 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11657 memset(&info, 0, sizeof(info));
11658 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11659 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11660 RTE_ETH_FILTER_GET, &info);
11663 printf("Cannot get symmetric hash enable per port "
11664 "on port %u\n", res->port_id);
11668 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11669 "enabled" : "disabled", res->port_id);
11672 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
11673 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11674 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
11675 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
11676 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
11679 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11680 .f = cmd_get_sym_hash_per_port_parsed,
11682 .help_str = "get_sym_hash_ena_per_port <port_id>",
11684 (void *)&cmd_get_sym_hash_ena_per_port_all,
11685 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11690 /* *** Set symmetric hash enable per port *** */
11691 struct cmd_set_sym_hash_ena_per_port_result {
11692 cmdline_fixed_string_t set_sym_hash_ena_per_port;
11693 cmdline_fixed_string_t enable;
11698 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11699 __rte_unused struct cmdline *cl,
11700 __rte_unused void *data)
11702 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11703 struct rte_eth_hash_filter_info info;
11706 if (rte_eth_dev_filter_supported(res->port_id,
11707 RTE_ETH_FILTER_HASH) < 0) {
11708 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
11713 memset(&info, 0, sizeof(info));
11714 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
11715 if (!strcmp(res->enable, "enable"))
11716 info.info.enable = 1;
11717 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11718 RTE_ETH_FILTER_SET, &info);
11720 printf("Cannot set symmetric hash enable per port on "
11721 "port %u\n", res->port_id);
11724 printf("Symmetric hash has been set to %s on port %u\n",
11725 res->enable, res->port_id);
11728 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
11729 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11730 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
11731 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
11732 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11734 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
11735 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
11736 enable, "enable#disable");
11738 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11739 .f = cmd_set_sym_hash_per_port_parsed,
11741 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11743 (void *)&cmd_set_sym_hash_ena_per_port_all,
11744 (void *)&cmd_set_sym_hash_ena_per_port_port_id,
11745 (void *)&cmd_set_sym_hash_ena_per_port_enable,
11750 /* Get global config of hash function */
11751 struct cmd_get_hash_global_config_result {
11752 cmdline_fixed_string_t get_hash_global_config;
11757 flowtype_to_str(uint16_t ftype)
11763 } ftype_table[] = {
11764 {"ipv4", RTE_ETH_FLOW_IPV4},
11765 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4},
11766 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP},
11767 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP},
11768 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP},
11769 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER},
11770 {"ipv6", RTE_ETH_FLOW_IPV6},
11771 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6},
11772 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP},
11773 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP},
11774 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP},
11775 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER},
11776 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD},
11777 {"port", RTE_ETH_FLOW_PORT},
11778 {"vxlan", RTE_ETH_FLOW_VXLAN},
11779 {"geneve", RTE_ETH_FLOW_GENEVE},
11780 {"nvgre", RTE_ETH_FLOW_NVGRE},
11783 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11784 if (ftype_table[i].ftype == ftype)
11785 return ftype_table[i].str;
11792 cmd_get_hash_global_config_parsed(void *parsed_result,
11793 __rte_unused struct cmdline *cl,
11794 __rte_unused void *data)
11796 struct cmd_get_hash_global_config_result *res = parsed_result;
11797 struct rte_eth_hash_filter_info info;
11798 uint32_t idx, offset;
11803 if (rte_eth_dev_filter_supported(res->port_id,
11804 RTE_ETH_FILTER_HASH) < 0) {
11805 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11810 memset(&info, 0, sizeof(info));
11811 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11812 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11813 RTE_ETH_FILTER_GET, &info);
11815 printf("Cannot get hash global configurations by port %d\n",
11820 switch (info.info.global_conf.hash_func) {
11821 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11822 printf("Hash function is Toeplitz\n");
11824 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11825 printf("Hash function is Simple XOR\n");
11828 printf("Unknown hash function\n");
11832 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) {
11833 idx = i / UINT64_BIT;
11834 offset = i % UINT64_BIT;
11835 if (!(info.info.global_conf.valid_bit_mask[idx] &
11838 str = flowtype_to_str(i);
11841 printf("Symmetric hash is %s globally for flow type %s "
11843 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11844 (1ULL << offset)) ? "enabled" : "disabled"), str,
11849 cmdline_parse_token_string_t cmd_get_hash_global_config_all =
11850 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result,
11851 get_hash_global_config, "get_hash_global_config");
11852 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id =
11853 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result,
11856 cmdline_parse_inst_t cmd_get_hash_global_config = {
11857 .f = cmd_get_hash_global_config_parsed,
11859 .help_str = "get_hash_global_config <port_id>",
11861 (void *)&cmd_get_hash_global_config_all,
11862 (void *)&cmd_get_hash_global_config_port_id,
11867 /* Set global config of hash function */
11868 struct cmd_set_hash_global_config_result {
11869 cmdline_fixed_string_t set_hash_global_config;
11871 cmdline_fixed_string_t hash_func;
11872 cmdline_fixed_string_t flow_type;
11873 cmdline_fixed_string_t enable;
11877 cmd_set_hash_global_config_parsed(void *parsed_result,
11878 __rte_unused struct cmdline *cl,
11879 __rte_unused void *data)
11881 struct cmd_set_hash_global_config_result *res = parsed_result;
11882 struct rte_eth_hash_filter_info info;
11883 uint32_t ftype, idx, offset;
11886 if (rte_eth_dev_filter_supported(res->port_id,
11887 RTE_ETH_FILTER_HASH) < 0) {
11888 printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
11892 memset(&info, 0, sizeof(info));
11893 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG;
11894 if (!strcmp(res->hash_func, "toeplitz"))
11895 info.info.global_conf.hash_func =
11896 RTE_ETH_HASH_FUNCTION_TOEPLITZ;
11897 else if (!strcmp(res->hash_func, "simple_xor"))
11898 info.info.global_conf.hash_func =
11899 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
11900 else if (!strcmp(res->hash_func, "default"))
11901 info.info.global_conf.hash_func =
11902 RTE_ETH_HASH_FUNCTION_DEFAULT;
11904 ftype = str2flowtype(res->flow_type);
11905 idx = ftype / UINT64_BIT;
11906 offset = ftype % UINT64_BIT;
11907 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset);
11908 if (!strcmp(res->enable, "enable"))
11909 info.info.global_conf.sym_hash_enable_mask[idx] |=
11911 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11912 RTE_ETH_FILTER_SET, &info);
11914 printf("Cannot set global hash configurations by port %d\n",
11917 printf("Global hash configurations have been set "
11918 "succcessfully by port %d\n", res->port_id);
11921 cmdline_parse_token_string_t cmd_set_hash_global_config_all =
11922 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11923 set_hash_global_config, "set_hash_global_config");
11924 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id =
11925 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result,
11927 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func =
11928 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11929 hash_func, "toeplitz#simple_xor#default");
11930 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type =
11931 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11933 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
11934 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
11935 cmdline_parse_token_string_t cmd_set_hash_global_config_enable =
11936 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result,
11937 enable, "enable#disable");
11939 cmdline_parse_inst_t cmd_set_hash_global_config = {
11940 .f = cmd_set_hash_global_config_parsed,
11942 .help_str = "set_hash_global_config <port_id> "
11943 "toeplitz|simple_xor|default "
11944 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
11945 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
11946 "l2_payload enable|disable",
11948 (void *)&cmd_set_hash_global_config_all,
11949 (void *)&cmd_set_hash_global_config_port_id,
11950 (void *)&cmd_set_hash_global_config_hash_func,
11951 (void *)&cmd_set_hash_global_config_flow_type,
11952 (void *)&cmd_set_hash_global_config_enable,
11957 /* Set hash input set */
11958 struct cmd_set_hash_input_set_result {
11959 cmdline_fixed_string_t set_hash_input_set;
11961 cmdline_fixed_string_t flow_type;
11962 cmdline_fixed_string_t inset_field;
11963 cmdline_fixed_string_t select;
11966 static enum rte_eth_input_set_field
11967 str2inset(char *string)
11971 static const struct {
11973 enum rte_eth_input_set_field inset;
11974 } inset_table[] = {
11975 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE},
11976 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
11977 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
11978 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
11979 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
11980 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
11981 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
11982 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL},
11983 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
11984 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
11985 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
11986 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
11987 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS},
11988 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
11989 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
11990 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
11991 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
11992 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
11993 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
11994 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
11995 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
11996 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
11997 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
11998 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
11999 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
12000 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
12001 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
12002 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
12003 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
12004 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
12005 {"none", RTE_ETH_INPUT_SET_NONE},
12008 for (i = 0; i < RTE_DIM(inset_table); i++) {
12009 if (!strcmp(string, inset_table[i].str))
12010 return inset_table[i].inset;
12013 return RTE_ETH_INPUT_SET_UNKNOWN;
12017 cmd_set_hash_input_set_parsed(void *parsed_result,
12018 __rte_unused struct cmdline *cl,
12019 __rte_unused void *data)
12021 struct cmd_set_hash_input_set_result *res = parsed_result;
12022 struct rte_eth_hash_filter_info info;
12024 memset(&info, 0, sizeof(info));
12025 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
12026 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12027 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12028 info.info.input_set_conf.inset_size = 1;
12029 if (!strcmp(res->select, "select"))
12030 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12031 else if (!strcmp(res->select, "add"))
12032 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12033 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
12034 RTE_ETH_FILTER_SET, &info);
12037 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
12038 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12039 set_hash_input_set, "set_hash_input_set");
12040 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
12041 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
12043 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12044 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12046 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12047 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12049 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12050 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#"
12051 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#"
12052 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#"
12053 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#"
12055 cmdline_parse_token_string_t cmd_set_hash_input_set_select =
12056 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12057 select, "select#add");
12059 cmdline_parse_inst_t cmd_set_hash_input_set = {
12060 .f = cmd_set_hash_input_set_parsed,
12062 .help_str = "set_hash_input_set <port_id> "
12063 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12064 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> "
12065 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|"
12066 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|"
12067 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|"
12068 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|"
12069 "fld-7th|fld-8th|none select|add",
12071 (void *)&cmd_set_hash_input_set_cmd,
12072 (void *)&cmd_set_hash_input_set_port_id,
12073 (void *)&cmd_set_hash_input_set_flow_type,
12074 (void *)&cmd_set_hash_input_set_field,
12075 (void *)&cmd_set_hash_input_set_select,
12080 /* Set flow director input set */
12081 struct cmd_set_fdir_input_set_result {
12082 cmdline_fixed_string_t set_fdir_input_set;
12084 cmdline_fixed_string_t flow_type;
12085 cmdline_fixed_string_t inset_field;
12086 cmdline_fixed_string_t select;
12090 cmd_set_fdir_input_set_parsed(void *parsed_result,
12091 __rte_unused struct cmdline *cl,
12092 __rte_unused void *data)
12094 struct cmd_set_fdir_input_set_result *res = parsed_result;
12095 struct rte_eth_fdir_filter_info info;
12097 memset(&info, 0, sizeof(info));
12098 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT;
12099 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
12100 info.info.input_set_conf.field[0] = str2inset(res->inset_field);
12101 info.info.input_set_conf.inset_size = 1;
12102 if (!strcmp(res->select, "select"))
12103 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
12104 else if (!strcmp(res->select, "add"))
12105 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
12106 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
12107 RTE_ETH_FILTER_SET, &info);
12110 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd =
12111 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12112 set_fdir_input_set, "set_fdir_input_set");
12113 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id =
12114 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result,
12116 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12117 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12119 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#"
12120 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
12121 cmdline_parse_token_string_t cmd_set_fdir_input_set_field =
12122 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12124 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#"
12125 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#"
12126 "ipv6-hop-limits#udp-src-port#udp-dst-port#"
12127 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#"
12128 "sctp-veri-tag#none");
12129 cmdline_parse_token_string_t cmd_set_fdir_input_set_select =
12130 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12131 select, "select#add");
12133 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12134 .f = cmd_set_fdir_input_set_parsed,
12136 .help_str = "set_fdir_input_set <port_id> "
12137 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
12138 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload "
12139 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
12140 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|"
12141 "ipv6-hop-limits|udp-src-port|udp-dst-port|"
12142 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|"
12143 "sctp-veri-tag|none select|add",
12145 (void *)&cmd_set_fdir_input_set_cmd,
12146 (void *)&cmd_set_fdir_input_set_port_id,
12147 (void *)&cmd_set_fdir_input_set_flow_type,
12148 (void *)&cmd_set_fdir_input_set_field,
12149 (void *)&cmd_set_fdir_input_set_select,
12154 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
12155 struct cmd_mcast_addr_result {
12156 cmdline_fixed_string_t mcast_addr_cmd;
12157 cmdline_fixed_string_t what;
12159 struct ether_addr mc_addr;
12162 static void cmd_mcast_addr_parsed(void *parsed_result,
12163 __attribute__((unused)) struct cmdline *cl,
12164 __attribute__((unused)) void *data)
12166 struct cmd_mcast_addr_result *res = parsed_result;
12168 if (!is_multicast_ether_addr(&res->mc_addr)) {
12169 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n",
12170 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1],
12171 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3],
12172 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]);
12175 if (strcmp(res->what, "add") == 0)
12176 mcast_addr_add(res->port_num, &res->mc_addr);
12178 mcast_addr_remove(res->port_num, &res->mc_addr);
12181 cmdline_parse_token_string_t cmd_mcast_addr_cmd =
12182 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
12183 mcast_addr_cmd, "mcast_addr");
12184 cmdline_parse_token_string_t cmd_mcast_addr_what =
12185 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
12187 cmdline_parse_token_num_t cmd_mcast_addr_portnum =
12188 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16);
12189 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
12190 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
12192 cmdline_parse_inst_t cmd_mcast_addr = {
12193 .f = cmd_mcast_addr_parsed,
12195 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12196 "Add/Remove multicast MAC address on port_id",
12198 (void *)&cmd_mcast_addr_cmd,
12199 (void *)&cmd_mcast_addr_what,
12200 (void *)&cmd_mcast_addr_portnum,
12201 (void *)&cmd_mcast_addr_addr,
12206 /* l2 tunnel config
12207 * only support E-tag now.
12210 /* Ether type config */
12211 struct cmd_config_l2_tunnel_eth_type_result {
12212 cmdline_fixed_string_t port;
12213 cmdline_fixed_string_t config;
12214 cmdline_fixed_string_t all;
12216 cmdline_fixed_string_t l2_tunnel;
12217 cmdline_fixed_string_t l2_tunnel_type;
12218 cmdline_fixed_string_t eth_type;
12219 uint16_t eth_type_val;
12222 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
12223 TOKEN_STRING_INITIALIZER
12224 (struct cmd_config_l2_tunnel_eth_type_result,
12226 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
12227 TOKEN_STRING_INITIALIZER
12228 (struct cmd_config_l2_tunnel_eth_type_result,
12230 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
12231 TOKEN_STRING_INITIALIZER
12232 (struct cmd_config_l2_tunnel_eth_type_result,
12234 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
12235 TOKEN_NUM_INITIALIZER
12236 (struct cmd_config_l2_tunnel_eth_type_result,
12238 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
12239 TOKEN_STRING_INITIALIZER
12240 (struct cmd_config_l2_tunnel_eth_type_result,
12241 l2_tunnel, "l2-tunnel");
12242 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
12243 TOKEN_STRING_INITIALIZER
12244 (struct cmd_config_l2_tunnel_eth_type_result,
12245 l2_tunnel_type, "E-tag");
12246 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
12247 TOKEN_STRING_INITIALIZER
12248 (struct cmd_config_l2_tunnel_eth_type_result,
12249 eth_type, "ether-type");
12250 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
12251 TOKEN_NUM_INITIALIZER
12252 (struct cmd_config_l2_tunnel_eth_type_result,
12253 eth_type_val, UINT16);
12255 static enum rte_eth_tunnel_type
12256 str2fdir_l2_tunnel_type(char *string)
12260 static const struct {
12262 enum rte_eth_tunnel_type type;
12263 } l2_tunnel_type_str[] = {
12264 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12267 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
12268 if (!strcmp(l2_tunnel_type_str[i].str, string))
12269 return l2_tunnel_type_str[i].type;
12271 return RTE_TUNNEL_TYPE_NONE;
12274 /* ether type config for all ports */
12276 cmd_config_l2_tunnel_eth_type_all_parsed
12277 (void *parsed_result,
12278 __attribute__((unused)) struct cmdline *cl,
12279 __attribute__((unused)) void *data)
12281 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12282 struct rte_eth_l2_tunnel_conf entry;
12285 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12286 entry.ether_type = res->eth_type_val;
12288 RTE_ETH_FOREACH_DEV(pid) {
12289 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12293 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12294 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12296 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12298 (void *)&cmd_config_l2_tunnel_eth_type_port,
12299 (void *)&cmd_config_l2_tunnel_eth_type_config,
12300 (void *)&cmd_config_l2_tunnel_eth_type_all_str,
12301 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12302 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12303 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12304 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12309 /* ether type config for a specific port */
12311 cmd_config_l2_tunnel_eth_type_specific_parsed(
12312 void *parsed_result,
12313 __attribute__((unused)) struct cmdline *cl,
12314 __attribute__((unused)) void *data)
12316 struct cmd_config_l2_tunnel_eth_type_result *res =
12318 struct rte_eth_l2_tunnel_conf entry;
12320 if (port_id_is_invalid(res->id, ENABLED_WARN))
12323 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12324 entry.ether_type = res->eth_type_val;
12326 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12329 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12330 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12332 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12334 (void *)&cmd_config_l2_tunnel_eth_type_port,
12335 (void *)&cmd_config_l2_tunnel_eth_type_config,
12336 (void *)&cmd_config_l2_tunnel_eth_type_id,
12337 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
12338 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
12339 (void *)&cmd_config_l2_tunnel_eth_type_eth_type,
12340 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
12345 /* Enable/disable l2 tunnel */
12346 struct cmd_config_l2_tunnel_en_dis_result {
12347 cmdline_fixed_string_t port;
12348 cmdline_fixed_string_t config;
12349 cmdline_fixed_string_t all;
12351 cmdline_fixed_string_t l2_tunnel;
12352 cmdline_fixed_string_t l2_tunnel_type;
12353 cmdline_fixed_string_t en_dis;
12356 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
12357 TOKEN_STRING_INITIALIZER
12358 (struct cmd_config_l2_tunnel_en_dis_result,
12360 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
12361 TOKEN_STRING_INITIALIZER
12362 (struct cmd_config_l2_tunnel_en_dis_result,
12364 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
12365 TOKEN_STRING_INITIALIZER
12366 (struct cmd_config_l2_tunnel_en_dis_result,
12368 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
12369 TOKEN_NUM_INITIALIZER
12370 (struct cmd_config_l2_tunnel_en_dis_result,
12372 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
12373 TOKEN_STRING_INITIALIZER
12374 (struct cmd_config_l2_tunnel_en_dis_result,
12375 l2_tunnel, "l2-tunnel");
12376 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
12377 TOKEN_STRING_INITIALIZER
12378 (struct cmd_config_l2_tunnel_en_dis_result,
12379 l2_tunnel_type, "E-tag");
12380 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
12381 TOKEN_STRING_INITIALIZER
12382 (struct cmd_config_l2_tunnel_en_dis_result,
12383 en_dis, "enable#disable");
12385 /* enable/disable l2 tunnel for all ports */
12387 cmd_config_l2_tunnel_en_dis_all_parsed(
12388 void *parsed_result,
12389 __attribute__((unused)) struct cmdline *cl,
12390 __attribute__((unused)) void *data)
12392 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12393 struct rte_eth_l2_tunnel_conf entry;
12397 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12399 if (!strcmp("enable", res->en_dis))
12404 RTE_ETH_FOREACH_DEV(pid) {
12405 rte_eth_dev_l2_tunnel_offload_set(pid,
12407 ETH_L2_TUNNEL_ENABLE_MASK,
12412 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12413 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12415 .help_str = "port config all l2-tunnel E-tag enable|disable",
12417 (void *)&cmd_config_l2_tunnel_en_dis_port,
12418 (void *)&cmd_config_l2_tunnel_en_dis_config,
12419 (void *)&cmd_config_l2_tunnel_en_dis_all_str,
12420 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12421 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12422 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12427 /* enable/disable l2 tunnel for a port */
12429 cmd_config_l2_tunnel_en_dis_specific_parsed(
12430 void *parsed_result,
12431 __attribute__((unused)) struct cmdline *cl,
12432 __attribute__((unused)) void *data)
12434 struct cmd_config_l2_tunnel_en_dis_result *res =
12436 struct rte_eth_l2_tunnel_conf entry;
12438 if (port_id_is_invalid(res->id, ENABLED_WARN))
12441 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12443 if (!strcmp("enable", res->en_dis))
12444 rte_eth_dev_l2_tunnel_offload_set(res->id,
12446 ETH_L2_TUNNEL_ENABLE_MASK,
12449 rte_eth_dev_l2_tunnel_offload_set(res->id,
12451 ETH_L2_TUNNEL_ENABLE_MASK,
12455 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12456 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12458 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12460 (void *)&cmd_config_l2_tunnel_en_dis_port,
12461 (void *)&cmd_config_l2_tunnel_en_dis_config,
12462 (void *)&cmd_config_l2_tunnel_en_dis_id,
12463 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
12464 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
12465 (void *)&cmd_config_l2_tunnel_en_dis_en_dis,
12470 /* E-tag configuration */
12472 /* Common result structure for all E-tag configuration */
12473 struct cmd_config_e_tag_result {
12474 cmdline_fixed_string_t e_tag;
12475 cmdline_fixed_string_t set;
12476 cmdline_fixed_string_t insertion;
12477 cmdline_fixed_string_t stripping;
12478 cmdline_fixed_string_t forwarding;
12479 cmdline_fixed_string_t filter;
12480 cmdline_fixed_string_t add;
12481 cmdline_fixed_string_t del;
12482 cmdline_fixed_string_t on;
12483 cmdline_fixed_string_t off;
12484 cmdline_fixed_string_t on_off;
12485 cmdline_fixed_string_t port_tag_id;
12486 uint32_t port_tag_id_val;
12487 cmdline_fixed_string_t e_tag_id;
12488 uint16_t e_tag_id_val;
12489 cmdline_fixed_string_t dst_pool;
12490 uint8_t dst_pool_val;
12491 cmdline_fixed_string_t port;
12493 cmdline_fixed_string_t vf;
12497 /* Common CLI fields for all E-tag configuration */
12498 cmdline_parse_token_string_t cmd_config_e_tag_e_tag =
12499 TOKEN_STRING_INITIALIZER
12500 (struct cmd_config_e_tag_result,
12502 cmdline_parse_token_string_t cmd_config_e_tag_set =
12503 TOKEN_STRING_INITIALIZER
12504 (struct cmd_config_e_tag_result,
12506 cmdline_parse_token_string_t cmd_config_e_tag_insertion =
12507 TOKEN_STRING_INITIALIZER
12508 (struct cmd_config_e_tag_result,
12509 insertion, "insertion");
12510 cmdline_parse_token_string_t cmd_config_e_tag_stripping =
12511 TOKEN_STRING_INITIALIZER
12512 (struct cmd_config_e_tag_result,
12513 stripping, "stripping");
12514 cmdline_parse_token_string_t cmd_config_e_tag_forwarding =
12515 TOKEN_STRING_INITIALIZER
12516 (struct cmd_config_e_tag_result,
12517 forwarding, "forwarding");
12518 cmdline_parse_token_string_t cmd_config_e_tag_filter =
12519 TOKEN_STRING_INITIALIZER
12520 (struct cmd_config_e_tag_result,
12522 cmdline_parse_token_string_t cmd_config_e_tag_add =
12523 TOKEN_STRING_INITIALIZER
12524 (struct cmd_config_e_tag_result,
12526 cmdline_parse_token_string_t cmd_config_e_tag_del =
12527 TOKEN_STRING_INITIALIZER
12528 (struct cmd_config_e_tag_result,
12530 cmdline_parse_token_string_t cmd_config_e_tag_on =
12531 TOKEN_STRING_INITIALIZER
12532 (struct cmd_config_e_tag_result,
12534 cmdline_parse_token_string_t cmd_config_e_tag_off =
12535 TOKEN_STRING_INITIALIZER
12536 (struct cmd_config_e_tag_result,
12538 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12539 TOKEN_STRING_INITIALIZER
12540 (struct cmd_config_e_tag_result,
12542 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id =
12543 TOKEN_STRING_INITIALIZER
12544 (struct cmd_config_e_tag_result,
12545 port_tag_id, "port-tag-id");
12546 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val =
12547 TOKEN_NUM_INITIALIZER
12548 (struct cmd_config_e_tag_result,
12549 port_tag_id_val, UINT32);
12550 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id =
12551 TOKEN_STRING_INITIALIZER
12552 (struct cmd_config_e_tag_result,
12553 e_tag_id, "e-tag-id");
12554 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val =
12555 TOKEN_NUM_INITIALIZER
12556 (struct cmd_config_e_tag_result,
12557 e_tag_id_val, UINT16);
12558 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool =
12559 TOKEN_STRING_INITIALIZER
12560 (struct cmd_config_e_tag_result,
12561 dst_pool, "dst-pool");
12562 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val =
12563 TOKEN_NUM_INITIALIZER
12564 (struct cmd_config_e_tag_result,
12565 dst_pool_val, UINT8);
12566 cmdline_parse_token_string_t cmd_config_e_tag_port =
12567 TOKEN_STRING_INITIALIZER
12568 (struct cmd_config_e_tag_result,
12570 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12571 TOKEN_NUM_INITIALIZER
12572 (struct cmd_config_e_tag_result,
12574 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12575 TOKEN_STRING_INITIALIZER
12576 (struct cmd_config_e_tag_result,
12578 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12579 TOKEN_NUM_INITIALIZER
12580 (struct cmd_config_e_tag_result,
12583 /* E-tag insertion configuration */
12585 cmd_config_e_tag_insertion_en_parsed(
12586 void *parsed_result,
12587 __attribute__((unused)) struct cmdline *cl,
12588 __attribute__((unused)) void *data)
12590 struct cmd_config_e_tag_result *res =
12592 struct rte_eth_l2_tunnel_conf entry;
12594 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12597 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12598 entry.tunnel_id = res->port_tag_id_val;
12599 entry.vf_id = res->vf_id;
12600 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12602 ETH_L2_TUNNEL_INSERTION_MASK,
12607 cmd_config_e_tag_insertion_dis_parsed(
12608 void *parsed_result,
12609 __attribute__((unused)) struct cmdline *cl,
12610 __attribute__((unused)) void *data)
12612 struct cmd_config_e_tag_result *res =
12614 struct rte_eth_l2_tunnel_conf entry;
12616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12619 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12620 entry.vf_id = res->vf_id;
12622 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12624 ETH_L2_TUNNEL_INSERTION_MASK,
12628 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12629 .f = cmd_config_e_tag_insertion_en_parsed,
12631 .help_str = "E-tag ... : E-tag insertion enable",
12633 (void *)&cmd_config_e_tag_e_tag,
12634 (void *)&cmd_config_e_tag_set,
12635 (void *)&cmd_config_e_tag_insertion,
12636 (void *)&cmd_config_e_tag_on,
12637 (void *)&cmd_config_e_tag_port_tag_id,
12638 (void *)&cmd_config_e_tag_port_tag_id_val,
12639 (void *)&cmd_config_e_tag_port,
12640 (void *)&cmd_config_e_tag_port_id,
12641 (void *)&cmd_config_e_tag_vf,
12642 (void *)&cmd_config_e_tag_vf_id,
12647 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12648 .f = cmd_config_e_tag_insertion_dis_parsed,
12650 .help_str = "E-tag ... : E-tag insertion disable",
12652 (void *)&cmd_config_e_tag_e_tag,
12653 (void *)&cmd_config_e_tag_set,
12654 (void *)&cmd_config_e_tag_insertion,
12655 (void *)&cmd_config_e_tag_off,
12656 (void *)&cmd_config_e_tag_port,
12657 (void *)&cmd_config_e_tag_port_id,
12658 (void *)&cmd_config_e_tag_vf,
12659 (void *)&cmd_config_e_tag_vf_id,
12664 /* E-tag stripping configuration */
12666 cmd_config_e_tag_stripping_parsed(
12667 void *parsed_result,
12668 __attribute__((unused)) struct cmdline *cl,
12669 __attribute__((unused)) void *data)
12671 struct cmd_config_e_tag_result *res =
12673 struct rte_eth_l2_tunnel_conf entry;
12675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12678 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12680 if (!strcmp(res->on_off, "on"))
12681 rte_eth_dev_l2_tunnel_offload_set
12684 ETH_L2_TUNNEL_STRIPPING_MASK,
12687 rte_eth_dev_l2_tunnel_offload_set
12690 ETH_L2_TUNNEL_STRIPPING_MASK,
12694 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12695 .f = cmd_config_e_tag_stripping_parsed,
12697 .help_str = "E-tag ... : E-tag stripping enable/disable",
12699 (void *)&cmd_config_e_tag_e_tag,
12700 (void *)&cmd_config_e_tag_set,
12701 (void *)&cmd_config_e_tag_stripping,
12702 (void *)&cmd_config_e_tag_on_off,
12703 (void *)&cmd_config_e_tag_port,
12704 (void *)&cmd_config_e_tag_port_id,
12709 /* E-tag forwarding configuration */
12711 cmd_config_e_tag_forwarding_parsed(
12712 void *parsed_result,
12713 __attribute__((unused)) struct cmdline *cl,
12714 __attribute__((unused)) void *data)
12716 struct cmd_config_e_tag_result *res = parsed_result;
12717 struct rte_eth_l2_tunnel_conf entry;
12719 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12722 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12724 if (!strcmp(res->on_off, "on"))
12725 rte_eth_dev_l2_tunnel_offload_set
12728 ETH_L2_TUNNEL_FORWARDING_MASK,
12731 rte_eth_dev_l2_tunnel_offload_set
12734 ETH_L2_TUNNEL_FORWARDING_MASK,
12738 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12739 .f = cmd_config_e_tag_forwarding_parsed,
12741 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12743 (void *)&cmd_config_e_tag_e_tag,
12744 (void *)&cmd_config_e_tag_set,
12745 (void *)&cmd_config_e_tag_forwarding,
12746 (void *)&cmd_config_e_tag_on_off,
12747 (void *)&cmd_config_e_tag_port,
12748 (void *)&cmd_config_e_tag_port_id,
12753 /* E-tag filter configuration */
12755 cmd_config_e_tag_filter_add_parsed(
12756 void *parsed_result,
12757 __attribute__((unused)) struct cmdline *cl,
12758 __attribute__((unused)) void *data)
12760 struct cmd_config_e_tag_result *res = parsed_result;
12761 struct rte_eth_l2_tunnel_conf entry;
12764 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12767 if (res->e_tag_id_val > 0x3fff) {
12768 printf("e-tag-id must be equal or less than 0x3fff.\n");
12772 ret = rte_eth_dev_filter_supported(res->port_id,
12773 RTE_ETH_FILTER_L2_TUNNEL);
12775 printf("E-tag filter is not supported on port %u.\n",
12780 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12781 entry.tunnel_id = res->e_tag_id_val;
12782 entry.pool = res->dst_pool_val;
12784 ret = rte_eth_dev_filter_ctrl(res->port_id,
12785 RTE_ETH_FILTER_L2_TUNNEL,
12786 RTE_ETH_FILTER_ADD,
12789 printf("E-tag filter programming error: (%s)\n",
12793 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12794 .f = cmd_config_e_tag_filter_add_parsed,
12796 .help_str = "E-tag ... : E-tag filter add",
12798 (void *)&cmd_config_e_tag_e_tag,
12799 (void *)&cmd_config_e_tag_set,
12800 (void *)&cmd_config_e_tag_filter,
12801 (void *)&cmd_config_e_tag_add,
12802 (void *)&cmd_config_e_tag_e_tag_id,
12803 (void *)&cmd_config_e_tag_e_tag_id_val,
12804 (void *)&cmd_config_e_tag_dst_pool,
12805 (void *)&cmd_config_e_tag_dst_pool_val,
12806 (void *)&cmd_config_e_tag_port,
12807 (void *)&cmd_config_e_tag_port_id,
12813 cmd_config_e_tag_filter_del_parsed(
12814 void *parsed_result,
12815 __attribute__((unused)) struct cmdline *cl,
12816 __attribute__((unused)) void *data)
12818 struct cmd_config_e_tag_result *res = parsed_result;
12819 struct rte_eth_l2_tunnel_conf entry;
12822 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12825 if (res->e_tag_id_val > 0x3fff) {
12826 printf("e-tag-id must be less than 0x3fff.\n");
12830 ret = rte_eth_dev_filter_supported(res->port_id,
12831 RTE_ETH_FILTER_L2_TUNNEL);
12833 printf("E-tag filter is not supported on port %u.\n",
12838 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12839 entry.tunnel_id = res->e_tag_id_val;
12841 ret = rte_eth_dev_filter_ctrl(res->port_id,
12842 RTE_ETH_FILTER_L2_TUNNEL,
12843 RTE_ETH_FILTER_DELETE,
12846 printf("E-tag filter programming error: (%s)\n",
12850 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12851 .f = cmd_config_e_tag_filter_del_parsed,
12853 .help_str = "E-tag ... : E-tag filter delete",
12855 (void *)&cmd_config_e_tag_e_tag,
12856 (void *)&cmd_config_e_tag_set,
12857 (void *)&cmd_config_e_tag_filter,
12858 (void *)&cmd_config_e_tag_del,
12859 (void *)&cmd_config_e_tag_e_tag_id,
12860 (void *)&cmd_config_e_tag_e_tag_id_val,
12861 (void *)&cmd_config_e_tag_port,
12862 (void *)&cmd_config_e_tag_port_id,
12867 /* vf vlan anti spoof configuration */
12869 /* Common result structure for vf vlan anti spoof */
12870 struct cmd_vf_vlan_anti_spoof_result {
12871 cmdline_fixed_string_t set;
12872 cmdline_fixed_string_t vf;
12873 cmdline_fixed_string_t vlan;
12874 cmdline_fixed_string_t antispoof;
12877 cmdline_fixed_string_t on_off;
12880 /* Common CLI fields for vf vlan anti spoof enable disable */
12881 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
12882 TOKEN_STRING_INITIALIZER
12883 (struct cmd_vf_vlan_anti_spoof_result,
12885 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12886 TOKEN_STRING_INITIALIZER
12887 (struct cmd_vf_vlan_anti_spoof_result,
12889 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12890 TOKEN_STRING_INITIALIZER
12891 (struct cmd_vf_vlan_anti_spoof_result,
12893 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
12894 TOKEN_STRING_INITIALIZER
12895 (struct cmd_vf_vlan_anti_spoof_result,
12896 antispoof, "antispoof");
12897 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
12898 TOKEN_NUM_INITIALIZER
12899 (struct cmd_vf_vlan_anti_spoof_result,
12901 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
12902 TOKEN_NUM_INITIALIZER
12903 (struct cmd_vf_vlan_anti_spoof_result,
12905 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
12906 TOKEN_STRING_INITIALIZER
12907 (struct cmd_vf_vlan_anti_spoof_result,
12911 cmd_set_vf_vlan_anti_spoof_parsed(
12912 void *parsed_result,
12913 __attribute__((unused)) struct cmdline *cl,
12914 __attribute__((unused)) void *data)
12916 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12917 int ret = -ENOTSUP;
12919 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12921 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12924 #ifdef RTE_LIBRTE_IXGBE_PMD
12925 if (ret == -ENOTSUP)
12926 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
12927 res->vf_id, is_on);
12929 #ifdef RTE_LIBRTE_I40E_PMD
12930 if (ret == -ENOTSUP)
12931 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
12932 res->vf_id, is_on);
12934 #ifdef RTE_LIBRTE_BNXT_PMD
12935 if (ret == -ENOTSUP)
12936 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
12937 res->vf_id, is_on);
12944 printf("invalid vf_id %d\n", res->vf_id);
12947 printf("invalid port_id %d\n", res->port_id);
12950 printf("function not implemented\n");
12953 printf("programming error: (%s)\n", strerror(-ret));
12957 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12958 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12960 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12962 (void *)&cmd_vf_vlan_anti_spoof_set,
12963 (void *)&cmd_vf_vlan_anti_spoof_vf,
12964 (void *)&cmd_vf_vlan_anti_spoof_vlan,
12965 (void *)&cmd_vf_vlan_anti_spoof_antispoof,
12966 (void *)&cmd_vf_vlan_anti_spoof_port_id,
12967 (void *)&cmd_vf_vlan_anti_spoof_vf_id,
12968 (void *)&cmd_vf_vlan_anti_spoof_on_off,
12973 /* vf mac anti spoof configuration */
12975 /* Common result structure for vf mac anti spoof */
12976 struct cmd_vf_mac_anti_spoof_result {
12977 cmdline_fixed_string_t set;
12978 cmdline_fixed_string_t vf;
12979 cmdline_fixed_string_t mac;
12980 cmdline_fixed_string_t antispoof;
12983 cmdline_fixed_string_t on_off;
12986 /* Common CLI fields for vf mac anti spoof enable disable */
12987 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
12988 TOKEN_STRING_INITIALIZER
12989 (struct cmd_vf_mac_anti_spoof_result,
12991 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12992 TOKEN_STRING_INITIALIZER
12993 (struct cmd_vf_mac_anti_spoof_result,
12995 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12996 TOKEN_STRING_INITIALIZER
12997 (struct cmd_vf_mac_anti_spoof_result,
12999 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
13000 TOKEN_STRING_INITIALIZER
13001 (struct cmd_vf_mac_anti_spoof_result,
13002 antispoof, "antispoof");
13003 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
13004 TOKEN_NUM_INITIALIZER
13005 (struct cmd_vf_mac_anti_spoof_result,
13007 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
13008 TOKEN_NUM_INITIALIZER
13009 (struct cmd_vf_mac_anti_spoof_result,
13011 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
13012 TOKEN_STRING_INITIALIZER
13013 (struct cmd_vf_mac_anti_spoof_result,
13017 cmd_set_vf_mac_anti_spoof_parsed(
13018 void *parsed_result,
13019 __attribute__((unused)) struct cmdline *cl,
13020 __attribute__((unused)) void *data)
13022 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13023 int ret = -ENOTSUP;
13025 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13030 #ifdef RTE_LIBRTE_IXGBE_PMD
13031 if (ret == -ENOTSUP)
13032 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
13033 res->vf_id, is_on);
13035 #ifdef RTE_LIBRTE_I40E_PMD
13036 if (ret == -ENOTSUP)
13037 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
13038 res->vf_id, is_on);
13040 #ifdef RTE_LIBRTE_BNXT_PMD
13041 if (ret == -ENOTSUP)
13042 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
13043 res->vf_id, is_on);
13050 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13053 printf("invalid port_id %d\n", res->port_id);
13056 printf("function not implemented\n");
13059 printf("programming error: (%s)\n", strerror(-ret));
13063 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13064 .f = cmd_set_vf_mac_anti_spoof_parsed,
13066 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13068 (void *)&cmd_vf_mac_anti_spoof_set,
13069 (void *)&cmd_vf_mac_anti_spoof_vf,
13070 (void *)&cmd_vf_mac_anti_spoof_mac,
13071 (void *)&cmd_vf_mac_anti_spoof_antispoof,
13072 (void *)&cmd_vf_mac_anti_spoof_port_id,
13073 (void *)&cmd_vf_mac_anti_spoof_vf_id,
13074 (void *)&cmd_vf_mac_anti_spoof_on_off,
13079 /* vf vlan strip queue configuration */
13081 /* Common result structure for vf mac anti spoof */
13082 struct cmd_vf_vlan_stripq_result {
13083 cmdline_fixed_string_t set;
13084 cmdline_fixed_string_t vf;
13085 cmdline_fixed_string_t vlan;
13086 cmdline_fixed_string_t stripq;
13089 cmdline_fixed_string_t on_off;
13092 /* Common CLI fields for vf vlan strip enable disable */
13093 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
13094 TOKEN_STRING_INITIALIZER
13095 (struct cmd_vf_vlan_stripq_result,
13097 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13098 TOKEN_STRING_INITIALIZER
13099 (struct cmd_vf_vlan_stripq_result,
13101 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13102 TOKEN_STRING_INITIALIZER
13103 (struct cmd_vf_vlan_stripq_result,
13105 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13106 TOKEN_STRING_INITIALIZER
13107 (struct cmd_vf_vlan_stripq_result,
13109 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13110 TOKEN_NUM_INITIALIZER
13111 (struct cmd_vf_vlan_stripq_result,
13113 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13114 TOKEN_NUM_INITIALIZER
13115 (struct cmd_vf_vlan_stripq_result,
13117 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13118 TOKEN_STRING_INITIALIZER
13119 (struct cmd_vf_vlan_stripq_result,
13123 cmd_set_vf_vlan_stripq_parsed(
13124 void *parsed_result,
13125 __attribute__((unused)) struct cmdline *cl,
13126 __attribute__((unused)) void *data)
13128 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13129 int ret = -ENOTSUP;
13131 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13133 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13136 #ifdef RTE_LIBRTE_IXGBE_PMD
13137 if (ret == -ENOTSUP)
13138 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
13139 res->vf_id, is_on);
13141 #ifdef RTE_LIBRTE_I40E_PMD
13142 if (ret == -ENOTSUP)
13143 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
13144 res->vf_id, is_on);
13146 #ifdef RTE_LIBRTE_BNXT_PMD
13147 if (ret == -ENOTSUP)
13148 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
13149 res->vf_id, is_on);
13156 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13159 printf("invalid port_id %d\n", res->port_id);
13162 printf("function not implemented\n");
13165 printf("programming error: (%s)\n", strerror(-ret));
13169 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13170 .f = cmd_set_vf_vlan_stripq_parsed,
13172 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13174 (void *)&cmd_vf_vlan_stripq_set,
13175 (void *)&cmd_vf_vlan_stripq_vf,
13176 (void *)&cmd_vf_vlan_stripq_vlan,
13177 (void *)&cmd_vf_vlan_stripq_stripq,
13178 (void *)&cmd_vf_vlan_stripq_port_id,
13179 (void *)&cmd_vf_vlan_stripq_vf_id,
13180 (void *)&cmd_vf_vlan_stripq_on_off,
13185 /* vf vlan insert configuration */
13187 /* Common result structure for vf vlan insert */
13188 struct cmd_vf_vlan_insert_result {
13189 cmdline_fixed_string_t set;
13190 cmdline_fixed_string_t vf;
13191 cmdline_fixed_string_t vlan;
13192 cmdline_fixed_string_t insert;
13198 /* Common CLI fields for vf vlan insert enable disable */
13199 cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
13200 TOKEN_STRING_INITIALIZER
13201 (struct cmd_vf_vlan_insert_result,
13203 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13204 TOKEN_STRING_INITIALIZER
13205 (struct cmd_vf_vlan_insert_result,
13207 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13208 TOKEN_STRING_INITIALIZER
13209 (struct cmd_vf_vlan_insert_result,
13211 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13212 TOKEN_STRING_INITIALIZER
13213 (struct cmd_vf_vlan_insert_result,
13215 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13216 TOKEN_NUM_INITIALIZER
13217 (struct cmd_vf_vlan_insert_result,
13219 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13220 TOKEN_NUM_INITIALIZER
13221 (struct cmd_vf_vlan_insert_result,
13223 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13224 TOKEN_NUM_INITIALIZER
13225 (struct cmd_vf_vlan_insert_result,
13229 cmd_set_vf_vlan_insert_parsed(
13230 void *parsed_result,
13231 __attribute__((unused)) struct cmdline *cl,
13232 __attribute__((unused)) void *data)
13234 struct cmd_vf_vlan_insert_result *res = parsed_result;
13235 int ret = -ENOTSUP;
13237 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13240 #ifdef RTE_LIBRTE_IXGBE_PMD
13241 if (ret == -ENOTSUP)
13242 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
13245 #ifdef RTE_LIBRTE_I40E_PMD
13246 if (ret == -ENOTSUP)
13247 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
13250 #ifdef RTE_LIBRTE_BNXT_PMD
13251 if (ret == -ENOTSUP)
13252 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
13260 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13263 printf("invalid port_id %d\n", res->port_id);
13266 printf("function not implemented\n");
13269 printf("programming error: (%s)\n", strerror(-ret));
13273 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13274 .f = cmd_set_vf_vlan_insert_parsed,
13276 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13278 (void *)&cmd_vf_vlan_insert_set,
13279 (void *)&cmd_vf_vlan_insert_vf,
13280 (void *)&cmd_vf_vlan_insert_vlan,
13281 (void *)&cmd_vf_vlan_insert_insert,
13282 (void *)&cmd_vf_vlan_insert_port_id,
13283 (void *)&cmd_vf_vlan_insert_vf_id,
13284 (void *)&cmd_vf_vlan_insert_vlan_id,
13289 /* tx loopback configuration */
13291 /* Common result structure for tx loopback */
13292 struct cmd_tx_loopback_result {
13293 cmdline_fixed_string_t set;
13294 cmdline_fixed_string_t tx;
13295 cmdline_fixed_string_t loopback;
13297 cmdline_fixed_string_t on_off;
13300 /* Common CLI fields for tx loopback enable disable */
13301 cmdline_parse_token_string_t cmd_tx_loopback_set =
13302 TOKEN_STRING_INITIALIZER
13303 (struct cmd_tx_loopback_result,
13305 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13306 TOKEN_STRING_INITIALIZER
13307 (struct cmd_tx_loopback_result,
13309 cmdline_parse_token_string_t cmd_tx_loopback_loopback =
13310 TOKEN_STRING_INITIALIZER
13311 (struct cmd_tx_loopback_result,
13312 loopback, "loopback");
13313 cmdline_parse_token_num_t cmd_tx_loopback_port_id =
13314 TOKEN_NUM_INITIALIZER
13315 (struct cmd_tx_loopback_result,
13317 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13318 TOKEN_STRING_INITIALIZER
13319 (struct cmd_tx_loopback_result,
13323 cmd_set_tx_loopback_parsed(
13324 void *parsed_result,
13325 __attribute__((unused)) struct cmdline *cl,
13326 __attribute__((unused)) void *data)
13328 struct cmd_tx_loopback_result *res = parsed_result;
13329 int ret = -ENOTSUP;
13331 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13333 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13336 #ifdef RTE_LIBRTE_IXGBE_PMD
13337 if (ret == -ENOTSUP)
13338 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13340 #ifdef RTE_LIBRTE_I40E_PMD
13341 if (ret == -ENOTSUP)
13342 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13344 #ifdef RTE_LIBRTE_BNXT_PMD
13345 if (ret == -ENOTSUP)
13346 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13348 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
13349 if (ret == -ENOTSUP)
13350 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
13357 printf("invalid is_on %d\n", is_on);
13360 printf("invalid port_id %d\n", res->port_id);
13363 printf("function not implemented\n");
13366 printf("programming error: (%s)\n", strerror(-ret));
13370 cmdline_parse_inst_t cmd_set_tx_loopback = {
13371 .f = cmd_set_tx_loopback_parsed,
13373 .help_str = "set tx loopback <port_id> on|off",
13375 (void *)&cmd_tx_loopback_set,
13376 (void *)&cmd_tx_loopback_tx,
13377 (void *)&cmd_tx_loopback_loopback,
13378 (void *)&cmd_tx_loopback_port_id,
13379 (void *)&cmd_tx_loopback_on_off,
13384 /* all queues drop enable configuration */
13386 /* Common result structure for all queues drop enable */
13387 struct cmd_all_queues_drop_en_result {
13388 cmdline_fixed_string_t set;
13389 cmdline_fixed_string_t all;
13390 cmdline_fixed_string_t queues;
13391 cmdline_fixed_string_t drop;
13393 cmdline_fixed_string_t on_off;
13396 /* Common CLI fields for tx loopback enable disable */
13397 cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
13398 TOKEN_STRING_INITIALIZER
13399 (struct cmd_all_queues_drop_en_result,
13401 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13402 TOKEN_STRING_INITIALIZER
13403 (struct cmd_all_queues_drop_en_result,
13405 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13406 TOKEN_STRING_INITIALIZER
13407 (struct cmd_all_queues_drop_en_result,
13409 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13410 TOKEN_STRING_INITIALIZER
13411 (struct cmd_all_queues_drop_en_result,
13413 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
13414 TOKEN_NUM_INITIALIZER
13415 (struct cmd_all_queues_drop_en_result,
13417 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
13418 TOKEN_STRING_INITIALIZER
13419 (struct cmd_all_queues_drop_en_result,
13423 cmd_set_all_queues_drop_en_parsed(
13424 void *parsed_result,
13425 __attribute__((unused)) struct cmdline *cl,
13426 __attribute__((unused)) void *data)
13428 struct cmd_all_queues_drop_en_result *res = parsed_result;
13429 int ret = -ENOTSUP;
13430 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13432 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13435 #ifdef RTE_LIBRTE_IXGBE_PMD
13436 if (ret == -ENOTSUP)
13437 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
13439 #ifdef RTE_LIBRTE_BNXT_PMD
13440 if (ret == -ENOTSUP)
13441 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
13447 printf("invalid is_on %d\n", is_on);
13450 printf("invalid port_id %d\n", res->port_id);
13453 printf("function not implemented\n");
13456 printf("programming error: (%s)\n", strerror(-ret));
13460 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13461 .f = cmd_set_all_queues_drop_en_parsed,
13463 .help_str = "set all queues drop <port_id> on|off",
13465 (void *)&cmd_all_queues_drop_en_set,
13466 (void *)&cmd_all_queues_drop_en_all,
13467 (void *)&cmd_all_queues_drop_en_queues,
13468 (void *)&cmd_all_queues_drop_en_drop,
13469 (void *)&cmd_all_queues_drop_en_port_id,
13470 (void *)&cmd_all_queues_drop_en_on_off,
13475 /* vf split drop enable configuration */
13477 /* Common result structure for vf split drop enable */
13478 struct cmd_vf_split_drop_en_result {
13479 cmdline_fixed_string_t set;
13480 cmdline_fixed_string_t vf;
13481 cmdline_fixed_string_t split;
13482 cmdline_fixed_string_t drop;
13485 cmdline_fixed_string_t on_off;
13488 /* Common CLI fields for vf split drop enable disable */
13489 cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
13490 TOKEN_STRING_INITIALIZER
13491 (struct cmd_vf_split_drop_en_result,
13493 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13494 TOKEN_STRING_INITIALIZER
13495 (struct cmd_vf_split_drop_en_result,
13497 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13498 TOKEN_STRING_INITIALIZER
13499 (struct cmd_vf_split_drop_en_result,
13501 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13502 TOKEN_STRING_INITIALIZER
13503 (struct cmd_vf_split_drop_en_result,
13505 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
13506 TOKEN_NUM_INITIALIZER
13507 (struct cmd_vf_split_drop_en_result,
13509 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
13510 TOKEN_NUM_INITIALIZER
13511 (struct cmd_vf_split_drop_en_result,
13513 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
13514 TOKEN_STRING_INITIALIZER
13515 (struct cmd_vf_split_drop_en_result,
13519 cmd_set_vf_split_drop_en_parsed(
13520 void *parsed_result,
13521 __attribute__((unused)) struct cmdline *cl,
13522 __attribute__((unused)) void *data)
13524 struct cmd_vf_split_drop_en_result *res = parsed_result;
13525 int ret = -ENOTSUP;
13526 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13528 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13531 #ifdef RTE_LIBRTE_IXGBE_PMD
13532 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13539 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13542 printf("invalid port_id %d\n", res->port_id);
13545 printf("not supported on port %d\n", res->port_id);
13548 printf("programming error: (%s)\n", strerror(-ret));
13552 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13553 .f = cmd_set_vf_split_drop_en_parsed,
13555 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13557 (void *)&cmd_vf_split_drop_en_set,
13558 (void *)&cmd_vf_split_drop_en_vf,
13559 (void *)&cmd_vf_split_drop_en_split,
13560 (void *)&cmd_vf_split_drop_en_drop,
13561 (void *)&cmd_vf_split_drop_en_port_id,
13562 (void *)&cmd_vf_split_drop_en_vf_id,
13563 (void *)&cmd_vf_split_drop_en_on_off,
13568 /* vf mac address configuration */
13570 /* Common result structure for vf mac address */
13571 struct cmd_set_vf_mac_addr_result {
13572 cmdline_fixed_string_t set;
13573 cmdline_fixed_string_t vf;
13574 cmdline_fixed_string_t mac;
13575 cmdline_fixed_string_t addr;
13578 struct ether_addr mac_addr;
13582 /* Common CLI fields for vf split drop enable disable */
13583 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
13584 TOKEN_STRING_INITIALIZER
13585 (struct cmd_set_vf_mac_addr_result,
13587 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13588 TOKEN_STRING_INITIALIZER
13589 (struct cmd_set_vf_mac_addr_result,
13591 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13592 TOKEN_STRING_INITIALIZER
13593 (struct cmd_set_vf_mac_addr_result,
13595 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13596 TOKEN_STRING_INITIALIZER
13597 (struct cmd_set_vf_mac_addr_result,
13599 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
13600 TOKEN_NUM_INITIALIZER
13601 (struct cmd_set_vf_mac_addr_result,
13603 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
13604 TOKEN_NUM_INITIALIZER
13605 (struct cmd_set_vf_mac_addr_result,
13607 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13608 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13612 cmd_set_vf_mac_addr_parsed(
13613 void *parsed_result,
13614 __attribute__((unused)) struct cmdline *cl,
13615 __attribute__((unused)) void *data)
13617 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13618 int ret = -ENOTSUP;
13620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13623 #ifdef RTE_LIBRTE_IXGBE_PMD
13624 if (ret == -ENOTSUP)
13625 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
13628 #ifdef RTE_LIBRTE_I40E_PMD
13629 if (ret == -ENOTSUP)
13630 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
13633 #ifdef RTE_LIBRTE_BNXT_PMD
13634 if (ret == -ENOTSUP)
13635 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
13643 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13646 printf("invalid port_id %d\n", res->port_id);
13649 printf("function not implemented\n");
13652 printf("programming error: (%s)\n", strerror(-ret));
13656 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13657 .f = cmd_set_vf_mac_addr_parsed,
13659 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13661 (void *)&cmd_set_vf_mac_addr_set,
13662 (void *)&cmd_set_vf_mac_addr_vf,
13663 (void *)&cmd_set_vf_mac_addr_mac,
13664 (void *)&cmd_set_vf_mac_addr_addr,
13665 (void *)&cmd_set_vf_mac_addr_port_id,
13666 (void *)&cmd_set_vf_mac_addr_vf_id,
13667 (void *)&cmd_set_vf_mac_addr_mac_addr,
13672 /* MACsec configuration */
13674 /* Common result structure for MACsec offload enable */
13675 struct cmd_macsec_offload_on_result {
13676 cmdline_fixed_string_t set;
13677 cmdline_fixed_string_t macsec;
13678 cmdline_fixed_string_t offload;
13680 cmdline_fixed_string_t on;
13681 cmdline_fixed_string_t encrypt;
13682 cmdline_fixed_string_t en_on_off;
13683 cmdline_fixed_string_t replay_protect;
13684 cmdline_fixed_string_t rp_on_off;
13687 /* Common CLI fields for MACsec offload disable */
13688 cmdline_parse_token_string_t cmd_macsec_offload_on_set =
13689 TOKEN_STRING_INITIALIZER
13690 (struct cmd_macsec_offload_on_result,
13692 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13693 TOKEN_STRING_INITIALIZER
13694 (struct cmd_macsec_offload_on_result,
13696 cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
13697 TOKEN_STRING_INITIALIZER
13698 (struct cmd_macsec_offload_on_result,
13699 offload, "offload");
13700 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
13701 TOKEN_NUM_INITIALIZER
13702 (struct cmd_macsec_offload_on_result,
13704 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13705 TOKEN_STRING_INITIALIZER
13706 (struct cmd_macsec_offload_on_result,
13708 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
13709 TOKEN_STRING_INITIALIZER
13710 (struct cmd_macsec_offload_on_result,
13711 encrypt, "encrypt");
13712 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
13713 TOKEN_STRING_INITIALIZER
13714 (struct cmd_macsec_offload_on_result,
13715 en_on_off, "on#off");
13716 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
13717 TOKEN_STRING_INITIALIZER
13718 (struct cmd_macsec_offload_on_result,
13719 replay_protect, "replay-protect");
13720 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
13721 TOKEN_STRING_INITIALIZER
13722 (struct cmd_macsec_offload_on_result,
13723 rp_on_off, "on#off");
13726 cmd_set_macsec_offload_on_parsed(
13727 void *parsed_result,
13728 __attribute__((unused)) struct cmdline *cl,
13729 __attribute__((unused)) void *data)
13731 struct cmd_macsec_offload_on_result *res = parsed_result;
13732 int ret = -ENOTSUP;
13733 portid_t port_id = res->port_id;
13734 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
13735 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
13736 struct rte_eth_dev_info dev_info;
13738 if (port_id_is_invalid(port_id, ENABLED_WARN))
13740 if (!port_is_stopped(port_id)) {
13741 printf("Please stop port %d first\n", port_id);
13745 rte_eth_dev_info_get(port_id, &dev_info);
13746 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13747 #ifdef RTE_LIBRTE_IXGBE_PMD
13748 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
13756 ports[port_id].dev_conf.txmode.offloads |=
13757 DEV_TX_OFFLOAD_MACSEC_INSERT;
13758 cmd_reconfig_device_queue(port_id, 1, 1);
13761 printf("invalid port_id %d\n", port_id);
13764 printf("not supported on port %d\n", port_id);
13767 printf("programming error: (%s)\n", strerror(-ret));
13771 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13772 .f = cmd_set_macsec_offload_on_parsed,
13774 .help_str = "set macsec offload <port_id> on "
13775 "encrypt on|off replay-protect on|off",
13777 (void *)&cmd_macsec_offload_on_set,
13778 (void *)&cmd_macsec_offload_on_macsec,
13779 (void *)&cmd_macsec_offload_on_offload,
13780 (void *)&cmd_macsec_offload_on_port_id,
13781 (void *)&cmd_macsec_offload_on_on,
13782 (void *)&cmd_macsec_offload_on_encrypt,
13783 (void *)&cmd_macsec_offload_on_en_on_off,
13784 (void *)&cmd_macsec_offload_on_replay_protect,
13785 (void *)&cmd_macsec_offload_on_rp_on_off,
13790 /* Common result structure for MACsec offload disable */
13791 struct cmd_macsec_offload_off_result {
13792 cmdline_fixed_string_t set;
13793 cmdline_fixed_string_t macsec;
13794 cmdline_fixed_string_t offload;
13796 cmdline_fixed_string_t off;
13799 /* Common CLI fields for MACsec offload disable */
13800 cmdline_parse_token_string_t cmd_macsec_offload_off_set =
13801 TOKEN_STRING_INITIALIZER
13802 (struct cmd_macsec_offload_off_result,
13804 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13805 TOKEN_STRING_INITIALIZER
13806 (struct cmd_macsec_offload_off_result,
13808 cmdline_parse_token_string_t cmd_macsec_offload_off_offload =
13809 TOKEN_STRING_INITIALIZER
13810 (struct cmd_macsec_offload_off_result,
13811 offload, "offload");
13812 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id =
13813 TOKEN_NUM_INITIALIZER
13814 (struct cmd_macsec_offload_off_result,
13816 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13817 TOKEN_STRING_INITIALIZER
13818 (struct cmd_macsec_offload_off_result,
13822 cmd_set_macsec_offload_off_parsed(
13823 void *parsed_result,
13824 __attribute__((unused)) struct cmdline *cl,
13825 __attribute__((unused)) void *data)
13827 struct cmd_macsec_offload_off_result *res = parsed_result;
13828 int ret = -ENOTSUP;
13829 struct rte_eth_dev_info dev_info;
13830 portid_t port_id = res->port_id;
13832 if (port_id_is_invalid(port_id, ENABLED_WARN))
13834 if (!port_is_stopped(port_id)) {
13835 printf("Please stop port %d first\n", port_id);
13839 rte_eth_dev_info_get(port_id, &dev_info);
13840 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
13841 #ifdef RTE_LIBRTE_IXGBE_PMD
13842 ret = rte_pmd_ixgbe_macsec_disable(port_id);
13847 ports[port_id].dev_conf.txmode.offloads &=
13848 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13849 cmd_reconfig_device_queue(port_id, 1, 1);
13852 printf("invalid port_id %d\n", port_id);
13855 printf("not supported on port %d\n", port_id);
13858 printf("programming error: (%s)\n", strerror(-ret));
13862 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13863 .f = cmd_set_macsec_offload_off_parsed,
13865 .help_str = "set macsec offload <port_id> off",
13867 (void *)&cmd_macsec_offload_off_set,
13868 (void *)&cmd_macsec_offload_off_macsec,
13869 (void *)&cmd_macsec_offload_off_offload,
13870 (void *)&cmd_macsec_offload_off_port_id,
13871 (void *)&cmd_macsec_offload_off_off,
13876 /* Common result structure for MACsec secure connection configure */
13877 struct cmd_macsec_sc_result {
13878 cmdline_fixed_string_t set;
13879 cmdline_fixed_string_t macsec;
13880 cmdline_fixed_string_t sc;
13881 cmdline_fixed_string_t tx_rx;
13883 struct ether_addr mac;
13887 /* Common CLI fields for MACsec secure connection configure */
13888 cmdline_parse_token_string_t cmd_macsec_sc_set =
13889 TOKEN_STRING_INITIALIZER
13890 (struct cmd_macsec_sc_result,
13892 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13893 TOKEN_STRING_INITIALIZER
13894 (struct cmd_macsec_sc_result,
13896 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13897 TOKEN_STRING_INITIALIZER
13898 (struct cmd_macsec_sc_result,
13900 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13901 TOKEN_STRING_INITIALIZER
13902 (struct cmd_macsec_sc_result,
13904 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13905 TOKEN_NUM_INITIALIZER
13906 (struct cmd_macsec_sc_result,
13908 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13909 TOKEN_ETHERADDR_INITIALIZER
13910 (struct cmd_macsec_sc_result,
13912 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13913 TOKEN_NUM_INITIALIZER
13914 (struct cmd_macsec_sc_result,
13918 cmd_set_macsec_sc_parsed(
13919 void *parsed_result,
13920 __attribute__((unused)) struct cmdline *cl,
13921 __attribute__((unused)) void *data)
13923 struct cmd_macsec_sc_result *res = parsed_result;
13924 int ret = -ENOTSUP;
13925 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
13927 #ifdef RTE_LIBRTE_IXGBE_PMD
13929 rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
13930 res->mac.addr_bytes) :
13931 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
13932 res->mac.addr_bytes, res->pi);
13934 RTE_SET_USED(is_tx);
13940 printf("invalid port_id %d\n", res->port_id);
13943 printf("not supported on port %d\n", res->port_id);
13946 printf("programming error: (%s)\n", strerror(-ret));
13950 cmdline_parse_inst_t cmd_set_macsec_sc = {
13951 .f = cmd_set_macsec_sc_parsed,
13953 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13955 (void *)&cmd_macsec_sc_set,
13956 (void *)&cmd_macsec_sc_macsec,
13957 (void *)&cmd_macsec_sc_sc,
13958 (void *)&cmd_macsec_sc_tx_rx,
13959 (void *)&cmd_macsec_sc_port_id,
13960 (void *)&cmd_macsec_sc_mac,
13961 (void *)&cmd_macsec_sc_pi,
13966 /* Common result structure for MACsec secure connection configure */
13967 struct cmd_macsec_sa_result {
13968 cmdline_fixed_string_t set;
13969 cmdline_fixed_string_t macsec;
13970 cmdline_fixed_string_t sa;
13971 cmdline_fixed_string_t tx_rx;
13976 cmdline_fixed_string_t key;
13979 /* Common CLI fields for MACsec secure connection configure */
13980 cmdline_parse_token_string_t cmd_macsec_sa_set =
13981 TOKEN_STRING_INITIALIZER
13982 (struct cmd_macsec_sa_result,
13984 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13985 TOKEN_STRING_INITIALIZER
13986 (struct cmd_macsec_sa_result,
13988 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13989 TOKEN_STRING_INITIALIZER
13990 (struct cmd_macsec_sa_result,
13992 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13993 TOKEN_STRING_INITIALIZER
13994 (struct cmd_macsec_sa_result,
13996 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13997 TOKEN_NUM_INITIALIZER
13998 (struct cmd_macsec_sa_result,
14000 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14001 TOKEN_NUM_INITIALIZER
14002 (struct cmd_macsec_sa_result,
14004 cmdline_parse_token_num_t cmd_macsec_sa_an =
14005 TOKEN_NUM_INITIALIZER
14006 (struct cmd_macsec_sa_result,
14008 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14009 TOKEN_NUM_INITIALIZER
14010 (struct cmd_macsec_sa_result,
14012 cmdline_parse_token_string_t cmd_macsec_sa_key =
14013 TOKEN_STRING_INITIALIZER
14014 (struct cmd_macsec_sa_result,
14018 cmd_set_macsec_sa_parsed(
14019 void *parsed_result,
14020 __attribute__((unused)) struct cmdline *cl,
14021 __attribute__((unused)) void *data)
14023 struct cmd_macsec_sa_result *res = parsed_result;
14024 int ret = -ENOTSUP;
14025 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
14026 uint8_t key[16] = { 0 };
14032 key_len = strlen(res->key) / 2;
14036 for (i = 0; i < key_len; i++) {
14037 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14040 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14043 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14046 #ifdef RTE_LIBRTE_IXGBE_PMD
14048 rte_pmd_ixgbe_macsec_select_txsa(res->port_id,
14049 res->idx, res->an, res->pn, key) :
14050 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id,
14051 res->idx, res->an, res->pn, key);
14053 RTE_SET_USED(is_tx);
14060 printf("invalid idx %d or an %d\n", res->idx, res->an);
14063 printf("invalid port_id %d\n", res->port_id);
14066 printf("not supported on port %d\n", res->port_id);
14069 printf("programming error: (%s)\n", strerror(-ret));
14073 cmdline_parse_inst_t cmd_set_macsec_sa = {
14074 .f = cmd_set_macsec_sa_parsed,
14076 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14078 (void *)&cmd_macsec_sa_set,
14079 (void *)&cmd_macsec_sa_macsec,
14080 (void *)&cmd_macsec_sa_sa,
14081 (void *)&cmd_macsec_sa_tx_rx,
14082 (void *)&cmd_macsec_sa_port_id,
14083 (void *)&cmd_macsec_sa_idx,
14084 (void *)&cmd_macsec_sa_an,
14085 (void *)&cmd_macsec_sa_pn,
14086 (void *)&cmd_macsec_sa_key,
14091 /* VF unicast promiscuous mode configuration */
14093 /* Common result structure for VF unicast promiscuous mode */
14094 struct cmd_vf_promisc_result {
14095 cmdline_fixed_string_t set;
14096 cmdline_fixed_string_t vf;
14097 cmdline_fixed_string_t promisc;
14100 cmdline_fixed_string_t on_off;
14103 /* Common CLI fields for VF unicast promiscuous mode enable disable */
14104 cmdline_parse_token_string_t cmd_vf_promisc_set =
14105 TOKEN_STRING_INITIALIZER
14106 (struct cmd_vf_promisc_result,
14108 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14109 TOKEN_STRING_INITIALIZER
14110 (struct cmd_vf_promisc_result,
14112 cmdline_parse_token_string_t cmd_vf_promisc_promisc =
14113 TOKEN_STRING_INITIALIZER
14114 (struct cmd_vf_promisc_result,
14115 promisc, "promisc");
14116 cmdline_parse_token_num_t cmd_vf_promisc_port_id =
14117 TOKEN_NUM_INITIALIZER
14118 (struct cmd_vf_promisc_result,
14120 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14121 TOKEN_NUM_INITIALIZER
14122 (struct cmd_vf_promisc_result,
14124 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14125 TOKEN_STRING_INITIALIZER
14126 (struct cmd_vf_promisc_result,
14130 cmd_set_vf_promisc_parsed(
14131 void *parsed_result,
14132 __attribute__((unused)) struct cmdline *cl,
14133 __attribute__((unused)) void *data)
14135 struct cmd_vf_promisc_result *res = parsed_result;
14136 int ret = -ENOTSUP;
14138 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14143 #ifdef RTE_LIBRTE_I40E_PMD
14144 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14145 res->vf_id, is_on);
14152 printf("invalid vf_id %d\n", res->vf_id);
14155 printf("invalid port_id %d\n", res->port_id);
14158 printf("function not implemented\n");
14161 printf("programming error: (%s)\n", strerror(-ret));
14165 cmdline_parse_inst_t cmd_set_vf_promisc = {
14166 .f = cmd_set_vf_promisc_parsed,
14168 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14169 "Set unicast promiscuous mode for a VF from the PF",
14171 (void *)&cmd_vf_promisc_set,
14172 (void *)&cmd_vf_promisc_vf,
14173 (void *)&cmd_vf_promisc_promisc,
14174 (void *)&cmd_vf_promisc_port_id,
14175 (void *)&cmd_vf_promisc_vf_id,
14176 (void *)&cmd_vf_promisc_on_off,
14181 /* VF multicast promiscuous mode configuration */
14183 /* Common result structure for VF multicast promiscuous mode */
14184 struct cmd_vf_allmulti_result {
14185 cmdline_fixed_string_t set;
14186 cmdline_fixed_string_t vf;
14187 cmdline_fixed_string_t allmulti;
14190 cmdline_fixed_string_t on_off;
14193 /* Common CLI fields for VF multicast promiscuous mode enable disable */
14194 cmdline_parse_token_string_t cmd_vf_allmulti_set =
14195 TOKEN_STRING_INITIALIZER
14196 (struct cmd_vf_allmulti_result,
14198 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14199 TOKEN_STRING_INITIALIZER
14200 (struct cmd_vf_allmulti_result,
14202 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti =
14203 TOKEN_STRING_INITIALIZER
14204 (struct cmd_vf_allmulti_result,
14205 allmulti, "allmulti");
14206 cmdline_parse_token_num_t cmd_vf_allmulti_port_id =
14207 TOKEN_NUM_INITIALIZER
14208 (struct cmd_vf_allmulti_result,
14210 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14211 TOKEN_NUM_INITIALIZER
14212 (struct cmd_vf_allmulti_result,
14214 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14215 TOKEN_STRING_INITIALIZER
14216 (struct cmd_vf_allmulti_result,
14220 cmd_set_vf_allmulti_parsed(
14221 void *parsed_result,
14222 __attribute__((unused)) struct cmdline *cl,
14223 __attribute__((unused)) void *data)
14225 struct cmd_vf_allmulti_result *res = parsed_result;
14226 int ret = -ENOTSUP;
14228 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14230 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14233 #ifdef RTE_LIBRTE_I40E_PMD
14234 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14235 res->vf_id, is_on);
14242 printf("invalid vf_id %d\n", res->vf_id);
14245 printf("invalid port_id %d\n", res->port_id);
14248 printf("function not implemented\n");
14251 printf("programming error: (%s)\n", strerror(-ret));
14255 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14256 .f = cmd_set_vf_allmulti_parsed,
14258 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14259 "Set multicast promiscuous mode for a VF from the PF",
14261 (void *)&cmd_vf_allmulti_set,
14262 (void *)&cmd_vf_allmulti_vf,
14263 (void *)&cmd_vf_allmulti_allmulti,
14264 (void *)&cmd_vf_allmulti_port_id,
14265 (void *)&cmd_vf_allmulti_vf_id,
14266 (void *)&cmd_vf_allmulti_on_off,
14271 /* vf broadcast mode configuration */
14273 /* Common result structure for vf broadcast */
14274 struct cmd_set_vf_broadcast_result {
14275 cmdline_fixed_string_t set;
14276 cmdline_fixed_string_t vf;
14277 cmdline_fixed_string_t broadcast;
14280 cmdline_fixed_string_t on_off;
14283 /* Common CLI fields for vf broadcast enable disable */
14284 cmdline_parse_token_string_t cmd_set_vf_broadcast_set =
14285 TOKEN_STRING_INITIALIZER
14286 (struct cmd_set_vf_broadcast_result,
14288 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14289 TOKEN_STRING_INITIALIZER
14290 (struct cmd_set_vf_broadcast_result,
14292 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast =
14293 TOKEN_STRING_INITIALIZER
14294 (struct cmd_set_vf_broadcast_result,
14295 broadcast, "broadcast");
14296 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id =
14297 TOKEN_NUM_INITIALIZER
14298 (struct cmd_set_vf_broadcast_result,
14300 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14301 TOKEN_NUM_INITIALIZER
14302 (struct cmd_set_vf_broadcast_result,
14304 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14305 TOKEN_STRING_INITIALIZER
14306 (struct cmd_set_vf_broadcast_result,
14310 cmd_set_vf_broadcast_parsed(
14311 void *parsed_result,
14312 __attribute__((unused)) struct cmdline *cl,
14313 __attribute__((unused)) void *data)
14315 struct cmd_set_vf_broadcast_result *res = parsed_result;
14316 int ret = -ENOTSUP;
14318 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14320 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14323 #ifdef RTE_LIBRTE_I40E_PMD
14324 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14325 res->vf_id, is_on);
14332 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14335 printf("invalid port_id %d\n", res->port_id);
14338 printf("function not implemented\n");
14341 printf("programming error: (%s)\n", strerror(-ret));
14345 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14346 .f = cmd_set_vf_broadcast_parsed,
14348 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14350 (void *)&cmd_set_vf_broadcast_set,
14351 (void *)&cmd_set_vf_broadcast_vf,
14352 (void *)&cmd_set_vf_broadcast_broadcast,
14353 (void *)&cmd_set_vf_broadcast_port_id,
14354 (void *)&cmd_set_vf_broadcast_vf_id,
14355 (void *)&cmd_set_vf_broadcast_on_off,
14360 /* vf vlan tag configuration */
14362 /* Common result structure for vf vlan tag */
14363 struct cmd_set_vf_vlan_tag_result {
14364 cmdline_fixed_string_t set;
14365 cmdline_fixed_string_t vf;
14366 cmdline_fixed_string_t vlan;
14367 cmdline_fixed_string_t tag;
14370 cmdline_fixed_string_t on_off;
14373 /* Common CLI fields for vf vlan tag enable disable */
14374 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set =
14375 TOKEN_STRING_INITIALIZER
14376 (struct cmd_set_vf_vlan_tag_result,
14378 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14379 TOKEN_STRING_INITIALIZER
14380 (struct cmd_set_vf_vlan_tag_result,
14382 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14383 TOKEN_STRING_INITIALIZER
14384 (struct cmd_set_vf_vlan_tag_result,
14386 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14387 TOKEN_STRING_INITIALIZER
14388 (struct cmd_set_vf_vlan_tag_result,
14390 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id =
14391 TOKEN_NUM_INITIALIZER
14392 (struct cmd_set_vf_vlan_tag_result,
14394 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id =
14395 TOKEN_NUM_INITIALIZER
14396 (struct cmd_set_vf_vlan_tag_result,
14398 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off =
14399 TOKEN_STRING_INITIALIZER
14400 (struct cmd_set_vf_vlan_tag_result,
14404 cmd_set_vf_vlan_tag_parsed(
14405 void *parsed_result,
14406 __attribute__((unused)) struct cmdline *cl,
14407 __attribute__((unused)) void *data)
14409 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14410 int ret = -ENOTSUP;
14412 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14414 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14417 #ifdef RTE_LIBRTE_I40E_PMD
14418 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14419 res->vf_id, is_on);
14426 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14429 printf("invalid port_id %d\n", res->port_id);
14432 printf("function not implemented\n");
14435 printf("programming error: (%s)\n", strerror(-ret));
14439 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14440 .f = cmd_set_vf_vlan_tag_parsed,
14442 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14444 (void *)&cmd_set_vf_vlan_tag_set,
14445 (void *)&cmd_set_vf_vlan_tag_vf,
14446 (void *)&cmd_set_vf_vlan_tag_vlan,
14447 (void *)&cmd_set_vf_vlan_tag_tag,
14448 (void *)&cmd_set_vf_vlan_tag_port_id,
14449 (void *)&cmd_set_vf_vlan_tag_vf_id,
14450 (void *)&cmd_set_vf_vlan_tag_on_off,
14455 /* Common definition of VF and TC TX bandwidth configuration */
14456 struct cmd_vf_tc_bw_result {
14457 cmdline_fixed_string_t set;
14458 cmdline_fixed_string_t vf;
14459 cmdline_fixed_string_t tc;
14460 cmdline_fixed_string_t tx;
14461 cmdline_fixed_string_t min_bw;
14462 cmdline_fixed_string_t max_bw;
14463 cmdline_fixed_string_t strict_link_prio;
14468 cmdline_fixed_string_t bw_list;
14472 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14473 TOKEN_STRING_INITIALIZER
14474 (struct cmd_vf_tc_bw_result,
14476 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14477 TOKEN_STRING_INITIALIZER
14478 (struct cmd_vf_tc_bw_result,
14480 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14481 TOKEN_STRING_INITIALIZER
14482 (struct cmd_vf_tc_bw_result,
14484 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14485 TOKEN_STRING_INITIALIZER
14486 (struct cmd_vf_tc_bw_result,
14488 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio =
14489 TOKEN_STRING_INITIALIZER
14490 (struct cmd_vf_tc_bw_result,
14491 strict_link_prio, "strict-link-priority");
14492 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw =
14493 TOKEN_STRING_INITIALIZER
14494 (struct cmd_vf_tc_bw_result,
14495 min_bw, "min-bandwidth");
14496 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw =
14497 TOKEN_STRING_INITIALIZER
14498 (struct cmd_vf_tc_bw_result,
14499 max_bw, "max-bandwidth");
14500 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id =
14501 TOKEN_NUM_INITIALIZER
14502 (struct cmd_vf_tc_bw_result,
14504 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14505 TOKEN_NUM_INITIALIZER
14506 (struct cmd_vf_tc_bw_result,
14508 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14509 TOKEN_NUM_INITIALIZER
14510 (struct cmd_vf_tc_bw_result,
14512 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14513 TOKEN_NUM_INITIALIZER
14514 (struct cmd_vf_tc_bw_result,
14516 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14517 TOKEN_STRING_INITIALIZER
14518 (struct cmd_vf_tc_bw_result,
14520 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14521 TOKEN_NUM_INITIALIZER
14522 (struct cmd_vf_tc_bw_result,
14525 /* VF max bandwidth setting */
14527 cmd_vf_max_bw_parsed(
14528 void *parsed_result,
14529 __attribute__((unused)) struct cmdline *cl,
14530 __attribute__((unused)) void *data)
14532 struct cmd_vf_tc_bw_result *res = parsed_result;
14533 int ret = -ENOTSUP;
14535 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14538 #ifdef RTE_LIBRTE_I40E_PMD
14539 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14540 res->vf_id, res->bw);
14547 printf("invalid vf_id %d or bandwidth %d\n",
14548 res->vf_id, res->bw);
14551 printf("invalid port_id %d\n", res->port_id);
14554 printf("function not implemented\n");
14557 printf("programming error: (%s)\n", strerror(-ret));
14561 cmdline_parse_inst_t cmd_vf_max_bw = {
14562 .f = cmd_vf_max_bw_parsed,
14564 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14566 (void *)&cmd_vf_tc_bw_set,
14567 (void *)&cmd_vf_tc_bw_vf,
14568 (void *)&cmd_vf_tc_bw_tx,
14569 (void *)&cmd_vf_tc_bw_max_bw,
14570 (void *)&cmd_vf_tc_bw_port_id,
14571 (void *)&cmd_vf_tc_bw_vf_id,
14572 (void *)&cmd_vf_tc_bw_bw,
14578 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14583 const char *p, *p0 = str;
14590 p = strchr(p0, '(');
14592 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14596 p0 = strchr(p, ')');
14598 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14602 if (size >= sizeof(s)) {
14603 printf("The string size exceeds the internal buffer size\n");
14606 snprintf(s, sizeof(s), "%.*s", size, p);
14607 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14609 printf("Failed to get the bandwidth list. ");
14613 for (i = 0; i < ret; i++)
14614 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14619 /* TC min bandwidth setting */
14621 cmd_vf_tc_min_bw_parsed(
14622 void *parsed_result,
14623 __attribute__((unused)) struct cmdline *cl,
14624 __attribute__((unused)) void *data)
14626 struct cmd_vf_tc_bw_result *res = parsed_result;
14629 int ret = -ENOTSUP;
14631 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14634 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14638 #ifdef RTE_LIBRTE_I40E_PMD
14639 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14647 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14650 printf("invalid port_id %d\n", res->port_id);
14653 printf("function not implemented\n");
14656 printf("programming error: (%s)\n", strerror(-ret));
14660 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14661 .f = cmd_vf_tc_min_bw_parsed,
14663 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14664 " <bw1, bw2, ...>",
14666 (void *)&cmd_vf_tc_bw_set,
14667 (void *)&cmd_vf_tc_bw_vf,
14668 (void *)&cmd_vf_tc_bw_tc,
14669 (void *)&cmd_vf_tc_bw_tx,
14670 (void *)&cmd_vf_tc_bw_min_bw,
14671 (void *)&cmd_vf_tc_bw_port_id,
14672 (void *)&cmd_vf_tc_bw_vf_id,
14673 (void *)&cmd_vf_tc_bw_bw_list,
14679 cmd_tc_min_bw_parsed(
14680 void *parsed_result,
14681 __attribute__((unused)) struct cmdline *cl,
14682 __attribute__((unused)) void *data)
14684 struct cmd_vf_tc_bw_result *res = parsed_result;
14685 struct rte_port *port;
14688 int ret = -ENOTSUP;
14690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14693 port = &ports[res->port_id];
14694 /** Check if the port is not started **/
14695 if (port->port_status != RTE_PORT_STOPPED) {
14696 printf("Please stop port %d first\n", res->port_id);
14700 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14704 #ifdef RTE_LIBRTE_IXGBE_PMD
14705 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14712 printf("invalid bandwidth\n");
14715 printf("invalid port_id %d\n", res->port_id);
14718 printf("function not implemented\n");
14721 printf("programming error: (%s)\n", strerror(-ret));
14725 cmdline_parse_inst_t cmd_tc_min_bw = {
14726 .f = cmd_tc_min_bw_parsed,
14728 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14730 (void *)&cmd_vf_tc_bw_set,
14731 (void *)&cmd_vf_tc_bw_tc,
14732 (void *)&cmd_vf_tc_bw_tx,
14733 (void *)&cmd_vf_tc_bw_min_bw,
14734 (void *)&cmd_vf_tc_bw_port_id,
14735 (void *)&cmd_vf_tc_bw_bw_list,
14740 /* TC max bandwidth setting */
14742 cmd_vf_tc_max_bw_parsed(
14743 void *parsed_result,
14744 __attribute__((unused)) struct cmdline *cl,
14745 __attribute__((unused)) void *data)
14747 struct cmd_vf_tc_bw_result *res = parsed_result;
14748 int ret = -ENOTSUP;
14750 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14753 #ifdef RTE_LIBRTE_I40E_PMD
14754 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id,
14755 res->tc_no, res->bw);
14762 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14763 res->vf_id, res->tc_no, res->bw);
14766 printf("invalid port_id %d\n", res->port_id);
14769 printf("function not implemented\n");
14772 printf("programming error: (%s)\n", strerror(-ret));
14776 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14777 .f = cmd_vf_tc_max_bw_parsed,
14779 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14782 (void *)&cmd_vf_tc_bw_set,
14783 (void *)&cmd_vf_tc_bw_vf,
14784 (void *)&cmd_vf_tc_bw_tc,
14785 (void *)&cmd_vf_tc_bw_tx,
14786 (void *)&cmd_vf_tc_bw_max_bw,
14787 (void *)&cmd_vf_tc_bw_port_id,
14788 (void *)&cmd_vf_tc_bw_vf_id,
14789 (void *)&cmd_vf_tc_bw_tc_no,
14790 (void *)&cmd_vf_tc_bw_bw,
14796 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14798 /* *** Set Port default Traffic Management Hierarchy *** */
14799 struct cmd_set_port_tm_hierarchy_default_result {
14800 cmdline_fixed_string_t set;
14801 cmdline_fixed_string_t port;
14802 cmdline_fixed_string_t tm;
14803 cmdline_fixed_string_t hierarchy;
14804 cmdline_fixed_string_t def;
14808 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set =
14809 TOKEN_STRING_INITIALIZER(
14810 struct cmd_set_port_tm_hierarchy_default_result, set, "set");
14811 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port =
14812 TOKEN_STRING_INITIALIZER(
14813 struct cmd_set_port_tm_hierarchy_default_result, port, "port");
14814 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm =
14815 TOKEN_STRING_INITIALIZER(
14816 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm");
14817 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy =
14818 TOKEN_STRING_INITIALIZER(
14819 struct cmd_set_port_tm_hierarchy_default_result,
14820 hierarchy, "hierarchy");
14821 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default =
14822 TOKEN_STRING_INITIALIZER(
14823 struct cmd_set_port_tm_hierarchy_default_result,
14825 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id =
14826 TOKEN_NUM_INITIALIZER(
14827 struct cmd_set_port_tm_hierarchy_default_result,
14830 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14831 __attribute__((unused)) struct cmdline *cl,
14832 __attribute__((unused)) void *data)
14834 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result;
14835 struct rte_port *p;
14836 portid_t port_id = res->port_id;
14838 if (port_id_is_invalid(port_id, ENABLED_WARN))
14841 p = &ports[port_id];
14843 /* Forward mode: tm */
14844 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
14845 printf(" softnicfwd mode not enabled(error)\n");
14849 /* Set the default tm hierarchy */
14850 p->softport.default_tm_hierarchy_enable = 1;
14853 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14854 .f = cmd_set_port_tm_hierarchy_default_parsed,
14856 .help_str = "set port tm hierarchy default <port_id>",
14858 (void *)&cmd_set_port_tm_hierarchy_default_set,
14859 (void *)&cmd_set_port_tm_hierarchy_default_port,
14860 (void *)&cmd_set_port_tm_hierarchy_default_tm,
14861 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy,
14862 (void *)&cmd_set_port_tm_hierarchy_default_default,
14863 (void *)&cmd_set_port_tm_hierarchy_default_port_id,
14869 /** Set VXLAN encapsulation details */
14870 struct cmd_set_vxlan_result {
14871 cmdline_fixed_string_t set;
14872 cmdline_fixed_string_t vxlan;
14873 cmdline_fixed_string_t pos_token;
14874 cmdline_fixed_string_t ip_version;
14875 uint32_t vlan_present:1;
14879 cmdline_ipaddr_t ip_src;
14880 cmdline_ipaddr_t ip_dst;
14882 struct ether_addr eth_src;
14883 struct ether_addr eth_dst;
14886 cmdline_parse_token_string_t cmd_set_vxlan_set =
14887 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
14888 cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
14889 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
14890 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
14891 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
14892 "vxlan-with-vlan");
14893 cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
14894 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14896 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
14897 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
14899 cmdline_parse_token_string_t cmd_set_vxlan_vni =
14900 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14902 cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
14903 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32);
14904 cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
14905 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14907 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
14908 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16);
14909 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
14910 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14912 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
14913 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16);
14914 cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
14915 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14917 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
14918 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
14919 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
14920 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14922 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
14923 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
14924 cmdline_parse_token_string_t cmd_set_vxlan_vlan =
14925 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14927 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
14928 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16);
14929 cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
14930 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14932 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
14933 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
14934 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
14935 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14937 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
14938 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
14940 static void cmd_set_vxlan_parsed(void *parsed_result,
14941 __attribute__((unused)) struct cmdline *cl,
14942 __attribute__((unused)) void *data)
14944 struct cmd_set_vxlan_result *res = parsed_result;
14949 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
14952 if (strcmp(res->vxlan, "vxlan") == 0)
14953 vxlan_encap_conf.select_vlan = 0;
14954 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
14955 vxlan_encap_conf.select_vlan = 1;
14956 if (strcmp(res->ip_version, "ipv4") == 0)
14957 vxlan_encap_conf.select_ipv4 = 1;
14958 else if (strcmp(res->ip_version, "ipv6") == 0)
14959 vxlan_encap_conf.select_ipv4 = 0;
14962 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
14963 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
14964 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
14965 if (vxlan_encap_conf.select_ipv4) {
14966 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
14967 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
14969 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
14970 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
14972 if (vxlan_encap_conf.select_vlan)
14973 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
14974 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
14976 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14980 cmdline_parse_inst_t cmd_set_vxlan = {
14981 .f = cmd_set_vxlan_parsed,
14983 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
14984 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
14985 " eth-src <eth-src> eth-dst <eth-dst>",
14987 (void *)&cmd_set_vxlan_set,
14988 (void *)&cmd_set_vxlan_vxlan,
14989 (void *)&cmd_set_vxlan_ip_version,
14990 (void *)&cmd_set_vxlan_ip_version_value,
14991 (void *)&cmd_set_vxlan_vni,
14992 (void *)&cmd_set_vxlan_vni_value,
14993 (void *)&cmd_set_vxlan_udp_src,
14994 (void *)&cmd_set_vxlan_udp_src_value,
14995 (void *)&cmd_set_vxlan_udp_dst,
14996 (void *)&cmd_set_vxlan_udp_dst_value,
14997 (void *)&cmd_set_vxlan_ip_src,
14998 (void *)&cmd_set_vxlan_ip_src_value,
14999 (void *)&cmd_set_vxlan_ip_dst,
15000 (void *)&cmd_set_vxlan_ip_dst_value,
15001 (void *)&cmd_set_vxlan_eth_src,
15002 (void *)&cmd_set_vxlan_eth_src_value,
15003 (void *)&cmd_set_vxlan_eth_dst,
15004 (void *)&cmd_set_vxlan_eth_dst_value,
15009 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15010 .f = cmd_set_vxlan_parsed,
15012 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
15013 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
15014 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
15017 (void *)&cmd_set_vxlan_set,
15018 (void *)&cmd_set_vxlan_vxlan_with_vlan,
15019 (void *)&cmd_set_vxlan_ip_version,
15020 (void *)&cmd_set_vxlan_ip_version_value,
15021 (void *)&cmd_set_vxlan_vni,
15022 (void *)&cmd_set_vxlan_vni_value,
15023 (void *)&cmd_set_vxlan_udp_src,
15024 (void *)&cmd_set_vxlan_udp_src_value,
15025 (void *)&cmd_set_vxlan_udp_dst,
15026 (void *)&cmd_set_vxlan_udp_dst_value,
15027 (void *)&cmd_set_vxlan_ip_src,
15028 (void *)&cmd_set_vxlan_ip_src_value,
15029 (void *)&cmd_set_vxlan_ip_dst,
15030 (void *)&cmd_set_vxlan_ip_dst_value,
15031 (void *)&cmd_set_vxlan_vlan,
15032 (void *)&cmd_set_vxlan_vlan_value,
15033 (void *)&cmd_set_vxlan_eth_src,
15034 (void *)&cmd_set_vxlan_eth_src_value,
15035 (void *)&cmd_set_vxlan_eth_dst,
15036 (void *)&cmd_set_vxlan_eth_dst_value,
15041 /** Set NVGRE encapsulation details */
15042 struct cmd_set_nvgre_result {
15043 cmdline_fixed_string_t set;
15044 cmdline_fixed_string_t nvgre;
15045 cmdline_fixed_string_t pos_token;
15046 cmdline_fixed_string_t ip_version;
15048 cmdline_ipaddr_t ip_src;
15049 cmdline_ipaddr_t ip_dst;
15051 struct ether_addr eth_src;
15052 struct ether_addr eth_dst;
15055 cmdline_parse_token_string_t cmd_set_nvgre_set =
15056 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
15057 cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
15058 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
15059 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
15060 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
15061 "nvgre-with-vlan");
15062 cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
15063 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15065 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15066 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15068 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15069 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15071 cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
15072 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32);
15073 cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
15074 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15076 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
15077 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
15078 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
15079 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15081 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
15082 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
15083 cmdline_parse_token_string_t cmd_set_nvgre_vlan =
15084 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15086 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
15087 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16);
15088 cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
15089 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15091 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
15092 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
15093 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
15094 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15096 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15097 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15099 static void cmd_set_nvgre_parsed(void *parsed_result,
15100 __attribute__((unused)) struct cmdline *cl,
15101 __attribute__((unused)) void *data)
15103 struct cmd_set_nvgre_result *res = parsed_result;
15105 uint32_t nvgre_tni;
15108 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15111 if (strcmp(res->nvgre, "nvgre") == 0)
15112 nvgre_encap_conf.select_vlan = 0;
15113 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
15114 nvgre_encap_conf.select_vlan = 1;
15115 if (strcmp(res->ip_version, "ipv4") == 0)
15116 nvgre_encap_conf.select_ipv4 = 1;
15117 else if (strcmp(res->ip_version, "ipv6") == 0)
15118 nvgre_encap_conf.select_ipv4 = 0;
15121 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
15122 if (nvgre_encap_conf.select_ipv4) {
15123 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
15124 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
15126 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
15127 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
15129 if (nvgre_encap_conf.select_vlan)
15130 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
15131 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
15133 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15137 cmdline_parse_inst_t cmd_set_nvgre = {
15138 .f = cmd_set_nvgre_parsed,
15140 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
15141 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
15142 " eth-dst <eth-dst>",
15144 (void *)&cmd_set_nvgre_set,
15145 (void *)&cmd_set_nvgre_nvgre,
15146 (void *)&cmd_set_nvgre_ip_version,
15147 (void *)&cmd_set_nvgre_ip_version_value,
15148 (void *)&cmd_set_nvgre_tni,
15149 (void *)&cmd_set_nvgre_tni_value,
15150 (void *)&cmd_set_nvgre_ip_src,
15151 (void *)&cmd_set_nvgre_ip_src_value,
15152 (void *)&cmd_set_nvgre_ip_dst,
15153 (void *)&cmd_set_nvgre_ip_dst_value,
15154 (void *)&cmd_set_nvgre_eth_src,
15155 (void *)&cmd_set_nvgre_eth_src_value,
15156 (void *)&cmd_set_nvgre_eth_dst,
15157 (void *)&cmd_set_nvgre_eth_dst_value,
15162 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15163 .f = cmd_set_nvgre_parsed,
15165 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
15166 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
15167 " eth-src <eth-src> eth-dst <eth-dst>",
15169 (void *)&cmd_set_nvgre_set,
15170 (void *)&cmd_set_nvgre_nvgre_with_vlan,
15171 (void *)&cmd_set_nvgre_ip_version,
15172 (void *)&cmd_set_nvgre_ip_version_value,
15173 (void *)&cmd_set_nvgre_tni,
15174 (void *)&cmd_set_nvgre_tni_value,
15175 (void *)&cmd_set_nvgre_ip_src,
15176 (void *)&cmd_set_nvgre_ip_src_value,
15177 (void *)&cmd_set_nvgre_ip_dst,
15178 (void *)&cmd_set_nvgre_ip_dst_value,
15179 (void *)&cmd_set_nvgre_vlan,
15180 (void *)&cmd_set_nvgre_vlan_value,
15181 (void *)&cmd_set_nvgre_eth_src,
15182 (void *)&cmd_set_nvgre_eth_src_value,
15183 (void *)&cmd_set_nvgre_eth_dst,
15184 (void *)&cmd_set_nvgre_eth_dst_value,
15189 /* Strict link priority scheduling mode setting */
15191 cmd_strict_link_prio_parsed(
15192 void *parsed_result,
15193 __attribute__((unused)) struct cmdline *cl,
15194 __attribute__((unused)) void *data)
15196 struct cmd_vf_tc_bw_result *res = parsed_result;
15197 int ret = -ENOTSUP;
15199 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15202 #ifdef RTE_LIBRTE_I40E_PMD
15203 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15210 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15213 printf("invalid port_id %d\n", res->port_id);
15216 printf("function not implemented\n");
15219 printf("programming error: (%s)\n", strerror(-ret));
15223 cmdline_parse_inst_t cmd_strict_link_prio = {
15224 .f = cmd_strict_link_prio_parsed,
15226 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
15228 (void *)&cmd_vf_tc_bw_set,
15229 (void *)&cmd_vf_tc_bw_tx,
15230 (void *)&cmd_vf_tc_bw_strict_link_prio,
15231 (void *)&cmd_vf_tc_bw_port_id,
15232 (void *)&cmd_vf_tc_bw_tc_map,
15237 /* Load dynamic device personalization*/
15238 struct cmd_ddp_add_result {
15239 cmdline_fixed_string_t ddp;
15240 cmdline_fixed_string_t add;
15245 cmdline_parse_token_string_t cmd_ddp_add_ddp =
15246 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp");
15247 cmdline_parse_token_string_t cmd_ddp_add_add =
15248 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add");
15249 cmdline_parse_token_num_t cmd_ddp_add_port_id =
15250 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16);
15251 cmdline_parse_token_string_t cmd_ddp_add_filepath =
15252 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL);
15255 cmd_ddp_add_parsed(
15256 void *parsed_result,
15257 __attribute__((unused)) struct cmdline *cl,
15258 __attribute__((unused)) void *data)
15260 struct cmd_ddp_add_result *res = parsed_result;
15266 int ret = -ENOTSUP;
15268 if (!all_ports_stopped()) {
15269 printf("Please stop all ports first\n");
15273 filepath = strdup(res->filepath);
15274 if (filepath == NULL) {
15275 printf("Failed to allocate memory\n");
15278 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
15280 buff = open_file(file_fld[0], &size);
15282 free((void *)filepath);
15286 #ifdef RTE_LIBRTE_I40E_PMD
15287 if (ret == -ENOTSUP)
15288 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15290 RTE_PMD_I40E_PKG_OP_WR_ADD);
15293 if (ret == -EEXIST)
15294 printf("Profile has already existed.\n");
15296 printf("Failed to load profile.\n");
15297 else if (file_num == 2)
15298 save_file(file_fld[1], buff, size);
15301 free((void *)filepath);
15304 cmdline_parse_inst_t cmd_ddp_add = {
15305 .f = cmd_ddp_add_parsed,
15307 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
15309 (void *)&cmd_ddp_add_ddp,
15310 (void *)&cmd_ddp_add_add,
15311 (void *)&cmd_ddp_add_port_id,
15312 (void *)&cmd_ddp_add_filepath,
15317 /* Delete dynamic device personalization*/
15318 struct cmd_ddp_del_result {
15319 cmdline_fixed_string_t ddp;
15320 cmdline_fixed_string_t del;
15325 cmdline_parse_token_string_t cmd_ddp_del_ddp =
15326 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp");
15327 cmdline_parse_token_string_t cmd_ddp_del_del =
15328 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del");
15329 cmdline_parse_token_num_t cmd_ddp_del_port_id =
15330 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16);
15331 cmdline_parse_token_string_t cmd_ddp_del_filepath =
15332 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL);
15335 cmd_ddp_del_parsed(
15336 void *parsed_result,
15337 __attribute__((unused)) struct cmdline *cl,
15338 __attribute__((unused)) void *data)
15340 struct cmd_ddp_del_result *res = parsed_result;
15343 int ret = -ENOTSUP;
15345 if (!all_ports_stopped()) {
15346 printf("Please stop all ports first\n");
15350 buff = open_file(res->filepath, &size);
15354 #ifdef RTE_LIBRTE_I40E_PMD
15355 if (ret == -ENOTSUP)
15356 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15358 RTE_PMD_I40E_PKG_OP_WR_DEL);
15361 if (ret == -EACCES)
15362 printf("Profile does not exist.\n");
15364 printf("Failed to delete profile.\n");
15369 cmdline_parse_inst_t cmd_ddp_del = {
15370 .f = cmd_ddp_del_parsed,
15372 .help_str = "ddp del <port_id> <backup_profile_path>",
15374 (void *)&cmd_ddp_del_ddp,
15375 (void *)&cmd_ddp_del_del,
15376 (void *)&cmd_ddp_del_port_id,
15377 (void *)&cmd_ddp_del_filepath,
15382 /* Get dynamic device personalization profile info */
15383 struct cmd_ddp_info_result {
15384 cmdline_fixed_string_t ddp;
15385 cmdline_fixed_string_t get;
15386 cmdline_fixed_string_t info;
15390 cmdline_parse_token_string_t cmd_ddp_info_ddp =
15391 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp");
15392 cmdline_parse_token_string_t cmd_ddp_info_get =
15393 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get");
15394 cmdline_parse_token_string_t cmd_ddp_info_info =
15395 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info");
15396 cmdline_parse_token_string_t cmd_ddp_info_filepath =
15397 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL);
15400 cmd_ddp_info_parsed(
15401 void *parsed_result,
15402 __attribute__((unused)) struct cmdline *cl,
15403 __attribute__((unused)) void *data)
15405 struct cmd_ddp_info_result *res = parsed_result;
15408 int ret = -ENOTSUP;
15409 #ifdef RTE_LIBRTE_I40E_PMD
15412 uint32_t buff_size = 0;
15413 struct rte_pmd_i40e_profile_info info;
15414 uint32_t dev_num = 0;
15415 struct rte_pmd_i40e_ddp_device_id *devs;
15416 uint32_t proto_num = 0;
15417 struct rte_pmd_i40e_proto_info *proto = NULL;
15418 uint32_t pctype_num = 0;
15419 struct rte_pmd_i40e_ptype_info *pctype;
15420 uint32_t ptype_num = 0;
15421 struct rte_pmd_i40e_ptype_info *ptype;
15426 pkg = open_file(res->filepath, &pkg_size);
15430 #ifdef RTE_LIBRTE_I40E_PMD
15431 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15432 (uint8_t *)&info, sizeof(info),
15433 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER);
15435 printf("Global Track id: 0x%x\n", info.track_id);
15436 printf("Global Version: %d.%d.%d.%d\n",
15437 info.version.major,
15438 info.version.minor,
15439 info.version.update,
15440 info.version.draft);
15441 printf("Global Package name: %s\n\n", info.name);
15444 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15445 (uint8_t *)&info, sizeof(info),
15446 RTE_PMD_I40E_PKG_INFO_HEADER);
15448 printf("i40e Profile Track id: 0x%x\n", info.track_id);
15449 printf("i40e Profile Version: %d.%d.%d.%d\n",
15450 info.version.major,
15451 info.version.minor,
15452 info.version.update,
15453 info.version.draft);
15454 printf("i40e Profile name: %s\n\n", info.name);
15457 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15458 (uint8_t *)&buff_size, sizeof(buff_size),
15459 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE);
15460 if (!ret && buff_size) {
15461 buff = (uint8_t *)malloc(buff_size);
15463 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15465 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15467 printf("Package Notes:\n%s\n\n", buff);
15472 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15473 (uint8_t *)&dev_num, sizeof(dev_num),
15474 RTE_PMD_I40E_PKG_INFO_DEVID_NUM);
15475 if (!ret && dev_num) {
15476 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id);
15477 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size);
15479 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15480 (uint8_t *)devs, buff_size,
15481 RTE_PMD_I40E_PKG_INFO_DEVID_LIST);
15483 printf("List of supported devices:\n");
15484 for (i = 0; i < dev_num; i++) {
15485 printf(" %04X:%04X %04X:%04X\n",
15486 devs[i].vendor_dev_id >> 16,
15487 devs[i].vendor_dev_id & 0xFFFF,
15488 devs[i].sub_vendor_dev_id >> 16,
15489 devs[i].sub_vendor_dev_id & 0xFFFF);
15497 /* get information about protocols and packet types */
15498 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15499 (uint8_t *)&proto_num, sizeof(proto_num),
15500 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM);
15501 if (ret || !proto_num)
15502 goto no_print_return;
15504 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15505 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15507 goto no_print_return;
15509 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15511 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15513 printf("List of used protocols:\n");
15514 for (i = 0; i < proto_num; i++)
15515 printf(" %2u: %s\n", proto[i].proto_id,
15519 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15520 (uint8_t *)&pctype_num, sizeof(pctype_num),
15521 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM);
15522 if (ret || !pctype_num)
15523 goto no_print_pctypes;
15525 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15526 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15528 goto no_print_pctypes;
15530 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15532 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15535 goto no_print_pctypes;
15538 printf("List of defined packet classification types:\n");
15539 for (i = 0; i < pctype_num; i++) {
15540 printf(" %2u:", pctype[i].ptype_id);
15541 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15542 proto_id = pctype[i].protocols[j];
15543 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15544 for (n = 0; n < proto_num; n++) {
15545 if (proto[n].proto_id == proto_id) {
15546 printf(" %s", proto[n].name);
15559 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15561 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15562 if (ret || !ptype_num)
15563 goto no_print_return;
15565 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15566 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15568 goto no_print_return;
15570 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15572 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15575 goto no_print_return;
15577 printf("List of defined packet types:\n");
15578 for (i = 0; i < ptype_num; i++) {
15579 printf(" %2u:", ptype[i].ptype_id);
15580 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) {
15581 proto_id = ptype[i].protocols[j];
15582 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) {
15583 for (n = 0; n < proto_num; n++) {
15584 if (proto[n].proto_id == proto_id) {
15585 printf(" %s", proto[n].name);
15601 if (ret == -ENOTSUP)
15602 printf("Function not supported in PMD driver\n");
15606 cmdline_parse_inst_t cmd_ddp_get_info = {
15607 .f = cmd_ddp_info_parsed,
15609 .help_str = "ddp get info <profile_path>",
15611 (void *)&cmd_ddp_info_ddp,
15612 (void *)&cmd_ddp_info_get,
15613 (void *)&cmd_ddp_info_info,
15614 (void *)&cmd_ddp_info_filepath,
15619 /* Get dynamic device personalization profile info list*/
15620 #define PROFILE_INFO_SIZE 48
15621 #define MAX_PROFILE_NUM 16
15623 struct cmd_ddp_get_list_result {
15624 cmdline_fixed_string_t ddp;
15625 cmdline_fixed_string_t get;
15626 cmdline_fixed_string_t list;
15630 cmdline_parse_token_string_t cmd_ddp_get_list_ddp =
15631 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp");
15632 cmdline_parse_token_string_t cmd_ddp_get_list_get =
15633 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get");
15634 cmdline_parse_token_string_t cmd_ddp_get_list_list =
15635 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list");
15636 cmdline_parse_token_num_t cmd_ddp_get_list_port_id =
15637 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16);
15640 cmd_ddp_get_list_parsed(
15641 __attribute__((unused)) void *parsed_result,
15642 __attribute__((unused)) struct cmdline *cl,
15643 __attribute__((unused)) void *data)
15645 #ifdef RTE_LIBRTE_I40E_PMD
15646 struct cmd_ddp_get_list_result *res = parsed_result;
15647 struct rte_pmd_i40e_profile_list *p_list;
15648 struct rte_pmd_i40e_profile_info *p_info;
15653 int ret = -ENOTSUP;
15655 #ifdef RTE_LIBRTE_I40E_PMD
15656 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
15657 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size);
15659 printf("%s: Failed to malloc buffer\n", __func__);
15661 if (ret == -ENOTSUP)
15662 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15663 (uint8_t *)p_list, size);
15666 p_num = p_list->p_count;
15667 printf("Profile number is: %d\n\n", p_num);
15669 for (i = 0; i < p_num; i++) {
15670 p_info = &p_list->p_info[i];
15671 printf("Profile %d:\n", i);
15672 printf("Track id: 0x%x\n", p_info->track_id);
15673 printf("Version: %d.%d.%d.%d\n",
15674 p_info->version.major,
15675 p_info->version.minor,
15676 p_info->version.update,
15677 p_info->version.draft);
15678 printf("Profile name: %s\n\n", p_info->name);
15686 printf("Failed to get ddp list\n");
15689 cmdline_parse_inst_t cmd_ddp_get_list = {
15690 .f = cmd_ddp_get_list_parsed,
15692 .help_str = "ddp get list <port_id>",
15694 (void *)&cmd_ddp_get_list_ddp,
15695 (void *)&cmd_ddp_get_list_get,
15696 (void *)&cmd_ddp_get_list_list,
15697 (void *)&cmd_ddp_get_list_port_id,
15702 /* Configure input set */
15703 struct cmd_cfg_input_set_result {
15704 cmdline_fixed_string_t port;
15705 cmdline_fixed_string_t cfg;
15707 cmdline_fixed_string_t pctype;
15709 cmdline_fixed_string_t inset_type;
15710 cmdline_fixed_string_t opt;
15711 cmdline_fixed_string_t field;
15716 cmd_cfg_input_set_parsed(
15717 __attribute__((unused)) void *parsed_result,
15718 __attribute__((unused)) struct cmdline *cl,
15719 __attribute__((unused)) void *data)
15721 #ifdef RTE_LIBRTE_I40E_PMD
15722 struct cmd_cfg_input_set_result *res = parsed_result;
15723 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15724 struct rte_pmd_i40e_inset inset;
15726 int ret = -ENOTSUP;
15728 if (!all_ports_stopped()) {
15729 printf("Please stop all ports first\n");
15733 #ifdef RTE_LIBRTE_I40E_PMD
15734 if (!strcmp(res->inset_type, "hash_inset"))
15735 inset_type = INSET_HASH;
15736 else if (!strcmp(res->inset_type, "fdir_inset"))
15737 inset_type = INSET_FDIR;
15738 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15739 inset_type = INSET_FDIR_FLX;
15740 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id,
15741 &inset, inset_type);
15743 printf("Failed to get input set.\n");
15747 if (!strcmp(res->opt, "get")) {
15748 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15751 printf("Field index %d is enabled.\n", res->field_idx);
15753 printf("Field index %d is disabled.\n", res->field_idx);
15755 } else if (!strcmp(res->opt, "set"))
15756 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15758 else if (!strcmp(res->opt, "clear"))
15759 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15762 printf("Failed to configure input set field.\n");
15766 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15767 &inset, inset_type);
15769 printf("Failed to set input set.\n");
15774 if (ret == -ENOTSUP)
15775 printf("Function not supported\n");
15778 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15779 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15781 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15782 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15784 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15785 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15787 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15788 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15790 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15791 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15793 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15794 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15796 "hash_inset#fdir_inset#fdir_flx_inset");
15797 cmdline_parse_token_string_t cmd_cfg_input_set_opt =
15798 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15799 opt, "get#set#clear");
15800 cmdline_parse_token_string_t cmd_cfg_input_set_field =
15801 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15803 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15804 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15807 cmdline_parse_inst_t cmd_cfg_input_set = {
15808 .f = cmd_cfg_input_set_parsed,
15810 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15811 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15813 (void *)&cmd_cfg_input_set_port,
15814 (void *)&cmd_cfg_input_set_cfg,
15815 (void *)&cmd_cfg_input_set_port_id,
15816 (void *)&cmd_cfg_input_set_pctype,
15817 (void *)&cmd_cfg_input_set_pctype_id,
15818 (void *)&cmd_cfg_input_set_inset_type,
15819 (void *)&cmd_cfg_input_set_opt,
15820 (void *)&cmd_cfg_input_set_field,
15821 (void *)&cmd_cfg_input_set_field_idx,
15826 /* Clear input set */
15827 struct cmd_clear_input_set_result {
15828 cmdline_fixed_string_t port;
15829 cmdline_fixed_string_t cfg;
15831 cmdline_fixed_string_t pctype;
15833 cmdline_fixed_string_t inset_type;
15834 cmdline_fixed_string_t clear;
15835 cmdline_fixed_string_t all;
15839 cmd_clear_input_set_parsed(
15840 __attribute__((unused)) void *parsed_result,
15841 __attribute__((unused)) struct cmdline *cl,
15842 __attribute__((unused)) void *data)
15844 #ifdef RTE_LIBRTE_I40E_PMD
15845 struct cmd_clear_input_set_result *res = parsed_result;
15846 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE;
15847 struct rte_pmd_i40e_inset inset;
15849 int ret = -ENOTSUP;
15851 if (!all_ports_stopped()) {
15852 printf("Please stop all ports first\n");
15856 #ifdef RTE_LIBRTE_I40E_PMD
15857 if (!strcmp(res->inset_type, "hash_inset"))
15858 inset_type = INSET_HASH;
15859 else if (!strcmp(res->inset_type, "fdir_inset"))
15860 inset_type = INSET_FDIR;
15861 else if (!strcmp(res->inset_type, "fdir_flx_inset"))
15862 inset_type = INSET_FDIR_FLX;
15864 memset(&inset, 0, sizeof(inset));
15866 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15867 &inset, inset_type);
15869 printf("Failed to clear input set.\n");
15875 if (ret == -ENOTSUP)
15876 printf("Function not supported\n");
15879 cmdline_parse_token_string_t cmd_clear_input_set_port =
15880 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15882 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15883 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15885 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15886 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15888 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15889 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15891 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15892 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15894 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15895 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15897 "hash_inset#fdir_inset#fdir_flx_inset");
15898 cmdline_parse_token_string_t cmd_clear_input_set_clear =
15899 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15901 cmdline_parse_token_string_t cmd_clear_input_set_all =
15902 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15905 cmdline_parse_inst_t cmd_clear_input_set = {
15906 .f = cmd_clear_input_set_parsed,
15908 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15909 "fdir_inset|fdir_flx_inset clear all",
15911 (void *)&cmd_clear_input_set_port,
15912 (void *)&cmd_clear_input_set_cfg,
15913 (void *)&cmd_clear_input_set_port_id,
15914 (void *)&cmd_clear_input_set_pctype,
15915 (void *)&cmd_clear_input_set_pctype_id,
15916 (void *)&cmd_clear_input_set_inset_type,
15917 (void *)&cmd_clear_input_set_clear,
15918 (void *)&cmd_clear_input_set_all,
15923 /* show vf stats */
15925 /* Common result structure for show vf stats */
15926 struct cmd_show_vf_stats_result {
15927 cmdline_fixed_string_t show;
15928 cmdline_fixed_string_t vf;
15929 cmdline_fixed_string_t stats;
15934 /* Common CLI fields show vf stats*/
15935 cmdline_parse_token_string_t cmd_show_vf_stats_show =
15936 TOKEN_STRING_INITIALIZER
15937 (struct cmd_show_vf_stats_result,
15939 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15940 TOKEN_STRING_INITIALIZER
15941 (struct cmd_show_vf_stats_result,
15943 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15944 TOKEN_STRING_INITIALIZER
15945 (struct cmd_show_vf_stats_result,
15947 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15948 TOKEN_NUM_INITIALIZER
15949 (struct cmd_show_vf_stats_result,
15951 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15952 TOKEN_NUM_INITIALIZER
15953 (struct cmd_show_vf_stats_result,
15957 cmd_show_vf_stats_parsed(
15958 void *parsed_result,
15959 __attribute__((unused)) struct cmdline *cl,
15960 __attribute__((unused)) void *data)
15962 struct cmd_show_vf_stats_result *res = parsed_result;
15963 struct rte_eth_stats stats;
15964 int ret = -ENOTSUP;
15965 static const char *nic_stats_border = "########################";
15967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15970 memset(&stats, 0, sizeof(stats));
15972 #ifdef RTE_LIBRTE_I40E_PMD
15973 if (ret == -ENOTSUP)
15974 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15978 #ifdef RTE_LIBRTE_BNXT_PMD
15979 if (ret == -ENOTSUP)
15980 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15989 printf("invalid vf_id %d\n", res->vf_id);
15992 printf("invalid port_id %d\n", res->port_id);
15995 printf("function not implemented\n");
15998 printf("programming error: (%s)\n", strerror(-ret));
16001 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
16002 nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
16004 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16006 stats.ipackets, stats.imissed, stats.ibytes);
16007 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16008 printf(" RX-nombuf: %-10"PRIu64"\n",
16010 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16012 stats.opackets, stats.oerrors, stats.obytes);
16014 printf(" %s############################%s\n",
16015 nic_stats_border, nic_stats_border);
16018 cmdline_parse_inst_t cmd_show_vf_stats = {
16019 .f = cmd_show_vf_stats_parsed,
16021 .help_str = "show vf stats <port_id> <vf_id>",
16023 (void *)&cmd_show_vf_stats_show,
16024 (void *)&cmd_show_vf_stats_vf,
16025 (void *)&cmd_show_vf_stats_stats,
16026 (void *)&cmd_show_vf_stats_port_id,
16027 (void *)&cmd_show_vf_stats_vf_id,
16032 /* clear vf stats */
16034 /* Common result structure for clear vf stats */
16035 struct cmd_clear_vf_stats_result {
16036 cmdline_fixed_string_t clear;
16037 cmdline_fixed_string_t vf;
16038 cmdline_fixed_string_t stats;
16043 /* Common CLI fields clear vf stats*/
16044 cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
16045 TOKEN_STRING_INITIALIZER
16046 (struct cmd_clear_vf_stats_result,
16048 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16049 TOKEN_STRING_INITIALIZER
16050 (struct cmd_clear_vf_stats_result,
16052 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16053 TOKEN_STRING_INITIALIZER
16054 (struct cmd_clear_vf_stats_result,
16056 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16057 TOKEN_NUM_INITIALIZER
16058 (struct cmd_clear_vf_stats_result,
16060 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16061 TOKEN_NUM_INITIALIZER
16062 (struct cmd_clear_vf_stats_result,
16066 cmd_clear_vf_stats_parsed(
16067 void *parsed_result,
16068 __attribute__((unused)) struct cmdline *cl,
16069 __attribute__((unused)) void *data)
16071 struct cmd_clear_vf_stats_result *res = parsed_result;
16072 int ret = -ENOTSUP;
16074 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16077 #ifdef RTE_LIBRTE_I40E_PMD
16078 if (ret == -ENOTSUP)
16079 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16082 #ifdef RTE_LIBRTE_BNXT_PMD
16083 if (ret == -ENOTSUP)
16084 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16092 printf("invalid vf_id %d\n", res->vf_id);
16095 printf("invalid port_id %d\n", res->port_id);
16098 printf("function not implemented\n");
16101 printf("programming error: (%s)\n", strerror(-ret));
16105 cmdline_parse_inst_t cmd_clear_vf_stats = {
16106 .f = cmd_clear_vf_stats_parsed,
16108 .help_str = "clear vf stats <port_id> <vf_id>",
16110 (void *)&cmd_clear_vf_stats_clear,
16111 (void *)&cmd_clear_vf_stats_vf,
16112 (void *)&cmd_clear_vf_stats_stats,
16113 (void *)&cmd_clear_vf_stats_port_id,
16114 (void *)&cmd_clear_vf_stats_vf_id,
16119 /* port config pctype mapping reset */
16121 /* Common result structure for port config pctype mapping reset */
16122 struct cmd_pctype_mapping_reset_result {
16123 cmdline_fixed_string_t port;
16124 cmdline_fixed_string_t config;
16126 cmdline_fixed_string_t pctype;
16127 cmdline_fixed_string_t mapping;
16128 cmdline_fixed_string_t reset;
16131 /* Common CLI fields for port config pctype mapping reset*/
16132 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port =
16133 TOKEN_STRING_INITIALIZER
16134 (struct cmd_pctype_mapping_reset_result,
16136 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16137 TOKEN_STRING_INITIALIZER
16138 (struct cmd_pctype_mapping_reset_result,
16140 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16141 TOKEN_NUM_INITIALIZER
16142 (struct cmd_pctype_mapping_reset_result,
16144 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16145 TOKEN_STRING_INITIALIZER
16146 (struct cmd_pctype_mapping_reset_result,
16148 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping =
16149 TOKEN_STRING_INITIALIZER
16150 (struct cmd_pctype_mapping_reset_result,
16151 mapping, "mapping");
16152 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset =
16153 TOKEN_STRING_INITIALIZER
16154 (struct cmd_pctype_mapping_reset_result,
16158 cmd_pctype_mapping_reset_parsed(
16159 void *parsed_result,
16160 __attribute__((unused)) struct cmdline *cl,
16161 __attribute__((unused)) void *data)
16163 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16164 int ret = -ENOTSUP;
16166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16169 #ifdef RTE_LIBRTE_I40E_PMD
16170 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16177 printf("invalid port_id %d\n", res->port_id);
16180 printf("function not implemented\n");
16183 printf("programming error: (%s)\n", strerror(-ret));
16187 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16188 .f = cmd_pctype_mapping_reset_parsed,
16190 .help_str = "port config <port_id> pctype mapping reset",
16192 (void *)&cmd_pctype_mapping_reset_port,
16193 (void *)&cmd_pctype_mapping_reset_config,
16194 (void *)&cmd_pctype_mapping_reset_port_id,
16195 (void *)&cmd_pctype_mapping_reset_pctype,
16196 (void *)&cmd_pctype_mapping_reset_mapping,
16197 (void *)&cmd_pctype_mapping_reset_reset,
16202 /* show port pctype mapping */
16204 /* Common result structure for show port pctype mapping */
16205 struct cmd_pctype_mapping_get_result {
16206 cmdline_fixed_string_t show;
16207 cmdline_fixed_string_t port;
16209 cmdline_fixed_string_t pctype;
16210 cmdline_fixed_string_t mapping;
16213 /* Common CLI fields for pctype mapping get */
16214 cmdline_parse_token_string_t cmd_pctype_mapping_get_show =
16215 TOKEN_STRING_INITIALIZER
16216 (struct cmd_pctype_mapping_get_result,
16218 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16219 TOKEN_STRING_INITIALIZER
16220 (struct cmd_pctype_mapping_get_result,
16222 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
16223 TOKEN_NUM_INITIALIZER
16224 (struct cmd_pctype_mapping_get_result,
16226 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
16227 TOKEN_STRING_INITIALIZER
16228 (struct cmd_pctype_mapping_get_result,
16230 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping =
16231 TOKEN_STRING_INITIALIZER
16232 (struct cmd_pctype_mapping_get_result,
16233 mapping, "mapping");
16236 cmd_pctype_mapping_get_parsed(
16237 void *parsed_result,
16238 __attribute__((unused)) struct cmdline *cl,
16239 __attribute__((unused)) void *data)
16241 struct cmd_pctype_mapping_get_result *res = parsed_result;
16242 int ret = -ENOTSUP;
16243 #ifdef RTE_LIBRTE_I40E_PMD
16244 struct rte_pmd_i40e_flow_type_mapping
16245 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX];
16246 int i, j, first_pctype;
16249 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16252 #ifdef RTE_LIBRTE_I40E_PMD
16253 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
16260 printf("invalid port_id %d\n", res->port_id);
16263 printf("function not implemented\n");
16266 printf("programming error: (%s)\n", strerror(-ret));
16270 #ifdef RTE_LIBRTE_I40E_PMD
16271 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
16272 if (mapping[i].pctype != 0ULL) {
16275 printf("pctype: ");
16276 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) {
16277 if (mapping[i].pctype & (1ULL << j)) {
16278 printf(first_pctype ?
16279 "%02d" : ",%02d", j);
16283 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
16289 cmdline_parse_inst_t cmd_pctype_mapping_get = {
16290 .f = cmd_pctype_mapping_get_parsed,
16292 .help_str = "show port <port_id> pctype mapping",
16294 (void *)&cmd_pctype_mapping_get_show,
16295 (void *)&cmd_pctype_mapping_get_port,
16296 (void *)&cmd_pctype_mapping_get_port_id,
16297 (void *)&cmd_pctype_mapping_get_pctype,
16298 (void *)&cmd_pctype_mapping_get_mapping,
16303 /* port config pctype mapping update */
16305 /* Common result structure for port config pctype mapping update */
16306 struct cmd_pctype_mapping_update_result {
16307 cmdline_fixed_string_t port;
16308 cmdline_fixed_string_t config;
16310 cmdline_fixed_string_t pctype;
16311 cmdline_fixed_string_t mapping;
16312 cmdline_fixed_string_t update;
16313 cmdline_fixed_string_t pctype_list;
16314 uint16_t flow_type;
16317 /* Common CLI fields for pctype mapping update*/
16318 cmdline_parse_token_string_t cmd_pctype_mapping_update_port =
16319 TOKEN_STRING_INITIALIZER
16320 (struct cmd_pctype_mapping_update_result,
16322 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
16323 TOKEN_STRING_INITIALIZER
16324 (struct cmd_pctype_mapping_update_result,
16326 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
16327 TOKEN_NUM_INITIALIZER
16328 (struct cmd_pctype_mapping_update_result,
16330 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
16331 TOKEN_STRING_INITIALIZER
16332 (struct cmd_pctype_mapping_update_result,
16334 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping =
16335 TOKEN_STRING_INITIALIZER
16336 (struct cmd_pctype_mapping_update_result,
16337 mapping, "mapping");
16338 cmdline_parse_token_string_t cmd_pctype_mapping_update_update =
16339 TOKEN_STRING_INITIALIZER
16340 (struct cmd_pctype_mapping_update_result,
16342 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type =
16343 TOKEN_STRING_INITIALIZER
16344 (struct cmd_pctype_mapping_update_result,
16345 pctype_list, NULL);
16346 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type =
16347 TOKEN_NUM_INITIALIZER
16348 (struct cmd_pctype_mapping_update_result,
16349 flow_type, UINT16);
16352 cmd_pctype_mapping_update_parsed(
16353 void *parsed_result,
16354 __attribute__((unused)) struct cmdline *cl,
16355 __attribute__((unused)) void *data)
16357 struct cmd_pctype_mapping_update_result *res = parsed_result;
16358 int ret = -ENOTSUP;
16359 #ifdef RTE_LIBRTE_I40E_PMD
16360 struct rte_pmd_i40e_flow_type_mapping mapping;
16362 unsigned int nb_item;
16363 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16366 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16369 #ifdef RTE_LIBRTE_I40E_PMD
16370 nb_item = parse_item_list(res->pctype_list, "pctypes",
16371 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1);
16372 mapping.flow_type = res->flow_type;
16373 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++)
16374 mapping.pctype |= (1ULL << pctype_list[i]);
16375 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id,
16385 printf("invalid pctype or flow type\n");
16388 printf("invalid port_id %d\n", res->port_id);
16391 printf("function not implemented\n");
16394 printf("programming error: (%s)\n", strerror(-ret));
16398 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16399 .f = cmd_pctype_mapping_update_parsed,
16401 .help_str = "port config <port_id> pctype mapping update"
16402 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16404 (void *)&cmd_pctype_mapping_update_port,
16405 (void *)&cmd_pctype_mapping_update_config,
16406 (void *)&cmd_pctype_mapping_update_port_id,
16407 (void *)&cmd_pctype_mapping_update_pctype,
16408 (void *)&cmd_pctype_mapping_update_mapping,
16409 (void *)&cmd_pctype_mapping_update_update,
16410 (void *)&cmd_pctype_mapping_update_pc_type,
16411 (void *)&cmd_pctype_mapping_update_flow_type,
16416 /* ptype mapping get */
16418 /* Common result structure for ptype mapping get */
16419 struct cmd_ptype_mapping_get_result {
16420 cmdline_fixed_string_t ptype;
16421 cmdline_fixed_string_t mapping;
16422 cmdline_fixed_string_t get;
16424 uint8_t valid_only;
16427 /* Common CLI fields for ptype mapping get */
16428 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype =
16429 TOKEN_STRING_INITIALIZER
16430 (struct cmd_ptype_mapping_get_result,
16432 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping =
16433 TOKEN_STRING_INITIALIZER
16434 (struct cmd_ptype_mapping_get_result,
16435 mapping, "mapping");
16436 cmdline_parse_token_string_t cmd_ptype_mapping_get_get =
16437 TOKEN_STRING_INITIALIZER
16438 (struct cmd_ptype_mapping_get_result,
16440 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16441 TOKEN_NUM_INITIALIZER
16442 (struct cmd_ptype_mapping_get_result,
16444 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only =
16445 TOKEN_NUM_INITIALIZER
16446 (struct cmd_ptype_mapping_get_result,
16447 valid_only, UINT8);
16450 cmd_ptype_mapping_get_parsed(
16451 void *parsed_result,
16452 __attribute__((unused)) struct cmdline *cl,
16453 __attribute__((unused)) void *data)
16455 struct cmd_ptype_mapping_get_result *res = parsed_result;
16456 int ret = -ENOTSUP;
16457 #ifdef RTE_LIBRTE_I40E_PMD
16458 int max_ptype_num = 256;
16459 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num];
16464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16467 #ifdef RTE_LIBRTE_I40E_PMD
16468 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16479 printf("invalid port_id %d\n", res->port_id);
16482 printf("function not implemented\n");
16485 printf("programming error: (%s)\n", strerror(-ret));
16488 #ifdef RTE_LIBRTE_I40E_PMD
16490 for (i = 0; i < count; i++)
16491 printf("%3d\t0x%08x\n",
16492 mapping[i].hw_ptype, mapping[i].sw_ptype);
16497 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16498 .f = cmd_ptype_mapping_get_parsed,
16500 .help_str = "ptype mapping get <port_id> <valid_only>",
16502 (void *)&cmd_ptype_mapping_get_ptype,
16503 (void *)&cmd_ptype_mapping_get_mapping,
16504 (void *)&cmd_ptype_mapping_get_get,
16505 (void *)&cmd_ptype_mapping_get_port_id,
16506 (void *)&cmd_ptype_mapping_get_valid_only,
16511 /* ptype mapping replace */
16513 /* Common result structure for ptype mapping replace */
16514 struct cmd_ptype_mapping_replace_result {
16515 cmdline_fixed_string_t ptype;
16516 cmdline_fixed_string_t mapping;
16517 cmdline_fixed_string_t replace;
16524 /* Common CLI fields for ptype mapping replace */
16525 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype =
16526 TOKEN_STRING_INITIALIZER
16527 (struct cmd_ptype_mapping_replace_result,
16529 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping =
16530 TOKEN_STRING_INITIALIZER
16531 (struct cmd_ptype_mapping_replace_result,
16532 mapping, "mapping");
16533 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace =
16534 TOKEN_STRING_INITIALIZER
16535 (struct cmd_ptype_mapping_replace_result,
16536 replace, "replace");
16537 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id =
16538 TOKEN_NUM_INITIALIZER
16539 (struct cmd_ptype_mapping_replace_result,
16541 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16542 TOKEN_NUM_INITIALIZER
16543 (struct cmd_ptype_mapping_replace_result,
16545 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16546 TOKEN_NUM_INITIALIZER
16547 (struct cmd_ptype_mapping_replace_result,
16549 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16550 TOKEN_NUM_INITIALIZER
16551 (struct cmd_ptype_mapping_replace_result,
16555 cmd_ptype_mapping_replace_parsed(
16556 void *parsed_result,
16557 __attribute__((unused)) struct cmdline *cl,
16558 __attribute__((unused)) void *data)
16560 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16561 int ret = -ENOTSUP;
16563 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16566 #ifdef RTE_LIBRTE_I40E_PMD
16567 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16577 printf("invalid ptype 0x%8x or 0x%8x\n",
16578 res->target, res->pkt_type);
16581 printf("invalid port_id %d\n", res->port_id);
16584 printf("function not implemented\n");
16587 printf("programming error: (%s)\n", strerror(-ret));
16591 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16592 .f = cmd_ptype_mapping_replace_parsed,
16595 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16597 (void *)&cmd_ptype_mapping_replace_ptype,
16598 (void *)&cmd_ptype_mapping_replace_mapping,
16599 (void *)&cmd_ptype_mapping_replace_replace,
16600 (void *)&cmd_ptype_mapping_replace_port_id,
16601 (void *)&cmd_ptype_mapping_replace_target,
16602 (void *)&cmd_ptype_mapping_replace_mask,
16603 (void *)&cmd_ptype_mapping_replace_pkt_type,
16608 /* ptype mapping reset */
16610 /* Common result structure for ptype mapping reset */
16611 struct cmd_ptype_mapping_reset_result {
16612 cmdline_fixed_string_t ptype;
16613 cmdline_fixed_string_t mapping;
16614 cmdline_fixed_string_t reset;
16618 /* Common CLI fields for ptype mapping reset*/
16619 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype =
16620 TOKEN_STRING_INITIALIZER
16621 (struct cmd_ptype_mapping_reset_result,
16623 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping =
16624 TOKEN_STRING_INITIALIZER
16625 (struct cmd_ptype_mapping_reset_result,
16626 mapping, "mapping");
16627 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset =
16628 TOKEN_STRING_INITIALIZER
16629 (struct cmd_ptype_mapping_reset_result,
16631 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16632 TOKEN_NUM_INITIALIZER
16633 (struct cmd_ptype_mapping_reset_result,
16637 cmd_ptype_mapping_reset_parsed(
16638 void *parsed_result,
16639 __attribute__((unused)) struct cmdline *cl,
16640 __attribute__((unused)) void *data)
16642 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16643 int ret = -ENOTSUP;
16645 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16648 #ifdef RTE_LIBRTE_I40E_PMD
16649 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16656 printf("invalid port_id %d\n", res->port_id);
16659 printf("function not implemented\n");
16662 printf("programming error: (%s)\n", strerror(-ret));
16666 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16667 .f = cmd_ptype_mapping_reset_parsed,
16669 .help_str = "ptype mapping reset <port_id>",
16671 (void *)&cmd_ptype_mapping_reset_ptype,
16672 (void *)&cmd_ptype_mapping_reset_mapping,
16673 (void *)&cmd_ptype_mapping_reset_reset,
16674 (void *)&cmd_ptype_mapping_reset_port_id,
16679 /* ptype mapping update */
16681 /* Common result structure for ptype mapping update */
16682 struct cmd_ptype_mapping_update_result {
16683 cmdline_fixed_string_t ptype;
16684 cmdline_fixed_string_t mapping;
16685 cmdline_fixed_string_t reset;
16691 /* Common CLI fields for ptype mapping update*/
16692 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype =
16693 TOKEN_STRING_INITIALIZER
16694 (struct cmd_ptype_mapping_update_result,
16696 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping =
16697 TOKEN_STRING_INITIALIZER
16698 (struct cmd_ptype_mapping_update_result,
16699 mapping, "mapping");
16700 cmdline_parse_token_string_t cmd_ptype_mapping_update_update =
16701 TOKEN_STRING_INITIALIZER
16702 (struct cmd_ptype_mapping_update_result,
16704 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16705 TOKEN_NUM_INITIALIZER
16706 (struct cmd_ptype_mapping_update_result,
16708 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16709 TOKEN_NUM_INITIALIZER
16710 (struct cmd_ptype_mapping_update_result,
16712 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16713 TOKEN_NUM_INITIALIZER
16714 (struct cmd_ptype_mapping_update_result,
16718 cmd_ptype_mapping_update_parsed(
16719 void *parsed_result,
16720 __attribute__((unused)) struct cmdline *cl,
16721 __attribute__((unused)) void *data)
16723 struct cmd_ptype_mapping_update_result *res = parsed_result;
16724 int ret = -ENOTSUP;
16725 #ifdef RTE_LIBRTE_I40E_PMD
16726 struct rte_pmd_i40e_ptype_mapping mapping;
16728 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16731 #ifdef RTE_LIBRTE_I40E_PMD
16732 mapping.hw_ptype = res->hw_ptype;
16733 mapping.sw_ptype = res->sw_ptype;
16734 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id,
16744 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16747 printf("invalid port_id %d\n", res->port_id);
16750 printf("function not implemented\n");
16753 printf("programming error: (%s)\n", strerror(-ret));
16757 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16758 .f = cmd_ptype_mapping_update_parsed,
16760 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16762 (void *)&cmd_ptype_mapping_update_ptype,
16763 (void *)&cmd_ptype_mapping_update_mapping,
16764 (void *)&cmd_ptype_mapping_update_update,
16765 (void *)&cmd_ptype_mapping_update_port_id,
16766 (void *)&cmd_ptype_mapping_update_hw_ptype,
16767 (void *)&cmd_ptype_mapping_update_sw_ptype,
16772 /* Common result structure for file commands */
16773 struct cmd_cmdfile_result {
16774 cmdline_fixed_string_t load;
16775 cmdline_fixed_string_t filename;
16778 /* Common CLI fields for file commands */
16779 cmdline_parse_token_string_t cmd_load_cmdfile =
16780 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
16781 cmdline_parse_token_string_t cmd_load_cmdfile_filename =
16782 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
16785 cmd_load_from_file_parsed(
16786 void *parsed_result,
16787 __attribute__((unused)) struct cmdline *cl,
16788 __attribute__((unused)) void *data)
16790 struct cmd_cmdfile_result *res = parsed_result;
16792 cmdline_read_from_file(res->filename);
16795 cmdline_parse_inst_t cmd_load_from_file = {
16796 .f = cmd_load_from_file_parsed,
16798 .help_str = "load <filename>",
16800 (void *)&cmd_load_cmdfile,
16801 (void *)&cmd_load_cmdfile_filename,
16806 /* Get Rx offloads capabilities */
16807 struct cmd_rx_offload_get_capa_result {
16808 cmdline_fixed_string_t show;
16809 cmdline_fixed_string_t port;
16811 cmdline_fixed_string_t rx_offload;
16812 cmdline_fixed_string_t capabilities;
16815 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16816 TOKEN_STRING_INITIALIZER
16817 (struct cmd_rx_offload_get_capa_result,
16819 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16820 TOKEN_STRING_INITIALIZER
16821 (struct cmd_rx_offload_get_capa_result,
16823 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
16824 TOKEN_NUM_INITIALIZER
16825 (struct cmd_rx_offload_get_capa_result,
16827 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
16828 TOKEN_STRING_INITIALIZER
16829 (struct cmd_rx_offload_get_capa_result,
16830 rx_offload, "rx_offload");
16831 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
16832 TOKEN_STRING_INITIALIZER
16833 (struct cmd_rx_offload_get_capa_result,
16834 capabilities, "capabilities");
16837 print_rx_offloads(uint64_t offloads)
16839 uint64_t single_offload;
16847 begin = __builtin_ctzll(offloads);
16848 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16850 single_offload = 1 << begin;
16851 for (bit = begin; bit < end; bit++) {
16852 if (offloads & single_offload)
16854 rte_eth_dev_rx_offload_name(single_offload));
16855 single_offload <<= 1;
16860 cmd_rx_offload_get_capa_parsed(
16861 void *parsed_result,
16862 __attribute__((unused)) struct cmdline *cl,
16863 __attribute__((unused)) void *data)
16865 struct cmd_rx_offload_get_capa_result *res = parsed_result;
16866 struct rte_eth_dev_info dev_info;
16867 portid_t port_id = res->port_id;
16868 uint64_t queue_offloads;
16869 uint64_t port_offloads;
16871 rte_eth_dev_info_get(port_id, &dev_info);
16872 queue_offloads = dev_info.rx_queue_offload_capa;
16873 port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
16875 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16876 printf(" Per Queue :");
16877 print_rx_offloads(queue_offloads);
16880 printf(" Per Port :");
16881 print_rx_offloads(port_offloads);
16885 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16886 .f = cmd_rx_offload_get_capa_parsed,
16888 .help_str = "show port <port_id> rx_offload capabilities",
16890 (void *)&cmd_rx_offload_get_capa_show,
16891 (void *)&cmd_rx_offload_get_capa_port,
16892 (void *)&cmd_rx_offload_get_capa_port_id,
16893 (void *)&cmd_rx_offload_get_capa_rx_offload,
16894 (void *)&cmd_rx_offload_get_capa_capabilities,
16899 /* Get Rx offloads configuration */
16900 struct cmd_rx_offload_get_configuration_result {
16901 cmdline_fixed_string_t show;
16902 cmdline_fixed_string_t port;
16904 cmdline_fixed_string_t rx_offload;
16905 cmdline_fixed_string_t configuration;
16908 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16909 TOKEN_STRING_INITIALIZER
16910 (struct cmd_rx_offload_get_configuration_result,
16912 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16913 TOKEN_STRING_INITIALIZER
16914 (struct cmd_rx_offload_get_configuration_result,
16916 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
16917 TOKEN_NUM_INITIALIZER
16918 (struct cmd_rx_offload_get_configuration_result,
16920 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
16921 TOKEN_STRING_INITIALIZER
16922 (struct cmd_rx_offload_get_configuration_result,
16923 rx_offload, "rx_offload");
16924 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
16925 TOKEN_STRING_INITIALIZER
16926 (struct cmd_rx_offload_get_configuration_result,
16927 configuration, "configuration");
16930 cmd_rx_offload_get_configuration_parsed(
16931 void *parsed_result,
16932 __attribute__((unused)) struct cmdline *cl,
16933 __attribute__((unused)) void *data)
16935 struct cmd_rx_offload_get_configuration_result *res = parsed_result;
16936 struct rte_eth_dev_info dev_info;
16937 portid_t port_id = res->port_id;
16938 struct rte_port *port = &ports[port_id];
16939 uint64_t port_offloads;
16940 uint64_t queue_offloads;
16941 uint16_t nb_rx_queues;
16944 printf("Rx Offloading Configuration of port %d :\n", port_id);
16946 port_offloads = port->dev_conf.rxmode.offloads;
16948 print_rx_offloads(port_offloads);
16951 rte_eth_dev_info_get(port_id, &dev_info);
16952 nb_rx_queues = dev_info.nb_rx_queues;
16953 for (q = 0; q < nb_rx_queues; q++) {
16954 queue_offloads = port->rx_conf[q].offloads;
16955 printf(" Queue[%2d] :", q);
16956 print_rx_offloads(queue_offloads);
16962 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16963 .f = cmd_rx_offload_get_configuration_parsed,
16965 .help_str = "show port <port_id> rx_offload configuration",
16967 (void *)&cmd_rx_offload_get_configuration_show,
16968 (void *)&cmd_rx_offload_get_configuration_port,
16969 (void *)&cmd_rx_offload_get_configuration_port_id,
16970 (void *)&cmd_rx_offload_get_configuration_rx_offload,
16971 (void *)&cmd_rx_offload_get_configuration_configuration,
16976 /* Enable/Disable a per port offloading */
16977 struct cmd_config_per_port_rx_offload_result {
16978 cmdline_fixed_string_t port;
16979 cmdline_fixed_string_t config;
16981 cmdline_fixed_string_t rx_offload;
16982 cmdline_fixed_string_t offload;
16983 cmdline_fixed_string_t on_off;
16986 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
16987 TOKEN_STRING_INITIALIZER
16988 (struct cmd_config_per_port_rx_offload_result,
16990 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
16991 TOKEN_STRING_INITIALIZER
16992 (struct cmd_config_per_port_rx_offload_result,
16994 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
16995 TOKEN_NUM_INITIALIZER
16996 (struct cmd_config_per_port_rx_offload_result,
16998 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
16999 TOKEN_STRING_INITIALIZER
17000 (struct cmd_config_per_port_rx_offload_result,
17001 rx_offload, "rx_offload");
17002 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
17003 TOKEN_STRING_INITIALIZER
17004 (struct cmd_config_per_port_rx_offload_result,
17005 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17006 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17007 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17008 "crc_strip#scatter#timestamp#security");
17009 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
17010 TOKEN_STRING_INITIALIZER
17011 (struct cmd_config_per_port_rx_offload_result,
17015 search_rx_offload(const char *name)
17017 uint64_t single_offload;
17018 const char *single_name;
17022 single_offload = 1;
17023 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17024 single_name = rte_eth_dev_rx_offload_name(single_offload);
17025 if (!strcasecmp(single_name, name)) {
17028 } else if (!strcasecmp(single_name, "UNKNOWN"))
17030 else if (single_name == NULL)
17032 single_offload <<= 1;
17036 return single_offload;
17042 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17043 __attribute__((unused)) struct cmdline *cl,
17044 __attribute__((unused)) void *data)
17046 struct cmd_config_per_port_rx_offload_result *res = parsed_result;
17047 portid_t port_id = res->port_id;
17048 struct rte_eth_dev_info dev_info;
17049 struct rte_port *port = &ports[port_id];
17050 uint64_t single_offload;
17051 uint16_t nb_rx_queues;
17054 if (port->port_status != RTE_PORT_STOPPED) {
17055 printf("Error: Can't config offload when Port %d "
17056 "is not stopped\n", port_id);
17060 single_offload = search_rx_offload(res->offload);
17061 if (single_offload == 0) {
17062 printf("Unknown offload name: %s\n", res->offload);
17066 rte_eth_dev_info_get(port_id, &dev_info);
17067 nb_rx_queues = dev_info.nb_rx_queues;
17068 if (!strcmp(res->on_off, "on")) {
17069 port->dev_conf.rxmode.offloads |= single_offload;
17070 for (q = 0; q < nb_rx_queues; q++)
17071 port->rx_conf[q].offloads |= single_offload;
17073 port->dev_conf.rxmode.offloads &= ~single_offload;
17074 for (q = 0; q < nb_rx_queues; q++)
17075 port->rx_conf[q].offloads &= ~single_offload;
17078 cmd_reconfig_device_queue(port_id, 1, 1);
17081 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17082 .f = cmd_config_per_port_rx_offload_parsed,
17084 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|"
17085 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17086 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17087 "jumbo_frame|crc_strip|scatter|timestamp|security "
17090 (void *)&cmd_config_per_port_rx_offload_result_port,
17091 (void *)&cmd_config_per_port_rx_offload_result_config,
17092 (void *)&cmd_config_per_port_rx_offload_result_port_id,
17093 (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
17094 (void *)&cmd_config_per_port_rx_offload_result_offload,
17095 (void *)&cmd_config_per_port_rx_offload_result_on_off,
17100 /* Enable/Disable a per queue offloading */
17101 struct cmd_config_per_queue_rx_offload_result {
17102 cmdline_fixed_string_t port;
17104 cmdline_fixed_string_t rxq;
17106 cmdline_fixed_string_t rx_offload;
17107 cmdline_fixed_string_t offload;
17108 cmdline_fixed_string_t on_off;
17111 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
17112 TOKEN_STRING_INITIALIZER
17113 (struct cmd_config_per_queue_rx_offload_result,
17115 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
17116 TOKEN_NUM_INITIALIZER
17117 (struct cmd_config_per_queue_rx_offload_result,
17119 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
17120 TOKEN_STRING_INITIALIZER
17121 (struct cmd_config_per_queue_rx_offload_result,
17123 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
17124 TOKEN_NUM_INITIALIZER
17125 (struct cmd_config_per_queue_rx_offload_result,
17127 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
17128 TOKEN_STRING_INITIALIZER
17129 (struct cmd_config_per_queue_rx_offload_result,
17130 rx_offload, "rx_offload");
17131 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
17132 TOKEN_STRING_INITIALIZER
17133 (struct cmd_config_per_queue_rx_offload_result,
17134 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
17135 "qinq_strip#outer_ipv4_cksum#macsec_strip#"
17136 "header_split#vlan_filter#vlan_extend#jumbo_frame#"
17137 "crc_strip#scatter#timestamp#security");
17138 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
17139 TOKEN_STRING_INITIALIZER
17140 (struct cmd_config_per_queue_rx_offload_result,
17144 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17145 __attribute__((unused)) struct cmdline *cl,
17146 __attribute__((unused)) void *data)
17148 struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
17149 struct rte_eth_dev_info dev_info;
17150 portid_t port_id = res->port_id;
17151 uint16_t queue_id = res->queue_id;
17152 struct rte_port *port = &ports[port_id];
17153 uint64_t single_offload;
17155 if (port->port_status != RTE_PORT_STOPPED) {
17156 printf("Error: Can't config offload when Port %d "
17157 "is not stopped\n", port_id);
17161 rte_eth_dev_info_get(port_id, &dev_info);
17162 if (queue_id >= dev_info.nb_rx_queues) {
17163 printf("Error: input queue_id should be 0 ... "
17164 "%d\n", dev_info.nb_rx_queues - 1);
17168 single_offload = search_rx_offload(res->offload);
17169 if (single_offload == 0) {
17170 printf("Unknown offload name: %s\n", res->offload);
17174 if (!strcmp(res->on_off, "on"))
17175 port->rx_conf[queue_id].offloads |= single_offload;
17177 port->rx_conf[queue_id].offloads &= ~single_offload;
17179 cmd_reconfig_device_queue(port_id, 1, 1);
17182 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17183 .f = cmd_config_per_queue_rx_offload_parsed,
17185 .help_str = "port <port_id> rxq <queue_id> rx_offload "
17186 "vlan_strip|ipv4_cksum|"
17187 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
17188 "macsec_strip|header_split|vlan_filter|vlan_extend|"
17189 "jumbo_frame|crc_strip|scatter|timestamp|security "
17192 (void *)&cmd_config_per_queue_rx_offload_result_port,
17193 (void *)&cmd_config_per_queue_rx_offload_result_port_id,
17194 (void *)&cmd_config_per_queue_rx_offload_result_rxq,
17195 (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
17196 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
17197 (void *)&cmd_config_per_queue_rx_offload_result_offload,
17198 (void *)&cmd_config_per_queue_rx_offload_result_on_off,
17203 /* Get Tx offloads capabilities */
17204 struct cmd_tx_offload_get_capa_result {
17205 cmdline_fixed_string_t show;
17206 cmdline_fixed_string_t port;
17208 cmdline_fixed_string_t tx_offload;
17209 cmdline_fixed_string_t capabilities;
17212 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17213 TOKEN_STRING_INITIALIZER
17214 (struct cmd_tx_offload_get_capa_result,
17216 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17217 TOKEN_STRING_INITIALIZER
17218 (struct cmd_tx_offload_get_capa_result,
17220 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
17221 TOKEN_NUM_INITIALIZER
17222 (struct cmd_tx_offload_get_capa_result,
17224 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
17225 TOKEN_STRING_INITIALIZER
17226 (struct cmd_tx_offload_get_capa_result,
17227 tx_offload, "tx_offload");
17228 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
17229 TOKEN_STRING_INITIALIZER
17230 (struct cmd_tx_offload_get_capa_result,
17231 capabilities, "capabilities");
17234 print_tx_offloads(uint64_t offloads)
17236 uint64_t single_offload;
17244 begin = __builtin_ctzll(offloads);
17245 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17247 single_offload = 1 << begin;
17248 for (bit = begin; bit < end; bit++) {
17249 if (offloads & single_offload)
17251 rte_eth_dev_tx_offload_name(single_offload));
17252 single_offload <<= 1;
17257 cmd_tx_offload_get_capa_parsed(
17258 void *parsed_result,
17259 __attribute__((unused)) struct cmdline *cl,
17260 __attribute__((unused)) void *data)
17262 struct cmd_tx_offload_get_capa_result *res = parsed_result;
17263 struct rte_eth_dev_info dev_info;
17264 portid_t port_id = res->port_id;
17265 uint64_t queue_offloads;
17266 uint64_t port_offloads;
17268 rte_eth_dev_info_get(port_id, &dev_info);
17269 queue_offloads = dev_info.tx_queue_offload_capa;
17270 port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
17272 printf("Tx Offloading Capabilities of port %d :\n", port_id);
17273 printf(" Per Queue :");
17274 print_tx_offloads(queue_offloads);
17277 printf(" Per Port :");
17278 print_tx_offloads(port_offloads);
17282 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
17283 .f = cmd_tx_offload_get_capa_parsed,
17285 .help_str = "show port <port_id> tx_offload capabilities",
17287 (void *)&cmd_tx_offload_get_capa_show,
17288 (void *)&cmd_tx_offload_get_capa_port,
17289 (void *)&cmd_tx_offload_get_capa_port_id,
17290 (void *)&cmd_tx_offload_get_capa_tx_offload,
17291 (void *)&cmd_tx_offload_get_capa_capabilities,
17296 /* Get Tx offloads configuration */
17297 struct cmd_tx_offload_get_configuration_result {
17298 cmdline_fixed_string_t show;
17299 cmdline_fixed_string_t port;
17301 cmdline_fixed_string_t tx_offload;
17302 cmdline_fixed_string_t configuration;
17305 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
17306 TOKEN_STRING_INITIALIZER
17307 (struct cmd_tx_offload_get_configuration_result,
17309 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
17310 TOKEN_STRING_INITIALIZER
17311 (struct cmd_tx_offload_get_configuration_result,
17313 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
17314 TOKEN_NUM_INITIALIZER
17315 (struct cmd_tx_offload_get_configuration_result,
17317 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
17318 TOKEN_STRING_INITIALIZER
17319 (struct cmd_tx_offload_get_configuration_result,
17320 tx_offload, "tx_offload");
17321 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
17322 TOKEN_STRING_INITIALIZER
17323 (struct cmd_tx_offload_get_configuration_result,
17324 configuration, "configuration");
17327 cmd_tx_offload_get_configuration_parsed(
17328 void *parsed_result,
17329 __attribute__((unused)) struct cmdline *cl,
17330 __attribute__((unused)) void *data)
17332 struct cmd_tx_offload_get_configuration_result *res = parsed_result;
17333 struct rte_eth_dev_info dev_info;
17334 portid_t port_id = res->port_id;
17335 struct rte_port *port = &ports[port_id];
17336 uint64_t port_offloads;
17337 uint64_t queue_offloads;
17338 uint16_t nb_tx_queues;
17341 printf("Tx Offloading Configuration of port %d :\n", port_id);
17343 port_offloads = port->dev_conf.txmode.offloads;
17345 print_tx_offloads(port_offloads);
17348 rte_eth_dev_info_get(port_id, &dev_info);
17349 nb_tx_queues = dev_info.nb_tx_queues;
17350 for (q = 0; q < nb_tx_queues; q++) {
17351 queue_offloads = port->tx_conf[q].offloads;
17352 printf(" Queue[%2d] :", q);
17353 print_tx_offloads(queue_offloads);
17359 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17360 .f = cmd_tx_offload_get_configuration_parsed,
17362 .help_str = "show port <port_id> tx_offload configuration",
17364 (void *)&cmd_tx_offload_get_configuration_show,
17365 (void *)&cmd_tx_offload_get_configuration_port,
17366 (void *)&cmd_tx_offload_get_configuration_port_id,
17367 (void *)&cmd_tx_offload_get_configuration_tx_offload,
17368 (void *)&cmd_tx_offload_get_configuration_configuration,
17373 /* Enable/Disable a per port offloading */
17374 struct cmd_config_per_port_tx_offload_result {
17375 cmdline_fixed_string_t port;
17376 cmdline_fixed_string_t config;
17378 cmdline_fixed_string_t tx_offload;
17379 cmdline_fixed_string_t offload;
17380 cmdline_fixed_string_t on_off;
17383 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
17384 TOKEN_STRING_INITIALIZER
17385 (struct cmd_config_per_port_tx_offload_result,
17387 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
17388 TOKEN_STRING_INITIALIZER
17389 (struct cmd_config_per_port_tx_offload_result,
17391 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
17392 TOKEN_NUM_INITIALIZER
17393 (struct cmd_config_per_port_tx_offload_result,
17395 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
17396 TOKEN_STRING_INITIALIZER
17397 (struct cmd_config_per_port_tx_offload_result,
17398 tx_offload, "tx_offload");
17399 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
17400 TOKEN_STRING_INITIALIZER
17401 (struct cmd_config_per_port_tx_offload_result,
17402 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17403 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17404 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17405 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17406 "mt_lockfree#multi_segs#fast_free#security");
17407 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
17408 TOKEN_STRING_INITIALIZER
17409 (struct cmd_config_per_port_tx_offload_result,
17413 search_tx_offload(const char *name)
17415 uint64_t single_offload;
17416 const char *single_name;
17420 single_offload = 1;
17421 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
17422 single_name = rte_eth_dev_tx_offload_name(single_offload);
17423 if (!strcasecmp(single_name, name)) {
17426 } else if (!strcasecmp(single_name, "UNKNOWN"))
17428 else if (single_name == NULL)
17430 single_offload <<= 1;
17434 return single_offload;
17440 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17441 __attribute__((unused)) struct cmdline *cl,
17442 __attribute__((unused)) void *data)
17444 struct cmd_config_per_port_tx_offload_result *res = parsed_result;
17445 portid_t port_id = res->port_id;
17446 struct rte_eth_dev_info dev_info;
17447 struct rte_port *port = &ports[port_id];
17448 uint64_t single_offload;
17449 uint16_t nb_tx_queues;
17452 if (port->port_status != RTE_PORT_STOPPED) {
17453 printf("Error: Can't config offload when Port %d "
17454 "is not stopped\n", port_id);
17458 single_offload = search_tx_offload(res->offload);
17459 if (single_offload == 0) {
17460 printf("Unknown offload name: %s\n", res->offload);
17464 rte_eth_dev_info_get(port_id, &dev_info);
17465 nb_tx_queues = dev_info.nb_tx_queues;
17466 if (!strcmp(res->on_off, "on")) {
17467 port->dev_conf.txmode.offloads |= single_offload;
17468 for (q = 0; q < nb_tx_queues; q++)
17469 port->tx_conf[q].offloads |= single_offload;
17471 port->dev_conf.txmode.offloads &= ~single_offload;
17472 for (q = 0; q < nb_tx_queues; q++)
17473 port->tx_conf[q].offloads &= ~single_offload;
17476 cmd_reconfig_device_queue(port_id, 1, 1);
17479 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17480 .f = cmd_config_per_port_tx_offload_parsed,
17482 .help_str = "port config <port_id> tx_offload "
17483 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17484 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17485 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17486 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17487 "mt_lockfree|multi_segs|fast_free|security "
17490 (void *)&cmd_config_per_port_tx_offload_result_port,
17491 (void *)&cmd_config_per_port_tx_offload_result_config,
17492 (void *)&cmd_config_per_port_tx_offload_result_port_id,
17493 (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
17494 (void *)&cmd_config_per_port_tx_offload_result_offload,
17495 (void *)&cmd_config_per_port_tx_offload_result_on_off,
17500 /* Enable/Disable a per queue offloading */
17501 struct cmd_config_per_queue_tx_offload_result {
17502 cmdline_fixed_string_t port;
17504 cmdline_fixed_string_t txq;
17506 cmdline_fixed_string_t tx_offload;
17507 cmdline_fixed_string_t offload;
17508 cmdline_fixed_string_t on_off;
17511 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
17512 TOKEN_STRING_INITIALIZER
17513 (struct cmd_config_per_queue_tx_offload_result,
17515 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
17516 TOKEN_NUM_INITIALIZER
17517 (struct cmd_config_per_queue_tx_offload_result,
17519 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
17520 TOKEN_STRING_INITIALIZER
17521 (struct cmd_config_per_queue_tx_offload_result,
17523 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
17524 TOKEN_NUM_INITIALIZER
17525 (struct cmd_config_per_queue_tx_offload_result,
17527 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
17528 TOKEN_STRING_INITIALIZER
17529 (struct cmd_config_per_queue_tx_offload_result,
17530 tx_offload, "tx_offload");
17531 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
17532 TOKEN_STRING_INITIALIZER
17533 (struct cmd_config_per_queue_tx_offload_result,
17534 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
17535 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
17536 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
17537 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
17538 "mt_lockfree#multi_segs#fast_free#security");
17539 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
17540 TOKEN_STRING_INITIALIZER
17541 (struct cmd_config_per_queue_tx_offload_result,
17545 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17546 __attribute__((unused)) struct cmdline *cl,
17547 __attribute__((unused)) void *data)
17549 struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
17550 struct rte_eth_dev_info dev_info;
17551 portid_t port_id = res->port_id;
17552 uint16_t queue_id = res->queue_id;
17553 struct rte_port *port = &ports[port_id];
17554 uint64_t single_offload;
17556 if (port->port_status != RTE_PORT_STOPPED) {
17557 printf("Error: Can't config offload when Port %d "
17558 "is not stopped\n", port_id);
17562 rte_eth_dev_info_get(port_id, &dev_info);
17563 if (queue_id >= dev_info.nb_tx_queues) {
17564 printf("Error: input queue_id should be 0 ... "
17565 "%d\n", dev_info.nb_tx_queues - 1);
17569 single_offload = search_tx_offload(res->offload);
17570 if (single_offload == 0) {
17571 printf("Unknown offload name: %s\n", res->offload);
17575 if (!strcmp(res->on_off, "on"))
17576 port->tx_conf[queue_id].offloads |= single_offload;
17578 port->tx_conf[queue_id].offloads &= ~single_offload;
17580 cmd_reconfig_device_queue(port_id, 1, 1);
17583 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17584 .f = cmd_config_per_queue_tx_offload_parsed,
17586 .help_str = "port <port_id> txq <queue_id> tx_offload "
17587 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
17588 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
17589 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
17590 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
17591 "mt_lockfree|multi_segs|fast_free|security "
17594 (void *)&cmd_config_per_queue_tx_offload_result_port,
17595 (void *)&cmd_config_per_queue_tx_offload_result_port_id,
17596 (void *)&cmd_config_per_queue_tx_offload_result_txq,
17597 (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
17598 (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
17599 (void *)&cmd_config_per_queue_tx_offload_result_offload,
17600 (void *)&cmd_config_per_queue_tx_offload_result_on_off,
17605 /* ******************************************************************************** */
17607 /* list of instructions */
17608 cmdline_parse_ctx_t main_ctx[] = {
17609 (cmdline_parse_inst_t *)&cmd_help_brief,
17610 (cmdline_parse_inst_t *)&cmd_help_long,
17611 (cmdline_parse_inst_t *)&cmd_quit,
17612 (cmdline_parse_inst_t *)&cmd_load_from_file,
17613 (cmdline_parse_inst_t *)&cmd_showport,
17614 (cmdline_parse_inst_t *)&cmd_showqueue,
17615 (cmdline_parse_inst_t *)&cmd_showportall,
17616 (cmdline_parse_inst_t *)&cmd_showcfg,
17617 (cmdline_parse_inst_t *)&cmd_start,
17618 (cmdline_parse_inst_t *)&cmd_start_tx_first,
17619 (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
17620 (cmdline_parse_inst_t *)&cmd_set_link_up,
17621 (cmdline_parse_inst_t *)&cmd_set_link_down,
17622 (cmdline_parse_inst_t *)&cmd_reset,
17623 (cmdline_parse_inst_t *)&cmd_set_numbers,
17624 (cmdline_parse_inst_t *)&cmd_set_log,
17625 (cmdline_parse_inst_t *)&cmd_set_txpkts,
17626 (cmdline_parse_inst_t *)&cmd_set_txsplit,
17627 (cmdline_parse_inst_t *)&cmd_set_fwd_list,
17628 (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
17629 (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
17630 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
17631 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
17632 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
17633 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
17634 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
17635 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
17636 (cmdline_parse_inst_t *)&cmd_set_flush_rx,
17637 (cmdline_parse_inst_t *)&cmd_set_link_check,
17638 (cmdline_parse_inst_t *)&cmd_set_bypass_mode,
17639 (cmdline_parse_inst_t *)&cmd_set_bypass_event,
17640 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout,
17641 (cmdline_parse_inst_t *)&cmd_show_bypass_config,
17642 #ifdef RTE_LIBRTE_PMD_BOND
17643 (cmdline_parse_inst_t *) &cmd_set_bonding_mode,
17644 (cmdline_parse_inst_t *) &cmd_show_bonding_config,
17645 (cmdline_parse_inst_t *) &cmd_set_bonding_primary,
17646 (cmdline_parse_inst_t *) &cmd_add_bonding_slave,
17647 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave,
17648 (cmdline_parse_inst_t *) &cmd_create_bonded_device,
17649 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr,
17650 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy,
17651 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period,
17652 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues,
17653 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy,
17655 (cmdline_parse_inst_t *)&cmd_vlan_offload,
17656 (cmdline_parse_inst_t *)&cmd_vlan_tpid,
17657 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
17658 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
17659 (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
17660 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
17661 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
17662 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
17663 (cmdline_parse_inst_t *)&cmd_csum_set,
17664 (cmdline_parse_inst_t *)&cmd_csum_show,
17665 (cmdline_parse_inst_t *)&cmd_csum_tunnel,
17666 (cmdline_parse_inst_t *)&cmd_tso_set,
17667 (cmdline_parse_inst_t *)&cmd_tso_show,
17668 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
17669 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
17670 (cmdline_parse_inst_t *)&cmd_gro_enable,
17671 (cmdline_parse_inst_t *)&cmd_gro_flush,
17672 (cmdline_parse_inst_t *)&cmd_gro_show,
17673 (cmdline_parse_inst_t *)&cmd_gso_enable,
17674 (cmdline_parse_inst_t *)&cmd_gso_size,
17675 (cmdline_parse_inst_t *)&cmd_gso_show,
17676 (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
17677 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
17678 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
17679 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
17680 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
17681 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
17682 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
17683 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
17684 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
17685 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
17686 (cmdline_parse_inst_t *)&cmd_config_dcb,
17687 (cmdline_parse_inst_t *)&cmd_read_reg,
17688 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field,
17689 (cmdline_parse_inst_t *)&cmd_read_reg_bit,
17690 (cmdline_parse_inst_t *)&cmd_write_reg,
17691 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field,
17692 (cmdline_parse_inst_t *)&cmd_write_reg_bit,
17693 (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
17694 (cmdline_parse_inst_t *)&cmd_stop,
17695 (cmdline_parse_inst_t *)&cmd_mac_addr,
17696 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
17697 (cmdline_parse_inst_t *)&cmd_set_qmap,
17698 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
17699 (cmdline_parse_inst_t *)&cmd_operate_port,
17700 (cmdline_parse_inst_t *)&cmd_operate_specific_port,
17701 (cmdline_parse_inst_t *)&cmd_operate_attach_port,
17702 (cmdline_parse_inst_t *)&cmd_operate_detach_port,
17703 (cmdline_parse_inst_t *)&cmd_config_speed_all,
17704 (cmdline_parse_inst_t *)&cmd_config_speed_specific,
17705 (cmdline_parse_inst_t *)&cmd_config_loopback_all,
17706 (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
17707 (cmdline_parse_inst_t *)&cmd_config_rx_tx,
17708 (cmdline_parse_inst_t *)&cmd_config_mtu,
17709 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
17710 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
17711 (cmdline_parse_inst_t *)&cmd_config_rss,
17712 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
17713 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
17714 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
17715 (cmdline_parse_inst_t *)&cmd_config_rss_reta,
17716 (cmdline_parse_inst_t *)&cmd_showport_reta,
17717 (cmdline_parse_inst_t *)&cmd_config_burst,
17718 (cmdline_parse_inst_t *)&cmd_config_thresh,
17719 (cmdline_parse_inst_t *)&cmd_config_threshold,
17720 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
17721 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
17722 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
17723 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter,
17724 (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
17725 (cmdline_parse_inst_t *)&cmd_tunnel_filter,
17726 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
17727 (cmdline_parse_inst_t *)&cmd_global_config,
17728 (cmdline_parse_inst_t *)&cmd_set_mirror_mask,
17729 (cmdline_parse_inst_t *)&cmd_set_mirror_link,
17730 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
17731 (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
17732 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
17733 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
17734 (cmdline_parse_inst_t *)&cmd_dump,
17735 (cmdline_parse_inst_t *)&cmd_dump_one,
17736 (cmdline_parse_inst_t *)&cmd_ethertype_filter,
17737 (cmdline_parse_inst_t *)&cmd_syn_filter,
17738 (cmdline_parse_inst_t *)&cmd_2tuple_filter,
17739 (cmdline_parse_inst_t *)&cmd_5tuple_filter,
17740 (cmdline_parse_inst_t *)&cmd_flex_filter,
17741 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
17742 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
17743 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
17744 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director,
17745 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director,
17746 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director,
17747 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director,
17748 (cmdline_parse_inst_t *)&cmd_flush_flow_director,
17749 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask,
17750 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask,
17751 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask,
17752 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask,
17753 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload,
17754 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port,
17755 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
17756 (cmdline_parse_inst_t *)&cmd_get_hash_global_config,
17757 (cmdline_parse_inst_t *)&cmd_set_hash_global_config,
17758 (cmdline_parse_inst_t *)&cmd_set_hash_input_set,
17759 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
17760 (cmdline_parse_inst_t *)&cmd_flow,
17761 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
17762 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
17763 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
17764 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
17765 (cmdline_parse_inst_t *)&cmd_create_port_meter,
17766 (cmdline_parse_inst_t *)&cmd_enable_port_meter,
17767 (cmdline_parse_inst_t *)&cmd_disable_port_meter,
17768 (cmdline_parse_inst_t *)&cmd_del_port_meter,
17769 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
17770 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
17771 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action,
17772 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
17773 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
17774 (cmdline_parse_inst_t *)&cmd_mcast_addr,
17775 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
17776 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
17777 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
17778 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
17779 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en,
17780 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis,
17781 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis,
17782 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
17783 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
17784 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
17785 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
17786 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
17787 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
17788 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
17789 (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
17790 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
17791 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
17792 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on,
17793 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off,
17794 (cmdline_parse_inst_t *)&cmd_set_macsec_sc,
17795 (cmdline_parse_inst_t *)&cmd_set_macsec_sa,
17796 (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
17797 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
17798 (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
17799 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
17800 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
17801 (cmdline_parse_inst_t *)&cmd_set_vf_promisc,
17802 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti,
17803 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
17804 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
17805 (cmdline_parse_inst_t *)&cmd_vf_max_bw,
17806 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
17807 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
17808 (cmdline_parse_inst_t *)&cmd_strict_link_prio,
17809 (cmdline_parse_inst_t *)&cmd_tc_min_bw,
17810 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
17811 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default,
17813 (cmdline_parse_inst_t *)&cmd_set_vxlan,
17814 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
17815 (cmdline_parse_inst_t *)&cmd_set_nvgre,
17816 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
17817 (cmdline_parse_inst_t *)&cmd_ddp_add,
17818 (cmdline_parse_inst_t *)&cmd_ddp_del,
17819 (cmdline_parse_inst_t *)&cmd_ddp_get_list,
17820 (cmdline_parse_inst_t *)&cmd_ddp_get_info,
17821 (cmdline_parse_inst_t *)&cmd_cfg_input_set,
17822 (cmdline_parse_inst_t *)&cmd_clear_input_set,
17823 (cmdline_parse_inst_t *)&cmd_show_vf_stats,
17824 (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
17825 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get,
17826 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace,
17827 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset,
17828 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update,
17830 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get,
17831 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset,
17832 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update,
17833 (cmdline_parse_inst_t *)&cmd_queue_region,
17834 (cmdline_parse_inst_t *)&cmd_region_flowtype,
17835 (cmdline_parse_inst_t *)&cmd_user_priority_region,
17836 (cmdline_parse_inst_t *)&cmd_flush_queue_region,
17837 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all,
17838 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
17839 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
17840 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
17841 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
17842 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
17843 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
17844 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
17845 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
17846 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
17847 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
17848 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
17849 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
17850 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
17851 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
17852 (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
17853 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
17854 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
17855 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
17856 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
17857 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
17858 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
17859 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
17860 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
17861 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
17862 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
17863 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
17864 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
17865 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
17866 #ifdef RTE_LIBRTE_BPF
17867 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
17868 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
17873 /* read cmdline commands from file */
17875 cmdline_read_from_file(const char *filename)
17877 struct cmdline *cl;
17879 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17881 printf("Failed to create file based cmdline context: %s\n",
17886 cmdline_interact(cl);
17891 printf("Read CLI commands from %s\n", filename);
17894 /* prompt function, called from main on MASTER lcore */
17898 /* initialize non-constant commands */
17899 cmd_set_fwd_mode_init();
17900 cmd_set_fwd_retry_mode_init();
17902 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17903 if (testpmd_cl == NULL)
17905 cmdline_interact(testpmd_cl);
17906 cmdline_stdin_exit(testpmd_cl);
17912 if (testpmd_cl != NULL)
17913 cmdline_quit(testpmd_cl);
17917 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17919 if (id == (portid_t)RTE_PORT_ALL) {
17922 RTE_ETH_FOREACH_DEV(pid) {
17923 /* check if need_reconfig has been set to 1 */
17924 if (ports[pid].need_reconfig == 0)
17925 ports[pid].need_reconfig = dev;
17926 /* check if need_reconfig_queues has been set to 1 */
17927 if (ports[pid].need_reconfig_queues == 0)
17928 ports[pid].need_reconfig_queues = queue;
17930 } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
17931 /* check if need_reconfig has been set to 1 */
17932 if (ports[id].need_reconfig == 0)
17933 ports[id].need_reconfig = dev;
17934 /* check if need_reconfig_queues has been set to 1 */
17935 if (ports[id].need_reconfig_queues == 0)
17936 ports[id].need_reconfig_queues = queue;