]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/app/test-pmd/cmdline.c
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / dpdk / app / test-pmd / cmdline.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2016 Intel Corporation.
3 * Copyright(c) 2014 6WIND S.A.
4 */
5
6 #include <stdarg.h>
7 #include <errno.h>
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <string.h>
11 #include <termios.h>
12 #include <unistd.h>
13 #include <inttypes.h>
14 #ifndef __linux__
15 #ifndef __FreeBSD__
16 #include <net/socket.h>
17 #else
18 #include <sys/socket.h>
19 #endif
20 #endif
21 #include <netinet/in.h>
22
23 #include <sys/queue.h>
24
25 #include <rte_common.h>
26 #include <rte_byteorder.h>
27 #include <rte_log.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>
34 #include <rte_eal.h>
35 #include <rte_per_lcore.h>
36 #include <rte_lcore.h>
37 #include <rte_atomic.h>
38 #include <rte_branch_prediction.h>
39 #include <rte_ring.h>
40 #include <rte_mempool.h>
41 #include <rte_interrupts.h>
42 #include <rte_pci.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>
48 #include <rte_flow.h>
49 #include <rte_gro.h>
50
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>
58 #include <cmdline.h>
59 #ifdef RTE_LIBRTE_PMD_BOND
60 #include <rte_eth_bond.h>
61 #include <rte_eth_bond_8023ad.h>
62 #endif
63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD
64 #include <rte_pmd_dpaa.h>
65 #endif
66 #ifdef RTE_LIBRTE_IXGBE_PMD
67 #include <rte_pmd_ixgbe.h>
68 #endif
69 #ifdef RTE_LIBRTE_I40E_PMD
70 #include <rte_pmd_i40e.h>
71 #endif
72 #ifdef RTE_LIBRTE_BNXT_PMD
73 #include <rte_pmd_bnxt.h>
74 #endif
75 #include "testpmd.h"
76 #include "cmdline_mtr.h"
77 #include "cmdline_tm.h"
78 #include "bpf_cmd.h"
79
80 static struct cmdline *testpmd_cl;
81
82 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue);
83
84 /* *** Help command with introduction. *** */
85 struct cmd_help_brief_result {
86 cmdline_fixed_string_t help;
87 };
88
89 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result,
90 struct cmdline *cl,
91 __attribute__((unused)) void *data)
92 {
93 cmdline_printf(
94 cl,
95 "\n"
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 "
99 "information.\n"
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"
105 );
106
107 }
108
109 cmdline_parse_token_string_t cmd_help_brief_help =
110 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
111
112 cmdline_parse_inst_t cmd_help_brief = {
113 .f = cmd_help_brief_parsed,
114 .data = NULL,
115 .help_str = "help: Show help",
116 .tokens = {
117 (void *)&cmd_help_brief_help,
118 NULL,
119 },
120 };
121
122 /* *** Help command with help sections. *** */
123 struct cmd_help_long_result {
124 cmdline_fixed_string_t help;
125 cmdline_fixed_string_t section;
126 };
127
128 static void cmd_help_long_parsed(void *parsed_result,
129 struct cmdline *cl,
130 __attribute__((unused)) void *data)
131 {
132 int show_all = 0;
133 struct cmd_help_long_result *res = parsed_result;
134
135 if (!strcmp(res->section, "all"))
136 show_all = 1;
137
138 if (show_all || !strcmp(res->section, "control")) {
139
140 cmdline_printf(
141 cl,
142 "\n"
143 "Control forwarding:\n"
144 "-------------------\n\n"
145
146 "start\n"
147 " Start packet forwarding with current configuration.\n\n"
148
149 "start tx_first\n"
150 " Start packet forwarding with current config"
151 " after sending one burst of packets.\n\n"
152
153 "stop\n"
154 " Stop packet forwarding, and display accumulated"
155 " statistics.\n\n"
156
157 "quit\n"
158 " Quit to prompt.\n\n"
159 );
160 }
161
162 if (show_all || !strcmp(res->section, "display")) {
163
164 cmdline_printf(
165 cl,
166 "\n"
167 "Display:\n"
168 "--------\n\n"
169
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"
172
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"
177
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"
182 " of port X\n\n"
183
184 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n"
185 " Clear information for port_id, or all.\n\n"
186
187 "show (rxq|txq) info (port_id) (queue_id)\n"
188 " Display information for configured RX/TX queue.\n\n"
189
190 "show config (rxtx|cores|fwd|txpkts)\n"
191 " Display the given configuration.\n\n"
192
193 "read rxd (port_id) (queue_id) (rxd_id)\n"
194 " Display an RX descriptor of a port RX queue.\n\n"
195
196 "read txd (port_id) (queue_id) (txd_id)\n"
197 " Display a TX descriptor of a port TX queue.\n\n"
198
199 "ddp get list (port_id)\n"
200 " Get ddp profile info list\n\n"
201
202 "ddp get info (profile_path)\n"
203 " Get ddp profile information.\n\n"
204
205 "show vf stats (port_id) (vf_id)\n"
206 " Display a VF's statistics.\n\n"
207
208 "clear vf stats (port_id) (vf_id)\n"
209 " Reset a VF's statistics.\n\n"
210
211 "show port (port_id) pctype mapping\n"
212 " Get flow ptype to pctype mapping on a port\n\n"
213
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"
218
219 "show port tm level cap (port_id) (level_id)\n"
220 " Display the port TM hierarchical level capability.\n\n"
221
222 "show port tm node cap (port_id) (node_id)\n"
223 " Display the port TM node capability.\n\n"
224
225 "show port tm node type (port_id) (node_id)\n"
226 " Display the port TM node type.\n\n"
227
228 "show port tm node stats (port_id) (node_id) (clear)\n"
229 " Display the port TM node stats.\n\n"
230
231 );
232 }
233
234 if (show_all || !strcmp(res->section, "config")) {
235 cmdline_printf(
236 cl,
237 "\n"
238 "Configuration:\n"
239 "--------------\n"
240 "Configuration changes only become active when"
241 " forwarding is started/restarted.\n\n"
242
243 "set default\n"
244 " Reset forwarding to the default configuration.\n\n"
245
246 "set verbose (level)\n"
247 " Set the debug verbosity level X.\n\n"
248
249 "set log global|(type) (level)\n"
250 " Set the log level.\n\n"
251
252 "set nbport (num)\n"
253 " Set number of ports.\n\n"
254
255 "set nbcore (num)\n"
256 " Set number of cores.\n\n"
257
258 "set coremask (mask)\n"
259 " Set the forwarding cores hexadecimal mask.\n\n"
260
261 "set portmask (mask)\n"
262 " Set the forwarding ports hexadecimal mask.\n\n"
263
264 "set burst (num)\n"
265 " Set number of packets per burst.\n\n"
266
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"
270
271 "set txpkts (x[,y]*)\n"
272 " Set the length of each segment of TXONLY"
273 " and optionally CSUM packets.\n\n"
274
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"
278 " modes\n\n"
279
280 "set corelist (x[,y]*)\n"
281 " Set the list of forwarding cores.\n\n"
282
283 "set portlist (x[,y]*)\n"
284 " Set the list of forwarding ports.\n\n"
285
286 "set tx loopback (port_id) (on|off)\n"
287 " Enable or disable tx loopback.\n\n"
288
289 "set all queues drop (port_id) (on|off)\n"
290 " Set drop enable bit for all queues.\n\n"
291
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"
294
295 "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
296 " Set MAC antispoof for a VF from the PF.\n\n"
297
298 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n"
299 " Enable MACsec offload.\n\n"
300
301 "set macsec offload (port_id) off\n"
302 " Disable MACsec offload.\n\n"
303
304 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
305 " Configure MACsec secure connection (SC).\n\n"
306
307 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n"
308 " Configure MACsec secure association (SA).\n\n"
309
310 "set vf broadcast (port_id) (vf_id) (on|off)\n"
311 " Set VF broadcast for a VF from the PF.\n\n"
312
313 "vlan set strip (on|off) (port_id)\n"
314 " Set the VLAN strip on a port.\n\n"
315
316 "vlan set stripq (on|off) (port_id,queue_id)\n"
317 " Set the VLAN strip for a queue on a port.\n\n"
318
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"
321
322 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
323 " Set VLAN insert for a VF from the PF.\n\n"
324
325 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
326 " Set VLAN antispoof for a VF from the PF.\n\n"
327
328 "set vf vlan tag (port_id) (vf_id) (on|off)\n"
329 " Set VLAN tag for a VF from the PF.\n\n"
330
331 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n"
332 " Set a VF's max bandwidth(Mbps).\n\n"
333
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"
336
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"
339
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"
342
343 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n"
344 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n"
345
346 "vlan set filter (on|off) (port_id)\n"
347 " Set the VLAN filter on a port.\n\n"
348
349 "vlan set qinq (on|off) (port_id)\n"
350 " Set the VLAN QinQ (extended queue in queue)"
351 " on a port.\n\n"
352
353 "vlan set (inner|outer) tpid (value) (port_id)\n"
354 " Set the VLAN TPID for Packet Filtering on"
355 " a port\n\n"
356
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"
360
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"
364
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"
368
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"
372
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"
377
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"
382
383 "rx_vxlan_port add (udp_port) (port_id)\n"
384 " Add an UDP port for VXLAN packet filter on a port\n\n"
385
386 "rx_vxlan_port rm (udp_port) (port_id)\n"
387 " Remove an UDP port for VXLAN packet filter on a port\n\n"
388
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"
392
393 "tx_vlan set pvid port_id vlan_id (on|off)\n"
394 " Set port based TX VLAN insertion.\n\n"
395
396 "tx_vlan reset (port_id)\n"
397 " Disable hardware insertion of a VLAN header in"
398 " packets sent on a port.\n\n"
399
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"
409
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"
414 " engine.\n\n"
415
416 "csum show (port_id)\n"
417 " Display tx checksum offload configuration\n\n"
418
419 "tso set (segsize) (portid)\n"
420 " Enable TCP Segmentation Offload in csum forward"
421 " engine.\n"
422 " Please check the NIC datasheet for HW limits.\n\n"
423
424 "tso show (portid)"
425 " Display the status of TCP Segmentation Offload.\n\n"
426
427 "set port (port_id) gro on|off\n"
428 " Enable or disable Generic Receive Offload in"
429 " csum forwarding engine.\n\n"
430
431 "show port (port_id) gro\n"
432 " Display GRO configuration.\n\n"
433
434 "set gro flush (cycles)\n"
435 " Set the cycle to flush GROed packets from"
436 " reassembly tables.\n\n"
437
438 "set port (port_id) gso (on|off)"
439 " Enable or disable Generic Segmentation Offload in"
440 " csum forwarding engine.\n\n"
441
442 "set gso segsz (length)\n"
443 " Set max packet length for output GSO segments,"
444 " including packet header and payload.\n\n"
445
446 "show port (port_id) gso\n"
447 " Show GSO configuration.\n\n"
448
449 "set fwd (%s)\n"
450 " Set packet forwarding mode.\n\n"
451
452 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
453 " Add a MAC address on port_id.\n\n"
454
455 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
456 " Remove a MAC address from port_id.\n\n"
457
458 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
459 " Set the default MAC address for port_id.\n\n"
460
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"
463
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"
466
467 "set eth-peer (port_id) (peer_addr)\n"
468 " set the peer address for certain port.\n\n"
469
470 "set port (port_id) uta (mac_address|all) (on|off)\n"
471 " Add/Remove a or all unicast hash filter(s)"
472 "from port X.\n\n"
473
474 "set promisc (port_id|all) (on|off)\n"
475 " Set the promiscuous mode on port_id, or all.\n\n"
476
477 "set allmulti (port_id|all) (on|off)\n"
478 " Set the allmulti mode on port_id, or all.\n\n"
479
480 "set vf promisc (port_id) (vf_id) (on|off)\n"
481 " Set unicast promiscuous mode for a VF from the PF.\n\n"
482
483 "set vf allmulti (port_id) (vf_id) (on|off)\n"
484 " Set multicast promiscuous mode for a VF from the PF.\n\n"
485
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"
498
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"
502 " port.\n\n"
503
504 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
505 " Set statistics mapping (qmapping 0..15) for RX/TX"
506 " queue on port.\n"
507 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
508 " on port 0 to mapping 5.\n\n"
509
510 "set xstats-hide-zero on|off\n"
511 " Set the option to hide the zero values"
512 " for xstats display.\n"
513
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"
516
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"
520 " for a VF.\n\n"
521
522 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
523 "|MPE) (on|off)\n"
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"
529
530 "set port (port_id) queue (queue_id) rate (rate_num)\n"
531 " Set rate limit for a queue of a port\n\n"
532
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"
536
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"
543 " to pool 0.\n\n"
544
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"
551
552 "reset port (port_id) mirror-rule (rule_id)\n"
553 " Reset a mirror rule.\n\n"
554
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"
558
559 "set bypass mode (normal|bypass|isolate) (port_id)\n"
560 " Set the bypass mode for the lowest port on bypass enabled"
561 " NIC.\n\n"
562
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."
572 "\n\n"
573
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"
577
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"
581
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"
585
586 "add bonding slave (slave_id) (port_id)\n"
587 " Add a slave device to a bonded device.\n\n"
588
589 "remove bonding slave (slave_id) (port_id)\n"
590 " Remove a slave device from a bonded device.\n\n"
591
592 "set bonding mode (value) (port_id)\n"
593 " Set the bonding mode on a bonded device.\n\n"
594
595 "set bonding primary (slave_id) (port_id)\n"
596 " Set the primary slave for a bonded device.\n\n"
597
598 "show bonding config (port_id)\n"
599 " Show the bonding config for port_id.\n\n"
600
601 "set bonding mac_addr (port_id) (address)\n"
602 " Set the MAC address of a bonded device.\n\n"
603
604 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)"
605 " Set Aggregation mode for IEEE802.3AD (mode 4)"
606
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"
609
610 "set bonding mon_period (port_id) (value)\n"
611 " Set the bonding link status monitoring polling period in ms.\n\n"
612
613 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n"
614 " Enable/disable dedicated queues for LACP control traffic.\n\n"
615
616 #endif
617 "set link-up port (port_id)\n"
618 " Set link up for a port.\n\n"
619
620 "set link-down port (port_id)\n"
621 " Set link down for a port.\n\n"
622
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"
626
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"
629
630 "E-tag set stripping (on|off) port (port_id)\n"
631 " Enable/disable E-tag stripping on a port\n\n"
632
633 "E-tag set forwarding (on|off) port (port_id)\n"
634 " Enable/disable E-tag based forwarding"
635 " on a port\n\n"
636
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"
640
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"
643
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"
647
648 #endif
649 "ddp add (port_id) (profile_path[,backup_profile_path])\n"
650 " Load a profile package on a port\n\n"
651
652 "ddp del (port_id) (backup_profile_path)\n"
653 " Delete a profile package from a port\n\n"
654
655 "ptype mapping get (port_id) (valid_only)\n"
656 " Get ptype mapping on a port\n\n"
657
658 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n"
659 " Replace target with the pkt_type in ptype mapping\n\n"
660
661 "ptype mapping reset (port_id)\n"
662 " Reset ptype mapping on a port\n\n"
663
664 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n"
665 " Update a ptype mapping item on a port\n\n"
666
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"
670
671 "set port (port_id) queue-region region_id (value) "
672 "flowtype (value)\n"
673 " Set a flowtype region index on a port\n\n"
674
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"
678
679 "set port (port_id) queue-region flush (on|off)\n"
680 " flush all queue region related configuration\n\n"
681
682 "show port meter cap (port_id)\n"
683 " Show port meter capability information\n\n"
684
685 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n"
686 " meter profile add - srtcm rfc 2697\n\n"
687
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"
690
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"
693
694 "del port meter profile (port_id) (profile_id)\n"
695 " meter profile delete\n\n"
696
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"
701 " meter create\n\n"
702
703 "enable port meter (port_id) (mtr_id)\n"
704 " meter enable\n\n"
705
706 "disable port meter (port_id) (mtr_id)\n"
707 " meter disable\n\n"
708
709 "del port meter (port_id) (mtr_id)\n"
710 " meter delete\n\n"
711
712 "set port meter profile (port_id) (mtr_id) (profile_id)\n"
713 " meter update meter profile\n\n"
714
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"
718
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"
722
723 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
724 " meter update stats\n\n"
725
726 "show port (port_id) queue-region\n"
727 " show all queue region related configuration info\n\n"
728
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"
732
733 "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
734 " Delete port tm node private shaper profile.\n\n"
735
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"
739
740 "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
741 " Delete port tm node shared shaper.\n\n"
742
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"
746
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"
752
753 "del port tm node wred profile (port_id) (wred_profile_id)\n"
754 " Delete port tm node wred profile.\n\n"
755
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"
761
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"
767
768 "del port tm node (port_id) (node_id)\n"
769 " Delete port tm node.\n\n"
770
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"
774
775 "suspend port tm node (port_id) (node_id)"
776 " Suspend tm node.\n\n"
777
778 "resume port tm node (port_id) (node_id)"
779 " Resume tm node.\n\n"
780
781 "port tm hierarchy commit (port_id) (clean_on_fail)\n"
782 " Commit tm hierarchy.\n\n"
783
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"
788
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"
794
795 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
796 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
797 " (eth-dst)\n"
798 " Configure the NVGRE encapsulation for flows.\n\n"
799
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"
804
805 , list_pkt_forwarding_modes()
806 );
807 }
808
809 if (show_all || !strcmp(res->section, "ports")) {
810
811 cmdline_printf(
812 cl,
813 "\n"
814 "Port Operations:\n"
815 "----------------\n\n"
816
817 "port start (port_id|all)\n"
818 " Start all ports or port_id.\n\n"
819
820 "port stop (port_id|all)\n"
821 " Stop all ports or port_id.\n\n"
822
823 "port close (port_id|all)\n"
824 " Close all ports or port_id.\n\n"
825
826 "port attach (ident)\n"
827 " Attach physical or virtual dev by pci address or virtual device name\n\n"
828
829 "port detach (port_id)\n"
830 " Detach physical or virtual dev by port_id\n\n"
831
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"
836
837 "port config (port_id|all) loopback (mode)\n"
838 " Set loopback mode for all ports or port_id\n\n"
839
840 "port config all (rxq|txq|rxd|txd) (value)\n"
841 " Set number for rxq/txq/rxd/txd.\n\n"
842
843 "port config all max-pkt-len (value)\n"
844 " Set the max packet length.\n\n"
845
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)"
848 " (on|off)\n"
849 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en"
850 " for ports.\n\n"
851
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"
855
856 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
857 " Set the RSS redirection table.\n\n"
858
859 "port config (port_id) dcb vt (on|off) (traffic_class)"
860 " pfc (on|off)\n"
861 " Set the DCB mode.\n\n"
862
863 "port config all burst (value)\n"
864 " Set the number of packets per burst.\n\n"
865
866 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
867 " (value)\n"
868 " Set the ring prefetch/host/writeback threshold"
869 " for tx/rx queue.\n\n"
870
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"
876
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"
881
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"
885
886 "port (port_id) (rxq|txq) (queue_id) setup\n"
887 " Setup a rx/tx queue of port X.\n\n"
888
889 "port config (port_id|all) l2-tunnel E-tag ether-type"
890 " (value)\n"
891 " Set the value of E-tag ether-type.\n\n"
892
893 "port config (port_id|all) l2-tunnel E-tag"
894 " (enable|disable)\n"
895 " Enable/disable the E-tag support.\n\n"
896
897 "port config (port_id) pctype mapping reset\n"
898 " Reset flow type to pctype mapping on a port\n\n"
899
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"
903
904 "port config (port_id) pctype (pctype_id) hash_inset|"
905 "fdir_inset|fdir_flx_inset get|set|clear field\n"
906 " (field_idx)\n"
907 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n"
908
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"
912
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"
915 );
916 }
917
918 if (show_all || !strcmp(res->section, "registers")) {
919
920 cmdline_printf(
921 cl,
922 "\n"
923 "Registers:\n"
924 "----------\n\n"
925
926 "read reg (port_id) (address)\n"
927 " Display value of a port register.\n\n"
928
929 "read regfield (port_id) (address) (bit_x) (bit_y)\n"
930 " Display a port register bit field.\n\n"
931
932 "read regbit (port_id) (address) (bit_x)\n"
933 " Display a single port register bit.\n\n"
934
935 "write reg (port_id) (address) (value)\n"
936 " Set value of a port register.\n\n"
937
938 "write regfield (port_id) (address) (bit_x) (bit_y)"
939 " (value)\n"
940 " Set bit field of a port register.\n\n"
941
942 "write regbit (port_id) (address) (bit_x) (value)\n"
943 " Set single bit value of a port register.\n\n"
944 );
945 }
946 if (show_all || !strcmp(res->section, "filters")) {
947
948 cmdline_printf(
949 cl,
950 "\n"
951 "filters:\n"
952 "--------\n\n"
953
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"
958
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"
964
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"
972
973 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)"
974 " Add/Del syn filter.\n\n"
975
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"
980
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"
989
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"
999
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"
1010
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"
1016
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"
1022
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"
1029
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"
1034
1035 "flush_flow_director (port_id)\n"
1036 " Flush all flow director entries of a device.\n\n"
1037
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"
1042
1043 "flow_director_mask (port_id) mode MAC-VLAN"
1044 " vlan (vlan_value)\n"
1045 " Set flow director MAC-VLAN mask.\n\n"
1046
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"
1052
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)"
1056 " (mask)\n"
1057 " Configure mask of flex payload.\n\n"
1058
1059 "flow_director_flex_payload (port_id)"
1060 " (raw|l2|l3|l4) (config)\n"
1061 " Configure flex payload selection.\n\n"
1062
1063 "get_sym_hash_ena_per_port (port_id)\n"
1064 " get symmetric hash enable configuration per port.\n\n"
1065
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"
1069
1070 "get_hash_global_config (port_id)\n"
1071 " Get the global configurations of hash filters.\n\n"
1072
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"
1078
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"
1090
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)"
1099 " (select|add)\n"
1100 " Set the input set for FDir.\n\n"
1101
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"
1108
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"
1115
1116 "flow destroy {port_id} rule {rule_id} [...]\n"
1117 " Destroy specific flow rules.\n\n"
1118
1119 "flow flush {port_id}\n"
1120 " Destroy all flow rules.\n\n"
1121
1122 "flow query {port_id} {rule_id} {action}\n"
1123 " Query an existing flow rule.\n\n"
1124
1125 "flow list {port_id} [group {group_id}] [...]\n"
1126 " List existing flow rules sorted by priority,"
1127 " filtered by group identifiers.\n\n"
1128
1129 "flow isolate {port_id} {boolean}\n"
1130 " Restrict ingress traffic to the defined"
1131 " flow rules\n\n"
1132 );
1133 }
1134 }
1135
1136 cmdline_parse_token_string_t cmd_help_long_help =
1137 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1138
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");
1143
1144 cmdline_parse_inst_t cmd_help_long = {
1145 .f = cmd_help_long_parsed,
1146 .data = NULL,
1147 .help_str = "help all|control|display|config|ports|register|filters: "
1148 "Show help",
1149 .tokens = {
1150 (void *)&cmd_help_long_help,
1151 (void *)&cmd_help_long_section,
1152 NULL,
1153 },
1154 };
1155
1156
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;
1162 };
1163
1164 static void cmd_operate_port_parsed(void *parsed_result,
1165 __attribute__((unused)) struct cmdline *cl,
1166 __attribute__((unused)) void *data)
1167 {
1168 struct cmd_operate_port_result *res = parsed_result;
1169
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);
1178 else
1179 printf("Unknown parameter\n");
1180 }
1181
1182 cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1183 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1184 "port");
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");
1190
1191 cmdline_parse_inst_t cmd_operate_port = {
1192 .f = cmd_operate_port_parsed,
1193 .data = NULL,
1194 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports",
1195 .tokens = {
1196 (void *)&cmd_operate_port_all_cmd,
1197 (void *)&cmd_operate_port_all_port,
1198 (void *)&cmd_operate_port_all_all,
1199 NULL,
1200 },
1201 };
1202
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;
1207 uint8_t value;
1208 };
1209
1210 static void cmd_operate_specific_port_parsed(void *parsed_result,
1211 __attribute__((unused)) struct cmdline *cl,
1212 __attribute__((unused)) void *data)
1213 {
1214 struct cmd_operate_specific_port_result *res = parsed_result;
1215
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);
1224 else
1225 printf("Unknown parameter\n");
1226 }
1227
1228 cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1229 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1230 keyword, "port");
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,
1236 value, UINT8);
1237
1238 cmdline_parse_inst_t cmd_operate_specific_port = {
1239 .f = cmd_operate_specific_port_parsed,
1240 .data = NULL,
1241 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id",
1242 .tokens = {
1243 (void *)&cmd_operate_specific_port_cmd,
1244 (void *)&cmd_operate_specific_port_port,
1245 (void *)&cmd_operate_specific_port_id,
1246 NULL,
1247 },
1248 };
1249
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;
1255 };
1256
1257 static void cmd_operate_attach_port_parsed(void *parsed_result,
1258 __attribute__((unused)) struct cmdline *cl,
1259 __attribute__((unused)) void *data)
1260 {
1261 struct cmd_operate_attach_port_result *res = parsed_result;
1262
1263 if (!strcmp(res->keyword, "attach"))
1264 attach_port(res->identifier);
1265 else
1266 printf("Unknown parameter\n");
1267 }
1268
1269 cmdline_parse_token_string_t cmd_operate_attach_port_port =
1270 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1271 port, "port");
1272 cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1273 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1274 keyword, "attach");
1275 cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1276 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1277 identifier, NULL);
1278
1279 cmdline_parse_inst_t cmd_operate_attach_port = {
1280 .f = cmd_operate_attach_port_parsed,
1281 .data = NULL,
1282 .help_str = "port attach <identifier>: "
1283 "(identifier: pci address or virtual dev name)",
1284 .tokens = {
1285 (void *)&cmd_operate_attach_port_port,
1286 (void *)&cmd_operate_attach_port_keyword,
1287 (void *)&cmd_operate_attach_port_identifier,
1288 NULL,
1289 },
1290 };
1291
1292 /* *** detach a specified port *** */
1293 struct cmd_operate_detach_port_result {
1294 cmdline_fixed_string_t port;
1295 cmdline_fixed_string_t keyword;
1296 portid_t port_id;
1297 };
1298
1299 static void cmd_operate_detach_port_parsed(void *parsed_result,
1300 __attribute__((unused)) struct cmdline *cl,
1301 __attribute__((unused)) void *data)
1302 {
1303 struct cmd_operate_detach_port_result *res = parsed_result;
1304
1305 if (!strcmp(res->keyword, "detach"))
1306 detach_port(res->port_id);
1307 else
1308 printf("Unknown parameter\n");
1309 }
1310
1311 cmdline_parse_token_string_t cmd_operate_detach_port_port =
1312 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1313 port, "port");
1314 cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1315 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1316 keyword, "detach");
1317 cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1318 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1319 port_id, UINT16);
1320
1321 cmdline_parse_inst_t cmd_operate_detach_port = {
1322 .f = cmd_operate_detach_port_parsed,
1323 .data = NULL,
1324 .help_str = "port detach <port_id>",
1325 .tokens = {
1326 (void *)&cmd_operate_detach_port_port,
1327 (void *)&cmd_operate_detach_port_keyword,
1328 (void *)&cmd_operate_detach_port_port_id,
1329 NULL,
1330 },
1331 };
1332
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;
1342 };
1343
1344 static int
1345 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1346 {
1347
1348 int duplex;
1349
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;
1356 } else {
1357 printf("Unknown duplex parameter\n");
1358 return -1;
1359 }
1360
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;
1367 } else {
1368 if (duplex != ETH_LINK_FULL_DUPLEX) {
1369 printf("Invalid speed/duplex parameters\n");
1370 return -1;
1371 }
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;
1386 } else {
1387 printf("Unknown speed parameter\n");
1388 return -1;
1389 }
1390 }
1391
1392 return 0;
1393 }
1394
1395 static void
1396 cmd_config_speed_all_parsed(void *parsed_result,
1397 __attribute__((unused)) struct cmdline *cl,
1398 __attribute__((unused)) void *data)
1399 {
1400 struct cmd_config_speed_all *res = parsed_result;
1401 uint32_t link_speed;
1402 portid_t pid;
1403
1404 if (!all_ports_stopped()) {
1405 printf("Please stop all ports first\n");
1406 return;
1407 }
1408
1409 if (parse_and_check_speed_duplex(res->value1, res->value2,
1410 &link_speed) < 0)
1411 return;
1412
1413 RTE_ETH_FOREACH_DEV(pid) {
1414 ports[pid].dev_conf.link_speeds = link_speed;
1415 }
1416
1417 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1418 }
1419
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,
1424 "config");
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,
1436 "half#full#auto");
1437
1438 cmdline_parse_inst_t cmd_config_speed_all = {
1439 .f = cmd_config_speed_all_parsed,
1440 .data = NULL,
1441 .help_str = "port config all speed "
1442 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1443 "half|full|auto",
1444 .tokens = {
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,
1452 NULL,
1453 },
1454 };
1455
1456 /* *** configure speed for specific port *** */
1457 struct cmd_config_speed_specific {
1458 cmdline_fixed_string_t port;
1459 cmdline_fixed_string_t keyword;
1460 portid_t id;
1461 cmdline_fixed_string_t item1;
1462 cmdline_fixed_string_t item2;
1463 cmdline_fixed_string_t value1;
1464 cmdline_fixed_string_t value2;
1465 };
1466
1467 static void
1468 cmd_config_speed_specific_parsed(void *parsed_result,
1469 __attribute__((unused)) struct cmdline *cl,
1470 __attribute__((unused)) void *data)
1471 {
1472 struct cmd_config_speed_specific *res = parsed_result;
1473 uint32_t link_speed;
1474
1475 if (!all_ports_stopped()) {
1476 printf("Please stop all ports first\n");
1477 return;
1478 }
1479
1480 if (port_id_is_invalid(res->id, ENABLED_WARN))
1481 return;
1482
1483 if (parse_and_check_speed_duplex(res->value1, res->value2,
1484 &link_speed) < 0)
1485 return;
1486
1487 ports[res->id].dev_conf.link_speeds = link_speed;
1488
1489 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1490 }
1491
1492
1493 cmdline_parse_token_string_t cmd_config_speed_specific_port =
1494 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1495 "port");
1496 cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1497 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1498 "config");
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,
1503 "speed");
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,
1509 "duplex");
1510 cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1511 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1512 "half#full#auto");
1513
1514 cmdline_parse_inst_t cmd_config_speed_specific = {
1515 .f = cmd_config_speed_specific_parsed,
1516 .data = NULL,
1517 .help_str = "port config <port_id> speed "
1518 "10|100|1000|10000|25000|40000|50000|100000|auto duplex "
1519 "half|full|auto",
1520 .tokens = {
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,
1528 NULL,
1529 },
1530 };
1531
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;
1538 uint32_t mode;
1539 };
1540
1541 static void
1542 cmd_config_loopback_all_parsed(void *parsed_result,
1543 __attribute__((unused)) struct cmdline *cl,
1544 __attribute__((unused)) void *data)
1545 {
1546 struct cmd_config_loopback_all *res = parsed_result;
1547 portid_t pid;
1548
1549 if (!all_ports_stopped()) {
1550 printf("Please stop all ports first\n");
1551 return;
1552 }
1553
1554 RTE_ETH_FOREACH_DEV(pid) {
1555 ports[pid].dev_conf.lpbk_mode = res->mode;
1556 }
1557
1558 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1559 }
1560
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,
1565 "config");
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,
1570 "loopback");
1571 cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1572 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32);
1573
1574 cmdline_parse_inst_t cmd_config_loopback_all = {
1575 .f = cmd_config_loopback_all_parsed,
1576 .data = NULL,
1577 .help_str = "port config all loopback <mode>",
1578 .tokens = {
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,
1584 NULL,
1585 },
1586 };
1587
1588 /* *** configure loopback for specific port *** */
1589 struct cmd_config_loopback_specific {
1590 cmdline_fixed_string_t port;
1591 cmdline_fixed_string_t keyword;
1592 uint16_t port_id;
1593 cmdline_fixed_string_t item;
1594 uint32_t mode;
1595 };
1596
1597 static void
1598 cmd_config_loopback_specific_parsed(void *parsed_result,
1599 __attribute__((unused)) struct cmdline *cl,
1600 __attribute__((unused)) void *data)
1601 {
1602 struct cmd_config_loopback_specific *res = parsed_result;
1603
1604 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1605 return;
1606
1607 if (!port_is_stopped(res->port_id)) {
1608 printf("Please stop port %u first\n", res->port_id);
1609 return;
1610 }
1611
1612 ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1613
1614 cmd_reconfig_device_queue(res->port_id, 1, 1);
1615 }
1616
1617
1618 cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1619 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1620 "port");
1621 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1622 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1623 "config");
1624 cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1625 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1626 UINT16);
1627 cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1628 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1629 "loopback");
1630 cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1631 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1632 UINT32);
1633
1634 cmdline_parse_inst_t cmd_config_loopback_specific = {
1635 .f = cmd_config_loopback_specific_parsed,
1636 .data = NULL,
1637 .help_str = "port config <port_id> loopback <mode>",
1638 .tokens = {
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,
1644 NULL,
1645 },
1646 };
1647
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;
1654 uint16_t value;
1655 };
1656
1657 static void
1658 cmd_config_rx_tx_parsed(void *parsed_result,
1659 __attribute__((unused)) struct cmdline *cl,
1660 __attribute__((unused)) void *data)
1661 {
1662 struct cmd_config_rx_tx *res = parsed_result;
1663
1664 if (!all_ports_stopped()) {
1665 printf("Please stop all ports first\n");
1666 return;
1667 }
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");
1671 return;
1672 }
1673 if (check_nb_rxq(res->value) != 0)
1674 return;
1675 nb_rxq = res->value;
1676 }
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");
1680 return;
1681 }
1682 if (check_nb_txq(res->value) != 0)
1683 return;
1684 nb_txq = res->value;
1685 }
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);
1690 return;
1691 }
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);
1697 return;
1698 }
1699 nb_txd = res->value;
1700 } else {
1701 printf("Unknown parameter\n");
1702 return;
1703 }
1704
1705 fwd_config_setup();
1706
1707 init_port_config();
1708
1709 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1710 }
1711
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,
1720 "rxq#txq#rxd#txd");
1721 cmdline_parse_token_num_t cmd_config_rx_tx_value =
1722 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16);
1723
1724 cmdline_parse_inst_t cmd_config_rx_tx = {
1725 .f = cmd_config_rx_tx_parsed,
1726 .data = NULL,
1727 .help_str = "port config all rxq|txq|rxd|txd <value>",
1728 .tokens = {
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,
1734 NULL,
1735 },
1736 };
1737
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;
1744 uint32_t value;
1745 };
1746
1747 static void
1748 cmd_config_max_pkt_len_parsed(void *parsed_result,
1749 __attribute__((unused)) struct cmdline *cl,
1750 __attribute__((unused)) void *data)
1751 {
1752 struct cmd_config_max_pkt_len_result *res = parsed_result;
1753 portid_t pid;
1754
1755 if (!all_ports_stopped()) {
1756 printf("Please stop all ports first\n");
1757 return;
1758 }
1759
1760 RTE_ETH_FOREACH_DEV(pid) {
1761 struct rte_port *port = &ports[pid];
1762 uint64_t rx_offloads = port->dev_conf.rxmode.offloads;
1763
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",
1767 ETHER_MIN_LEN);
1768 return;
1769 }
1770 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len)
1771 return;
1772
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;
1776 else
1777 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME;
1778 port->dev_conf.rxmode.offloads = rx_offloads;
1779 } else {
1780 printf("Unknown parameter\n");
1781 return;
1782 }
1783 }
1784
1785 init_port_config();
1786
1787 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1788 }
1789
1790 cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1791 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1792 "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,
1795 "config");
1796 cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1797 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1798 "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,
1801 "max-pkt-len");
1802 cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1803 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1804 UINT32);
1805
1806 cmdline_parse_inst_t cmd_config_max_pkt_len = {
1807 .f = cmd_config_max_pkt_len_parsed,
1808 .data = NULL,
1809 .help_str = "port config all max-pkt-len <value>",
1810 .tokens = {
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,
1816 NULL,
1817 },
1818 };
1819
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;
1825 portid_t port_id;
1826 uint16_t value;
1827 };
1828
1829 static void
1830 cmd_config_mtu_parsed(void *parsed_result,
1831 __attribute__((unused)) struct cmdline *cl,
1832 __attribute__((unused)) void *data)
1833 {
1834 struct cmd_config_mtu_result *res = parsed_result;
1835
1836 if (res->value < ETHER_MIN_LEN) {
1837 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
1838 return;
1839 }
1840 port_mtu_set(res->port_id, res->value);
1841 }
1842
1843 cmdline_parse_token_string_t cmd_config_mtu_port =
1844 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1845 "port");
1846 cmdline_parse_token_string_t cmd_config_mtu_keyword =
1847 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1848 "config");
1849 cmdline_parse_token_string_t cmd_config_mtu_mtu =
1850 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1851 "mtu");
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);
1856
1857 cmdline_parse_inst_t cmd_config_mtu = {
1858 .f = cmd_config_mtu_parsed,
1859 .data = NULL,
1860 .help_str = "port config mtu <port_id> <value>",
1861 .tokens = {
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,
1867 NULL,
1868 },
1869 };
1870
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;
1878 };
1879
1880 static void
1881 cmd_config_rx_mode_flag_parsed(void *parsed_result,
1882 __attribute__((unused)) struct cmdline *cl,
1883 __attribute__((unused)) void *data)
1884 {
1885 struct cmd_config_rx_mode_flag *res = parsed_result;
1886 portid_t pid;
1887
1888 if (!all_ports_stopped()) {
1889 printf("Please stop all ports first\n");
1890 return;
1891 }
1892
1893 RTE_ETH_FOREACH_DEV(pid) {
1894 struct rte_port *port;
1895 uint64_t rx_offloads;
1896
1897 port = &ports[pid];
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;
1906 } else {
1907 printf("Unknown parameter\n");
1908 return;
1909 }
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;
1915 } else {
1916 printf("Unknown parameter\n");
1917 return;
1918 }
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;
1924 else {
1925 printf("Unknown parameter\n");
1926 return;
1927 }
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;
1933 else {
1934 printf("Unknown parameter\n");
1935 return;
1936 }
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);
1944 } else {
1945 printf("Unknown parameter\n");
1946 return;
1947 }
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;
1953 else {
1954 printf("Unknown parameter\n");
1955 return;
1956 }
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;
1962 else {
1963 printf("Unknown parameter\n");
1964 return;
1965 }
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;
1971 else {
1972 printf("Unknown parameter\n");
1973 return;
1974 }
1975 } else if (!strcmp(res->name, "drop-en")) {
1976 if (!strcmp(res->value, "on"))
1977 rx_drop_en = 1;
1978 else if (!strcmp(res->value, "off"))
1979 rx_drop_en = 0;
1980 else {
1981 printf("Unknown parameter\n");
1982 return;
1983 }
1984 } else {
1985 printf("Unknown parameter\n");
1986 return;
1987 }
1988 port->dev_conf.rxmode.offloads = rx_offloads;
1989 }
1990
1991 init_port_config();
1992
1993 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1994 }
1995
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,
2000 "config");
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,
2009 "on#off");
2010
2011 cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2012 .f = cmd_config_rx_mode_flag_parsed,
2013 .data = NULL,
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",
2016 .tokens = {
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,
2022 NULL,
2023 },
2024 };
2025
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;
2033 };
2034
2035 static void
2036 cmd_config_rss_parsed(void *parsed_result,
2037 __attribute__((unused)) struct cmdline *cl,
2038 __attribute__((unused)) void *data)
2039 {
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;
2045 int diag;
2046 uint16_t i;
2047
2048 if (!strcmp(res->value, "all"))
2049 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
2050 ETH_RSS_UDP | ETH_RSS_SCTP |
2051 ETH_RSS_L2_PAYLOAD;
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"))
2073 use_default = 1;
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);
2077 else {
2078 printf("Unknown parameter\n");
2079 return;
2080 }
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;
2085
2086 rte_eth_dev_info_get(i, &dev_info);
2087 if (use_default)
2088 rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2089
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);
2097 }
2098 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2099 if (diag < 0) {
2100 all_updated = 0;
2101 printf("Configuration of RSS hash at ethernet port %d "
2102 "failed with error (%d): %s.\n",
2103 i, -diag, strerror(-diag));
2104 }
2105 }
2106 if (all_updated && !use_default)
2107 rss_hf = rss_conf.rss_hf;
2108 }
2109
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);
2120
2121 cmdline_parse_inst_t cmd_config_rss = {
2122 .f = cmd_config_rss_parsed,
2123 .data = NULL,
2124 .help_str = "port config all rss "
2125 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>",
2126 .tokens = {
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,
2132 NULL,
2133 },
2134 };
2135
2136 /* *** configure rss hash key *** */
2137 struct cmd_config_rss_hash_key {
2138 cmdline_fixed_string_t port;
2139 cmdline_fixed_string_t config;
2140 portid_t port_id;
2141 cmdline_fixed_string_t rss_hash_key;
2142 cmdline_fixed_string_t rss_type;
2143 cmdline_fixed_string_t key;
2144 };
2145
2146 static uint8_t
2147 hexa_digit_to_value(char hexa_digit)
2148 {
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 */
2156 return 0xFF;
2157 }
2158
2159 static uint8_t
2160 parse_and_check_key_hexa_digit(char *key, int idx)
2161 {
2162 uint8_t hexa_v;
2163
2164 hexa_v = hexa_digit_to_value(key[idx]);
2165 if (hexa_v == 0xFF)
2166 printf("invalid key: character %c at position %d is not a "
2167 "valid hexa digit\n", key[idx], idx);
2168 return hexa_v;
2169 }
2170
2171 static void
2172 cmd_config_rss_hash_key_parsed(void *parsed_result,
2173 __attribute__((unused)) struct cmdline *cl,
2174 __attribute__((unused)) void *data)
2175 {
2176 struct cmd_config_rss_hash_key *res = parsed_result;
2177 uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2178 uint8_t xdgt0;
2179 uint8_t xdgt1;
2180 int i;
2181 struct rte_eth_dev_info dev_info;
2182 uint8_t hash_key_size;
2183 uint32_t key_len;
2184
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;
2190 else {
2191 printf("dev_info did not provide a valid hash key size\n");
2192 return;
2193 }
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);
2200 return;
2201 }
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));
2205 if (xdgt0 == 0xFF)
2206 return;
2207 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2208 if (xdgt1 == 0xFF)
2209 return;
2210 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2211 }
2212 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2213 hash_key_size);
2214 }
2215
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,
2220 "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);
2234
2235 cmdline_parse_inst_t cmd_config_rss_hash_key = {
2236 .f = cmd_config_rss_hash_key_parsed,
2237 .data = NULL,
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)>",
2243 .tokens = {
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,
2250 NULL,
2251 },
2252 };
2253
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;
2258 portid_t portid;
2259 cmdline_fixed_string_t rxtxq;
2260 uint16_t qid;
2261 cmdline_fixed_string_t rsize;
2262 uint16_t size;
2263 };
2264
2265 static void
2266 cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2267 __attribute__((unused)) struct cmdline *cl,
2268 __attribute__((unused)) void *data)
2269 {
2270 struct cmd_config_rxtx_ring_size *res = parsed_result;
2271 struct rte_port *port;
2272 uint8_t isrx;
2273
2274 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2275 return;
2276
2277 if (res->portid == (portid_t)RTE_PORT_ALL) {
2278 printf("Invalid port id\n");
2279 return;
2280 }
2281
2282 port = &ports[res->portid];
2283
2284 if (!strcmp(res->rxtxq, "rxq"))
2285 isrx = 1;
2286 else if (!strcmp(res->rxtxq, "txq"))
2287 isrx = 0;
2288 else {
2289 printf("Unknown parameter\n");
2290 return;
2291 }
2292
2293 if (isrx && rx_queue_id_is_invalid(res->qid))
2294 return;
2295 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2296 return;
2297
2298 if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2299 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n",
2300 rx_free_thresh);
2301 return;
2302 }
2303
2304 if (isrx)
2305 port->nb_rx_desc[res->qid] = res->size;
2306 else
2307 port->nb_tx_desc[res->qid] = res->size;
2308
2309 cmd_reconfig_device_queue(res->portid, 0, 1);
2310 }
2311
2312 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2313 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2314 port, "port");
2315 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2316 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2317 config, "config");
2318 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2319 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2320 portid, UINT16);
2321 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2322 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2323 rxtxq, "rxq#txq");
2324 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2325 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2326 qid, UINT16);
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,
2332 size, UINT16);
2333
2334 cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2335 .f = cmd_config_rxtx_ring_size_parsed,
2336 .data = NULL,
2337 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2338 .tokens = {
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,
2346 NULL,
2347 },
2348 };
2349
2350 /* *** configure port rxq/txq start/stop *** */
2351 struct cmd_config_rxtx_queue {
2352 cmdline_fixed_string_t port;
2353 portid_t portid;
2354 cmdline_fixed_string_t rxtxq;
2355 uint16_t qid;
2356 cmdline_fixed_string_t opname;
2357 };
2358
2359 static void
2360 cmd_config_rxtx_queue_parsed(void *parsed_result,
2361 __attribute__((unused)) struct cmdline *cl,
2362 __attribute__((unused)) void *data)
2363 {
2364 struct cmd_config_rxtx_queue *res = parsed_result;
2365 uint8_t isrx;
2366 uint8_t isstart;
2367 int ret = 0;
2368
2369 if (test_done == 0) {
2370 printf("Please stop forwarding first\n");
2371 return;
2372 }
2373
2374 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2375 return;
2376
2377 if (port_is_started(res->portid) != 1) {
2378 printf("Please start port %u first\n", res->portid);
2379 return;
2380 }
2381
2382 if (!strcmp(res->rxtxq, "rxq"))
2383 isrx = 1;
2384 else if (!strcmp(res->rxtxq, "txq"))
2385 isrx = 0;
2386 else {
2387 printf("Unknown parameter\n");
2388 return;
2389 }
2390
2391 if (isrx && rx_queue_id_is_invalid(res->qid))
2392 return;
2393 else if (!isrx && tx_queue_id_is_invalid(res->qid))
2394 return;
2395
2396 if (!strcmp(res->opname, "start"))
2397 isstart = 1;
2398 else if (!strcmp(res->opname, "stop"))
2399 isstart = 0;
2400 else {
2401 printf("Unknown parameter\n");
2402 return;
2403 }
2404
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);
2411 else
2412 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2413
2414 if (ret == -ENOTSUP)
2415 printf("Function not supported in PMD driver\n");
2416 }
2417
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,
2428 "start#stop");
2429
2430 cmdline_parse_inst_t cmd_config_rxtx_queue = {
2431 .f = cmd_config_rxtx_queue_parsed,
2432 .data = NULL,
2433 .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2434 .tokens = {
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,
2440 NULL,
2441 },
2442 };
2443
2444 /* *** configure port rxq/txq setup *** */
2445 struct cmd_setup_rxtx_queue {
2446 cmdline_fixed_string_t port;
2447 portid_t portid;
2448 cmdline_fixed_string_t rxtxq;
2449 uint16_t qid;
2450 cmdline_fixed_string_t setup;
2451 };
2452
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");
2464
2465 static void
2466 cmd_setup_rxtx_queue_parsed(
2467 void *parsed_result,
2468 __attribute__((unused)) struct cmdline *cl,
2469 __attribute__((unused)) void *data)
2470 {
2471 struct cmd_setup_rxtx_queue *res = parsed_result;
2472 struct rte_port *port;
2473 struct rte_mempool *mp;
2474 unsigned int socket_id;
2475 uint8_t isrx = 0;
2476 int ret;
2477
2478 if (port_id_is_invalid(res->portid, ENABLED_WARN))
2479 return;
2480
2481 if (res->portid == (portid_t)RTE_PORT_ALL) {
2482 printf("Invalid port id\n");
2483 return;
2484 }
2485
2486 if (!strcmp(res->rxtxq, "rxq"))
2487 isrx = 1;
2488 else if (!strcmp(res->rxtxq, "txq"))
2489 isrx = 0;
2490 else {
2491 printf("Unknown parameter\n");
2492 return;
2493 }
2494
2495 if (isrx && rx_queue_id_is_invalid(res->qid)) {
2496 printf("Invalid rx queue\n");
2497 return;
2498 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2499 printf("Invalid tx queue\n");
2500 return;
2501 }
2502
2503 port = &ports[res->portid];
2504 if (isrx) {
2505 socket_id = rxring_numa[res->portid];
2506 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2507 socket_id = port->socket_id;
2508
2509 mp = mbuf_pool_find(socket_id);
2510 if (mp == NULL) {
2511 printf("Failed to setup RX queue: "
2512 "No mempool allocation"
2513 " on the socket %d\n",
2514 rxring_numa[res->portid]);
2515 return;
2516 }
2517 ret = rte_eth_rx_queue_setup(res->portid,
2518 res->qid,
2519 port->nb_rx_desc[res->qid],
2520 socket_id,
2521 &port->rx_conf[res->qid],
2522 mp);
2523 if (ret)
2524 printf("Failed to setup RX queue\n");
2525 } else {
2526 socket_id = txring_numa[res->portid];
2527 if (!numa_support || socket_id == NUMA_NO_CONFIG)
2528 socket_id = port->socket_id;
2529
2530 ret = rte_eth_tx_queue_setup(res->portid,
2531 res->qid,
2532 port->nb_tx_desc[res->qid],
2533 socket_id,
2534 &port->tx_conf[res->qid]);
2535 if (ret)
2536 printf("Failed to setup TX queue\n");
2537 }
2538 }
2539
2540 cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2541 .f = cmd_setup_rxtx_queue_parsed,
2542 .data = NULL,
2543 .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2544 .tokens = {
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,
2550 NULL,
2551 },
2552 };
2553
2554
2555 /* *** Configure RSS RETA *** */
2556 struct cmd_config_rss_reta {
2557 cmdline_fixed_string_t port;
2558 cmdline_fixed_string_t keyword;
2559 portid_t port_id;
2560 cmdline_fixed_string_t name;
2561 cmdline_fixed_string_t list_name;
2562 cmdline_fixed_string_t list_of_items;
2563 };
2564
2565 static int
2566 parse_reta_config(const char *str,
2567 struct rte_eth_rss_reta_entry64 *reta_conf,
2568 uint16_t nb_entries)
2569 {
2570 int i;
2571 unsigned size;
2572 uint16_t hash_index, idx, shift;
2573 uint16_t nb_queue;
2574 char s[256];
2575 const char *p, *p0 = str;
2576 char *end;
2577 enum fieldnames {
2578 FLD_HASH_INDEX = 0,
2579 FLD_QUEUE,
2580 _NUM_FLD
2581 };
2582 unsigned long int_fld[_NUM_FLD];
2583 char *str_fld[_NUM_FLD];
2584
2585 while ((p = strchr(p0,'(')) != NULL) {
2586 ++p;
2587 if((p0 = strchr(p,')')) == NULL)
2588 return -1;
2589
2590 size = p0 - p;
2591 if(size >= sizeof(s))
2592 return -1;
2593
2594 snprintf(s, sizeof(s), "%.*s", size, p);
2595 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2596 return -1;
2597 for (i = 0; i < _NUM_FLD; i++) {
2598 errno = 0;
2599 int_fld[i] = strtoul(str_fld[i], &end, 0);
2600 if (errno != 0 || end == str_fld[i] ||
2601 int_fld[i] > 65535)
2602 return -1;
2603 }
2604
2605 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2606 nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2607
2608 if (hash_index >= nb_entries) {
2609 printf("Invalid RETA hash index=%d\n", hash_index);
2610 return -1;
2611 }
2612
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;
2617 }
2618
2619 return 0;
2620 }
2621
2622 static void
2623 cmd_set_rss_reta_parsed(void *parsed_result,
2624 __attribute__((unused)) struct cmdline *cl,
2625 __attribute__((unused)) void *data)
2626 {
2627 int ret;
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;
2631
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");
2637 return;
2638 } else
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);
2644 return;
2645 }
2646
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");
2653 return;
2654 }
2655 ret = rte_eth_dev_rss_reta_update(res->port_id,
2656 reta_conf, dev_info.reta_size);
2657 if (ret != 0)
2658 printf("Bad redirection table parameter, "
2659 "return code = %d \n", ret);
2660 }
2661 }
2662
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,
2675 NULL);
2676 cmdline_parse_inst_t cmd_config_rss_reta = {
2677 .f = cmd_set_rss_reta_parsed,
2678 .data = NULL,
2679 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2680 .tokens = {
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,
2687 NULL,
2688 },
2689 };
2690
2691 /* *** SHOW PORT RETA INFO *** */
2692 struct cmd_showport_reta {
2693 cmdline_fixed_string_t show;
2694 cmdline_fixed_string_t port;
2695 portid_t port_id;
2696 cmdline_fixed_string_t rss;
2697 cmdline_fixed_string_t reta;
2698 uint16_t size;
2699 cmdline_fixed_string_t list_of_items;
2700 };
2701
2702 static int
2703 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2704 uint16_t nb_entries,
2705 char *str)
2706 {
2707 uint32_t size;
2708 const char *p, *p0 = str;
2709 char s[256];
2710 char *end;
2711 char *str_fld[8];
2712 uint16_t i;
2713 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) /
2714 RTE_RETA_GROUP_SIZE;
2715 int ret;
2716
2717 p = strchr(p0, '(');
2718 if (p == NULL)
2719 return -1;
2720 p++;
2721 p0 = strchr(p, ')');
2722 if (p0 == NULL)
2723 return -1;
2724 size = p0 - p;
2725 if (size >= sizeof(s)) {
2726 printf("The string size exceeds the internal buffer size\n");
2727 return -1;
2728 }
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);
2734 return -1;
2735 }
2736 for (i = 0; i < ret; i++)
2737 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0);
2738
2739 return 0;
2740 }
2741
2742 static void
2743 cmd_showport_reta_parsed(void *parsed_result,
2744 __attribute__((unused)) struct cmdline *cl,
2745 __attribute__((unused)) void *data)
2746 {
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;
2751
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);
2758 return;
2759 }
2760
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);
2766 return;
2767 }
2768 port_rss_reta_info(res->port_id, reta_conf, res->size);
2769 }
2770
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);
2786
2787 cmdline_parse_inst_t cmd_showport_reta = {
2788 .f = cmd_showport_reta_parsed,
2789 .data = NULL,
2790 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
2791 .tokens = {
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,
2799 NULL,
2800 },
2801 };
2802
2803 /* *** Show RSS hash configuration *** */
2804 struct cmd_showport_rss_hash {
2805 cmdline_fixed_string_t show;
2806 cmdline_fixed_string_t port;
2807 portid_t port_id;
2808 cmdline_fixed_string_t rss_hash;
2809 cmdline_fixed_string_t rss_type;
2810 cmdline_fixed_string_t key; /* optional argument */
2811 };
2812
2813 static void cmd_showport_rss_hash_parsed(void *parsed_result,
2814 __attribute__((unused)) struct cmdline *cl,
2815 void *show_rss_key)
2816 {
2817 struct cmd_showport_rss_hash *res = parsed_result;
2818
2819 port_rss_hash_conf_show(res->port_id, res->rss_type,
2820 show_rss_key != NULL);
2821 }
2822
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,
2831 "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");
2840
2841 cmdline_parse_inst_t cmd_showport_rss_hash = {
2842 .f = cmd_showport_rss_hash_parsed,
2843 .data = NULL,
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",
2848 .tokens = {
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,
2854 NULL,
2855 },
2856 };
2857
2858 cmdline_parse_inst_t cmd_showport_rss_hash_key = {
2859 .f = cmd_showport_rss_hash_parsed,
2860 .data = (void *)1,
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",
2865 .tokens = {
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,
2872 NULL,
2873 },
2874 };
2875
2876 /* *** Configure DCB *** */
2877 struct cmd_config_dcb {
2878 cmdline_fixed_string_t port;
2879 cmdline_fixed_string_t config;
2880 portid_t port_id;
2881 cmdline_fixed_string_t dcb;
2882 cmdline_fixed_string_t vt;
2883 cmdline_fixed_string_t vt_en;
2884 uint8_t num_tcs;
2885 cmdline_fixed_string_t pfc;
2886 cmdline_fixed_string_t pfc_en;
2887 };
2888
2889 static void
2890 cmd_config_dcb_parsed(void *parsed_result,
2891 __attribute__((unused)) struct cmdline *cl,
2892 __attribute__((unused)) void *data)
2893 {
2894 struct cmd_config_dcb *res = parsed_result;
2895 portid_t port_id = res->port_id;
2896 struct rte_port *port;
2897 uint8_t pfc_en;
2898 int ret;
2899
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);
2904 return;
2905 }
2906
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");
2910 return;
2911 }
2912
2913 if (nb_fwd_lcores < res->num_tcs) {
2914 printf("nb_cores shouldn't be less than number of TCs.\n");
2915 return;
2916 }
2917 if (!strncmp(res->pfc_en, "on", 2))
2918 pfc_en = 1;
2919 else
2920 pfc_en = 0;
2921
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,
2926 pfc_en);
2927 else
2928 ret = init_port_dcb_config(port_id, DCB_ENABLED,
2929 (enum rte_eth_nb_tcs)res->num_tcs,
2930 pfc_en);
2931
2932
2933 if (ret != 0) {
2934 printf("Cannot initialize network ports.\n");
2935 return;
2936 }
2937
2938 cmd_reconfig_device_queue(port_id, 1, 1);
2939 }
2940
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");
2959
2960 cmdline_parse_inst_t cmd_config_dcb = {
2961 .f = cmd_config_dcb_parsed,
2962 .data = NULL,
2963 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
2964 .tokens = {
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,
2974 NULL,
2975 },
2976 };
2977
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;
2984 uint16_t value;
2985 };
2986
2987 static void
2988 cmd_config_burst_parsed(void *parsed_result,
2989 __attribute__((unused)) struct cmdline *cl,
2990 __attribute__((unused)) void *data)
2991 {
2992 struct cmd_config_burst *res = parsed_result;
2993 struct rte_eth_dev_info dev_info;
2994 uint16_t rec_nb_pkts;
2995
2996 if (!all_ports_stopped()) {
2997 printf("Please stop all ports first\n");
2998 return;
2999 }
3000
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.
3007 */
3008 rte_eth_dev_info_get(0, &dev_info);
3009 rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3010
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);
3015 return;
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);
3020 return;
3021 }
3022 printf("Using PMD-provided burst value of %d\n",
3023 rec_nb_pkts);
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);
3027 return;
3028 } else
3029 nb_pkt_per_burst = res->value;
3030 } else {
3031 printf("Unknown parameter\n");
3032 return;
3033 }
3034
3035 init_port_config();
3036
3037 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3038 }
3039
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);
3050
3051 cmdline_parse_inst_t cmd_config_burst = {
3052 .f = cmd_config_burst_parsed,
3053 .data = NULL,
3054 .help_str = "port config all burst <value>",
3055 .tokens = {
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,
3061 NULL,
3062 },
3063 };
3064
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;
3071 uint8_t value;
3072 };
3073
3074 static void
3075 cmd_config_thresh_parsed(void *parsed_result,
3076 __attribute__((unused)) struct cmdline *cl,
3077 __attribute__((unused)) void *data)
3078 {
3079 struct cmd_config_thresh *res = parsed_result;
3080
3081 if (!all_ports_stopped()) {
3082 printf("Please stop all ports first\n");
3083 return;
3084 }
3085
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;
3098 else {
3099 printf("Unknown parameter\n");
3100 return;
3101 }
3102
3103 init_port_config();
3104
3105 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3106 }
3107
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);
3119
3120 cmdline_parse_inst_t cmd_config_thresh = {
3121 .f = cmd_config_thresh_parsed,
3122 .data = NULL,
3123 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3124 .tokens = {
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,
3130 NULL,
3131 },
3132 };
3133
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;
3140 uint16_t value;
3141 };
3142
3143 static void
3144 cmd_config_threshold_parsed(void *parsed_result,
3145 __attribute__((unused)) struct cmdline *cl,
3146 __attribute__((unused)) void *data)
3147 {
3148 struct cmd_config_threshold *res = parsed_result;
3149
3150 if (!all_ports_stopped()) {
3151 printf("Please stop all ports first\n");
3152 return;
3153 }
3154
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;
3161 else {
3162 printf("Unknown parameter\n");
3163 return;
3164 }
3165
3166 init_port_config();
3167
3168 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3169 }
3170
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,
3175 "config");
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);
3183
3184 cmdline_parse_inst_t cmd_config_threshold = {
3185 .f = cmd_config_threshold_parsed,
3186 .data = NULL,
3187 .help_str = "port config all txfreet|txrst|rxfreet <value>",
3188 .tokens = {
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,
3194 NULL,
3195 },
3196 };
3197
3198 /* *** stop *** */
3199 struct cmd_stop_result {
3200 cmdline_fixed_string_t stop;
3201 };
3202
3203 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result,
3204 __attribute__((unused)) struct cmdline *cl,
3205 __attribute__((unused)) void *data)
3206 {
3207 stop_packet_forwarding();
3208 }
3209
3210 cmdline_parse_token_string_t cmd_stop_stop =
3211 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3212
3213 cmdline_parse_inst_t cmd_stop = {
3214 .f = cmd_stop_parsed,
3215 .data = NULL,
3216 .help_str = "stop: Stop packet forwarding",
3217 .tokens = {
3218 (void *)&cmd_stop_stop,
3219 NULL,
3220 },
3221 };
3222
3223 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3224
3225 unsigned int
3226 parse_item_list(char* str, const char* item_name, unsigned int max_items,
3227 unsigned int *parsed_items, int check_unique_values)
3228 {
3229 unsigned int nb_item;
3230 unsigned int value;
3231 unsigned int i;
3232 unsigned int j;
3233 int value_ok;
3234 char c;
3235
3236 /*
3237 * First parse all items in the list and store their value.
3238 */
3239 value = 0;
3240 nb_item = 0;
3241 value_ok = 0;
3242 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3243 c = str[i];
3244 if ((c >= '0') && (c <= '9')) {
3245 value = (unsigned int) (value * 10 + (c - '0'));
3246 value_ok = 1;
3247 continue;
3248 }
3249 if (c != ',') {
3250 printf("character %c is not a decimal digit\n", c);
3251 return 0;
3252 }
3253 if (! value_ok) {
3254 printf("No valid value before comma\n");
3255 return 0;
3256 }
3257 if (nb_item < max_items) {
3258 parsed_items[nb_item] = value;
3259 value_ok = 0;
3260 value = 0;
3261 }
3262 nb_item++;
3263 }
3264 if (nb_item >= max_items) {
3265 printf("Number of %s = %u > %u (maximum items)\n",
3266 item_name, nb_item + 1, max_items);
3267 return 0;
3268 }
3269 parsed_items[nb_item++] = value;
3270 if (! check_unique_values)
3271 return nb_item;
3272
3273 /*
3274 * Then, check that all values in the list are differents.
3275 * No optimization here...
3276 */
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);
3282 return 0;
3283 }
3284 }
3285 }
3286 return nb_item;
3287 }
3288
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;
3293 };
3294
3295 static void cmd_set_list_parsed(void *parsed_result,
3296 __attribute__((unused)) struct cmdline *cl,
3297 __attribute__((unused)) void *data)
3298 {
3299 struct cmd_set_list_result *res;
3300 union {
3301 unsigned int lcorelist[RTE_MAX_LCORE];
3302 unsigned int portlist[RTE_MAX_ETHPORTS];
3303 } parsed_items;
3304 unsigned int nb_item;
3305
3306 if (test_done == 0) {
3307 printf("Please stop forwarding first\n");
3308 return;
3309 }
3310
3311 res = parsed_result;
3312 if (!strcmp(res->list_name, "corelist")) {
3313 nb_item = parse_item_list(res->list_of_items, "core",
3314 RTE_MAX_LCORE,
3315 parsed_items.lcorelist, 1);
3316 if (nb_item > 0) {
3317 set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3318 fwd_config_setup();
3319 }
3320 return;
3321 }
3322 if (!strcmp(res->list_name, "portlist")) {
3323 nb_item = parse_item_list(res->list_of_items, "port",
3324 RTE_MAX_ETHPORTS,
3325 parsed_items.portlist, 1);
3326 if (nb_item > 0) {
3327 set_fwd_ports_list(parsed_items.portlist, nb_item);
3328 fwd_config_setup();
3329 }
3330 }
3331 }
3332
3333 cmdline_parse_token_string_t cmd_set_list_keyword =
3334 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3335 "set");
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,
3341 NULL);
3342
3343 cmdline_parse_inst_t cmd_set_fwd_list = {
3344 .f = cmd_set_list_parsed,
3345 .data = NULL,
3346 .help_str = "set corelist|portlist <list0[,list1]*>",
3347 .tokens = {
3348 (void *)&cmd_set_list_keyword,
3349 (void *)&cmd_set_list_name,
3350 (void *)&cmd_set_list_of_items,
3351 NULL,
3352 },
3353 };
3354
3355 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3356
3357 struct cmd_setmask_result {
3358 cmdline_fixed_string_t set;
3359 cmdline_fixed_string_t mask;
3360 uint64_t hexavalue;
3361 };
3362
3363 static void cmd_set_mask_parsed(void *parsed_result,
3364 __attribute__((unused)) struct cmdline *cl,
3365 __attribute__((unused)) void *data)
3366 {
3367 struct cmd_setmask_result *res = parsed_result;
3368
3369 if (test_done == 0) {
3370 printf("Please stop forwarding first\n");
3371 return;
3372 }
3373 if (!strcmp(res->mask, "coremask")) {
3374 set_fwd_lcores_mask(res->hexavalue);
3375 fwd_config_setup();
3376 } else if (!strcmp(res->mask, "portmask")) {
3377 set_fwd_ports_mask(res->hexavalue);
3378 fwd_config_setup();
3379 }
3380 }
3381
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);
3389
3390 cmdline_parse_inst_t cmd_set_fwd_mask = {
3391 .f = cmd_set_mask_parsed,
3392 .data = NULL,
3393 .help_str = "set coremask|portmask <hexadecimal value>",
3394 .tokens = {
3395 (void *)&cmd_setmask_set,
3396 (void *)&cmd_setmask_mask,
3397 (void *)&cmd_setmask_value,
3398 NULL,
3399 },
3400 };
3401
3402 /*
3403 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3404 */
3405 struct cmd_set_result {
3406 cmdline_fixed_string_t set;
3407 cmdline_fixed_string_t what;
3408 uint16_t value;
3409 };
3410
3411 static void cmd_set_parsed(void *parsed_result,
3412 __attribute__((unused)) struct cmdline *cl,
3413 __attribute__((unused)) void *data)
3414 {
3415 struct cmd_set_result *res = parsed_result;
3416 if (!strcmp(res->what, "nbport")) {
3417 set_fwd_ports_number(res->value);
3418 fwd_config_setup();
3419 } else if (!strcmp(res->what, "nbcore")) {
3420 set_fwd_lcores_number(res->value);
3421 fwd_config_setup();
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);
3426 }
3427
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);
3435
3436 cmdline_parse_inst_t cmd_set_numbers = {
3437 .f = cmd_set_parsed,
3438 .data = NULL,
3439 .help_str = "set nbport|nbcore|burst|verbose <value>",
3440 .tokens = {
3441 (void *)&cmd_set_set,
3442 (void *)&cmd_set_what,
3443 (void *)&cmd_set_value,
3444 NULL,
3445 },
3446 };
3447
3448 /* *** SET LOG LEVEL CONFIGURATION *** */
3449
3450 struct cmd_set_log_result {
3451 cmdline_fixed_string_t set;
3452 cmdline_fixed_string_t log;
3453 cmdline_fixed_string_t type;
3454 uint32_t level;
3455 };
3456
3457 static void
3458 cmd_set_log_parsed(void *parsed_result,
3459 __attribute__((unused)) struct cmdline *cl,
3460 __attribute__((unused)) void *data)
3461 {
3462 struct cmd_set_log_result *res;
3463 int ret;
3464
3465 res = parsed_result;
3466 if (!strcmp(res->type, "global"))
3467 rte_log_set_global_level(res->level);
3468 else {
3469 ret = rte_log_set_level_regexp(res->type, res->level);
3470 if (ret < 0)
3471 printf("Unable to set log level\n");
3472 }
3473 }
3474
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);
3483
3484 cmdline_parse_inst_t cmd_set_log = {
3485 .f = cmd_set_log_parsed,
3486 .data = NULL,
3487 .help_str = "set log global|<type> <level>",
3488 .tokens = {
3489 (void *)&cmd_set_log_set,
3490 (void *)&cmd_set_log_log,
3491 (void *)&cmd_set_log_type,
3492 (void *)&cmd_set_log_level,
3493 NULL,
3494 },
3495 };
3496
3497 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
3498
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;
3503 };
3504
3505 static void
3506 cmd_set_txpkts_parsed(void *parsed_result,
3507 __attribute__((unused)) struct cmdline *cl,
3508 __attribute__((unused)) void *data)
3509 {
3510 struct cmd_set_txpkts_result *res;
3511 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
3512 unsigned int nb_segs;
3513
3514 res = parsed_result;
3515 nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3516 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
3517 if (nb_segs > 0)
3518 set_tx_pkt_segments(seg_lengths, nb_segs);
3519 }
3520
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,
3526 txpkts, "txpkts");
3527 cmdline_parse_token_string_t cmd_set_txpkts_lengths =
3528 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
3529 seg_lengths, NULL);
3530
3531 cmdline_parse_inst_t cmd_set_txpkts = {
3532 .f = cmd_set_txpkts_parsed,
3533 .data = NULL,
3534 .help_str = "set txpkts <len0[,len1]*>",
3535 .tokens = {
3536 (void *)&cmd_set_txpkts_keyword,
3537 (void *)&cmd_set_txpkts_name,
3538 (void *)&cmd_set_txpkts_lengths,
3539 NULL,
3540 },
3541 };
3542
3543 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
3544
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;
3549 };
3550
3551 static void
3552 cmd_set_txsplit_parsed(void *parsed_result,
3553 __attribute__((unused)) struct cmdline *cl,
3554 __attribute__((unused)) void *data)
3555 {
3556 struct cmd_set_txsplit_result *res;
3557
3558 res = parsed_result;
3559 set_tx_pkt_split(res->mode);
3560 }
3561
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,
3570 mode, NULL);
3571
3572 cmdline_parse_inst_t cmd_set_txsplit = {
3573 .f = cmd_set_txsplit_parsed,
3574 .data = NULL,
3575 .help_str = "set txsplit on|off|rand",
3576 .tokens = {
3577 (void *)&cmd_set_txsplit_keyword,
3578 (void *)&cmd_set_txsplit_name,
3579 (void *)&cmd_set_txsplit_mode,
3580 NULL,
3581 },
3582 };
3583
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;
3589 portid_t port_id;
3590 };
3591
3592 static void
3593 cmd_rx_vlan_filter_all_parsed(void *parsed_result,
3594 __attribute__((unused)) struct cmdline *cl,
3595 __attribute__((unused)) void *data)
3596 {
3597 struct cmd_rx_vlan_filter_all_result *res = parsed_result;
3598
3599 if (!strcmp(res->what, "add"))
3600 rx_vlan_all_filter_set(res->port_id, 1);
3601 else
3602 rx_vlan_all_filter_set(res->port_id, 0);
3603 }
3604
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,
3610 what, "add#rm");
3611 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
3612 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3613 all, "all");
3614 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
3615 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
3616 port_id, UINT16);
3617
3618 cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
3619 .f = cmd_rx_vlan_filter_all_parsed,
3620 .data = NULL,
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",
3624 .tokens = {
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,
3629 NULL,
3630 },
3631 };
3632
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;
3641 };
3642
3643 static void
3644 cmd_vlan_offload_parsed(void *parsed_result,
3645 __attribute__((unused)) struct cmdline *cl,
3646 __attribute__((unused)) void *data)
3647 {
3648 int on;
3649 struct cmd_vlan_offload_result *res = parsed_result;
3650 char *str;
3651 int i, len = 0;
3652 portid_t port_id = 0;
3653 unsigned int tmp;
3654
3655 str = res->port_id;
3656 len = strnlen(str, STR_TOKEN_SIZE);
3657 i = 0;
3658 /* Get port_id first */
3659 while(i < len){
3660 if(str[i] == ',')
3661 break;
3662
3663 i++;
3664 }
3665 str[i]='\0';
3666 tmp = strtoul(str, NULL, 0);
3667 /* If port_id greater that what portid_t can represent, return */
3668 if(tmp >= RTE_MAX_ETHPORTS)
3669 return;
3670 port_id = (portid_t)tmp;
3671
3672 if (!strcmp(res->on, "on"))
3673 on = 1;
3674 else
3675 on = 0;
3676
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;
3681
3682 /* No queue_id, return */
3683 if(i + 1 >= len) {
3684 printf("must specify (port,queue_id)\n");
3685 return;
3686 }
3687 tmp = strtoul(str + i + 1, NULL, 0);
3688 /* If queue_id greater that what 16-bits can represent, return */
3689 if(tmp > 0xffff)
3690 return;
3691
3692 queue_id = (uint16_t)tmp;
3693 rx_vlan_strip_set_on_queue(port_id, queue_id, on);
3694 }
3695 else if (!strcmp(res->what, "filter"))
3696 rx_vlan_filter_set(port_id, on);
3697 else
3698 vlan_extend_set(port_id, on);
3699
3700 return;
3701 }
3702
3703 cmdline_parse_token_string_t cmd_vlan_offload_vlan =
3704 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3705 vlan, "vlan");
3706 cmdline_parse_token_string_t cmd_vlan_offload_set =
3707 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3708 set, "set");
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,
3714 on, "on#off");
3715 cmdline_parse_token_string_t cmd_vlan_offload_portid =
3716 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
3717 port_id, NULL);
3718
3719 cmdline_parse_inst_t cmd_vlan_offload = {
3720 .f = cmd_vlan_offload_parsed,
3721 .data = NULL,
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",
3725 .tokens = {
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,
3731 NULL,
3732 },
3733 };
3734
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;
3741 uint16_t tp_id;
3742 portid_t port_id;
3743 };
3744
3745 static void
3746 cmd_vlan_tpid_parsed(void *parsed_result,
3747 __attribute__((unused)) struct cmdline *cl,
3748 __attribute__((unused)) void *data)
3749 {
3750 struct cmd_vlan_tpid_result *res = parsed_result;
3751 enum rte_vlan_type vlan_type;
3752
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;
3757 else {
3758 printf("Unknown vlan type\n");
3759 return;
3760 }
3761 vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
3762 }
3763
3764 cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
3765 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3766 vlan, "vlan");
3767 cmdline_parse_token_string_t cmd_vlan_tpid_set =
3768 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
3769 set, "set");
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,
3775 what, "tpid");
3776 cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
3777 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3778 tp_id, UINT16);
3779 cmdline_parse_token_num_t cmd_vlan_tpid_portid =
3780 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
3781 port_id, UINT16);
3782
3783 cmdline_parse_inst_t cmd_vlan_tpid = {
3784 .f = cmd_vlan_tpid_parsed,
3785 .data = NULL,
3786 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
3787 "Set the VLAN Ether type",
3788 .tokens = {
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,
3795 NULL,
3796 },
3797 };
3798
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;
3803 uint16_t vlan_id;
3804 portid_t port_id;
3805 };
3806
3807 static void
3808 cmd_rx_vlan_filter_parsed(void *parsed_result,
3809 __attribute__((unused)) struct cmdline *cl,
3810 __attribute__((unused)) void *data)
3811 {
3812 struct cmd_rx_vlan_filter_result *res = parsed_result;
3813
3814 if (!strcmp(res->what, "add"))
3815 rx_vft_set(res->port_id, res->vlan_id, 1);
3816 else
3817 rx_vft_set(res->port_id, res->vlan_id, 0);
3818 }
3819
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,
3825 what, "add#rm");
3826 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
3827 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3828 vlan_id, UINT16);
3829 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
3830 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
3831 port_id, UINT16);
3832
3833 cmdline_parse_inst_t cmd_rx_vlan_filter = {
3834 .f = cmd_rx_vlan_filter_parsed,
3835 .data = NULL,
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",
3839 .tokens = {
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,
3844 NULL,
3845 },
3846 };
3847
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;
3852 portid_t port_id;
3853 uint16_t vlan_id;
3854 };
3855
3856 static void
3857 cmd_tx_vlan_set_parsed(void *parsed_result,
3858 __attribute__((unused)) struct cmdline *cl,
3859 __attribute__((unused)) void *data)
3860 {
3861 struct cmd_tx_vlan_set_result *res = parsed_result;
3862
3863 if (!port_is_stopped(res->port_id)) {
3864 printf("Please stop port %d first\n", res->port_id);
3865 return;
3866 }
3867
3868 tx_vlan_set(res->port_id, res->vlan_id);
3869
3870 cmd_reconfig_device_queue(res->port_id, 1, 1);
3871 }
3872
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,
3878 set, "set");
3879 cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
3880 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3881 port_id, UINT16);
3882 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
3883 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
3884 vlan_id, UINT16);
3885
3886 cmdline_parse_inst_t cmd_tx_vlan_set = {
3887 .f = cmd_tx_vlan_set_parsed,
3888 .data = NULL,
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",
3892 .tokens = {
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,
3897 NULL,
3898 },
3899 };
3900
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;
3905 portid_t port_id;
3906 uint16_t vlan_id;
3907 uint16_t vlan_id_outer;
3908 };
3909
3910 static void
3911 cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
3912 __attribute__((unused)) struct cmdline *cl,
3913 __attribute__((unused)) void *data)
3914 {
3915 struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
3916
3917 if (!port_is_stopped(res->port_id)) {
3918 printf("Please stop port %d first\n", res->port_id);
3919 return;
3920 }
3921
3922 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
3923
3924 cmd_reconfig_device_queue(res->port_id, 1, 1);
3925 }
3926
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,
3932 set, "set");
3933 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
3934 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3935 port_id, UINT16);
3936 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
3937 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
3938 vlan_id, UINT16);
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);
3942
3943 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
3944 .f = cmd_tx_vlan_set_qinq_parsed,
3945 .data = NULL,
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",
3949 .tokens = {
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,
3955 NULL,
3956 },
3957 };
3958
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;
3964 portid_t port_id;
3965 uint16_t vlan_id;
3966 cmdline_fixed_string_t mode;
3967 };
3968
3969 static void
3970 cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
3971 __attribute__((unused)) struct cmdline *cl,
3972 __attribute__((unused)) void *data)
3973 {
3974 struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
3975
3976 if (strcmp(res->mode, "on") == 0)
3977 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
3978 else
3979 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
3980 }
3981
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,
3987 set, "set");
3988 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
3989 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3990 pvid, "pvid");
3991 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
3992 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3993 port_id, UINT16);
3994 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
3995 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3996 vlan_id, UINT16);
3997 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
3998 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
3999 mode, "on#off");
4000
4001 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4002 .f = cmd_tx_vlan_set_pvid_parsed,
4003 .data = NULL,
4004 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4005 .tokens = {
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,
4012 NULL,
4013 },
4014 };
4015
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;
4020 portid_t port_id;
4021 };
4022
4023 static void
4024 cmd_tx_vlan_reset_parsed(void *parsed_result,
4025 __attribute__((unused)) struct cmdline *cl,
4026 __attribute__((unused)) void *data)
4027 {
4028 struct cmd_tx_vlan_reset_result *res = parsed_result;
4029
4030 if (!port_is_stopped(res->port_id)) {
4031 printf("Please stop port %d first\n", res->port_id);
4032 return;
4033 }
4034
4035 tx_vlan_reset(res->port_id);
4036
4037 cmd_reconfig_device_queue(res->port_id, 1, 1);
4038 }
4039
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,
4045 reset, "reset");
4046 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4047 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4048 port_id, UINT16);
4049
4050 cmdline_parse_inst_t cmd_tx_vlan_reset = {
4051 .f = cmd_tx_vlan_reset_parsed,
4052 .data = NULL,
4053 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4054 "VLAN header in packets sent on a port",
4055 .tokens = {
4056 (void *)&cmd_tx_vlan_reset_tx_vlan,
4057 (void *)&cmd_tx_vlan_reset_reset,
4058 (void *)&cmd_tx_vlan_reset_portid,
4059 NULL,
4060 },
4061 };
4062
4063
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;
4070 portid_t port_id;
4071 };
4072
4073 static void
4074 csum_show(int port_id)
4075 {
4076 struct rte_eth_dev_info dev_info;
4077 uint64_t tx_offloads;
4078
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");
4092
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);
4099 }
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);
4104 }
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);
4109 }
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);
4114 }
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);
4119 }
4120 }
4121
4122 static void
4123 cmd_csum_parsed(void *parsed_result,
4124 __attribute__((unused)) struct cmdline *cl,
4125 __attribute__((unused)) void *data)
4126 {
4127 struct cmd_csum_result *res = parsed_result;
4128 int hw = 0;
4129 uint64_t csum_offloads = 0;
4130 struct rte_eth_dev_info dev_info;
4131
4132 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4133 printf("invalid port %d\n", res->port_id);
4134 return;
4135 }
4136 if (!port_is_stopped(res->port_id)) {
4137 printf("Please stop port %d first\n", res->port_id);
4138 return;
4139 }
4140
4141 rte_eth_dev_info_get(res->port_id, &dev_info);
4142 if (!strcmp(res->mode, "set")) {
4143
4144 if (!strcmp(res->hwsw, "hw"))
4145 hw = 1;
4146
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;
4151 } else {
4152 printf("IP checksum offload is not supported "
4153 "by port %u\n", res->port_id);
4154 }
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;
4159 } else {
4160 printf("UDP checksum offload is not supported "
4161 "by port %u\n", res->port_id);
4162 }
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;
4167 } else {
4168 printf("TCP checksum offload is not supported "
4169 "by port %u\n", res->port_id);
4170 }
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;
4175 } else {
4176 printf("SCTP checksum offload is not supported "
4177 "by port %u\n", res->port_id);
4178 }
4179 } else if (!strcmp(res->proto, "outer-ip")) {
4180 if (hw == 0 || (dev_info.tx_offload_capa &
4181 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4182 csum_offloads |=
4183 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4184 } else {
4185 printf("Outer IP checksum offload is not "
4186 "supported by port %u\n", res->port_id);
4187 }
4188 }
4189
4190 if (hw) {
4191 ports[res->port_id].dev_conf.txmode.offloads |=
4192 csum_offloads;
4193 } else {
4194 ports[res->port_id].dev_conf.txmode.offloads &=
4195 (~csum_offloads);
4196 }
4197 }
4198 csum_show(res->port_id);
4199
4200 cmd_reconfig_device_queue(res->port_id, 1, 1);
4201 }
4202
4203 cmdline_parse_token_string_t cmd_csum_csum =
4204 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4205 csum, "csum");
4206 cmdline_parse_token_string_t cmd_csum_mode =
4207 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4208 mode, "set");
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,
4214 hwsw, "hw#sw");
4215 cmdline_parse_token_num_t cmd_csum_portid =
4216 TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4217 port_id, UINT16);
4218
4219 cmdline_parse_inst_t cmd_csum_set = {
4220 .f = cmd_csum_parsed,
4221 .data = NULL,
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",
4225 .tokens = {
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,
4231 NULL,
4232 },
4233 };
4234
4235 cmdline_parse_token_string_t cmd_csum_mode_show =
4236 TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4237 mode, "show");
4238
4239 cmdline_parse_inst_t cmd_csum_show = {
4240 .f = cmd_csum_parsed,
4241 .data = NULL,
4242 .help_str = "csum show <port_id>: Show checksum offload configuration",
4243 .tokens = {
4244 (void *)&cmd_csum_csum,
4245 (void *)&cmd_csum_mode_show,
4246 (void *)&cmd_csum_portid,
4247 NULL,
4248 },
4249 };
4250
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;
4256 portid_t port_id;
4257 };
4258
4259 static void
4260 cmd_csum_tunnel_parsed(void *parsed_result,
4261 __attribute__((unused)) struct cmdline *cl,
4262 __attribute__((unused)) void *data)
4263 {
4264 struct cmd_csum_tunnel_result *res = parsed_result;
4265
4266 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4267 return;
4268
4269 if (!strcmp(res->onoff, "on"))
4270 ports[res->port_id].parse_tunnel = 1;
4271 else
4272 ports[res->port_id].parse_tunnel = 0;
4273
4274 csum_show(res->port_id);
4275 }
4276
4277 cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4278 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4279 csum, "csum");
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,
4285 onoff, "on#off");
4286 cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4287 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4288 port_id, UINT16);
4289
4290 cmdline_parse_inst_t cmd_csum_tunnel = {
4291 .f = cmd_csum_tunnel_parsed,
4292 .data = NULL,
4293 .help_str = "csum parse_tunnel on|off <port_id>: "
4294 "Enable/Disable parsing of tunnels for csum engine",
4295 .tokens = {
4296 (void *)&cmd_csum_tunnel_csum,
4297 (void *)&cmd_csum_tunnel_parse,
4298 (void *)&cmd_csum_tunnel_onoff,
4299 (void *)&cmd_csum_tunnel_portid,
4300 NULL,
4301 },
4302 };
4303
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;
4308 uint16_t tso_segsz;
4309 portid_t port_id;
4310 };
4311
4312 static void
4313 cmd_tso_set_parsed(void *parsed_result,
4314 __attribute__((unused)) struct cmdline *cl,
4315 __attribute__((unused)) void *data)
4316 {
4317 struct cmd_tso_set_result *res = parsed_result;
4318 struct rte_eth_dev_info dev_info;
4319
4320 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4321 return;
4322 if (!port_is_stopped(res->port_id)) {
4323 printf("Please stop port %d first\n", res->port_id);
4324 return;
4325 }
4326
4327 if (!strcmp(res->mode, "set"))
4328 ports[res->port_id].tso_segsz = res->tso_segsz;
4329
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",
4334 res->port_id);
4335 return;
4336 }
4337
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");
4342 } else {
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);
4347 }
4348
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);
4355 }
4356
4357 cmd_reconfig_device_queue(res->port_id, 1, 1);
4358 }
4359
4360 cmdline_parse_token_string_t cmd_tso_set_tso =
4361 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4362 tso, "tso");
4363 cmdline_parse_token_string_t cmd_tso_set_mode =
4364 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4365 mode, "set");
4366 cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
4367 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4368 tso_segsz, UINT16);
4369 cmdline_parse_token_num_t cmd_tso_set_portid =
4370 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
4371 port_id, UINT16);
4372
4373 cmdline_parse_inst_t cmd_tso_set = {
4374 .f = cmd_tso_set_parsed,
4375 .data = NULL,
4376 .help_str = "tso set <tso_segsz> <port_id>: "
4377 "Set TSO segment size of non-tunneled packets for csum engine "
4378 "(0 to disable)",
4379 .tokens = {
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,
4384 NULL,
4385 },
4386 };
4387
4388 cmdline_parse_token_string_t cmd_tso_show_mode =
4389 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
4390 mode, "show");
4391
4392
4393 cmdline_parse_inst_t cmd_tso_show = {
4394 .f = cmd_tso_set_parsed,
4395 .data = NULL,
4396 .help_str = "tso show <port_id>: "
4397 "Show TSO segment size of non-tunneled packets for csum engine",
4398 .tokens = {
4399 (void *)&cmd_tso_set_tso,
4400 (void *)&cmd_tso_show_mode,
4401 (void *)&cmd_tso_set_portid,
4402 NULL,
4403 },
4404 };
4405
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;
4410 uint16_t tso_segsz;
4411 portid_t port_id;
4412 };
4413
4414 static struct rte_eth_dev_info
4415 check_tunnel_tso_nic_support(portid_t port_id)
4416 {
4417 struct rte_eth_dev_info dev_info;
4418
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);
4438 return dev_info;
4439 }
4440
4441 static void
4442 cmd_tunnel_tso_set_parsed(void *parsed_result,
4443 __attribute__((unused)) struct cmdline *cl,
4444 __attribute__((unused)) void *data)
4445 {
4446 struct cmd_tunnel_tso_set_result *res = parsed_result;
4447 struct rte_eth_dev_info dev_info;
4448
4449 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4450 return;
4451 if (!port_is_stopped(res->port_id)) {
4452 printf("Please stop port %d first\n", res->port_id);
4453 return;
4454 }
4455
4456 if (!strcmp(res->mode, "set"))
4457 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
4458
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");
4469 } else {
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);
4476
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);
4481
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
4485 * are recognized;
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.
4492 */
4493
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");
4501 }
4502
4503 cmd_reconfig_device_queue(res->port_id, 1, 1);
4504 }
4505
4506 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
4507 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4508 tso, "tunnel_tso");
4509 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
4510 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4511 mode, "set");
4512 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
4513 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4514 tso_segsz, UINT16);
4515 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
4516 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
4517 port_id, UINT16);
4518
4519 cmdline_parse_inst_t cmd_tunnel_tso_set = {
4520 .f = cmd_tunnel_tso_set_parsed,
4521 .data = NULL,
4522 .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
4523 "Set TSO segment size of tunneled packets for csum engine "
4524 "(0 to disable)",
4525 .tokens = {
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,
4530 NULL,
4531 },
4532 };
4533
4534 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
4535 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
4536 mode, "show");
4537
4538
4539 cmdline_parse_inst_t cmd_tunnel_tso_show = {
4540 .f = cmd_tunnel_tso_set_parsed,
4541 .data = NULL,
4542 .help_str = "tunnel_tso show <port_id> "
4543 "Show TSO segment size of tunneled packets for csum engine",
4544 .tokens = {
4545 (void *)&cmd_tunnel_tso_set_tso,
4546 (void *)&cmd_tunnel_tso_show_mode,
4547 (void *)&cmd_tunnel_tso_set_portid,
4548 NULL,
4549 },
4550 };
4551
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;
4558 portid_t cmd_pid;
4559 };
4560
4561 static void
4562 cmd_gro_enable_parsed(void *parsed_result,
4563 __attribute__((unused)) struct cmdline *cl,
4564 __attribute__((unused)) void *data)
4565 {
4566 struct cmd_gro_enable_result *res;
4567
4568 res = parsed_result;
4569 if (!strcmp(res->cmd_keyword, "gro"))
4570 setup_gro(res->cmd_onoff, res->cmd_pid);
4571 }
4572
4573 cmdline_parse_token_string_t cmd_gro_enable_set =
4574 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
4575 cmd_set, "set");
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,
4581 cmd_pid, UINT16);
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");
4588
4589 cmdline_parse_inst_t cmd_gro_enable = {
4590 .f = cmd_gro_enable_parsed,
4591 .data = NULL,
4592 .help_str = "set port <port_id> gro on|off",
4593 .tokens = {
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,
4599 NULL,
4600 },
4601 };
4602
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;
4608 portid_t cmd_pid;
4609 };
4610
4611 static void
4612 cmd_gro_show_parsed(void *parsed_result,
4613 __attribute__((unused)) struct cmdline *cl,
4614 __attribute__((unused)) void *data)
4615 {
4616 struct cmd_gro_show_result *res;
4617
4618 res = parsed_result;
4619 if (!strcmp(res->cmd_keyword, "gro"))
4620 show_gro(res->cmd_pid);
4621 }
4622
4623 cmdline_parse_token_string_t cmd_gro_show_show =
4624 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4625 cmd_show, "show");
4626 cmdline_parse_token_string_t cmd_gro_show_port =
4627 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4628 cmd_port, "port");
4629 cmdline_parse_token_num_t cmd_gro_show_pid =
4630 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
4631 cmd_pid, UINT16);
4632 cmdline_parse_token_string_t cmd_gro_show_keyword =
4633 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
4634 cmd_keyword, "gro");
4635
4636 cmdline_parse_inst_t cmd_gro_show = {
4637 .f = cmd_gro_show_parsed,
4638 .data = NULL,
4639 .help_str = "show port <port_id> gro",
4640 .tokens = {
4641 (void *)&cmd_gro_show_show,
4642 (void *)&cmd_gro_show_port,
4643 (void *)&cmd_gro_show_pid,
4644 (void *)&cmd_gro_show_keyword,
4645 NULL,
4646 },
4647 };
4648
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;
4654 uint8_t cmd_cycles;
4655 };
4656
4657 static void
4658 cmd_gro_flush_parsed(void *parsed_result,
4659 __attribute__((unused)) struct cmdline *cl,
4660 __attribute__((unused)) void *data)
4661 {
4662 struct cmd_gro_flush_result *res;
4663
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);
4668 }
4669
4670 cmdline_parse_token_string_t cmd_gro_flush_set =
4671 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
4672 cmd_set, "set");
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,
4681 cmd_cycles, UINT8);
4682
4683 cmdline_parse_inst_t cmd_gro_flush = {
4684 .f = cmd_gro_flush_parsed,
4685 .data = NULL,
4686 .help_str = "set gro flush <cycles>",
4687 .tokens = {
4688 (void *)&cmd_gro_flush_set,
4689 (void *)&cmd_gro_flush_keyword,
4690 (void *)&cmd_gro_flush_flush,
4691 (void *)&cmd_gro_flush_cycles,
4692 NULL,
4693 },
4694 };
4695
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;
4702 portid_t cmd_pid;
4703 };
4704
4705 static void
4706 cmd_gso_enable_parsed(void *parsed_result,
4707 __attribute__((unused)) struct cmdline *cl,
4708 __attribute__((unused)) void *data)
4709 {
4710 struct cmd_gso_enable_result *res;
4711
4712 res = parsed_result;
4713 if (!strcmp(res->cmd_keyword, "gso"))
4714 setup_gso(res->cmd_mode, res->cmd_pid);
4715 }
4716
4717 cmdline_parse_token_string_t cmd_gso_enable_set =
4718 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4719 cmd_set, "set");
4720 cmdline_parse_token_string_t cmd_gso_enable_port =
4721 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
4722 cmd_port, "port");
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,
4731 cmd_pid, UINT16);
4732
4733 cmdline_parse_inst_t cmd_gso_enable = {
4734 .f = cmd_gso_enable_parsed,
4735 .data = NULL,
4736 .help_str = "set port <port_id> gso on|off",
4737 .tokens = {
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,
4743 NULL,
4744 },
4745 };
4746
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;
4752 uint16_t cmd_size;
4753 };
4754
4755 static void
4756 cmd_gso_size_parsed(void *parsed_result,
4757 __attribute__((unused)) struct cmdline *cl,
4758 __attribute__((unused)) void *data)
4759 {
4760 struct cmd_gso_size_result *res = parsed_result;
4761
4762 if (test_done == 0) {
4763 printf("Before setting GSO segsz, please first"
4764 " stop fowarding\n");
4765 return;
4766 }
4767
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);
4774 else
4775 gso_max_segment_size = res->cmd_size;
4776 }
4777 }
4778
4779 cmdline_parse_token_string_t cmd_gso_size_set =
4780 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
4781 cmd_set, "set");
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,
4790 cmd_size, UINT16);
4791
4792 cmdline_parse_inst_t cmd_gso_size = {
4793 .f = cmd_gso_size_parsed,
4794 .data = NULL,
4795 .help_str = "set gso segsz <length>",
4796 .tokens = {
4797 (void *)&cmd_gso_size_set,
4798 (void *)&cmd_gso_size_keyword,
4799 (void *)&cmd_gso_size_segsz,
4800 (void *)&cmd_gso_size_size,
4801 NULL,
4802 },
4803 };
4804
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;
4810 portid_t cmd_pid;
4811 };
4812
4813 static void
4814 cmd_gso_show_parsed(void *parsed_result,
4815 __attribute__((unused)) struct cmdline *cl,
4816 __attribute__((unused)) void *data)
4817 {
4818 struct cmd_gso_show_result *res = parsed_result;
4819
4820 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
4821 printf("invalid port id %u\n", res->cmd_pid);
4822 return;
4823 }
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);
4832 } else
4833 printf("GSO is not enabled on Port %u\n", res->cmd_pid);
4834 }
4835 }
4836
4837 cmdline_parse_token_string_t cmd_gso_show_show =
4838 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4839 cmd_show, "show");
4840 cmdline_parse_token_string_t cmd_gso_show_port =
4841 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
4842 cmd_port, "port");
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,
4848 cmd_pid, UINT16);
4849
4850 cmdline_parse_inst_t cmd_gso_show = {
4851 .f = cmd_gso_show_parsed,
4852 .data = NULL,
4853 .help_str = "show port <port_id> gso",
4854 .tokens = {
4855 (void *)&cmd_gso_show_show,
4856 (void *)&cmd_gso_show_port,
4857 (void *)&cmd_gso_show_pid,
4858 (void *)&cmd_gso_show_keyword,
4859 NULL,
4860 },
4861 };
4862
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;
4868 };
4869
4870 static void
4871 cmd_set_flush_rx_parsed(void *parsed_result,
4872 __attribute__((unused)) struct cmdline *cl,
4873 __attribute__((unused)) void *data)
4874 {
4875 struct cmd_set_flush_rx *res = parsed_result;
4876 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4877 }
4878
4879 cmdline_parse_token_string_t cmd_setflushrx_set =
4880 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
4881 set, "set");
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,
4887 mode, "on#off");
4888
4889
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",
4893 .data = NULL,
4894 .tokens = {
4895 (void *)&cmd_setflushrx_set,
4896 (void *)&cmd_setflushrx_flush_rx,
4897 (void *)&cmd_setflushrx_mode,
4898 NULL,
4899 },
4900 };
4901
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;
4907 };
4908
4909 static void
4910 cmd_set_link_check_parsed(void *parsed_result,
4911 __attribute__((unused)) struct cmdline *cl,
4912 __attribute__((unused)) void *data)
4913 {
4914 struct cmd_set_link_check *res = parsed_result;
4915 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
4916 }
4917
4918 cmdline_parse_token_string_t cmd_setlinkcheck_set =
4919 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
4920 set, "set");
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,
4926 mode, "on#off");
4927
4928
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",
4933 .data = NULL,
4934 .tokens = {
4935 (void *)&cmd_setlinkcheck_set,
4936 (void *)&cmd_setlinkcheck_link_check,
4937 (void *)&cmd_setlinkcheck_mode,
4938 NULL,
4939 },
4940 };
4941
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;
4948 portid_t port_id;
4949 };
4950
4951 static void
4952 cmd_set_bypass_mode_parsed(void *parsed_result,
4953 __attribute__((unused)) struct cmdline *cl,
4954 __attribute__((unused)) void *data)
4955 {
4956 struct cmd_set_bypass_mode_result *res = parsed_result;
4957 portid_t port_id = res->port_id;
4958 int32_t rc = -EINVAL;
4959
4960 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS
4961 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4962
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;
4967 else
4968 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
4969
4970 /* Set the bypass mode for the relevant port. */
4971 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode);
4972 #endif
4973 if (rc != 0)
4974 printf("\t Failed to set bypass mode for port = %d.\n", port_id);
4975 }
4976
4977 cmdline_parse_token_string_t cmd_setbypass_mode_set =
4978 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4979 set, "set");
4980 cmdline_parse_token_string_t cmd_setbypass_mode_bypass =
4981 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4982 bypass, "bypass");
4983 cmdline_parse_token_string_t cmd_setbypass_mode_mode =
4984 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result,
4985 mode, "mode");
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,
4991 port_id, UINT16);
4992
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",
4997 .data = NULL,
4998 .tokens = {
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,
5004 NULL,
5005 },
5006 };
5007
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;
5016 portid_t port_id;
5017 };
5018
5019 static void
5020 cmd_set_bypass_event_parsed(void *parsed_result,
5021 __attribute__((unused)) struct cmdline *cl,
5022 __attribute__((unused)) void *data)
5023 {
5024 int32_t rc = -EINVAL;
5025 struct cmd_set_bypass_event_result *res = parsed_result;
5026 portid_t port_id = res->port_id;
5027
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;
5031
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;
5042 else
5043 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE;
5044
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;
5049 else
5050 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL;
5051
5052 /* Set the watchdog timeout. */
5053 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) {
5054
5055 rc = -EINVAL;
5056 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) {
5057 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id,
5058 bypass_timeout);
5059 }
5060 if (rc != 0) {
5061 printf("Failed to set timeout value %u "
5062 "for port %d, errto code: %d.\n",
5063 bypass_timeout, port_id, rc);
5064 }
5065 }
5066
5067 /* Set the bypass event to transition to bypass mode. */
5068 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event,
5069 bypass_mode);
5070 #endif
5071
5072 if (rc != 0)
5073 printf("\t Failed to set bypass event for port = %d.\n",
5074 port_id);
5075 }
5076
5077 cmdline_parse_token_string_t cmd_setbypass_event_set =
5078 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5079 set, "set");
5080 cmdline_parse_token_string_t cmd_setbypass_event_bypass =
5081 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5082 bypass, "bypass");
5083 cmdline_parse_token_string_t cmd_setbypass_event_event =
5084 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result,
5085 event, "event");
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,
5091 mode, "mode");
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,
5097 port_id, UINT16);
5098
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",
5104 .data = NULL,
5105 .tokens = {
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,
5113 NULL,
5114 },
5115 };
5116
5117
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;
5124 };
5125
5126 static void
5127 cmd_set_bypass_timeout_parsed(void *parsed_result,
5128 __attribute__((unused)) struct cmdline *cl,
5129 __attribute__((unused)) void *data)
5130 {
5131 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result;
5132
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;
5148 else
5149 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5150 #endif
5151 }
5152
5153 cmdline_parse_token_string_t cmd_setbypass_timeout_set =
5154 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5155 set, "set");
5156 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass =
5157 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result,
5158 bypass, "bypass");
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");
5165
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",
5170 .data = NULL,
5171 .tokens = {
5172 (void *)&cmd_setbypass_timeout_set,
5173 (void *)&cmd_setbypass_timeout_bypass,
5174 (void *)&cmd_setbypass_timeout_timeout,
5175 (void *)&cmd_setbypass_timeout_value,
5176 NULL,
5177 },
5178 };
5179
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;
5185 portid_t port_id;
5186 };
5187
5188 static void
5189 cmd_show_bypass_config_parsed(void *parsed_result,
5190 __attribute__((unused)) struct cmdline *cl,
5191 __attribute__((unused)) void *data)
5192 {
5193 struct cmd_show_bypass_config_result *res = parsed_result;
5194 portid_t port_id = res->port_id;
5195 int rc = -EINVAL;
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;
5200 int i;
5201
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] = {
5207 "NONE",
5208 "OS/board on",
5209 "power supply on",
5210 "OS/board off",
5211 "power supply off",
5212 "timeout"};
5213 int num_events = (sizeof events) / (sizeof events[0]);
5214
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);
5218 return;
5219 }
5220 else {
5221 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode))
5222 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5223
5224 printf("\tbypass mode = %s\n", modes[bypass_mode]);
5225 }
5226
5227 /* Display the bypass timeout.*/
5228 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout))
5229 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF;
5230
5231 printf("\tbypass timeout = %s\n", timeouts[timeout]);
5232
5233 /* Display the bypass events and associated modes. */
5234 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) {
5235
5236 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) {
5237 printf("\tFailed to get bypass mode for event = %s\n",
5238 events[i]);
5239 } else {
5240 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode))
5241 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE;
5242
5243 printf("\tbypass event: %-16s = %s\n", events[i],
5244 modes[event_mode]);
5245 }
5246 }
5247 #endif
5248 if (rc != 0)
5249 printf("\tFailed to get bypass configuration for port = %d\n",
5250 port_id);
5251 }
5252
5253 cmdline_parse_token_string_t cmd_showbypass_config_show =
5254 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5255 show, "show");
5256 cmdline_parse_token_string_t cmd_showbypass_config_bypass =
5257 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5258 bypass, "bypass");
5259 cmdline_parse_token_string_t cmd_showbypass_config_config =
5260 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result,
5261 config, "config");
5262 cmdline_parse_token_num_t cmd_showbypass_config_port =
5263 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result,
5264 port_id, UINT16);
5265
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",
5270 .data = NULL,
5271 .tokens = {
5272 (void *)&cmd_showbypass_config_show,
5273 (void *)&cmd_showbypass_config_bypass,
5274 (void *)&cmd_showbypass_config_config,
5275 (void *)&cmd_showbypass_config_port,
5276 NULL,
5277 },
5278 };
5279
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;
5286 uint8_t value;
5287 portid_t port_id;
5288 };
5289
5290 static void cmd_set_bonding_mode_parsed(void *parsed_result,
5291 __attribute__((unused)) struct cmdline *cl,
5292 __attribute__((unused)) void *data)
5293 {
5294 struct cmd_set_bonding_mode_result *res = parsed_result;
5295 portid_t port_id = res->port_id;
5296
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);
5300 }
5301
5302 cmdline_parse_token_string_t cmd_setbonding_mode_set =
5303 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result,
5304 set, "set");
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,
5310 mode, "mode");
5311 cmdline_parse_token_num_t cmd_setbonding_mode_value =
5312 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5313 value, UINT8);
5314 cmdline_parse_token_num_t cmd_setbonding_mode_port =
5315 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result,
5316 port_id, UINT16);
5317
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",
5322 .data = NULL,
5323 .tokens = {
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,
5329 NULL
5330 }
5331 };
5332
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;
5339 portid_t port_id;
5340 cmdline_fixed_string_t mode;
5341 };
5342
5343 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result,
5344 __attribute__((unused)) struct cmdline *cl,
5345 __attribute__((unused)) void *data)
5346 {
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;
5350
5351 port = &ports[port_id];
5352
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);
5356 return;
5357 }
5358
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"
5362 " enabled\n");
5363 else
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 "
5369 "disabled\n");
5370 else
5371 printf("Disabling dedicated queues for LACP control "
5372 "traffic on port %d failed\n", port_id);
5373 }
5374 }
5375
5376 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set =
5377 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result,
5378 set, "set");
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,
5384 lacp, "lacp");
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,
5390 port_id, UINT16);
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");
5394
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> "
5398 "enable|disable: "
5399 "Enable/disable dedicated queues for LACP control traffic for port_id",
5400 .data = NULL,
5401 .tokens = {
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,
5408 NULL
5409 }
5410 };
5411
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;
5417 portid_t port_id;
5418 cmdline_fixed_string_t policy;
5419 };
5420
5421 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result,
5422 __attribute__((unused)) struct cmdline *cl,
5423 __attribute__((unused)) void *data)
5424 {
5425 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result;
5426 portid_t port_id = res->port_id;
5427 uint8_t policy;
5428
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;
5435 } else {
5436 printf("\t Invalid xmit policy selection");
5437 return;
5438 }
5439
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",
5443 port_id);
5444 }
5445 }
5446
5447 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set =
5448 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result,
5449 set, "set");
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,
5458 port_id, UINT16);
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");
5462
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> "
5466 "l2|l23|l34: "
5467 "Set the bonding balance_xmit_policy for port_id",
5468 .data = NULL,
5469 .tokens = {
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,
5475 NULL
5476 }
5477 };
5478
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;
5484 portid_t port_id;
5485 };
5486
5487 static void cmd_show_bonding_config_parsed(void *parsed_result,
5488 __attribute__((unused)) struct cmdline *cl,
5489 __attribute__((unused)) void *data)
5490 {
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;
5495 int primary_id;
5496 int i;
5497 portid_t port_id = res->port_id;
5498
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);
5503 return;
5504 } else
5505 printf("\tBonding mode: %d\n", bonding_mode);
5506
5507 if (bonding_mode == BONDING_MODE_BALANCE) {
5508 int balance_xmit_policy;
5509
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",
5513 port_id);
5514 return;
5515 } else {
5516 printf("\tBalance Xmit Policy: ");
5517
5518 switch (balance_xmit_policy) {
5519 case BALANCE_XMIT_POLICY_LAYER2:
5520 printf("BALANCE_XMIT_POLICY_LAYER2");
5521 break;
5522 case BALANCE_XMIT_POLICY_LAYER23:
5523 printf("BALANCE_XMIT_POLICY_LAYER23");
5524 break;
5525 case BALANCE_XMIT_POLICY_LAYER34:
5526 printf("BALANCE_XMIT_POLICY_LAYER34");
5527 break;
5528 }
5529 printf("\n");
5530 }
5531 }
5532
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: ");
5536 switch (agg_mode) {
5537 case AGG_BANDWIDTH:
5538 printf("bandwidth");
5539 break;
5540 case AGG_STABLE:
5541 printf("stable");
5542 break;
5543 case AGG_COUNT:
5544 printf("count");
5545 break;
5546 }
5547 printf("\n");
5548 }
5549
5550 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
5551
5552 if (num_slaves < 0) {
5553 printf("\tFailed to get slave list for port = %d\n", port_id);
5554 return;
5555 }
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]);
5560
5561 printf("%d]\n", slaves[num_slaves - 1]);
5562 } else {
5563 printf("\tSlaves: []\n");
5564
5565 }
5566
5567 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
5568 RTE_MAX_ETHPORTS);
5569
5570 if (num_active_slaves < 0) {
5571 printf("\tFailed to get active slave list for port = %d\n", port_id);
5572 return;
5573 }
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]);
5578
5579 printf("%d]\n", slaves[num_active_slaves - 1]);
5580
5581 } else {
5582 printf("\tActive Slaves: []\n");
5583
5584 }
5585
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);
5589 return;
5590 } else
5591 printf("\tPrimary: [%d]\n", primary_id);
5592
5593 }
5594
5595 cmdline_parse_token_string_t cmd_showbonding_config_show =
5596 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result,
5597 show, "show");
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,
5603 config, "config");
5604 cmdline_parse_token_num_t cmd_showbonding_config_port =
5605 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result,
5606 port_id, UINT16);
5607
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",
5612 .data = NULL,
5613 .tokens = {
5614 (void *)&cmd_showbonding_config_show,
5615 (void *)&cmd_showbonding_config_bonding,
5616 (void *)&cmd_showbonding_config_config,
5617 (void *)&cmd_showbonding_config_port,
5618 NULL
5619 }
5620 };
5621
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;
5627 portid_t slave_id;
5628 portid_t port_id;
5629 };
5630
5631 static void cmd_set_bonding_primary_parsed(void *parsed_result,
5632 __attribute__((unused)) struct cmdline *cl,
5633 __attribute__((unused)) void *data)
5634 {
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;
5638
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",
5642 master_port_id);
5643 return;
5644 }
5645 init_port_config();
5646 }
5647
5648 cmdline_parse_token_string_t cmd_setbonding_primary_set =
5649 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result,
5650 set, "set");
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,
5659 slave_id, UINT16);
5660 cmdline_parse_token_num_t cmd_setbonding_primary_port =
5661 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result,
5662 port_id, UINT16);
5663
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",
5668 .data = NULL,
5669 .tokens = {
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,
5675 NULL
5676 }
5677 };
5678
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;
5684 portid_t slave_id;
5685 portid_t port_id;
5686 };
5687
5688 static void cmd_add_bonding_slave_parsed(void *parsed_result,
5689 __attribute__((unused)) struct cmdline *cl,
5690 __attribute__((unused)) void *data)
5691 {
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;
5695
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);
5700 return;
5701 }
5702 init_port_config();
5703 set_port_slave_flag(slave_port_id);
5704 }
5705
5706 cmdline_parse_token_string_t cmd_addbonding_slave_add =
5707 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result,
5708 add, "add");
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,
5714 slave, "slave");
5715 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid =
5716 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5717 slave_id, UINT16);
5718 cmdline_parse_token_num_t cmd_addbonding_slave_port =
5719 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result,
5720 port_id, UINT16);
5721
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",
5726 .data = NULL,
5727 .tokens = {
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,
5733 NULL
5734 }
5735 };
5736
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;
5742 portid_t slave_id;
5743 portid_t port_id;
5744 };
5745
5746 static void cmd_remove_bonding_slave_parsed(void *parsed_result,
5747 __attribute__((unused)) struct cmdline *cl,
5748 __attribute__((unused)) void *data)
5749 {
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;
5753
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);
5758 return;
5759 }
5760 init_port_config();
5761 clear_port_slave_flag(slave_port_id);
5762 }
5763
5764 cmdline_parse_token_string_t cmd_removebonding_slave_remove =
5765 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result,
5766 remove, "remove");
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,
5772 slave, "slave");
5773 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid =
5774 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5775 slave_id, UINT16);
5776 cmdline_parse_token_num_t cmd_removebonding_slave_port =
5777 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result,
5778 port_id, UINT16);
5779
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",
5784 .data = NULL,
5785 .tokens = {
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,
5791 NULL
5792 }
5793 };
5794
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;
5800 uint8_t mode;
5801 uint8_t socket;
5802 };
5803
5804 static int bond_dev_num = 0;
5805
5806 static void cmd_create_bonded_device_parsed(void *parsed_result,
5807 __attribute__((unused)) struct cmdline *cl,
5808 __attribute__((unused)) void *data)
5809 {
5810 struct cmd_create_bonded_device_result *res = parsed_result;
5811 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
5812 int port_id;
5813
5814 if (test_done == 0) {
5815 printf("Please stop forwarding first\n");
5816 return;
5817 }
5818
5819 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d",
5820 bond_dev_num++);
5821
5822 /* Create a new bonded device. */
5823 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket);
5824 if (port_id < 0) {
5825 printf("\t Failed to create bonded device.\n");
5826 return;
5827 } else {
5828 printf("Created new bonded device %s on (port %d).\n", ethdev_name,
5829 port_id);
5830
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);
5835 }
5836
5837 }
5838
5839 cmdline_parse_token_string_t cmd_createbonded_device_create =
5840 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5841 create, "create");
5842 cmdline_parse_token_string_t cmd_createbonded_device_bonded =
5843 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5844 bonded, "bonded");
5845 cmdline_parse_token_string_t cmd_createbonded_device_device =
5846 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result,
5847 device, "device");
5848 cmdline_parse_token_num_t cmd_createbonded_device_mode =
5849 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5850 mode, UINT8);
5851 cmdline_parse_token_num_t cmd_createbonded_device_socket =
5852 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result,
5853 socket, UINT8);
5854
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",
5859 .data = NULL,
5860 .tokens = {
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,
5866 NULL
5867 }
5868 };
5869
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;
5875 uint16_t port_num;
5876 struct ether_addr address;
5877 };
5878
5879 static void cmd_set_bond_mac_addr_parsed(void *parsed_result,
5880 __attribute__((unused)) struct cmdline *cl,
5881 __attribute__((unused)) void *data)
5882 {
5883 struct cmd_set_bond_mac_addr_result *res = parsed_result;
5884 int ret;
5885
5886 if (port_id_is_invalid(res->port_num, ENABLED_WARN))
5887 return;
5888
5889 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address);
5890
5891 /* check the return value and print it if is < 0 */
5892 if (ret < 0)
5893 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5894 }
5895
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,
5900 "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,
5903 "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,
5906 port_num, UINT16);
5907 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr =
5908 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address);
5909
5910 cmdline_parse_inst_t cmd_set_bond_mac_addr = {
5911 .f = cmd_set_bond_mac_addr_parsed,
5912 .data = (void *) 0,
5913 .help_str = "set bonding mac_addr <port_id> <mac_addr>",
5914 .tokens = {
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,
5920 NULL
5921 }
5922 };
5923
5924
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;
5930 uint16_t port_num;
5931 uint32_t period_ms;
5932 };
5933
5934 static void cmd_set_bond_mon_period_parsed(void *parsed_result,
5935 __attribute__((unused)) struct cmdline *cl,
5936 __attribute__((unused)) void *data)
5937 {
5938 struct cmd_set_bond_mon_period_result *res = parsed_result;
5939 int ret;
5940
5941 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms);
5942
5943 /* check the return value and print it if is < 0 */
5944 if (ret < 0)
5945 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret));
5946 }
5947
5948 cmdline_parse_token_string_t cmd_set_bond_mon_period_set =
5949 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result,
5950 set, "set");
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,
5959 port_num, UINT16);
5960 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms =
5961 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result,
5962 period_ms, UINT32);
5963
5964 cmdline_parse_inst_t cmd_set_bond_mon_period = {
5965 .f = cmd_set_bond_mon_period_parsed,
5966 .data = (void *) 0,
5967 .help_str = "set bonding mon_period <port_id> <period_ms>",
5968 .tokens = {
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,
5974 NULL
5975 }
5976 };
5977
5978
5979
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;
5984 uint16_t port_num;
5985 cmdline_fixed_string_t policy;
5986 };
5987
5988
5989 static void
5990 cmd_set_bonding_agg_mode(void *parsed_result,
5991 __attribute__((unused)) struct cmdline *cl,
5992 __attribute__((unused)) void *data)
5993 {
5994 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result;
5995 uint8_t policy = AGG_BANDWIDTH;
5996
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"))
6002 policy = AGG_COUNT;
6003
6004 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy);
6005 }
6006
6007
6008 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set =
6009 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6010 set, "set");
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");
6014
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");
6018
6019 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum =
6020 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result,
6021 port_num, UINT16);
6022
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");
6027
6028 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = {
6029 .f = cmd_set_bonding_agg_mode,
6030 .data = (void *) 0,
6031 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>",
6032 .tokens = {
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,
6038 NULL
6039 }
6040 };
6041
6042
6043 #endif /* RTE_LIBRTE_PMD_BOND */
6044
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;
6050 };
6051
6052 static void cmd_set_fwd_mode_parsed(void *parsed_result,
6053 __attribute__((unused)) struct cmdline *cl,
6054 __attribute__((unused)) void *data)
6055 {
6056 struct cmd_set_fwd_mode_result *res = parsed_result;
6057
6058 retry_enabled = 0;
6059 set_pkt_forwarding_mode(res->mode);
6060 }
6061
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 */);
6069
6070 cmdline_parse_inst_t cmd_set_fwd_mode = {
6071 .f = cmd_set_fwd_mode_parsed,
6072 .data = NULL,
6073 .help_str = NULL, /* defined at init */
6074 .tokens = {
6075 (void *)&cmd_setfwd_set,
6076 (void *)&cmd_setfwd_fwd,
6077 (void *)&cmd_setfwd_mode,
6078 NULL,
6079 },
6080 };
6081
6082 static void cmd_set_fwd_mode_init(void)
6083 {
6084 char *modes, *c;
6085 static char token[128];
6086 static char help[256];
6087 cmdline_parse_token_string_t *token_struct;
6088
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;
6093
6094 /* string token separator is # */
6095 for (c = token; *modes != '\0'; modes++)
6096 if (*modes == '|')
6097 *c++ = '#';
6098 else
6099 *c++ = *modes;
6100 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6101 token_struct->string_data.str = token;
6102 }
6103
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;
6110 };
6111
6112 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6113 __attribute__((unused)) struct cmdline *cl,
6114 __attribute__((unused)) void *data)
6115 {
6116 struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6117
6118 retry_enabled = 1;
6119 set_pkt_forwarding_mode(res->mode);
6120 }
6121
6122 cmdline_parse_token_string_t cmd_setfwd_retry_set =
6123 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6124 set, "set");
6125 cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6126 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6127 fwd, "fwd");
6128 cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6129 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6130 mode,
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,
6134 retry, "retry");
6135
6136 cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6137 .f = cmd_set_fwd_retry_mode_parsed,
6138 .data = NULL,
6139 .help_str = NULL, /* defined at init */
6140 .tokens = {
6141 (void *)&cmd_setfwd_retry_set,
6142 (void *)&cmd_setfwd_retry_fwd,
6143 (void *)&cmd_setfwd_retry_mode,
6144 (void *)&cmd_setfwd_retry_retry,
6145 NULL,
6146 },
6147 };
6148
6149 static void cmd_set_fwd_retry_mode_init(void)
6150 {
6151 char *modes, *c;
6152 static char token[128];
6153 static char help[256];
6154 cmdline_parse_token_string_t *token_struct;
6155
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;
6160
6161 /* string token separator is # */
6162 for (c = token; *modes != '\0'; modes++)
6163 if (*modes == '|')
6164 *c++ = '#';
6165 else
6166 *c++ = *modes;
6167 token_struct = (cmdline_parse_token_string_t *)
6168 cmd_set_fwd_retry_mode.tokens[2];
6169 token_struct->string_data.str = token;
6170 }
6171
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;
6178 uint32_t time;
6179 cmdline_fixed_string_t retry;
6180 uint32_t retry_num;
6181 };
6182
6183 static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6184 __attribute__((unused)) struct cmdline *cl,
6185 __attribute__((unused)) void *data)
6186 {
6187 struct cmd_set_burst_tx_retry_result *res = parsed_result;
6188
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;
6195 }
6196
6197 }
6198
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,
6203 "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);
6214
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>",
6218 .tokens = {
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,
6226 NULL,
6227 },
6228 };
6229
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;
6237 };
6238
6239 static void cmd_set_promisc_mode_parsed(void *parsed_result,
6240 __attribute__((unused)) struct cmdline *cl,
6241 void *allports)
6242 {
6243 struct cmd_set_promisc_mode_result *res = parsed_result;
6244 int enable;
6245 portid_t i;
6246
6247 if (!strcmp(res->mode, "on"))
6248 enable = 1;
6249 else
6250 enable = 0;
6251
6252 /* all ports */
6253 if (allports) {
6254 RTE_ETH_FOREACH_DEV(i) {
6255 if (enable)
6256 rte_eth_promiscuous_enable(i);
6257 else
6258 rte_eth_promiscuous_disable(i);
6259 }
6260 }
6261 else {
6262 if (enable)
6263 rte_eth_promiscuous_enable(res->port_num);
6264 else
6265 rte_eth_promiscuous_disable(res->port_num);
6266 }
6267 }
6268
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,
6273 "promisc");
6274 cmdline_parse_token_string_t cmd_setpromisc_portall =
6275 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6276 "all");
6277 cmdline_parse_token_num_t cmd_setpromisc_portnum =
6278 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6279 UINT16);
6280 cmdline_parse_token_string_t cmd_setpromisc_mode =
6281 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6282 "on#off");
6283
6284 cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6285 .f = cmd_set_promisc_mode_parsed,
6286 .data = (void *)1,
6287 .help_str = "set promisc all on|off: Set promisc mode for all ports",
6288 .tokens = {
6289 (void *)&cmd_setpromisc_set,
6290 (void *)&cmd_setpromisc_promisc,
6291 (void *)&cmd_setpromisc_portall,
6292 (void *)&cmd_setpromisc_mode,
6293 NULL,
6294 },
6295 };
6296
6297 cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6298 .f = cmd_set_promisc_mode_parsed,
6299 .data = (void *)0,
6300 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6301 .tokens = {
6302 (void *)&cmd_setpromisc_set,
6303 (void *)&cmd_setpromisc_promisc,
6304 (void *)&cmd_setpromisc_portnum,
6305 (void *)&cmd_setpromisc_mode,
6306 NULL,
6307 },
6308 };
6309
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;
6317 };
6318
6319 static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6320 __attribute__((unused)) struct cmdline *cl,
6321 void *allports)
6322 {
6323 struct cmd_set_allmulti_mode_result *res = parsed_result;
6324 int enable;
6325 portid_t i;
6326
6327 if (!strcmp(res->mode, "on"))
6328 enable = 1;
6329 else
6330 enable = 0;
6331
6332 /* all ports */
6333 if (allports) {
6334 RTE_ETH_FOREACH_DEV(i) {
6335 if (enable)
6336 rte_eth_allmulticast_enable(i);
6337 else
6338 rte_eth_allmulticast_disable(i);
6339 }
6340 }
6341 else {
6342 if (enable)
6343 rte_eth_allmulticast_enable(res->port_num);
6344 else
6345 rte_eth_allmulticast_disable(res->port_num);
6346 }
6347 }
6348
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,
6353 "allmulti");
6354 cmdline_parse_token_string_t cmd_setallmulti_portall =
6355 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6356 "all");
6357 cmdline_parse_token_num_t cmd_setallmulti_portnum =
6358 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6359 UINT16);
6360 cmdline_parse_token_string_t cmd_setallmulti_mode =
6361 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6362 "on#off");
6363
6364 cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6365 .f = cmd_set_allmulti_mode_parsed,
6366 .data = (void *)1,
6367 .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6368 .tokens = {
6369 (void *)&cmd_setallmulti_set,
6370 (void *)&cmd_setallmulti_allmulti,
6371 (void *)&cmd_setallmulti_portall,
6372 (void *)&cmd_setallmulti_mode,
6373 NULL,
6374 },
6375 };
6376
6377 cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6378 .f = cmd_set_allmulti_mode_parsed,
6379 .data = (void *)0,
6380 .help_str = "set allmulti <port_id> on|off: "
6381 "Set allmulti mode on port_id",
6382 .tokens = {
6383 (void *)&cmd_setallmulti_set,
6384 (void *)&cmd_setallmulti_allmulti,
6385 (void *)&cmd_setallmulti_portnum,
6386 (void *)&cmd_setallmulti_mode,
6387 NULL,
6388 },
6389 };
6390
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;
6406 uint32_t low_water;
6407 cmdline_fixed_string_t pt_str;
6408 uint16_t pause_time;
6409 cmdline_fixed_string_t xon_str;
6410 uint16_t send_xon;
6411 portid_t port_id;
6412 };
6413
6414 cmdline_parse_token_string_t cmd_lfc_set_set =
6415 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6416 set, "set");
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,
6422 rx, "rx");
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,
6428 tx, "tx");
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,
6443 low_water, UINT32);
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,
6455 send_xon, UINT16);
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,
6467 autoneg, "on#off");
6468 cmdline_parse_token_num_t cmd_lfc_set_portid =
6469 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6470 port_id, UINT16);
6471
6472 /* forward declaration */
6473 static void
6474 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6475 void *data);
6476
6477 cmdline_parse_inst_t cmd_link_flow_control_set = {
6478 .f = cmd_link_flow_ctrl_set_parsed,
6479 .data = NULL,
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",
6483 .tokens = {
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,
6499 NULL,
6500 },
6501 };
6502
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",
6508 .tokens = {
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,
6514 NULL,
6515 },
6516 };
6517
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",
6523 .tokens = {
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,
6529 NULL,
6530 },
6531 };
6532
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",
6538 .tokens = {
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,
6544 NULL,
6545 },
6546 };
6547
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",
6553 .tokens = {
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,
6559 NULL,
6560 },
6561 };
6562
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",
6568 .tokens = {
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,
6574 NULL,
6575 },
6576 };
6577
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",
6583 .tokens = {
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,
6589 NULL,
6590 },
6591 };
6592
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",
6598 .tokens = {
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,
6604 NULL,
6605 },
6606 };
6607
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",
6613 .tokens = {
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,
6619 NULL,
6620 },
6621 };
6622
6623 static void
6624 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6625 __attribute__((unused)) struct cmdline *cl,
6626 void *data)
6627 {
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;
6631 int rx_fc_en = 0;
6632 int tx_fc_en = 0;
6633 int ret;
6634
6635 /*
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.
6640 */
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}
6643 };
6644
6645 /* Partial command line, retrieve current configuration */
6646 if (cmd) {
6647 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6648 if (ret != 0) {
6649 printf("cannot get current flow ctrl parameters, return"
6650 "code = %d\n", ret);
6651 return;
6652 }
6653
6654 if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
6655 (fc_conf.mode == RTE_FC_FULL))
6656 rx_fc_en = 1;
6657 if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
6658 (fc_conf.mode == RTE_FC_FULL))
6659 tx_fc_en = 1;
6660 }
6661
6662 if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6663 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6664
6665 if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6666 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6667
6668 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6669
6670 if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6671 fc_conf.high_water = res->high_water;
6672
6673 if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6674 fc_conf.low_water = res->low_water;
6675
6676 if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6677 fc_conf.pause_time = res->pause_time;
6678
6679 if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6680 fc_conf.send_xon = res->send_xon;
6681
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;
6685 else
6686 fc_conf.mac_ctrl_frame_fwd = 0;
6687 }
6688
6689 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6690 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6691
6692 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6693 if (ret != 0)
6694 printf("bad flow contrl parameter, return code = %d \n", ret);
6695 }
6696
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;
6706 uint32_t low_water;
6707 uint16_t pause_time;
6708 uint8_t priority;
6709 portid_t port_id;
6710 };
6711
6712 static void
6713 cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6714 __attribute__((unused)) struct cmdline *cl,
6715 __attribute__((unused)) void *data)
6716 {
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;
6720 int ret;
6721
6722 /*
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.
6727 */
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}
6730 };
6731
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;
6739
6740 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6741 if (ret != 0)
6742 printf("bad priority flow contrl parameter, return code = %d \n", ret);
6743 }
6744
6745 cmdline_parse_token_string_t cmd_pfc_set_set =
6746 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6747 set, "set");
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,
6753 rx, "rx");
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,
6759 tx, "tx");
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,
6768 low_water, UINT32);
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,
6774 priority, UINT8);
6775 cmdline_parse_token_num_t cmd_pfc_set_portid =
6776 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6777 port_id, UINT16);
6778
6779 cmdline_parse_inst_t cmd_priority_flow_control_set = {
6780 .f = cmd_priority_flow_ctrl_set_parsed,
6781 .data = NULL,
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",
6785 .tokens = {
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,
6797 NULL,
6798 },
6799 };
6800
6801 /* *** RESET CONFIGURATION *** */
6802 struct cmd_reset_result {
6803 cmdline_fixed_string_t reset;
6804 cmdline_fixed_string_t def;
6805 };
6806
6807 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
6808 struct cmdline *cl,
6809 __attribute__((unused)) void *data)
6810 {
6811 cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6812 set_def_fwd_config();
6813 }
6814
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,
6819 "default");
6820
6821 cmdline_parse_inst_t cmd_reset = {
6822 .f = cmd_reset_parsed,
6823 .data = NULL,
6824 .help_str = "set default: Reset default forwarding configuration",
6825 .tokens = {
6826 (void *)&cmd_reset_set,
6827 (void *)&cmd_reset_def,
6828 NULL,
6829 },
6830 };
6831
6832 /* *** START FORWARDING *** */
6833 struct cmd_start_result {
6834 cmdline_fixed_string_t start;
6835 };
6836
6837 cmdline_parse_token_string_t cmd_start_start =
6838 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6839
6840 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result,
6841 __attribute__((unused)) struct cmdline *cl,
6842 __attribute__((unused)) void *data)
6843 {
6844 start_packet_forwarding(0);
6845 }
6846
6847 cmdline_parse_inst_t cmd_start = {
6848 .f = cmd_start_parsed,
6849 .data = NULL,
6850 .help_str = "start: Start packet forwarding",
6851 .tokens = {
6852 (void *)&cmd_start_start,
6853 NULL,
6854 },
6855 };
6856
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;
6861 };
6862
6863 static void
6864 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result,
6865 __attribute__((unused)) struct cmdline *cl,
6866 __attribute__((unused)) void *data)
6867 {
6868 start_packet_forwarding(1);
6869 }
6870
6871 cmdline_parse_token_string_t cmd_start_tx_first_start =
6872 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6873 "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");
6877
6878 cmdline_parse_inst_t cmd_start_tx_first = {
6879 .f = cmd_start_tx_first_parsed,
6880 .data = NULL,
6881 .help_str = "start tx_first: Start packet forwarding, "
6882 "after sending 1 burst of packets",
6883 .tokens = {
6884 (void *)&cmd_start_tx_first_start,
6885 (void *)&cmd_start_tx_first_tx_first,
6886 NULL,
6887 },
6888 };
6889
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;
6894 uint32_t tx_num;
6895 };
6896
6897 static void
6898 cmd_start_tx_first_n_parsed(void *parsed_result,
6899 __attribute__((unused)) struct cmdline *cl,
6900 __attribute__((unused)) void *data)
6901 {
6902 struct cmd_start_tx_first_n_result *res = parsed_result;
6903
6904 start_packet_forwarding(res->tx_num);
6905 }
6906
6907 cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6908 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6909 start, "start");
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,
6915 tx_num, UINT32);
6916
6917 cmdline_parse_inst_t cmd_start_tx_first_n = {
6918 .f = cmd_start_tx_first_n_parsed,
6919 .data = NULL,
6920 .help_str = "start tx_first <num>: "
6921 "packet forwarding, after sending <num> bursts of packets",
6922 .tokens = {
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,
6926 NULL,
6927 },
6928 };
6929
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;
6935 portid_t port_id;
6936 };
6937
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,
6942 "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);
6947
6948 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result,
6949 __attribute__((unused)) struct cmdline *cl,
6950 __attribute__((unused)) void *data)
6951 {
6952 struct cmd_set_link_up_result *res = parsed_result;
6953 dev_set_link_up(res->port_id);
6954 }
6955
6956 cmdline_parse_inst_t cmd_set_link_up = {
6957 .f = cmd_set_link_up_parsed,
6958 .data = NULL,
6959 .help_str = "set link-up port <port id>",
6960 .tokens = {
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,
6965 NULL,
6966 },
6967 };
6968
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;
6974 portid_t port_id;
6975 };
6976
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,
6981 "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);
6986
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)
6991 {
6992 struct cmd_set_link_down_result *res = parsed_result;
6993 dev_set_link_down(res->port_id);
6994 }
6995
6996 cmdline_parse_inst_t cmd_set_link_down = {
6997 .f = cmd_set_link_down_parsed,
6998 .data = NULL,
6999 .help_str = "set link-down port <port id>",
7000 .tokens = {
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,
7005 NULL,
7006 },
7007 };
7008
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;
7014 };
7015
7016 static void cmd_showcfg_parsed(void *parsed_result,
7017 __attribute__((unused)) struct cmdline *cl,
7018 __attribute__((unused)) void *data)
7019 {
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();
7029 }
7030
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");
7038
7039 cmdline_parse_inst_t cmd_showcfg = {
7040 .f = cmd_showcfg_parsed,
7041 .data = NULL,
7042 .help_str = "show config rxtx|cores|fwd|txpkts",
7043 .tokens = {
7044 (void *)&cmd_showcfg_show,
7045 (void *)&cmd_showcfg_port,
7046 (void *)&cmd_showcfg_what,
7047 NULL,
7048 },
7049 };
7050
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;
7057 };
7058
7059 static void cmd_showportall_parsed(void *parsed_result,
7060 __attribute__((unused)) struct cmdline *cl,
7061 __attribute__((unused)) void *data)
7062 {
7063 portid_t i;
7064
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)
7069 nic_stats_clear(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)
7084 fdir_get_infos(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);
7094 }
7095
7096 cmdline_parse_token_string_t cmd_showportall_show =
7097 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7098 "show#clear");
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,
7108 .data = NULL,
7109 .help_str = "show|clear port "
7110 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all",
7111 .tokens = {
7112 (void *)&cmd_showportall_show,
7113 (void *)&cmd_showportall_port,
7114 (void *)&cmd_showportall_what,
7115 (void *)&cmd_showportall_all,
7116 NULL,
7117 },
7118 };
7119
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;
7125 uint16_t portnum;
7126 };
7127
7128 static void cmd_showport_parsed(void *parsed_result,
7129 __attribute__((unused)) struct cmdline *cl,
7130 __attribute__((unused)) void *data)
7131 {
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);
7152 }
7153
7154 cmdline_parse_token_string_t cmd_showport_show =
7155 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7156 "show#clear");
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);
7164
7165 cmdline_parse_inst_t cmd_showport = {
7166 .f = cmd_showport_parsed,
7167 .data = NULL,
7168 .help_str = "show|clear port "
7169 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap "
7170 "<port_id>",
7171 .tokens = {
7172 (void *)&cmd_showport_show,
7173 (void *)&cmd_showport_port,
7174 (void *)&cmd_showport_what,
7175 (void *)&cmd_showport_portnum,
7176 NULL,
7177 },
7178 };
7179
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;
7185 uint16_t portnum;
7186 uint16_t queuenum;
7187 };
7188
7189 static void
7190 cmd_showqueue_parsed(void *parsed_result,
7191 __attribute__((unused)) struct cmdline *cl,
7192 __attribute__((unused)) void *data)
7193 {
7194 struct cmd_showqueue_result *res = parsed_result;
7195
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);
7200 }
7201
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);
7212
7213 cmdline_parse_inst_t cmd_showqueue = {
7214 .f = cmd_showqueue_parsed,
7215 .data = NULL,
7216 .help_str = "show rxq|txq info <port_id> <queue_id>",
7217 .tokens = {
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,
7223 NULL,
7224 },
7225 };
7226
7227 /* *** READ PORT REGISTER *** */
7228 struct cmd_read_reg_result {
7229 cmdline_fixed_string_t read;
7230 cmdline_fixed_string_t reg;
7231 portid_t port_id;
7232 uint32_t reg_off;
7233 };
7234
7235 static void
7236 cmd_read_reg_parsed(void *parsed_result,
7237 __attribute__((unused)) struct cmdline *cl,
7238 __attribute__((unused)) void *data)
7239 {
7240 struct cmd_read_reg_result *res = parsed_result;
7241 port_reg_display(res->port_id, res->reg_off);
7242 }
7243
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);
7252
7253 cmdline_parse_inst_t cmd_read_reg = {
7254 .f = cmd_read_reg_parsed,
7255 .data = NULL,
7256 .help_str = "read reg <port_id> <reg_off>",
7257 .tokens = {
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,
7262 NULL,
7263 },
7264 };
7265
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;
7270 portid_t port_id;
7271 uint32_t reg_off;
7272 uint8_t bit1_pos;
7273 uint8_t bit2_pos;
7274 };
7275
7276 static void
7277 cmd_read_reg_bit_field_parsed(void *parsed_result,
7278 __attribute__((unused)) struct cmdline *cl,
7279 __attribute__((unused)) void *data)
7280 {
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);
7284 }
7285
7286 cmdline_parse_token_string_t cmd_read_reg_bit_field_read =
7287 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read,
7288 "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,
7294 UINT16);
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,
7297 UINT32);
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,
7300 UINT8);
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,
7303 UINT8);
7304
7305 cmdline_parse_inst_t cmd_read_reg_bit_field = {
7306 .f = cmd_read_reg_bit_field_parsed,
7307 .data = NULL,
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",
7310 .tokens = {
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,
7317 NULL,
7318 },
7319 };
7320
7321 /* *** READ PORT REGISTER BIT *** */
7322 struct cmd_read_reg_bit_result {
7323 cmdline_fixed_string_t read;
7324 cmdline_fixed_string_t regbit;
7325 portid_t port_id;
7326 uint32_t reg_off;
7327 uint8_t bit_pos;
7328 };
7329
7330 static void
7331 cmd_read_reg_bit_parsed(void *parsed_result,
7332 __attribute__((unused)) struct cmdline *cl,
7333 __attribute__((unused)) void *data)
7334 {
7335 struct cmd_read_reg_bit_result *res = parsed_result;
7336 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos);
7337 }
7338
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,
7343 regbit, "regbit");
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);
7350
7351 cmdline_parse_inst_t cmd_read_reg_bit = {
7352 .f = cmd_read_reg_bit_parsed,
7353 .data = NULL,
7354 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31",
7355 .tokens = {
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,
7361 NULL,
7362 },
7363 };
7364
7365 /* *** WRITE PORT REGISTER *** */
7366 struct cmd_write_reg_result {
7367 cmdline_fixed_string_t write;
7368 cmdline_fixed_string_t reg;
7369 portid_t port_id;
7370 uint32_t reg_off;
7371 uint32_t value;
7372 };
7373
7374 static void
7375 cmd_write_reg_parsed(void *parsed_result,
7376 __attribute__((unused)) struct cmdline *cl,
7377 __attribute__((unused)) void *data)
7378 {
7379 struct cmd_write_reg_result *res = parsed_result;
7380 port_reg_set(res->port_id, res->reg_off, res->value);
7381 }
7382
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);
7393
7394 cmdline_parse_inst_t cmd_write_reg = {
7395 .f = cmd_write_reg_parsed,
7396 .data = NULL,
7397 .help_str = "write reg <port_id> <reg_off> <reg_value>",
7398 .tokens = {
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,
7404 NULL,
7405 },
7406 };
7407
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;
7412 portid_t port_id;
7413 uint32_t reg_off;
7414 uint8_t bit1_pos;
7415 uint8_t bit2_pos;
7416 uint32_t value;
7417 };
7418
7419 static void
7420 cmd_write_reg_bit_field_parsed(void *parsed_result,
7421 __attribute__((unused)) struct cmdline *cl,
7422 __attribute__((unused)) void *data)
7423 {
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);
7427 }
7428
7429 cmdline_parse_token_string_t cmd_write_reg_bit_field_write =
7430 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write,
7431 "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,
7437 UINT16);
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,
7440 UINT32);
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,
7443 UINT8);
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,
7446 UINT8);
7447 cmdline_parse_token_num_t cmd_write_reg_bit_field_value =
7448 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value,
7449 UINT32);
7450
7451 cmdline_parse_inst_t cmd_write_reg_bit_field = {
7452 .f = cmd_write_reg_bit_field_parsed,
7453 .data = NULL,
7454 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> "
7455 "<reg_value>: "
7456 "Set register bit field between bit_x and bit_y included",
7457 .tokens = {
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,
7465 NULL,
7466 },
7467 };
7468
7469 /* *** WRITE PORT REGISTER BIT *** */
7470 struct cmd_write_reg_bit_result {
7471 cmdline_fixed_string_t write;
7472 cmdline_fixed_string_t regbit;
7473 portid_t port_id;
7474 uint32_t reg_off;
7475 uint8_t bit_pos;
7476 uint8_t value;
7477 };
7478
7479 static void
7480 cmd_write_reg_bit_parsed(void *parsed_result,
7481 __attribute__((unused)) struct cmdline *cl,
7482 __attribute__((unused)) void *data)
7483 {
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);
7486 }
7487
7488 cmdline_parse_token_string_t cmd_write_reg_bit_write =
7489 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write,
7490 "write");
7491 cmdline_parse_token_string_t cmd_write_reg_bit_regbit =
7492 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result,
7493 regbit, "regbit");
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);
7502
7503 cmdline_parse_inst_t cmd_write_reg_bit = {
7504 .f = cmd_write_reg_bit_parsed,
7505 .data = NULL,
7506 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: "
7507 "0 <= bit_x <= 31",
7508 .tokens = {
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,
7515 NULL,
7516 },
7517 };
7518
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;
7523 portid_t port_id;
7524 uint16_t queue_id;
7525 uint16_t desc_id;
7526 };
7527
7528 static void
7529 cmd_read_rxd_txd_parsed(void *parsed_result,
7530 __attribute__((unused)) struct cmdline *cl,
7531 __attribute__((unused)) void *data)
7532 {
7533 struct cmd_read_rxd_txd_result *res = parsed_result;
7534
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);
7539 }
7540
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,
7545 "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);
7552
7553 cmdline_parse_inst_t cmd_read_rxd_txd = {
7554 .f = cmd_read_rxd_txd_parsed,
7555 .data = NULL,
7556 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7557 .tokens = {
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,
7563 NULL,
7564 },
7565 };
7566
7567 /* *** QUIT *** */
7568 struct cmd_quit_result {
7569 cmdline_fixed_string_t quit;
7570 };
7571
7572 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
7573 struct cmdline *cl,
7574 __attribute__((unused)) void *data)
7575 {
7576 pmd_test_exit();
7577 cmdline_quit(cl);
7578 }
7579
7580 cmdline_parse_token_string_t cmd_quit_quit =
7581 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7582
7583 cmdline_parse_inst_t cmd_quit = {
7584 .f = cmd_quit_parsed,
7585 .data = NULL,
7586 .help_str = "quit: Exit application",
7587 .tokens = {
7588 (void *)&cmd_quit_quit,
7589 NULL,
7590 },
7591 };
7592
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;
7597 uint16_t port_num;
7598 struct ether_addr address;
7599 };
7600
7601 static void cmd_mac_addr_parsed(void *parsed_result,
7602 __attribute__((unused)) struct cmdline *cl,
7603 __attribute__((unused)) void *data)
7604 {
7605 struct cmd_mac_addr_result *res = parsed_result;
7606 int ret;
7607
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,
7612 &res->address);
7613 else
7614 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7615
7616 /* check the return value and print it if is < 0 */
7617 if(ret < 0)
7618 printf("mac_addr_cmd error: (%s)\n", strerror(-ret));
7619
7620 }
7621
7622 cmdline_parse_token_string_t cmd_mac_addr_cmd =
7623 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7624 "mac_addr");
7625 cmdline_parse_token_string_t cmd_mac_addr_what =
7626 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7627 "add#remove#set");
7628 cmdline_parse_token_num_t cmd_mac_addr_portnum =
7629 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7630 UINT16);
7631 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7632 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7633
7634 cmdline_parse_inst_t cmd_mac_addr = {
7635 .f = cmd_mac_addr_parsed,
7636 .data = (void *)0,
7637 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7638 "Add/Remove/Set MAC address on port_id",
7639 .tokens = {
7640 (void *)&cmd_mac_addr_cmd,
7641 (void *)&cmd_mac_addr_what,
7642 (void *)&cmd_mac_addr_portnum,
7643 (void *)&cmd_mac_addr_addr,
7644 NULL,
7645 },
7646 };
7647
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;
7652 portid_t port_id;
7653 cmdline_fixed_string_t peer_addr;
7654 };
7655
7656 static void cmd_set_eth_peer_parsed(void *parsed_result,
7657 __attribute__((unused)) struct cmdline *cl,
7658 __attribute__((unused)) void *data)
7659 {
7660 struct cmd_eth_peer_result *res = parsed_result;
7661
7662 if (test_done == 0) {
7663 printf("Please stop forwarding first\n");
7664 return;
7665 }
7666 if (!strcmp(res->eth_peer, "eth-peer")) {
7667 set_fwd_eth_peer(res->port_id, res->peer_addr);
7668 fwd_config_setup();
7669 }
7670 }
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);
7679
7680 cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7681 .f = cmd_set_eth_peer_parsed,
7682 .data = NULL,
7683 .help_str = "set eth-peer <port_id> <peer_mac>",
7684 .tokens = {
7685 (void *)&cmd_eth_peer_set,
7686 (void *)&cmd_eth_peer,
7687 (void *)&cmd_eth_peer_port_id,
7688 (void *)&cmd_eth_peer_addr,
7689 NULL,
7690 },
7691 };
7692
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;
7698 portid_t port_id;
7699 uint16_t queue_id;
7700 uint8_t map_value;
7701 };
7702
7703 static void
7704 cmd_set_qmap_parsed(void *parsed_result,
7705 __attribute__((unused)) struct cmdline *cl,
7706 __attribute__((unused)) void *data)
7707 {
7708 struct cmd_set_qmap_result *res = parsed_result;
7709 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7710
7711 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7712 }
7713
7714 cmdline_parse_token_string_t cmd_setqmap_set =
7715 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7716 set, "set");
7717 cmdline_parse_token_string_t cmd_setqmap_qmap =
7718 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7719 qmap, "stat_qmap");
7720 cmdline_parse_token_string_t cmd_setqmap_what =
7721 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7722 what, "tx#rx");
7723 cmdline_parse_token_num_t cmd_setqmap_portid =
7724 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7725 port_id, UINT16);
7726 cmdline_parse_token_num_t cmd_setqmap_queueid =
7727 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7728 queue_id, UINT16);
7729 cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7730 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7731 map_value, UINT8);
7732
7733 cmdline_parse_inst_t cmd_set_qmap = {
7734 .f = cmd_set_qmap_parsed,
7735 .data = NULL,
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",
7738 .tokens = {
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,
7745 NULL,
7746 },
7747 };
7748
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;
7754 };
7755
7756 static void
7757 cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7758 __attribute__((unused)) struct cmdline *cl,
7759 __attribute__((unused)) void *data)
7760 {
7761 struct cmd_set_xstats_hide_zero_result *res;
7762 uint16_t on_off = 0;
7763
7764 res = parsed_result;
7765 on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7766 set_xstats_hide_zero(on_off);
7767 }
7768
7769 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7770 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7771 keyword, "set");
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,
7777 on_off, "on#off");
7778
7779 cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7780 .f = cmd_set_xstats_hide_zero_parsed,
7781 .data = NULL,
7782 .help_str = "set xstats-hide-zero on|off",
7783 .tokens = {
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,
7787 NULL,
7788 },
7789 };
7790
7791 /* *** CONFIGURE UNICAST HASH TABLE *** */
7792 struct cmd_set_uc_hash_table {
7793 cmdline_fixed_string_t set;
7794 cmdline_fixed_string_t port;
7795 portid_t port_id;
7796 cmdline_fixed_string_t what;
7797 struct ether_addr address;
7798 cmdline_fixed_string_t mode;
7799 };
7800
7801 static void
7802 cmd_set_uc_hash_parsed(void *parsed_result,
7803 __attribute__((unused)) struct cmdline *cl,
7804 __attribute__((unused)) void *data)
7805 {
7806 int ret=0;
7807 struct cmd_set_uc_hash_table *res = parsed_result;
7808
7809 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7810
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);
7814 if (ret < 0)
7815 printf("bad unicast hash table parameter, return code = %d \n", ret);
7816
7817 }
7818
7819 cmdline_parse_token_string_t cmd_set_uc_hash_set =
7820 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7821 set, "set");
7822 cmdline_parse_token_string_t cmd_set_uc_hash_port =
7823 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7824 port, "port");
7825 cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7826 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7827 port_id, UINT16);
7828 cmdline_parse_token_string_t cmd_set_uc_hash_what =
7829 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7830 what, "uta");
7831 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7832 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7833 address);
7834 cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7835 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7836 mode, "on#off");
7837
7838 cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7839 .f = cmd_set_uc_hash_parsed,
7840 .data = NULL,
7841 .help_str = "set port <port_id> uta <mac_addr> on|off)",
7842 .tokens = {
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,
7849 NULL,
7850 },
7851 };
7852
7853 struct cmd_set_uc_all_hash_table {
7854 cmdline_fixed_string_t set;
7855 cmdline_fixed_string_t port;
7856 portid_t port_id;
7857 cmdline_fixed_string_t what;
7858 cmdline_fixed_string_t value;
7859 cmdline_fixed_string_t mode;
7860 };
7861
7862 static void
7863 cmd_set_uc_all_hash_parsed(void *parsed_result,
7864 __attribute__((unused)) struct cmdline *cl,
7865 __attribute__((unused)) void *data)
7866 {
7867 int ret=0;
7868 struct cmd_set_uc_all_hash_table *res = parsed_result;
7869
7870 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7871
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);
7875 if (ret < 0)
7876 printf("bad unicast hash table parameter,"
7877 "return code = %d \n", ret);
7878 }
7879
7880 cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7881 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7882 set, "set");
7883 cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7884 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7885 port, "port");
7886 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7887 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7888 port_id, UINT16);
7889 cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7890 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7891 what, "uta");
7892 cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7893 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7894 value,"all");
7895 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7896 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7897 mode, "on#off");
7898
7899 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7900 .f = cmd_set_uc_all_hash_parsed,
7901 .data = NULL,
7902 .help_str = "set port <port_id> uta all on|off",
7903 .tokens = {
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,
7910 NULL,
7911 },
7912 };
7913
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;
7918 portid_t port_id;
7919 cmdline_fixed_string_t vf;
7920 uint8_t vf_id;
7921 struct ether_addr address;
7922 cmdline_fixed_string_t filter_type;
7923 cmdline_fixed_string_t mode;
7924 };
7925
7926 static void
7927 cmd_set_vf_macvlan_parsed(void *parsed_result,
7928 __attribute__((unused)) struct cmdline *cl,
7929 __attribute__((unused)) void *data)
7930 {
7931 int is_on, ret = 0;
7932 struct cmd_set_vf_macvlan_filter *res = parsed_result;
7933 struct rte_eth_mac_filter filter;
7934
7935 memset(&filter, 0, sizeof(struct rte_eth_mac_filter));
7936
7937 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN);
7938
7939 /* set VF MAC filter */
7940 filter.is_vf = 1;
7941
7942 /* set VF ID */
7943 filter.dst_id = res->vf_id;
7944
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;
7953
7954 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7955
7956 if (is_on)
7957 ret = rte_eth_dev_filter_ctrl(res->port_id,
7958 RTE_ETH_FILTER_MACVLAN,
7959 RTE_ETH_FILTER_ADD,
7960 &filter);
7961 else
7962 ret = rte_eth_dev_filter_ctrl(res->port_id,
7963 RTE_ETH_FILTER_MACVLAN,
7964 RTE_ETH_FILTER_DELETE,
7965 &filter);
7966
7967 if (ret < 0)
7968 printf("bad set MAC hash parameter, return code = %d\n", ret);
7969
7970 }
7971
7972 cmdline_parse_token_string_t cmd_set_vf_macvlan_set =
7973 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7974 set, "set");
7975 cmdline_parse_token_string_t cmd_set_vf_macvlan_port =
7976 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7977 port, "port");
7978 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid =
7979 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7980 port_id, UINT16);
7981 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf =
7982 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7983 vf, "vf");
7984 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id =
7985 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7986 vf_id, UINT8);
7987 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac =
7988 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter,
7989 address);
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,
7996 mode, "on#off");
7997
7998 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = {
7999 .f = cmd_set_vf_macvlan_parsed,
8000 .data = NULL,
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",
8005 .tokens = {
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,
8014 NULL,
8015 },
8016 };
8017
8018 /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8019 struct cmd_set_vf_traffic {
8020 cmdline_fixed_string_t set;
8021 cmdline_fixed_string_t port;
8022 portid_t port_id;
8023 cmdline_fixed_string_t vf;
8024 uint8_t vf_id;
8025 cmdline_fixed_string_t what;
8026 cmdline_fixed_string_t mode;
8027 };
8028
8029 static void
8030 cmd_set_vf_traffic_parsed(void *parsed_result,
8031 __attribute__((unused)) struct cmdline *cl,
8032 __attribute__((unused)) void *data)
8033 {
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;
8037
8038 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8039 }
8040
8041 cmdline_parse_token_string_t cmd_setvf_traffic_set =
8042 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8043 set, "set");
8044 cmdline_parse_token_string_t cmd_setvf_traffic_port =
8045 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8046 port, "port");
8047 cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8048 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8049 port_id, UINT16);
8050 cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8051 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8052 vf, "vf");
8053 cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8054 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8055 vf_id, UINT8);
8056 cmdline_parse_token_string_t cmd_setvf_traffic_what =
8057 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8058 what, "tx#rx");
8059 cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8060 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8061 mode, "on#off");
8062
8063 cmdline_parse_inst_t cmd_set_vf_traffic = {
8064 .f = cmd_set_vf_traffic_parsed,
8065 .data = NULL,
8066 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8067 .tokens = {
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,
8075 NULL,
8076 },
8077 };
8078
8079 /* *** CONFIGURE VF RECEIVE MODE *** */
8080 struct cmd_set_vf_rxmode {
8081 cmdline_fixed_string_t set;
8082 cmdline_fixed_string_t port;
8083 portid_t port_id;
8084 cmdline_fixed_string_t vf;
8085 uint8_t vf_id;
8086 cmdline_fixed_string_t what;
8087 cmdline_fixed_string_t mode;
8088 cmdline_fixed_string_t on;
8089 };
8090
8091 static void
8092 cmd_set_vf_rxmode_parsed(void *parsed_result,
8093 __attribute__((unused)) struct cmdline *cl,
8094 __attribute__((unused)) void *data)
8095 {
8096 int ret = -ENOTSUP;
8097 uint16_t rx_mode = 0;
8098 struct cmd_set_vf_rxmode *res = parsed_result;
8099
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;
8110 }
8111
8112 RTE_SET_USED(is_on);
8113
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);
8118 #endif
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);
8123 #endif
8124 if (ret < 0)
8125 printf("bad VF receive mode parameter, return code = %d \n",
8126 ret);
8127 }
8128
8129 cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8130 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8131 set, "set");
8132 cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8133 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8134 port, "port");
8135 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8136 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8137 port_id, UINT16);
8138 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8139 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8140 vf, "vf");
8141 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8142 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8143 vf_id, UINT8);
8144 cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8145 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8146 what, "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,
8152 on, "on#off");
8153
8154 cmdline_parse_inst_t cmd_set_vf_rxmode = {
8155 .f = cmd_set_vf_rxmode_parsed,
8156 .data = NULL,
8157 .help_str = "set port <port_id> vf <vf_id> rxmode "
8158 "AUPE|ROPE|BAM|MPE on|off",
8159 .tokens = {
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,
8168 NULL,
8169 },
8170 };
8171
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;
8177 uint16_t port_num;
8178 cmdline_fixed_string_t vf;
8179 uint8_t vf_num;
8180 struct ether_addr address;
8181 };
8182
8183 static void cmd_vf_mac_addr_parsed(void *parsed_result,
8184 __attribute__((unused)) struct cmdline *cl,
8185 __attribute__((unused)) void *data)
8186 {
8187 struct cmd_vf_mac_addr_result *res = parsed_result;
8188 int ret = -ENOTSUP;
8189
8190 if (strcmp(res->what, "add") != 0)
8191 return;
8192
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,
8196 &res->address);
8197 #endif
8198 #ifdef RTE_LIBRTE_BNXT_PMD
8199 if (ret == -ENOTSUP)
8200 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8201 res->vf_num);
8202 #endif
8203
8204 if(ret < 0)
8205 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8206
8207 }
8208
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,
8214 what,"add");
8215 cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8216 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8217 port,"port");
8218 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8219 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8220 port_num, UINT16);
8221 cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8222 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8223 vf,"vf");
8224 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8225 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8226 vf_num, UINT8);
8227 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8228 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8229 address);
8230
8231 cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8232 .f = cmd_vf_mac_addr_parsed,
8233 .data = (void *)0,
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",
8236 .tokens = {
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,
8244 NULL,
8245 },
8246 };
8247
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;
8252 uint16_t vlan_id;
8253 cmdline_fixed_string_t port;
8254 portid_t port_id;
8255 cmdline_fixed_string_t vf;
8256 uint64_t vf_mask;
8257 };
8258
8259 static void
8260 cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8261 __attribute__((unused)) struct cmdline *cl,
8262 __attribute__((unused)) void *data)
8263 {
8264 struct cmd_vf_rx_vlan_filter *res = parsed_result;
8265 int ret = -ENOTSUP;
8266
8267 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8268
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);
8273 #endif
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);
8278 #endif
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);
8283 #endif
8284
8285 switch (ret) {
8286 case 0:
8287 break;
8288 case -EINVAL:
8289 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n",
8290 res->vlan_id, res->vf_mask);
8291 break;
8292 case -ENODEV:
8293 printf("invalid port_id %d\n", res->port_id);
8294 break;
8295 case -ENOTSUP:
8296 printf("function not implemented or supported\n");
8297 break;
8298 default:
8299 printf("programming error: (%s)\n", strerror(-ret));
8300 }
8301 }
8302
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,
8308 what, "add#rm");
8309 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8310 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8311 vlan_id, UINT16);
8312 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8313 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8314 port, "port");
8315 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8316 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8317 port_id, UINT16);
8318 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8319 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8320 vf, "vf");
8321 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8322 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8323 vf_mask, UINT64);
8324
8325 cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8326 .f = cmd_vf_rx_vlan_filter_parsed,
8327 .data = NULL,
8328 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8329 "(vf_mask = hexadecimal VF mask)",
8330 .tokens = {
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,
8338 NULL,
8339 },
8340 };
8341
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;
8346 uint16_t port_num;
8347 cmdline_fixed_string_t queue;
8348 uint8_t queue_num;
8349 cmdline_fixed_string_t rate;
8350 uint16_t rate_num;
8351 };
8352
8353 static void cmd_queue_rate_limit_parsed(void *parsed_result,
8354 __attribute__((unused)) struct cmdline *cl,
8355 __attribute__((unused)) void *data)
8356 {
8357 struct cmd_queue_rate_limit_result *res = parsed_result;
8358 int ret = 0;
8359
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,
8364 res->rate_num);
8365 if (ret < 0)
8366 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret));
8367
8368 }
8369
8370 cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8371 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8372 set, "set");
8373 cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8374 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8375 port, "port");
8376 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8377 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8378 port_num, UINT16);
8379 cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8380 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8381 queue, "queue");
8382 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8383 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8384 queue_num, UINT8);
8385 cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8386 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8387 rate, "rate");
8388 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8389 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8390 rate_num, UINT16);
8391
8392 cmdline_parse_inst_t cmd_queue_rate_limit = {
8393 .f = cmd_queue_rate_limit_parsed,
8394 .data = (void *)0,
8395 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8396 "Set rate limit for a queue on port_id",
8397 .tokens = {
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,
8405 NULL,
8406 },
8407 };
8408
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;
8413 uint16_t port_num;
8414 cmdline_fixed_string_t vf;
8415 uint8_t vf_num;
8416 cmdline_fixed_string_t rate;
8417 uint16_t rate_num;
8418 cmdline_fixed_string_t q_msk;
8419 uint64_t q_msk_val;
8420 };
8421
8422 static void cmd_vf_rate_limit_parsed(void *parsed_result,
8423 __attribute__((unused)) struct cmdline *cl,
8424 __attribute__((unused)) void *data)
8425 {
8426 struct cmd_vf_rate_limit_result *res = parsed_result;
8427 int ret = 0;
8428
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);
8435 if (ret < 0)
8436 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret));
8437
8438 }
8439
8440 cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8441 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8442 set, "set");
8443 cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8444 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8445 port, "port");
8446 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8447 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8448 port_num, UINT16);
8449 cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8450 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8451 vf, "vf");
8452 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8453 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8454 vf_num, UINT8);
8455 cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8456 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8457 rate, "rate");
8458 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8459 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8460 rate_num, UINT16);
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,
8466 q_msk_val, UINT64);
8467
8468 cmdline_parse_inst_t cmd_vf_rate_limit = {
8469 .f = cmd_vf_rate_limit_parsed,
8470 .data = (void *)0,
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",
8474 .tokens = {
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,
8484 NULL,
8485 },
8486 };
8487
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;
8492 portid_t port_id;
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;
8499 uint32_t tenant_id;
8500 uint16_t queue_num;
8501 };
8502
8503 static void
8504 cmd_tunnel_filter_parsed(void *parsed_result,
8505 __attribute__((unused)) struct cmdline *cl,
8506 __attribute__((unused)) void *data)
8507 {
8508 struct cmd_tunnel_filter_result *res = parsed_result;
8509 struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
8510 int ret = 0;
8511
8512 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf));
8513
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;
8517
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;
8522 } else {
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;
8527 }
8528
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;
8545 else {
8546 printf("The filter type is not supported");
8547 return;
8548 }
8549
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;
8556 else {
8557 printf("The tunnel type %s not supported.\n", res->tunnel_type);
8558 return;
8559 }
8560
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,
8566 RTE_ETH_FILTER_ADD,
8567 &tunnel_filter_conf);
8568 else
8569 ret = rte_eth_dev_filter_ctrl(res->port_id,
8570 RTE_ETH_FILTER_TUNNEL,
8571 RTE_ETH_FILTER_DELETE,
8572 &tunnel_filter_conf);
8573 if (ret < 0)
8574 printf("cmd_tunnel_filter_parsed error: (%s)\n",
8575 strerror(-ret));
8576
8577 }
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,
8583 what, "add#rm");
8584 cmdline_parse_token_num_t cmd_tunnel_filter_port_id =
8585 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8586 port_id, UINT16);
8587 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac =
8588 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8589 outer_mac);
8590 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac =
8591 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result,
8592 inner_mac);
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,
8598 ip_value);
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");
8602
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,
8609 tenant_id, UINT32);
8610 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num =
8611 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result,
8612 queue_num, UINT16);
8613
8614 cmdline_parse_inst_t cmd_tunnel_filter = {
8615 .f = cmd_tunnel_filter_parsed,
8616 .data = (void *)0,
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",
8621 .tokens = {
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,
8633 NULL,
8634 },
8635 };
8636
8637 /* *** CONFIGURE TUNNEL UDP PORT *** */
8638 struct cmd_tunnel_udp_config {
8639 cmdline_fixed_string_t cmd;
8640 cmdline_fixed_string_t what;
8641 uint16_t udp_port;
8642 portid_t port_id;
8643 };
8644
8645 static void
8646 cmd_tunnel_udp_config_parsed(void *parsed_result,
8647 __attribute__((unused)) struct cmdline *cl,
8648 __attribute__((unused)) void *data)
8649 {
8650 struct cmd_tunnel_udp_config *res = parsed_result;
8651 struct rte_eth_udp_tunnel tunnel_udp;
8652 int ret;
8653
8654 tunnel_udp.udp_port = res->udp_port;
8655
8656 if (!strcmp(res->cmd, "rx_vxlan_port"))
8657 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN;
8658
8659 if (!strcmp(res->what, "add"))
8660 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8661 &tunnel_udp);
8662 else
8663 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8664 &tunnel_udp);
8665
8666 if (ret < 0)
8667 printf("udp tunneling add error: (%s)\n", strerror(-ret));
8668 }
8669
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,
8675 what, "add#rm");
8676 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8677 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8678 udp_port, UINT16);
8679 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8680 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8681 port_id, UINT16);
8682
8683 cmdline_parse_inst_t cmd_tunnel_udp_config = {
8684 .f = cmd_tunnel_udp_config_parsed,
8685 .data = (void *)0,
8686 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8687 "Add/Remove a tunneling UDP port filter",
8688 .tokens = {
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,
8693 NULL,
8694 },
8695 };
8696
8697 struct cmd_config_tunnel_udp_port {
8698 cmdline_fixed_string_t port;
8699 cmdline_fixed_string_t config;
8700 portid_t port_id;
8701 cmdline_fixed_string_t udp_tunnel_port;
8702 cmdline_fixed_string_t action;
8703 cmdline_fixed_string_t tunnel_type;
8704 uint16_t udp_port;
8705 };
8706
8707 static void
8708 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8709 __attribute__((unused)) struct cmdline *cl,
8710 __attribute__((unused)) void *data)
8711 {
8712 struct cmd_config_tunnel_udp_port *res = parsed_result;
8713 struct rte_eth_udp_tunnel tunnel_udp;
8714 int ret = 0;
8715
8716 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8717 return;
8718
8719 tunnel_udp.udp_port = res->udp_port;
8720
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;
8725 } else {
8726 printf("Invalid tunnel type\n");
8727 return;
8728 }
8729
8730 if (!strcmp(res->action, "add"))
8731 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8732 &tunnel_udp);
8733 else
8734 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8735 &tunnel_udp);
8736
8737 if (ret < 0)
8738 printf("udp tunneling port add error: (%s)\n", strerror(-ret));
8739 }
8740
8741 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8742 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8743 "port");
8744 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8745 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8746 "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,
8749 UINT16);
8750 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8751 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8752 udp_tunnel_port,
8753 "udp_tunnel_port");
8754 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8755 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8756 "add#rm");
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,
8759 "vxlan#geneve");
8760 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8761 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8762 UINT16);
8763
8764 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8765 .f = cmd_cfg_tunnel_udp_port_parsed,
8766 .data = NULL,
8767 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>",
8768 .tokens = {
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,
8776 NULL,
8777 },
8778 };
8779
8780 /* *** GLOBAL CONFIG *** */
8781 struct cmd_global_config_result {
8782 cmdline_fixed_string_t cmd;
8783 portid_t port_id;
8784 cmdline_fixed_string_t cfg_type;
8785 uint8_t len;
8786 };
8787
8788 static void
8789 cmd_global_config_parsed(void *parsed_result,
8790 __attribute__((unused)) struct cmdline *cl,
8791 __attribute__((unused)) void *data)
8792 {
8793 struct cmd_global_config_result *res = parsed_result;
8794 struct rte_eth_global_cfg conf;
8795 int ret;
8796
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);
8802 if (ret != 0)
8803 printf("Global config error\n");
8804 }
8805
8806 cmdline_parse_token_string_t cmd_global_config_cmd =
8807 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
8808 "global_config");
8809 cmdline_parse_token_num_t cmd_global_config_port_id =
8810 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id,
8811 UINT16);
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,
8817 len, UINT8);
8818
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>",
8823 .tokens = {
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,
8828 NULL,
8829 },
8830 };
8831
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;
8836 portid_t port_id;
8837 cmdline_fixed_string_t mirror;
8838 uint8_t rule_id;
8839 cmdline_fixed_string_t what;
8840 cmdline_fixed_string_t value;
8841 cmdline_fixed_string_t dstpool;
8842 uint8_t dstpool_id;
8843 cmdline_fixed_string_t on;
8844 };
8845
8846 cmdline_parse_token_string_t cmd_mirror_mask_set =
8847 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8848 set, "set");
8849 cmdline_parse_token_string_t cmd_mirror_mask_port =
8850 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8851 port, "port");
8852 cmdline_parse_token_num_t cmd_mirror_mask_portid =
8853 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result,
8854 port_id, UINT16);
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,
8860 rule_id, UINT8);
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"
8864 "#vlan-mirror");
8865 cmdline_parse_token_string_t cmd_mirror_mask_value =
8866 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8867 value, NULL);
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,
8873 dstpool_id, UINT8);
8874 cmdline_parse_token_string_t cmd_mirror_mask_on =
8875 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result,
8876 on, "on#off");
8877
8878 static void
8879 cmd_set_mirror_mask_parsed(void *parsed_result,
8880 __attribute__((unused)) struct cmdline *cl,
8881 __attribute__((unused)) void *data)
8882 {
8883 int ret,nb_item,i;
8884 struct cmd_set_mirror_mask_result *res = parsed_result;
8885 struct rte_eth_mirror_conf mr_conf;
8886
8887 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf));
8888
8889 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS];
8890
8891 mr_conf.dst_pool = res->dstpool_id;
8892
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);
8903 if (nb_item <= 0)
8904 return;
8905
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");
8909 return;
8910 }
8911
8912 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i];
8913 mr_conf.vlan.vlan_mask |= 1ULL << i;
8914 }
8915 }
8916
8917 if (!strcmp(res->on, "on"))
8918 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8919 res->rule_id, 1);
8920 else
8921 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
8922 res->rule_id, 0);
8923 if (ret < 0)
8924 printf("mirror rule add error: (%s)\n", strerror(-ret));
8925 }
8926
8927 cmdline_parse_inst_t cmd_set_mirror_mask = {
8928 .f = cmd_set_mirror_mask_parsed,
8929 .data = NULL,
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",
8933 .tokens = {
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,
8944 NULL,
8945 },
8946 };
8947
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;
8952 portid_t port_id;
8953 cmdline_fixed_string_t mirror;
8954 uint8_t rule_id;
8955 cmdline_fixed_string_t what;
8956 cmdline_fixed_string_t dstpool;
8957 uint8_t dstpool_id;
8958 cmdline_fixed_string_t on;
8959 };
8960
8961 cmdline_parse_token_string_t cmd_mirror_link_set =
8962 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8963 set, "set");
8964 cmdline_parse_token_string_t cmd_mirror_link_port =
8965 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8966 port, "port");
8967 cmdline_parse_token_num_t cmd_mirror_link_portid =
8968 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result,
8969 port_id, UINT16);
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,
8975 rule_id, UINT8);
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,
8984 dstpool_id, UINT8);
8985 cmdline_parse_token_string_t cmd_mirror_link_on =
8986 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result,
8987 on, "on#off");
8988
8989 static void
8990 cmd_set_mirror_link_parsed(void *parsed_result,
8991 __attribute__((unused)) struct cmdline *cl,
8992 __attribute__((unused)) void *data)
8993 {
8994 int ret;
8995 struct cmd_set_mirror_link_result *res = parsed_result;
8996 struct rte_eth_mirror_conf mr_conf;
8997
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;
9001 else
9002 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT;
9003
9004 mr_conf.dst_pool = res->dstpool_id;
9005
9006 if (!strcmp(res->on, "on"))
9007 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9008 res->rule_id, 1);
9009 else
9010 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf,
9011 res->rule_id, 0);
9012
9013 /* check the return value and print it if is < 0 */
9014 if (ret < 0)
9015 printf("mirror rule add error: (%s)\n", strerror(-ret));
9016
9017 }
9018
9019 cmdline_parse_inst_t cmd_set_mirror_link = {
9020 .f = cmd_set_mirror_link_parsed,
9021 .data = NULL,
9022 .help_str = "set port <port_id> mirror-rule <rule_id> "
9023 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off",
9024 .tokens = {
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,
9034 NULL,
9035 },
9036 };
9037
9038 /* *** RESET VM MIRROR RULE *** */
9039 struct cmd_rm_mirror_rule_result {
9040 cmdline_fixed_string_t reset;
9041 cmdline_fixed_string_t port;
9042 portid_t port_id;
9043 cmdline_fixed_string_t mirror;
9044 uint8_t rule_id;
9045 };
9046
9047 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset =
9048 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9049 reset, "reset");
9050 cmdline_parse_token_string_t cmd_rm_mirror_rule_port =
9051 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result,
9052 port, "port");
9053 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid =
9054 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result,
9055 port_id, UINT16);
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,
9061 rule_id, UINT8);
9062
9063 static void
9064 cmd_reset_mirror_rule_parsed(void *parsed_result,
9065 __attribute__((unused)) struct cmdline *cl,
9066 __attribute__((unused)) void *data)
9067 {
9068 int ret;
9069 struct cmd_set_mirror_link_result *res = parsed_result;
9070 /* check rule_id */
9071 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id);
9072 if(ret < 0)
9073 printf("mirror rule remove error: (%s)\n", strerror(-ret));
9074 }
9075
9076 cmdline_parse_inst_t cmd_reset_mirror_rule = {
9077 .f = cmd_reset_mirror_rule_parsed,
9078 .data = NULL,
9079 .help_str = "reset port <port_id> mirror-rule <rule_id>",
9080 .tokens = {
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,
9086 NULL,
9087 },
9088 };
9089
9090 /* ******************************************************************************** */
9091
9092 struct cmd_dump_result {
9093 cmdline_fixed_string_t dump;
9094 };
9095
9096 static void
9097 dump_struct_sizes(void)
9098 {
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);
9103 #undef DUMP_SIZE
9104 }
9105
9106 static void cmd_dump_parsed(void *parsed_result,
9107 __attribute__((unused)) struct cmdline *cl,
9108 __attribute__((unused)) void *data)
9109 {
9110 struct cmd_dump_result *res = parsed_result;
9111
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);
9126 }
9127
9128 cmdline_parse_token_string_t cmd_dump_dump =
9129 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9130 "dump_physmem#"
9131 "dump_memzone#"
9132 "dump_struct_sizes#"
9133 "dump_ring#"
9134 "dump_mempool#"
9135 "dump_devargs#"
9136 "dump_log_types");
9137
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,
9144 NULL,
9145 },
9146 };
9147
9148 /* ******************************************************************************** */
9149
9150 struct cmd_dump_one_result {
9151 cmdline_fixed_string_t dump;
9152 cmdline_fixed_string_t name;
9153 };
9154
9155 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9156 __attribute__((unused)) void *data)
9157 {
9158 struct cmd_dump_one_result *res = parsed_result;
9159
9160 if (!strcmp(res->dump, "dump_ring")) {
9161 struct rte_ring *r;
9162 r = rte_ring_lookup(res->name);
9163 if (r == NULL) {
9164 cmdline_printf(cl, "Cannot find ring\n");
9165 return;
9166 }
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);
9171 if (mp == NULL) {
9172 cmdline_printf(cl, "Cannot find mempool\n");
9173 return;
9174 }
9175 rte_mempool_dump(stdout, mp);
9176 }
9177 }
9178
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");
9182
9183 cmdline_parse_token_string_t cmd_dump_one_name =
9184 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9185
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,
9193 NULL,
9194 },
9195 };
9196
9197 /* *** Add/Del syn filter *** */
9198 struct cmd_syn_filter_result {
9199 cmdline_fixed_string_t filter;
9200 portid_t port_id;
9201 cmdline_fixed_string_t ops;
9202 cmdline_fixed_string_t priority;
9203 cmdline_fixed_string_t high;
9204 cmdline_fixed_string_t queue;
9205 uint16_t queue_id;
9206 };
9207
9208 static void
9209 cmd_syn_filter_parsed(void *parsed_result,
9210 __attribute__((unused)) struct cmdline *cl,
9211 __attribute__((unused)) void *data)
9212 {
9213 struct cmd_syn_filter_result *res = parsed_result;
9214 struct rte_eth_syn_filter syn_filter;
9215 int ret = 0;
9216
9217 ret = rte_eth_dev_filter_supported(res->port_id,
9218 RTE_ETH_FILTER_SYN);
9219 if (ret < 0) {
9220 printf("syn filter is not supported on port %u.\n",
9221 res->port_id);
9222 return;
9223 }
9224
9225 memset(&syn_filter, 0, sizeof(syn_filter));
9226
9227 if (!strcmp(res->ops, "add")) {
9228 if (!strcmp(res->high, "high"))
9229 syn_filter.hig_pri = 1;
9230 else
9231 syn_filter.hig_pri = 0;
9232
9233 syn_filter.queue = res->queue_id;
9234 ret = rte_eth_dev_filter_ctrl(res->port_id,
9235 RTE_ETH_FILTER_SYN,
9236 RTE_ETH_FILTER_ADD,
9237 &syn_filter);
9238 } else
9239 ret = rte_eth_dev_filter_ctrl(res->port_id,
9240 RTE_ETH_FILTER_SYN,
9241 RTE_ETH_FILTER_DELETE,
9242 &syn_filter);
9243
9244 if (ret < 0)
9245 printf("syn filter programming error: (%s)\n",
9246 strerror(-ret));
9247 }
9248
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,
9254 port_id, UINT16);
9255 cmdline_parse_token_string_t cmd_syn_filter_ops =
9256 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9257 ops, "add#del");
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,
9263 high, "high#low");
9264 cmdline_parse_token_string_t cmd_syn_filter_queue =
9265 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result,
9266 queue, "queue");
9267 cmdline_parse_token_num_t cmd_syn_filter_queue_id =
9268 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result,
9269 queue_id, UINT16);
9270
9271 cmdline_parse_inst_t cmd_syn_filter = {
9272 .f = cmd_syn_filter_parsed,
9273 .data = NULL,
9274 .help_str = "syn_filter <port_id> add|del priority high|low queue "
9275 "<queue_id>: Add/Delete syn filter",
9276 .tokens = {
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,
9284 NULL,
9285 },
9286 };
9287
9288 /* *** queue region set *** */
9289 struct cmd_queue_region_result {
9290 cmdline_fixed_string_t set;
9291 cmdline_fixed_string_t port;
9292 portid_t port_id;
9293 cmdline_fixed_string_t cmd;
9294 cmdline_fixed_string_t region;
9295 uint8_t region_id;
9296 cmdline_fixed_string_t queue_start_index;
9297 uint8_t queue_id;
9298 cmdline_fixed_string_t queue_num;
9299 uint8_t queue_num_value;
9300 };
9301
9302 static void
9303 cmd_queue_region_parsed(void *parsed_result,
9304 __attribute__((unused)) struct cmdline *cl,
9305 __attribute__((unused)) void *data)
9306 {
9307 struct cmd_queue_region_result *res = parsed_result;
9308 int ret = -ENOTSUP;
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;
9312 #endif
9313
9314 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9315 return;
9316
9317 #ifdef RTE_LIBRTE_I40E_PMD
9318 memset(&region_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;
9323
9324 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9325 op_type, &region_conf);
9326 #endif
9327
9328 switch (ret) {
9329 case 0:
9330 break;
9331 case -ENOTSUP:
9332 printf("function not implemented or supported\n");
9333 break;
9334 default:
9335 printf("queue region config error: (%s)\n", strerror(-ret));
9336 }
9337 }
9338
9339 cmdline_parse_token_string_t cmd_queue_region_set =
9340 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result,
9341 set, "set");
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,
9346 port_id, UINT16);
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,
9355 region_id, UINT8);
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,
9361 queue_id, UINT8);
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);
9368
9369 cmdline_parse_inst_t cmd_queue_region = {
9370 .f = cmd_queue_region_parsed,
9371 .data = NULL,
9372 .help_str = "set port <port_id> queue-region region_id <value> "
9373 "queue_start_index <value> queue_num <value>: Set a queue region",
9374 .tokens = {
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,
9385 NULL,
9386 },
9387 };
9388
9389 /* *** queue region and flowtype set *** */
9390 struct cmd_region_flowtype_result {
9391 cmdline_fixed_string_t set;
9392 cmdline_fixed_string_t port;
9393 portid_t port_id;
9394 cmdline_fixed_string_t cmd;
9395 cmdline_fixed_string_t region;
9396 uint8_t region_id;
9397 cmdline_fixed_string_t flowtype;
9398 uint8_t flowtype_id;
9399 };
9400
9401 static void
9402 cmd_region_flowtype_parsed(void *parsed_result,
9403 __attribute__((unused)) struct cmdline *cl,
9404 __attribute__((unused)) void *data)
9405 {
9406 struct cmd_region_flowtype_result *res = parsed_result;
9407 int ret = -ENOTSUP;
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;
9411 #endif
9412
9413 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9414 return;
9415
9416 #ifdef RTE_LIBRTE_I40E_PMD
9417 memset(&region_conf, 0, sizeof(region_conf));
9418
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;
9422
9423 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9424 op_type, &region_conf);
9425 #endif
9426
9427 switch (ret) {
9428 case 0:
9429 break;
9430 case -ENOTSUP:
9431 printf("function not implemented or supported\n");
9432 break;
9433 default:
9434 printf("region flowtype config error: (%s)\n", strerror(-ret));
9435 }
9436 }
9437
9438 cmdline_parse_token_string_t cmd_region_flowtype_set =
9439 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9440 set, "set");
9441 cmdline_parse_token_string_t cmd_region_flowtype_port =
9442 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result,
9443 port, "port");
9444 cmdline_parse_token_num_t cmd_region_flowtype_port_index =
9445 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result,
9446 port_id, UINT16);
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,
9455 region_id, UINT8);
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,
9464 .data = NULL,
9465 .help_str = "set port <port_id> queue-region region_id <value> "
9466 "flowtype <value>: Set a flowtype region index",
9467 .tokens = {
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,
9476 NULL,
9477 },
9478 };
9479
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;
9484 portid_t port_id;
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;
9489 uint8_t region_id;
9490 };
9491
9492 static void
9493 cmd_user_priority_region_parsed(void *parsed_result,
9494 __attribute__((unused)) struct cmdline *cl,
9495 __attribute__((unused)) void *data)
9496 {
9497 struct cmd_user_priority_region_result *res = parsed_result;
9498 int ret = -ENOTSUP;
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;
9502 #endif
9503
9504 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9505 return;
9506
9507 #ifdef RTE_LIBRTE_I40E_PMD
9508 memset(&region_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;
9512
9513 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9514 op_type, &region_conf);
9515 #endif
9516
9517 switch (ret) {
9518 case 0:
9519 break;
9520 case -ENOTSUP:
9521 printf("function not implemented or supported\n");
9522 break;
9523 default:
9524 printf("user_priority region config error: (%s)\n",
9525 strerror(-ret));
9526 }
9527 }
9528
9529 cmdline_parse_token_string_t cmd_user_priority_region_set =
9530 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9531 set, "set");
9532 cmdline_parse_token_string_t cmd_user_priority_region_port =
9533 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result,
9534 port, "port");
9535 cmdline_parse_token_num_t cmd_user_priority_region_port_index =
9536 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result,
9537 port_id, UINT16);
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,
9552 region_id, UINT8);
9553
9554 cmdline_parse_inst_t cmd_user_priority_region = {
9555 .f = cmd_user_priority_region_parsed,
9556 .data = NULL,
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) ",
9560 .tokens = {
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,
9569 NULL,
9570 },
9571 };
9572
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;
9577 portid_t port_id;
9578 cmdline_fixed_string_t cmd;
9579 cmdline_fixed_string_t flush;
9580 cmdline_fixed_string_t what;
9581 };
9582
9583 static void
9584 cmd_flush_queue_region_parsed(void *parsed_result,
9585 __attribute__((unused)) struct cmdline *cl,
9586 __attribute__((unused)) void *data)
9587 {
9588 struct cmd_flush_queue_region_result *res = parsed_result;
9589 int ret = -ENOTSUP;
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;
9593 #endif
9594
9595 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9596 return;
9597
9598 #ifdef RTE_LIBRTE_I40E_PMD
9599 memset(&region_conf, 0, sizeof(region_conf));
9600
9601 if (strcmp(res->what, "on") == 0)
9602 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON;
9603 else
9604 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF;
9605
9606 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9607 op_type, &region_conf);
9608 #endif
9609
9610 switch (ret) {
9611 case 0:
9612 break;
9613 case -ENOTSUP:
9614 printf("function not implemented or supported\n");
9615 break;
9616 default:
9617 printf("queue region config flush error: (%s)\n",
9618 strerror(-ret));
9619 }
9620 }
9621
9622 cmdline_parse_token_string_t cmd_flush_queue_region_set =
9623 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9624 set, "set");
9625 cmdline_parse_token_string_t cmd_flush_queue_region_port =
9626 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9627 port, "port");
9628 cmdline_parse_token_num_t cmd_flush_queue_region_port_index =
9629 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result,
9630 port_id, UINT16);
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,
9636 flush, "flush");
9637 cmdline_parse_token_string_t cmd_flush_queue_region_what =
9638 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result,
9639 what, "on#off");
9640
9641 cmdline_parse_inst_t cmd_flush_queue_region = {
9642 .f = cmd_flush_queue_region_parsed,
9643 .data = NULL,
9644 .help_str = "set port <port_id> queue-region flush on|off"
9645 ": flush all queue region related configuration",
9646 .tokens = {
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,
9653 NULL,
9654 },
9655 };
9656
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;
9661 portid_t port_id;
9662 cmdline_fixed_string_t cmd;
9663 };
9664
9665 static void
9666 cmd_show_queue_region_info_parsed(void *parsed_result,
9667 __attribute__((unused)) struct cmdline *cl,
9668 __attribute__((unused)) void *data)
9669 {
9670 struct cmd_show_queue_region_info *res = parsed_result;
9671 int ret = -ENOTSUP;
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;
9675 #endif
9676
9677 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9678 return;
9679
9680 #ifdef RTE_LIBRTE_I40E_PMD
9681 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions));
9682
9683 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET;
9684
9685 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id,
9686 op_type, &rte_pmd_regions);
9687
9688 port_queue_region_info_display(res->port_id, &rte_pmd_regions);
9689 #endif
9690
9691 switch (ret) {
9692 case 0:
9693 break;
9694 case -ENOTSUP:
9695 printf("function not implemented or supported\n");
9696 break;
9697 default:
9698 printf("queue region config info show error: (%s)\n",
9699 strerror(-ret));
9700 }
9701 }
9702
9703 cmdline_parse_token_string_t cmd_show_queue_region_info_get =
9704 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9705 show, "show");
9706 cmdline_parse_token_string_t cmd_show_queue_region_info_port =
9707 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info,
9708 port, "port");
9709 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index =
9710 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info,
9711 port_id, UINT16);
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");
9715
9716 cmdline_parse_inst_t cmd_show_queue_region_info_all = {
9717 .f = cmd_show_queue_region_info_parsed,
9718 .data = NULL,
9719 .help_str = "show port <port_id> queue-region"
9720 ": show all queue region related configuration info",
9721 .tokens = {
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,
9726 NULL,
9727 },
9728 };
9729
9730 /* *** ADD/REMOVE A 2tuple FILTER *** */
9731 struct cmd_2tuple_filter_result {
9732 cmdline_fixed_string_t filter;
9733 portid_t port_id;
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;
9740 uint8_t mask_value;
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;
9746 uint16_t queue_id;
9747 };
9748
9749 static void
9750 cmd_2tuple_filter_parsed(void *parsed_result,
9751 __attribute__((unused)) struct cmdline *cl,
9752 __attribute__((unused)) void *data)
9753 {
9754 struct rte_eth_ntuple_filter filter;
9755 struct cmd_2tuple_filter_result *res = parsed_result;
9756 int ret = 0;
9757
9758 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9759 if (ret < 0) {
9760 printf("ntuple filter is not supported on port %u.\n",
9761 res->port_id);
9762 return;
9763 }
9764
9765 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9766
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");
9775 return;
9776 }
9777 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9778 printf("invalid TCP flags.\n");
9779 return;
9780 }
9781
9782 if (res->tcp_flags_value != 0) {
9783 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9784 filter.tcp_flags = res->tcp_flags_value;
9785 }
9786
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;
9790
9791 if (!strcmp(res->ops, "add"))
9792 ret = rte_eth_dev_filter_ctrl(res->port_id,
9793 RTE_ETH_FILTER_NTUPLE,
9794 RTE_ETH_FILTER_ADD,
9795 &filter);
9796 else
9797 ret = rte_eth_dev_filter_ctrl(res->port_id,
9798 RTE_ETH_FILTER_NTUPLE,
9799 RTE_ETH_FILTER_DELETE,
9800 &filter);
9801 if (ret < 0)
9802 printf("2tuple filter programming error: (%s)\n",
9803 strerror(-ret));
9804
9805 }
9806
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,
9812 port_id, UINT16);
9813 cmdline_parse_token_string_t cmd_2tuple_filter_ops =
9814 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result,
9815 ops, "add#del");
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,
9830 mask, "mask");
9831 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value =
9832 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9833 mask_value, INT8);
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,
9848 queue, "queue");
9849 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id =
9850 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result,
9851 queue_id, UINT16);
9852
9853 cmdline_parse_inst_t cmd_2tuple_filter = {
9854 .f = cmd_2tuple_filter_parsed,
9855 .data = NULL,
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",
9859 .tokens = {
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,
9875 NULL,
9876 },
9877 };
9878
9879 /* *** ADD/REMOVE A 5tuple FILTER *** */
9880 struct cmd_5tuple_filter_result {
9881 cmdline_fixed_string_t filter;
9882 portid_t port_id;
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;
9895 uint8_t mask_value;
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;
9901 uint16_t queue_id;
9902 };
9903
9904 static void
9905 cmd_5tuple_filter_parsed(void *parsed_result,
9906 __attribute__((unused)) struct cmdline *cl,
9907 __attribute__((unused)) void *data)
9908 {
9909 struct rte_eth_ntuple_filter filter;
9910 struct cmd_5tuple_filter_result *res = parsed_result;
9911 int ret = 0;
9912
9913 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE);
9914 if (ret < 0) {
9915 printf("ntuple filter is not supported on port %u.\n",
9916 res->port_id);
9917 return;
9918 }
9919
9920 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter));
9921
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");
9933 return;
9934 }
9935 if (res->tcp_flags_value > TCP_FLAG_ALL) {
9936 printf("invalid TCP flags.\n");
9937 return;
9938 }
9939
9940 if (res->tcp_flags_value != 0) {
9941 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG;
9942 filter.tcp_flags = res->tcp_flags_value;
9943 }
9944
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;
9948 else {
9949 if (filter.dst_ip_mask == 0) {
9950 printf("can not support ipv6 involved compare.\n");
9951 return;
9952 }
9953 filter.dst_ip = 0;
9954 }
9955
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;
9959 else {
9960 if (filter.src_ip_mask == 0) {
9961 printf("can not support ipv6 involved compare.\n");
9962 return;
9963 }
9964 filter.src_ip = 0;
9965 }
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;
9970
9971 if (!strcmp(res->ops, "add"))
9972 ret = rte_eth_dev_filter_ctrl(res->port_id,
9973 RTE_ETH_FILTER_NTUPLE,
9974 RTE_ETH_FILTER_ADD,
9975 &filter);
9976 else
9977 ret = rte_eth_dev_filter_ctrl(res->port_id,
9978 RTE_ETH_FILTER_NTUPLE,
9979 RTE_ETH_FILTER_DELETE,
9980 &filter);
9981 if (ret < 0)
9982 printf("5tuple filter programming error: (%s)\n",
9983 strerror(-ret));
9984 }
9985
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,
9991 port_id, UINT16);
9992 cmdline_parse_token_string_t cmd_5tuple_filter_ops =
9993 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9994 ops, "add#del");
9995 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip =
9996 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
9997 dst_ip, "dst_ip");
9998 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value =
9999 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10000 dst_ip_value);
10001 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip =
10002 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result,
10003 src_ip, "src_ip");
10004 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value =
10005 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result,
10006 src_ip_value);
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,
10027 mask, "mask");
10028 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value =
10029 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10030 mask_value, INT8);
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,
10045 queue, "queue");
10046 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id =
10047 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result,
10048 queue_id, UINT16);
10049
10050 cmdline_parse_inst_t cmd_5tuple_filter = {
10051 .f = cmd_5tuple_filter_parsed,
10052 .data = NULL,
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",
10057 .tokens = {
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,
10079 NULL,
10080 },
10081 };
10082
10083 /* *** ADD/REMOVE A flex FILTER *** */
10084 struct cmd_flex_filter_result {
10085 cmdline_fixed_string_t filter;
10086 cmdline_fixed_string_t ops;
10087 portid_t port_id;
10088 cmdline_fixed_string_t len;
10089 uint8_t len_value;
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;
10097 uint16_t queue_id;
10098 };
10099
10100 static int xdigit2val(unsigned char c)
10101 {
10102 int val;
10103 if (isdigit(c))
10104 val = c - '0';
10105 else if (isupper(c))
10106 val = c - 'A' + 10;
10107 else
10108 val = c - 'a' + 10;
10109 return val;
10110 }
10111
10112 static void
10113 cmd_flex_filter_parsed(void *parsed_result,
10114 __attribute__((unused)) struct cmdline *cl,
10115 __attribute__((unused)) void *data)
10116 {
10117 int ret = 0;
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;
10122 char c;
10123 int val;
10124 uint8_t byte = 0;
10125
10126 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
10127 printf("the len exceed the max length 128\n");
10128 return;
10129 }
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;
10136
10137 /* translate bytes string to array. */
10138 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
10139 (bytes_ptr[1] == 'X')))
10140 bytes_ptr += 2;
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");
10144 return;
10145 }
10146 for (i = 0; i < len; i++) {
10147 c = bytes_ptr[i];
10148 if (isxdigit(c) == 0) {
10149 /* invalid characters. */
10150 printf("invalid input\n");
10151 return;
10152 }
10153 val = xdigit2val(c);
10154 if (i % 2) {
10155 byte |= val;
10156 filter.bytes[j] = byte;
10157 printf("bytes[%d]:%02x ", j, filter.bytes[j]);
10158 j++;
10159 byte = 0;
10160 } else
10161 byte |= val << 4;
10162 }
10163 printf("\n");
10164 /* translate mask string to uint8_t array. */
10165 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
10166 (mask_ptr[1] == 'X')))
10167 mask_ptr += 2;
10168 len = strnlen(mask_ptr, (res->len_value + 3) / 4);
10169 if (len == 0) {
10170 printf("invalid input\n");
10171 return;
10172 }
10173 j = 0;
10174 byte = 0;
10175 for (i = 0; i < len; i++) {
10176 c = mask_ptr[i];
10177 if (isxdigit(c) == 0) {
10178 /* invalid characters. */
10179 printf("invalid input\n");
10180 return;
10181 }
10182 val = xdigit2val(c);
10183 if (i % 2) {
10184 byte |= val;
10185 filter.mask[j] = byte;
10186 printf("mask[%d]:%02x ", j, filter.mask[j]);
10187 j++;
10188 byte = 0;
10189 } else
10190 byte |= val << 4;
10191 }
10192 printf("\n");
10193
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,
10198 &filter);
10199 else
10200 ret = rte_eth_dev_filter_ctrl(res->port_id,
10201 RTE_ETH_FILTER_FLEXIBLE,
10202 RTE_ETH_FILTER_DELETE,
10203 &filter);
10204
10205 if (ret < 0)
10206 printf("flex filter setting error: (%s)\n", strerror(-ret));
10207 }
10208
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,
10214 port_id, UINT16);
10215 cmdline_parse_token_string_t cmd_flex_filter_ops =
10216 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10217 ops, "add#del");
10218 cmdline_parse_token_string_t cmd_flex_filter_len =
10219 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10220 len, "len");
10221 cmdline_parse_token_num_t cmd_flex_filter_len_value =
10222 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10223 len_value, UINT8);
10224 cmdline_parse_token_string_t cmd_flex_filter_bytes =
10225 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10226 bytes, "bytes");
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,
10232 mask, "mask");
10233 cmdline_parse_token_string_t cmd_flex_filter_mask_value =
10234 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
10235 mask_value, NULL);
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,
10244 queue, "queue");
10245 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
10246 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
10247 queue_id, UINT16);
10248 cmdline_parse_inst_t cmd_flex_filter = {
10249 .f = cmd_flex_filter_parsed,
10250 .data = NULL,
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",
10254 .tokens = {
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,
10268 NULL,
10269 },
10270 };
10271
10272 /* *** Filters Control *** */
10273
10274 /* *** deal with ethertype filter *** */
10275 struct cmd_ethertype_filter_result {
10276 cmdline_fixed_string_t filter;
10277 portid_t port_id;
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;
10285 uint16_t queue_id;
10286 };
10287
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,
10293 port_id, UINT16);
10294 cmdline_parse_token_string_t cmd_ethertype_filter_ops =
10295 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10296 ops, "add#del");
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,
10302 mac_addr);
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,
10311 drop, "drop#fwd");
10312 cmdline_parse_token_string_t cmd_ethertype_filter_queue =
10313 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
10314 queue, "queue");
10315 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
10316 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
10317 queue_id, UINT16);
10318
10319 static void
10320 cmd_ethertype_filter_parsed(void *parsed_result,
10321 __attribute__((unused)) struct cmdline *cl,
10322 __attribute__((unused)) void *data)
10323 {
10324 struct cmd_ethertype_filter_result *res = parsed_result;
10325 struct rte_eth_ethertype_filter filter;
10326 int ret = 0;
10327
10328 ret = rte_eth_dev_filter_supported(res->port_id,
10329 RTE_ETH_FILTER_ETHERTYPE);
10330 if (ret < 0) {
10331 printf("ethertype filter is not supported on port %u.\n",
10332 res->port_id);
10333 return;
10334 }
10335
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));
10341 }
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;
10346
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,
10351 &filter);
10352 else
10353 ret = rte_eth_dev_filter_ctrl(res->port_id,
10354 RTE_ETH_FILTER_ETHERTYPE,
10355 RTE_ETH_FILTER_DELETE,
10356 &filter);
10357 if (ret < 0)
10358 printf("ethertype filter programming error: (%s)\n",
10359 strerror(-ret));
10360 }
10361
10362 cmdline_parse_inst_t cmd_ethertype_filter = {
10363 .f = cmd_ethertype_filter_parsed,
10364 .data = NULL,
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",
10368 .tokens = {
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,
10379 NULL,
10380 },
10381 };
10382
10383 /* *** deal with flow director filter *** */
10384 struct cmd_flow_director_result {
10385 cmdline_fixed_string_t flow_director_filter;
10386 portid_t port_id;
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;
10396 uint16_t port_src;
10397 cmdline_fixed_string_t dst;
10398 cmdline_ipaddr_t ip_dst;
10399 uint16_t port_dst;
10400 cmdline_fixed_string_t verify_tag;
10401 uint32_t verify_tag_value;
10402 cmdline_fixed_string_t tos;
10403 uint8_t tos_value;
10404 cmdline_fixed_string_t proto;
10405 uint8_t proto_value;
10406 cmdline_fixed_string_t ttl;
10407 uint8_t ttl_value;
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;
10415 uint16_t queue_id;
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;
10425 char filepath[];
10426 };
10427
10428 static inline int
10429 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num)
10430 {
10431 char s[256];
10432 const char *p, *p0 = q_arg;
10433 char *end;
10434 unsigned long int_fld;
10435 char *str_fld[max_num];
10436 int i;
10437 unsigned size;
10438 int ret = -1;
10439
10440 p = strchr(p0, '(');
10441 if (p == NULL)
10442 return -1;
10443 ++p;
10444 p0 = strchr(p, ')');
10445 if (p0 == NULL)
10446 return -1;
10447
10448 size = p0 - p;
10449 if (size >= sizeof(s))
10450 return -1;
10451
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)
10455 return -1;
10456 for (i = 0; i < ret; i++) {
10457 errno = 0;
10458 int_fld = strtoul(str_fld[i], &end, 0);
10459 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX)
10460 return -1;
10461 flexbytes[i] = (uint8_t)int_fld;
10462 }
10463 return ret;
10464 }
10465
10466 static uint16_t
10467 str2flowtype(char *string)
10468 {
10469 uint8_t i = 0;
10470 static const struct {
10471 char str[32];
10472 uint16_t type;
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},
10488 };
10489
10490 for (i = 0; i < RTE_DIM(flowtype_str); i++) {
10491 if (!strcmp(flowtype_str[i].str, string))
10492 return flowtype_str[i].type;
10493 }
10494
10495 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64)
10496 return (uint16_t)atoi(string);
10497
10498 return RTE_ETH_FLOW_UNKNOWN;
10499 }
10500
10501 static enum rte_eth_fdir_tunnel_type
10502 str2fdir_tunneltype(char *string)
10503 {
10504 uint8_t i = 0;
10505
10506 static const struct {
10507 char str[32];
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},
10512 };
10513
10514 for (i = 0; i < RTE_DIM(tunneltype_str); i++) {
10515 if (!strcmp(tunneltype_str[i].str, string))
10516 return tunneltype_str[i].type;
10517 }
10518 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN;
10519 }
10520
10521 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
10522 do { \
10523 if ((ip_addr).family == AF_INET) \
10524 (ip) = (ip_addr).addr.ipv4.s_addr; \
10525 else { \
10526 printf("invalid parameter.\n"); \
10527 return; \
10528 } \
10529 } while (0)
10530
10531 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
10532 do { \
10533 if ((ip_addr).family == AF_INET6) \
10534 rte_memcpy(&(ip), \
10535 &((ip_addr).addr.ipv6), \
10536 sizeof(struct in6_addr)); \
10537 else { \
10538 printf("invalid parameter.\n"); \
10539 return; \
10540 } \
10541 } while (0)
10542
10543 static void
10544 cmd_flow_director_filter_parsed(void *parsed_result,
10545 __attribute__((unused)) struct cmdline *cl,
10546 __attribute__((unused)) void *data)
10547 {
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];
10551 char *end;
10552 unsigned long vf_id;
10553 int ret = 0;
10554
10555 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
10556 if (ret < 0) {
10557 printf("flow director is not supported on port %u.\n",
10558 res->port_id);
10559 return;
10560 }
10561 memset(flexbytes, 0, sizeof(flexbytes));
10562 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter));
10563
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");
10567 return;
10568 }
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");
10572 return;
10573 }
10574 } else {
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;
10582 uint8_t add;
10583
10584 memset(&conf, 0, sizeof(conf));
10585
10586 if (flow_type == RTE_ETH_FLOW_UNKNOWN) {
10587 printf("Invalid flow type specified.\n");
10588 return;
10589 }
10590 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id,
10591 mapping);
10592 if (ret)
10593 return;
10594 if (mapping[flow_type].pctype == 0ULL) {
10595 printf("Invalid flow type specified.\n");
10596 return;
10597 }
10598 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) {
10599 if (mapping[flow_type].pctype & (1ULL << i)) {
10600 conf.input.pctype = i;
10601 break;
10602 }
10603 }
10604
10605 conf.input.packet = open_file(res->filepath,
10606 &conf.input.length);
10607 if (!conf.input.packet)
10608 return;
10609 if (!strcmp(res->drop, "drop"))
10610 conf.action.behavior =
10611 RTE_PMD_I40E_PKT_TEMPLATE_REJECT;
10612 else
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,
10621 &conf,
10622 add);
10623 if (ret < 0)
10624 printf("flow director config error: (%s)\n",
10625 strerror(-ret));
10626 close_file(conf.input.packet);
10627 #endif
10628 return;
10629 } else if (strcmp(res->mode_value, "IP")) {
10630 printf("Please set mode to IP or raw.\n");
10631 return;
10632 }
10633 entry.input.flow_type = str2flowtype(res->flow_type);
10634 }
10635
10636 ret = parse_flexbytes(res->flexbytes_value,
10637 flexbytes,
10638 RTE_ETH_FDIR_MAX_FLEXLEN);
10639 if (ret < 0) {
10640 printf("error: Cannot parse flexbytes input.\n");
10641 return;
10642 }
10643
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;
10648 /* fall-through */
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);
10662 break;
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);
10677 break;
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;
10681 /* fall-through */
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);
10695 break;
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);
10710 break;
10711 case RTE_ETH_FLOW_L2_PAYLOAD:
10712 entry.input.flow.l2_flow.ether_type =
10713 rte_cpu_to_be_16(res->ether_type);
10714 break;
10715 default:
10716 break;
10717 }
10718
10719 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN)
10720 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr,
10721 &res->mac_addr,
10722 sizeof(struct ether_addr));
10723
10724 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) {
10725 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr,
10726 &res->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);
10732 }
10733
10734 rte_memcpy(entry.input.flow_ext.flexbytes,
10735 flexbytes,
10736 RTE_ETH_FDIR_MAX_FLEXLEN);
10737
10738 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value);
10739
10740 entry.action.flex_off = 0; /*use 0 by default */
10741 if (!strcmp(res->drop, "drop"))
10742 entry.action.behavior = RTE_ETH_FDIR_REJECT;
10743 else
10744 entry.action.behavior = RTE_ETH_FDIR_ACCEPT;
10745
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;
10752
10753 memset(&dev_info, 0, sizeof(dev_info));
10754 rte_eth_dev_info_get(res->port_id, &dev_info);
10755 errno = 0;
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);
10760 return;
10761 }
10762 entry.input.flow_ext.is_vf = 1;
10763 entry.input.flow_ext.dst_id = (uint16_t)vf_id;
10764 } else {
10765 printf("invalid parameter %s.\n", res->pf_vf);
10766 return;
10767 }
10768 }
10769
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);
10780 else
10781 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
10782 RTE_ETH_FILTER_UPDATE, &entry);
10783 if (ret < 0)
10784 printf("flow director programming error: (%s)\n",
10785 strerror(-ret));
10786 }
10787
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,
10793 port_id, UINT16);
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,
10799 flow, "flow");
10800 cmdline_parse_token_string_t cmd_flow_director_flow_type =
10801 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10802 flow_type, NULL);
10803 cmdline_parse_token_string_t cmd_flow_director_ether =
10804 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10805 ether, "ether");
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,
10811 src, "src");
10812 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src =
10813 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10814 ip_src);
10815 cmdline_parse_token_num_t cmd_flow_director_port_src =
10816 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10817 port_src, UINT16);
10818 cmdline_parse_token_string_t cmd_flow_director_dst =
10819 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10820 dst, "dst");
10821 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst =
10822 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result,
10823 ip_dst);
10824 cmdline_parse_token_num_t cmd_flow_director_port_dst =
10825 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10826 port_dst, UINT16);
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,
10835 tos, "tos");
10836 cmdline_parse_token_num_t cmd_flow_director_tos_value =
10837 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10838 tos_value, UINT8);
10839 cmdline_parse_token_string_t cmd_flow_director_proto =
10840 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10841 proto, "proto");
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,
10847 ttl, "ttl");
10848 cmdline_parse_token_num_t cmd_flow_director_ttl_value =
10849 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10850 ttl_value, UINT8);
10851 cmdline_parse_token_string_t cmd_flow_director_vlan =
10852 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10853 vlan, "vlan");
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,
10865 drop, "drop#fwd");
10866 cmdline_parse_token_string_t cmd_flow_director_pf_vf =
10867 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10868 pf_vf, NULL);
10869 cmdline_parse_token_string_t cmd_flow_director_queue =
10870 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10871 queue, "queue");
10872 cmdline_parse_token_num_t cmd_flow_director_queue_id =
10873 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result,
10874 queue_id, UINT16);
10875 cmdline_parse_token_string_t cmd_flow_director_fd_id =
10876 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10877 fd_id, "fd_id");
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);
10881
10882 cmdline_parse_token_string_t cmd_flow_director_mode =
10883 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10884 mode, "mode");
10885 cmdline_parse_token_string_t cmd_flow_director_mode_ip =
10886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10887 mode_value, "IP");
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,
10899 mac, "mac");
10900 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr =
10901 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result,
10902 mac_addr);
10903 cmdline_parse_token_string_t cmd_flow_director_tunnel =
10904 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10905 tunnel, "tunnel");
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,
10917 packet, "packet");
10918 cmdline_parse_token_string_t cmd_flow_director_filepath =
10919 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result,
10920 filepath, NULL);
10921
10922 cmdline_parse_inst_t cmd_add_del_ip_flow_director = {
10923 .f = cmd_flow_director_filter_parsed,
10924 .data = NULL,
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",
10933 .tokens = {
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,
10961 NULL,
10962 },
10963 };
10964
10965 cmdline_parse_inst_t cmd_add_del_udp_flow_director = {
10966 .f = cmd_flow_director_filter_parsed,
10967 .data = NULL,
10968 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow "
10969 "director entry on NIC",
10970 .tokens = {
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,
10998 NULL,
10999 },
11000 };
11001
11002 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = {
11003 .f = cmd_flow_director_filter_parsed,
11004 .data = NULL,
11005 .help_str = "flow_director_filter ... : Add or delete a sctp flow "
11006 "director entry on NIC",
11007 .tokens = {
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,
11037 NULL,
11038 },
11039 };
11040
11041 cmdline_parse_inst_t cmd_add_del_l2_flow_director = {
11042 .f = cmd_flow_director_filter_parsed,
11043 .data = NULL,
11044 .help_str = "flow_director_filter ... : Add or delete a L2 flow "
11045 "director entry on NIC",
11046 .tokens = {
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,
11064 NULL,
11065 },
11066 };
11067
11068 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = {
11069 .f = cmd_flow_director_filter_parsed,
11070 .data = NULL,
11071 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow "
11072 "director entry on NIC",
11073 .tokens = {
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,
11090 NULL,
11091 },
11092 };
11093
11094 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = {
11095 .f = cmd_flow_director_filter_parsed,
11096 .data = NULL,
11097 .help_str = "flow_director_filter ... : Add or delete a tunnel flow "
11098 "director entry on NIC",
11099 .tokens = {
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,
11120 NULL,
11121 },
11122 };
11123
11124 cmdline_parse_inst_t cmd_add_del_raw_flow_director = {
11125 .f = cmd_flow_director_filter_parsed,
11126 .data = NULL,
11127 .help_str = "flow_director_filter ... : Add or delete a raw flow "
11128 "director entry on NIC",
11129 .tokens = {
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,
11144 NULL,
11145 },
11146 };
11147
11148 struct cmd_flush_flow_director_result {
11149 cmdline_fixed_string_t flush_flow_director;
11150 portid_t port_id;
11151 };
11152
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,
11158 port_id, UINT16);
11159
11160 static void
11161 cmd_flush_flow_director_parsed(void *parsed_result,
11162 __attribute__((unused)) struct cmdline *cl,
11163 __attribute__((unused)) void *data)
11164 {
11165 struct cmd_flow_director_result *res = parsed_result;
11166 int ret = 0;
11167
11168 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR);
11169 if (ret < 0) {
11170 printf("flow director is not supported on port %u.\n",
11171 res->port_id);
11172 return;
11173 }
11174
11175 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR,
11176 RTE_ETH_FILTER_FLUSH, NULL);
11177 if (ret < 0)
11178 printf("flow director table flushing error: (%s)\n",
11179 strerror(-ret));
11180 }
11181
11182 cmdline_parse_inst_t cmd_flush_flow_director = {
11183 .f = cmd_flush_flow_director_parsed,
11184 .data = NULL,
11185 .help_str = "flush_flow_director <port_id>: "
11186 "Flush all flow director entries of a device on NIC",
11187 .tokens = {
11188 (void *)&cmd_flush_flow_director_flush,
11189 (void *)&cmd_flush_flow_director_port_id,
11190 NULL,
11191 },
11192 };
11193
11194 /* *** deal with flow director mask *** */
11195 struct cmd_flow_director_mask_result {
11196 cmdline_fixed_string_t flow_director_mask;
11197 portid_t port_id;
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;
11205 uint16_t port_src;
11206 cmdline_fixed_string_t dst_mask;
11207 cmdline_ipaddr_t ipv4_dst;
11208 cmdline_ipaddr_t ipv6_dst;
11209 uint16_t port_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;
11216 };
11217
11218 static void
11219 cmd_flow_director_mask_parsed(void *parsed_result,
11220 __attribute__((unused)) struct cmdline *cl,
11221 __attribute__((unused)) void *data)
11222 {
11223 struct cmd_flow_director_mask_result *res = parsed_result;
11224 struct rte_eth_fdir_masks *mask;
11225 struct rte_port *port;
11226
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);
11231 return;
11232 }
11233
11234 mask = &port->dev_conf.fdir_conf.mask;
11235
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");
11239 return;
11240 }
11241
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");
11246 return;
11247 }
11248
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;
11253 } else {
11254 if (strcmp(res->mode_value, "IP")) {
11255 printf("Please set mode to IP.\n");
11256 return;
11257 }
11258
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);
11266 }
11267
11268 cmd_reconfig_device_queue(res->port_id, 1, 1);
11269 }
11270
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,
11276 port_id, UINT16);
11277 cmdline_parse_token_string_t cmd_flow_director_mask_vlan =
11278 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11279 vlan, "vlan");
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,
11288 ipv4_src);
11289 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src =
11290 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11291 ipv6_src);
11292 cmdline_parse_token_num_t cmd_flow_director_mask_port_src =
11293 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11294 port_src, UINT16);
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,
11300 ipv4_dst);
11301 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst =
11302 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result,
11303 ipv6_dst);
11304 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst =
11305 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result,
11306 port_dst, UINT16);
11307
11308 cmdline_parse_token_string_t cmd_flow_director_mask_mode =
11309 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11310 mode, "mode");
11311 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip =
11312 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result,
11313 mode_value, "IP");
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,
11322 mac, "mac");
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);
11338
11339 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = {
11340 .f = cmd_flow_director_mask_parsed,
11341 .data = NULL,
11342 .help_str = "flow_director_mask ... : "
11343 "Set IP mode flow director's mask on NIC",
11344 .tokens = {
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,
11359 NULL,
11360 },
11361 };
11362
11363 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = {
11364 .f = cmd_flow_director_mask_parsed,
11365 .data = NULL,
11366 .help_str = "flow_director_mask ... : Set MAC VLAN mode "
11367 "flow director's mask on NIC",
11368 .tokens = {
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,
11375 NULL,
11376 },
11377 };
11378
11379 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = {
11380 .f = cmd_flow_director_mask_parsed,
11381 .data = NULL,
11382 .help_str = "flow_director_mask ... : Set tunnel mode "
11383 "flow director's mask on NIC",
11384 .tokens = {
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,
11397 NULL,
11398 },
11399 };
11400
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;
11404 portid_t port_id;
11405 cmdline_fixed_string_t flow;
11406 cmdline_fixed_string_t flow_type;
11407 cmdline_fixed_string_t mask;
11408 };
11409
11410 static void
11411 cmd_flow_director_flex_mask_parsed(void *parsed_result,
11412 __attribute__((unused)) struct cmdline *cl,
11413 __attribute__((unused)) void *data)
11414 {
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;
11420 uint16_t i;
11421 int ret;
11422
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);
11427 return;
11428 }
11429
11430 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask));
11431 ret = parse_flexbytes(res->mask,
11432 flex_mask.mask,
11433 RTE_ETH_FDIR_MAX_FLEXLEN);
11434 if (ret < 0) {
11435 printf("error: Cannot parse mask input.\n");
11436 return;
11437 }
11438
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);
11442 if (ret < 0) {
11443 printf("Cannot get FDir filter info\n");
11444 return;
11445 }
11446
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],
11455 &flex_mask,
11456 sizeof(struct rte_eth_fdir_flex_mask));
11457 cmd_reconfig_device_queue(res->port_id, 1, 1);
11458 return;
11459 }
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");
11464 return;
11465 }
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);
11470 }
11471 }
11472 cmd_reconfig_device_queue(res->port_id, 1, 1);
11473 return;
11474 }
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);
11479 return;
11480 }
11481 fdir_set_flex_mask(res->port_id, &flex_mask);
11482 cmd_reconfig_device_queue(res->port_id, 1, 1);
11483 }
11484
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,
11491 port_id, UINT16);
11492 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow =
11493 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result,
11494 flow, "flow");
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,
11501 mask, NULL);
11502
11503 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = {
11504 .f = cmd_flow_director_flex_mask_parsed,
11505 .data = NULL,
11506 .help_str = "flow_director_flex_mask ... : "
11507 "Set flow director's flex mask on NIC",
11508 .tokens = {
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,
11514 NULL,
11515 },
11516 };
11517
11518 /* *** deal with flow director flexible payload configuration *** */
11519 struct cmd_flow_director_flexpayload_result {
11520 cmdline_fixed_string_t flow_director_flexpayload;
11521 portid_t port_id;
11522 cmdline_fixed_string_t payload_layer;
11523 cmdline_fixed_string_t payload_cfg;
11524 };
11525
11526 static inline int
11527 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num)
11528 {
11529 char s[256];
11530 const char *p, *p0 = q_arg;
11531 char *end;
11532 unsigned long int_fld;
11533 char *str_fld[max_num];
11534 int i;
11535 unsigned size;
11536 int ret = -1;
11537
11538 p = strchr(p0, '(');
11539 if (p == NULL)
11540 return -1;
11541 ++p;
11542 p0 = strchr(p, ')');
11543 if (p0 == NULL)
11544 return -1;
11545
11546 size = p0 - p;
11547 if (size >= sizeof(s))
11548 return -1;
11549
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)
11553 return -1;
11554 for (i = 0; i < ret; i++) {
11555 errno = 0;
11556 int_fld = strtoul(str_fld[i], &end, 0);
11557 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX)
11558 return -1;
11559 offsets[i] = (uint16_t)int_fld;
11560 }
11561 return ret;
11562 }
11563
11564 static void
11565 cmd_flow_director_flxpld_parsed(void *parsed_result,
11566 __attribute__((unused)) struct cmdline *cl,
11567 __attribute__((unused)) void *data)
11568 {
11569 struct cmd_flow_director_flexpayload_result *res = parsed_result;
11570 struct rte_eth_flex_payload_cfg flex_cfg;
11571 struct rte_port *port;
11572 int ret = 0;
11573
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);
11578 return;
11579 }
11580
11581 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg));
11582
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;
11591
11592 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset,
11593 RTE_ETH_FDIR_MAX_FLEXLEN);
11594 if (ret < 0) {
11595 printf("error: Cannot parse flex payload input.\n");
11596 return;
11597 }
11598
11599 fdir_set_flex_payload(res->port_id, &flex_cfg);
11600 cmd_reconfig_device_queue(res->port_id, 1, 1);
11601 }
11602
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,
11609 port_id, UINT16);
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);
11616
11617 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = {
11618 .f = cmd_flow_director_flxpld_parsed,
11619 .data = NULL,
11620 .help_str = "flow_director_flexpayload ... : "
11621 "Set flow director's flex payload on NIC",
11622 .tokens = {
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,
11627 NULL,
11628 },
11629 };
11630
11631 /* Generic flow interface command. */
11632 extern cmdline_parse_inst_t cmd_flow;
11633
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;
11638 portid_t port_id;
11639 };
11640
11641 static void
11642 cmd_get_sym_hash_per_port_parsed(void *parsed_result,
11643 __rte_unused struct cmdline *cl,
11644 __rte_unused void *data)
11645 {
11646 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
11647 struct rte_eth_hash_filter_info info;
11648 int ret;
11649
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",
11653 res->port_id);
11654 return;
11655 }
11656
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);
11661
11662 if (ret < 0) {
11663 printf("Cannot get symmetric hash enable per port "
11664 "on port %u\n", res->port_id);
11665 return;
11666 }
11667
11668 printf("Symmetric hash is %s on port %u\n", info.info.enable ?
11669 "enabled" : "disabled", res->port_id);
11670 }
11671
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,
11677 port_id, UINT16);
11678
11679 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
11680 .f = cmd_get_sym_hash_per_port_parsed,
11681 .data = NULL,
11682 .help_str = "get_sym_hash_ena_per_port <port_id>",
11683 .tokens = {
11684 (void *)&cmd_get_sym_hash_ena_per_port_all,
11685 (void *)&cmd_get_sym_hash_ena_per_port_port_id,
11686 NULL,
11687 },
11688 };
11689
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;
11694 portid_t port_id;
11695 };
11696
11697 static void
11698 cmd_set_sym_hash_per_port_parsed(void *parsed_result,
11699 __rte_unused struct cmdline *cl,
11700 __rte_unused void *data)
11701 {
11702 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
11703 struct rte_eth_hash_filter_info info;
11704 int ret;
11705
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",
11709 res->port_id);
11710 return;
11711 }
11712
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);
11719 if (ret < 0) {
11720 printf("Cannot set symmetric hash enable per port on "
11721 "port %u\n", res->port_id);
11722 return;
11723 }
11724 printf("Symmetric hash has been set to %s on port %u\n",
11725 res->enable, res->port_id);
11726 }
11727
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,
11733 port_id, UINT16);
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");
11737
11738 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
11739 .f = cmd_set_sym_hash_per_port_parsed,
11740 .data = NULL,
11741 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable",
11742 .tokens = {
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,
11746 NULL,
11747 },
11748 };
11749
11750 /* Get global config of hash function */
11751 struct cmd_get_hash_global_config_result {
11752 cmdline_fixed_string_t get_hash_global_config;
11753 portid_t port_id;
11754 };
11755
11756 static char *
11757 flowtype_to_str(uint16_t ftype)
11758 {
11759 uint16_t i;
11760 static struct {
11761 char str[16];
11762 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},
11781 };
11782
11783 for (i = 0; i < RTE_DIM(ftype_table); i++) {
11784 if (ftype_table[i].ftype == ftype)
11785 return ftype_table[i].str;
11786 }
11787
11788 return NULL;
11789 }
11790
11791 static void
11792 cmd_get_hash_global_config_parsed(void *parsed_result,
11793 __rte_unused struct cmdline *cl,
11794 __rte_unused void *data)
11795 {
11796 struct cmd_get_hash_global_config_result *res = parsed_result;
11797 struct rte_eth_hash_filter_info info;
11798 uint32_t idx, offset;
11799 uint16_t i;
11800 char *str;
11801 int ret;
11802
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",
11806 res->port_id);
11807 return;
11808 }
11809
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);
11814 if (ret < 0) {
11815 printf("Cannot get hash global configurations by port %d\n",
11816 res->port_id);
11817 return;
11818 }
11819
11820 switch (info.info.global_conf.hash_func) {
11821 case RTE_ETH_HASH_FUNCTION_TOEPLITZ:
11822 printf("Hash function is Toeplitz\n");
11823 break;
11824 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR:
11825 printf("Hash function is Simple XOR\n");
11826 break;
11827 default:
11828 printf("Unknown hash function\n");
11829 break;
11830 }
11831
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] &
11836 (1ULL << offset)))
11837 continue;
11838 str = flowtype_to_str(i);
11839 if (!str)
11840 continue;
11841 printf("Symmetric hash is %s globally for flow type %s "
11842 "by port %d\n",
11843 ((info.info.global_conf.sym_hash_enable_mask[idx] &
11844 (1ULL << offset)) ? "enabled" : "disabled"), str,
11845 res->port_id);
11846 }
11847 }
11848
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,
11854 port_id, UINT16);
11855
11856 cmdline_parse_inst_t cmd_get_hash_global_config = {
11857 .f = cmd_get_hash_global_config_parsed,
11858 .data = NULL,
11859 .help_str = "get_hash_global_config <port_id>",
11860 .tokens = {
11861 (void *)&cmd_get_hash_global_config_all,
11862 (void *)&cmd_get_hash_global_config_port_id,
11863 NULL,
11864 },
11865 };
11866
11867 /* Set global config of hash function */
11868 struct cmd_set_hash_global_config_result {
11869 cmdline_fixed_string_t set_hash_global_config;
11870 portid_t port_id;
11871 cmdline_fixed_string_t hash_func;
11872 cmdline_fixed_string_t flow_type;
11873 cmdline_fixed_string_t enable;
11874 };
11875
11876 static void
11877 cmd_set_hash_global_config_parsed(void *parsed_result,
11878 __rte_unused struct cmdline *cl,
11879 __rte_unused void *data)
11880 {
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;
11884 int ret;
11885
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",
11889 res->port_id);
11890 return;
11891 }
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;
11903
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] |=
11910 (1ULL << offset);
11911 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
11912 RTE_ETH_FILTER_SET, &info);
11913 if (ret < 0)
11914 printf("Cannot set global hash configurations by port %d\n",
11915 res->port_id);
11916 else
11917 printf("Global hash configurations have been set "
11918 "succcessfully by port %d\n", res->port_id);
11919 }
11920
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,
11926 port_id, UINT16);
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,
11932 flow_type,
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");
11938
11939 cmdline_parse_inst_t cmd_set_hash_global_config = {
11940 .f = cmd_set_hash_global_config_parsed,
11941 .data = NULL,
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",
11947 .tokens = {
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,
11953 NULL,
11954 },
11955 };
11956
11957 /* Set hash input set */
11958 struct cmd_set_hash_input_set_result {
11959 cmdline_fixed_string_t set_hash_input_set;
11960 portid_t port_id;
11961 cmdline_fixed_string_t flow_type;
11962 cmdline_fixed_string_t inset_field;
11963 cmdline_fixed_string_t select;
11964 };
11965
11966 static enum rte_eth_input_set_field
11967 str2inset(char *string)
11968 {
11969 uint16_t i;
11970
11971 static const struct {
11972 char str[32];
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},
12006 };
12007
12008 for (i = 0; i < RTE_DIM(inset_table); i++) {
12009 if (!strcmp(string, inset_table[i].str))
12010 return inset_table[i].inset;
12011 }
12012
12013 return RTE_ETH_INPUT_SET_UNKNOWN;
12014 }
12015
12016 static void
12017 cmd_set_hash_input_set_parsed(void *parsed_result,
12018 __rte_unused struct cmdline *cl,
12019 __rte_unused void *data)
12020 {
12021 struct cmd_set_hash_input_set_result *res = parsed_result;
12022 struct rte_eth_hash_filter_info info;
12023
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);
12035 }
12036
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,
12042 port_id, UINT16);
12043 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
12044 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12045 flow_type, NULL);
12046 cmdline_parse_token_string_t cmd_set_hash_input_set_field =
12047 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
12048 inset_field,
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#"
12054 "fld-8th#none");
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");
12058
12059 cmdline_parse_inst_t cmd_set_hash_input_set = {
12060 .f = cmd_set_hash_input_set_parsed,
12061 .data = NULL,
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",
12070 .tokens = {
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,
12076 NULL,
12077 },
12078 };
12079
12080 /* Set flow director input set */
12081 struct cmd_set_fdir_input_set_result {
12082 cmdline_fixed_string_t set_fdir_input_set;
12083 portid_t port_id;
12084 cmdline_fixed_string_t flow_type;
12085 cmdline_fixed_string_t inset_field;
12086 cmdline_fixed_string_t select;
12087 };
12088
12089 static void
12090 cmd_set_fdir_input_set_parsed(void *parsed_result,
12091 __rte_unused struct cmdline *cl,
12092 __rte_unused void *data)
12093 {
12094 struct cmd_set_fdir_input_set_result *res = parsed_result;
12095 struct rte_eth_fdir_filter_info info;
12096
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);
12108 }
12109
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,
12115 port_id, UINT16);
12116 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type =
12117 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result,
12118 flow_type,
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,
12123 inset_field,
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");
12132
12133 cmdline_parse_inst_t cmd_set_fdir_input_set = {
12134 .f = cmd_set_fdir_input_set_parsed,
12135 .data = NULL,
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",
12144 .tokens = {
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,
12150 NULL,
12151 },
12152 };
12153
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;
12158 uint16_t port_num;
12159 struct ether_addr mc_addr;
12160 };
12161
12162 static void cmd_mcast_addr_parsed(void *parsed_result,
12163 __attribute__((unused)) struct cmdline *cl,
12164 __attribute__((unused)) void *data)
12165 {
12166 struct cmd_mcast_addr_result *res = parsed_result;
12167
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]);
12173 return;
12174 }
12175 if (strcmp(res->what, "add") == 0)
12176 mcast_addr_add(res->port_num, &res->mc_addr);
12177 else
12178 mcast_addr_remove(res->port_num, &res->mc_addr);
12179 }
12180
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,
12186 "add#remove");
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);
12191
12192 cmdline_parse_inst_t cmd_mcast_addr = {
12193 .f = cmd_mcast_addr_parsed,
12194 .data = (void *)0,
12195 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
12196 "Add/Remove multicast MAC address on port_id",
12197 .tokens = {
12198 (void *)&cmd_mcast_addr_cmd,
12199 (void *)&cmd_mcast_addr_what,
12200 (void *)&cmd_mcast_addr_portnum,
12201 (void *)&cmd_mcast_addr_addr,
12202 NULL,
12203 },
12204 };
12205
12206 /* l2 tunnel config
12207 * only support E-tag now.
12208 */
12209
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;
12215 portid_t id;
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;
12220 };
12221
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,
12225 port, "port");
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,
12229 config, "config");
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,
12233 all, "all");
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,
12237 id, UINT16);
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);
12254
12255 static enum rte_eth_tunnel_type
12256 str2fdir_l2_tunnel_type(char *string)
12257 {
12258 uint32_t i = 0;
12259
12260 static const struct {
12261 char str[32];
12262 enum rte_eth_tunnel_type type;
12263 } l2_tunnel_type_str[] = {
12264 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
12265 };
12266
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;
12270 }
12271 return RTE_TUNNEL_TYPE_NONE;
12272 }
12273
12274 /* ether type config for all ports */
12275 static void
12276 cmd_config_l2_tunnel_eth_type_all_parsed
12277 (void *parsed_result,
12278 __attribute__((unused)) struct cmdline *cl,
12279 __attribute__((unused)) void *data)
12280 {
12281 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
12282 struct rte_eth_l2_tunnel_conf entry;
12283 portid_t pid;
12284
12285 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12286 entry.ether_type = res->eth_type_val;
12287
12288 RTE_ETH_FOREACH_DEV(pid) {
12289 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
12290 }
12291 }
12292
12293 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
12294 .f = cmd_config_l2_tunnel_eth_type_all_parsed,
12295 .data = NULL,
12296 .help_str = "port config all l2-tunnel E-tag ether-type <value>",
12297 .tokens = {
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,
12305 NULL,
12306 },
12307 };
12308
12309 /* ether type config for a specific port */
12310 static void
12311 cmd_config_l2_tunnel_eth_type_specific_parsed(
12312 void *parsed_result,
12313 __attribute__((unused)) struct cmdline *cl,
12314 __attribute__((unused)) void *data)
12315 {
12316 struct cmd_config_l2_tunnel_eth_type_result *res =
12317 parsed_result;
12318 struct rte_eth_l2_tunnel_conf entry;
12319
12320 if (port_id_is_invalid(res->id, ENABLED_WARN))
12321 return;
12322
12323 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12324 entry.ether_type = res->eth_type_val;
12325
12326 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
12327 }
12328
12329 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
12330 .f = cmd_config_l2_tunnel_eth_type_specific_parsed,
12331 .data = NULL,
12332 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>",
12333 .tokens = {
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,
12341 NULL,
12342 },
12343 };
12344
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;
12350 portid_t id;
12351 cmdline_fixed_string_t l2_tunnel;
12352 cmdline_fixed_string_t l2_tunnel_type;
12353 cmdline_fixed_string_t en_dis;
12354 };
12355
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,
12359 port, "port");
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,
12363 config, "config");
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,
12367 all, "all");
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,
12371 id, UINT16);
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");
12384
12385 /* enable/disable l2 tunnel for all ports */
12386 static void
12387 cmd_config_l2_tunnel_en_dis_all_parsed(
12388 void *parsed_result,
12389 __attribute__((unused)) struct cmdline *cl,
12390 __attribute__((unused)) void *data)
12391 {
12392 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
12393 struct rte_eth_l2_tunnel_conf entry;
12394 portid_t pid;
12395 uint8_t en;
12396
12397 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12398
12399 if (!strcmp("enable", res->en_dis))
12400 en = 1;
12401 else
12402 en = 0;
12403
12404 RTE_ETH_FOREACH_DEV(pid) {
12405 rte_eth_dev_l2_tunnel_offload_set(pid,
12406 &entry,
12407 ETH_L2_TUNNEL_ENABLE_MASK,
12408 en);
12409 }
12410 }
12411
12412 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
12413 .f = cmd_config_l2_tunnel_en_dis_all_parsed,
12414 .data = NULL,
12415 .help_str = "port config all l2-tunnel E-tag enable|disable",
12416 .tokens = {
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,
12423 NULL,
12424 },
12425 };
12426
12427 /* enable/disable l2 tunnel for a port */
12428 static void
12429 cmd_config_l2_tunnel_en_dis_specific_parsed(
12430 void *parsed_result,
12431 __attribute__((unused)) struct cmdline *cl,
12432 __attribute__((unused)) void *data)
12433 {
12434 struct cmd_config_l2_tunnel_en_dis_result *res =
12435 parsed_result;
12436 struct rte_eth_l2_tunnel_conf entry;
12437
12438 if (port_id_is_invalid(res->id, ENABLED_WARN))
12439 return;
12440
12441 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
12442
12443 if (!strcmp("enable", res->en_dis))
12444 rte_eth_dev_l2_tunnel_offload_set(res->id,
12445 &entry,
12446 ETH_L2_TUNNEL_ENABLE_MASK,
12447 1);
12448 else
12449 rte_eth_dev_l2_tunnel_offload_set(res->id,
12450 &entry,
12451 ETH_L2_TUNNEL_ENABLE_MASK,
12452 0);
12453 }
12454
12455 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
12456 .f = cmd_config_l2_tunnel_en_dis_specific_parsed,
12457 .data = NULL,
12458 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable",
12459 .tokens = {
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,
12466 NULL,
12467 },
12468 };
12469
12470 /* E-tag configuration */
12471
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;
12492 portid_t port_id;
12493 cmdline_fixed_string_t vf;
12494 uint8_t vf_id;
12495 };
12496
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,
12501 e_tag, "E-tag");
12502 cmdline_parse_token_string_t cmd_config_e_tag_set =
12503 TOKEN_STRING_INITIALIZER
12504 (struct cmd_config_e_tag_result,
12505 set, "set");
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,
12521 filter, "filter");
12522 cmdline_parse_token_string_t cmd_config_e_tag_add =
12523 TOKEN_STRING_INITIALIZER
12524 (struct cmd_config_e_tag_result,
12525 add, "add");
12526 cmdline_parse_token_string_t cmd_config_e_tag_del =
12527 TOKEN_STRING_INITIALIZER
12528 (struct cmd_config_e_tag_result,
12529 del, "del");
12530 cmdline_parse_token_string_t cmd_config_e_tag_on =
12531 TOKEN_STRING_INITIALIZER
12532 (struct cmd_config_e_tag_result,
12533 on, "on");
12534 cmdline_parse_token_string_t cmd_config_e_tag_off =
12535 TOKEN_STRING_INITIALIZER
12536 (struct cmd_config_e_tag_result,
12537 off, "off");
12538 cmdline_parse_token_string_t cmd_config_e_tag_on_off =
12539 TOKEN_STRING_INITIALIZER
12540 (struct cmd_config_e_tag_result,
12541 on_off, "on#off");
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,
12569 port, "port");
12570 cmdline_parse_token_num_t cmd_config_e_tag_port_id =
12571 TOKEN_NUM_INITIALIZER
12572 (struct cmd_config_e_tag_result,
12573 port_id, UINT16);
12574 cmdline_parse_token_string_t cmd_config_e_tag_vf =
12575 TOKEN_STRING_INITIALIZER
12576 (struct cmd_config_e_tag_result,
12577 vf, "vf");
12578 cmdline_parse_token_num_t cmd_config_e_tag_vf_id =
12579 TOKEN_NUM_INITIALIZER
12580 (struct cmd_config_e_tag_result,
12581 vf_id, UINT8);
12582
12583 /* E-tag insertion configuration */
12584 static void
12585 cmd_config_e_tag_insertion_en_parsed(
12586 void *parsed_result,
12587 __attribute__((unused)) struct cmdline *cl,
12588 __attribute__((unused)) void *data)
12589 {
12590 struct cmd_config_e_tag_result *res =
12591 parsed_result;
12592 struct rte_eth_l2_tunnel_conf entry;
12593
12594 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12595 return;
12596
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,
12601 &entry,
12602 ETH_L2_TUNNEL_INSERTION_MASK,
12603 1);
12604 }
12605
12606 static void
12607 cmd_config_e_tag_insertion_dis_parsed(
12608 void *parsed_result,
12609 __attribute__((unused)) struct cmdline *cl,
12610 __attribute__((unused)) void *data)
12611 {
12612 struct cmd_config_e_tag_result *res =
12613 parsed_result;
12614 struct rte_eth_l2_tunnel_conf entry;
12615
12616 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12617 return;
12618
12619 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12620 entry.vf_id = res->vf_id;
12621
12622 rte_eth_dev_l2_tunnel_offload_set(res->port_id,
12623 &entry,
12624 ETH_L2_TUNNEL_INSERTION_MASK,
12625 0);
12626 }
12627
12628 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = {
12629 .f = cmd_config_e_tag_insertion_en_parsed,
12630 .data = NULL,
12631 .help_str = "E-tag ... : E-tag insertion enable",
12632 .tokens = {
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,
12643 NULL,
12644 },
12645 };
12646
12647 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = {
12648 .f = cmd_config_e_tag_insertion_dis_parsed,
12649 .data = NULL,
12650 .help_str = "E-tag ... : E-tag insertion disable",
12651 .tokens = {
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,
12660 NULL,
12661 },
12662 };
12663
12664 /* E-tag stripping configuration */
12665 static void
12666 cmd_config_e_tag_stripping_parsed(
12667 void *parsed_result,
12668 __attribute__((unused)) struct cmdline *cl,
12669 __attribute__((unused)) void *data)
12670 {
12671 struct cmd_config_e_tag_result *res =
12672 parsed_result;
12673 struct rte_eth_l2_tunnel_conf entry;
12674
12675 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12676 return;
12677
12678 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12679
12680 if (!strcmp(res->on_off, "on"))
12681 rte_eth_dev_l2_tunnel_offload_set
12682 (res->port_id,
12683 &entry,
12684 ETH_L2_TUNNEL_STRIPPING_MASK,
12685 1);
12686 else
12687 rte_eth_dev_l2_tunnel_offload_set
12688 (res->port_id,
12689 &entry,
12690 ETH_L2_TUNNEL_STRIPPING_MASK,
12691 0);
12692 }
12693
12694 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = {
12695 .f = cmd_config_e_tag_stripping_parsed,
12696 .data = NULL,
12697 .help_str = "E-tag ... : E-tag stripping enable/disable",
12698 .tokens = {
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,
12705 NULL,
12706 },
12707 };
12708
12709 /* E-tag forwarding configuration */
12710 static void
12711 cmd_config_e_tag_forwarding_parsed(
12712 void *parsed_result,
12713 __attribute__((unused)) struct cmdline *cl,
12714 __attribute__((unused)) void *data)
12715 {
12716 struct cmd_config_e_tag_result *res = parsed_result;
12717 struct rte_eth_l2_tunnel_conf entry;
12718
12719 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12720 return;
12721
12722 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12723
12724 if (!strcmp(res->on_off, "on"))
12725 rte_eth_dev_l2_tunnel_offload_set
12726 (res->port_id,
12727 &entry,
12728 ETH_L2_TUNNEL_FORWARDING_MASK,
12729 1);
12730 else
12731 rte_eth_dev_l2_tunnel_offload_set
12732 (res->port_id,
12733 &entry,
12734 ETH_L2_TUNNEL_FORWARDING_MASK,
12735 0);
12736 }
12737
12738 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = {
12739 .f = cmd_config_e_tag_forwarding_parsed,
12740 .data = NULL,
12741 .help_str = "E-tag ... : E-tag forwarding enable/disable",
12742 .tokens = {
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,
12749 NULL,
12750 },
12751 };
12752
12753 /* E-tag filter configuration */
12754 static void
12755 cmd_config_e_tag_filter_add_parsed(
12756 void *parsed_result,
12757 __attribute__((unused)) struct cmdline *cl,
12758 __attribute__((unused)) void *data)
12759 {
12760 struct cmd_config_e_tag_result *res = parsed_result;
12761 struct rte_eth_l2_tunnel_conf entry;
12762 int ret = 0;
12763
12764 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12765 return;
12766
12767 if (res->e_tag_id_val > 0x3fff) {
12768 printf("e-tag-id must be equal or less than 0x3fff.\n");
12769 return;
12770 }
12771
12772 ret = rte_eth_dev_filter_supported(res->port_id,
12773 RTE_ETH_FILTER_L2_TUNNEL);
12774 if (ret < 0) {
12775 printf("E-tag filter is not supported on port %u.\n",
12776 res->port_id);
12777 return;
12778 }
12779
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;
12783
12784 ret = rte_eth_dev_filter_ctrl(res->port_id,
12785 RTE_ETH_FILTER_L2_TUNNEL,
12786 RTE_ETH_FILTER_ADD,
12787 &entry);
12788 if (ret < 0)
12789 printf("E-tag filter programming error: (%s)\n",
12790 strerror(-ret));
12791 }
12792
12793 cmdline_parse_inst_t cmd_config_e_tag_filter_add = {
12794 .f = cmd_config_e_tag_filter_add_parsed,
12795 .data = NULL,
12796 .help_str = "E-tag ... : E-tag filter add",
12797 .tokens = {
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,
12808 NULL,
12809 },
12810 };
12811
12812 static void
12813 cmd_config_e_tag_filter_del_parsed(
12814 void *parsed_result,
12815 __attribute__((unused)) struct cmdline *cl,
12816 __attribute__((unused)) void *data)
12817 {
12818 struct cmd_config_e_tag_result *res = parsed_result;
12819 struct rte_eth_l2_tunnel_conf entry;
12820 int ret = 0;
12821
12822 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12823 return;
12824
12825 if (res->e_tag_id_val > 0x3fff) {
12826 printf("e-tag-id must be less than 0x3fff.\n");
12827 return;
12828 }
12829
12830 ret = rte_eth_dev_filter_supported(res->port_id,
12831 RTE_ETH_FILTER_L2_TUNNEL);
12832 if (ret < 0) {
12833 printf("E-tag filter is not supported on port %u.\n",
12834 res->port_id);
12835 return;
12836 }
12837
12838 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG;
12839 entry.tunnel_id = res->e_tag_id_val;
12840
12841 ret = rte_eth_dev_filter_ctrl(res->port_id,
12842 RTE_ETH_FILTER_L2_TUNNEL,
12843 RTE_ETH_FILTER_DELETE,
12844 &entry);
12845 if (ret < 0)
12846 printf("E-tag filter programming error: (%s)\n",
12847 strerror(-ret));
12848 }
12849
12850 cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
12851 .f = cmd_config_e_tag_filter_del_parsed,
12852 .data = NULL,
12853 .help_str = "E-tag ... : E-tag filter delete",
12854 .tokens = {
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,
12863 NULL,
12864 },
12865 };
12866
12867 /* vf vlan anti spoof configuration */
12868
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;
12875 portid_t port_id;
12876 uint32_t vf_id;
12877 cmdline_fixed_string_t on_off;
12878 };
12879
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,
12884 set, "set");
12885 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
12886 TOKEN_STRING_INITIALIZER
12887 (struct cmd_vf_vlan_anti_spoof_result,
12888 vf, "vf");
12889 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
12890 TOKEN_STRING_INITIALIZER
12891 (struct cmd_vf_vlan_anti_spoof_result,
12892 vlan, "vlan");
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,
12900 port_id, UINT16);
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,
12904 vf_id, UINT32);
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,
12908 on_off, "on#off");
12909
12910 static void
12911 cmd_set_vf_vlan_anti_spoof_parsed(
12912 void *parsed_result,
12913 __attribute__((unused)) struct cmdline *cl,
12914 __attribute__((unused)) void *data)
12915 {
12916 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
12917 int ret = -ENOTSUP;
12918
12919 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
12920
12921 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12922 return;
12923
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);
12928 #endif
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);
12933 #endif
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);
12938 #endif
12939
12940 switch (ret) {
12941 case 0:
12942 break;
12943 case -EINVAL:
12944 printf("invalid vf_id %d\n", res->vf_id);
12945 break;
12946 case -ENODEV:
12947 printf("invalid port_id %d\n", res->port_id);
12948 break;
12949 case -ENOTSUP:
12950 printf("function not implemented\n");
12951 break;
12952 default:
12953 printf("programming error: (%s)\n", strerror(-ret));
12954 }
12955 }
12956
12957 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
12958 .f = cmd_set_vf_vlan_anti_spoof_parsed,
12959 .data = NULL,
12960 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
12961 .tokens = {
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,
12969 NULL,
12970 },
12971 };
12972
12973 /* vf mac anti spoof configuration */
12974
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;
12981 portid_t port_id;
12982 uint32_t vf_id;
12983 cmdline_fixed_string_t on_off;
12984 };
12985
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,
12990 set, "set");
12991 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
12992 TOKEN_STRING_INITIALIZER
12993 (struct cmd_vf_mac_anti_spoof_result,
12994 vf, "vf");
12995 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
12996 TOKEN_STRING_INITIALIZER
12997 (struct cmd_vf_mac_anti_spoof_result,
12998 mac, "mac");
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,
13006 port_id, UINT16);
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,
13010 vf_id, UINT32);
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,
13014 on_off, "on#off");
13015
13016 static void
13017 cmd_set_vf_mac_anti_spoof_parsed(
13018 void *parsed_result,
13019 __attribute__((unused)) struct cmdline *cl,
13020 __attribute__((unused)) void *data)
13021 {
13022 struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
13023 int ret = -ENOTSUP;
13024
13025 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13026
13027 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13028 return;
13029
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);
13034 #endif
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);
13039 #endif
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);
13044 #endif
13045
13046 switch (ret) {
13047 case 0:
13048 break;
13049 case -EINVAL:
13050 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13051 break;
13052 case -ENODEV:
13053 printf("invalid port_id %d\n", res->port_id);
13054 break;
13055 case -ENOTSUP:
13056 printf("function not implemented\n");
13057 break;
13058 default:
13059 printf("programming error: (%s)\n", strerror(-ret));
13060 }
13061 }
13062
13063 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
13064 .f = cmd_set_vf_mac_anti_spoof_parsed,
13065 .data = NULL,
13066 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
13067 .tokens = {
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,
13075 NULL,
13076 },
13077 };
13078
13079 /* vf vlan strip queue configuration */
13080
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;
13087 portid_t port_id;
13088 uint16_t vf_id;
13089 cmdline_fixed_string_t on_off;
13090 };
13091
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,
13096 set, "set");
13097 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
13098 TOKEN_STRING_INITIALIZER
13099 (struct cmd_vf_vlan_stripq_result,
13100 vf, "vf");
13101 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
13102 TOKEN_STRING_INITIALIZER
13103 (struct cmd_vf_vlan_stripq_result,
13104 vlan, "vlan");
13105 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
13106 TOKEN_STRING_INITIALIZER
13107 (struct cmd_vf_vlan_stripq_result,
13108 stripq, "stripq");
13109 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
13110 TOKEN_NUM_INITIALIZER
13111 (struct cmd_vf_vlan_stripq_result,
13112 port_id, UINT16);
13113 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
13114 TOKEN_NUM_INITIALIZER
13115 (struct cmd_vf_vlan_stripq_result,
13116 vf_id, UINT16);
13117 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
13118 TOKEN_STRING_INITIALIZER
13119 (struct cmd_vf_vlan_stripq_result,
13120 on_off, "on#off");
13121
13122 static void
13123 cmd_set_vf_vlan_stripq_parsed(
13124 void *parsed_result,
13125 __attribute__((unused)) struct cmdline *cl,
13126 __attribute__((unused)) void *data)
13127 {
13128 struct cmd_vf_vlan_stripq_result *res = parsed_result;
13129 int ret = -ENOTSUP;
13130
13131 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13132
13133 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13134 return;
13135
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);
13140 #endif
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);
13145 #endif
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);
13150 #endif
13151
13152 switch (ret) {
13153 case 0:
13154 break;
13155 case -EINVAL:
13156 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13157 break;
13158 case -ENODEV:
13159 printf("invalid port_id %d\n", res->port_id);
13160 break;
13161 case -ENOTSUP:
13162 printf("function not implemented\n");
13163 break;
13164 default:
13165 printf("programming error: (%s)\n", strerror(-ret));
13166 }
13167 }
13168
13169 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
13170 .f = cmd_set_vf_vlan_stripq_parsed,
13171 .data = NULL,
13172 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
13173 .tokens = {
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,
13181 NULL,
13182 },
13183 };
13184
13185 /* vf vlan insert configuration */
13186
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;
13193 portid_t port_id;
13194 uint16_t vf_id;
13195 uint16_t vlan_id;
13196 };
13197
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,
13202 set, "set");
13203 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
13204 TOKEN_STRING_INITIALIZER
13205 (struct cmd_vf_vlan_insert_result,
13206 vf, "vf");
13207 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
13208 TOKEN_STRING_INITIALIZER
13209 (struct cmd_vf_vlan_insert_result,
13210 vlan, "vlan");
13211 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
13212 TOKEN_STRING_INITIALIZER
13213 (struct cmd_vf_vlan_insert_result,
13214 insert, "insert");
13215 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
13216 TOKEN_NUM_INITIALIZER
13217 (struct cmd_vf_vlan_insert_result,
13218 port_id, UINT16);
13219 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
13220 TOKEN_NUM_INITIALIZER
13221 (struct cmd_vf_vlan_insert_result,
13222 vf_id, UINT16);
13223 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
13224 TOKEN_NUM_INITIALIZER
13225 (struct cmd_vf_vlan_insert_result,
13226 vlan_id, UINT16);
13227
13228 static void
13229 cmd_set_vf_vlan_insert_parsed(
13230 void *parsed_result,
13231 __attribute__((unused)) struct cmdline *cl,
13232 __attribute__((unused)) void *data)
13233 {
13234 struct cmd_vf_vlan_insert_result *res = parsed_result;
13235 int ret = -ENOTSUP;
13236
13237 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13238 return;
13239
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,
13243 res->vlan_id);
13244 #endif
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,
13248 res->vlan_id);
13249 #endif
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,
13253 res->vlan_id);
13254 #endif
13255
13256 switch (ret) {
13257 case 0:
13258 break;
13259 case -EINVAL:
13260 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id);
13261 break;
13262 case -ENODEV:
13263 printf("invalid port_id %d\n", res->port_id);
13264 break;
13265 case -ENOTSUP:
13266 printf("function not implemented\n");
13267 break;
13268 default:
13269 printf("programming error: (%s)\n", strerror(-ret));
13270 }
13271 }
13272
13273 cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
13274 .f = cmd_set_vf_vlan_insert_parsed,
13275 .data = NULL,
13276 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
13277 .tokens = {
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,
13285 NULL,
13286 },
13287 };
13288
13289 /* tx loopback configuration */
13290
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;
13296 portid_t port_id;
13297 cmdline_fixed_string_t on_off;
13298 };
13299
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,
13304 set, "set");
13305 cmdline_parse_token_string_t cmd_tx_loopback_tx =
13306 TOKEN_STRING_INITIALIZER
13307 (struct cmd_tx_loopback_result,
13308 tx, "tx");
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,
13316 port_id, UINT16);
13317 cmdline_parse_token_string_t cmd_tx_loopback_on_off =
13318 TOKEN_STRING_INITIALIZER
13319 (struct cmd_tx_loopback_result,
13320 on_off, "on#off");
13321
13322 static void
13323 cmd_set_tx_loopback_parsed(
13324 void *parsed_result,
13325 __attribute__((unused)) struct cmdline *cl,
13326 __attribute__((unused)) void *data)
13327 {
13328 struct cmd_tx_loopback_result *res = parsed_result;
13329 int ret = -ENOTSUP;
13330
13331 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
13332
13333 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13334 return;
13335
13336 #ifdef RTE_LIBRTE_IXGBE_PMD
13337 if (ret == -ENOTSUP)
13338 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
13339 #endif
13340 #ifdef RTE_LIBRTE_I40E_PMD
13341 if (ret == -ENOTSUP)
13342 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
13343 #endif
13344 #ifdef RTE_LIBRTE_BNXT_PMD
13345 if (ret == -ENOTSUP)
13346 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
13347 #endif
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);
13351 #endif
13352
13353 switch (ret) {
13354 case 0:
13355 break;
13356 case -EINVAL:
13357 printf("invalid is_on %d\n", is_on);
13358 break;
13359 case -ENODEV:
13360 printf("invalid port_id %d\n", res->port_id);
13361 break;
13362 case -ENOTSUP:
13363 printf("function not implemented\n");
13364 break;
13365 default:
13366 printf("programming error: (%s)\n", strerror(-ret));
13367 }
13368 }
13369
13370 cmdline_parse_inst_t cmd_set_tx_loopback = {
13371 .f = cmd_set_tx_loopback_parsed,
13372 .data = NULL,
13373 .help_str = "set tx loopback <port_id> on|off",
13374 .tokens = {
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,
13380 NULL,
13381 },
13382 };
13383
13384 /* all queues drop enable configuration */
13385
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;
13392 portid_t port_id;
13393 cmdline_fixed_string_t on_off;
13394 };
13395
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,
13400 set, "set");
13401 cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
13402 TOKEN_STRING_INITIALIZER
13403 (struct cmd_all_queues_drop_en_result,
13404 all, "all");
13405 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
13406 TOKEN_STRING_INITIALIZER
13407 (struct cmd_all_queues_drop_en_result,
13408 queues, "queues");
13409 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
13410 TOKEN_STRING_INITIALIZER
13411 (struct cmd_all_queues_drop_en_result,
13412 drop, "drop");
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,
13416 port_id, UINT16);
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,
13420 on_off, "on#off");
13421
13422 static void
13423 cmd_set_all_queues_drop_en_parsed(
13424 void *parsed_result,
13425 __attribute__((unused)) struct cmdline *cl,
13426 __attribute__((unused)) void *data)
13427 {
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;
13431
13432 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13433 return;
13434
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);
13438 #endif
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);
13442 #endif
13443 switch (ret) {
13444 case 0:
13445 break;
13446 case -EINVAL:
13447 printf("invalid is_on %d\n", is_on);
13448 break;
13449 case -ENODEV:
13450 printf("invalid port_id %d\n", res->port_id);
13451 break;
13452 case -ENOTSUP:
13453 printf("function not implemented\n");
13454 break;
13455 default:
13456 printf("programming error: (%s)\n", strerror(-ret));
13457 }
13458 }
13459
13460 cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
13461 .f = cmd_set_all_queues_drop_en_parsed,
13462 .data = NULL,
13463 .help_str = "set all queues drop <port_id> on|off",
13464 .tokens = {
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,
13471 NULL,
13472 },
13473 };
13474
13475 /* vf split drop enable configuration */
13476
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;
13483 portid_t port_id;
13484 uint16_t vf_id;
13485 cmdline_fixed_string_t on_off;
13486 };
13487
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,
13492 set, "set");
13493 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
13494 TOKEN_STRING_INITIALIZER
13495 (struct cmd_vf_split_drop_en_result,
13496 vf, "vf");
13497 cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
13498 TOKEN_STRING_INITIALIZER
13499 (struct cmd_vf_split_drop_en_result,
13500 split, "split");
13501 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
13502 TOKEN_STRING_INITIALIZER
13503 (struct cmd_vf_split_drop_en_result,
13504 drop, "drop");
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,
13508 port_id, UINT16);
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,
13512 vf_id, UINT16);
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,
13516 on_off, "on#off");
13517
13518 static void
13519 cmd_set_vf_split_drop_en_parsed(
13520 void *parsed_result,
13521 __attribute__((unused)) struct cmdline *cl,
13522 __attribute__((unused)) void *data)
13523 {
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;
13527
13528 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13529 return;
13530
13531 #ifdef RTE_LIBRTE_IXGBE_PMD
13532 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
13533 is_on);
13534 #endif
13535 switch (ret) {
13536 case 0:
13537 break;
13538 case -EINVAL:
13539 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
13540 break;
13541 case -ENODEV:
13542 printf("invalid port_id %d\n", res->port_id);
13543 break;
13544 case -ENOTSUP:
13545 printf("not supported on port %d\n", res->port_id);
13546 break;
13547 default:
13548 printf("programming error: (%s)\n", strerror(-ret));
13549 }
13550 }
13551
13552 cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
13553 .f = cmd_set_vf_split_drop_en_parsed,
13554 .data = NULL,
13555 .help_str = "set vf split drop <port_id> <vf_id> on|off",
13556 .tokens = {
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,
13564 NULL,
13565 },
13566 };
13567
13568 /* vf mac address configuration */
13569
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;
13576 portid_t port_id;
13577 uint16_t vf_id;
13578 struct ether_addr mac_addr;
13579
13580 };
13581
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,
13586 set, "set");
13587 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
13588 TOKEN_STRING_INITIALIZER
13589 (struct cmd_set_vf_mac_addr_result,
13590 vf, "vf");
13591 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
13592 TOKEN_STRING_INITIALIZER
13593 (struct cmd_set_vf_mac_addr_result,
13594 mac, "mac");
13595 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
13596 TOKEN_STRING_INITIALIZER
13597 (struct cmd_set_vf_mac_addr_result,
13598 addr, "addr");
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,
13602 port_id, UINT16);
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,
13606 vf_id, UINT16);
13607 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
13608 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
13609 mac_addr);
13610
13611 static void
13612 cmd_set_vf_mac_addr_parsed(
13613 void *parsed_result,
13614 __attribute__((unused)) struct cmdline *cl,
13615 __attribute__((unused)) void *data)
13616 {
13617 struct cmd_set_vf_mac_addr_result *res = parsed_result;
13618 int ret = -ENOTSUP;
13619
13620 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13621 return;
13622
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,
13626 &res->mac_addr);
13627 #endif
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,
13631 &res->mac_addr);
13632 #endif
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,
13636 &res->mac_addr);
13637 #endif
13638
13639 switch (ret) {
13640 case 0:
13641 break;
13642 case -EINVAL:
13643 printf("invalid vf_id %d or mac_addr\n", res->vf_id);
13644 break;
13645 case -ENODEV:
13646 printf("invalid port_id %d\n", res->port_id);
13647 break;
13648 case -ENOTSUP:
13649 printf("function not implemented\n");
13650 break;
13651 default:
13652 printf("programming error: (%s)\n", strerror(-ret));
13653 }
13654 }
13655
13656 cmdline_parse_inst_t cmd_set_vf_mac_addr = {
13657 .f = cmd_set_vf_mac_addr_parsed,
13658 .data = NULL,
13659 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
13660 .tokens = {
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,
13668 NULL,
13669 },
13670 };
13671
13672 /* MACsec configuration */
13673
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;
13679 portid_t port_id;
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;
13685 };
13686
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,
13691 set, "set");
13692 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
13693 TOKEN_STRING_INITIALIZER
13694 (struct cmd_macsec_offload_on_result,
13695 macsec, "macsec");
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,
13703 port_id, UINT16);
13704 cmdline_parse_token_string_t cmd_macsec_offload_on_on =
13705 TOKEN_STRING_INITIALIZER
13706 (struct cmd_macsec_offload_on_result,
13707 on, "on");
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");
13724
13725 static void
13726 cmd_set_macsec_offload_on_parsed(
13727 void *parsed_result,
13728 __attribute__((unused)) struct cmdline *cl,
13729 __attribute__((unused)) void *data)
13730 {
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;
13737
13738 if (port_id_is_invalid(port_id, ENABLED_WARN))
13739 return;
13740 if (!port_is_stopped(port_id)) {
13741 printf("Please stop port %d first\n", port_id);
13742 return;
13743 }
13744
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);
13749 #endif
13750 }
13751 RTE_SET_USED(en);
13752 RTE_SET_USED(rp);
13753
13754 switch (ret) {
13755 case 0:
13756 ports[port_id].dev_conf.txmode.offloads |=
13757 DEV_TX_OFFLOAD_MACSEC_INSERT;
13758 cmd_reconfig_device_queue(port_id, 1, 1);
13759 break;
13760 case -ENODEV:
13761 printf("invalid port_id %d\n", port_id);
13762 break;
13763 case -ENOTSUP:
13764 printf("not supported on port %d\n", port_id);
13765 break;
13766 default:
13767 printf("programming error: (%s)\n", strerror(-ret));
13768 }
13769 }
13770
13771 cmdline_parse_inst_t cmd_set_macsec_offload_on = {
13772 .f = cmd_set_macsec_offload_on_parsed,
13773 .data = NULL,
13774 .help_str = "set macsec offload <port_id> on "
13775 "encrypt on|off replay-protect on|off",
13776 .tokens = {
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,
13786 NULL,
13787 },
13788 };
13789
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;
13795 portid_t port_id;
13796 cmdline_fixed_string_t off;
13797 };
13798
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,
13803 set, "set");
13804 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec =
13805 TOKEN_STRING_INITIALIZER
13806 (struct cmd_macsec_offload_off_result,
13807 macsec, "macsec");
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,
13815 port_id, UINT16);
13816 cmdline_parse_token_string_t cmd_macsec_offload_off_off =
13817 TOKEN_STRING_INITIALIZER
13818 (struct cmd_macsec_offload_off_result,
13819 off, "off");
13820
13821 static void
13822 cmd_set_macsec_offload_off_parsed(
13823 void *parsed_result,
13824 __attribute__((unused)) struct cmdline *cl,
13825 __attribute__((unused)) void *data)
13826 {
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;
13831
13832 if (port_id_is_invalid(port_id, ENABLED_WARN))
13833 return;
13834 if (!port_is_stopped(port_id)) {
13835 printf("Please stop port %d first\n", port_id);
13836 return;
13837 }
13838
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);
13843 #endif
13844 }
13845 switch (ret) {
13846 case 0:
13847 ports[port_id].dev_conf.txmode.offloads &=
13848 ~DEV_TX_OFFLOAD_MACSEC_INSERT;
13849 cmd_reconfig_device_queue(port_id, 1, 1);
13850 break;
13851 case -ENODEV:
13852 printf("invalid port_id %d\n", port_id);
13853 break;
13854 case -ENOTSUP:
13855 printf("not supported on port %d\n", port_id);
13856 break;
13857 default:
13858 printf("programming error: (%s)\n", strerror(-ret));
13859 }
13860 }
13861
13862 cmdline_parse_inst_t cmd_set_macsec_offload_off = {
13863 .f = cmd_set_macsec_offload_off_parsed,
13864 .data = NULL,
13865 .help_str = "set macsec offload <port_id> off",
13866 .tokens = {
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,
13872 NULL,
13873 },
13874 };
13875
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;
13882 portid_t port_id;
13883 struct ether_addr mac;
13884 uint16_t pi;
13885 };
13886
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,
13891 set, "set");
13892 cmdline_parse_token_string_t cmd_macsec_sc_macsec =
13893 TOKEN_STRING_INITIALIZER
13894 (struct cmd_macsec_sc_result,
13895 macsec, "macsec");
13896 cmdline_parse_token_string_t cmd_macsec_sc_sc =
13897 TOKEN_STRING_INITIALIZER
13898 (struct cmd_macsec_sc_result,
13899 sc, "sc");
13900 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx =
13901 TOKEN_STRING_INITIALIZER
13902 (struct cmd_macsec_sc_result,
13903 tx_rx, "tx#rx");
13904 cmdline_parse_token_num_t cmd_macsec_sc_port_id =
13905 TOKEN_NUM_INITIALIZER
13906 (struct cmd_macsec_sc_result,
13907 port_id, UINT16);
13908 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac =
13909 TOKEN_ETHERADDR_INITIALIZER
13910 (struct cmd_macsec_sc_result,
13911 mac);
13912 cmdline_parse_token_num_t cmd_macsec_sc_pi =
13913 TOKEN_NUM_INITIALIZER
13914 (struct cmd_macsec_sc_result,
13915 pi, UINT16);
13916
13917 static void
13918 cmd_set_macsec_sc_parsed(
13919 void *parsed_result,
13920 __attribute__((unused)) struct cmdline *cl,
13921 __attribute__((unused)) void *data)
13922 {
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;
13926
13927 #ifdef RTE_LIBRTE_IXGBE_PMD
13928 ret = is_tx ?
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);
13933 #endif
13934 RTE_SET_USED(is_tx);
13935
13936 switch (ret) {
13937 case 0:
13938 break;
13939 case -ENODEV:
13940 printf("invalid port_id %d\n", res->port_id);
13941 break;
13942 case -ENOTSUP:
13943 printf("not supported on port %d\n", res->port_id);
13944 break;
13945 default:
13946 printf("programming error: (%s)\n", strerror(-ret));
13947 }
13948 }
13949
13950 cmdline_parse_inst_t cmd_set_macsec_sc = {
13951 .f = cmd_set_macsec_sc_parsed,
13952 .data = NULL,
13953 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>",
13954 .tokens = {
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,
13962 NULL,
13963 },
13964 };
13965
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;
13972 portid_t port_id;
13973 uint8_t idx;
13974 uint8_t an;
13975 uint32_t pn;
13976 cmdline_fixed_string_t key;
13977 };
13978
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,
13983 set, "set");
13984 cmdline_parse_token_string_t cmd_macsec_sa_macsec =
13985 TOKEN_STRING_INITIALIZER
13986 (struct cmd_macsec_sa_result,
13987 macsec, "macsec");
13988 cmdline_parse_token_string_t cmd_macsec_sa_sa =
13989 TOKEN_STRING_INITIALIZER
13990 (struct cmd_macsec_sa_result,
13991 sa, "sa");
13992 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx =
13993 TOKEN_STRING_INITIALIZER
13994 (struct cmd_macsec_sa_result,
13995 tx_rx, "tx#rx");
13996 cmdline_parse_token_num_t cmd_macsec_sa_port_id =
13997 TOKEN_NUM_INITIALIZER
13998 (struct cmd_macsec_sa_result,
13999 port_id, UINT16);
14000 cmdline_parse_token_num_t cmd_macsec_sa_idx =
14001 TOKEN_NUM_INITIALIZER
14002 (struct cmd_macsec_sa_result,
14003 idx, UINT8);
14004 cmdline_parse_token_num_t cmd_macsec_sa_an =
14005 TOKEN_NUM_INITIALIZER
14006 (struct cmd_macsec_sa_result,
14007 an, UINT8);
14008 cmdline_parse_token_num_t cmd_macsec_sa_pn =
14009 TOKEN_NUM_INITIALIZER
14010 (struct cmd_macsec_sa_result,
14011 pn, UINT32);
14012 cmdline_parse_token_string_t cmd_macsec_sa_key =
14013 TOKEN_STRING_INITIALIZER
14014 (struct cmd_macsec_sa_result,
14015 key, NULL);
14016
14017 static void
14018 cmd_set_macsec_sa_parsed(
14019 void *parsed_result,
14020 __attribute__((unused)) struct cmdline *cl,
14021 __attribute__((unused)) void *data)
14022 {
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 };
14027 uint8_t xdgt0;
14028 uint8_t xdgt1;
14029 int key_len;
14030 int i;
14031
14032 key_len = strlen(res->key) / 2;
14033 if (key_len > 16)
14034 key_len = 16;
14035
14036 for (i = 0; i < key_len; i++) {
14037 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
14038 if (xdgt0 == 0xFF)
14039 return;
14040 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
14041 if (xdgt1 == 0xFF)
14042 return;
14043 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
14044 }
14045
14046 #ifdef RTE_LIBRTE_IXGBE_PMD
14047 ret = is_tx ?
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);
14052 #endif
14053 RTE_SET_USED(is_tx);
14054 RTE_SET_USED(key);
14055
14056 switch (ret) {
14057 case 0:
14058 break;
14059 case -EINVAL:
14060 printf("invalid idx %d or an %d\n", res->idx, res->an);
14061 break;
14062 case -ENODEV:
14063 printf("invalid port_id %d\n", res->port_id);
14064 break;
14065 case -ENOTSUP:
14066 printf("not supported on port %d\n", res->port_id);
14067 break;
14068 default:
14069 printf("programming error: (%s)\n", strerror(-ret));
14070 }
14071 }
14072
14073 cmdline_parse_inst_t cmd_set_macsec_sa = {
14074 .f = cmd_set_macsec_sa_parsed,
14075 .data = NULL,
14076 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>",
14077 .tokens = {
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,
14087 NULL,
14088 },
14089 };
14090
14091 /* VF unicast promiscuous mode configuration */
14092
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;
14098 portid_t port_id;
14099 uint32_t vf_id;
14100 cmdline_fixed_string_t on_off;
14101 };
14102
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,
14107 set, "set");
14108 cmdline_parse_token_string_t cmd_vf_promisc_vf =
14109 TOKEN_STRING_INITIALIZER
14110 (struct cmd_vf_promisc_result,
14111 vf, "vf");
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,
14119 port_id, UINT16);
14120 cmdline_parse_token_num_t cmd_vf_promisc_vf_id =
14121 TOKEN_NUM_INITIALIZER
14122 (struct cmd_vf_promisc_result,
14123 vf_id, UINT32);
14124 cmdline_parse_token_string_t cmd_vf_promisc_on_off =
14125 TOKEN_STRING_INITIALIZER
14126 (struct cmd_vf_promisc_result,
14127 on_off, "on#off");
14128
14129 static void
14130 cmd_set_vf_promisc_parsed(
14131 void *parsed_result,
14132 __attribute__((unused)) struct cmdline *cl,
14133 __attribute__((unused)) void *data)
14134 {
14135 struct cmd_vf_promisc_result *res = parsed_result;
14136 int ret = -ENOTSUP;
14137
14138 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14139
14140 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14141 return;
14142
14143 #ifdef RTE_LIBRTE_I40E_PMD
14144 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id,
14145 res->vf_id, is_on);
14146 #endif
14147
14148 switch (ret) {
14149 case 0:
14150 break;
14151 case -EINVAL:
14152 printf("invalid vf_id %d\n", res->vf_id);
14153 break;
14154 case -ENODEV:
14155 printf("invalid port_id %d\n", res->port_id);
14156 break;
14157 case -ENOTSUP:
14158 printf("function not implemented\n");
14159 break;
14160 default:
14161 printf("programming error: (%s)\n", strerror(-ret));
14162 }
14163 }
14164
14165 cmdline_parse_inst_t cmd_set_vf_promisc = {
14166 .f = cmd_set_vf_promisc_parsed,
14167 .data = NULL,
14168 .help_str = "set vf promisc <port_id> <vf_id> on|off: "
14169 "Set unicast promiscuous mode for a VF from the PF",
14170 .tokens = {
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,
14177 NULL,
14178 },
14179 };
14180
14181 /* VF multicast promiscuous mode configuration */
14182
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;
14188 portid_t port_id;
14189 uint32_t vf_id;
14190 cmdline_fixed_string_t on_off;
14191 };
14192
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,
14197 set, "set");
14198 cmdline_parse_token_string_t cmd_vf_allmulti_vf =
14199 TOKEN_STRING_INITIALIZER
14200 (struct cmd_vf_allmulti_result,
14201 vf, "vf");
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,
14209 port_id, UINT16);
14210 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id =
14211 TOKEN_NUM_INITIALIZER
14212 (struct cmd_vf_allmulti_result,
14213 vf_id, UINT32);
14214 cmdline_parse_token_string_t cmd_vf_allmulti_on_off =
14215 TOKEN_STRING_INITIALIZER
14216 (struct cmd_vf_allmulti_result,
14217 on_off, "on#off");
14218
14219 static void
14220 cmd_set_vf_allmulti_parsed(
14221 void *parsed_result,
14222 __attribute__((unused)) struct cmdline *cl,
14223 __attribute__((unused)) void *data)
14224 {
14225 struct cmd_vf_allmulti_result *res = parsed_result;
14226 int ret = -ENOTSUP;
14227
14228 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14229
14230 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14231 return;
14232
14233 #ifdef RTE_LIBRTE_I40E_PMD
14234 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id,
14235 res->vf_id, is_on);
14236 #endif
14237
14238 switch (ret) {
14239 case 0:
14240 break;
14241 case -EINVAL:
14242 printf("invalid vf_id %d\n", res->vf_id);
14243 break;
14244 case -ENODEV:
14245 printf("invalid port_id %d\n", res->port_id);
14246 break;
14247 case -ENOTSUP:
14248 printf("function not implemented\n");
14249 break;
14250 default:
14251 printf("programming error: (%s)\n", strerror(-ret));
14252 }
14253 }
14254
14255 cmdline_parse_inst_t cmd_set_vf_allmulti = {
14256 .f = cmd_set_vf_allmulti_parsed,
14257 .data = NULL,
14258 .help_str = "set vf allmulti <port_id> <vf_id> on|off: "
14259 "Set multicast promiscuous mode for a VF from the PF",
14260 .tokens = {
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,
14267 NULL,
14268 },
14269 };
14270
14271 /* vf broadcast mode configuration */
14272
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;
14278 portid_t port_id;
14279 uint16_t vf_id;
14280 cmdline_fixed_string_t on_off;
14281 };
14282
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,
14287 set, "set");
14288 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf =
14289 TOKEN_STRING_INITIALIZER
14290 (struct cmd_set_vf_broadcast_result,
14291 vf, "vf");
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,
14299 port_id, UINT16);
14300 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id =
14301 TOKEN_NUM_INITIALIZER
14302 (struct cmd_set_vf_broadcast_result,
14303 vf_id, UINT16);
14304 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off =
14305 TOKEN_STRING_INITIALIZER
14306 (struct cmd_set_vf_broadcast_result,
14307 on_off, "on#off");
14308
14309 static void
14310 cmd_set_vf_broadcast_parsed(
14311 void *parsed_result,
14312 __attribute__((unused)) struct cmdline *cl,
14313 __attribute__((unused)) void *data)
14314 {
14315 struct cmd_set_vf_broadcast_result *res = parsed_result;
14316 int ret = -ENOTSUP;
14317
14318 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14319
14320 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14321 return;
14322
14323 #ifdef RTE_LIBRTE_I40E_PMD
14324 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id,
14325 res->vf_id, is_on);
14326 #endif
14327
14328 switch (ret) {
14329 case 0:
14330 break;
14331 case -EINVAL:
14332 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14333 break;
14334 case -ENODEV:
14335 printf("invalid port_id %d\n", res->port_id);
14336 break;
14337 case -ENOTSUP:
14338 printf("function not implemented\n");
14339 break;
14340 default:
14341 printf("programming error: (%s)\n", strerror(-ret));
14342 }
14343 }
14344
14345 cmdline_parse_inst_t cmd_set_vf_broadcast = {
14346 .f = cmd_set_vf_broadcast_parsed,
14347 .data = NULL,
14348 .help_str = "set vf broadcast <port_id> <vf_id> on|off",
14349 .tokens = {
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,
14356 NULL,
14357 },
14358 };
14359
14360 /* vf vlan tag configuration */
14361
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;
14368 portid_t port_id;
14369 uint16_t vf_id;
14370 cmdline_fixed_string_t on_off;
14371 };
14372
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,
14377 set, "set");
14378 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf =
14379 TOKEN_STRING_INITIALIZER
14380 (struct cmd_set_vf_vlan_tag_result,
14381 vf, "vf");
14382 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan =
14383 TOKEN_STRING_INITIALIZER
14384 (struct cmd_set_vf_vlan_tag_result,
14385 vlan, "vlan");
14386 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag =
14387 TOKEN_STRING_INITIALIZER
14388 (struct cmd_set_vf_vlan_tag_result,
14389 tag, "tag");
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,
14393 port_id, UINT16);
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,
14397 vf_id, UINT16);
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,
14401 on_off, "on#off");
14402
14403 static void
14404 cmd_set_vf_vlan_tag_parsed(
14405 void *parsed_result,
14406 __attribute__((unused)) struct cmdline *cl,
14407 __attribute__((unused)) void *data)
14408 {
14409 struct cmd_set_vf_vlan_tag_result *res = parsed_result;
14410 int ret = -ENOTSUP;
14411
14412 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
14413
14414 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14415 return;
14416
14417 #ifdef RTE_LIBRTE_I40E_PMD
14418 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id,
14419 res->vf_id, is_on);
14420 #endif
14421
14422 switch (ret) {
14423 case 0:
14424 break;
14425 case -EINVAL:
14426 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
14427 break;
14428 case -ENODEV:
14429 printf("invalid port_id %d\n", res->port_id);
14430 break;
14431 case -ENOTSUP:
14432 printf("function not implemented\n");
14433 break;
14434 default:
14435 printf("programming error: (%s)\n", strerror(-ret));
14436 }
14437 }
14438
14439 cmdline_parse_inst_t cmd_set_vf_vlan_tag = {
14440 .f = cmd_set_vf_vlan_tag_parsed,
14441 .data = NULL,
14442 .help_str = "set vf vlan tag <port_id> <vf_id> on|off",
14443 .tokens = {
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,
14451 NULL,
14452 },
14453 };
14454
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;
14464 portid_t port_id;
14465 uint16_t vf_id;
14466 uint8_t tc_no;
14467 uint32_t bw;
14468 cmdline_fixed_string_t bw_list;
14469 uint8_t tc_map;
14470 };
14471
14472 cmdline_parse_token_string_t cmd_vf_tc_bw_set =
14473 TOKEN_STRING_INITIALIZER
14474 (struct cmd_vf_tc_bw_result,
14475 set, "set");
14476 cmdline_parse_token_string_t cmd_vf_tc_bw_vf =
14477 TOKEN_STRING_INITIALIZER
14478 (struct cmd_vf_tc_bw_result,
14479 vf, "vf");
14480 cmdline_parse_token_string_t cmd_vf_tc_bw_tc =
14481 TOKEN_STRING_INITIALIZER
14482 (struct cmd_vf_tc_bw_result,
14483 tc, "tc");
14484 cmdline_parse_token_string_t cmd_vf_tc_bw_tx =
14485 TOKEN_STRING_INITIALIZER
14486 (struct cmd_vf_tc_bw_result,
14487 tx, "tx");
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,
14503 port_id, UINT16);
14504 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id =
14505 TOKEN_NUM_INITIALIZER
14506 (struct cmd_vf_tc_bw_result,
14507 vf_id, UINT16);
14508 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no =
14509 TOKEN_NUM_INITIALIZER
14510 (struct cmd_vf_tc_bw_result,
14511 tc_no, UINT8);
14512 cmdline_parse_token_num_t cmd_vf_tc_bw_bw =
14513 TOKEN_NUM_INITIALIZER
14514 (struct cmd_vf_tc_bw_result,
14515 bw, UINT32);
14516 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list =
14517 TOKEN_STRING_INITIALIZER
14518 (struct cmd_vf_tc_bw_result,
14519 bw_list, NULL);
14520 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map =
14521 TOKEN_NUM_INITIALIZER
14522 (struct cmd_vf_tc_bw_result,
14523 tc_map, UINT8);
14524
14525 /* VF max bandwidth setting */
14526 static void
14527 cmd_vf_max_bw_parsed(
14528 void *parsed_result,
14529 __attribute__((unused)) struct cmdline *cl,
14530 __attribute__((unused)) void *data)
14531 {
14532 struct cmd_vf_tc_bw_result *res = parsed_result;
14533 int ret = -ENOTSUP;
14534
14535 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14536 return;
14537
14538 #ifdef RTE_LIBRTE_I40E_PMD
14539 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id,
14540 res->vf_id, res->bw);
14541 #endif
14542
14543 switch (ret) {
14544 case 0:
14545 break;
14546 case -EINVAL:
14547 printf("invalid vf_id %d or bandwidth %d\n",
14548 res->vf_id, res->bw);
14549 break;
14550 case -ENODEV:
14551 printf("invalid port_id %d\n", res->port_id);
14552 break;
14553 case -ENOTSUP:
14554 printf("function not implemented\n");
14555 break;
14556 default:
14557 printf("programming error: (%s)\n", strerror(-ret));
14558 }
14559 }
14560
14561 cmdline_parse_inst_t cmd_vf_max_bw = {
14562 .f = cmd_vf_max_bw_parsed,
14563 .data = NULL,
14564 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>",
14565 .tokens = {
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,
14573 NULL,
14574 },
14575 };
14576
14577 static int
14578 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list,
14579 uint8_t *tc_num,
14580 char *str)
14581 {
14582 uint32_t size;
14583 const char *p, *p0 = str;
14584 char s[256];
14585 char *end;
14586 char *str_fld[16];
14587 uint16_t i;
14588 int ret;
14589
14590 p = strchr(p0, '(');
14591 if (p == NULL) {
14592 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14593 return -1;
14594 }
14595 p++;
14596 p0 = strchr(p, ')');
14597 if (p0 == NULL) {
14598 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n");
14599 return -1;
14600 }
14601 size = p0 - p;
14602 if (size >= sizeof(s)) {
14603 printf("The string size exceeds the internal buffer size\n");
14604 return -1;
14605 }
14606 snprintf(s, sizeof(s), "%.*s", size, p);
14607 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ',');
14608 if (ret <= 0) {
14609 printf("Failed to get the bandwidth list. ");
14610 return -1;
14611 }
14612 *tc_num = ret;
14613 for (i = 0; i < ret; i++)
14614 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0);
14615
14616 return 0;
14617 }
14618
14619 /* TC min bandwidth setting */
14620 static void
14621 cmd_vf_tc_min_bw_parsed(
14622 void *parsed_result,
14623 __attribute__((unused)) struct cmdline *cl,
14624 __attribute__((unused)) void *data)
14625 {
14626 struct cmd_vf_tc_bw_result *res = parsed_result;
14627 uint8_t tc_num;
14628 uint8_t bw[16];
14629 int ret = -ENOTSUP;
14630
14631 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14632 return;
14633
14634 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14635 if (ret)
14636 return;
14637
14638 #ifdef RTE_LIBRTE_I40E_PMD
14639 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id,
14640 tc_num, bw);
14641 #endif
14642
14643 switch (ret) {
14644 case 0:
14645 break;
14646 case -EINVAL:
14647 printf("invalid vf_id %d or bandwidth\n", res->vf_id);
14648 break;
14649 case -ENODEV:
14650 printf("invalid port_id %d\n", res->port_id);
14651 break;
14652 case -ENOTSUP:
14653 printf("function not implemented\n");
14654 break;
14655 default:
14656 printf("programming error: (%s)\n", strerror(-ret));
14657 }
14658 }
14659
14660 cmdline_parse_inst_t cmd_vf_tc_min_bw = {
14661 .f = cmd_vf_tc_min_bw_parsed,
14662 .data = NULL,
14663 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>"
14664 " <bw1, bw2, ...>",
14665 .tokens = {
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,
14674 NULL,
14675 },
14676 };
14677
14678 static void
14679 cmd_tc_min_bw_parsed(
14680 void *parsed_result,
14681 __attribute__((unused)) struct cmdline *cl,
14682 __attribute__((unused)) void *data)
14683 {
14684 struct cmd_vf_tc_bw_result *res = parsed_result;
14685 struct rte_port *port;
14686 uint8_t tc_num;
14687 uint8_t bw[16];
14688 int ret = -ENOTSUP;
14689
14690 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14691 return;
14692
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);
14697 return;
14698 }
14699
14700 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list);
14701 if (ret)
14702 return;
14703
14704 #ifdef RTE_LIBRTE_IXGBE_PMD
14705 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw);
14706 #endif
14707
14708 switch (ret) {
14709 case 0:
14710 break;
14711 case -EINVAL:
14712 printf("invalid bandwidth\n");
14713 break;
14714 case -ENODEV:
14715 printf("invalid port_id %d\n", res->port_id);
14716 break;
14717 case -ENOTSUP:
14718 printf("function not implemented\n");
14719 break;
14720 default:
14721 printf("programming error: (%s)\n", strerror(-ret));
14722 }
14723 }
14724
14725 cmdline_parse_inst_t cmd_tc_min_bw = {
14726 .f = cmd_tc_min_bw_parsed,
14727 .data = NULL,
14728 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>",
14729 .tokens = {
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,
14736 NULL,
14737 },
14738 };
14739
14740 /* TC max bandwidth setting */
14741 static void
14742 cmd_vf_tc_max_bw_parsed(
14743 void *parsed_result,
14744 __attribute__((unused)) struct cmdline *cl,
14745 __attribute__((unused)) void *data)
14746 {
14747 struct cmd_vf_tc_bw_result *res = parsed_result;
14748 int ret = -ENOTSUP;
14749
14750 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
14751 return;
14752
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);
14756 #endif
14757
14758 switch (ret) {
14759 case 0:
14760 break;
14761 case -EINVAL:
14762 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n",
14763 res->vf_id, res->tc_no, res->bw);
14764 break;
14765 case -ENODEV:
14766 printf("invalid port_id %d\n", res->port_id);
14767 break;
14768 case -ENOTSUP:
14769 printf("function not implemented\n");
14770 break;
14771 default:
14772 printf("programming error: (%s)\n", strerror(-ret));
14773 }
14774 }
14775
14776 cmdline_parse_inst_t cmd_vf_tc_max_bw = {
14777 .f = cmd_vf_tc_max_bw_parsed,
14778 .data = NULL,
14779 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>"
14780 " <bandwidth>",
14781 .tokens = {
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,
14791 NULL,
14792 },
14793 };
14794
14795
14796 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED
14797
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;
14805 portid_t port_id;
14806 };
14807
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,
14824 def, "default");
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,
14828 port_id, UINT16);
14829
14830 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result,
14831 __attribute__((unused)) struct cmdline *cl,
14832 __attribute__((unused)) void *data)
14833 {
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;
14837
14838 if (port_id_is_invalid(port_id, ENABLED_WARN))
14839 return;
14840
14841 p = &ports[port_id];
14842
14843 /* Forward mode: tm */
14844 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) {
14845 printf(" softnicfwd mode not enabled(error)\n");
14846 return;
14847 }
14848
14849 /* Set the default tm hierarchy */
14850 p->softport.default_tm_hierarchy_enable = 1;
14851 }
14852
14853 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = {
14854 .f = cmd_set_port_tm_hierarchy_default_parsed,
14855 .data = NULL,
14856 .help_str = "set port tm hierarchy default <port_id>",
14857 .tokens = {
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,
14864 NULL,
14865 },
14866 };
14867 #endif
14868
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;
14876 uint32_t vni;
14877 uint16_t udp_src;
14878 uint16_t udp_dst;
14879 cmdline_ipaddr_t ip_src;
14880 cmdline_ipaddr_t ip_dst;
14881 uint16_t tci;
14882 struct ether_addr eth_src;
14883 struct ether_addr eth_dst;
14884 };
14885
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,
14895 "ip-version");
14896 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
14897 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
14898 "ipv4#ipv6");
14899 cmdline_parse_token_string_t cmd_set_vxlan_vni =
14900 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
14901 "vni");
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,
14906 "udp-src");
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,
14911 "udp-dst");
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,
14916 "ip-src");
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,
14921 "ip-dst");
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,
14926 "vlan-tci");
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,
14931 "eth-src");
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,
14936 "eth-dst");
14937 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
14938 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
14939
14940 static void cmd_set_vxlan_parsed(void *parsed_result,
14941 __attribute__((unused)) struct cmdline *cl,
14942 __attribute__((unused)) void *data)
14943 {
14944 struct cmd_set_vxlan_result *res = parsed_result;
14945 union {
14946 uint32_t vxlan_id;
14947 uint8_t vni[4];
14948 } id = {
14949 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
14950 };
14951
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;
14960 else
14961 return;
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);
14968 } else {
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);
14971 }
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,
14975 ETHER_ADDR_LEN);
14976 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
14977 ETHER_ADDR_LEN);
14978 }
14979
14980 cmdline_parse_inst_t cmd_set_vxlan = {
14981 .f = cmd_set_vxlan_parsed,
14982 .data = NULL,
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>",
14986 .tokens = {
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,
15005 NULL,
15006 },
15007 };
15008
15009 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
15010 .f = cmd_set_vxlan_parsed,
15011 .data = NULL,
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"
15015 " <eth-dst>",
15016 .tokens = {
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,
15037 NULL,
15038 },
15039 };
15040
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;
15047 uint32_t tni;
15048 cmdline_ipaddr_t ip_src;
15049 cmdline_ipaddr_t ip_dst;
15050 uint16_t tci;
15051 struct ether_addr eth_src;
15052 struct ether_addr eth_dst;
15053 };
15054
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,
15064 "ip-version");
15065 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
15066 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
15067 "ipv4#ipv6");
15068 cmdline_parse_token_string_t cmd_set_nvgre_tni =
15069 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
15070 "tni");
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,
15075 "ip-src");
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,
15080 "ip-dst");
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,
15085 "vlan-tci");
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,
15090 "eth-src");
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,
15095 "eth-dst");
15096 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
15097 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
15098
15099 static void cmd_set_nvgre_parsed(void *parsed_result,
15100 __attribute__((unused)) struct cmdline *cl,
15101 __attribute__((unused)) void *data)
15102 {
15103 struct cmd_set_nvgre_result *res = parsed_result;
15104 union {
15105 uint32_t nvgre_tni;
15106 uint8_t tni[4];
15107 } id = {
15108 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
15109 };
15110
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;
15119 else
15120 return;
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);
15125 } else {
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);
15128 }
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,
15132 ETHER_ADDR_LEN);
15133 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
15134 ETHER_ADDR_LEN);
15135 }
15136
15137 cmdline_parse_inst_t cmd_set_nvgre = {
15138 .f = cmd_set_nvgre_parsed,
15139 .data = NULL,
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>",
15143 .tokens = {
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,
15158 NULL,
15159 },
15160 };
15161
15162 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
15163 .f = cmd_set_nvgre_parsed,
15164 .data = NULL,
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>",
15168 .tokens = {
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,
15185 NULL,
15186 },
15187 };
15188
15189 /* Strict link priority scheduling mode setting */
15190 static void
15191 cmd_strict_link_prio_parsed(
15192 void *parsed_result,
15193 __attribute__((unused)) struct cmdline *cl,
15194 __attribute__((unused)) void *data)
15195 {
15196 struct cmd_vf_tc_bw_result *res = parsed_result;
15197 int ret = -ENOTSUP;
15198
15199 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15200 return;
15201
15202 #ifdef RTE_LIBRTE_I40E_PMD
15203 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map);
15204 #endif
15205
15206 switch (ret) {
15207 case 0:
15208 break;
15209 case -EINVAL:
15210 printf("invalid tc_bitmap 0x%x\n", res->tc_map);
15211 break;
15212 case -ENODEV:
15213 printf("invalid port_id %d\n", res->port_id);
15214 break;
15215 case -ENOTSUP:
15216 printf("function not implemented\n");
15217 break;
15218 default:
15219 printf("programming error: (%s)\n", strerror(-ret));
15220 }
15221 }
15222
15223 cmdline_parse_inst_t cmd_strict_link_prio = {
15224 .f = cmd_strict_link_prio_parsed,
15225 .data = NULL,
15226 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>",
15227 .tokens = {
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,
15233 NULL,
15234 },
15235 };
15236
15237 /* Load dynamic device personalization*/
15238 struct cmd_ddp_add_result {
15239 cmdline_fixed_string_t ddp;
15240 cmdline_fixed_string_t add;
15241 portid_t port_id;
15242 char filepath[];
15243 };
15244
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);
15253
15254 static void
15255 cmd_ddp_add_parsed(
15256 void *parsed_result,
15257 __attribute__((unused)) struct cmdline *cl,
15258 __attribute__((unused)) void *data)
15259 {
15260 struct cmd_ddp_add_result *res = parsed_result;
15261 uint8_t *buff;
15262 uint32_t size;
15263 char *filepath;
15264 char *file_fld[2];
15265 int file_num;
15266 int ret = -ENOTSUP;
15267
15268 if (!all_ports_stopped()) {
15269 printf("Please stop all ports first\n");
15270 return;
15271 }
15272
15273 filepath = strdup(res->filepath);
15274 if (filepath == NULL) {
15275 printf("Failed to allocate memory\n");
15276 return;
15277 }
15278 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
15279
15280 buff = open_file(file_fld[0], &size);
15281 if (!buff) {
15282 free((void *)filepath);
15283 return;
15284 }
15285
15286 #ifdef RTE_LIBRTE_I40E_PMD
15287 if (ret == -ENOTSUP)
15288 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15289 buff, size,
15290 RTE_PMD_I40E_PKG_OP_WR_ADD);
15291 #endif
15292
15293 if (ret == -EEXIST)
15294 printf("Profile has already existed.\n");
15295 else if (ret < 0)
15296 printf("Failed to load profile.\n");
15297 else if (file_num == 2)
15298 save_file(file_fld[1], buff, size);
15299
15300 close_file(buff);
15301 free((void *)filepath);
15302 }
15303
15304 cmdline_parse_inst_t cmd_ddp_add = {
15305 .f = cmd_ddp_add_parsed,
15306 .data = NULL,
15307 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>",
15308 .tokens = {
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,
15313 NULL,
15314 },
15315 };
15316
15317 /* Delete dynamic device personalization*/
15318 struct cmd_ddp_del_result {
15319 cmdline_fixed_string_t ddp;
15320 cmdline_fixed_string_t del;
15321 portid_t port_id;
15322 char filepath[];
15323 };
15324
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);
15333
15334 static void
15335 cmd_ddp_del_parsed(
15336 void *parsed_result,
15337 __attribute__((unused)) struct cmdline *cl,
15338 __attribute__((unused)) void *data)
15339 {
15340 struct cmd_ddp_del_result *res = parsed_result;
15341 uint8_t *buff;
15342 uint32_t size;
15343 int ret = -ENOTSUP;
15344
15345 if (!all_ports_stopped()) {
15346 printf("Please stop all ports first\n");
15347 return;
15348 }
15349
15350 buff = open_file(res->filepath, &size);
15351 if (!buff)
15352 return;
15353
15354 #ifdef RTE_LIBRTE_I40E_PMD
15355 if (ret == -ENOTSUP)
15356 ret = rte_pmd_i40e_process_ddp_package(res->port_id,
15357 buff, size,
15358 RTE_PMD_I40E_PKG_OP_WR_DEL);
15359 #endif
15360
15361 if (ret == -EACCES)
15362 printf("Profile does not exist.\n");
15363 else if (ret < 0)
15364 printf("Failed to delete profile.\n");
15365
15366 close_file(buff);
15367 }
15368
15369 cmdline_parse_inst_t cmd_ddp_del = {
15370 .f = cmd_ddp_del_parsed,
15371 .data = NULL,
15372 .help_str = "ddp del <port_id> <backup_profile_path>",
15373 .tokens = {
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,
15378 NULL,
15379 },
15380 };
15381
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;
15387 char filepath[];
15388 };
15389
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);
15398
15399 static void
15400 cmd_ddp_info_parsed(
15401 void *parsed_result,
15402 __attribute__((unused)) struct cmdline *cl,
15403 __attribute__((unused)) void *data)
15404 {
15405 struct cmd_ddp_info_result *res = parsed_result;
15406 uint8_t *pkg;
15407 uint32_t pkg_size;
15408 int ret = -ENOTSUP;
15409 #ifdef RTE_LIBRTE_I40E_PMD
15410 uint32_t i, j, n;
15411 uint8_t *buff;
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;
15422 uint8_t proto_id;
15423
15424 #endif
15425
15426 pkg = open_file(res->filepath, &pkg_size);
15427 if (!pkg)
15428 return;
15429
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);
15434 if (!ret) {
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);
15442 }
15443
15444 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15445 (uint8_t *)&info, sizeof(info),
15446 RTE_PMD_I40E_PKG_INFO_HEADER);
15447 if (!ret) {
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);
15455 }
15456
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);
15462 if (buff) {
15463 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
15464 buff, buff_size,
15465 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES);
15466 if (!ret)
15467 printf("Package Notes:\n%s\n\n", buff);
15468 free(buff);
15469 }
15470 }
15471
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);
15478 if (devs) {
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);
15482 if (!ret) {
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);
15490 }
15491 printf("\n");
15492 }
15493 free(devs);
15494 }
15495 }
15496
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;
15503
15504 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
15505 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size);
15506 if (!proto)
15507 goto no_print_return;
15508
15509 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto,
15510 buff_size,
15511 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
15512 if (!ret) {
15513 printf("List of used protocols:\n");
15514 for (i = 0; i < proto_num; i++)
15515 printf(" %2u: %s\n", proto[i].proto_id,
15516 proto[i].name);
15517 printf("\n");
15518 }
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;
15524
15525 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15526 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15527 if (!pctype)
15528 goto no_print_pctypes;
15529
15530 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype,
15531 buff_size,
15532 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
15533 if (ret) {
15534 free(pctype);
15535 goto no_print_pctypes;
15536 }
15537
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);
15547 break;
15548 }
15549 }
15550 }
15551 }
15552 printf("\n");
15553 }
15554 printf("\n");
15555 free(pctype);
15556
15557 no_print_pctypes:
15558
15559 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num,
15560 sizeof(ptype_num),
15561 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM);
15562 if (ret || !ptype_num)
15563 goto no_print_return;
15564
15565 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
15566 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size);
15567 if (!ptype)
15568 goto no_print_return;
15569
15570 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype,
15571 buff_size,
15572 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
15573 if (ret) {
15574 free(ptype);
15575 goto no_print_return;
15576 }
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);
15586 break;
15587 }
15588 }
15589 }
15590 }
15591 printf("\n");
15592 }
15593 free(ptype);
15594 printf("\n");
15595
15596 ret = 0;
15597 no_print_return:
15598 if (proto)
15599 free(proto);
15600 #endif
15601 if (ret == -ENOTSUP)
15602 printf("Function not supported in PMD driver\n");
15603 close_file(pkg);
15604 }
15605
15606 cmdline_parse_inst_t cmd_ddp_get_info = {
15607 .f = cmd_ddp_info_parsed,
15608 .data = NULL,
15609 .help_str = "ddp get info <profile_path>",
15610 .tokens = {
15611 (void *)&cmd_ddp_info_ddp,
15612 (void *)&cmd_ddp_info_get,
15613 (void *)&cmd_ddp_info_info,
15614 (void *)&cmd_ddp_info_filepath,
15615 NULL,
15616 },
15617 };
15618
15619 /* Get dynamic device personalization profile info list*/
15620 #define PROFILE_INFO_SIZE 48
15621 #define MAX_PROFILE_NUM 16
15622
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;
15627 portid_t port_id;
15628 };
15629
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);
15638
15639 static void
15640 cmd_ddp_get_list_parsed(
15641 __attribute__((unused)) void *parsed_result,
15642 __attribute__((unused)) struct cmdline *cl,
15643 __attribute__((unused)) void *data)
15644 {
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;
15649 uint32_t p_num;
15650 uint32_t size;
15651 uint32_t i;
15652 #endif
15653 int ret = -ENOTSUP;
15654
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);
15658 if (!p_list)
15659 printf("%s: Failed to malloc buffer\n", __func__);
15660
15661 if (ret == -ENOTSUP)
15662 ret = rte_pmd_i40e_get_ddp_list(res->port_id,
15663 (uint8_t *)p_list, size);
15664
15665 if (!ret) {
15666 p_num = p_list->p_count;
15667 printf("Profile number is: %d\n\n", p_num);
15668
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);
15679 }
15680 }
15681
15682 free(p_list);
15683 #endif
15684
15685 if (ret < 0)
15686 printf("Failed to get ddp list\n");
15687 }
15688
15689 cmdline_parse_inst_t cmd_ddp_get_list = {
15690 .f = cmd_ddp_get_list_parsed,
15691 .data = NULL,
15692 .help_str = "ddp get list <port_id>",
15693 .tokens = {
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,
15698 NULL,
15699 },
15700 };
15701
15702 /* Configure input set */
15703 struct cmd_cfg_input_set_result {
15704 cmdline_fixed_string_t port;
15705 cmdline_fixed_string_t cfg;
15706 portid_t port_id;
15707 cmdline_fixed_string_t pctype;
15708 uint8_t pctype_id;
15709 cmdline_fixed_string_t inset_type;
15710 cmdline_fixed_string_t opt;
15711 cmdline_fixed_string_t field;
15712 uint8_t field_idx;
15713 };
15714
15715 static void
15716 cmd_cfg_input_set_parsed(
15717 __attribute__((unused)) void *parsed_result,
15718 __attribute__((unused)) struct cmdline *cl,
15719 __attribute__((unused)) void *data)
15720 {
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;
15725 #endif
15726 int ret = -ENOTSUP;
15727
15728 if (!all_ports_stopped()) {
15729 printf("Please stop all ports first\n");
15730 return;
15731 }
15732
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);
15742 if (ret) {
15743 printf("Failed to get input set.\n");
15744 return;
15745 }
15746
15747 if (!strcmp(res->opt, "get")) {
15748 ret = rte_pmd_i40e_inset_field_get(inset.inset,
15749 res->field_idx);
15750 if (ret)
15751 printf("Field index %d is enabled.\n", res->field_idx);
15752 else
15753 printf("Field index %d is disabled.\n", res->field_idx);
15754 return;
15755 } else if (!strcmp(res->opt, "set"))
15756 ret = rte_pmd_i40e_inset_field_set(&inset.inset,
15757 res->field_idx);
15758 else if (!strcmp(res->opt, "clear"))
15759 ret = rte_pmd_i40e_inset_field_clear(&inset.inset,
15760 res->field_idx);
15761 if (ret) {
15762 printf("Failed to configure input set field.\n");
15763 return;
15764 }
15765
15766 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15767 &inset, inset_type);
15768 if (ret) {
15769 printf("Failed to set input set.\n");
15770 return;
15771 }
15772 #endif
15773
15774 if (ret == -ENOTSUP)
15775 printf("Function not supported\n");
15776 }
15777
15778 cmdline_parse_token_string_t cmd_cfg_input_set_port =
15779 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15780 port, "port");
15781 cmdline_parse_token_string_t cmd_cfg_input_set_cfg =
15782 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15783 cfg, "config");
15784 cmdline_parse_token_num_t cmd_cfg_input_set_port_id =
15785 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15786 port_id, UINT16);
15787 cmdline_parse_token_string_t cmd_cfg_input_set_pctype =
15788 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15789 pctype, "pctype");
15790 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id =
15791 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15792 pctype_id, UINT8);
15793 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type =
15794 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result,
15795 inset_type,
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,
15802 field, "field");
15803 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx =
15804 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result,
15805 field_idx, UINT8);
15806
15807 cmdline_parse_inst_t cmd_cfg_input_set = {
15808 .f = cmd_cfg_input_set_parsed,
15809 .data = NULL,
15810 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15811 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>",
15812 .tokens = {
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,
15822 NULL,
15823 },
15824 };
15825
15826 /* Clear input set */
15827 struct cmd_clear_input_set_result {
15828 cmdline_fixed_string_t port;
15829 cmdline_fixed_string_t cfg;
15830 portid_t port_id;
15831 cmdline_fixed_string_t pctype;
15832 uint8_t pctype_id;
15833 cmdline_fixed_string_t inset_type;
15834 cmdline_fixed_string_t clear;
15835 cmdline_fixed_string_t all;
15836 };
15837
15838 static void
15839 cmd_clear_input_set_parsed(
15840 __attribute__((unused)) void *parsed_result,
15841 __attribute__((unused)) struct cmdline *cl,
15842 __attribute__((unused)) void *data)
15843 {
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;
15848 #endif
15849 int ret = -ENOTSUP;
15850
15851 if (!all_ports_stopped()) {
15852 printf("Please stop all ports first\n");
15853 return;
15854 }
15855
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;
15863
15864 memset(&inset, 0, sizeof(inset));
15865
15866 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id,
15867 &inset, inset_type);
15868 if (ret) {
15869 printf("Failed to clear input set.\n");
15870 return;
15871 }
15872
15873 #endif
15874
15875 if (ret == -ENOTSUP)
15876 printf("Function not supported\n");
15877 }
15878
15879 cmdline_parse_token_string_t cmd_clear_input_set_port =
15880 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15881 port, "port");
15882 cmdline_parse_token_string_t cmd_clear_input_set_cfg =
15883 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15884 cfg, "config");
15885 cmdline_parse_token_num_t cmd_clear_input_set_port_id =
15886 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15887 port_id, UINT16);
15888 cmdline_parse_token_string_t cmd_clear_input_set_pctype =
15889 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15890 pctype, "pctype");
15891 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id =
15892 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result,
15893 pctype_id, UINT8);
15894 cmdline_parse_token_string_t cmd_clear_input_set_inset_type =
15895 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15896 inset_type,
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,
15900 clear, "clear");
15901 cmdline_parse_token_string_t cmd_clear_input_set_all =
15902 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result,
15903 all, "all");
15904
15905 cmdline_parse_inst_t cmd_clear_input_set = {
15906 .f = cmd_clear_input_set_parsed,
15907 .data = NULL,
15908 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|"
15909 "fdir_inset|fdir_flx_inset clear all",
15910 .tokens = {
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,
15919 NULL,
15920 },
15921 };
15922
15923 /* show vf stats */
15924
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;
15930 portid_t port_id;
15931 uint16_t vf_id;
15932 };
15933
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,
15938 show, "show");
15939 cmdline_parse_token_string_t cmd_show_vf_stats_vf =
15940 TOKEN_STRING_INITIALIZER
15941 (struct cmd_show_vf_stats_result,
15942 vf, "vf");
15943 cmdline_parse_token_string_t cmd_show_vf_stats_stats =
15944 TOKEN_STRING_INITIALIZER
15945 (struct cmd_show_vf_stats_result,
15946 stats, "stats");
15947 cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
15948 TOKEN_NUM_INITIALIZER
15949 (struct cmd_show_vf_stats_result,
15950 port_id, UINT16);
15951 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
15952 TOKEN_NUM_INITIALIZER
15953 (struct cmd_show_vf_stats_result,
15954 vf_id, UINT16);
15955
15956 static void
15957 cmd_show_vf_stats_parsed(
15958 void *parsed_result,
15959 __attribute__((unused)) struct cmdline *cl,
15960 __attribute__((unused)) void *data)
15961 {
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 = "########################";
15966
15967 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
15968 return;
15969
15970 memset(&stats, 0, sizeof(stats));
15971
15972 #ifdef RTE_LIBRTE_I40E_PMD
15973 if (ret == -ENOTSUP)
15974 ret = rte_pmd_i40e_get_vf_stats(res->port_id,
15975 res->vf_id,
15976 &stats);
15977 #endif
15978 #ifdef RTE_LIBRTE_BNXT_PMD
15979 if (ret == -ENOTSUP)
15980 ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
15981 res->vf_id,
15982 &stats);
15983 #endif
15984
15985 switch (ret) {
15986 case 0:
15987 break;
15988 case -EINVAL:
15989 printf("invalid vf_id %d\n", res->vf_id);
15990 break;
15991 case -ENODEV:
15992 printf("invalid port_id %d\n", res->port_id);
15993 break;
15994 case -ENOTSUP:
15995 printf("function not implemented\n");
15996 break;
15997 default:
15998 printf("programming error: (%s)\n", strerror(-ret));
15999 }
16000
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);
16003
16004 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
16005 "%-"PRIu64"\n",
16006 stats.ipackets, stats.imissed, stats.ibytes);
16007 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
16008 printf(" RX-nombuf: %-10"PRIu64"\n",
16009 stats.rx_nombuf);
16010 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
16011 "%-"PRIu64"\n",
16012 stats.opackets, stats.oerrors, stats.obytes);
16013
16014 printf(" %s############################%s\n",
16015 nic_stats_border, nic_stats_border);
16016 }
16017
16018 cmdline_parse_inst_t cmd_show_vf_stats = {
16019 .f = cmd_show_vf_stats_parsed,
16020 .data = NULL,
16021 .help_str = "show vf stats <port_id> <vf_id>",
16022 .tokens = {
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,
16028 NULL,
16029 },
16030 };
16031
16032 /* clear vf stats */
16033
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;
16039 portid_t port_id;
16040 uint16_t vf_id;
16041 };
16042
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,
16047 clear, "clear");
16048 cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
16049 TOKEN_STRING_INITIALIZER
16050 (struct cmd_clear_vf_stats_result,
16051 vf, "vf");
16052 cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
16053 TOKEN_STRING_INITIALIZER
16054 (struct cmd_clear_vf_stats_result,
16055 stats, "stats");
16056 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
16057 TOKEN_NUM_INITIALIZER
16058 (struct cmd_clear_vf_stats_result,
16059 port_id, UINT16);
16060 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
16061 TOKEN_NUM_INITIALIZER
16062 (struct cmd_clear_vf_stats_result,
16063 vf_id, UINT16);
16064
16065 static void
16066 cmd_clear_vf_stats_parsed(
16067 void *parsed_result,
16068 __attribute__((unused)) struct cmdline *cl,
16069 __attribute__((unused)) void *data)
16070 {
16071 struct cmd_clear_vf_stats_result *res = parsed_result;
16072 int ret = -ENOTSUP;
16073
16074 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16075 return;
16076
16077 #ifdef RTE_LIBRTE_I40E_PMD
16078 if (ret == -ENOTSUP)
16079 ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
16080 res->vf_id);
16081 #endif
16082 #ifdef RTE_LIBRTE_BNXT_PMD
16083 if (ret == -ENOTSUP)
16084 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
16085 res->vf_id);
16086 #endif
16087
16088 switch (ret) {
16089 case 0:
16090 break;
16091 case -EINVAL:
16092 printf("invalid vf_id %d\n", res->vf_id);
16093 break;
16094 case -ENODEV:
16095 printf("invalid port_id %d\n", res->port_id);
16096 break;
16097 case -ENOTSUP:
16098 printf("function not implemented\n");
16099 break;
16100 default:
16101 printf("programming error: (%s)\n", strerror(-ret));
16102 }
16103 }
16104
16105 cmdline_parse_inst_t cmd_clear_vf_stats = {
16106 .f = cmd_clear_vf_stats_parsed,
16107 .data = NULL,
16108 .help_str = "clear vf stats <port_id> <vf_id>",
16109 .tokens = {
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,
16115 NULL,
16116 },
16117 };
16118
16119 /* port config pctype mapping reset */
16120
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;
16125 portid_t port_id;
16126 cmdline_fixed_string_t pctype;
16127 cmdline_fixed_string_t mapping;
16128 cmdline_fixed_string_t reset;
16129 };
16130
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,
16135 port, "port");
16136 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config =
16137 TOKEN_STRING_INITIALIZER
16138 (struct cmd_pctype_mapping_reset_result,
16139 config, "config");
16140 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id =
16141 TOKEN_NUM_INITIALIZER
16142 (struct cmd_pctype_mapping_reset_result,
16143 port_id, UINT16);
16144 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype =
16145 TOKEN_STRING_INITIALIZER
16146 (struct cmd_pctype_mapping_reset_result,
16147 pctype, "pctype");
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,
16155 reset, "reset");
16156
16157 static void
16158 cmd_pctype_mapping_reset_parsed(
16159 void *parsed_result,
16160 __attribute__((unused)) struct cmdline *cl,
16161 __attribute__((unused)) void *data)
16162 {
16163 struct cmd_pctype_mapping_reset_result *res = parsed_result;
16164 int ret = -ENOTSUP;
16165
16166 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16167 return;
16168
16169 #ifdef RTE_LIBRTE_I40E_PMD
16170 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id);
16171 #endif
16172
16173 switch (ret) {
16174 case 0:
16175 break;
16176 case -ENODEV:
16177 printf("invalid port_id %d\n", res->port_id);
16178 break;
16179 case -ENOTSUP:
16180 printf("function not implemented\n");
16181 break;
16182 default:
16183 printf("programming error: (%s)\n", strerror(-ret));
16184 }
16185 }
16186
16187 cmdline_parse_inst_t cmd_pctype_mapping_reset = {
16188 .f = cmd_pctype_mapping_reset_parsed,
16189 .data = NULL,
16190 .help_str = "port config <port_id> pctype mapping reset",
16191 .tokens = {
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,
16198 NULL,
16199 },
16200 };
16201
16202 /* show port pctype mapping */
16203
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;
16208 portid_t port_id;
16209 cmdline_fixed_string_t pctype;
16210 cmdline_fixed_string_t mapping;
16211 };
16212
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,
16217 show, "show");
16218 cmdline_parse_token_string_t cmd_pctype_mapping_get_port =
16219 TOKEN_STRING_INITIALIZER
16220 (struct cmd_pctype_mapping_get_result,
16221 port, "port");
16222 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id =
16223 TOKEN_NUM_INITIALIZER
16224 (struct cmd_pctype_mapping_get_result,
16225 port_id, UINT16);
16226 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype =
16227 TOKEN_STRING_INITIALIZER
16228 (struct cmd_pctype_mapping_get_result,
16229 pctype, "pctype");
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");
16234
16235 static void
16236 cmd_pctype_mapping_get_parsed(
16237 void *parsed_result,
16238 __attribute__((unused)) struct cmdline *cl,
16239 __attribute__((unused)) void *data)
16240 {
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;
16247 #endif
16248
16249 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16250 return;
16251
16252 #ifdef RTE_LIBRTE_I40E_PMD
16253 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping);
16254 #endif
16255
16256 switch (ret) {
16257 case 0:
16258 break;
16259 case -ENODEV:
16260 printf("invalid port_id %d\n", res->port_id);
16261 return;
16262 case -ENOTSUP:
16263 printf("function not implemented\n");
16264 return;
16265 default:
16266 printf("programming error: (%s)\n", strerror(-ret));
16267 return;
16268 }
16269
16270 #ifdef RTE_LIBRTE_I40E_PMD
16271 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) {
16272 if (mapping[i].pctype != 0ULL) {
16273 first_pctype = 1;
16274
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);
16280 first_pctype = 0;
16281 }
16282 }
16283 printf(" -> flowtype: %02d\n", mapping[i].flow_type);
16284 }
16285 }
16286 #endif
16287 }
16288
16289 cmdline_parse_inst_t cmd_pctype_mapping_get = {
16290 .f = cmd_pctype_mapping_get_parsed,
16291 .data = NULL,
16292 .help_str = "show port <port_id> pctype mapping",
16293 .tokens = {
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,
16299 NULL,
16300 },
16301 };
16302
16303 /* port config pctype mapping update */
16304
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;
16309 portid_t port_id;
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;
16315 };
16316
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,
16321 port, "port");
16322 cmdline_parse_token_string_t cmd_pctype_mapping_update_config =
16323 TOKEN_STRING_INITIALIZER
16324 (struct cmd_pctype_mapping_update_result,
16325 config, "config");
16326 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id =
16327 TOKEN_NUM_INITIALIZER
16328 (struct cmd_pctype_mapping_update_result,
16329 port_id, UINT16);
16330 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype =
16331 TOKEN_STRING_INITIALIZER
16332 (struct cmd_pctype_mapping_update_result,
16333 pctype, "pctype");
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,
16341 update, "update");
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);
16350
16351 static void
16352 cmd_pctype_mapping_update_parsed(
16353 void *parsed_result,
16354 __attribute__((unused)) struct cmdline *cl,
16355 __attribute__((unused)) void *data)
16356 {
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;
16361 unsigned int i;
16362 unsigned int nb_item;
16363 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX];
16364 #endif
16365
16366 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16367 return;
16368
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,
16376 &mapping,
16377 1,
16378 0);
16379 #endif
16380
16381 switch (ret) {
16382 case 0:
16383 break;
16384 case -EINVAL:
16385 printf("invalid pctype or flow type\n");
16386 break;
16387 case -ENODEV:
16388 printf("invalid port_id %d\n", res->port_id);
16389 break;
16390 case -ENOTSUP:
16391 printf("function not implemented\n");
16392 break;
16393 default:
16394 printf("programming error: (%s)\n", strerror(-ret));
16395 }
16396 }
16397
16398 cmdline_parse_inst_t cmd_pctype_mapping_update = {
16399 .f = cmd_pctype_mapping_update_parsed,
16400 .data = NULL,
16401 .help_str = "port config <port_id> pctype mapping update"
16402 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>",
16403 .tokens = {
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,
16412 NULL,
16413 },
16414 };
16415
16416 /* ptype mapping get */
16417
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;
16423 portid_t port_id;
16424 uint8_t valid_only;
16425 };
16426
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,
16431 ptype, "ptype");
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,
16439 get, "get");
16440 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id =
16441 TOKEN_NUM_INITIALIZER
16442 (struct cmd_ptype_mapping_get_result,
16443 port_id, UINT16);
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);
16448
16449 static void
16450 cmd_ptype_mapping_get_parsed(
16451 void *parsed_result,
16452 __attribute__((unused)) struct cmdline *cl,
16453 __attribute__((unused)) void *data)
16454 {
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];
16460 uint16_t count;
16461 int i;
16462 #endif
16463
16464 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16465 return;
16466
16467 #ifdef RTE_LIBRTE_I40E_PMD
16468 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id,
16469 mapping,
16470 max_ptype_num,
16471 &count,
16472 res->valid_only);
16473 #endif
16474
16475 switch (ret) {
16476 case 0:
16477 break;
16478 case -ENODEV:
16479 printf("invalid port_id %d\n", res->port_id);
16480 break;
16481 case -ENOTSUP:
16482 printf("function not implemented\n");
16483 break;
16484 default:
16485 printf("programming error: (%s)\n", strerror(-ret));
16486 }
16487
16488 #ifdef RTE_LIBRTE_I40E_PMD
16489 if (!ret) {
16490 for (i = 0; i < count; i++)
16491 printf("%3d\t0x%08x\n",
16492 mapping[i].hw_ptype, mapping[i].sw_ptype);
16493 }
16494 #endif
16495 }
16496
16497 cmdline_parse_inst_t cmd_ptype_mapping_get = {
16498 .f = cmd_ptype_mapping_get_parsed,
16499 .data = NULL,
16500 .help_str = "ptype mapping get <port_id> <valid_only>",
16501 .tokens = {
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,
16507 NULL,
16508 },
16509 };
16510
16511 /* ptype mapping replace */
16512
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;
16518 portid_t port_id;
16519 uint32_t target;
16520 uint8_t mask;
16521 uint32_t pkt_type;
16522 };
16523
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,
16528 ptype, "ptype");
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,
16540 port_id, UINT16);
16541 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target =
16542 TOKEN_NUM_INITIALIZER
16543 (struct cmd_ptype_mapping_replace_result,
16544 target, UINT32);
16545 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask =
16546 TOKEN_NUM_INITIALIZER
16547 (struct cmd_ptype_mapping_replace_result,
16548 mask, UINT8);
16549 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type =
16550 TOKEN_NUM_INITIALIZER
16551 (struct cmd_ptype_mapping_replace_result,
16552 pkt_type, UINT32);
16553
16554 static void
16555 cmd_ptype_mapping_replace_parsed(
16556 void *parsed_result,
16557 __attribute__((unused)) struct cmdline *cl,
16558 __attribute__((unused)) void *data)
16559 {
16560 struct cmd_ptype_mapping_replace_result *res = parsed_result;
16561 int ret = -ENOTSUP;
16562
16563 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16564 return;
16565
16566 #ifdef RTE_LIBRTE_I40E_PMD
16567 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id,
16568 res->target,
16569 res->mask,
16570 res->pkt_type);
16571 #endif
16572
16573 switch (ret) {
16574 case 0:
16575 break;
16576 case -EINVAL:
16577 printf("invalid ptype 0x%8x or 0x%8x\n",
16578 res->target, res->pkt_type);
16579 break;
16580 case -ENODEV:
16581 printf("invalid port_id %d\n", res->port_id);
16582 break;
16583 case -ENOTSUP:
16584 printf("function not implemented\n");
16585 break;
16586 default:
16587 printf("programming error: (%s)\n", strerror(-ret));
16588 }
16589 }
16590
16591 cmdline_parse_inst_t cmd_ptype_mapping_replace = {
16592 .f = cmd_ptype_mapping_replace_parsed,
16593 .data = NULL,
16594 .help_str =
16595 "ptype mapping replace <port_id> <target> <mask> <pkt_type>",
16596 .tokens = {
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,
16604 NULL,
16605 },
16606 };
16607
16608 /* ptype mapping reset */
16609
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;
16615 portid_t port_id;
16616 };
16617
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,
16622 ptype, "ptype");
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,
16630 reset, "reset");
16631 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id =
16632 TOKEN_NUM_INITIALIZER
16633 (struct cmd_ptype_mapping_reset_result,
16634 port_id, UINT16);
16635
16636 static void
16637 cmd_ptype_mapping_reset_parsed(
16638 void *parsed_result,
16639 __attribute__((unused)) struct cmdline *cl,
16640 __attribute__((unused)) void *data)
16641 {
16642 struct cmd_ptype_mapping_reset_result *res = parsed_result;
16643 int ret = -ENOTSUP;
16644
16645 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16646 return;
16647
16648 #ifdef RTE_LIBRTE_I40E_PMD
16649 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id);
16650 #endif
16651
16652 switch (ret) {
16653 case 0:
16654 break;
16655 case -ENODEV:
16656 printf("invalid port_id %d\n", res->port_id);
16657 break;
16658 case -ENOTSUP:
16659 printf("function not implemented\n");
16660 break;
16661 default:
16662 printf("programming error: (%s)\n", strerror(-ret));
16663 }
16664 }
16665
16666 cmdline_parse_inst_t cmd_ptype_mapping_reset = {
16667 .f = cmd_ptype_mapping_reset_parsed,
16668 .data = NULL,
16669 .help_str = "ptype mapping reset <port_id>",
16670 .tokens = {
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,
16675 NULL,
16676 },
16677 };
16678
16679 /* ptype mapping update */
16680
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;
16686 portid_t port_id;
16687 uint8_t hw_ptype;
16688 uint32_t sw_ptype;
16689 };
16690
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,
16695 ptype, "ptype");
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,
16703 reset, "update");
16704 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id =
16705 TOKEN_NUM_INITIALIZER
16706 (struct cmd_ptype_mapping_update_result,
16707 port_id, UINT16);
16708 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype =
16709 TOKEN_NUM_INITIALIZER
16710 (struct cmd_ptype_mapping_update_result,
16711 hw_ptype, UINT8);
16712 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype =
16713 TOKEN_NUM_INITIALIZER
16714 (struct cmd_ptype_mapping_update_result,
16715 sw_ptype, UINT32);
16716
16717 static void
16718 cmd_ptype_mapping_update_parsed(
16719 void *parsed_result,
16720 __attribute__((unused)) struct cmdline *cl,
16721 __attribute__((unused)) void *data)
16722 {
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;
16727 #endif
16728 if (port_id_is_invalid(res->port_id, ENABLED_WARN))
16729 return;
16730
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,
16735 &mapping,
16736 1,
16737 0);
16738 #endif
16739
16740 switch (ret) {
16741 case 0:
16742 break;
16743 case -EINVAL:
16744 printf("invalid ptype 0x%8x\n", res->sw_ptype);
16745 break;
16746 case -ENODEV:
16747 printf("invalid port_id %d\n", res->port_id);
16748 break;
16749 case -ENOTSUP:
16750 printf("function not implemented\n");
16751 break;
16752 default:
16753 printf("programming error: (%s)\n", strerror(-ret));
16754 }
16755 }
16756
16757 cmdline_parse_inst_t cmd_ptype_mapping_update = {
16758 .f = cmd_ptype_mapping_update_parsed,
16759 .data = NULL,
16760 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>",
16761 .tokens = {
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,
16768 NULL,
16769 },
16770 };
16771
16772 /* Common result structure for file commands */
16773 struct cmd_cmdfile_result {
16774 cmdline_fixed_string_t load;
16775 cmdline_fixed_string_t filename;
16776 };
16777
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);
16783
16784 static void
16785 cmd_load_from_file_parsed(
16786 void *parsed_result,
16787 __attribute__((unused)) struct cmdline *cl,
16788 __attribute__((unused)) void *data)
16789 {
16790 struct cmd_cmdfile_result *res = parsed_result;
16791
16792 cmdline_read_from_file(res->filename);
16793 }
16794
16795 cmdline_parse_inst_t cmd_load_from_file = {
16796 .f = cmd_load_from_file_parsed,
16797 .data = NULL,
16798 .help_str = "load <filename>",
16799 .tokens = {
16800 (void *)&cmd_load_cmdfile,
16801 (void *)&cmd_load_cmdfile_filename,
16802 NULL,
16803 },
16804 };
16805
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;
16810 portid_t port_id;
16811 cmdline_fixed_string_t rx_offload;
16812 cmdline_fixed_string_t capabilities;
16813 };
16814
16815 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
16816 TOKEN_STRING_INITIALIZER
16817 (struct cmd_rx_offload_get_capa_result,
16818 show, "show");
16819 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
16820 TOKEN_STRING_INITIALIZER
16821 (struct cmd_rx_offload_get_capa_result,
16822 port, "port");
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,
16826 port_id, UINT16);
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");
16835
16836 static void
16837 print_rx_offloads(uint64_t offloads)
16838 {
16839 uint64_t single_offload;
16840 int begin;
16841 int end;
16842 int bit;
16843
16844 if (offloads == 0)
16845 return;
16846
16847 begin = __builtin_ctzll(offloads);
16848 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
16849
16850 single_offload = 1 << begin;
16851 for (bit = begin; bit < end; bit++) {
16852 if (offloads & single_offload)
16853 printf(" %s",
16854 rte_eth_dev_rx_offload_name(single_offload));
16855 single_offload <<= 1;
16856 }
16857 }
16858
16859 static void
16860 cmd_rx_offload_get_capa_parsed(
16861 void *parsed_result,
16862 __attribute__((unused)) struct cmdline *cl,
16863 __attribute__((unused)) void *data)
16864 {
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;
16870
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;
16874
16875 printf("Rx Offloading Capabilities of port %d :\n", port_id);
16876 printf(" Per Queue :");
16877 print_rx_offloads(queue_offloads);
16878
16879 printf("\n");
16880 printf(" Per Port :");
16881 print_rx_offloads(port_offloads);
16882 printf("\n\n");
16883 }
16884
16885 cmdline_parse_inst_t cmd_rx_offload_get_capa = {
16886 .f = cmd_rx_offload_get_capa_parsed,
16887 .data = NULL,
16888 .help_str = "show port <port_id> rx_offload capabilities",
16889 .tokens = {
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,
16895 NULL,
16896 }
16897 };
16898
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;
16903 portid_t port_id;
16904 cmdline_fixed_string_t rx_offload;
16905 cmdline_fixed_string_t configuration;
16906 };
16907
16908 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
16909 TOKEN_STRING_INITIALIZER
16910 (struct cmd_rx_offload_get_configuration_result,
16911 show, "show");
16912 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
16913 TOKEN_STRING_INITIALIZER
16914 (struct cmd_rx_offload_get_configuration_result,
16915 port, "port");
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,
16919 port_id, UINT16);
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");
16928
16929 static void
16930 cmd_rx_offload_get_configuration_parsed(
16931 void *parsed_result,
16932 __attribute__((unused)) struct cmdline *cl,
16933 __attribute__((unused)) void *data)
16934 {
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;
16942 int q;
16943
16944 printf("Rx Offloading Configuration of port %d :\n", port_id);
16945
16946 port_offloads = port->dev_conf.rxmode.offloads;
16947 printf(" Port :");
16948 print_rx_offloads(port_offloads);
16949 printf("\n");
16950
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);
16957 printf("\n");
16958 }
16959 printf("\n");
16960 }
16961
16962 cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
16963 .f = cmd_rx_offload_get_configuration_parsed,
16964 .data = NULL,
16965 .help_str = "show port <port_id> rx_offload configuration",
16966 .tokens = {
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,
16972 NULL,
16973 }
16974 };
16975
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;
16980 portid_t port_id;
16981 cmdline_fixed_string_t rx_offload;
16982 cmdline_fixed_string_t offload;
16983 cmdline_fixed_string_t on_off;
16984 };
16985
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,
16989 port, "port");
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,
16993 config, "config");
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,
16997 port_id, UINT16);
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#keep_crc");
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,
17012 on_off, "on#off");
17013
17014 static uint64_t
17015 search_rx_offload(const char *name)
17016 {
17017 uint64_t single_offload;
17018 const char *single_name;
17019 int found = 0;
17020 unsigned int bit;
17021
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)) {
17026 found = 1;
17027 break;
17028 } else if (!strcasecmp(single_name, "UNKNOWN"))
17029 break;
17030 else if (single_name == NULL)
17031 break;
17032 single_offload <<= 1;
17033 }
17034
17035 if (found)
17036 return single_offload;
17037
17038 return 0;
17039 }
17040
17041 static void
17042 cmd_config_per_port_rx_offload_parsed(void *parsed_result,
17043 __attribute__((unused)) struct cmdline *cl,
17044 __attribute__((unused)) void *data)
17045 {
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;
17052 int q;
17053
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);
17057 return;
17058 }
17059
17060 single_offload = search_rx_offload(res->offload);
17061 if (single_offload == 0) {
17062 printf("Unknown offload name: %s\n", res->offload);
17063 return;
17064 }
17065
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;
17072 } else {
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;
17076 }
17077
17078 cmd_reconfig_device_queue(port_id, 1, 1);
17079 }
17080
17081 cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
17082 .f = cmd_config_per_port_rx_offload_parsed,
17083 .data = NULL,
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|keep_crc "
17088 "on|off",
17089 .tokens = {
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,
17096 NULL,
17097 }
17098 };
17099
17100 /* Enable/Disable a per queue offloading */
17101 struct cmd_config_per_queue_rx_offload_result {
17102 cmdline_fixed_string_t port;
17103 portid_t port_id;
17104 cmdline_fixed_string_t rxq;
17105 uint16_t queue_id;
17106 cmdline_fixed_string_t rx_offload;
17107 cmdline_fixed_string_t offload;
17108 cmdline_fixed_string_t on_off;
17109 };
17110
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,
17114 port, "port");
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,
17118 port_id, UINT16);
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,
17122 rxq, "rxq");
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,
17126 queue_id, UINT16);
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#keep_crc");
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,
17141 on_off, "on#off");
17142
17143 static void
17144 cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
17145 __attribute__((unused)) struct cmdline *cl,
17146 __attribute__((unused)) void *data)
17147 {
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;
17154
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);
17158 return;
17159 }
17160
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);
17165 return;
17166 }
17167
17168 single_offload = search_rx_offload(res->offload);
17169 if (single_offload == 0) {
17170 printf("Unknown offload name: %s\n", res->offload);
17171 return;
17172 }
17173
17174 if (!strcmp(res->on_off, "on"))
17175 port->rx_conf[queue_id].offloads |= single_offload;
17176 else
17177 port->rx_conf[queue_id].offloads &= ~single_offload;
17178
17179 cmd_reconfig_device_queue(port_id, 1, 1);
17180 }
17181
17182 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
17183 .f = cmd_config_per_queue_rx_offload_parsed,
17184 .data = NULL,
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|keep_crc "
17190 "on|off",
17191 .tokens = {
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,
17199 NULL,
17200 }
17201 };
17202
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;
17207 portid_t port_id;
17208 cmdline_fixed_string_t tx_offload;
17209 cmdline_fixed_string_t capabilities;
17210 };
17211
17212 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
17213 TOKEN_STRING_INITIALIZER
17214 (struct cmd_tx_offload_get_capa_result,
17215 show, "show");
17216 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
17217 TOKEN_STRING_INITIALIZER
17218 (struct cmd_tx_offload_get_capa_result,
17219 port, "port");
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,
17223 port_id, UINT16);
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");
17232
17233 static void
17234 print_tx_offloads(uint64_t offloads)
17235 {
17236 uint64_t single_offload;
17237 int begin;
17238 int end;
17239 int bit;
17240
17241 if (offloads == 0)
17242 return;
17243
17244 begin = __builtin_ctzll(offloads);
17245 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
17246
17247 single_offload = 1 << begin;
17248 for (bit = begin; bit < end; bit++) {
17249 if (offloads & single_offload)
17250 printf(" %s",
17251 rte_eth_dev_tx_offload_name(single_offload));
17252 single_offload <<= 1;
17253 }
17254 }
17255
17256 static void
17257 cmd_tx_offload_get_capa_parsed(
17258 void *parsed_result,
17259 __attribute__((unused)) struct cmdline *cl,
17260 __attribute__((unused)) void *data)
17261 {
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;
17267
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;
17271
17272 printf("Tx Offloading Capabilities of port %d :\n", port_id);
17273 printf(" Per Queue :");
17274 print_tx_offloads(queue_offloads);
17275
17276 printf("\n");
17277 printf(" Per Port :");
17278 print_tx_offloads(port_offloads);
17279 printf("\n\n");
17280 }
17281
17282 cmdline_parse_inst_t cmd_tx_offload_get_capa = {
17283 .f = cmd_tx_offload_get_capa_parsed,
17284 .data = NULL,
17285 .help_str = "show port <port_id> tx_offload capabilities",
17286 .tokens = {
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,
17292 NULL,
17293 }
17294 };
17295
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;
17300 portid_t port_id;
17301 cmdline_fixed_string_t tx_offload;
17302 cmdline_fixed_string_t configuration;
17303 };
17304
17305 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
17306 TOKEN_STRING_INITIALIZER
17307 (struct cmd_tx_offload_get_configuration_result,
17308 show, "show");
17309 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
17310 TOKEN_STRING_INITIALIZER
17311 (struct cmd_tx_offload_get_configuration_result,
17312 port, "port");
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,
17316 port_id, UINT16);
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");
17325
17326 static void
17327 cmd_tx_offload_get_configuration_parsed(
17328 void *parsed_result,
17329 __attribute__((unused)) struct cmdline *cl,
17330 __attribute__((unused)) void *data)
17331 {
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;
17339 int q;
17340
17341 printf("Tx Offloading Configuration of port %d :\n", port_id);
17342
17343 port_offloads = port->dev_conf.txmode.offloads;
17344 printf(" Port :");
17345 print_tx_offloads(port_offloads);
17346 printf("\n");
17347
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);
17354 printf("\n");
17355 }
17356 printf("\n");
17357 }
17358
17359 cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
17360 .f = cmd_tx_offload_get_configuration_parsed,
17361 .data = NULL,
17362 .help_str = "show port <port_id> tx_offload configuration",
17363 .tokens = {
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,
17369 NULL,
17370 }
17371 };
17372
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;
17377 portid_t port_id;
17378 cmdline_fixed_string_t tx_offload;
17379 cmdline_fixed_string_t offload;
17380 cmdline_fixed_string_t on_off;
17381 };
17382
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,
17386 port, "port");
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,
17390 config, "config");
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,
17394 port_id, UINT16);
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#mbuf_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,
17410 on_off, "on#off");
17411
17412 static uint64_t
17413 search_tx_offload(const char *name)
17414 {
17415 uint64_t single_offload;
17416 const char *single_name;
17417 int found = 0;
17418 unsigned int bit;
17419
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)) {
17424 found = 1;
17425 break;
17426 } else if (!strcasecmp(single_name, "UNKNOWN"))
17427 break;
17428 else if (single_name == NULL)
17429 break;
17430 single_offload <<= 1;
17431 }
17432
17433 if (found)
17434 return single_offload;
17435
17436 return 0;
17437 }
17438
17439 static void
17440 cmd_config_per_port_tx_offload_parsed(void *parsed_result,
17441 __attribute__((unused)) struct cmdline *cl,
17442 __attribute__((unused)) void *data)
17443 {
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;
17450 int q;
17451
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);
17455 return;
17456 }
17457
17458 single_offload = search_tx_offload(res->offload);
17459 if (single_offload == 0) {
17460 printf("Unknown offload name: %s\n", res->offload);
17461 return;
17462 }
17463
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;
17470 } else {
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;
17474 }
17475
17476 cmd_reconfig_device_queue(port_id, 1, 1);
17477 }
17478
17479 cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
17480 .f = cmd_config_per_port_tx_offload_parsed,
17481 .data = NULL,
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|mbuf_fast_free|security "
17488 "on|off",
17489 .tokens = {
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,
17496 NULL,
17497 }
17498 };
17499
17500 /* Enable/Disable a per queue offloading */
17501 struct cmd_config_per_queue_tx_offload_result {
17502 cmdline_fixed_string_t port;
17503 portid_t port_id;
17504 cmdline_fixed_string_t txq;
17505 uint16_t queue_id;
17506 cmdline_fixed_string_t tx_offload;
17507 cmdline_fixed_string_t offload;
17508 cmdline_fixed_string_t on_off;
17509 };
17510
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,
17514 port, "port");
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,
17518 port_id, UINT16);
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,
17522 txq, "txq");
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,
17526 queue_id, UINT16);
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#mbuf_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,
17542 on_off, "on#off");
17543
17544 static void
17545 cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
17546 __attribute__((unused)) struct cmdline *cl,
17547 __attribute__((unused)) void *data)
17548 {
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;
17555
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);
17559 return;
17560 }
17561
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);
17566 return;
17567 }
17568
17569 single_offload = search_tx_offload(res->offload);
17570 if (single_offload == 0) {
17571 printf("Unknown offload name: %s\n", res->offload);
17572 return;
17573 }
17574
17575 if (!strcmp(res->on_off, "on"))
17576 port->tx_conf[queue_id].offloads |= single_offload;
17577 else
17578 port->tx_conf[queue_id].offloads &= ~single_offload;
17579
17580 cmd_reconfig_device_queue(port_id, 1, 1);
17581 }
17582
17583 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
17584 .f = cmd_config_per_queue_tx_offload_parsed,
17585 .data = NULL,
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|mbuf_fast_free|security "
17592 "on|off",
17593 .tokens = {
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,
17601 NULL,
17602 }
17603 };
17604
17605 /* ******************************************************************************** */
17606
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,
17654 #endif
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,
17812 #endif
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,
17829
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,
17869 #endif
17870 NULL,
17871 };
17872
17873 /* read cmdline commands from file */
17874 void
17875 cmdline_read_from_file(const char *filename)
17876 {
17877 struct cmdline *cl;
17878
17879 cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
17880 if (cl == NULL) {
17881 printf("Failed to create file based cmdline context: %s\n",
17882 filename);
17883 return;
17884 }
17885
17886 cmdline_interact(cl);
17887 cmdline_quit(cl);
17888
17889 cmdline_free(cl);
17890
17891 printf("Read CLI commands from %s\n", filename);
17892 }
17893
17894 /* prompt function, called from main on MASTER lcore */
17895 void
17896 prompt(void)
17897 {
17898 /* initialize non-constant commands */
17899 cmd_set_fwd_mode_init();
17900 cmd_set_fwd_retry_mode_init();
17901
17902 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
17903 if (testpmd_cl == NULL)
17904 return;
17905 cmdline_interact(testpmd_cl);
17906 cmdline_stdin_exit(testpmd_cl);
17907 }
17908
17909 void
17910 prompt_exit(void)
17911 {
17912 if (testpmd_cl != NULL)
17913 cmdline_quit(testpmd_cl);
17914 }
17915
17916 static void
17917 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
17918 {
17919 if (id == (portid_t)RTE_PORT_ALL) {
17920 portid_t pid;
17921
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;
17929 }
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;
17937 }
17938 }