Branch data Line data Source code
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 <ctype.h>
7 : : #include <stdarg.h>
8 : : #include <errno.h>
9 : : #include <fcntl.h>
10 : : #include <stdio.h>
11 : : #include <stdint.h>
12 : : #include <stdlib.h>
13 : : #include <string.h>
14 : : #include <unistd.h>
15 : : #include <inttypes.h>
16 : : #include <sys/queue.h>
17 : :
18 : : #include <rte_common.h>
19 : : #include <rte_byteorder.h>
20 : : #include <rte_log.h>
21 : : #include <rte_debug.h>
22 : : #include <rte_cycles.h>
23 : : #include <rte_memory.h>
24 : : #include <rte_memzone.h>
25 : : #include <rte_malloc.h>
26 : : #include <rte_launch.h>
27 : : #include <rte_eal.h>
28 : : #include <rte_per_lcore.h>
29 : : #include <rte_lcore.h>
30 : : #include <rte_branch_prediction.h>
31 : : #include <rte_ring.h>
32 : : #include <rte_mempool.h>
33 : : #include <rte_interrupts.h>
34 : : #include <rte_ether.h>
35 : : #include <rte_ethdev.h>
36 : : #include <rte_string_fns.h>
37 : : #include <rte_devargs.h>
38 : : #include <rte_flow.h>
39 : : #ifdef RTE_LIB_GRO
40 : : #include <rte_gro.h>
41 : : #endif
42 : : #include <rte_mbuf_dyn.h>
43 : : #include <rte_mbuf_history.h>
44 : : #include <rte_trace.h>
45 : :
46 : : #include <cmdline_rdline.h>
47 : : #include <cmdline_parse.h>
48 : : #include <cmdline_parse_num.h>
49 : : #include <cmdline_parse_bool.h>
50 : : #include <cmdline_parse_string.h>
51 : : #include <cmdline_parse_ipaddr.h>
52 : : #include <cmdline_parse_etheraddr.h>
53 : : #include <cmdline_socket.h>
54 : : #include <cmdline.h>
55 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
56 : : #include <rte_pmd_dpaa.h>
57 : : #endif
58 : : #ifdef RTE_NET_IXGBE
59 : : #include <rte_pmd_ixgbe.h>
60 : : #endif
61 : : #ifdef RTE_NET_I40E
62 : : #include <rte_pmd_i40e.h>
63 : : #endif
64 : : #ifdef RTE_NET_BNXT
65 : : #include <rte_pmd_bnxt.h>
66 : : #endif
67 : : #include "testpmd.h"
68 : : #include "cmdline_cman.h"
69 : : #include "cmdline_mtr.h"
70 : : #include "cmdline_tm.h"
71 : : #include "bpf_cmd.h"
72 : :
73 : : static struct cmdline *testpmd_cl;
74 : : static cmdline_parse_ctx_t *main_ctx;
75 : : static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
76 : : TAILQ_HEAD_INITIALIZER(driver_commands_head);
77 : :
78 : : /* *** Help command with introduction. *** */
79 : : struct cmd_help_brief_result {
80 : : cmdline_fixed_string_t help;
81 : : };
82 : :
83 : 0 : static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
84 : : struct cmdline *cl,
85 : : __rte_unused void *data)
86 : : {
87 : 0 : cmdline_printf(
88 : : cl,
89 : : "\n"
90 : : "Help is available for the following sections:\n\n"
91 : : " help control : Start and stop forwarding.\n"
92 : : " help display : Displaying port, stats and config "
93 : : "information.\n"
94 : : " help config : Configuration information.\n"
95 : : " help ports : Configuring ports.\n"
96 : : " help filters : Filters configuration help.\n"
97 : : " help traffic_management : Traffic Management commands.\n"
98 : : " help devices : Device related commands.\n"
99 : : " help drivers : Driver specific commands.\n"
100 : : " help all : All of the above sections.\n\n"
101 : : );
102 : :
103 : 0 : }
104 : :
105 : : static cmdline_parse_token_string_t cmd_help_brief_help =
106 : : TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
107 : :
108 : : static cmdline_parse_inst_t cmd_help_brief = {
109 : : .f = cmd_help_brief_parsed,
110 : : .data = NULL,
111 : : .help_str = "help: Show help",
112 : : .tokens = {
113 : : (void *)&cmd_help_brief_help,
114 : : NULL,
115 : : },
116 : : };
117 : :
118 : : /* *** Help command with help sections. *** */
119 : : struct cmd_help_long_result {
120 : : cmdline_fixed_string_t help;
121 : : cmdline_fixed_string_t section;
122 : : };
123 : :
124 : 0 : static void cmd_help_long_parsed(void *parsed_result,
125 : : struct cmdline *cl,
126 : : __rte_unused void *data)
127 : : {
128 : : int show_all = 0;
129 : : struct cmd_help_long_result *res = parsed_result;
130 : :
131 : 0 : if (!strcmp(res->section, "all"))
132 : : show_all = 1;
133 : :
134 : 0 : if (show_all || !strcmp(res->section, "control")) {
135 : :
136 : 0 : cmdline_printf(
137 : : cl,
138 : : "\n"
139 : : "Control forwarding:\n"
140 : : "-------------------\n\n"
141 : :
142 : : "start\n"
143 : : " Start packet forwarding with current configuration.\n\n"
144 : :
145 : : "start tx_first\n"
146 : : " Start packet forwarding with current config"
147 : : " after sending one burst of packets.\n\n"
148 : :
149 : : "stop\n"
150 : : " Stop packet forwarding, and display accumulated"
151 : : " statistics.\n\n"
152 : :
153 : : "quit\n"
154 : : " Quit to prompt.\n\n"
155 : : );
156 : : }
157 : :
158 : 0 : if (show_all || !strcmp(res->section, "display")) {
159 : :
160 : 0 : cmdline_printf(
161 : : cl,
162 : : "\n"
163 : : "Display:\n"
164 : : "--------\n\n"
165 : :
166 : : "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
167 : : " Display information for port_id, or all.\n\n"
168 : :
169 : : "show port info (port_id) representor\n"
170 : : " Show supported representors for a specific port\n\n"
171 : :
172 : : "show port port_id (module_eeprom|eeprom)\n"
173 : : " Display the module EEPROM or EEPROM information for port_id.\n\n"
174 : :
175 : : "set port (port_id) eeprom (accept_risk) magic (magic_num)"
176 : : " value (value) offset (offset)\n"
177 : : " Set the device eeprom for certain port.\nNote:\n"
178 : : " This is a high-risk command and its misuse may"
179 : : " result in unexpected behaviour from the NIC.\n"
180 : : " By inserting \"accept_risk\" into the command, the"
181 : : " user is acknowledging and taking responsibility for"
182 : : " this risk.\n\n"
183 : :
184 : : "show port X rss reta (size) (mask0,mask1,...)\n"
185 : : " Display the rss redirection table entry indicated"
186 : : " by masks on port X. size is used to indicate the"
187 : : " hardware supported reta size\n\n"
188 : :
189 : : "show port (port_id) rss-hash [key | algorithm]\n"
190 : : " Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
191 : :
192 : : "clear port (info|stats|xstats|fdir) (port_id|all)\n"
193 : : " Clear information for port_id, or all.\n\n"
194 : :
195 : : "show (rxq|txq) info (port_id) (queue_id)\n"
196 : : " Display information for configured RX/TX queue.\n\n"
197 : :
198 : : "show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
199 : : " Display the given configuration.\n\n"
200 : :
201 : : "read rxd (port_id) (queue_id) (rxd_id)\n"
202 : : " Display an RX descriptor of a port RX queue.\n\n"
203 : :
204 : : "read txd (port_id) (queue_id) (txd_id)\n"
205 : : " Display a TX descriptor of a port TX queue.\n\n"
206 : :
207 : : "show vf stats (port_id) (vf_id)\n"
208 : : " Display a VF's statistics.\n\n"
209 : :
210 : : "clear vf stats (port_id) (vf_id)\n"
211 : : " Reset a VF's statistics.\n\n"
212 : :
213 : : "show port meter stats (port_id) (meter_id) (clear)\n"
214 : : " Get meter stats on a port\n\n"
215 : :
216 : : "show fwd stats all\n"
217 : : " Display statistics for all fwd engines.\n\n"
218 : :
219 : : "clear fwd stats all\n"
220 : : " Clear statistics for all fwd engines.\n\n"
221 : :
222 : : "show port (port_id) rx_offload capabilities\n"
223 : : " List all per queue and per port Rx offloading"
224 : : " capabilities of a port\n\n"
225 : :
226 : : "show port (port_id) rx_offload configuration\n"
227 : : " List port level and all queue level"
228 : : " Rx offloading configuration\n\n"
229 : :
230 : : "show port (port_id) tx_offload capabilities\n"
231 : : " List all per queue and per port"
232 : : " Tx offloading capabilities of a port\n\n"
233 : :
234 : : "show port (port_id) tx_offload configuration\n"
235 : : " List port level and all queue level"
236 : : " Tx offloading configuration\n\n"
237 : :
238 : : "show port (port_id) tx_metadata\n"
239 : : " Show Tx metadata value set"
240 : : " for a specific port\n\n"
241 : :
242 : : "show port (port_id) ptypes\n"
243 : : " Show port supported ptypes"
244 : : " for a specific port\n\n"
245 : :
246 : : "show device info (<identifier>|all)"
247 : : " Show general information about devices probed.\n\n"
248 : :
249 : : "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
250 : : " Show status of rx|tx descriptor.\n\n"
251 : :
252 : : "show port (port_id) rxq|txq (queue_id) desc used count\n"
253 : : " Show current number of used descriptor count for rx|tx.\n\n"
254 : :
255 : : "show port (port_id) macs|mcast_macs"
256 : : " Display list of mac addresses added to port.\n\n"
257 : :
258 : : "show port (port_id) flow transfer proxy\n"
259 : : " Display proxy port to manage transfer flows\n\n"
260 : :
261 : : "show port (port_id) fec capabilities"
262 : : " Show fec capabilities of a port.\n\n"
263 : :
264 : : "show port (port_id) fec_mode"
265 : : " Show fec mode of a port.\n\n"
266 : :
267 : : "show port (port_id) flow_ctrl"
268 : : " Show flow control info of a port.\n\n"
269 : :
270 : : "dump physmem\n"
271 : : " Dumps all physical memory segment layouts\n\n"
272 : :
273 : : "dump socket_mem\n"
274 : : " Dumps the memory usage of all sockets\n\n"
275 : :
276 : : "dump memzone\n"
277 : : " Dumps the layout of all memory zones\n\n"
278 : :
279 : : "dump struct_sizes\n"
280 : : " Dumps the size of all memory structures\n\n"
281 : :
282 : : "dump ring [name]\n"
283 : : " Dumps the status of all or specific element in DPDK rings\n\n"
284 : :
285 : : "dump mempool [name]\n"
286 : : " Dumps the statistics of all or specific memory pool\n\n"
287 : :
288 : : "dump devargs\n"
289 : : " Dumps the user device list\n\n"
290 : :
291 : : "dump lcores\n"
292 : : " Dumps the logical cores list\n\n"
293 : :
294 : : "dump trace\n"
295 : : " Dumps the tracing data to the folder according to the current EAL settings\n\n"
296 : :
297 : : "dump log_types\n"
298 : : " Dumps the log level for all the dpdk modules\n\n"
299 : :
300 : : "dump mbuf history all [file_name]\n"
301 : : " Dumps the mbuf history for all mempools\n\n"
302 : :
303 : : "dump mbuf history <mbuf_addr> [file_name]\n"
304 : : " Dumps the history for a specific mbuf (use 0x<address> format)\n\n"
305 : :
306 : : "dump mbuf pool history <mempool_name> [file_name]\n"
307 : : " Dumps the history for a specific mempool\n\n"
308 : :
309 : : "show port (port_id) speed_lanes capabilities"
310 : : " Show speed lanes capabilities of a port.\n\n"
311 : : );
312 : : }
313 : :
314 : 0 : if (show_all || !strcmp(res->section, "config")) {
315 : 0 : cmdline_printf(
316 : : cl,
317 : : "\n"
318 : : "Configuration:\n"
319 : : "--------------\n"
320 : : "Configuration changes only become active when"
321 : : " forwarding is started/restarted.\n\n"
322 : :
323 : : "set default\n"
324 : : " Reset forwarding to the default configuration.\n\n"
325 : :
326 : : "set verbose (level)\n"
327 : : " Set the debug verbosity level X.\n\n"
328 : :
329 : : "set log global|(type) (level)\n"
330 : : " Set the log level.\n\n"
331 : :
332 : : "set nbport (num)\n"
333 : : " Set number of ports.\n\n"
334 : :
335 : : "set nbcore (num)\n"
336 : : " Set number of cores.\n\n"
337 : :
338 : : "set coremask (mask)\n"
339 : : " Set the forwarding cores hexadecimal mask.\n\n"
340 : :
341 : : "set portmask (mask)\n"
342 : : " Set the forwarding ports hexadecimal mask.\n\n"
343 : :
344 : : "set burst (num)\n"
345 : : " Set number of packets per burst.\n\n"
346 : :
347 : : "set burst tx delay (microseconds) retry (num)\n"
348 : : " Set the transmit delay time and number of retries,"
349 : : " effective when retry is enabled.\n\n"
350 : :
351 : : "set rxoffs (x[,y]*)\n"
352 : : " Set the offset of each packet segment on"
353 : : " receiving if split feature is engaged."
354 : : " Affects only the queues configured with split"
355 : : " offloads.\n\n"
356 : :
357 : : "set rxpkts (x[,y]*)\n"
358 : : " Set the length of each segment to scatter"
359 : : " packets on receiving if split feature is engaged."
360 : : " Affects only the queues configured with split"
361 : : " offloads.\n\n"
362 : :
363 : : "set rxhdrs (eth[,ipv4])*\n"
364 : : " Set the protocol hdr of each segment to scatter"
365 : : " packets on receiving if split feature is engaged."
366 : : " Affects only the queues configured with split"
367 : : " offloads.\n"
368 : : " Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
369 : : "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
370 : : "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
371 : : "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
372 : : "inner-ipv4-sctp|inner-ipv6-sctp\n\n"
373 : :
374 : : "set txpkts (x[,y]*)\n"
375 : : " Set the length of each segment of TXONLY"
376 : : " and optionally CSUM packets.\n\n"
377 : :
378 : : "set txsplit (off|on|rand)\n"
379 : : " Set the split policy for the TX packets."
380 : : " Right now only applicable for CSUM and TXONLY"
381 : : " modes\n\n"
382 : :
383 : : "set txtimes (x, y)\n"
384 : : " Set the scheduling on timestamps"
385 : : " timings for the TXONLY mode\n\n"
386 : :
387 : : "set corelist (x[,y]*)\n"
388 : : " Set the list of forwarding cores.\n\n"
389 : :
390 : : "set portlist (x[,y]*)\n"
391 : : " Set the list of forwarding ports.\n\n"
392 : :
393 : : "set port setup on (iterator|event)\n"
394 : : " Select how attached port is retrieved for setup.\n\n"
395 : :
396 : : "set tx loopback (port_id) (on|off)\n"
397 : : " Enable or disable tx loopback.\n\n"
398 : :
399 : : "set all queues drop (port_id) (on|off)\n"
400 : : " Set drop enable bit for all queues.\n\n"
401 : :
402 : : "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
403 : : " Set MAC antispoof for a VF from the PF.\n\n"
404 : :
405 : : "vlan set stripq (on|off) (port_id,queue_id)\n"
406 : : " Set the VLAN strip for a queue on a port.\n\n"
407 : :
408 : : "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
409 : : " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
410 : :
411 : : "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
412 : : " Set VLAN insert for a VF from the PF.\n\n"
413 : :
414 : : "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
415 : : " Set VLAN antispoof for a VF from the PF.\n\n"
416 : :
417 : : "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
418 : : " Set the VLAN strip or filter or qinq strip or extend\n\n"
419 : :
420 : : "vlan set (inner|outer) tpid (value) (port_id)\n"
421 : : " Set the VLAN TPID for Packet Filtering on"
422 : : " a port\n\n"
423 : :
424 : : "rx_vlan add (vlan_id|all) (port_id)\n"
425 : : " Add a vlan_id, or all identifiers, to the set"
426 : : " of VLAN identifiers filtered by port_id.\n\n"
427 : :
428 : : "rx_vlan rm (vlan_id|all) (port_id)\n"
429 : : " Remove a vlan_id, or all identifiers, from the set"
430 : : " of VLAN identifiers filtered by port_id.\n\n"
431 : :
432 : : "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
433 : : " Add a vlan_id, to the set of VLAN identifiers"
434 : : "filtered for VF(s) from port_id.\n\n"
435 : :
436 : : "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
437 : : " Remove a vlan_id, to the set of VLAN identifiers"
438 : : "filtered for VF(s) from port_id.\n\n"
439 : :
440 : : "rx_vxlan_port add (udp_port) (port_id)\n"
441 : : " Add an UDP port for VXLAN packet filter on a port\n\n"
442 : :
443 : : "rx_vxlan_port rm (udp_port) (port_id)\n"
444 : : " Remove an UDP port for VXLAN packet filter on a port\n\n"
445 : :
446 : : "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
447 : : " Set hardware insertion of VLAN IDs (single or double VLAN "
448 : : "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
449 : :
450 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
451 : : " Set port based TX VLAN insertion.\n\n"
452 : :
453 : : "tx_vlan reset (port_id)\n"
454 : : " Disable hardware insertion of a VLAN header in"
455 : : " packets sent on a port.\n\n"
456 : :
457 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
458 : : " Select hardware or software calculation of the"
459 : : " checksum when transmitting a packet using the"
460 : : " csum forward engine.\n"
461 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
462 : : " outer-ip concerns the outer IP layer in"
463 : : " outer-udp concerns the outer UDP layer in"
464 : : " case the packet is recognized as a tunnel packet by"
465 : : " the forward engine (vxlan, gre and ipip are supported)\n"
466 : : " Please check the NIC datasheet for HW limits.\n\n"
467 : :
468 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
469 : : " If disabled, treat tunnel packets as non-tunneled"
470 : : " packets (treat inner headers as payload). The port\n"
471 : : " argument is the port used for TX in csum forward"
472 : : " engine.\n\n"
473 : :
474 : : "csum show (port_id)\n"
475 : : " Display tx checksum offload configuration\n\n"
476 : :
477 : : "tso set (segsize) (portid)\n"
478 : : " Enable TCP Segmentation Offload in csum forward"
479 : : " engine.\n"
480 : : " Please check the NIC datasheet for HW limits.\n\n"
481 : :
482 : : "tso show (portid)"
483 : : " Display the status of TCP Segmentation Offload.\n\n"
484 : :
485 : : #ifdef RTE_LIB_GRO
486 : : "set port (port_id) gro on|off\n"
487 : : " Enable or disable Generic Receive Offload in"
488 : : " csum forwarding engine.\n\n"
489 : :
490 : : "show port (port_id) gro\n"
491 : : " Display GRO configuration.\n\n"
492 : :
493 : : "set gro flush (cycles)\n"
494 : : " Set the cycle to flush GROed packets from"
495 : : " reassembly tables.\n\n"
496 : : #endif
497 : :
498 : : #ifdef RTE_LIB_GSO
499 : : "set port (port_id) gso (on|off)"
500 : : " Enable or disable Generic Segmentation Offload in"
501 : : " csum forwarding engine.\n\n"
502 : :
503 : : "set gso segsz (length)\n"
504 : : " Set max packet length for output GSO segments,"
505 : : " including packet header and payload.\n\n"
506 : :
507 : : "show port (port_id) gso\n"
508 : : " Show GSO configuration.\n\n"
509 : : #endif
510 : :
511 : : "set fwd (%s)\n"
512 : : " Set packet forwarding mode.\n\n"
513 : :
514 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
515 : : " Add a MAC address on port_id.\n\n"
516 : :
517 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
518 : : " Remove a MAC address from port_id.\n\n"
519 : :
520 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
521 : : " Set the default MAC address for port_id.\n\n"
522 : :
523 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
524 : : " Add a MAC address for a VF on the port.\n\n"
525 : :
526 : : "mcast_addr add (port_id) (mcast_addr)\n"
527 : : " Add a multicast MAC addresses on port_id.\n\n"
528 : :
529 : : "mcast_addr remove (port_id) (mcast_addr)\n"
530 : : " Remove a multicast MAC address from port_id.\n\n"
531 : :
532 : : "mcast_addr flush (port_id)\n"
533 : : " Flush all multicast MAC addresses on port_id.\n\n"
534 : :
535 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
536 : : " Set the MAC address for a VF from the PF.\n\n"
537 : :
538 : : "set eth-peer (port_id) (peer_addr)\n"
539 : : " set the peer address for certain port.\n\n"
540 : :
541 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
542 : : " Add/Remove a or all unicast hash filter(s)"
543 : : "from port X.\n\n"
544 : :
545 : : "set promisc (port_id|all) (on|off)\n"
546 : : " Set the promiscuous mode on port_id, or all.\n\n"
547 : :
548 : : "set allmulti (port_id|all) (on|off)\n"
549 : : " Set the allmulti mode on port_id, or all.\n\n"
550 : :
551 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
552 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
553 : : " (on|off) autoneg (on|off) (port_id)\n"
554 : : "set flow_ctrl rx (on|off) (portid)\n"
555 : : "set flow_ctrl tx (on|off) (portid)\n"
556 : : "set flow_ctrl high_water (high_water) (portid)\n"
557 : : "set flow_ctrl low_water (low_water) (portid)\n"
558 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
559 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
560 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
561 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
562 : : " Set the link flow control parameter on a port.\n\n"
563 : :
564 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
565 : : " (low_water) (pause_time) (priority) (port_id)\n"
566 : : " Set the priority flow control parameter on a"
567 : : " port.\n\n"
568 : :
569 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
570 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
571 : : " Set the queue priority flow control parameter on a"
572 : : " given Rx and Tx queues of a port.\n\n"
573 : :
574 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
575 : : " set available descriptors threshold for Rx queue\n\n"
576 : :
577 : : "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
578 : : " Set statistics mapping (qmapping 0..15) for RX/TX"
579 : : " queue on port.\n"
580 : : " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
581 : : " on port 0 to mapping 5.\n\n"
582 : :
583 : : "set xstats-hide-zero on|off\n"
584 : : " Set the option to hide the zero values"
585 : : " for xstats display.\n"
586 : :
587 : : "set record-core-cycles on|off\n"
588 : : " Set the option to enable measurement of CPU cycles.\n"
589 : :
590 : : "set record-burst-stats on|off\n"
591 : : " Set the option to enable display of RX and TX bursts.\n"
592 : :
593 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
594 : : " Enable/Disable a VF receive/transmit from a port\n\n"
595 : :
596 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
597 : : "|MPE) (on|off)\n"
598 : : " AUPE:accepts untagged VLAN;"
599 : : "ROPE:accept unicast hash\n\n"
600 : : " BAM:accepts broadcast packets;"
601 : : "MPE:accepts all multicast packets\n\n"
602 : : " Enable/Disable a VF receive mode of a port\n\n"
603 : :
604 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
605 : : " Set rate limit for a queue of a port\n\n"
606 : :
607 : : "set port (port_id) vf (vf_id) rate (rate_num) "
608 : : "queue_mask (queue_mask_value)\n"
609 : : " Set rate limit for queues in VF of a port\n\n"
610 : :
611 : : "set flush_rx (on|off)\n"
612 : : " Flush (default) or don't flush RX streams before"
613 : : " forwarding. Mainly used with PCAP drivers.\n\n"
614 : :
615 : : "set link-up port (port_id)\n"
616 : : " Set link up for a port.\n\n"
617 : :
618 : : "set link-down port (port_id)\n"
619 : : " Set link down for a port.\n\n"
620 : :
621 : : "set port (port_id) ptype_mask (ptype_mask)\n"
622 : : " set packet types classification for a specific port\n\n"
623 : :
624 : : "show port meter cap (port_id)\n"
625 : : " Show port meter capability information\n\n"
626 : :
627 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
628 : : " meter profile add - srtcm rfc 2697\n\n"
629 : :
630 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
631 : : " meter profile add - trtcm rfc 2698\n\n"
632 : :
633 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
634 : : " meter profile add - trtcm rfc 4115\n\n"
635 : :
636 : : "del port meter profile (port_id) (profile_id)\n"
637 : : " meter profile delete\n\n"
638 : :
639 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
640 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
641 : : "(dscp_tbl_entry63)]\n"
642 : : " meter create\n\n"
643 : :
644 : : "enable port meter (port_id) (mtr_id)\n"
645 : : " meter enable\n\n"
646 : :
647 : : "disable port meter (port_id) (mtr_id)\n"
648 : : " meter disable\n\n"
649 : :
650 : : "del port meter (port_id) (mtr_id)\n"
651 : : " meter delete\n\n"
652 : :
653 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
654 : : "y_actions (actions) r_actions (actions)\n"
655 : : " meter policy add\n\n"
656 : :
657 : : "del port meter policy (port_id) (policy_id)\n"
658 : : " meter policy delete\n\n"
659 : :
660 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
661 : : " meter update meter profile\n\n"
662 : :
663 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
664 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
665 : : " update meter dscp table entries\n\n"
666 : :
667 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
668 : : "(action0) [(action1) (action2)]\n"
669 : : " meter update policer action\n\n"
670 : :
671 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
672 : : " meter update stats\n\n"
673 : :
674 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
675 : : " set fec mode for a specific port\n\n"
676 : :
677 : : "show port cman capa (port_id)\n"
678 : : " Show congestion management capabilities\n\n"
679 : :
680 : : "show port cman config (port_id)\n"
681 : : " Show congestion management configuration\n\n"
682 : :
683 : : "set port cman config (port_id) (queue_id) default | "
684 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
685 : : "(max_thresh) (prob_inv)]\n"
686 : : " Set congestion management configuration\n\n"
687 : :
688 : : "set port (port_id) led (on|off)\n"
689 : : " Set a controllable LED associated with a certain"
690 : : " port on or off.\n\n"
691 : :
692 : : , list_pkt_forwarding_modes()
693 : : );
694 : : }
695 : :
696 : 0 : if (show_all || !strcmp(res->section, "ports")) {
697 : :
698 : 0 : cmdline_printf(
699 : : cl,
700 : : "\n"
701 : : "Port Operations:\n"
702 : : "----------------\n\n"
703 : :
704 : : "port start (port_id|all)\n"
705 : : " Start all ports or port_id.\n\n"
706 : :
707 : : "port stop (port_id|all)\n"
708 : : " Stop all ports or port_id.\n\n"
709 : :
710 : : "port close (port_id|all)\n"
711 : : " Close all ports or port_id.\n\n"
712 : :
713 : : "port reset (port_id|all)\n"
714 : : " Reset all ports or port_id.\n\n"
715 : :
716 : : "port attach (ident)\n"
717 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
718 : :
719 : : "port detach (port_id)\n"
720 : : " Detach physical or virtual dev by port_id\n\n"
721 : :
722 : : "port config (port_id|all)"
723 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|"
724 : : "100000|200000|400000|800000|auto)"
725 : : " duplex (half|full|auto)\n"
726 : : " Set speed and duplex for all ports or port_id\n\n"
727 : :
728 : : "port config (port_id|all) loopback (mode)\n"
729 : : " Set loopback mode for all ports or port_id\n\n"
730 : :
731 : : "port config all (rxq|txq|rxd|txd) (value)\n"
732 : : " Set number for rxq/txq/rxd/txd.\n\n"
733 : :
734 : : "port config all max-pkt-len (value)\n"
735 : : " Set the max packet length.\n\n"
736 : :
737 : : "port config all max-lro-pkt-size (value)\n"
738 : : " Set the max LRO aggregated packet size.\n\n"
739 : :
740 : : "port config all drop-en (on|off)\n"
741 : : " Enable or disable packet drop on all RX queues of all ports when no "
742 : : "receive buffers available.\n\n"
743 : :
744 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
745 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
746 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
747 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
748 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
749 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
750 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
751 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
752 : : " Set the RSS mode.\n\n"
753 : :
754 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
755 : : " Set the RSS redirection table.\n\n"
756 : :
757 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
758 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
759 : : " Set the RSS hash algorithm.\n\n"
760 : :
761 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
762 : : " pfc (on|off)\n"
763 : : " Set the DCB mode.\n\n"
764 : :
765 : : "port config all burst (value)\n"
766 : : " Set the number of packets per burst.\n\n"
767 : :
768 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
769 : : " (value)\n"
770 : : " Set the ring prefetch/host/writeback threshold"
771 : : " for tx/rx queue.\n\n"
772 : :
773 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
774 : : " Set free threshold for rx/tx, or set"
775 : : " tx rs bit threshold.\n\n"
776 : : "port config mtu X value\n"
777 : : " Set the MTU of port X to a given value\n\n"
778 : :
779 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
780 : : " Set a rx/tx queue's ring size configuration, the new"
781 : : " value will take effect after command that (re-)start the port"
782 : : " or command that setup the specific queue\n\n"
783 : :
784 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
785 : : " Start/stop a rx/tx queue of port X. Only take effect"
786 : : " when port X is started\n\n"
787 : :
788 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
789 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
790 : : " take effect when port X is stopped.\n\n"
791 : :
792 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
793 : : " Setup a rx/tx queue of port X.\n\n"
794 : :
795 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
796 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
797 : :
798 : : "port config (port_id|all) rx_offload all|vlan_strip|"
799 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
800 : : "outer_ipv4_cksum|macsec_strip|"
801 : : "vlan_filter|vlan_extend|scatter|"
802 : : "buffer_split|timestamp|security|keep_crc on|off\n"
803 : : " Enable or disable a per port Rx offloading"
804 : : " on all Rx queues of a port\n\n"
805 : :
806 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
807 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
808 : : "outer_ipv4_cksum|macsec_strip|"
809 : : "vlan_filter|vlan_extend|scatter|"
810 : : "buffer_split|timestamp|security|keep_crc on|off\n"
811 : : " Enable or disable a per queue Rx offloading"
812 : : " only on a specific Rx queue\n\n"
813 : :
814 : : "port config (port_id|all) tx_offload all|vlan_insert|"
815 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
816 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
817 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
818 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
819 : : "security on|off\n"
820 : : " Enable or disable a per port Tx offloading"
821 : : " on all Tx queues of a port\n\n"
822 : :
823 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
824 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
825 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
826 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
827 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
828 : : " on|off\n"
829 : : " Enable or disable a per queue Tx offloading"
830 : : " only on a specific Tx queue\n\n"
831 : :
832 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
833 : : " Load an eBPF program as a callback"
834 : : " for particular RX/TX queue\n\n"
835 : :
836 : : "bpf-unload rx|tx (port) (queue)\n"
837 : : " Unload previously loaded eBPF program"
838 : : " for particular RX/TX queue\n\n"
839 : :
840 : : "port config (port_id) tx_metadata (value)\n"
841 : : " Set Tx metadata value per port. Testpmd will add this value"
842 : : " to any Tx packet sent from this port\n\n"
843 : :
844 : : "port config (port_id) dynf (name) set|clear\n"
845 : : " Register a dynf and Set/clear this flag on Tx. "
846 : : "Testpmd will set this value to any Tx packet "
847 : : "sent from this port\n\n"
848 : :
849 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
850 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
851 : :
852 : : "port config (port_id) txq (queue_id) affinity (value)\n"
853 : : " Map a Tx queue with an aggregated port "
854 : : "of the DPDK port\n\n"
855 : :
856 : : "port config (port_id|all) speed_lanes (value)\n"
857 : : " Set number of lanes for all ports or port_id for a forced speed\n\n"
858 : : );
859 : : }
860 : :
861 : 0 : if (show_all || !strcmp(res->section, "filters")) {
862 : :
863 : 0 : cmdline_printf(
864 : : cl,
865 : : "\n"
866 : : "filters:\n"
867 : : "--------\n\n"
868 : :
869 : : "flow validate {port_id}"
870 : : " [group {group_id}] [priority {level}]"
871 : : " [ingress] [egress]"
872 : : " pattern {item} [/ {item} [...]] / end"
873 : : " actions {action} [/ {action} [...]] / end\n"
874 : : " Check whether a flow rule can be created.\n\n"
875 : :
876 : : "flow create {port_id}"
877 : : " [group {group_id}] [priority {level}]"
878 : : " [ingress] [egress]"
879 : : " pattern {item} [/ {item} [...]] / end"
880 : : " actions {action} [/ {action} [...]] / end\n"
881 : : " Create a flow rule.\n\n"
882 : :
883 : : "flow destroy {port_id} rule {rule_id} [...]\n"
884 : : " Destroy specific flow rules.\n\n"
885 : :
886 : : "flow update {port_id} {rule_id}"
887 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
888 : : " Update a flow rule with new actions.\n\n"
889 : :
890 : : "flow flush {port_id}\n"
891 : : " Destroy all flow rules.\n\n"
892 : :
893 : : "flow query {port_id} {rule_id} {action}\n"
894 : : " Query an existing flow rule.\n\n"
895 : :
896 : : "flow list {port_id} [group {group_id}] [...]\n"
897 : : " List existing flow rules sorted by priority,"
898 : : " filtered by group identifiers.\n\n"
899 : :
900 : : "flow isolate {port_id} {boolean}\n"
901 : : " Restrict ingress traffic to the defined"
902 : : " flow rules\n\n"
903 : :
904 : : "flow aged {port_id} [destroy]\n"
905 : : " List and destroy aged flows"
906 : : " flow rules\n\n"
907 : :
908 : : "flow indirect_action {port_id} create"
909 : : " [action_id {indirect_action_id}]"
910 : : " [ingress] [egress]"
911 : : " action {action} / end\n"
912 : : " Create indirect action.\n\n"
913 : :
914 : : "flow indirect_action {port_id} update"
915 : : " {indirect_action_id} action {action} / end\n"
916 : : " Update indirect action.\n\n"
917 : :
918 : : "flow indirect_action {port_id} destroy"
919 : : " action_id {indirect_action_id} [...]\n"
920 : : " Destroy specific indirect actions.\n\n"
921 : :
922 : : "flow indirect_action {port_id} query"
923 : : " {indirect_action_id}\n"
924 : : " Query an existing indirect action.\n\n"
925 : :
926 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
927 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
928 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
929 : : " Configure the VXLAN encapsulation for flows.\n\n"
930 : :
931 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
932 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
933 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
934 : : " eth-dst (eth-dst)\n"
935 : : " Configure the VXLAN encapsulation for flows.\n\n"
936 : :
937 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
938 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
939 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
940 : : " eth-dst (eth-dst)\n"
941 : : " Configure the VXLAN encapsulation for flows.\n\n"
942 : :
943 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
944 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
945 : : " (eth-dst)\n"
946 : : " Configure the NVGRE encapsulation for flows.\n\n"
947 : :
948 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
949 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
950 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
951 : : " Configure the NVGRE encapsulation for flows.\n\n"
952 : :
953 : : "set raw_encap {flow items}\n"
954 : : " Configure the encapsulation with raw data.\n\n"
955 : :
956 : : "set raw_decap {flow items}\n"
957 : : " Configure the decapsulation with raw data.\n\n"
958 : :
959 : : );
960 : : }
961 : :
962 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
963 : 0 : cmdline_printf(
964 : : cl,
965 : : "\n"
966 : : "Traffic Management:\n"
967 : : "--------------\n"
968 : : "show port tm cap (port_id)\n"
969 : : " Display the port TM capability.\n\n"
970 : :
971 : : "show port tm level cap (port_id) (level_id)\n"
972 : : " Display the port TM hierarchical level capability.\n\n"
973 : :
974 : : "show port tm node cap (port_id) (node_id)\n"
975 : : " Display the port TM node capability.\n\n"
976 : :
977 : : "show port tm node type (port_id) (node_id)\n"
978 : : " Display the port TM node type.\n\n"
979 : :
980 : : "show port tm node stats (port_id) (node_id) (clear)\n"
981 : : " Display the port TM node stats.\n\n"
982 : :
983 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
984 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
985 : : " (packet_length_adjust) (packet_mode)\n"
986 : : " Add port tm node private shaper profile.\n\n"
987 : :
988 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
989 : : " Delete port tm node private shaper profile.\n\n"
990 : :
991 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
992 : : " (shaper_profile_id)\n"
993 : : " Add/update port tm node shared shaper.\n\n"
994 : :
995 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
996 : : " Delete port tm node shared shaper.\n\n"
997 : :
998 : : "set port tm node shaper profile (port_id) (node_id)"
999 : : " (shaper_profile_id)\n"
1000 : : " Set port tm node shaper profile.\n\n"
1001 : :
1002 : : "add port tm node wred profile (port_id) (wred_profile_id)"
1003 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1004 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1005 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1006 : : " Add port tm node wred profile.\n\n"
1007 : :
1008 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
1009 : : " Delete port tm node wred profile.\n\n"
1010 : :
1011 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1012 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1013 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1014 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1015 : : " Add port tm nonleaf node.\n\n"
1016 : :
1017 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1018 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1019 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1020 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1021 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
1022 : :
1023 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1024 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1025 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1026 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1027 : : " Add port tm leaf node.\n\n"
1028 : :
1029 : : "del port tm node (port_id) (node_id)\n"
1030 : : " Delete port tm node.\n\n"
1031 : :
1032 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1033 : : " (priority) (weight)\n"
1034 : : " Set port tm node parent.\n\n"
1035 : :
1036 : : "suspend port tm node (port_id) (node_id)"
1037 : : " Suspend tm node.\n\n"
1038 : :
1039 : : "resume port tm node (port_id) (node_id)"
1040 : : " Resume tm node.\n\n"
1041 : :
1042 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1043 : : " Commit tm hierarchy.\n\n"
1044 : :
1045 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1046 : : " (red)\n"
1047 : : " Enables/Disables the traffic management marking"
1048 : : " for IP ECN (Explicit Congestion Notification)"
1049 : : " packets on a given port\n\n"
1050 : :
1051 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1052 : : " (red)\n"
1053 : : " Enables/Disables the traffic management marking"
1054 : : " on the port for IP dscp packets\n\n"
1055 : :
1056 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1057 : : " (red)\n"
1058 : : " Enables/Disables the traffic management marking"
1059 : : " on the port for VLAN packets with DEI enabled\n\n"
1060 : : );
1061 : : }
1062 : :
1063 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1064 : 0 : cmdline_printf(
1065 : : cl,
1066 : : "\n"
1067 : : "Device Operations:\n"
1068 : : "--------------\n"
1069 : : "device detach (identifier)\n"
1070 : : " Detach device by identifier.\n\n"
1071 : : );
1072 : : }
1073 : :
1074 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1075 : : struct testpmd_driver_commands *c;
1076 : : unsigned int i;
1077 : :
1078 : 0 : cmdline_printf(
1079 : : cl,
1080 : : "\n"
1081 : : "Driver specific:\n"
1082 : : "----------------\n"
1083 : : );
1084 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1085 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1086 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1087 : : }
1088 : : }
1089 : 0 : }
1090 : :
1091 : : static cmdline_parse_token_string_t cmd_help_long_help =
1092 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1093 : :
1094 : : static cmdline_parse_token_string_t cmd_help_long_section =
1095 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1096 : : "all#control#display#config#ports#"
1097 : : "filters#traffic_management#devices#drivers");
1098 : :
1099 : : static cmdline_parse_inst_t cmd_help_long = {
1100 : : .f = cmd_help_long_parsed,
1101 : : .data = NULL,
1102 : : .help_str = "help all|control|display|config|ports|"
1103 : : "filters|traffic_management|devices|drivers: "
1104 : : "Show help",
1105 : : .tokens = {
1106 : : (void *)&cmd_help_long_help,
1107 : : (void *)&cmd_help_long_section,
1108 : : NULL,
1109 : : },
1110 : : };
1111 : :
1112 : :
1113 : : /* *** start/stop/close all ports *** */
1114 : : struct cmd_operate_port_result {
1115 : : cmdline_fixed_string_t keyword;
1116 : : cmdline_fixed_string_t name;
1117 : : cmdline_fixed_string_t value;
1118 : : };
1119 : :
1120 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1121 : : __rte_unused struct cmdline *cl,
1122 : : __rte_unused void *data)
1123 : : {
1124 : : struct cmd_operate_port_result *res = parsed_result;
1125 : :
1126 : 0 : if (!strcmp(res->name, "start"))
1127 : 0 : start_port(RTE_PORT_ALL);
1128 : 0 : else if (!strcmp(res->name, "stop"))
1129 : 0 : stop_port(RTE_PORT_ALL);
1130 : 0 : else if (!strcmp(res->name, "close"))
1131 : 0 : close_port(RTE_PORT_ALL);
1132 : 0 : else if (!strcmp(res->name, "reset"))
1133 : 0 : reset_port(RTE_PORT_ALL);
1134 : : else
1135 : 0 : fprintf(stderr, "Unknown parameter\n");
1136 : 0 : }
1137 : :
1138 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1139 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1140 : : "port");
1141 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1142 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1143 : : "start#stop#close#reset");
1144 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1145 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1146 : :
1147 : : static cmdline_parse_inst_t cmd_operate_port = {
1148 : : .f = cmd_operate_port_parsed,
1149 : : .data = NULL,
1150 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1151 : : .tokens = {
1152 : : (void *)&cmd_operate_port_all_cmd,
1153 : : (void *)&cmd_operate_port_all_port,
1154 : : (void *)&cmd_operate_port_all_all,
1155 : : NULL,
1156 : : },
1157 : : };
1158 : :
1159 : : /* *** start/stop/close specific port *** */
1160 : : struct cmd_operate_specific_port_result {
1161 : : cmdline_fixed_string_t keyword;
1162 : : cmdline_fixed_string_t name;
1163 : : uint8_t value;
1164 : : };
1165 : :
1166 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1167 : : __rte_unused struct cmdline *cl,
1168 : : __rte_unused void *data)
1169 : : {
1170 : : struct cmd_operate_specific_port_result *res = parsed_result;
1171 : :
1172 : 0 : if (!strcmp(res->name, "start"))
1173 : 0 : start_port(res->value);
1174 : 0 : else if (!strcmp(res->name, "stop"))
1175 : 0 : stop_port(res->value);
1176 : 0 : else if (!strcmp(res->name, "close"))
1177 : 0 : close_port(res->value);
1178 : 0 : else if (!strcmp(res->name, "reset"))
1179 : 0 : reset_port(res->value);
1180 : : else
1181 : 0 : fprintf(stderr, "Unknown parameter\n");
1182 : 0 : }
1183 : :
1184 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1185 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1186 : : keyword, "port");
1187 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1188 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1189 : : name, "start#stop#close#reset");
1190 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1191 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1192 : : value, RTE_UINT8);
1193 : :
1194 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1195 : : .f = cmd_operate_specific_port_parsed,
1196 : : .data = NULL,
1197 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1198 : : .tokens = {
1199 : : (void *)&cmd_operate_specific_port_cmd,
1200 : : (void *)&cmd_operate_specific_port_port,
1201 : : (void *)&cmd_operate_specific_port_id,
1202 : : NULL,
1203 : : },
1204 : : };
1205 : :
1206 : : /* *** enable port setup (after attach) via iterator or event *** */
1207 : : struct cmd_set_port_setup_on_result {
1208 : : cmdline_fixed_string_t set;
1209 : : cmdline_fixed_string_t port;
1210 : : cmdline_fixed_string_t setup;
1211 : : cmdline_fixed_string_t on;
1212 : : cmdline_fixed_string_t mode;
1213 : : };
1214 : :
1215 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1216 : : __rte_unused struct cmdline *cl,
1217 : : __rte_unused void *data)
1218 : : {
1219 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1220 : :
1221 : 0 : if (strcmp(res->mode, "event") == 0)
1222 : 0 : setup_on_probe_event = true;
1223 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1224 : 0 : setup_on_probe_event = false;
1225 : : else
1226 : 0 : fprintf(stderr, "Unknown mode\n");
1227 : 0 : }
1228 : :
1229 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1230 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1231 : : set, "set");
1232 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1233 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1234 : : port, "port");
1235 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1236 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1237 : : setup, "setup");
1238 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1239 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1240 : : on, "on");
1241 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1242 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1243 : : mode, "iterator#event");
1244 : :
1245 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1246 : : .f = cmd_set_port_setup_on_parsed,
1247 : : .data = NULL,
1248 : : .help_str = "set port setup on iterator|event",
1249 : : .tokens = {
1250 : : (void *)&cmd_set_port_setup_on_set,
1251 : : (void *)&cmd_set_port_setup_on_port,
1252 : : (void *)&cmd_set_port_setup_on_setup,
1253 : : (void *)&cmd_set_port_setup_on_on,
1254 : : (void *)&cmd_set_port_setup_on_mode,
1255 : : NULL,
1256 : : },
1257 : : };
1258 : :
1259 : : /* *** attach a specified port *** */
1260 : : struct cmd_operate_attach_port_result {
1261 : : cmdline_fixed_string_t port;
1262 : : cmdline_fixed_string_t keyword;
1263 : : cmdline_multi_string_t identifier;
1264 : : };
1265 : :
1266 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1267 : : __rte_unused struct cmdline *cl,
1268 : : __rte_unused void *data)
1269 : : {
1270 : : struct cmd_operate_attach_port_result *res = parsed_result;
1271 : :
1272 : 0 : if (!strcmp(res->keyword, "attach"))
1273 : 0 : attach_port(res->identifier);
1274 : : else
1275 : 0 : fprintf(stderr, "Unknown parameter\n");
1276 : 0 : }
1277 : :
1278 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1279 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1280 : : port, "port");
1281 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1282 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1283 : : keyword, "attach");
1284 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1285 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1286 : : identifier, TOKEN_STRING_MULTI);
1287 : :
1288 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1289 : : .f = cmd_operate_attach_port_parsed,
1290 : : .data = NULL,
1291 : : .help_str = "port attach <identifier>: "
1292 : : "(identifier: pci address or virtual dev name)",
1293 : : .tokens = {
1294 : : (void *)&cmd_operate_attach_port_port,
1295 : : (void *)&cmd_operate_attach_port_keyword,
1296 : : (void *)&cmd_operate_attach_port_identifier,
1297 : : NULL,
1298 : : },
1299 : : };
1300 : :
1301 : : /* *** detach a specified port *** */
1302 : : struct cmd_operate_detach_port_result {
1303 : : cmdline_fixed_string_t port;
1304 : : cmdline_fixed_string_t keyword;
1305 : : portid_t port_id;
1306 : : };
1307 : :
1308 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1309 : : __rte_unused struct cmdline *cl,
1310 : : __rte_unused void *data)
1311 : : {
1312 : : struct cmd_operate_detach_port_result *res = parsed_result;
1313 : :
1314 : 0 : if (!strcmp(res->keyword, "detach")) {
1315 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1316 : 0 : detach_port_device(res->port_id);
1317 : : } else {
1318 : 0 : fprintf(stderr, "Unknown parameter\n");
1319 : : }
1320 : : }
1321 : :
1322 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1323 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1324 : : port, "port");
1325 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1326 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1327 : : keyword, "detach");
1328 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1329 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1330 : : port_id, RTE_UINT16);
1331 : :
1332 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1333 : : .f = cmd_operate_detach_port_parsed,
1334 : : .data = NULL,
1335 : : .help_str = "port detach <port_id>",
1336 : : .tokens = {
1337 : : (void *)&cmd_operate_detach_port_port,
1338 : : (void *)&cmd_operate_detach_port_keyword,
1339 : : (void *)&cmd_operate_detach_port_port_id,
1340 : : NULL,
1341 : : },
1342 : : };
1343 : :
1344 : : /* *** detach device by identifier *** */
1345 : : struct cmd_operate_detach_device_result {
1346 : : cmdline_fixed_string_t device;
1347 : : cmdline_fixed_string_t keyword;
1348 : : cmdline_fixed_string_t identifier;
1349 : : };
1350 : :
1351 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1352 : : __rte_unused struct cmdline *cl,
1353 : : __rte_unused void *data)
1354 : : {
1355 : : struct cmd_operate_detach_device_result *res = parsed_result;
1356 : :
1357 : 0 : if (!strcmp(res->keyword, "detach"))
1358 : 0 : detach_devargs(res->identifier);
1359 : : else
1360 : 0 : fprintf(stderr, "Unknown parameter\n");
1361 : 0 : }
1362 : :
1363 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1364 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1365 : : device, "device");
1366 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1367 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1368 : : keyword, "detach");
1369 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1370 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1371 : : identifier, NULL);
1372 : :
1373 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1374 : : .f = cmd_operate_detach_device_parsed,
1375 : : .data = NULL,
1376 : : .help_str = "device detach <identifier>:"
1377 : : "(identifier: pci address or virtual dev name)",
1378 : : .tokens = {
1379 : : (void *)&cmd_operate_detach_device_device,
1380 : : (void *)&cmd_operate_detach_device_keyword,
1381 : : (void *)&cmd_operate_detach_device_identifier,
1382 : : NULL,
1383 : : },
1384 : : };
1385 : : /* *** configure speed for all ports *** */
1386 : : struct cmd_config_speed_all {
1387 : : cmdline_fixed_string_t port;
1388 : : cmdline_fixed_string_t keyword;
1389 : : cmdline_fixed_string_t all;
1390 : : cmdline_fixed_string_t item1;
1391 : : cmdline_fixed_string_t item2;
1392 : : cmdline_fixed_string_t value1;
1393 : : cmdline_fixed_string_t value2;
1394 : : };
1395 : :
1396 : : static int
1397 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1398 : : {
1399 : :
1400 : : int duplex;
1401 : :
1402 : 0 : if (!strcmp(duplexstr, "half")) {
1403 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1404 : 0 : } else if (!strcmp(duplexstr, "full")) {
1405 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1406 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1407 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1408 : : } else {
1409 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1410 : 0 : return -1;
1411 : : }
1412 : :
1413 : 0 : if (!strcmp(speedstr, "10")) {
1414 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1415 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1416 : 0 : } else if (!strcmp(speedstr, "100")) {
1417 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1418 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1419 : : } else {
1420 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1421 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1422 : 0 : return -1;
1423 : : }
1424 : 0 : if (!strcmp(speedstr, "1000")) {
1425 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1426 : 0 : } else if (!strcmp(speedstr, "2500")) {
1427 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1428 : 0 : } else if (!strcmp(speedstr, "5000")) {
1429 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1430 : 0 : } else if (!strcmp(speedstr, "10000")) {
1431 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1432 : 0 : } else if (!strcmp(speedstr, "25000")) {
1433 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1434 : 0 : } else if (!strcmp(speedstr, "40000")) {
1435 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1436 : 0 : } else if (!strcmp(speedstr, "50000")) {
1437 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1438 : 0 : } else if (!strcmp(speedstr, "100000")) {
1439 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1440 : 0 : } else if (!strcmp(speedstr, "200000")) {
1441 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1442 : 0 : } else if (!strcmp(speedstr, "400000")) {
1443 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1444 : 0 : } else if (!strcmp(speedstr, "800000")) {
1445 : 0 : *speed = RTE_ETH_LINK_SPEED_800G;
1446 : 0 : } else if (!strcmp(speedstr, "auto")) {
1447 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1448 : : } else {
1449 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1450 : 0 : return -1;
1451 : : }
1452 : : }
1453 : :
1454 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1455 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1456 : :
1457 : : return 0;
1458 : : }
1459 : :
1460 : : static void
1461 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1462 : : __rte_unused struct cmdline *cl,
1463 : : __rte_unused void *data)
1464 : : {
1465 : : struct cmd_config_speed_all *res = parsed_result;
1466 : : uint32_t link_speed;
1467 : : portid_t pid;
1468 : :
1469 : 0 : if (!all_ports_stopped()) {
1470 : 0 : fprintf(stderr, "Please stop all ports first\n");
1471 : 0 : return;
1472 : : }
1473 : :
1474 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1475 : : &link_speed) < 0)
1476 : : return;
1477 : :
1478 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1479 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1480 : : }
1481 : :
1482 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1483 : : }
1484 : :
1485 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1486 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1487 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1488 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1489 : : "config");
1490 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1491 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1492 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1493 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1494 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1495 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1496 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1497 : : "100000#200000#400000#800000#auto");
1498 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1499 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1500 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1501 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1502 : : "half#full#auto");
1503 : :
1504 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1505 : : .f = cmd_config_speed_all_parsed,
1506 : : .data = NULL,
1507 : : .help_str = "port config all speed "
1508 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1509 : : "100000|200000|400000|800000|auto "
1510 : : "duplex half|full|auto",
1511 : : .tokens = {
1512 : : (void *)&cmd_config_speed_all_port,
1513 : : (void *)&cmd_config_speed_all_keyword,
1514 : : (void *)&cmd_config_speed_all_all,
1515 : : (void *)&cmd_config_speed_all_item1,
1516 : : (void *)&cmd_config_speed_all_value1,
1517 : : (void *)&cmd_config_speed_all_item2,
1518 : : (void *)&cmd_config_speed_all_value2,
1519 : : NULL,
1520 : : },
1521 : : };
1522 : :
1523 : : /* *** configure speed for specific port *** */
1524 : : struct cmd_config_speed_specific {
1525 : : cmdline_fixed_string_t port;
1526 : : cmdline_fixed_string_t keyword;
1527 : : portid_t id;
1528 : : cmdline_fixed_string_t item1;
1529 : : cmdline_fixed_string_t item2;
1530 : : cmdline_fixed_string_t value1;
1531 : : cmdline_fixed_string_t value2;
1532 : : };
1533 : :
1534 : : static void
1535 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1536 : : __rte_unused struct cmdline *cl,
1537 : : __rte_unused void *data)
1538 : : {
1539 : : struct cmd_config_speed_specific *res = parsed_result;
1540 : : uint32_t link_speed;
1541 : :
1542 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1543 : 0 : return;
1544 : :
1545 : 0 : if (!port_is_stopped(res->id)) {
1546 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1547 : 0 : return;
1548 : : }
1549 : :
1550 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1551 : : &link_speed) < 0)
1552 : : return;
1553 : :
1554 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1555 : :
1556 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1557 : : }
1558 : :
1559 : :
1560 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1561 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1562 : : "port");
1563 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1564 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1565 : : "config");
1566 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1567 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1568 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1569 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1570 : : "speed");
1571 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1572 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1573 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1574 : : "100000#200000#400000#800000#auto");
1575 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1576 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1577 : : "duplex");
1578 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1579 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1580 : : "half#full#auto");
1581 : :
1582 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1583 : : .f = cmd_config_speed_specific_parsed,
1584 : : .data = NULL,
1585 : : .help_str = "port config <port_id> speed "
1586 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1587 : : "100000|200000|400000|800000|auto "
1588 : : "duplex half|full|auto",
1589 : : .tokens = {
1590 : : (void *)&cmd_config_speed_specific_port,
1591 : : (void *)&cmd_config_speed_specific_keyword,
1592 : : (void *)&cmd_config_speed_specific_id,
1593 : : (void *)&cmd_config_speed_specific_item1,
1594 : : (void *)&cmd_config_speed_specific_value1,
1595 : : (void *)&cmd_config_speed_specific_item2,
1596 : : (void *)&cmd_config_speed_specific_value2,
1597 : : NULL,
1598 : : },
1599 : : };
1600 : :
1601 : : static int
1602 : 0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
1603 : : {
1604 : : int ret;
1605 : :
1606 : 0 : ret = rte_eth_speed_lanes_set(pid, lanes);
1607 : 0 : if (ret == -ENOTSUP) {
1608 : 0 : fprintf(stderr, "Function not implemented\n");
1609 : 0 : return -1;
1610 : 0 : } else if (ret < 0) {
1611 : 0 : fprintf(stderr, "Set speed lanes failed\n");
1612 : 0 : return -1;
1613 : : }
1614 : :
1615 : : return 0;
1616 : : }
1617 : :
1618 : : static void
1619 : 0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
1620 : : {
1621 : : unsigned int i;
1622 : : uint32_t capa;
1623 : :
1624 : : printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
1625 : : printf("\n-----------------------------------\n");
1626 : 0 : for (i = 0; i < num; i++) {
1627 : 0 : printf("%-17s ",
1628 : 0 : rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
1629 : 0 : capa = speed_lanes_capa[i].capa;
1630 : : int s = 0;
1631 : :
1632 : 0 : while (capa) {
1633 : 0 : if (capa & 0x1)
1634 : : printf("%-2d ", s);
1635 : 0 : s++;
1636 : 0 : capa = capa >> 1;
1637 : : }
1638 : : printf("\n");
1639 : : }
1640 : 0 : }
1641 : :
1642 : : /* *** display speed lanes per port capabilities *** */
1643 : : struct cmd_show_speed_lanes_result {
1644 : : cmdline_fixed_string_t cmd_show;
1645 : : cmdline_fixed_string_t cmd_port;
1646 : : cmdline_fixed_string_t cmd_keyword;
1647 : : portid_t cmd_pid;
1648 : : };
1649 : :
1650 : : static void
1651 : 0 : cmd_show_speed_lanes_parsed(void *parsed_result,
1652 : : __rte_unused struct cmdline *cl,
1653 : : __rte_unused void *data)
1654 : : {
1655 : : struct cmd_show_speed_lanes_result *res = parsed_result;
1656 : : struct rte_eth_speed_lanes_capa *speed_lanes_capa;
1657 : : unsigned int num;
1658 : : int ret;
1659 : :
1660 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
1661 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
1662 : 0 : return;
1663 : : }
1664 : :
1665 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
1666 : 0 : if (ret == -ENOTSUP) {
1667 : 0 : fprintf(stderr, "Function not implemented\n");
1668 : 0 : return;
1669 : 0 : } else if (ret < 0) {
1670 : 0 : fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
1671 : 0 : return;
1672 : : }
1673 : :
1674 : 0 : num = (unsigned int)ret;
1675 : 0 : speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
1676 : 0 : if (speed_lanes_capa == NULL) {
1677 : 0 : fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
1678 : 0 : return;
1679 : : }
1680 : :
1681 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
1682 : 0 : if (ret < 0) {
1683 : 0 : fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
1684 : 0 : goto out;
1685 : : }
1686 : :
1687 : 0 : show_speed_lanes_capability(num, speed_lanes_capa);
1688 : 0 : out:
1689 : 0 : free(speed_lanes_capa);
1690 : : }
1691 : :
1692 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
1693 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1694 : : cmd_show, "show");
1695 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
1696 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1697 : : cmd_port, "port");
1698 : : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
1699 : : TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
1700 : : cmd_pid, RTE_UINT16);
1701 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
1702 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1703 : : cmd_keyword, "speed_lanes");
1704 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
1705 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1706 : : cmd_keyword, "capabilities");
1707 : :
1708 : : static cmdline_parse_inst_t cmd_show_speed_lanes = {
1709 : : .f = cmd_show_speed_lanes_parsed,
1710 : : .data = NULL,
1711 : : .help_str = "show port <port_id> speed_lanes capabilities",
1712 : : .tokens = {
1713 : : (void *)&cmd_show_speed_lanes_show,
1714 : : (void *)&cmd_show_speed_lanes_port,
1715 : : (void *)&cmd_show_speed_lanes_pid,
1716 : : (void *)&cmd_show_speed_lanes_keyword,
1717 : : (void *)&cmd_show_speed_lanes_cap_keyword,
1718 : : NULL,
1719 : : },
1720 : : };
1721 : :
1722 : : /* *** configure speed_lanes for all ports *** */
1723 : : struct cmd_config_speed_lanes_all {
1724 : : cmdline_fixed_string_t port;
1725 : : cmdline_fixed_string_t keyword;
1726 : : cmdline_fixed_string_t all;
1727 : : cmdline_fixed_string_t item;
1728 : : uint32_t lanes;
1729 : : };
1730 : :
1731 : : static void
1732 : 0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
1733 : : __rte_unused struct cmdline *cl,
1734 : : __rte_unused void *data)
1735 : : {
1736 : : struct cmd_config_speed_lanes_all *res = parsed_result;
1737 : : portid_t pid;
1738 : :
1739 : 0 : if (!all_ports_stopped()) {
1740 : 0 : fprintf(stderr, "Please stop all ports first\n");
1741 : 0 : return;
1742 : : }
1743 : :
1744 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1745 : 0 : if (parse_speed_lanes_cfg(pid, res->lanes))
1746 : : return;
1747 : : }
1748 : :
1749 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1750 : : }
1751 : :
1752 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
1753 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
1754 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
1755 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
1756 : : "config");
1757 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
1758 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
1759 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
1760 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
1761 : : "speed_lanes");
1762 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
1763 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
1764 : :
1765 : : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
1766 : : .f = cmd_config_speed_lanes_all_parsed,
1767 : : .data = NULL,
1768 : : .help_str = "port config all speed_lanes <value>",
1769 : : .tokens = {
1770 : : (void *)&cmd_config_speed_lanes_all_port,
1771 : : (void *)&cmd_config_speed_lanes_all_keyword,
1772 : : (void *)&cmd_config_speed_lanes_all_all,
1773 : : (void *)&cmd_config_speed_lanes_all_item,
1774 : : (void *)&cmd_config_speed_lanes_all_lanes,
1775 : : NULL,
1776 : : },
1777 : : };
1778 : :
1779 : : /* *** configure speed_lanes for specific port *** */
1780 : : struct cmd_config_speed_lanes_specific {
1781 : : cmdline_fixed_string_t port;
1782 : : cmdline_fixed_string_t keyword;
1783 : : uint16_t port_id;
1784 : : cmdline_fixed_string_t item;
1785 : : uint32_t lanes;
1786 : : };
1787 : :
1788 : : static void
1789 : 0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
1790 : : __rte_unused struct cmdline *cl,
1791 : : __rte_unused void *data)
1792 : : {
1793 : : struct cmd_config_speed_lanes_specific *res = parsed_result;
1794 : :
1795 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1796 : : return;
1797 : :
1798 : 0 : if (!port_is_stopped(res->port_id)) {
1799 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1800 : 0 : return;
1801 : : }
1802 : :
1803 : 0 : if (parse_speed_lanes_cfg(res->port_id, res->lanes))
1804 : : return;
1805 : :
1806 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1807 : : }
1808 : :
1809 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
1810 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
1811 : : "port");
1812 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
1813 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
1814 : : "config");
1815 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
1816 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
1817 : : RTE_UINT16);
1818 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
1819 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
1820 : : "speed_lanes");
1821 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
1822 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
1823 : : RTE_UINT32);
1824 : :
1825 : : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
1826 : : .f = cmd_config_speed_lanes_specific_parsed,
1827 : : .data = NULL,
1828 : : .help_str = "port config <port_id> speed_lanes <value>",
1829 : : .tokens = {
1830 : : (void *)&cmd_config_speed_lanes_specific_port,
1831 : : (void *)&cmd_config_speed_lanes_specific_keyword,
1832 : : (void *)&cmd_config_speed_lanes_specific_id,
1833 : : (void *)&cmd_config_speed_lanes_specific_item,
1834 : : (void *)&cmd_config_speed_lanes_specific_lanes,
1835 : : NULL,
1836 : : },
1837 : : };
1838 : :
1839 : : /* *** configure loopback for all ports *** */
1840 : : struct cmd_config_loopback_all {
1841 : : cmdline_fixed_string_t port;
1842 : : cmdline_fixed_string_t keyword;
1843 : : cmdline_fixed_string_t all;
1844 : : cmdline_fixed_string_t item;
1845 : : uint32_t mode;
1846 : : };
1847 : :
1848 : : static void
1849 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1850 : : __rte_unused struct cmdline *cl,
1851 : : __rte_unused void *data)
1852 : : {
1853 : : struct cmd_config_loopback_all *res = parsed_result;
1854 : : portid_t pid;
1855 : :
1856 : 0 : if (!all_ports_stopped()) {
1857 : 0 : fprintf(stderr, "Please stop all ports first\n");
1858 : 0 : return;
1859 : : }
1860 : :
1861 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1862 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1863 : : }
1864 : :
1865 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1866 : : }
1867 : :
1868 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1869 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1870 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1871 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1872 : : "config");
1873 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1874 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1875 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1876 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1877 : : "loopback");
1878 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1879 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1880 : :
1881 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1882 : : .f = cmd_config_loopback_all_parsed,
1883 : : .data = NULL,
1884 : : .help_str = "port config all loopback <mode>",
1885 : : .tokens = {
1886 : : (void *)&cmd_config_loopback_all_port,
1887 : : (void *)&cmd_config_loopback_all_keyword,
1888 : : (void *)&cmd_config_loopback_all_all,
1889 : : (void *)&cmd_config_loopback_all_item,
1890 : : (void *)&cmd_config_loopback_all_mode,
1891 : : NULL,
1892 : : },
1893 : : };
1894 : :
1895 : : /* *** configure loopback for specific port *** */
1896 : : struct cmd_config_loopback_specific {
1897 : : cmdline_fixed_string_t port;
1898 : : cmdline_fixed_string_t keyword;
1899 : : uint16_t port_id;
1900 : : cmdline_fixed_string_t item;
1901 : : uint32_t mode;
1902 : : };
1903 : :
1904 : : static void
1905 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1906 : : __rte_unused struct cmdline *cl,
1907 : : __rte_unused void *data)
1908 : : {
1909 : : struct cmd_config_loopback_specific *res = parsed_result;
1910 : :
1911 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1912 : : return;
1913 : :
1914 : 0 : if (!port_is_stopped(res->port_id)) {
1915 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1916 : 0 : return;
1917 : : }
1918 : :
1919 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1920 : :
1921 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1922 : : }
1923 : :
1924 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1925 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1926 : : "port");
1927 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1928 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1929 : : "config");
1930 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1931 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1932 : : RTE_UINT16);
1933 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1934 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1935 : : "loopback");
1936 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1937 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1938 : : RTE_UINT32);
1939 : :
1940 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1941 : : .f = cmd_config_loopback_specific_parsed,
1942 : : .data = NULL,
1943 : : .help_str = "port config <port_id> loopback <mode>",
1944 : : .tokens = {
1945 : : (void *)&cmd_config_loopback_specific_port,
1946 : : (void *)&cmd_config_loopback_specific_keyword,
1947 : : (void *)&cmd_config_loopback_specific_id,
1948 : : (void *)&cmd_config_loopback_specific_item,
1949 : : (void *)&cmd_config_loopback_specific_mode,
1950 : : NULL,
1951 : : },
1952 : : };
1953 : :
1954 : : /* *** configure txq/rxq, txd/rxd *** */
1955 : : struct cmd_config_rx_tx {
1956 : : cmdline_fixed_string_t port;
1957 : : cmdline_fixed_string_t keyword;
1958 : : cmdline_fixed_string_t all;
1959 : : cmdline_fixed_string_t name;
1960 : : uint16_t value;
1961 : : };
1962 : :
1963 : : static void
1964 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1965 : : __rte_unused struct cmdline *cl,
1966 : : __rte_unused void *data)
1967 : : {
1968 : : struct cmd_config_rx_tx *res = parsed_result;
1969 : :
1970 : 0 : if (!all_ports_stopped()) {
1971 : 0 : fprintf(stderr, "Please stop all ports first\n");
1972 : 0 : return;
1973 : : }
1974 : 0 : if (!strcmp(res->name, "rxq")) {
1975 : 0 : if (!res->value && !nb_txq) {
1976 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1977 : 0 : return;
1978 : : }
1979 : 0 : if (check_nb_rxq(res->value) != 0)
1980 : : return;
1981 : 0 : nb_rxq = res->value;
1982 : : }
1983 : 0 : else if (!strcmp(res->name, "txq")) {
1984 : 0 : if (!res->value && !nb_rxq) {
1985 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1986 : 0 : return;
1987 : : }
1988 : 0 : if (check_nb_txq(res->value) != 0)
1989 : : return;
1990 : 0 : nb_txq = res->value;
1991 : : }
1992 : 0 : else if (!strcmp(res->name, "rxd")) {
1993 : 0 : if (check_nb_rxd(res->value) != 0)
1994 : : return;
1995 : 0 : nb_rxd = res->value;
1996 : 0 : } else if (!strcmp(res->name, "txd")) {
1997 : 0 : if (check_nb_txd(res->value) != 0)
1998 : : return;
1999 : :
2000 : 0 : nb_txd = res->value;
2001 : : } else {
2002 : 0 : fprintf(stderr, "Unknown parameter\n");
2003 : 0 : return;
2004 : : }
2005 : :
2006 : 0 : fwd_config_setup();
2007 : :
2008 : 0 : init_port_config();
2009 : :
2010 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2011 : : }
2012 : :
2013 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
2014 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2015 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2016 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2017 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
2018 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2019 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
2020 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2021 : : "rxq#txq#rxd#txd");
2022 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
2023 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
2024 : :
2025 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
2026 : : .f = cmd_config_rx_tx_parsed,
2027 : : .data = NULL,
2028 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
2029 : : .tokens = {
2030 : : (void *)&cmd_config_rx_tx_port,
2031 : : (void *)&cmd_config_rx_tx_keyword,
2032 : : (void *)&cmd_config_rx_tx_all,
2033 : : (void *)&cmd_config_rx_tx_name,
2034 : : (void *)&cmd_config_rx_tx_value,
2035 : : NULL,
2036 : : },
2037 : : };
2038 : :
2039 : : /* *** config max packet length *** */
2040 : : struct cmd_config_max_pkt_len_result {
2041 : : cmdline_fixed_string_t port;
2042 : : cmdline_fixed_string_t keyword;
2043 : : cmdline_fixed_string_t all;
2044 : : cmdline_fixed_string_t name;
2045 : : uint32_t value;
2046 : : };
2047 : :
2048 : : static void
2049 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
2050 : : __rte_unused struct cmdline *cl,
2051 : : __rte_unused void *data)
2052 : : {
2053 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
2054 : : portid_t port_id;
2055 : : int ret;
2056 : :
2057 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
2058 : : printf("Unknown parameter\n");
2059 : 0 : return;
2060 : : }
2061 : :
2062 : 0 : if (!all_ports_stopped()) {
2063 : 0 : fprintf(stderr, "Please stop all ports first\n");
2064 : 0 : return;
2065 : : }
2066 : :
2067 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
2068 : 0 : struct rte_port *port = &ports[port_id];
2069 : :
2070 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
2071 : 0 : fprintf(stderr,
2072 : : "max-pkt-len can not be less than %d\n",
2073 : : RTE_ETHER_MIN_LEN);
2074 : 0 : return;
2075 : : }
2076 : :
2077 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
2078 : 0 : if (ret != 0) {
2079 : 0 : fprintf(stderr,
2080 : : "rte_eth_dev_info_get() failed for port %u\n",
2081 : : port_id);
2082 : 0 : return;
2083 : : }
2084 : :
2085 : 0 : update_mtu_from_frame_size(port_id, res->value);
2086 : : }
2087 : :
2088 : 0 : init_port_config();
2089 : :
2090 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2091 : : }
2092 : :
2093 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2094 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2095 : : "port");
2096 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2097 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2098 : : "config");
2099 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2100 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2101 : : "all");
2102 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2103 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2104 : : "max-pkt-len");
2105 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2106 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2107 : : RTE_UINT32);
2108 : :
2109 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
2110 : : .f = cmd_config_max_pkt_len_parsed,
2111 : : .data = NULL,
2112 : : .help_str = "port config all max-pkt-len <value>",
2113 : : .tokens = {
2114 : : (void *)&cmd_config_max_pkt_len_port,
2115 : : (void *)&cmd_config_max_pkt_len_keyword,
2116 : : (void *)&cmd_config_max_pkt_len_all,
2117 : : (void *)&cmd_config_max_pkt_len_name,
2118 : : (void *)&cmd_config_max_pkt_len_value,
2119 : : NULL,
2120 : : },
2121 : : };
2122 : :
2123 : : /* *** config max LRO aggregated packet size *** */
2124 : : struct cmd_config_max_lro_pkt_size_result {
2125 : : cmdline_fixed_string_t port;
2126 : : cmdline_fixed_string_t keyword;
2127 : : cmdline_fixed_string_t all;
2128 : : cmdline_fixed_string_t name;
2129 : : uint32_t value;
2130 : : };
2131 : :
2132 : : static void
2133 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2134 : : __rte_unused struct cmdline *cl,
2135 : : __rte_unused void *data)
2136 : : {
2137 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2138 : : portid_t pid;
2139 : :
2140 : 0 : if (!all_ports_stopped()) {
2141 : 0 : fprintf(stderr, "Please stop all ports first\n");
2142 : 0 : return;
2143 : : }
2144 : :
2145 : 0 : RTE_ETH_FOREACH_DEV(pid) {
2146 : 0 : struct rte_port *port = &ports[pid];
2147 : :
2148 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
2149 : 0 : if (res->value ==
2150 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
2151 : : return;
2152 : :
2153 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2154 : : } else {
2155 : 0 : fprintf(stderr, "Unknown parameter\n");
2156 : 0 : return;
2157 : : }
2158 : : }
2159 : :
2160 : 0 : init_port_config();
2161 : :
2162 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2163 : : }
2164 : :
2165 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2166 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2167 : : port, "port");
2168 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2169 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2170 : : keyword, "config");
2171 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2172 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2173 : : all, "all");
2174 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2175 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2176 : : name, "max-lro-pkt-size");
2177 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2178 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2179 : : value, RTE_UINT32);
2180 : :
2181 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2182 : : .f = cmd_config_max_lro_pkt_size_parsed,
2183 : : .data = NULL,
2184 : : .help_str = "port config all max-lro-pkt-size <value>",
2185 : : .tokens = {
2186 : : (void *)&cmd_config_max_lro_pkt_size_port,
2187 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
2188 : : (void *)&cmd_config_max_lro_pkt_size_all,
2189 : : (void *)&cmd_config_max_lro_pkt_size_name,
2190 : : (void *)&cmd_config_max_lro_pkt_size_value,
2191 : : NULL,
2192 : : },
2193 : : };
2194 : :
2195 : : /* *** configure port MTU *** */
2196 : : struct cmd_config_mtu_result {
2197 : : cmdline_fixed_string_t port;
2198 : : cmdline_fixed_string_t keyword;
2199 : : cmdline_fixed_string_t mtu;
2200 : : portid_t port_id;
2201 : : uint16_t value;
2202 : : };
2203 : :
2204 : : static void
2205 : 0 : cmd_config_mtu_parsed(void *parsed_result,
2206 : : __rte_unused struct cmdline *cl,
2207 : : __rte_unused void *data)
2208 : : {
2209 : : struct cmd_config_mtu_result *res = parsed_result;
2210 : :
2211 : 0 : port_mtu_set(res->port_id, res->value);
2212 : 0 : }
2213 : :
2214 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
2215 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2216 : : "port");
2217 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2218 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2219 : : "config");
2220 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2221 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2222 : : "mtu");
2223 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2224 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2225 : : RTE_UINT16);
2226 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
2227 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2228 : : RTE_UINT16);
2229 : :
2230 : : static cmdline_parse_inst_t cmd_config_mtu = {
2231 : : .f = cmd_config_mtu_parsed,
2232 : : .data = NULL,
2233 : : .help_str = "port config mtu <port_id> <value>",
2234 : : .tokens = {
2235 : : (void *)&cmd_config_mtu_port,
2236 : : (void *)&cmd_config_mtu_keyword,
2237 : : (void *)&cmd_config_mtu_mtu,
2238 : : (void *)&cmd_config_mtu_port_id,
2239 : : (void *)&cmd_config_mtu_value,
2240 : : NULL,
2241 : : },
2242 : : };
2243 : :
2244 : : /* *** configure rx mode *** */
2245 : : struct cmd_config_rx_mode_flag {
2246 : : cmdline_fixed_string_t port;
2247 : : cmdline_fixed_string_t keyword;
2248 : : cmdline_fixed_string_t all;
2249 : : cmdline_fixed_string_t name;
2250 : : cmdline_fixed_string_t value;
2251 : : };
2252 : :
2253 : : static void
2254 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
2255 : : __rte_unused struct cmdline *cl,
2256 : : __rte_unused void *data)
2257 : : {
2258 : : struct cmd_config_rx_mode_flag *res = parsed_result;
2259 : :
2260 : 0 : if (!all_ports_stopped()) {
2261 : 0 : fprintf(stderr, "Please stop all ports first\n");
2262 : 0 : return;
2263 : : }
2264 : :
2265 : 0 : if (!strcmp(res->name, "drop-en")) {
2266 : 0 : if (!strcmp(res->value, "on"))
2267 : 0 : rx_drop_en = 1;
2268 : 0 : else if (!strcmp(res->value, "off"))
2269 : 0 : rx_drop_en = 0;
2270 : : else {
2271 : 0 : fprintf(stderr, "Unknown parameter\n");
2272 : 0 : return;
2273 : : }
2274 : : } else {
2275 : 0 : fprintf(stderr, "Unknown parameter\n");
2276 : 0 : return;
2277 : : }
2278 : :
2279 : 0 : init_port_config();
2280 : :
2281 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2282 : : }
2283 : :
2284 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2285 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2286 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2287 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2288 : : "config");
2289 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2290 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2291 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2292 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2293 : : "drop-en");
2294 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2295 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2296 : : "on#off");
2297 : :
2298 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2299 : : .f = cmd_config_rx_mode_flag_parsed,
2300 : : .data = NULL,
2301 : : .help_str = "port config all drop-en on|off",
2302 : : .tokens = {
2303 : : (void *)&cmd_config_rx_mode_flag_port,
2304 : : (void *)&cmd_config_rx_mode_flag_keyword,
2305 : : (void *)&cmd_config_rx_mode_flag_all,
2306 : : (void *)&cmd_config_rx_mode_flag_name,
2307 : : (void *)&cmd_config_rx_mode_flag_value,
2308 : : NULL,
2309 : : },
2310 : : };
2311 : :
2312 : : /* *** configure rss *** */
2313 : : struct cmd_config_rss {
2314 : : cmdline_fixed_string_t port;
2315 : : cmdline_fixed_string_t keyword;
2316 : : cmdline_fixed_string_t all;
2317 : : cmdline_fixed_string_t name;
2318 : : cmdline_fixed_string_t value;
2319 : : };
2320 : :
2321 : : static void
2322 : 0 : cmd_config_rss_parsed(void *parsed_result,
2323 : : __rte_unused struct cmdline *cl,
2324 : : __rte_unused void *data)
2325 : : {
2326 : : struct cmd_config_rss *res = parsed_result;
2327 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2328 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2329 : : int use_default = 0;
2330 : : int all_updated = 1;
2331 : : int diag;
2332 : : uint16_t i;
2333 : : int ret;
2334 : :
2335 : 0 : if (!strcmp(res->value, "level-default")) {
2336 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2337 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2338 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2339 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2340 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2341 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2342 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2343 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2344 : 0 : } else if (!strcmp(res->value, "default")) {
2345 : : use_default = 1;
2346 : 0 : } else if (isdigit(res->value[0])) {
2347 : : int value = atoi(res->value);
2348 : 0 : if (value > 0 && value < 64)
2349 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2350 : : else {
2351 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2352 : 0 : return;
2353 : : }
2354 : 0 : } else if (!strcmp(res->value, "none")) {
2355 : : rss_conf.rss_hf = 0;
2356 : : } else {
2357 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2358 : 0 : if (rss_conf.rss_hf == 0) {
2359 : 0 : fprintf(stderr, "Unknown parameter\n");
2360 : 0 : return;
2361 : : }
2362 : : }
2363 : : rss_conf.rss_key = NULL;
2364 : : /* Update global configuration for RSS types. */
2365 : 0 : RTE_ETH_FOREACH_DEV(i) {
2366 : : struct rte_eth_rss_conf local_rss_conf;
2367 : :
2368 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2369 : 0 : if (ret != 0)
2370 : 0 : return;
2371 : :
2372 : 0 : if (use_default)
2373 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2374 : :
2375 : 0 : local_rss_conf = rss_conf;
2376 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2377 : 0 : dev_info.flow_type_rss_offloads;
2378 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2379 : : printf("Port %u modified RSS hash function based on hardware support,"
2380 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2381 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2382 : : }
2383 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2384 : 0 : if (diag < 0) {
2385 : : all_updated = 0;
2386 : 0 : fprintf(stderr,
2387 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2388 : : i, -diag, strerror(-diag));
2389 : : }
2390 : : }
2391 : 0 : if (all_updated && !use_default) {
2392 : 0 : rss_hf = rss_conf.rss_hf;
2393 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2394 : : }
2395 : : }
2396 : :
2397 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2398 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2399 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2400 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2401 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2402 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2403 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2404 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2405 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2406 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2407 : :
2408 : : static cmdline_parse_inst_t cmd_config_rss = {
2409 : : .f = cmd_config_rss_parsed,
2410 : : .data = NULL,
2411 : : .help_str = "port config all rss "
2412 : : "all|default|level-default|level-outer|level-inner|"
2413 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2414 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2415 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2416 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2417 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2418 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2419 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2420 : : .tokens = {
2421 : : (void *)&cmd_config_rss_port,
2422 : : (void *)&cmd_config_rss_keyword,
2423 : : (void *)&cmd_config_rss_all,
2424 : : (void *)&cmd_config_rss_name,
2425 : : (void *)&cmd_config_rss_value,
2426 : : NULL,
2427 : : },
2428 : : };
2429 : :
2430 : : /* *** configure rss hash key *** */
2431 : : struct cmd_config_rss_hash_key {
2432 : : cmdline_fixed_string_t port;
2433 : : cmdline_fixed_string_t config;
2434 : : portid_t port_id;
2435 : : cmdline_fixed_string_t rss_hash_key;
2436 : : cmdline_fixed_string_t rss_type;
2437 : : cmdline_fixed_string_t key;
2438 : : };
2439 : :
2440 : : static uint8_t
2441 : : hexa_digit_to_value(char hexa_digit)
2442 : : {
2443 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2444 : : return (uint8_t) (hexa_digit - '0');
2445 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2446 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2447 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2448 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2449 : : /* Invalid hexa digit */
2450 : : return 0xFF;
2451 : : }
2452 : :
2453 : : static uint8_t
2454 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2455 : : {
2456 : : uint8_t hexa_v;
2457 : :
2458 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2459 : : if (hexa_v == 0xFF)
2460 : 0 : fprintf(stderr,
2461 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2462 : : key[idx], idx);
2463 : 0 : return hexa_v;
2464 : : }
2465 : :
2466 : : static void
2467 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2468 : : __rte_unused struct cmdline *cl,
2469 : : __rte_unused void *data)
2470 : : {
2471 : : struct cmd_config_rss_hash_key *res = parsed_result;
2472 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2473 : : uint8_t xdgt0;
2474 : : uint8_t xdgt1;
2475 : : int i;
2476 : : struct rte_eth_dev_info dev_info;
2477 : : uint8_t hash_key_size;
2478 : : uint32_t key_len;
2479 : : int ret;
2480 : :
2481 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2482 : 0 : if (ret != 0)
2483 : 0 : return;
2484 : :
2485 : 0 : if (dev_info.hash_key_size > 0 &&
2486 : : dev_info.hash_key_size <= sizeof(hash_key))
2487 : : hash_key_size = dev_info.hash_key_size;
2488 : : else {
2489 : 0 : fprintf(stderr,
2490 : : "dev_info did not provide a valid hash key size\n");
2491 : 0 : return;
2492 : : }
2493 : : /* Check the length of the RSS hash key */
2494 : 0 : key_len = strlen(res->key);
2495 : 0 : if (key_len != (hash_key_size * 2)) {
2496 : 0 : fprintf(stderr,
2497 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2498 : : (int)key_len, hash_key_size * 2);
2499 : 0 : return;
2500 : : }
2501 : : /* Translate RSS hash key into binary representation */
2502 : 0 : for (i = 0; i < hash_key_size; i++) {
2503 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2504 : 0 : if (xdgt0 == 0xFF)
2505 : : return;
2506 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2507 : 0 : if (xdgt1 == 0xFF)
2508 : : return;
2509 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2510 : : }
2511 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2512 : : hash_key_size);
2513 : : }
2514 : :
2515 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2516 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2517 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2518 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2519 : : "config");
2520 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2521 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2522 : : RTE_UINT16);
2523 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2524 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2525 : : rss_hash_key, "rss-hash-key");
2526 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2527 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2528 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2529 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2530 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2531 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2532 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2533 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2534 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2535 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2536 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2537 : :
2538 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2539 : : .f = cmd_config_rss_hash_key_parsed,
2540 : : .data = NULL,
2541 : : .help_str = "port config <port_id> rss-hash-key "
2542 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2543 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2544 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2545 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2546 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2547 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2548 : : "<string of hex digits (variable length, NIC dependent)>",
2549 : : .tokens = {
2550 : : (void *)&cmd_config_rss_hash_key_port,
2551 : : (void *)&cmd_config_rss_hash_key_config,
2552 : : (void *)&cmd_config_rss_hash_key_port_id,
2553 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2554 : : (void *)&cmd_config_rss_hash_key_rss_type,
2555 : : (void *)&cmd_config_rss_hash_key_value,
2556 : : NULL,
2557 : : },
2558 : : };
2559 : :
2560 : : /* *** configure rss hash algorithm *** */
2561 : : struct cmd_config_rss_hash_algo {
2562 : : cmdline_fixed_string_t port;
2563 : : cmdline_fixed_string_t config;
2564 : : portid_t port_id;
2565 : : cmdline_fixed_string_t rss_hash_algo;
2566 : : cmdline_fixed_string_t algo;
2567 : : };
2568 : :
2569 : : static void
2570 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2571 : : __rte_unused struct cmdline *cl,
2572 : : __rte_unused void *data)
2573 : : {
2574 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2575 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2576 : : struct rte_eth_rss_conf rss_conf;
2577 : : uint32_t algorithm;
2578 : : int ret;
2579 : :
2580 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2581 : 0 : rss_conf.rss_key = rss_key;
2582 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2583 : 0 : if (ret != 0) {
2584 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2585 : 0 : res->port_id);
2586 : 0 : return;
2587 : : }
2588 : :
2589 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2590 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2591 : 0 : if (ret != 0) {
2592 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2593 : 0 : res->port_id, res->algo);
2594 : 0 : return;
2595 : : }
2596 : :
2597 : 0 : rss_conf.algorithm = algorithm;
2598 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2599 : 0 : if (ret != 0) {
2600 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2601 : 0 : res->port_id);
2602 : 0 : return;
2603 : : }
2604 : : }
2605 : :
2606 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2607 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2608 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2609 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2610 : : "config");
2611 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2612 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2613 : : RTE_UINT16);
2614 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2615 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2616 : : rss_hash_algo, "rss-hash-algo");
2617 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2618 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2619 : : "default#simple_xor#toeplitz#"
2620 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2621 : :
2622 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2623 : : .f = cmd_config_rss_hash_algo_parsed,
2624 : : .data = NULL,
2625 : : .help_str = "port config <port_id> rss-hash-algo "
2626 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2627 : : .tokens = {
2628 : : (void *)&cmd_config_rss_hash_algo_port,
2629 : : (void *)&cmd_config_rss_hash_algo_config,
2630 : : (void *)&cmd_config_rss_hash_algo_port_id,
2631 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2632 : : (void *)&cmd_config_rss_hash_algo_algo,
2633 : : NULL,
2634 : : },
2635 : : };
2636 : :
2637 : : /* *** cleanup txq mbufs *** */
2638 : : struct cmd_cleanup_txq_mbufs_result {
2639 : : cmdline_fixed_string_t port;
2640 : : cmdline_fixed_string_t keyword;
2641 : : cmdline_fixed_string_t name;
2642 : : uint16_t port_id;
2643 : : uint16_t queue_id;
2644 : : uint32_t free_cnt;
2645 : : };
2646 : :
2647 : : static void
2648 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2649 : : __rte_unused struct cmdline *cl,
2650 : : __rte_unused void *data)
2651 : : {
2652 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2653 : 0 : uint16_t port_id = res->port_id;
2654 : 0 : uint16_t queue_id = res->queue_id;
2655 : 0 : uint32_t free_cnt = res->free_cnt;
2656 : : struct rte_eth_txq_info qinfo;
2657 : : int ret;
2658 : :
2659 : 0 : if (test_done == 0) {
2660 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2661 : 0 : return;
2662 : : }
2663 : :
2664 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2665 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2666 : : port_id, queue_id);
2667 : 0 : return;
2668 : : }
2669 : :
2670 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2671 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2672 : 0 : return;
2673 : : }
2674 : :
2675 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2676 : 0 : if (ret < 0) {
2677 : 0 : fprintf(stderr,
2678 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2679 : : port_id, queue_id, strerror(-ret), ret);
2680 : 0 : return;
2681 : : }
2682 : :
2683 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2684 : : port_id, queue_id, ret);
2685 : : }
2686 : :
2687 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2688 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2689 : : "port");
2690 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2691 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2692 : : "cleanup");
2693 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2694 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2695 : : RTE_UINT16);
2696 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2697 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2698 : : "txq");
2699 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2700 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2701 : : RTE_UINT16);
2702 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2703 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2704 : : RTE_UINT32);
2705 : :
2706 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2707 : : .f = cmd_cleanup_txq_mbufs_parsed,
2708 : : .data = NULL,
2709 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2710 : : .tokens = {
2711 : : (void *)&cmd_cleanup_txq_mbufs_port,
2712 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2713 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2714 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2715 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2716 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2717 : : NULL,
2718 : : },
2719 : : };
2720 : :
2721 : : /* *** configure port rxq/txq ring size *** */
2722 : : struct cmd_config_rxtx_ring_size {
2723 : : cmdline_fixed_string_t port;
2724 : : cmdline_fixed_string_t config;
2725 : : portid_t portid;
2726 : : cmdline_fixed_string_t rxtxq;
2727 : : uint16_t qid;
2728 : : cmdline_fixed_string_t rsize;
2729 : : uint16_t size;
2730 : : };
2731 : :
2732 : : static void
2733 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2734 : : __rte_unused struct cmdline *cl,
2735 : : __rte_unused void *data)
2736 : : {
2737 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2738 : : struct rte_port *port;
2739 : : uint8_t isrx;
2740 : :
2741 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2742 : : return;
2743 : :
2744 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2745 : 0 : fprintf(stderr, "Invalid port id\n");
2746 : 0 : return;
2747 : : }
2748 : :
2749 : 0 : port = &ports[res->portid];
2750 : :
2751 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2752 : : isrx = 1;
2753 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2754 : : isrx = 0;
2755 : : else {
2756 : 0 : fprintf(stderr, "Unknown parameter\n");
2757 : 0 : return;
2758 : : }
2759 : :
2760 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2761 : : return;
2762 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2763 : : return;
2764 : :
2765 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2766 : 0 : fprintf(stderr,
2767 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2768 : : rx_free_thresh);
2769 : 0 : return;
2770 : : }
2771 : :
2772 : 0 : if (isrx)
2773 : 0 : port->nb_rx_desc[res->qid] = res->size;
2774 : : else
2775 : 0 : port->nb_tx_desc[res->qid] = res->size;
2776 : :
2777 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2778 : : }
2779 : :
2780 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2781 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2782 : : port, "port");
2783 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2784 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2785 : : config, "config");
2786 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2787 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2788 : : portid, RTE_UINT16);
2789 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2790 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2791 : : rxtxq, "rxq#txq");
2792 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2793 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2794 : : qid, RTE_UINT16);
2795 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2796 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2797 : : rsize, "ring_size");
2798 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2799 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2800 : : size, RTE_UINT16);
2801 : :
2802 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2803 : : .f = cmd_config_rxtx_ring_size_parsed,
2804 : : .data = NULL,
2805 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2806 : : .tokens = {
2807 : : (void *)&cmd_config_rxtx_ring_size_port,
2808 : : (void *)&cmd_config_rxtx_ring_size_config,
2809 : : (void *)&cmd_config_rxtx_ring_size_portid,
2810 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2811 : : (void *)&cmd_config_rxtx_ring_size_qid,
2812 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2813 : : (void *)&cmd_config_rxtx_ring_size_size,
2814 : : NULL,
2815 : : },
2816 : : };
2817 : :
2818 : : /* *** configure port rxq/txq start/stop *** */
2819 : : struct cmd_config_rxtx_queue {
2820 : : cmdline_fixed_string_t port;
2821 : : portid_t portid;
2822 : : cmdline_fixed_string_t rxtxq;
2823 : : uint16_t qid;
2824 : : cmdline_fixed_string_t opname;
2825 : : };
2826 : :
2827 : : static void
2828 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2829 : : __rte_unused struct cmdline *cl,
2830 : : __rte_unused void *data)
2831 : : {
2832 : : struct cmd_config_rxtx_queue *res = parsed_result;
2833 : : struct rte_port *port;
2834 : : uint8_t isrx;
2835 : : uint8_t isstart;
2836 : : uint8_t *state;
2837 : : int ret = 0;
2838 : :
2839 : 0 : if (test_done == 0) {
2840 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2841 : 0 : return;
2842 : : }
2843 : :
2844 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2845 : : return;
2846 : :
2847 : 0 : if (port_is_started(res->portid) != 1) {
2848 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2849 : 0 : return;
2850 : : }
2851 : :
2852 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2853 : : isrx = 1;
2854 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2855 : : isrx = 0;
2856 : : else {
2857 : 0 : fprintf(stderr, "Unknown parameter\n");
2858 : 0 : return;
2859 : : }
2860 : :
2861 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2862 : : return;
2863 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2864 : : return;
2865 : :
2866 : 0 : if (!strcmp(res->opname, "start"))
2867 : : isstart = 1;
2868 : 0 : else if (!strcmp(res->opname, "stop"))
2869 : : isstart = 0;
2870 : : else {
2871 : 0 : fprintf(stderr, "Unknown parameter\n");
2872 : 0 : return;
2873 : : }
2874 : :
2875 : 0 : if (isstart && isrx)
2876 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2877 : 0 : else if (!isstart && isrx)
2878 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2879 : 0 : else if (isstart && !isrx)
2880 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2881 : : else
2882 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2883 : :
2884 : 0 : if (ret == -ENOTSUP) {
2885 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2886 : 0 : return;
2887 : : }
2888 : :
2889 : 0 : port = &ports[res->portid];
2890 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2891 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2892 : : RTE_ETH_QUEUE_STATE_STOPPED;
2893 : : }
2894 : :
2895 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2896 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2897 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2898 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2899 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2900 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2901 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2902 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2903 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2904 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2905 : : "start#stop");
2906 : :
2907 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2908 : : .f = cmd_config_rxtx_queue_parsed,
2909 : : .data = NULL,
2910 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2911 : : .tokens = {
2912 : : (void *)&cmd_config_rxtx_queue_port,
2913 : : (void *)&cmd_config_rxtx_queue_portid,
2914 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2915 : : (void *)&cmd_config_rxtx_queue_qid,
2916 : : (void *)&cmd_config_rxtx_queue_opname,
2917 : : NULL,
2918 : : },
2919 : : };
2920 : :
2921 : : /* *** configure port rxq/txq deferred start on/off *** */
2922 : : struct cmd_config_deferred_start_rxtx_queue {
2923 : : cmdline_fixed_string_t port;
2924 : : portid_t port_id;
2925 : : cmdline_fixed_string_t rxtxq;
2926 : : uint16_t qid;
2927 : : cmdline_fixed_string_t opname;
2928 : : cmdline_fixed_string_t state;
2929 : : };
2930 : :
2931 : : static void
2932 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2933 : : __rte_unused struct cmdline *cl,
2934 : : __rte_unused void *data)
2935 : : {
2936 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2937 : : struct rte_port *port;
2938 : : uint8_t isrx;
2939 : : uint8_t ison;
2940 : : uint8_t needreconfig = 0;
2941 : :
2942 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2943 : : return;
2944 : :
2945 : 0 : if (port_is_started(res->port_id) != 0) {
2946 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2947 : 0 : return;
2948 : : }
2949 : :
2950 : 0 : port = &ports[res->port_id];
2951 : :
2952 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2953 : :
2954 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2955 : : return;
2956 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2957 : : return;
2958 : :
2959 : 0 : ison = !strcmp(res->state, "on");
2960 : :
2961 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2962 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2963 : : needreconfig = 1;
2964 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2965 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2966 : : needreconfig = 1;
2967 : : }
2968 : :
2969 : : if (needreconfig)
2970 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2971 : : }
2972 : :
2973 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2974 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2975 : : port, "port");
2976 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2977 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2978 : : port_id, RTE_UINT16);
2979 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2980 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2981 : : rxtxq, "rxq#txq");
2982 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2983 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2984 : : qid, RTE_UINT16);
2985 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2986 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2987 : : opname, "deferred_start");
2988 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2989 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2990 : : state, "on#off");
2991 : :
2992 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2993 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
2994 : : .data = NULL,
2995 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2996 : : .tokens = {
2997 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
2998 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2999 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
3000 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
3001 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
3002 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
3003 : : NULL,
3004 : : },
3005 : : };
3006 : :
3007 : : /* *** configure port rxq/txq setup *** */
3008 : : struct cmd_setup_rxtx_queue {
3009 : : cmdline_fixed_string_t port;
3010 : : portid_t portid;
3011 : : cmdline_fixed_string_t rxtxq;
3012 : : uint16_t qid;
3013 : : cmdline_fixed_string_t setup;
3014 : : };
3015 : :
3016 : : /* Common CLI fields for queue setup */
3017 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
3018 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
3019 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
3020 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
3021 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
3022 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
3023 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
3024 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
3025 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
3026 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
3027 : :
3028 : : static void
3029 : 0 : cmd_setup_rxtx_queue_parsed(
3030 : : void *parsed_result,
3031 : : __rte_unused struct cmdline *cl,
3032 : : __rte_unused void *data)
3033 : : {
3034 : : struct cmd_setup_rxtx_queue *res = parsed_result;
3035 : : struct rte_port *port;
3036 : : struct rte_mempool *mp;
3037 : : unsigned int socket_id;
3038 : : uint8_t isrx = 0;
3039 : : int ret;
3040 : :
3041 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
3042 : : return;
3043 : :
3044 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
3045 : 0 : fprintf(stderr, "Invalid port id\n");
3046 : 0 : return;
3047 : : }
3048 : :
3049 : 0 : if (!strcmp(res->rxtxq, "rxq"))
3050 : : isrx = 1;
3051 : 0 : else if (!strcmp(res->rxtxq, "txq"))
3052 : : isrx = 0;
3053 : : else {
3054 : 0 : fprintf(stderr, "Unknown parameter\n");
3055 : 0 : return;
3056 : : }
3057 : :
3058 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
3059 : 0 : fprintf(stderr, "Invalid rx queue\n");
3060 : 0 : return;
3061 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
3062 : 0 : fprintf(stderr, "Invalid tx queue\n");
3063 : 0 : return;
3064 : : }
3065 : :
3066 : 0 : port = &ports[res->portid];
3067 : 0 : if (isrx) {
3068 : 0 : socket_id = rxring_numa[res->portid];
3069 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3070 : 0 : socket_id = port->socket_id;
3071 : :
3072 : : mp = mbuf_pool_find(socket_id, 0);
3073 : 0 : if (mp == NULL) {
3074 : 0 : fprintf(stderr,
3075 : : "Failed to setup RX queue: No mempool allocation on the socket %d\n",
3076 : 0 : rxring_numa[res->portid]);
3077 : 0 : return;
3078 : : }
3079 : 0 : ret = rx_queue_setup(res->portid,
3080 : : res->qid,
3081 : 0 : port->nb_rx_desc[res->qid],
3082 : : socket_id,
3083 : 0 : &port->rxq[res->qid].conf,
3084 : : mp);
3085 : 0 : if (ret)
3086 : 0 : fprintf(stderr, "Failed to setup RX queue\n");
3087 : : } else {
3088 : 0 : socket_id = txring_numa[res->portid];
3089 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3090 : 0 : socket_id = port->socket_id;
3091 : :
3092 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
3093 : 0 : fprintf(stderr,
3094 : : "Failed to setup TX queue: not enough descriptors\n");
3095 : 0 : return;
3096 : : }
3097 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
3098 : : res->qid,
3099 : : port->nb_tx_desc[res->qid],
3100 : : socket_id,
3101 : 0 : &port->txq[res->qid].conf);
3102 : 0 : if (ret)
3103 : 0 : fprintf(stderr, "Failed to setup TX queue\n");
3104 : : }
3105 : : }
3106 : :
3107 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
3108 : : .f = cmd_setup_rxtx_queue_parsed,
3109 : : .data = NULL,
3110 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
3111 : : .tokens = {
3112 : : (void *)&cmd_setup_rxtx_queue_port,
3113 : : (void *)&cmd_setup_rxtx_queue_portid,
3114 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
3115 : : (void *)&cmd_setup_rxtx_queue_qid,
3116 : : (void *)&cmd_setup_rxtx_queue_setup,
3117 : : NULL,
3118 : : },
3119 : : };
3120 : :
3121 : :
3122 : : /* *** Configure RSS RETA *** */
3123 : : struct cmd_config_rss_reta {
3124 : : cmdline_fixed_string_t port;
3125 : : cmdline_fixed_string_t keyword;
3126 : : portid_t port_id;
3127 : : cmdline_fixed_string_t name;
3128 : : cmdline_fixed_string_t list_name;
3129 : : cmdline_fixed_string_t list_of_items;
3130 : : };
3131 : :
3132 : : static int
3133 : 0 : parse_reta_config(const char *str,
3134 : : struct rte_eth_rss_reta_entry64 *reta_conf,
3135 : : uint16_t nb_entries)
3136 : : {
3137 : : int i;
3138 : : unsigned size;
3139 : : uint16_t hash_index, idx, shift;
3140 : : uint16_t nb_queue;
3141 : : char s[256];
3142 : : const char *p, *p0 = str;
3143 : : char *end;
3144 : : enum fieldnames {
3145 : : FLD_HASH_INDEX = 0,
3146 : : FLD_QUEUE,
3147 : : _NUM_FLD
3148 : : };
3149 : : unsigned long int_fld[_NUM_FLD];
3150 : : char *str_fld[_NUM_FLD];
3151 : :
3152 : 0 : while ((p = strchr(p0,'(')) != NULL) {
3153 : 0 : ++p;
3154 : 0 : if((p0 = strchr(p,')')) == NULL)
3155 : : return -1;
3156 : :
3157 : 0 : size = p0 - p;
3158 : 0 : if(size >= sizeof(s))
3159 : : return -1;
3160 : :
3161 : : snprintf(s, sizeof(s), "%.*s", size, p);
3162 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3163 : : return -1;
3164 : 0 : for (i = 0; i < _NUM_FLD; i++) {
3165 : 0 : errno = 0;
3166 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
3167 : 0 : if (errno != 0 || end == str_fld[i] ||
3168 : : int_fld[i] > 65535)
3169 : : return -1;
3170 : : }
3171 : :
3172 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3173 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3174 : :
3175 : 0 : if (hash_index >= nb_entries) {
3176 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
3177 : : hash_index);
3178 : 0 : return -1;
3179 : : }
3180 : :
3181 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3182 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3183 : 0 : reta_conf[idx].mask |= (1ULL << shift);
3184 : 0 : reta_conf[idx].reta[shift] = nb_queue;
3185 : : }
3186 : :
3187 : : return 0;
3188 : : }
3189 : :
3190 : : static void
3191 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
3192 : : __rte_unused struct cmdline *cl,
3193 : : __rte_unused void *data)
3194 : : {
3195 : : int ret;
3196 : : struct rte_eth_dev_info dev_info;
3197 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3198 : : struct cmd_config_rss_reta *res = parsed_result;
3199 : :
3200 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3201 : 0 : if (ret != 0)
3202 : 0 : return;
3203 : :
3204 : 0 : if (dev_info.reta_size == 0) {
3205 : 0 : fprintf(stderr,
3206 : : "Redirection table size is 0 which is invalid for RSS\n");
3207 : 0 : return;
3208 : : } else
3209 : 0 : printf("The reta size of port %d is %u\n",
3210 : 0 : res->port_id, dev_info.reta_size);
3211 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3212 : 0 : fprintf(stderr,
3213 : : "Currently do not support more than %u entries of redirection table\n",
3214 : : RTE_ETH_RSS_RETA_SIZE_512);
3215 : 0 : return;
3216 : : }
3217 : :
3218 : : memset(reta_conf, 0, sizeof(reta_conf));
3219 : 0 : if (!strcmp(res->list_name, "reta")) {
3220 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
3221 : : dev_info.reta_size)) {
3222 : 0 : fprintf(stderr,
3223 : : "Invalid RSS Redirection Table config entered\n");
3224 : 0 : return;
3225 : : }
3226 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
3227 : 0 : reta_conf, dev_info.reta_size);
3228 : 0 : if (ret != 0)
3229 : 0 : fprintf(stderr,
3230 : : "Bad redirection table parameter, return code = %d\n",
3231 : : ret);
3232 : : }
3233 : : }
3234 : :
3235 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3236 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3237 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3238 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3239 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3240 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3241 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3242 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3243 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3244 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3245 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3246 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3247 : : NULL);
3248 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
3249 : : .f = cmd_set_rss_reta_parsed,
3250 : : .data = NULL,
3251 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3252 : : .tokens = {
3253 : : (void *)&cmd_config_rss_reta_port,
3254 : : (void *)&cmd_config_rss_reta_keyword,
3255 : : (void *)&cmd_config_rss_reta_port_id,
3256 : : (void *)&cmd_config_rss_reta_name,
3257 : : (void *)&cmd_config_rss_reta_list_name,
3258 : : (void *)&cmd_config_rss_reta_list_of_items,
3259 : : NULL,
3260 : : },
3261 : : };
3262 : :
3263 : : /* *** SHOW PORT RETA INFO *** */
3264 : : struct cmd_showport_reta {
3265 : : cmdline_fixed_string_t show;
3266 : : cmdline_fixed_string_t port;
3267 : : portid_t port_id;
3268 : : cmdline_fixed_string_t rss;
3269 : : cmdline_fixed_string_t reta;
3270 : : uint16_t size;
3271 : : cmdline_fixed_string_t list_of_items;
3272 : : };
3273 : :
3274 : : static int
3275 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3276 : : uint16_t nb_entries,
3277 : : char *str)
3278 : : {
3279 : : uint32_t size;
3280 : : const char *p, *p0 = str;
3281 : : char s[256];
3282 : : char *end;
3283 : : char *str_fld[8];
3284 : : uint16_t i;
3285 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3286 : : RTE_ETH_RETA_GROUP_SIZE;
3287 : : int ret;
3288 : :
3289 : 0 : p = strchr(p0, '(');
3290 : 0 : if (p == NULL)
3291 : : return -1;
3292 : 0 : p++;
3293 : 0 : p0 = strchr(p, ')');
3294 : 0 : if (p0 == NULL)
3295 : : return -1;
3296 : 0 : size = p0 - p;
3297 : 0 : if (size >= sizeof(s)) {
3298 : 0 : fprintf(stderr,
3299 : : "The string size exceeds the internal buffer size\n");
3300 : 0 : return -1;
3301 : : }
3302 : : snprintf(s, sizeof(s), "%.*s", size, p);
3303 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3304 : 0 : if (ret <= 0 || ret != num) {
3305 : 0 : fprintf(stderr,
3306 : : "The bits of masks do not match the number of reta entries: %u\n",
3307 : : num);
3308 : 0 : return -1;
3309 : : }
3310 : 0 : for (i = 0; i < ret; i++)
3311 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3312 : :
3313 : : return 0;
3314 : : }
3315 : :
3316 : : static void
3317 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3318 : : __rte_unused struct cmdline *cl,
3319 : : __rte_unused void *data)
3320 : : {
3321 : : struct cmd_showport_reta *res = parsed_result;
3322 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3323 : : struct rte_eth_dev_info dev_info;
3324 : : uint16_t max_reta_size;
3325 : : int ret;
3326 : :
3327 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3328 : 0 : if (ret != 0)
3329 : 0 : return;
3330 : :
3331 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3332 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3333 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3334 : : res->size, max_reta_size);
3335 : 0 : return;
3336 : : }
3337 : :
3338 : : memset(reta_conf, 0, sizeof(reta_conf));
3339 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3340 : 0 : res->list_of_items) < 0) {
3341 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3342 : : res->list_of_items);
3343 : 0 : return;
3344 : : }
3345 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3346 : : }
3347 : :
3348 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3349 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3350 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3351 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3352 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3353 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3354 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3355 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3356 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3357 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3358 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3359 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3360 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3361 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3362 : : list_of_items, NULL);
3363 : :
3364 : : static cmdline_parse_inst_t cmd_showport_reta = {
3365 : : .f = cmd_showport_reta_parsed,
3366 : : .data = NULL,
3367 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3368 : : .tokens = {
3369 : : (void *)&cmd_showport_reta_show,
3370 : : (void *)&cmd_showport_reta_port,
3371 : : (void *)&cmd_showport_reta_port_id,
3372 : : (void *)&cmd_showport_reta_rss,
3373 : : (void *)&cmd_showport_reta_reta,
3374 : : (void *)&cmd_showport_reta_size,
3375 : : (void *)&cmd_showport_reta_list_of_items,
3376 : : NULL,
3377 : : },
3378 : : };
3379 : :
3380 : : /* *** Show RSS hash configuration *** */
3381 : : struct cmd_showport_rss_hash {
3382 : : cmdline_fixed_string_t show;
3383 : : cmdline_fixed_string_t port;
3384 : : portid_t port_id;
3385 : : cmdline_fixed_string_t rss_hash;
3386 : : cmdline_fixed_string_t rss_type;
3387 : : cmdline_fixed_string_t key; /* optional argument */
3388 : : cmdline_fixed_string_t algorithm; /* optional argument */
3389 : : };
3390 : :
3391 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3392 : : __rte_unused struct cmdline *cl,
3393 : : __rte_unused void *data)
3394 : : {
3395 : : struct cmd_showport_rss_hash *res = parsed_result;
3396 : :
3397 : 0 : port_rss_hash_conf_show(res->port_id,
3398 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3399 : 0 : }
3400 : :
3401 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3402 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3403 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3404 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3405 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3406 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3407 : : RTE_UINT16);
3408 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3409 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3410 : : "rss-hash");
3411 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3412 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3413 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3414 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3415 : :
3416 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3417 : : .f = cmd_showport_rss_hash_parsed,
3418 : : .data = NULL,
3419 : : .help_str = "show port <port_id> rss-hash",
3420 : : .tokens = {
3421 : : (void *)&cmd_showport_rss_hash_show,
3422 : : (void *)&cmd_showport_rss_hash_port,
3423 : : (void *)&cmd_showport_rss_hash_port_id,
3424 : : (void *)&cmd_showport_rss_hash_rss_hash,
3425 : : NULL,
3426 : : },
3427 : : };
3428 : :
3429 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3430 : : .f = cmd_showport_rss_hash_parsed,
3431 : : .data = NULL,
3432 : : .help_str = "show port <port_id> rss-hash key",
3433 : : .tokens = {
3434 : : (void *)&cmd_showport_rss_hash_show,
3435 : : (void *)&cmd_showport_rss_hash_port,
3436 : : (void *)&cmd_showport_rss_hash_port_id,
3437 : : (void *)&cmd_showport_rss_hash_rss_hash,
3438 : : (void *)&cmd_showport_rss_hash_rss_key,
3439 : : NULL,
3440 : : },
3441 : : };
3442 : :
3443 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3444 : : .f = cmd_showport_rss_hash_parsed,
3445 : : .data = NULL,
3446 : : .help_str = "show port <port_id> rss-hash algorithm",
3447 : : .tokens = {
3448 : : (void *)&cmd_showport_rss_hash_show,
3449 : : (void *)&cmd_showport_rss_hash_port,
3450 : : (void *)&cmd_showport_rss_hash_port_id,
3451 : : (void *)&cmd_showport_rss_hash_rss_hash,
3452 : : (void *)&cmd_showport_rss_hash_rss_algo,
3453 : : NULL,
3454 : : },
3455 : : };
3456 : :
3457 : : /* *** Configure DCB *** */
3458 : : struct cmd_config_dcb {
3459 : : cmdline_fixed_string_t port;
3460 : : cmdline_fixed_string_t config;
3461 : : portid_t port_id;
3462 : : cmdline_fixed_string_t dcb;
3463 : : cmdline_fixed_string_t vt;
3464 : : cmdline_fixed_string_t vt_en;
3465 : : uint8_t num_tcs;
3466 : : cmdline_fixed_string_t pfc;
3467 : : cmdline_multi_string_t token_str;
3468 : : };
3469 : :
3470 : : static int
3471 : 0 : parse_dcb_token_prio_tc(char *param_str[], int param_num,
3472 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3473 : : uint8_t *prio_tc_en)
3474 : : {
3475 : : unsigned long prio, tc;
3476 : : int prio_tc_maps = 0;
3477 : : char *param, *end;
3478 : : int i;
3479 : :
3480 : 0 : for (i = 0; i < param_num; i++) {
3481 : 0 : param = param_str[i];
3482 : 0 : prio = strtoul(param, &end, 10);
3483 : 0 : if (prio >= RTE_ETH_DCB_NUM_USER_PRIORITIES) {
3484 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO %lu\n", prio);
3485 : 0 : return -1;
3486 : : }
3487 : 0 : if ((*end != ':') || (strlen(end + 1) == 0)) {
3488 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3489 : 0 : return -1;
3490 : : }
3491 : 0 : tc = strtoul(end + 1, &end, 10);
3492 : 0 : if (tc >= RTE_ETH_8_TCS) {
3493 : 0 : fprintf(stderr, "Bad Argument: invalid TC %lu\n", tc);
3494 : 0 : return -1;
3495 : : }
3496 : 0 : if (*end != '\0') {
3497 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3498 : 0 : return -1;
3499 : : }
3500 : 0 : prio_tc[prio] = tc;
3501 : 0 : prio_tc_maps++;
3502 : : } while (0);
3503 : :
3504 : 0 : if (prio_tc_maps == 0) {
3505 : 0 : fprintf(stderr, "Bad Argument: no PRIO:TC provided\n");
3506 : 0 : return -1;
3507 : : }
3508 : 0 : *prio_tc_en = 1;
3509 : :
3510 : 0 : return 0;
3511 : : }
3512 : :
3513 : : #define DCB_TOKEN_PRIO_TC "prio-tc"
3514 : : #define DCB_TOKEN_KEEP_QNUM "keep-qnum"
3515 : :
3516 : : static int
3517 : 0 : parse_dcb_token_find(char *split_str[], int split_num, int *param_num)
3518 : : {
3519 : : int i;
3520 : :
3521 : 0 : if (strcmp(split_str[0], DCB_TOKEN_KEEP_QNUM) == 0) {
3522 : 0 : *param_num = 0;
3523 : 0 : return 0;
3524 : : }
3525 : :
3526 : 0 : if (strcmp(split_str[0], DCB_TOKEN_PRIO_TC) != 0) {
3527 : 0 : fprintf(stderr, "Bad Argument: unknown token %s\n", split_str[0]);
3528 : 0 : return -EINVAL;
3529 : : }
3530 : :
3531 : 0 : for (i = 1; i < split_num; i++) {
3532 : 0 : if ((strcmp(split_str[i], DCB_TOKEN_PRIO_TC) != 0) &&
3533 : 0 : (strcmp(split_str[i], DCB_TOKEN_KEEP_QNUM) != 0))
3534 : : continue;
3535 : : /* find another optional parameter, then exit. */
3536 : : break;
3537 : : }
3538 : :
3539 : 0 : *param_num = i - 1;
3540 : :
3541 : 0 : return 0;
3542 : : }
3543 : :
3544 : : static int
3545 : 0 : parse_dcb_token_value(char *token_str,
3546 : : uint8_t *pfc_en,
3547 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3548 : : uint8_t *prio_tc_en,
3549 : : uint8_t *keep_qnum)
3550 : : {
3551 : : #define MAX_TOKEN_NUM 128
3552 : : char *split_str[MAX_TOKEN_NUM];
3553 : : int param_num, start, ret;
3554 : : int split_num = 0;
3555 : : char *token;
3556 : :
3557 : : /* split multiple token to split str. */
3558 : : do {
3559 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
3560 : 0 : if (token == NULL)
3561 : : break;
3562 : 0 : if (split_num >= MAX_TOKEN_NUM) {
3563 : 0 : fprintf(stderr, "Bad Argument: too much argument\n");
3564 : 0 : return -1;
3565 : : }
3566 : 0 : split_str[split_num++] = token;
3567 : : } while (1);
3568 : :
3569 : : /* parse fixed parameter "pfc-en" first. */
3570 : 0 : token = split_str[0];
3571 : 0 : if (strcmp(token, "on") == 0)
3572 : 0 : *pfc_en = 1;
3573 : 0 : else if (strcmp(token, "off") == 0)
3574 : 0 : *pfc_en = 0;
3575 : : else {
3576 : 0 : fprintf(stderr, "Bad Argument: pfc-en must be on or off\n");
3577 : 0 : return -EINVAL;
3578 : : }
3579 : :
3580 : 0 : if (split_num == 1)
3581 : : return 0;
3582 : :
3583 : : /* start parse optional parameter. */
3584 : : start = 1;
3585 : : do {
3586 : 0 : param_num = 0;
3587 : 0 : ret = parse_dcb_token_find(&split_str[start], split_num - start, ¶m_num);
3588 : 0 : if (ret != 0)
3589 : 0 : return ret;
3590 : :
3591 : 0 : token = split_str[start];
3592 : 0 : if (strcmp(token, DCB_TOKEN_PRIO_TC) == 0) {
3593 : 0 : if (*prio_tc_en == 1) {
3594 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3595 : : DCB_TOKEN_PRIO_TC);
3596 : 0 : return -1;
3597 : : }
3598 : 0 : ret = parse_dcb_token_prio_tc(&split_str[start + 1], param_num, prio_tc,
3599 : : prio_tc_en);
3600 : 0 : if (ret != 0)
3601 : 0 : return ret;
3602 : : } else {
3603 : : /* this must be keep-qnum. */
3604 : 0 : if (*keep_qnum == 1) {
3605 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3606 : : DCB_TOKEN_KEEP_QNUM);
3607 : 0 : return -1;
3608 : : }
3609 : 0 : *keep_qnum = 1;
3610 : : }
3611 : :
3612 : 0 : start += param_num + 1;
3613 : 0 : if (start >= split_num)
3614 : : break;
3615 : : } while (1);
3616 : :
3617 : : return 0;
3618 : : }
3619 : :
3620 : : static void
3621 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3622 : : __rte_unused struct cmdline *cl,
3623 : : __rte_unused void *data)
3624 : : {
3625 : 0 : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES] = {0};
3626 : : struct cmd_config_dcb *res = parsed_result;
3627 : : struct rte_eth_dcb_info dcb_info;
3628 : 0 : portid_t port_id = res->port_id;
3629 : 0 : uint8_t prio_tc_en = 0;
3630 : 0 : uint8_t keep_qnum = 0;
3631 : : struct rte_port *port;
3632 : 0 : uint8_t pfc_en = 0;
3633 : : int ret;
3634 : :
3635 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
3636 : 0 : return;
3637 : :
3638 : 0 : port = &ports[port_id];
3639 : : /** Check if the port is not started **/
3640 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3641 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3642 : 0 : return;
3643 : : }
3644 : :
3645 : 0 : if (res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS) {
3646 : 0 : fprintf(stderr,
3647 : : "The invalid number of traffic class, only 1~8 allowed.\n");
3648 : 0 : return;
3649 : : }
3650 : :
3651 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3652 : 0 : fprintf(stderr,
3653 : : "nb_cores shouldn't be less than number of TCs.\n");
3654 : 0 : return;
3655 : : }
3656 : :
3657 : : /* Check whether the port supports the report of DCB info. */
3658 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3659 : 0 : if (ret == -ENOTSUP) {
3660 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3661 : 0 : return;
3662 : : }
3663 : :
3664 : 0 : ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en, &keep_qnum);
3665 : 0 : if (ret != 0)
3666 : : return;
3667 : :
3668 : : /* DCB in VT mode */
3669 : 0 : if (!strncmp(res->vt_en, "on", 2))
3670 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3671 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3672 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3673 : : else
3674 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3675 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3676 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3677 : 0 : if (ret != 0) {
3678 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3679 : 0 : return;
3680 : : }
3681 : :
3682 : 0 : fwd_config_setup();
3683 : :
3684 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3685 : : }
3686 : :
3687 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3688 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3689 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3690 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3691 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3692 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3693 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3694 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3695 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3696 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3697 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3698 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3699 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3700 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3701 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3702 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3703 : : static cmdline_parse_token_string_t cmd_config_dcb_token_str =
3704 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, token_str, TOKEN_STRING_MULTI);
3705 : :
3706 : : static cmdline_parse_inst_t cmd_config_dcb = {
3707 : : .f = cmd_config_dcb_parsed,
3708 : : .data = NULL,
3709 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP keep-qnum\n"
3710 : : "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
3711 : : " PRIO-MAPPING := PRIO:TC\n"
3712 : : " PRIO: { 0 .. 7 }\n"
3713 : : " TC: { 0 .. 7 }",
3714 : : .tokens = {
3715 : : (void *)&cmd_config_dcb_port,
3716 : : (void *)&cmd_config_dcb_config,
3717 : : (void *)&cmd_config_dcb_port_id,
3718 : : (void *)&cmd_config_dcb_dcb,
3719 : : (void *)&cmd_config_dcb_vt,
3720 : : (void *)&cmd_config_dcb_vt_en,
3721 : : (void *)&cmd_config_dcb_num_tcs,
3722 : : (void *)&cmd_config_dcb_pfc,
3723 : : (void *)&cmd_config_dcb_token_str,
3724 : : NULL,
3725 : : },
3726 : : };
3727 : :
3728 : : /* *** configure number of packets per burst *** */
3729 : : struct cmd_config_burst {
3730 : : cmdline_fixed_string_t port;
3731 : : cmdline_fixed_string_t keyword;
3732 : : cmdline_fixed_string_t all;
3733 : : cmdline_fixed_string_t name;
3734 : : uint16_t value;
3735 : : };
3736 : :
3737 : : static void
3738 : 0 : cmd_config_burst_parsed(void *parsed_result,
3739 : : __rte_unused struct cmdline *cl,
3740 : : __rte_unused void *data)
3741 : : {
3742 : : struct cmd_config_burst *res = parsed_result;
3743 : : struct rte_eth_dev_info dev_info;
3744 : : uint16_t rec_nb_pkts;
3745 : : int ret;
3746 : :
3747 : 0 : if (!all_ports_stopped()) {
3748 : 0 : fprintf(stderr, "Please stop all ports first\n");
3749 : 0 : return;
3750 : : }
3751 : :
3752 : 0 : if (!strcmp(res->name, "burst")) {
3753 : 0 : if (res->value == 0) {
3754 : : /* If user gives a value of zero, query the PMD for
3755 : : * its recommended Rx burst size. Testpmd uses a single
3756 : : * size for all ports, so assume all ports are the same
3757 : : * NIC model and use the values from Port 0.
3758 : : */
3759 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3760 : 0 : if (ret != 0)
3761 : : return;
3762 : :
3763 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3764 : :
3765 : 0 : if (rec_nb_pkts == 0) {
3766 : : printf("PMD does not recommend a burst size.\n"
3767 : : "User provided value must be between"
3768 : : " 1 and %d\n", MAX_PKT_BURST);
3769 : 0 : return;
3770 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3771 : 0 : printf("PMD recommended burst size of %d"
3772 : : " exceeds maximum value of %d\n",
3773 : : rec_nb_pkts, MAX_PKT_BURST);
3774 : 0 : return;
3775 : : }
3776 : 0 : printf("Using PMD-provided burst value of %d\n",
3777 : : rec_nb_pkts);
3778 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3779 : 0 : } else if (res->value > MAX_PKT_BURST) {
3780 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3781 : : MAX_PKT_BURST);
3782 : 0 : return;
3783 : : } else
3784 : 0 : nb_pkt_per_burst = res->value;
3785 : : } else {
3786 : 0 : fprintf(stderr, "Unknown parameter\n");
3787 : 0 : return;
3788 : : }
3789 : :
3790 : 0 : init_port_config();
3791 : :
3792 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3793 : : }
3794 : :
3795 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3796 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3797 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3798 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3799 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3800 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3801 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3802 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3803 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3804 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3805 : :
3806 : : static cmdline_parse_inst_t cmd_config_burst = {
3807 : : .f = cmd_config_burst_parsed,
3808 : : .data = NULL,
3809 : : .help_str = "port config all burst <value>",
3810 : : .tokens = {
3811 : : (void *)&cmd_config_burst_port,
3812 : : (void *)&cmd_config_burst_keyword,
3813 : : (void *)&cmd_config_burst_all,
3814 : : (void *)&cmd_config_burst_name,
3815 : : (void *)&cmd_config_burst_value,
3816 : : NULL,
3817 : : },
3818 : : };
3819 : :
3820 : : /* *** configure rx/tx queues *** */
3821 : : struct cmd_config_thresh {
3822 : : cmdline_fixed_string_t port;
3823 : : cmdline_fixed_string_t keyword;
3824 : : cmdline_fixed_string_t all;
3825 : : cmdline_fixed_string_t name;
3826 : : uint8_t value;
3827 : : };
3828 : :
3829 : : static void
3830 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3831 : : __rte_unused struct cmdline *cl,
3832 : : __rte_unused void *data)
3833 : : {
3834 : : struct cmd_config_thresh *res = parsed_result;
3835 : :
3836 : 0 : if (!all_ports_stopped()) {
3837 : 0 : fprintf(stderr, "Please stop all ports first\n");
3838 : 0 : return;
3839 : : }
3840 : :
3841 : 0 : if (!strcmp(res->name, "txpt"))
3842 : 0 : tx_pthresh = res->value;
3843 : 0 : else if(!strcmp(res->name, "txht"))
3844 : 0 : tx_hthresh = res->value;
3845 : 0 : else if(!strcmp(res->name, "txwt"))
3846 : 0 : tx_wthresh = res->value;
3847 : 0 : else if(!strcmp(res->name, "rxpt"))
3848 : 0 : rx_pthresh = res->value;
3849 : 0 : else if(!strcmp(res->name, "rxht"))
3850 : 0 : rx_hthresh = res->value;
3851 : 0 : else if(!strcmp(res->name, "rxwt"))
3852 : 0 : rx_wthresh = res->value;
3853 : : else {
3854 : 0 : fprintf(stderr, "Unknown parameter\n");
3855 : 0 : return;
3856 : : }
3857 : :
3858 : 0 : init_port_config();
3859 : :
3860 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3861 : : }
3862 : :
3863 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3864 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3865 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3866 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3867 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3868 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3869 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3870 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3871 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3872 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3873 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3874 : :
3875 : : static cmdline_parse_inst_t cmd_config_thresh = {
3876 : : .f = cmd_config_thresh_parsed,
3877 : : .data = NULL,
3878 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3879 : : .tokens = {
3880 : : (void *)&cmd_config_thresh_port,
3881 : : (void *)&cmd_config_thresh_keyword,
3882 : : (void *)&cmd_config_thresh_all,
3883 : : (void *)&cmd_config_thresh_name,
3884 : : (void *)&cmd_config_thresh_value,
3885 : : NULL,
3886 : : },
3887 : : };
3888 : :
3889 : : /* *** configure free/rs threshold *** */
3890 : : struct cmd_config_threshold {
3891 : : cmdline_fixed_string_t port;
3892 : : cmdline_fixed_string_t keyword;
3893 : : cmdline_fixed_string_t all;
3894 : : cmdline_fixed_string_t name;
3895 : : uint16_t value;
3896 : : };
3897 : :
3898 : : static void
3899 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3900 : : __rte_unused struct cmdline *cl,
3901 : : __rte_unused void *data)
3902 : : {
3903 : : struct cmd_config_threshold *res = parsed_result;
3904 : :
3905 : 0 : if (!all_ports_stopped()) {
3906 : 0 : fprintf(stderr, "Please stop all ports first\n");
3907 : 0 : return;
3908 : : }
3909 : :
3910 : 0 : if (!strcmp(res->name, "txfreet"))
3911 : 0 : tx_free_thresh = res->value;
3912 : 0 : else if (!strcmp(res->name, "txrst"))
3913 : 0 : tx_rs_thresh = res->value;
3914 : 0 : else if (!strcmp(res->name, "rxfreet"))
3915 : 0 : rx_free_thresh = res->value;
3916 : : else {
3917 : 0 : fprintf(stderr, "Unknown parameter\n");
3918 : 0 : return;
3919 : : }
3920 : :
3921 : 0 : init_port_config();
3922 : :
3923 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3924 : : }
3925 : :
3926 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3927 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3928 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3929 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3930 : : "config");
3931 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3932 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3933 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3934 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3935 : : "txfreet#txrst#rxfreet");
3936 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3937 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3938 : :
3939 : : static cmdline_parse_inst_t cmd_config_threshold = {
3940 : : .f = cmd_config_threshold_parsed,
3941 : : .data = NULL,
3942 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3943 : : .tokens = {
3944 : : (void *)&cmd_config_threshold_port,
3945 : : (void *)&cmd_config_threshold_keyword,
3946 : : (void *)&cmd_config_threshold_all,
3947 : : (void *)&cmd_config_threshold_name,
3948 : : (void *)&cmd_config_threshold_value,
3949 : : NULL,
3950 : : },
3951 : : };
3952 : :
3953 : : /* *** stop *** */
3954 : : struct cmd_stop_result {
3955 : : cmdline_fixed_string_t stop;
3956 : : };
3957 : :
3958 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3959 : : __rte_unused struct cmdline *cl,
3960 : : __rte_unused void *data)
3961 : : {
3962 : 0 : stop_packet_forwarding();
3963 : 0 : }
3964 : :
3965 : : static cmdline_parse_token_string_t cmd_stop_stop =
3966 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3967 : :
3968 : : static cmdline_parse_inst_t cmd_stop = {
3969 : : .f = cmd_stop_parsed,
3970 : : .data = NULL,
3971 : : .help_str = "stop: Stop packet forwarding",
3972 : : .tokens = {
3973 : : (void *)&cmd_stop_stop,
3974 : : NULL,
3975 : : },
3976 : : };
3977 : :
3978 : : static unsigned int
3979 : 0 : get_ptype(char *value)
3980 : : {
3981 : : uint32_t protocol;
3982 : :
3983 : 0 : if (!strcmp(value, "eth"))
3984 : : protocol = RTE_PTYPE_L2_ETHER;
3985 : 0 : else if (!strcmp(value, "ipv4"))
3986 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3987 : 0 : else if (!strcmp(value, "ipv6"))
3988 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3989 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3990 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3991 : 0 : else if (!strcmp(value, "ipv4-udp"))
3992 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3993 : 0 : else if (!strcmp(value, "ipv4-sctp"))
3994 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3995 : 0 : else if (!strcmp(value, "ipv6-tcp"))
3996 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3997 : 0 : else if (!strcmp(value, "ipv6-udp"))
3998 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3999 : 0 : else if (!strcmp(value, "ipv6-sctp"))
4000 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4001 : 0 : else if (!strcmp(value, "grenat"))
4002 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
4003 : 0 : else if (!strcmp(value, "inner-eth"))
4004 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
4005 : 0 : else if (!strcmp(value, "inner-ipv4"))
4006 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4007 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
4008 : 0 : else if (!strcmp(value, "inner-ipv6"))
4009 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4010 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
4011 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
4012 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4013 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4014 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
4015 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4016 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4017 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
4018 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4019 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4020 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
4021 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4022 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4023 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
4024 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4025 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4026 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
4027 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4028 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4029 : : else {
4030 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
4031 : : protocol = RTE_PTYPE_UNKNOWN;
4032 : : }
4033 : :
4034 : 0 : return protocol;
4035 : : }
4036 : :
4037 : : /* *** SET RXHDRSLIST *** */
4038 : :
4039 : : unsigned int
4040 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
4041 : : unsigned int *parsed_items)
4042 : : {
4043 : : unsigned int nb_item;
4044 : : char *cur;
4045 : : char *tmp;
4046 : :
4047 : : nb_item = 0;
4048 : 0 : char *str2 = strdup(str);
4049 : 0 : if (str2 == NULL)
4050 : : return nb_item;
4051 : 0 : cur = strtok_r(str2, ",", &tmp);
4052 : 0 : while (cur != NULL) {
4053 : 0 : parsed_items[nb_item] = get_ptype(cur);
4054 : 0 : cur = strtok_r(NULL, ",", &tmp);
4055 : 0 : nb_item++;
4056 : : }
4057 : 0 : if (nb_item > max_items)
4058 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4059 : : item_name, nb_item + 1, max_items);
4060 : 0 : free(str2);
4061 : 0 : return nb_item;
4062 : : }
4063 : :
4064 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
4065 : :
4066 : : unsigned int
4067 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
4068 : : unsigned int *parsed_items, int check_unique_values)
4069 : : {
4070 : : unsigned int nb_item;
4071 : : unsigned int value;
4072 : : unsigned int i;
4073 : : unsigned int j;
4074 : : int value_ok;
4075 : : char c;
4076 : :
4077 : : /*
4078 : : * First parse all items in the list and store their value.
4079 : : */
4080 : : value = 0;
4081 : : nb_item = 0;
4082 : : value_ok = 0;
4083 : 0 : for (i = 0; i < strnlen(str, STR_MULTI_TOKEN_SIZE); i++) {
4084 : 0 : c = str[i];
4085 : 0 : if ((c >= '0') && (c <= '9')) {
4086 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
4087 : : value_ok = 1;
4088 : 0 : continue;
4089 : : }
4090 : 0 : if (c != ',') {
4091 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
4092 : 0 : return 0;
4093 : : }
4094 : 0 : if (! value_ok) {
4095 : 0 : fprintf(stderr, "No valid value before comma\n");
4096 : 0 : return 0;
4097 : : }
4098 : 0 : if (nb_item < max_items) {
4099 : 0 : parsed_items[nb_item] = value;
4100 : : value_ok = 0;
4101 : : value = 0;
4102 : : }
4103 : 0 : nb_item++;
4104 : : }
4105 : 0 : if (nb_item >= max_items) {
4106 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4107 : : item_name, nb_item + 1, max_items);
4108 : 0 : return 0;
4109 : : }
4110 : 0 : parsed_items[nb_item++] = value;
4111 : 0 : if (! check_unique_values)
4112 : : return nb_item;
4113 : :
4114 : : /*
4115 : : * Then, check that all values in the list are different.
4116 : : * No optimization here...
4117 : : */
4118 : 0 : for (i = 0; i < nb_item; i++) {
4119 : 0 : for (j = i + 1; j < nb_item; j++) {
4120 : 0 : if (parsed_items[j] == parsed_items[i]) {
4121 : 0 : fprintf(stderr,
4122 : : "duplicated %s %u at index %u and %u\n",
4123 : : item_name, parsed_items[i], i, j);
4124 : 0 : return 0;
4125 : : }
4126 : : }
4127 : : }
4128 : : return nb_item;
4129 : : }
4130 : :
4131 : : struct cmd_set_list_result {
4132 : : cmdline_fixed_string_t cmd_keyword;
4133 : : cmdline_fixed_string_t list_name;
4134 : : cmdline_multi_string_t list_of_items;
4135 : : };
4136 : :
4137 : 0 : static void cmd_set_list_parsed(void *parsed_result,
4138 : : __rte_unused struct cmdline *cl,
4139 : : __rte_unused void *data)
4140 : : {
4141 : : struct cmd_set_list_result *res;
4142 : : union {
4143 : : unsigned int lcorelist[RTE_MAX_LCORE];
4144 : : unsigned int portlist[RTE_MAX_ETHPORTS];
4145 : : } parsed_items;
4146 : : unsigned int nb_item;
4147 : :
4148 : 0 : if (test_done == 0) {
4149 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4150 : 0 : return;
4151 : : }
4152 : :
4153 : : res = parsed_result;
4154 : 0 : if (!strcmp(res->list_name, "corelist")) {
4155 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
4156 : : RTE_MAX_LCORE,
4157 : : parsed_items.lcorelist, 1);
4158 : 0 : if (nb_item > 0) {
4159 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
4160 : 0 : fwd_config_setup();
4161 : : }
4162 : 0 : return;
4163 : : }
4164 : 0 : if (!strcmp(res->list_name, "portlist")) {
4165 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
4166 : : RTE_MAX_ETHPORTS,
4167 : : parsed_items.portlist, 1);
4168 : 0 : if (nb_item > 0) {
4169 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
4170 : 0 : fwd_config_setup();
4171 : : }
4172 : : }
4173 : : }
4174 : :
4175 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
4176 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
4177 : : "set");
4178 : : static cmdline_parse_token_string_t cmd_set_list_name =
4179 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
4180 : : "corelist#portlist");
4181 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
4182 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
4183 : : TOKEN_STRING_MULTI);
4184 : :
4185 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
4186 : : .f = cmd_set_list_parsed,
4187 : : .data = NULL,
4188 : : .help_str = "set corelist|portlist <list0[,list1]*>",
4189 : : .tokens = {
4190 : : (void *)&cmd_set_list_keyword,
4191 : : (void *)&cmd_set_list_name,
4192 : : (void *)&cmd_set_list_of_items,
4193 : : NULL,
4194 : : },
4195 : : };
4196 : :
4197 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
4198 : :
4199 : : struct cmd_setmask_result {
4200 : : cmdline_fixed_string_t set;
4201 : : cmdline_fixed_string_t mask;
4202 : : uint64_t hexavalue;
4203 : : };
4204 : :
4205 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
4206 : : __rte_unused struct cmdline *cl,
4207 : : __rte_unused void *data)
4208 : : {
4209 : : struct cmd_setmask_result *res = parsed_result;
4210 : :
4211 : 0 : if (test_done == 0) {
4212 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4213 : 0 : return;
4214 : : }
4215 : 0 : if (!strcmp(res->mask, "coremask")) {
4216 : 0 : set_fwd_lcores_mask(res->hexavalue);
4217 : 0 : fwd_config_setup();
4218 : 0 : } else if (!strcmp(res->mask, "portmask")) {
4219 : 0 : set_fwd_ports_mask(res->hexavalue);
4220 : 0 : fwd_config_setup();
4221 : : }
4222 : : }
4223 : :
4224 : : static cmdline_parse_token_string_t cmd_setmask_set =
4225 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
4226 : : static cmdline_parse_token_string_t cmd_setmask_mask =
4227 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
4228 : : "coremask#portmask");
4229 : : static cmdline_parse_token_num_t cmd_setmask_value =
4230 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
4231 : :
4232 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
4233 : : .f = cmd_set_mask_parsed,
4234 : : .data = NULL,
4235 : : .help_str = "set coremask|portmask <hexadecimal value>",
4236 : : .tokens = {
4237 : : (void *)&cmd_setmask_set,
4238 : : (void *)&cmd_setmask_mask,
4239 : : (void *)&cmd_setmask_value,
4240 : : NULL,
4241 : : },
4242 : : };
4243 : :
4244 : : /*
4245 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
4246 : : */
4247 : : struct cmd_set_result {
4248 : : cmdline_fixed_string_t set;
4249 : : cmdline_fixed_string_t what;
4250 : : uint16_t value;
4251 : : };
4252 : :
4253 : 0 : static void cmd_set_parsed(void *parsed_result,
4254 : : __rte_unused struct cmdline *cl,
4255 : : __rte_unused void *data)
4256 : : {
4257 : : struct cmd_set_result *res = parsed_result;
4258 : 0 : if (!strcmp(res->what, "nbport")) {
4259 : 0 : set_fwd_ports_number(res->value);
4260 : 0 : fwd_config_setup();
4261 : 0 : } else if (!strcmp(res->what, "nbcore")) {
4262 : 0 : set_fwd_lcores_number(res->value);
4263 : 0 : fwd_config_setup();
4264 : 0 : } else if (!strcmp(res->what, "burst"))
4265 : 0 : set_nb_pkt_per_burst(res->value);
4266 : 0 : else if (!strcmp(res->what, "verbose"))
4267 : 0 : set_verbose_level(res->value);
4268 : 0 : }
4269 : :
4270 : : static cmdline_parse_token_string_t cmd_set_set =
4271 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
4272 : : static cmdline_parse_token_string_t cmd_set_what =
4273 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
4274 : : "nbport#nbcore#burst#verbose");
4275 : : static cmdline_parse_token_num_t cmd_set_value =
4276 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
4277 : :
4278 : : static cmdline_parse_inst_t cmd_set_numbers = {
4279 : : .f = cmd_set_parsed,
4280 : : .data = NULL,
4281 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
4282 : : .tokens = {
4283 : : (void *)&cmd_set_set,
4284 : : (void *)&cmd_set_what,
4285 : : (void *)&cmd_set_value,
4286 : : NULL,
4287 : : },
4288 : : };
4289 : :
4290 : : /* *** SET LOG LEVEL CONFIGURATION *** */
4291 : :
4292 : : struct cmd_set_log_result {
4293 : : cmdline_fixed_string_t set;
4294 : : cmdline_fixed_string_t log;
4295 : : cmdline_fixed_string_t type;
4296 : : uint32_t level;
4297 : : };
4298 : :
4299 : : static void
4300 : 0 : cmd_set_log_parsed(void *parsed_result,
4301 : : __rte_unused struct cmdline *cl,
4302 : : __rte_unused void *data)
4303 : : {
4304 : : struct cmd_set_log_result *res;
4305 : : int ret;
4306 : :
4307 : : res = parsed_result;
4308 : 0 : if (!strcmp(res->type, "global"))
4309 : 0 : rte_log_set_global_level(res->level);
4310 : : else {
4311 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
4312 : 0 : if (ret < 0)
4313 : 0 : fprintf(stderr, "Unable to set log level\n");
4314 : : }
4315 : 0 : }
4316 : :
4317 : : static cmdline_parse_token_string_t cmd_set_log_set =
4318 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
4319 : : static cmdline_parse_token_string_t cmd_set_log_log =
4320 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
4321 : : static cmdline_parse_token_string_t cmd_set_log_type =
4322 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
4323 : : static cmdline_parse_token_num_t cmd_set_log_level =
4324 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
4325 : :
4326 : : static cmdline_parse_inst_t cmd_set_log = {
4327 : : .f = cmd_set_log_parsed,
4328 : : .data = NULL,
4329 : : .help_str = "set log global|<type> <level>",
4330 : : .tokens = {
4331 : : (void *)&cmd_set_log_set,
4332 : : (void *)&cmd_set_log_log,
4333 : : (void *)&cmd_set_log_type,
4334 : : (void *)&cmd_set_log_level,
4335 : : NULL,
4336 : : },
4337 : : };
4338 : :
4339 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
4340 : :
4341 : : struct cmd_set_rxoffs_result {
4342 : : cmdline_fixed_string_t cmd_keyword;
4343 : : cmdline_fixed_string_t rxoffs;
4344 : : cmdline_fixed_string_t seg_offsets;
4345 : : };
4346 : :
4347 : : static void
4348 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
4349 : : __rte_unused struct cmdline *cl,
4350 : : __rte_unused void *data)
4351 : : {
4352 : : struct cmd_set_rxoffs_result *res;
4353 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
4354 : : unsigned int nb_segs;
4355 : :
4356 : : res = parsed_result;
4357 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
4358 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
4359 : 0 : if (nb_segs > 0)
4360 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
4361 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4362 : 0 : }
4363 : :
4364 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
4365 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4366 : : cmd_keyword, "set");
4367 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
4368 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4369 : : rxoffs, "rxoffs");
4370 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
4371 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4372 : : seg_offsets, NULL);
4373 : :
4374 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
4375 : : .f = cmd_set_rxoffs_parsed,
4376 : : .data = NULL,
4377 : : .help_str = "set rxoffs <len0[,len1]*>",
4378 : : .tokens = {
4379 : : (void *)&cmd_set_rxoffs_keyword,
4380 : : (void *)&cmd_set_rxoffs_name,
4381 : : (void *)&cmd_set_rxoffs_offsets,
4382 : : NULL,
4383 : : },
4384 : : };
4385 : :
4386 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
4387 : :
4388 : : struct cmd_set_rxpkts_result {
4389 : : cmdline_fixed_string_t cmd_keyword;
4390 : : cmdline_fixed_string_t rxpkts;
4391 : : cmdline_fixed_string_t seg_lengths;
4392 : : };
4393 : :
4394 : : static void
4395 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
4396 : : __rte_unused struct cmdline *cl,
4397 : : __rte_unused void *data)
4398 : : {
4399 : : struct cmd_set_rxpkts_result *res;
4400 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
4401 : : unsigned int nb_segs;
4402 : :
4403 : : res = parsed_result;
4404 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4405 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
4406 : 0 : if (nb_segs > 0)
4407 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
4408 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4409 : 0 : }
4410 : :
4411 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
4412 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4413 : : cmd_keyword, "set");
4414 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
4415 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4416 : : rxpkts, "rxpkts");
4417 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4418 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4419 : : seg_lengths, NULL);
4420 : :
4421 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
4422 : : .f = cmd_set_rxpkts_parsed,
4423 : : .data = NULL,
4424 : : .help_str = "set rxpkts <len0[,len1]*>",
4425 : : .tokens = {
4426 : : (void *)&cmd_set_rxpkts_keyword,
4427 : : (void *)&cmd_set_rxpkts_name,
4428 : : (void *)&cmd_set_rxpkts_lengths,
4429 : : NULL,
4430 : : },
4431 : : };
4432 : :
4433 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4434 : : struct cmd_set_rxhdrs_result {
4435 : : cmdline_fixed_string_t set;
4436 : : cmdline_fixed_string_t rxhdrs;
4437 : : cmdline_fixed_string_t values;
4438 : : };
4439 : :
4440 : : static void
4441 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4442 : : __rte_unused struct cmdline *cl,
4443 : : __rte_unused void *data)
4444 : : {
4445 : : struct cmd_set_rxhdrs_result *res;
4446 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4447 : : unsigned int nb_segs;
4448 : :
4449 : : res = parsed_result;
4450 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4451 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4452 : 0 : if (nb_segs > 0)
4453 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4454 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4455 : 0 : }
4456 : :
4457 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4458 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4459 : : set, "set");
4460 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4461 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4462 : : rxhdrs, "rxhdrs");
4463 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4464 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4465 : : values, NULL);
4466 : :
4467 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4468 : : .f = cmd_set_rxhdrs_parsed,
4469 : : .data = NULL,
4470 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4471 : : .tokens = {
4472 : : (void *)&cmd_set_rxhdrs_set,
4473 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4474 : : (void *)&cmd_set_rxhdrs_values,
4475 : : NULL,
4476 : : },
4477 : : };
4478 : :
4479 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4480 : :
4481 : : struct cmd_set_txpkts_result {
4482 : : cmdline_fixed_string_t cmd_keyword;
4483 : : cmdline_fixed_string_t txpkts;
4484 : : cmdline_fixed_string_t seg_lengths;
4485 : : };
4486 : :
4487 : : static void
4488 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4489 : : __rte_unused struct cmdline *cl,
4490 : : __rte_unused void *data)
4491 : : {
4492 : : struct cmd_set_txpkts_result *res;
4493 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4494 : : unsigned int nb_segs;
4495 : :
4496 : : res = parsed_result;
4497 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4498 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4499 : 0 : if (nb_segs > 0)
4500 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4501 : 0 : }
4502 : :
4503 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4504 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4505 : : cmd_keyword, "set");
4506 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4507 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4508 : : txpkts, "txpkts");
4509 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4510 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4511 : : seg_lengths, NULL);
4512 : :
4513 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4514 : : .f = cmd_set_txpkts_parsed,
4515 : : .data = NULL,
4516 : : .help_str = "set txpkts <len0[,len1]*>",
4517 : : .tokens = {
4518 : : (void *)&cmd_set_txpkts_keyword,
4519 : : (void *)&cmd_set_txpkts_name,
4520 : : (void *)&cmd_set_txpkts_lengths,
4521 : : NULL,
4522 : : },
4523 : : };
4524 : :
4525 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4526 : :
4527 : : struct cmd_set_txsplit_result {
4528 : : cmdline_fixed_string_t cmd_keyword;
4529 : : cmdline_fixed_string_t txsplit;
4530 : : cmdline_fixed_string_t mode;
4531 : : };
4532 : :
4533 : : static void
4534 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4535 : : __rte_unused struct cmdline *cl,
4536 : : __rte_unused void *data)
4537 : : {
4538 : : struct cmd_set_txsplit_result *res;
4539 : :
4540 : : res = parsed_result;
4541 : 0 : set_tx_pkt_split(res->mode);
4542 : 0 : }
4543 : :
4544 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4545 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4546 : : cmd_keyword, "set");
4547 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4548 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4549 : : txsplit, "txsplit");
4550 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4551 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4552 : : mode, NULL);
4553 : :
4554 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4555 : : .f = cmd_set_txsplit_parsed,
4556 : : .data = NULL,
4557 : : .help_str = "set txsplit on|off|rand",
4558 : : .tokens = {
4559 : : (void *)&cmd_set_txsplit_keyword,
4560 : : (void *)&cmd_set_txsplit_name,
4561 : : (void *)&cmd_set_txsplit_mode,
4562 : : NULL,
4563 : : },
4564 : : };
4565 : :
4566 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4567 : :
4568 : : struct cmd_set_txtimes_result {
4569 : : cmdline_fixed_string_t cmd_keyword;
4570 : : cmdline_fixed_string_t txtimes;
4571 : : cmdline_fixed_string_t tx_times;
4572 : : };
4573 : :
4574 : : static void
4575 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4576 : : __rte_unused struct cmdline *cl,
4577 : : __rte_unused void *data)
4578 : : {
4579 : : struct cmd_set_txtimes_result *res;
4580 : 0 : unsigned int tx_times[2] = {0, 0};
4581 : : unsigned int n_times;
4582 : :
4583 : : res = parsed_result;
4584 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4585 : : 2, tx_times, 0);
4586 : 0 : if (n_times == 2)
4587 : 0 : set_tx_pkt_times(tx_times);
4588 : 0 : }
4589 : :
4590 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4591 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4592 : : cmd_keyword, "set");
4593 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4594 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4595 : : txtimes, "txtimes");
4596 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4597 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4598 : : tx_times, NULL);
4599 : :
4600 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4601 : : .f = cmd_set_txtimes_parsed,
4602 : : .data = NULL,
4603 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4604 : : .tokens = {
4605 : : (void *)&cmd_set_txtimes_keyword,
4606 : : (void *)&cmd_set_txtimes_name,
4607 : : (void *)&cmd_set_txtimes_value,
4608 : : NULL,
4609 : : },
4610 : : };
4611 : :
4612 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4613 : : struct cmd_rx_vlan_filter_all_result {
4614 : : cmdline_fixed_string_t rx_vlan;
4615 : : cmdline_fixed_string_t what;
4616 : : cmdline_fixed_string_t all;
4617 : : portid_t port_id;
4618 : : };
4619 : :
4620 : : static void
4621 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4622 : : __rte_unused struct cmdline *cl,
4623 : : __rte_unused void *data)
4624 : : {
4625 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4626 : :
4627 : 0 : if (!strcmp(res->what, "add"))
4628 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4629 : : else
4630 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4631 : 0 : }
4632 : :
4633 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4634 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4635 : : rx_vlan, "rx_vlan");
4636 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4637 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4638 : : what, "add#rm");
4639 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4640 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4641 : : all, "all");
4642 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4643 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4644 : : port_id, RTE_UINT16);
4645 : :
4646 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4647 : : .f = cmd_rx_vlan_filter_all_parsed,
4648 : : .data = NULL,
4649 : : .help_str = "rx_vlan add|rm all <port_id>: "
4650 : : "Add/Remove all identifiers to/from the set of VLAN "
4651 : : "identifiers filtered by a port",
4652 : : .tokens = {
4653 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4654 : : (void *)&cmd_rx_vlan_filter_all_what,
4655 : : (void *)&cmd_rx_vlan_filter_all_all,
4656 : : (void *)&cmd_rx_vlan_filter_all_portid,
4657 : : NULL,
4658 : : },
4659 : : };
4660 : :
4661 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4662 : : struct cmd_vlan_offload_result {
4663 : : cmdline_fixed_string_t vlan;
4664 : : cmdline_fixed_string_t set;
4665 : : cmdline_fixed_string_t vlan_type;
4666 : : cmdline_fixed_string_t what;
4667 : : cmdline_fixed_string_t on;
4668 : : cmdline_fixed_string_t port_id;
4669 : : };
4670 : :
4671 : : static void
4672 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4673 : : __rte_unused struct cmdline *cl,
4674 : : __rte_unused void *data)
4675 : : {
4676 : : int on;
4677 : : struct cmd_vlan_offload_result *res = parsed_result;
4678 : : char *str;
4679 : : int i, len = 0;
4680 : : portid_t port_id = 0;
4681 : : unsigned int tmp;
4682 : :
4683 : 0 : str = res->port_id;
4684 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4685 : : i = 0;
4686 : : /* Get port_id first */
4687 : 0 : while(i < len){
4688 : 0 : if(str[i] == ',')
4689 : : break;
4690 : :
4691 : 0 : i++;
4692 : : }
4693 : 0 : str[i]='\0';
4694 : 0 : tmp = strtoul(str, NULL, 0);
4695 : : /* If port_id greater that what portid_t can represent, return */
4696 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4697 : : return;
4698 : 0 : port_id = (portid_t)tmp;
4699 : :
4700 : 0 : if (!strcmp(res->on, "on"))
4701 : : on = 1;
4702 : : else
4703 : : on = 0;
4704 : :
4705 : 0 : if (!strcmp(res->what, "strip"))
4706 : 0 : rx_vlan_strip_set(port_id, on);
4707 : 0 : else if(!strcmp(res->what, "stripq")){
4708 : : uint16_t queue_id = 0;
4709 : :
4710 : : /* No queue_id, return */
4711 : 0 : if(i + 1 >= len) {
4712 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4713 : 0 : return;
4714 : : }
4715 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4716 : : /* If queue_id greater that what 16-bits can represent, return */
4717 : 0 : if(tmp > 0xffff)
4718 : : return;
4719 : :
4720 : 0 : queue_id = (uint16_t)tmp;
4721 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4722 : : }
4723 : 0 : else if (!strcmp(res->what, "filter"))
4724 : 0 : rx_vlan_filter_set(port_id, on);
4725 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4726 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4727 : : else
4728 : 0 : vlan_extend_set(port_id, on);
4729 : :
4730 : : return;
4731 : : }
4732 : :
4733 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4734 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4735 : : vlan, "vlan");
4736 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4737 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4738 : : set, "set");
4739 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4740 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4741 : : what, "strip#filter#qinq_strip#extend#stripq");
4742 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4743 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4744 : : on, "on#off");
4745 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4746 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4747 : : port_id, NULL);
4748 : :
4749 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4750 : : .f = cmd_vlan_offload_parsed,
4751 : : .data = NULL,
4752 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4753 : : "<port_id[,queue_id]>: "
4754 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4755 : : .tokens = {
4756 : : (void *)&cmd_vlan_offload_vlan,
4757 : : (void *)&cmd_vlan_offload_set,
4758 : : (void *)&cmd_vlan_offload_what,
4759 : : (void *)&cmd_vlan_offload_on,
4760 : : (void *)&cmd_vlan_offload_portid,
4761 : : NULL,
4762 : : },
4763 : : };
4764 : :
4765 : : /* *** VLAN TPID SET ON A PORT *** */
4766 : : struct cmd_vlan_tpid_result {
4767 : : cmdline_fixed_string_t vlan;
4768 : : cmdline_fixed_string_t set;
4769 : : cmdline_fixed_string_t vlan_type;
4770 : : cmdline_fixed_string_t what;
4771 : : uint16_t tp_id;
4772 : : portid_t port_id;
4773 : : };
4774 : :
4775 : : static void
4776 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4777 : : __rte_unused struct cmdline *cl,
4778 : : __rte_unused void *data)
4779 : : {
4780 : : struct cmd_vlan_tpid_result *res = parsed_result;
4781 : : enum rte_vlan_type vlan_type;
4782 : :
4783 : 0 : if (!strcmp(res->vlan_type, "inner"))
4784 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4785 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4786 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4787 : : else {
4788 : 0 : fprintf(stderr, "Unknown vlan type\n");
4789 : 0 : return;
4790 : : }
4791 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4792 : : }
4793 : :
4794 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4795 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4796 : : vlan, "vlan");
4797 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4798 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4799 : : set, "set");
4800 : : static cmdline_parse_token_string_t cmd_vlan_type =
4801 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4802 : : vlan_type, "inner#outer");
4803 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4804 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4805 : : what, "tpid");
4806 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4807 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4808 : : tp_id, RTE_UINT16);
4809 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4810 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4811 : : port_id, RTE_UINT16);
4812 : :
4813 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4814 : : .f = cmd_vlan_tpid_parsed,
4815 : : .data = NULL,
4816 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4817 : : "Set the VLAN Ether type",
4818 : : .tokens = {
4819 : : (void *)&cmd_vlan_tpid_vlan,
4820 : : (void *)&cmd_vlan_tpid_set,
4821 : : (void *)&cmd_vlan_type,
4822 : : (void *)&cmd_vlan_tpid_what,
4823 : : (void *)&cmd_vlan_tpid_tpid,
4824 : : (void *)&cmd_vlan_tpid_portid,
4825 : : NULL,
4826 : : },
4827 : : };
4828 : :
4829 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4830 : : struct cmd_rx_vlan_filter_result {
4831 : : cmdline_fixed_string_t rx_vlan;
4832 : : cmdline_fixed_string_t what;
4833 : : uint16_t vlan_id;
4834 : : portid_t port_id;
4835 : : };
4836 : :
4837 : : static void
4838 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4839 : : __rte_unused struct cmdline *cl,
4840 : : __rte_unused void *data)
4841 : : {
4842 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4843 : :
4844 : 0 : if (!strcmp(res->what, "add"))
4845 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4846 : : else
4847 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4848 : 0 : }
4849 : :
4850 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4851 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4852 : : rx_vlan, "rx_vlan");
4853 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4854 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4855 : : what, "add#rm");
4856 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4857 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4858 : : vlan_id, RTE_UINT16);
4859 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4860 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4861 : : port_id, RTE_UINT16);
4862 : :
4863 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4864 : : .f = cmd_rx_vlan_filter_parsed,
4865 : : .data = NULL,
4866 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4867 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4868 : : "identifiers filtered by a port",
4869 : : .tokens = {
4870 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4871 : : (void *)&cmd_rx_vlan_filter_what,
4872 : : (void *)&cmd_rx_vlan_filter_vlanid,
4873 : : (void *)&cmd_rx_vlan_filter_portid,
4874 : : NULL,
4875 : : },
4876 : : };
4877 : :
4878 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4879 : : struct cmd_tx_vlan_set_result {
4880 : : cmdline_fixed_string_t tx_vlan;
4881 : : cmdline_fixed_string_t set;
4882 : : portid_t port_id;
4883 : : uint16_t vlan_id;
4884 : : };
4885 : :
4886 : : static void
4887 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4888 : : __rte_unused struct cmdline *cl,
4889 : : __rte_unused void *data)
4890 : : {
4891 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4892 : :
4893 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4894 : : return;
4895 : :
4896 : 0 : if (!port_is_stopped(res->port_id)) {
4897 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4898 : 0 : return;
4899 : : }
4900 : :
4901 : 0 : tx_vlan_set(res->port_id, res->vlan_id);
4902 : :
4903 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4904 : : }
4905 : :
4906 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4907 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4908 : : tx_vlan, "tx_vlan");
4909 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4910 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4911 : : set, "set");
4912 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4913 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4914 : : port_id, RTE_UINT16);
4915 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4916 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4917 : : vlan_id, RTE_UINT16);
4918 : :
4919 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4920 : : .f = cmd_tx_vlan_set_parsed,
4921 : : .data = NULL,
4922 : : .help_str = "tx_vlan set <port_id> <vlan_id>: "
4923 : : "Enable hardware insertion of a single VLAN header "
4924 : : "with a given TAG Identifier in packets sent on a port",
4925 : : .tokens = {
4926 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4927 : : (void *)&cmd_tx_vlan_set_set,
4928 : : (void *)&cmd_tx_vlan_set_portid,
4929 : : (void *)&cmd_tx_vlan_set_vlanid,
4930 : : NULL,
4931 : : },
4932 : : };
4933 : :
4934 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4935 : : struct cmd_tx_vlan_set_qinq_result {
4936 : : cmdline_fixed_string_t tx_vlan;
4937 : : cmdline_fixed_string_t set;
4938 : : portid_t port_id;
4939 : : uint16_t vlan_id;
4940 : : uint16_t vlan_id_outer;
4941 : : };
4942 : :
4943 : : static void
4944 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4945 : : __rte_unused struct cmdline *cl,
4946 : : __rte_unused void *data)
4947 : : {
4948 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4949 : :
4950 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4951 : : return;
4952 : :
4953 : 0 : if (!port_is_stopped(res->port_id)) {
4954 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4955 : 0 : return;
4956 : : }
4957 : :
4958 : 0 : tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4959 : :
4960 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4961 : : }
4962 : :
4963 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4964 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4965 : : tx_vlan, "tx_vlan");
4966 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4967 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4968 : : set, "set");
4969 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4970 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4971 : : port_id, RTE_UINT16);
4972 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4973 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4974 : : vlan_id, RTE_UINT16);
4975 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4976 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4977 : : vlan_id_outer, RTE_UINT16);
4978 : :
4979 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4980 : : .f = cmd_tx_vlan_set_qinq_parsed,
4981 : : .data = NULL,
4982 : : .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4983 : : "Enable hardware insertion of double VLAN header "
4984 : : "with given TAG Identifiers in packets sent on a port",
4985 : : .tokens = {
4986 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4987 : : (void *)&cmd_tx_vlan_set_qinq_set,
4988 : : (void *)&cmd_tx_vlan_set_qinq_portid,
4989 : : (void *)&cmd_tx_vlan_set_qinq_vlanid,
4990 : : (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4991 : : NULL,
4992 : : },
4993 : : };
4994 : :
4995 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4996 : : struct cmd_tx_vlan_set_pvid_result {
4997 : : cmdline_fixed_string_t tx_vlan;
4998 : : cmdline_fixed_string_t set;
4999 : : cmdline_fixed_string_t pvid;
5000 : : portid_t port_id;
5001 : : uint16_t vlan_id;
5002 : : cmdline_fixed_string_t mode;
5003 : : };
5004 : :
5005 : : static void
5006 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
5007 : : __rte_unused struct cmdline *cl,
5008 : : __rte_unused void *data)
5009 : : {
5010 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
5011 : :
5012 : 0 : if (strcmp(res->mode, "on") == 0)
5013 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
5014 : : else
5015 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
5016 : 0 : }
5017 : :
5018 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
5019 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5020 : : tx_vlan, "tx_vlan");
5021 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
5022 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5023 : : set, "set");
5024 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
5025 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5026 : : pvid, "pvid");
5027 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
5028 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5029 : : port_id, RTE_UINT16);
5030 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
5031 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5032 : : vlan_id, RTE_UINT16);
5033 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
5034 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5035 : : mode, "on#off");
5036 : :
5037 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
5038 : : .f = cmd_tx_vlan_set_pvid_parsed,
5039 : : .data = NULL,
5040 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
5041 : : .tokens = {
5042 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
5043 : : (void *)&cmd_tx_vlan_set_pvid_set,
5044 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
5045 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
5046 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
5047 : : (void *)&cmd_tx_vlan_set_pvid_mode,
5048 : : NULL,
5049 : : },
5050 : : };
5051 : :
5052 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
5053 : : struct cmd_tx_vlan_reset_result {
5054 : : cmdline_fixed_string_t tx_vlan;
5055 : : cmdline_fixed_string_t reset;
5056 : : portid_t port_id;
5057 : : };
5058 : :
5059 : : static void
5060 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
5061 : : __rte_unused struct cmdline *cl,
5062 : : __rte_unused void *data)
5063 : : {
5064 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
5065 : :
5066 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5067 : : return;
5068 : :
5069 : 0 : if (!port_is_stopped(res->port_id)) {
5070 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5071 : 0 : return;
5072 : : }
5073 : :
5074 : 0 : tx_vlan_reset(res->port_id);
5075 : :
5076 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5077 : : }
5078 : :
5079 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
5080 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5081 : : tx_vlan, "tx_vlan");
5082 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
5083 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5084 : : reset, "reset");
5085 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
5086 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
5087 : : port_id, RTE_UINT16);
5088 : :
5089 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
5090 : : .f = cmd_tx_vlan_reset_parsed,
5091 : : .data = NULL,
5092 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
5093 : : "VLAN header in packets sent on a port",
5094 : : .tokens = {
5095 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
5096 : : (void *)&cmd_tx_vlan_reset_reset,
5097 : : (void *)&cmd_tx_vlan_reset_portid,
5098 : : NULL,
5099 : : },
5100 : : };
5101 : :
5102 : :
5103 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
5104 : : struct cmd_csum_result {
5105 : : cmdline_fixed_string_t csum;
5106 : : cmdline_fixed_string_t mode;
5107 : : cmdline_fixed_string_t proto;
5108 : : cmdline_fixed_string_t hwsw;
5109 : : portid_t port_id;
5110 : : };
5111 : :
5112 : : static void
5113 : 0 : csum_show(int port_id)
5114 : : {
5115 : : struct rte_eth_dev_info dev_info;
5116 : : uint64_t tx_offloads;
5117 : : int ret;
5118 : :
5119 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
5120 : 0 : printf("Parse tunnel is %s\n",
5121 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
5122 : 0 : printf("IP checksum offload is %s\n",
5123 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
5124 : 0 : printf("UDP checksum offload is %s\n",
5125 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
5126 : 0 : printf("TCP checksum offload is %s\n",
5127 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
5128 : 0 : printf("SCTP checksum offload is %s\n",
5129 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
5130 : 0 : printf("Outer-Ip checksum offload is %s\n",
5131 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
5132 : 0 : printf("Outer-Udp checksum offload is %s\n",
5133 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
5134 : :
5135 : : /* display warnings if configuration is not supported by the NIC */
5136 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
5137 : 0 : if (ret != 0)
5138 : 0 : return;
5139 : :
5140 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
5141 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
5142 : 0 : fprintf(stderr,
5143 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
5144 : : port_id);
5145 : : }
5146 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
5147 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
5148 : 0 : fprintf(stderr,
5149 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
5150 : : port_id);
5151 : : }
5152 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
5153 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
5154 : 0 : fprintf(stderr,
5155 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
5156 : : port_id);
5157 : : }
5158 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
5159 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
5160 : 0 : fprintf(stderr,
5161 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
5162 : : port_id);
5163 : : }
5164 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
5165 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
5166 : 0 : fprintf(stderr,
5167 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
5168 : : port_id);
5169 : : }
5170 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
5171 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
5172 : : == 0) {
5173 : 0 : fprintf(stderr,
5174 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
5175 : : port_id);
5176 : : }
5177 : : }
5178 : :
5179 : : static void
5180 : : cmd_config_queue_tx_offloads(struct rte_port *port)
5181 : : {
5182 : : int k;
5183 : :
5184 : : /* Apply queue tx offloads configuration */
5185 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
5186 : 0 : port->txq[k].conf.offloads =
5187 : 0 : port->dev_conf.txmode.offloads;
5188 : : }
5189 : :
5190 : : static void
5191 : 0 : cmd_csum_parsed(void *parsed_result,
5192 : : __rte_unused struct cmdline *cl,
5193 : : __rte_unused void *data)
5194 : : {
5195 : : struct cmd_csum_result *res = parsed_result;
5196 : : int hw = 0;
5197 : : uint64_t csum_offloads = 0;
5198 : : struct rte_eth_dev_info dev_info;
5199 : : int ret;
5200 : :
5201 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
5202 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
5203 : 0 : return;
5204 : : }
5205 : 0 : if (!port_is_stopped(res->port_id)) {
5206 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5207 : 0 : return;
5208 : : }
5209 : :
5210 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5211 : 0 : if (ret != 0)
5212 : : return;
5213 : :
5214 : 0 : if (!strcmp(res->mode, "set")) {
5215 : :
5216 : 0 : if (!strcmp(res->hwsw, "hw"))
5217 : : hw = 1;
5218 : :
5219 : 0 : if (!strcmp(res->proto, "ip")) {
5220 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5221 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
5222 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
5223 : : } else {
5224 : 0 : fprintf(stderr,
5225 : : "IP checksum offload is not supported by port %u\n",
5226 : 0 : res->port_id);
5227 : : }
5228 : 0 : } else if (!strcmp(res->proto, "udp")) {
5229 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5230 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
5231 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
5232 : : } else {
5233 : 0 : fprintf(stderr,
5234 : : "UDP checksum offload is not supported by port %u\n",
5235 : 0 : res->port_id);
5236 : : }
5237 : 0 : } else if (!strcmp(res->proto, "tcp")) {
5238 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5239 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
5240 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
5241 : : } else {
5242 : 0 : fprintf(stderr,
5243 : : "TCP checksum offload is not supported by port %u\n",
5244 : 0 : res->port_id);
5245 : : }
5246 : 0 : } else if (!strcmp(res->proto, "sctp")) {
5247 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5248 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
5249 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
5250 : : } else {
5251 : 0 : fprintf(stderr,
5252 : : "SCTP checksum offload is not supported by port %u\n",
5253 : 0 : res->port_id);
5254 : : }
5255 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
5256 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5257 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5258 : : csum_offloads |=
5259 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
5260 : : } else {
5261 : 0 : fprintf(stderr,
5262 : : "Outer IP checksum offload is not supported by port %u\n",
5263 : 0 : res->port_id);
5264 : : }
5265 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
5266 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5267 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
5268 : : csum_offloads |=
5269 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
5270 : : } else {
5271 : 0 : fprintf(stderr,
5272 : : "Outer UDP checksum offload is not supported by port %u\n",
5273 : 0 : res->port_id);
5274 : : }
5275 : : }
5276 : :
5277 : 0 : if (hw) {
5278 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5279 : : csum_offloads;
5280 : : } else {
5281 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5282 : 0 : (~csum_offloads);
5283 : : }
5284 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5285 : : }
5286 : 0 : csum_show(res->port_id);
5287 : :
5288 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5289 : : }
5290 : :
5291 : : static cmdline_parse_token_string_t cmd_csum_csum =
5292 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5293 : : csum, "csum");
5294 : : static cmdline_parse_token_string_t cmd_csum_mode =
5295 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5296 : : mode, "set");
5297 : : static cmdline_parse_token_string_t cmd_csum_proto =
5298 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5299 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
5300 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
5301 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5302 : : hwsw, "hw#sw");
5303 : : static cmdline_parse_token_num_t cmd_csum_portid =
5304 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
5305 : : port_id, RTE_UINT16);
5306 : :
5307 : : static cmdline_parse_inst_t cmd_csum_set = {
5308 : : .f = cmd_csum_parsed,
5309 : : .data = NULL,
5310 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
5311 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
5312 : : "using csum forward engine",
5313 : : .tokens = {
5314 : : (void *)&cmd_csum_csum,
5315 : : (void *)&cmd_csum_mode,
5316 : : (void *)&cmd_csum_proto,
5317 : : (void *)&cmd_csum_hwsw,
5318 : : (void *)&cmd_csum_portid,
5319 : : NULL,
5320 : : },
5321 : : };
5322 : :
5323 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
5324 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5325 : : mode, "show");
5326 : :
5327 : : static cmdline_parse_inst_t cmd_csum_show = {
5328 : : .f = cmd_csum_parsed,
5329 : : .data = NULL,
5330 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
5331 : : .tokens = {
5332 : : (void *)&cmd_csum_csum,
5333 : : (void *)&cmd_csum_mode_show,
5334 : : (void *)&cmd_csum_portid,
5335 : : NULL,
5336 : : },
5337 : : };
5338 : :
5339 : : /* Enable/disable tunnel parsing */
5340 : : struct cmd_csum_tunnel_result {
5341 : : cmdline_fixed_string_t csum;
5342 : : cmdline_fixed_string_t parse;
5343 : : cmdline_fixed_string_t onoff;
5344 : : portid_t port_id;
5345 : : };
5346 : :
5347 : : static void
5348 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
5349 : : __rte_unused struct cmdline *cl,
5350 : : __rte_unused void *data)
5351 : : {
5352 : : struct cmd_csum_tunnel_result *res = parsed_result;
5353 : :
5354 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5355 : : return;
5356 : :
5357 : 0 : if (!strcmp(res->onoff, "on"))
5358 : 0 : ports[res->port_id].parse_tunnel = 1;
5359 : : else
5360 : 0 : ports[res->port_id].parse_tunnel = 0;
5361 : :
5362 : 0 : csum_show(res->port_id);
5363 : : }
5364 : :
5365 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
5366 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5367 : : csum, "csum");
5368 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
5369 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5370 : : parse, "parse-tunnel");
5371 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
5372 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5373 : : onoff, "on#off");
5374 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
5375 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
5376 : : port_id, RTE_UINT16);
5377 : :
5378 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
5379 : : .f = cmd_csum_tunnel_parsed,
5380 : : .data = NULL,
5381 : : .help_str = "csum parse-tunnel on|off <port_id>: "
5382 : : "Enable/Disable parsing of tunnels for csum engine",
5383 : : .tokens = {
5384 : : (void *)&cmd_csum_tunnel_csum,
5385 : : (void *)&cmd_csum_tunnel_parse,
5386 : : (void *)&cmd_csum_tunnel_onoff,
5387 : : (void *)&cmd_csum_tunnel_portid,
5388 : : NULL,
5389 : : },
5390 : : };
5391 : :
5392 : : struct cmd_csum_mac_swap_result {
5393 : : cmdline_fixed_string_t csum;
5394 : : cmdline_fixed_string_t parse;
5395 : : cmdline_fixed_string_t onoff;
5396 : : portid_t port_id;
5397 : : };
5398 : :
5399 : : static void
5400 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
5401 : : __rte_unused struct cmdline *cl,
5402 : : __rte_unused void *data)
5403 : : {
5404 : : struct cmd_csum_mac_swap_result *res = parsed_result;
5405 : :
5406 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5407 : : return;
5408 : 0 : if (strcmp(res->onoff, "on") == 0)
5409 : 0 : ports[res->port_id].fwd_mac_swap = 1;
5410 : : else
5411 : 0 : ports[res->port_id].fwd_mac_swap = 0;
5412 : : }
5413 : :
5414 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
5415 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5416 : : csum, "csum");
5417 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
5418 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5419 : : parse, "mac-swap");
5420 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
5421 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5422 : : onoff, "on#off");
5423 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
5424 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
5425 : : port_id, RTE_UINT16);
5426 : :
5427 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
5428 : : .f = cmd_csum_mac_swap_parsed,
5429 : : .data = NULL,
5430 : : .help_str = "csum mac-swap on|off <port_id>: "
5431 : : "Enable/Disable forward mac address swap",
5432 : : .tokens = {
5433 : : (void *)&cmd_csum_mac_swap_csum,
5434 : : (void *)&cmd_csum_mac_swap_parse,
5435 : : (void *)&cmd_csum_mac_swap_onoff,
5436 : : (void *)&cmd_csum_mac_swap_portid,
5437 : : NULL,
5438 : : },
5439 : : };
5440 : :
5441 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5442 : : struct cmd_tso_set_result {
5443 : : cmdline_fixed_string_t tso;
5444 : : cmdline_fixed_string_t mode;
5445 : : uint16_t tso_segsz;
5446 : : portid_t port_id;
5447 : : };
5448 : :
5449 : : static void
5450 : 0 : cmd_tso_set_parsed(void *parsed_result,
5451 : : __rte_unused struct cmdline *cl,
5452 : : __rte_unused void *data)
5453 : : {
5454 : : struct cmd_tso_set_result *res = parsed_result;
5455 : : struct rte_eth_dev_info dev_info;
5456 : : uint64_t offloads;
5457 : : int ret;
5458 : :
5459 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5460 : 0 : return;
5461 : 0 : if (!port_is_stopped(res->port_id)) {
5462 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5463 : 0 : return;
5464 : : }
5465 : :
5466 : 0 : if (!strcmp(res->mode, "set"))
5467 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5468 : :
5469 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5470 : 0 : if (ret != 0)
5471 : : return;
5472 : :
5473 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5474 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5475 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5476 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5477 : : res->port_id);
5478 : 0 : return;
5479 : : }
5480 : : /* display warnings if configuration is not supported by the NIC */
5481 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5482 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5483 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5484 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5485 : : }
5486 : :
5487 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5488 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5489 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5490 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5491 : : } else {
5492 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5493 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5494 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5495 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5496 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5497 : 0 : printf("segment size for non-tunneled packets is %d\n",
5498 : : ports[res->port_id].tso_segsz);
5499 : : }
5500 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5501 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5502 : : }
5503 : :
5504 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5505 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5506 : : tso, "tso");
5507 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5508 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5509 : : mode, "set");
5510 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5511 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5512 : : tso_segsz, RTE_UINT16);
5513 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5514 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5515 : : port_id, RTE_UINT16);
5516 : :
5517 : : static cmdline_parse_inst_t cmd_tso_set = {
5518 : : .f = cmd_tso_set_parsed,
5519 : : .data = NULL,
5520 : : .help_str = "tso set <tso_segsz> <port_id>: "
5521 : : "Set TSO segment size of non-tunneled packets for csum engine "
5522 : : "(0 to disable)",
5523 : : .tokens = {
5524 : : (void *)&cmd_tso_set_tso,
5525 : : (void *)&cmd_tso_set_mode,
5526 : : (void *)&cmd_tso_set_tso_segsz,
5527 : : (void *)&cmd_tso_set_portid,
5528 : : NULL,
5529 : : },
5530 : : };
5531 : :
5532 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5533 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5534 : : mode, "show");
5535 : :
5536 : :
5537 : : static cmdline_parse_inst_t cmd_tso_show = {
5538 : : .f = cmd_tso_set_parsed,
5539 : : .data = NULL,
5540 : : .help_str = "tso show <port_id>: "
5541 : : "Show TSO segment size of non-tunneled packets for csum engine",
5542 : : .tokens = {
5543 : : (void *)&cmd_tso_set_tso,
5544 : : (void *)&cmd_tso_show_mode,
5545 : : (void *)&cmd_tso_set_portid,
5546 : : NULL,
5547 : : },
5548 : : };
5549 : :
5550 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5551 : : struct cmd_tunnel_tso_set_result {
5552 : : cmdline_fixed_string_t tso;
5553 : : cmdline_fixed_string_t mode;
5554 : : uint16_t tso_segsz;
5555 : : portid_t port_id;
5556 : : };
5557 : :
5558 : : static void
5559 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5560 : : {
5561 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5562 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5563 : : port_id);
5564 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5565 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5566 : : port_id);
5567 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5568 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5569 : : port_id);
5570 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5571 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5572 : : port_id);
5573 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5574 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5575 : : port_id);
5576 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5577 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5578 : : port_id);
5579 : 0 : }
5580 : :
5581 : : static void
5582 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5583 : : __rte_unused struct cmdline *cl,
5584 : : __rte_unused void *data)
5585 : : {
5586 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5587 : : struct rte_eth_dev_info dev_info;
5588 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5589 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5590 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5591 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5592 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5593 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5594 : : int ret;
5595 : :
5596 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5597 : 0 : return;
5598 : 0 : if (!port_is_stopped(res->port_id)) {
5599 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5600 : 0 : return;
5601 : : }
5602 : :
5603 : 0 : if (!strcmp(res->mode, "set"))
5604 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5605 : :
5606 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5607 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5608 : : printf("TSO for tunneled packets is disabled\n");
5609 : : } else {
5610 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5611 : 0 : if (ret != 0)
5612 : : return;
5613 : :
5614 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5615 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5616 : 0 : res->port_id);
5617 : 0 : return;
5618 : : }
5619 : :
5620 : : /* Below conditions are needed to make it work:
5621 : : * (1) tunnel TSO is supported by the NIC;
5622 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5623 : : * are recognized;
5624 : : * (3) for tunneled pkts with outer L3 of IPv4,
5625 : : * "csum set outer-ip" must be set to hw, because after tso,
5626 : : * total_len of outer IP header is changed, and the checksum
5627 : : * of outer IP header calculated by sw should be wrong; that
5628 : : * is not necessary for IPv6 tunneled pkts because there's no
5629 : : * checksum in IP header anymore.
5630 : : */
5631 : 0 : if (!ports[res->port_id].parse_tunnel) {
5632 : 0 : fprintf(stderr,
5633 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5634 : 0 : return;
5635 : : }
5636 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5637 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5638 : 0 : fprintf(stderr,
5639 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5640 : 0 : return;
5641 : : }
5642 : :
5643 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5644 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5645 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5646 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5647 : 0 : ports[res->port_id].tunnel_tso_segsz);
5648 : : }
5649 : :
5650 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5651 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5652 : : }
5653 : :
5654 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5655 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5656 : : tso, "tunnel_tso");
5657 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5658 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5659 : : mode, "set");
5660 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5661 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5662 : : tso_segsz, RTE_UINT16);
5663 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5664 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5665 : : port_id, RTE_UINT16);
5666 : :
5667 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5668 : : .f = cmd_tunnel_tso_set_parsed,
5669 : : .data = NULL,
5670 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5671 : : "Set TSO segment size of tunneled packets for csum engine "
5672 : : "(0 to disable)",
5673 : : .tokens = {
5674 : : (void *)&cmd_tunnel_tso_set_tso,
5675 : : (void *)&cmd_tunnel_tso_set_mode,
5676 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5677 : : (void *)&cmd_tunnel_tso_set_portid,
5678 : : NULL,
5679 : : },
5680 : : };
5681 : :
5682 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5683 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5684 : : mode, "show");
5685 : :
5686 : :
5687 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5688 : : .f = cmd_tunnel_tso_set_parsed,
5689 : : .data = NULL,
5690 : : .help_str = "tunnel_tso show <port_id> "
5691 : : "Show TSO segment size of tunneled packets for csum engine",
5692 : : .tokens = {
5693 : : (void *)&cmd_tunnel_tso_set_tso,
5694 : : (void *)&cmd_tunnel_tso_show_mode,
5695 : : (void *)&cmd_tunnel_tso_set_portid,
5696 : : NULL,
5697 : : },
5698 : : };
5699 : :
5700 : : #ifdef RTE_LIB_GRO
5701 : : /* *** SET GRO FOR A PORT *** */
5702 : : struct cmd_gro_enable_result {
5703 : : cmdline_fixed_string_t cmd_set;
5704 : : cmdline_fixed_string_t cmd_port;
5705 : : cmdline_fixed_string_t cmd_keyword;
5706 : : cmdline_fixed_string_t cmd_onoff;
5707 : : portid_t cmd_pid;
5708 : : };
5709 : :
5710 : : static void
5711 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5712 : : __rte_unused struct cmdline *cl,
5713 : : __rte_unused void *data)
5714 : : {
5715 : : struct cmd_gro_enable_result *res;
5716 : :
5717 : : res = parsed_result;
5718 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5719 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5720 : 0 : }
5721 : :
5722 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5723 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5724 : : cmd_set, "set");
5725 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5726 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5727 : : cmd_keyword, "port");
5728 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5729 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5730 : : cmd_pid, RTE_UINT16);
5731 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5732 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5733 : : cmd_keyword, "gro");
5734 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5735 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5736 : : cmd_onoff, "on#off");
5737 : :
5738 : : static cmdline_parse_inst_t cmd_gro_enable = {
5739 : : .f = cmd_gro_enable_parsed,
5740 : : .data = NULL,
5741 : : .help_str = "set port <port_id> gro on|off",
5742 : : .tokens = {
5743 : : (void *)&cmd_gro_enable_set,
5744 : : (void *)&cmd_gro_enable_port,
5745 : : (void *)&cmd_gro_enable_pid,
5746 : : (void *)&cmd_gro_enable_keyword,
5747 : : (void *)&cmd_gro_enable_onoff,
5748 : : NULL,
5749 : : },
5750 : : };
5751 : :
5752 : : /* *** DISPLAY GRO CONFIGURATION *** */
5753 : : struct cmd_gro_show_result {
5754 : : cmdline_fixed_string_t cmd_show;
5755 : : cmdline_fixed_string_t cmd_port;
5756 : : cmdline_fixed_string_t cmd_keyword;
5757 : : portid_t cmd_pid;
5758 : : };
5759 : :
5760 : : static void
5761 : 0 : cmd_gro_show_parsed(void *parsed_result,
5762 : : __rte_unused struct cmdline *cl,
5763 : : __rte_unused void *data)
5764 : : {
5765 : : struct cmd_gro_show_result *res;
5766 : :
5767 : : res = parsed_result;
5768 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5769 : 0 : show_gro(res->cmd_pid);
5770 : 0 : }
5771 : :
5772 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5773 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5774 : : cmd_show, "show");
5775 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5776 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5777 : : cmd_port, "port");
5778 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5779 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5780 : : cmd_pid, RTE_UINT16);
5781 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5782 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5783 : : cmd_keyword, "gro");
5784 : :
5785 : : static cmdline_parse_inst_t cmd_gro_show = {
5786 : : .f = cmd_gro_show_parsed,
5787 : : .data = NULL,
5788 : : .help_str = "show port <port_id> gro",
5789 : : .tokens = {
5790 : : (void *)&cmd_gro_show_show,
5791 : : (void *)&cmd_gro_show_port,
5792 : : (void *)&cmd_gro_show_pid,
5793 : : (void *)&cmd_gro_show_keyword,
5794 : : NULL,
5795 : : },
5796 : : };
5797 : :
5798 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5799 : : struct cmd_gro_flush_result {
5800 : : cmdline_fixed_string_t cmd_set;
5801 : : cmdline_fixed_string_t cmd_keyword;
5802 : : cmdline_fixed_string_t cmd_flush;
5803 : : uint8_t cmd_cycles;
5804 : : };
5805 : :
5806 : : static void
5807 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5808 : : __rte_unused struct cmdline *cl,
5809 : : __rte_unused void *data)
5810 : : {
5811 : : struct cmd_gro_flush_result *res;
5812 : :
5813 : : res = parsed_result;
5814 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5815 : 0 : (!strcmp(res->cmd_flush, "flush")))
5816 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5817 : 0 : }
5818 : :
5819 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5820 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5821 : : cmd_set, "set");
5822 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5823 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5824 : : cmd_keyword, "gro");
5825 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5826 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5827 : : cmd_flush, "flush");
5828 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5829 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5830 : : cmd_cycles, RTE_UINT8);
5831 : :
5832 : : static cmdline_parse_inst_t cmd_gro_flush = {
5833 : : .f = cmd_gro_flush_parsed,
5834 : : .data = NULL,
5835 : : .help_str = "set gro flush <cycles>",
5836 : : .tokens = {
5837 : : (void *)&cmd_gro_flush_set,
5838 : : (void *)&cmd_gro_flush_keyword,
5839 : : (void *)&cmd_gro_flush_flush,
5840 : : (void *)&cmd_gro_flush_cycles,
5841 : : NULL,
5842 : : },
5843 : : };
5844 : : #endif /* RTE_LIB_GRO */
5845 : :
5846 : : #ifdef RTE_LIB_GSO
5847 : : /* *** ENABLE/DISABLE GSO *** */
5848 : : struct cmd_gso_enable_result {
5849 : : cmdline_fixed_string_t cmd_set;
5850 : : cmdline_fixed_string_t cmd_port;
5851 : : cmdline_fixed_string_t cmd_keyword;
5852 : : cmdline_fixed_string_t cmd_mode;
5853 : : portid_t cmd_pid;
5854 : : };
5855 : :
5856 : : static void
5857 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5858 : : __rte_unused struct cmdline *cl,
5859 : : __rte_unused void *data)
5860 : : {
5861 : : struct cmd_gso_enable_result *res;
5862 : :
5863 : : res = parsed_result;
5864 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5865 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5866 : 0 : }
5867 : :
5868 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5869 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5870 : : cmd_set, "set");
5871 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5872 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5873 : : cmd_port, "port");
5874 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5875 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5876 : : cmd_keyword, "gso");
5877 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5878 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5879 : : cmd_mode, "on#off");
5880 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5881 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5882 : : cmd_pid, RTE_UINT16);
5883 : :
5884 : : static cmdline_parse_inst_t cmd_gso_enable = {
5885 : : .f = cmd_gso_enable_parsed,
5886 : : .data = NULL,
5887 : : .help_str = "set port <port_id> gso on|off",
5888 : : .tokens = {
5889 : : (void *)&cmd_gso_enable_set,
5890 : : (void *)&cmd_gso_enable_port,
5891 : : (void *)&cmd_gso_enable_pid,
5892 : : (void *)&cmd_gso_enable_keyword,
5893 : : (void *)&cmd_gso_enable_mode,
5894 : : NULL,
5895 : : },
5896 : : };
5897 : :
5898 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5899 : : struct cmd_gso_size_result {
5900 : : cmdline_fixed_string_t cmd_set;
5901 : : cmdline_fixed_string_t cmd_keyword;
5902 : : cmdline_fixed_string_t cmd_segsz;
5903 : : uint16_t cmd_size;
5904 : : };
5905 : :
5906 : : static void
5907 : 0 : cmd_gso_size_parsed(void *parsed_result,
5908 : : __rte_unused struct cmdline *cl,
5909 : : __rte_unused void *data)
5910 : : {
5911 : : struct cmd_gso_size_result *res = parsed_result;
5912 : :
5913 : 0 : if (test_done == 0) {
5914 : 0 : fprintf(stderr,
5915 : : "Before setting GSO segsz, please first stop forwarding\n");
5916 : 0 : return;
5917 : : }
5918 : :
5919 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5920 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5921 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5922 : 0 : fprintf(stderr,
5923 : : "gso_size should be larger than %zu. Please input a legal value\n",
5924 : : RTE_GSO_SEG_SIZE_MIN);
5925 : : else
5926 : 0 : gso_max_segment_size = res->cmd_size;
5927 : : }
5928 : : }
5929 : :
5930 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5931 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5932 : : cmd_set, "set");
5933 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5934 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5935 : : cmd_keyword, "gso");
5936 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5937 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5938 : : cmd_segsz, "segsz");
5939 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5940 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5941 : : cmd_size, RTE_UINT16);
5942 : :
5943 : : static cmdline_parse_inst_t cmd_gso_size = {
5944 : : .f = cmd_gso_size_parsed,
5945 : : .data = NULL,
5946 : : .help_str = "set gso segsz <length>",
5947 : : .tokens = {
5948 : : (void *)&cmd_gso_size_set,
5949 : : (void *)&cmd_gso_size_keyword,
5950 : : (void *)&cmd_gso_size_segsz,
5951 : : (void *)&cmd_gso_size_size,
5952 : : NULL,
5953 : : },
5954 : : };
5955 : :
5956 : : /* *** SHOW GSO CONFIGURATION *** */
5957 : : struct cmd_gso_show_result {
5958 : : cmdline_fixed_string_t cmd_show;
5959 : : cmdline_fixed_string_t cmd_port;
5960 : : cmdline_fixed_string_t cmd_keyword;
5961 : : portid_t cmd_pid;
5962 : : };
5963 : :
5964 : : static void
5965 : 0 : cmd_gso_show_parsed(void *parsed_result,
5966 : : __rte_unused struct cmdline *cl,
5967 : : __rte_unused void *data)
5968 : : {
5969 : : struct cmd_gso_show_result *res = parsed_result;
5970 : :
5971 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5972 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5973 : 0 : return;
5974 : : }
5975 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
5976 : 0 : if (gso_ports[res->cmd_pid].enable) {
5977 : 0 : printf("Max GSO'd packet size: %uB\n"
5978 : : "Supported GSO types: TCP/IPv4, "
5979 : : "UDP/IPv4, VxLAN with inner "
5980 : : "TCP/IPv4 packet, GRE with inner "
5981 : : "TCP/IPv4 packet\n",
5982 : : gso_max_segment_size);
5983 : : } else
5984 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5985 : : }
5986 : : }
5987 : :
5988 : : static cmdline_parse_token_string_t cmd_gso_show_show =
5989 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5990 : : cmd_show, "show");
5991 : : static cmdline_parse_token_string_t cmd_gso_show_port =
5992 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5993 : : cmd_port, "port");
5994 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
5995 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5996 : : cmd_keyword, "gso");
5997 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
5998 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5999 : : cmd_pid, RTE_UINT16);
6000 : :
6001 : : static cmdline_parse_inst_t cmd_gso_show = {
6002 : : .f = cmd_gso_show_parsed,
6003 : : .data = NULL,
6004 : : .help_str = "show port <port_id> gso",
6005 : : .tokens = {
6006 : : (void *)&cmd_gso_show_show,
6007 : : (void *)&cmd_gso_show_port,
6008 : : (void *)&cmd_gso_show_pid,
6009 : : (void *)&cmd_gso_show_keyword,
6010 : : NULL,
6011 : : },
6012 : : };
6013 : : #endif /* RTE_LIB_GSO */
6014 : :
6015 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
6016 : : struct cmd_set_flush_rx {
6017 : : cmdline_fixed_string_t set;
6018 : : cmdline_fixed_string_t flush_rx;
6019 : : cmdline_fixed_string_t mode;
6020 : : };
6021 : :
6022 : : static void
6023 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
6024 : : __rte_unused struct cmdline *cl,
6025 : : __rte_unused void *data)
6026 : : {
6027 : : struct cmd_set_flush_rx *res = parsed_result;
6028 : :
6029 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
6030 : : printf("multi-process doesn't support to flush Rx queues.\n");
6031 : 0 : return;
6032 : : }
6033 : :
6034 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6035 : : }
6036 : :
6037 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
6038 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6039 : : set, "set");
6040 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
6041 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6042 : : flush_rx, "flush_rx");
6043 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
6044 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6045 : : mode, "on#off");
6046 : :
6047 : :
6048 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
6049 : : .f = cmd_set_flush_rx_parsed,
6050 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
6051 : : .data = NULL,
6052 : : .tokens = {
6053 : : (void *)&cmd_setflushrx_set,
6054 : : (void *)&cmd_setflushrx_flush_rx,
6055 : : (void *)&cmd_setflushrx_mode,
6056 : : NULL,
6057 : : },
6058 : : };
6059 : :
6060 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
6061 : : struct cmd_set_link_check {
6062 : : cmdline_fixed_string_t set;
6063 : : cmdline_fixed_string_t link_check;
6064 : : cmdline_fixed_string_t mode;
6065 : : };
6066 : :
6067 : : static void
6068 : 0 : cmd_set_link_check_parsed(void *parsed_result,
6069 : : __rte_unused struct cmdline *cl,
6070 : : __rte_unused void *data)
6071 : : {
6072 : : struct cmd_set_link_check *res = parsed_result;
6073 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6074 : 0 : }
6075 : :
6076 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
6077 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6078 : : set, "set");
6079 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
6080 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6081 : : link_check, "link_check");
6082 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
6083 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6084 : : mode, "on#off");
6085 : :
6086 : :
6087 : : static cmdline_parse_inst_t cmd_set_link_check = {
6088 : : .f = cmd_set_link_check_parsed,
6089 : : .help_str = "set link_check on|off: Enable/Disable link status check "
6090 : : "when starting/stopping a port",
6091 : : .data = NULL,
6092 : : .tokens = {
6093 : : (void *)&cmd_setlinkcheck_set,
6094 : : (void *)&cmd_setlinkcheck_link_check,
6095 : : (void *)&cmd_setlinkcheck_mode,
6096 : : NULL,
6097 : : },
6098 : : };
6099 : :
6100 : : /* *** SET FORWARDING MODE *** */
6101 : : struct cmd_set_fwd_mode_result {
6102 : : cmdline_fixed_string_t set;
6103 : : cmdline_fixed_string_t fwd;
6104 : : cmdline_fixed_string_t mode;
6105 : : };
6106 : :
6107 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
6108 : : __rte_unused struct cmdline *cl,
6109 : : __rte_unused void *data)
6110 : : {
6111 : : struct cmd_set_fwd_mode_result *res = parsed_result;
6112 : :
6113 : 0 : retry_enabled = 0;
6114 : 0 : set_pkt_forwarding_mode(res->mode);
6115 : 0 : }
6116 : :
6117 : : static cmdline_parse_token_string_t cmd_setfwd_set =
6118 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6119 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
6120 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6121 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
6122 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6123 : : "" /* defined at init */);
6124 : :
6125 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
6126 : : .f = cmd_set_fwd_mode_parsed,
6127 : : .data = NULL,
6128 : : .help_str = NULL, /* defined at init */
6129 : : .tokens = {
6130 : : (void *)&cmd_setfwd_set,
6131 : : (void *)&cmd_setfwd_fwd,
6132 : : (void *)&cmd_setfwd_mode,
6133 : : NULL,
6134 : : },
6135 : : };
6136 : :
6137 : 0 : static void cmd_set_fwd_mode_init(void)
6138 : : {
6139 : : char *modes, *c;
6140 : : static char token[128];
6141 : : static char help[256];
6142 : : cmdline_parse_token_string_t *token_struct;
6143 : :
6144 : 0 : modes = list_pkt_forwarding_modes();
6145 : : snprintf(help, sizeof(help), "set fwd %s: "
6146 : : "Set packet forwarding mode", modes);
6147 : 0 : cmd_set_fwd_mode.help_str = help;
6148 : :
6149 : : /* string token separator is # */
6150 : 0 : for (c = token; *modes != '\0'; modes++)
6151 : 0 : if (*modes == '|')
6152 : 0 : *c++ = '#';
6153 : : else
6154 : 0 : *c++ = *modes;
6155 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6156 : 0 : token_struct->string_data.str = token;
6157 : 0 : }
6158 : :
6159 : : /* *** SET RETRY FORWARDING MODE *** */
6160 : : struct cmd_set_fwd_retry_mode_result {
6161 : : cmdline_fixed_string_t set;
6162 : : cmdline_fixed_string_t fwd;
6163 : : cmdline_fixed_string_t mode;
6164 : : cmdline_fixed_string_t retry;
6165 : : };
6166 : :
6167 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6168 : : __rte_unused struct cmdline *cl,
6169 : : __rte_unused void *data)
6170 : : {
6171 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6172 : :
6173 : 0 : retry_enabled = 1;
6174 : 0 : set_pkt_forwarding_mode(res->mode);
6175 : 0 : }
6176 : :
6177 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6178 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6179 : : set, "set");
6180 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6181 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6182 : : fwd, "fwd");
6183 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6184 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6185 : : mode,
6186 : : "" /* defined at init */);
6187 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6188 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6189 : : retry, "retry");
6190 : :
6191 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6192 : : .f = cmd_set_fwd_retry_mode_parsed,
6193 : : .data = NULL,
6194 : : .help_str = NULL, /* defined at init */
6195 : : .tokens = {
6196 : : (void *)&cmd_setfwd_retry_set,
6197 : : (void *)&cmd_setfwd_retry_fwd,
6198 : : (void *)&cmd_setfwd_retry_mode,
6199 : : (void *)&cmd_setfwd_retry_retry,
6200 : : NULL,
6201 : : },
6202 : : };
6203 : :
6204 : 0 : static void cmd_set_fwd_retry_mode_init(void)
6205 : : {
6206 : : char *modes, *c;
6207 : : static char token[128];
6208 : : static char help[256];
6209 : : cmdline_parse_token_string_t *token_struct;
6210 : :
6211 : 0 : modes = list_pkt_forwarding_retry_modes();
6212 : : snprintf(help, sizeof(help), "set fwd %s retry: "
6213 : : "Set packet forwarding mode with retry", modes);
6214 : 0 : cmd_set_fwd_retry_mode.help_str = help;
6215 : :
6216 : : /* string token separator is # */
6217 : 0 : for (c = token; *modes != '\0'; modes++)
6218 : 0 : if (*modes == '|')
6219 : 0 : *c++ = '#';
6220 : : else
6221 : 0 : *c++ = *modes;
6222 : 0 : token_struct = (cmdline_parse_token_string_t *)
6223 : : cmd_set_fwd_retry_mode.tokens[2];
6224 : 0 : token_struct->string_data.str = token;
6225 : 0 : }
6226 : :
6227 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6228 : : struct cmd_set_burst_tx_retry_result {
6229 : : cmdline_fixed_string_t set;
6230 : : cmdline_fixed_string_t burst;
6231 : : cmdline_fixed_string_t tx;
6232 : : cmdline_fixed_string_t delay;
6233 : : uint32_t time;
6234 : : cmdline_fixed_string_t retry;
6235 : : uint32_t retry_num;
6236 : : };
6237 : :
6238 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6239 : : __rte_unused struct cmdline *cl,
6240 : : __rte_unused void *data)
6241 : : {
6242 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
6243 : :
6244 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6245 : 0 : && !strcmp(res->tx, "tx")) {
6246 : 0 : if (!strcmp(res->delay, "delay"))
6247 : 0 : burst_tx_delay_time = res->time;
6248 : 0 : if (!strcmp(res->retry, "retry"))
6249 : 0 : burst_tx_retry_num = res->retry_num;
6250 : : }
6251 : :
6252 : 0 : }
6253 : :
6254 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6255 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6256 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6257 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6258 : : "burst");
6259 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6260 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6261 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6262 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6263 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6264 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6265 : : RTE_UINT32);
6266 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6267 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6268 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6269 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6270 : : RTE_UINT32);
6271 : :
6272 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6273 : : .f = cmd_set_burst_tx_retry_parsed,
6274 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6275 : : .tokens = {
6276 : : (void *)&cmd_set_burst_tx_retry_set,
6277 : : (void *)&cmd_set_burst_tx_retry_burst,
6278 : : (void *)&cmd_set_burst_tx_retry_tx,
6279 : : (void *)&cmd_set_burst_tx_retry_delay,
6280 : : (void *)&cmd_set_burst_tx_retry_time,
6281 : : (void *)&cmd_set_burst_tx_retry_retry,
6282 : : (void *)&cmd_set_burst_tx_retry_retry_num,
6283 : : NULL,
6284 : : },
6285 : : };
6286 : :
6287 : : /* *** SET PROMISC MODE *** */
6288 : : struct cmd_set_promisc_mode_result {
6289 : : cmdline_fixed_string_t set;
6290 : : cmdline_fixed_string_t promisc;
6291 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6292 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6293 : : cmdline_fixed_string_t mode;
6294 : : };
6295 : :
6296 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
6297 : : __rte_unused struct cmdline *cl,
6298 : : void *allports)
6299 : : {
6300 : : struct cmd_set_promisc_mode_result *res = parsed_result;
6301 : : int enable;
6302 : : portid_t i;
6303 : :
6304 : 0 : if (!strcmp(res->mode, "on"))
6305 : : enable = 1;
6306 : : else
6307 : : enable = 0;
6308 : :
6309 : : /* all ports */
6310 : 0 : if (allports) {
6311 : 0 : RTE_ETH_FOREACH_DEV(i)
6312 : 0 : eth_set_promisc_mode(i, enable);
6313 : : } else {
6314 : 0 : eth_set_promisc_mode(res->port_num, enable);
6315 : : }
6316 : 0 : }
6317 : :
6318 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
6319 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6320 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
6321 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6322 : : "promisc");
6323 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
6324 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6325 : : "all");
6326 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
6327 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6328 : : RTE_UINT16);
6329 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
6330 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6331 : : "on#off");
6332 : :
6333 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6334 : : .f = cmd_set_promisc_mode_parsed,
6335 : : .data = (void *)1,
6336 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
6337 : : .tokens = {
6338 : : (void *)&cmd_setpromisc_set,
6339 : : (void *)&cmd_setpromisc_promisc,
6340 : : (void *)&cmd_setpromisc_portall,
6341 : : (void *)&cmd_setpromisc_mode,
6342 : : NULL,
6343 : : },
6344 : : };
6345 : :
6346 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6347 : : .f = cmd_set_promisc_mode_parsed,
6348 : : .data = (void *)0,
6349 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6350 : : .tokens = {
6351 : : (void *)&cmd_setpromisc_set,
6352 : : (void *)&cmd_setpromisc_promisc,
6353 : : (void *)&cmd_setpromisc_portnum,
6354 : : (void *)&cmd_setpromisc_mode,
6355 : : NULL,
6356 : : },
6357 : : };
6358 : :
6359 : : /* *** SET ALLMULTI MODE *** */
6360 : : struct cmd_set_allmulti_mode_result {
6361 : : cmdline_fixed_string_t set;
6362 : : cmdline_fixed_string_t allmulti;
6363 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6364 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6365 : : cmdline_fixed_string_t mode;
6366 : : };
6367 : :
6368 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6369 : : __rte_unused struct cmdline *cl,
6370 : : void *allports)
6371 : : {
6372 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
6373 : : int enable;
6374 : : portid_t i;
6375 : :
6376 : 0 : if (!strcmp(res->mode, "on"))
6377 : : enable = 1;
6378 : : else
6379 : : enable = 0;
6380 : :
6381 : : /* all ports */
6382 : 0 : if (allports) {
6383 : 0 : RTE_ETH_FOREACH_DEV(i) {
6384 : 0 : eth_set_allmulticast_mode(i, enable);
6385 : : }
6386 : : }
6387 : : else {
6388 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
6389 : : }
6390 : 0 : }
6391 : :
6392 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
6393 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6394 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6395 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6396 : : "allmulti");
6397 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
6398 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6399 : : "all");
6400 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
6401 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6402 : : RTE_UINT16);
6403 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
6404 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6405 : : "on#off");
6406 : :
6407 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6408 : : .f = cmd_set_allmulti_mode_parsed,
6409 : : .data = (void *)1,
6410 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6411 : : .tokens = {
6412 : : (void *)&cmd_setallmulti_set,
6413 : : (void *)&cmd_setallmulti_allmulti,
6414 : : (void *)&cmd_setallmulti_portall,
6415 : : (void *)&cmd_setallmulti_mode,
6416 : : NULL,
6417 : : },
6418 : : };
6419 : :
6420 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6421 : : .f = cmd_set_allmulti_mode_parsed,
6422 : : .data = (void *)0,
6423 : : .help_str = "set allmulti <port_id> on|off: "
6424 : : "Set allmulti mode on port_id",
6425 : : .tokens = {
6426 : : (void *)&cmd_setallmulti_set,
6427 : : (void *)&cmd_setallmulti_allmulti,
6428 : : (void *)&cmd_setallmulti_portnum,
6429 : : (void *)&cmd_setallmulti_mode,
6430 : : NULL,
6431 : : },
6432 : : };
6433 : :
6434 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6435 : : struct cmd_link_flow_ctrl_show {
6436 : : cmdline_fixed_string_t show;
6437 : : cmdline_fixed_string_t port;
6438 : : portid_t port_id;
6439 : : cmdline_fixed_string_t flow_ctrl;
6440 : : };
6441 : :
6442 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6443 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6444 : : show, "show");
6445 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6446 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6447 : : port, "port");
6448 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6449 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6450 : : port_id, RTE_UINT16);
6451 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6452 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6453 : : flow_ctrl, "flow_ctrl");
6454 : :
6455 : : static void
6456 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6457 : : __rte_unused struct cmdline *cl,
6458 : : __rte_unused void *data)
6459 : : {
6460 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6461 : : static const char *info_border = "*********************";
6462 : : struct rte_eth_fc_conf fc_conf;
6463 : : bool rx_fc_en = false;
6464 : : bool tx_fc_en = false;
6465 : : int ret;
6466 : :
6467 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6468 : 0 : if (ret != 0) {
6469 : 0 : fprintf(stderr,
6470 : : "Failed to get current flow ctrl information: err = %d\n",
6471 : : ret);
6472 : 0 : return;
6473 : : }
6474 : :
6475 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6476 : : rx_fc_en = true;
6477 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6478 : : tx_fc_en = true;
6479 : :
6480 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6481 : 0 : info_border, res->port_id, info_border);
6482 : : printf("FC mode:\n");
6483 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6484 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6485 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6486 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6487 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6488 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6489 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6490 : 0 : printf("Forward MAC control frames: %s\n",
6491 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6492 : 0 : printf("\n%s************** End ***********%s\n",
6493 : : info_border, info_border);
6494 : : }
6495 : :
6496 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6497 : : .f = cmd_link_flow_ctrl_show_parsed,
6498 : : .data = NULL,
6499 : : .help_str = "show port <port_id> flow_ctrl",
6500 : : .tokens = {
6501 : : (void *)&cmd_lfc_show_show,
6502 : : (void *)&cmd_lfc_show_port,
6503 : : (void *)&cmd_lfc_show_portid,
6504 : : (void *)&cmd_lfc_show_flow_ctrl,
6505 : : NULL,
6506 : : },
6507 : : };
6508 : :
6509 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6510 : : struct cmd_link_flow_ctrl_set_result {
6511 : : cmdline_fixed_string_t set;
6512 : : cmdline_fixed_string_t flow_ctrl;
6513 : : cmdline_fixed_string_t rx;
6514 : : cmdline_fixed_string_t rx_lfc_mode;
6515 : : cmdline_fixed_string_t tx;
6516 : : cmdline_fixed_string_t tx_lfc_mode;
6517 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6518 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6519 : : cmdline_fixed_string_t autoneg_str;
6520 : : cmdline_fixed_string_t autoneg;
6521 : : cmdline_fixed_string_t hw_str;
6522 : : uint32_t high_water;
6523 : : cmdline_fixed_string_t lw_str;
6524 : : uint32_t low_water;
6525 : : cmdline_fixed_string_t pt_str;
6526 : : uint16_t pause_time;
6527 : : cmdline_fixed_string_t xon_str;
6528 : : uint16_t send_xon;
6529 : : portid_t port_id;
6530 : : };
6531 : :
6532 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6533 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6534 : : set, "set");
6535 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6536 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6537 : : flow_ctrl, "flow_ctrl");
6538 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6539 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6540 : : rx, "rx");
6541 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6542 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6543 : : rx_lfc_mode, "on#off");
6544 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6545 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6546 : : tx, "tx");
6547 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6548 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6549 : : tx_lfc_mode, "on#off");
6550 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6551 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6552 : : hw_str, "high_water");
6553 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6554 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6555 : : high_water, RTE_UINT32);
6556 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6557 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6558 : : lw_str, "low_water");
6559 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6560 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6561 : : low_water, RTE_UINT32);
6562 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6563 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6564 : : pt_str, "pause_time");
6565 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6566 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6567 : : pause_time, RTE_UINT16);
6568 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6569 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6570 : : xon_str, "send_xon");
6571 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6572 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6573 : : send_xon, RTE_UINT16);
6574 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6575 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6576 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6577 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6578 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6579 : : mac_ctrl_frame_fwd_mode, "on#off");
6580 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6581 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6582 : : autoneg_str, "autoneg");
6583 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6584 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6585 : : autoneg, "on#off");
6586 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6587 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6588 : : port_id, RTE_UINT16);
6589 : :
6590 : : /* forward declaration */
6591 : : static void
6592 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6593 : : void *data);
6594 : :
6595 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6596 : : .f = cmd_link_flow_ctrl_set_parsed,
6597 : : .data = NULL,
6598 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6599 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6600 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6601 : : .tokens = {
6602 : : (void *)&cmd_lfc_set_set,
6603 : : (void *)&cmd_lfc_set_flow_ctrl,
6604 : : (void *)&cmd_lfc_set_rx,
6605 : : (void *)&cmd_lfc_set_rx_mode,
6606 : : (void *)&cmd_lfc_set_tx,
6607 : : (void *)&cmd_lfc_set_tx_mode,
6608 : : (void *)&cmd_lfc_set_high_water,
6609 : : (void *)&cmd_lfc_set_low_water,
6610 : : (void *)&cmd_lfc_set_pause_time,
6611 : : (void *)&cmd_lfc_set_send_xon,
6612 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6613 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6614 : : (void *)&cmd_lfc_set_autoneg_str,
6615 : : (void *)&cmd_lfc_set_autoneg,
6616 : : (void *)&cmd_lfc_set_portid,
6617 : : NULL,
6618 : : },
6619 : : };
6620 : :
6621 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6622 : : .f = cmd_link_flow_ctrl_set_parsed,
6623 : : .data = (void *)&cmd_link_flow_control_set_rx,
6624 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6625 : : "Change rx flow control parameter",
6626 : : .tokens = {
6627 : : (void *)&cmd_lfc_set_set,
6628 : : (void *)&cmd_lfc_set_flow_ctrl,
6629 : : (void *)&cmd_lfc_set_rx,
6630 : : (void *)&cmd_lfc_set_rx_mode,
6631 : : (void *)&cmd_lfc_set_portid,
6632 : : NULL,
6633 : : },
6634 : : };
6635 : :
6636 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6637 : : .f = cmd_link_flow_ctrl_set_parsed,
6638 : : .data = (void *)&cmd_link_flow_control_set_tx,
6639 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6640 : : "Change tx flow control parameter",
6641 : : .tokens = {
6642 : : (void *)&cmd_lfc_set_set,
6643 : : (void *)&cmd_lfc_set_flow_ctrl,
6644 : : (void *)&cmd_lfc_set_tx,
6645 : : (void *)&cmd_lfc_set_tx_mode,
6646 : : (void *)&cmd_lfc_set_portid,
6647 : : NULL,
6648 : : },
6649 : : };
6650 : :
6651 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6652 : : .f = cmd_link_flow_ctrl_set_parsed,
6653 : : .data = (void *)&cmd_link_flow_control_set_hw,
6654 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6655 : : "Change high water flow control parameter",
6656 : : .tokens = {
6657 : : (void *)&cmd_lfc_set_set,
6658 : : (void *)&cmd_lfc_set_flow_ctrl,
6659 : : (void *)&cmd_lfc_set_high_water_str,
6660 : : (void *)&cmd_lfc_set_high_water,
6661 : : (void *)&cmd_lfc_set_portid,
6662 : : NULL,
6663 : : },
6664 : : };
6665 : :
6666 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6667 : : .f = cmd_link_flow_ctrl_set_parsed,
6668 : : .data = (void *)&cmd_link_flow_control_set_lw,
6669 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6670 : : "Change low water flow control parameter",
6671 : : .tokens = {
6672 : : (void *)&cmd_lfc_set_set,
6673 : : (void *)&cmd_lfc_set_flow_ctrl,
6674 : : (void *)&cmd_lfc_set_low_water_str,
6675 : : (void *)&cmd_lfc_set_low_water,
6676 : : (void *)&cmd_lfc_set_portid,
6677 : : NULL,
6678 : : },
6679 : : };
6680 : :
6681 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6682 : : .f = cmd_link_flow_ctrl_set_parsed,
6683 : : .data = (void *)&cmd_link_flow_control_set_pt,
6684 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6685 : : "Change pause time flow control parameter",
6686 : : .tokens = {
6687 : : (void *)&cmd_lfc_set_set,
6688 : : (void *)&cmd_lfc_set_flow_ctrl,
6689 : : (void *)&cmd_lfc_set_pause_time_str,
6690 : : (void *)&cmd_lfc_set_pause_time,
6691 : : (void *)&cmd_lfc_set_portid,
6692 : : NULL,
6693 : : },
6694 : : };
6695 : :
6696 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6697 : : .f = cmd_link_flow_ctrl_set_parsed,
6698 : : .data = (void *)&cmd_link_flow_control_set_xon,
6699 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6700 : : "Change send_xon flow control parameter",
6701 : : .tokens = {
6702 : : (void *)&cmd_lfc_set_set,
6703 : : (void *)&cmd_lfc_set_flow_ctrl,
6704 : : (void *)&cmd_lfc_set_send_xon_str,
6705 : : (void *)&cmd_lfc_set_send_xon,
6706 : : (void *)&cmd_lfc_set_portid,
6707 : : NULL,
6708 : : },
6709 : : };
6710 : :
6711 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6712 : : .f = cmd_link_flow_ctrl_set_parsed,
6713 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6714 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6715 : : "Change mac ctrl fwd flow control parameter",
6716 : : .tokens = {
6717 : : (void *)&cmd_lfc_set_set,
6718 : : (void *)&cmd_lfc_set_flow_ctrl,
6719 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6720 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6721 : : (void *)&cmd_lfc_set_portid,
6722 : : NULL,
6723 : : },
6724 : : };
6725 : :
6726 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6727 : : .f = cmd_link_flow_ctrl_set_parsed,
6728 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6729 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6730 : : "Change autoneg flow control parameter",
6731 : : .tokens = {
6732 : : (void *)&cmd_lfc_set_set,
6733 : : (void *)&cmd_lfc_set_flow_ctrl,
6734 : : (void *)&cmd_lfc_set_autoneg_str,
6735 : : (void *)&cmd_lfc_set_autoneg,
6736 : : (void *)&cmd_lfc_set_portid,
6737 : : NULL,
6738 : : },
6739 : : };
6740 : :
6741 : : static void
6742 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6743 : : __rte_unused struct cmdline *cl,
6744 : : void *data)
6745 : : {
6746 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6747 : : cmdline_parse_inst_t *cmd = data;
6748 : : struct rte_eth_fc_conf fc_conf;
6749 : : int rx_fc_en = 0;
6750 : : int tx_fc_en = 0;
6751 : : int ret;
6752 : :
6753 : : /*
6754 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6755 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6756 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6757 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6758 : : */
6759 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6760 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6761 : : };
6762 : :
6763 : : /* Partial command line, retrieve current configuration */
6764 : 0 : if (cmd) {
6765 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6766 : 0 : if (ret != 0) {
6767 : 0 : fprintf(stderr,
6768 : : "cannot get current flow ctrl parameters, return code = %d\n",
6769 : : ret);
6770 : 0 : return;
6771 : : }
6772 : :
6773 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6774 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6775 : : rx_fc_en = 1;
6776 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6777 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6778 : : tx_fc_en = 1;
6779 : : }
6780 : :
6781 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6782 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6783 : :
6784 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6785 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6786 : :
6787 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6788 : :
6789 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6790 : 0 : fc_conf.high_water = res->high_water;
6791 : :
6792 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6793 : 0 : fc_conf.low_water = res->low_water;
6794 : :
6795 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6796 : 0 : fc_conf.pause_time = res->pause_time;
6797 : :
6798 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6799 : 0 : fc_conf.send_xon = res->send_xon;
6800 : :
6801 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6802 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6803 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6804 : : else
6805 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6806 : : }
6807 : :
6808 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6809 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6810 : :
6811 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6812 : 0 : if (ret != 0)
6813 : 0 : fprintf(stderr,
6814 : : "bad flow control parameter, return code = %d\n",
6815 : : ret);
6816 : : }
6817 : :
6818 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6819 : : struct cmd_priority_flow_ctrl_set_result {
6820 : : cmdline_fixed_string_t set;
6821 : : cmdline_fixed_string_t pfc_ctrl;
6822 : : cmdline_fixed_string_t rx;
6823 : : cmdline_fixed_string_t rx_pfc_mode;
6824 : : cmdline_fixed_string_t tx;
6825 : : cmdline_fixed_string_t tx_pfc_mode;
6826 : : uint32_t high_water;
6827 : : uint32_t low_water;
6828 : : uint16_t pause_time;
6829 : : uint8_t priority;
6830 : : portid_t port_id;
6831 : : };
6832 : :
6833 : : static void
6834 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6835 : : __rte_unused struct cmdline *cl,
6836 : : __rte_unused void *data)
6837 : : {
6838 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6839 : : struct rte_eth_pfc_conf pfc_conf;
6840 : : int rx_fc_enable, tx_fc_enable;
6841 : : int ret;
6842 : :
6843 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
6844 : 0 : return;
6845 : :
6846 : : /*
6847 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6848 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6849 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6850 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6851 : : */
6852 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6853 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6854 : : };
6855 : :
6856 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
6857 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6858 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6859 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6860 : 0 : pfc_conf.fc.high_water = res->high_water;
6861 : 0 : pfc_conf.fc.low_water = res->low_water;
6862 : 0 : pfc_conf.fc.pause_time = res->pause_time;
6863 : 0 : pfc_conf.priority = res->priority;
6864 : :
6865 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6866 : 0 : if (ret != 0)
6867 : 0 : fprintf(stderr,
6868 : : "bad priority flow control parameter, return code = %d\n",
6869 : : ret);
6870 : : }
6871 : :
6872 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
6873 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6874 : : set, "set");
6875 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6876 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6877 : : pfc_ctrl, "pfc_ctrl");
6878 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
6879 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6880 : : rx, "rx");
6881 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6882 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6883 : : rx_pfc_mode, "on#off");
6884 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
6885 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6886 : : tx, "tx");
6887 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6888 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6889 : : tx_pfc_mode, "on#off");
6890 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
6891 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6892 : : high_water, RTE_UINT32);
6893 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
6894 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6895 : : low_water, RTE_UINT32);
6896 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6897 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6898 : : pause_time, RTE_UINT16);
6899 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
6900 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6901 : : priority, RTE_UINT8);
6902 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
6903 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6904 : : port_id, RTE_UINT16);
6905 : :
6906 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
6907 : : .f = cmd_priority_flow_ctrl_set_parsed,
6908 : : .data = NULL,
6909 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6910 : : "<pause_time> <priority> <port_id>: "
6911 : : "Configure the Ethernet priority flow control",
6912 : : .tokens = {
6913 : : (void *)&cmd_pfc_set_set,
6914 : : (void *)&cmd_pfc_set_flow_ctrl,
6915 : : (void *)&cmd_pfc_set_rx,
6916 : : (void *)&cmd_pfc_set_rx_mode,
6917 : : (void *)&cmd_pfc_set_tx,
6918 : : (void *)&cmd_pfc_set_tx_mode,
6919 : : (void *)&cmd_pfc_set_high_water,
6920 : : (void *)&cmd_pfc_set_low_water,
6921 : : (void *)&cmd_pfc_set_pause_time,
6922 : : (void *)&cmd_pfc_set_priority,
6923 : : (void *)&cmd_pfc_set_portid,
6924 : : NULL,
6925 : : },
6926 : : };
6927 : :
6928 : : struct cmd_queue_priority_flow_ctrl_set_result {
6929 : : cmdline_fixed_string_t set;
6930 : : cmdline_fixed_string_t pfc_queue_ctrl;
6931 : : portid_t port_id;
6932 : : cmdline_fixed_string_t rx;
6933 : : cmdline_fixed_string_t rx_pfc_mode;
6934 : : uint16_t tx_qid;
6935 : : uint8_t tx_tc;
6936 : : cmdline_fixed_string_t tx;
6937 : : cmdline_fixed_string_t tx_pfc_mode;
6938 : : uint16_t rx_qid;
6939 : : uint8_t rx_tc;
6940 : : uint16_t pause_time;
6941 : : };
6942 : :
6943 : : static void
6944 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
6945 : : __rte_unused struct cmdline *cl,
6946 : : __rte_unused void *data)
6947 : : {
6948 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
6949 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
6950 : : int rx_fc_enable, tx_fc_enable;
6951 : : int ret;
6952 : :
6953 : : /*
6954 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
6955 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
6956 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
6957 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
6958 : : * the Tx side.
6959 : : */
6960 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
6961 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
6962 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6963 : : };
6964 : :
6965 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
6966 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
6967 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
6968 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
6969 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
6970 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
6971 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
6972 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
6973 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
6974 : :
6975 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
6976 : : &pfc_queue_conf);
6977 : 0 : if (ret != 0) {
6978 : 0 : fprintf(stderr,
6979 : : "bad queue priority flow control parameter, rc = %d\n",
6980 : : ret);
6981 : : }
6982 : 0 : }
6983 : :
6984 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
6985 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6986 : : set, "set");
6987 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
6988 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6989 : : pfc_queue_ctrl, "pfc_queue_ctrl");
6990 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
6991 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6992 : : port_id, RTE_UINT16);
6993 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
6994 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6995 : : rx, "rx");
6996 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
6997 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6998 : : rx_pfc_mode, "on#off");
6999 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7000 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7001 : : tx_qid, RTE_UINT16);
7002 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7003 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7004 : : tx_tc, RTE_UINT8);
7005 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7006 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7007 : : tx, "tx");
7008 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7009 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7010 : : tx_pfc_mode, "on#off");
7011 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7012 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7013 : : rx_qid, RTE_UINT16);
7014 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7015 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7016 : : rx_tc, RTE_UINT8);
7017 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7018 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7019 : : pause_time, RTE_UINT16);
7020 : :
7021 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7022 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
7023 : : .data = NULL,
7024 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7025 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7026 : : "Configure the Ethernet queue priority flow control",
7027 : : .tokens = {
7028 : : (void *)&cmd_q_pfc_set_set,
7029 : : (void *)&cmd_q_pfc_set_flow_ctrl,
7030 : : (void *)&cmd_q_pfc_set_portid,
7031 : : (void *)&cmd_q_pfc_set_rx,
7032 : : (void *)&cmd_q_pfc_set_rx_mode,
7033 : : (void *)&cmd_q_pfc_set_tx_qid,
7034 : : (void *)&cmd_q_pfc_set_tx_tc,
7035 : : (void *)&cmd_q_pfc_set_tx,
7036 : : (void *)&cmd_q_pfc_set_tx_mode,
7037 : : (void *)&cmd_q_pfc_set_rx_qid,
7038 : : (void *)&cmd_q_pfc_set_rx_tc,
7039 : : (void *)&cmd_q_pfc_set_pause_time,
7040 : : NULL,
7041 : : },
7042 : : };
7043 : :
7044 : : /* *** RESET CONFIGURATION *** */
7045 : : struct cmd_reset_result {
7046 : : cmdline_fixed_string_t reset;
7047 : : cmdline_fixed_string_t def;
7048 : : };
7049 : :
7050 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
7051 : : struct cmdline *cl,
7052 : : __rte_unused void *data)
7053 : : {
7054 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7055 : 0 : set_def_fwd_config();
7056 : 0 : }
7057 : :
7058 : : static cmdline_parse_token_string_t cmd_reset_set =
7059 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7060 : : static cmdline_parse_token_string_t cmd_reset_def =
7061 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7062 : : "default");
7063 : :
7064 : : static cmdline_parse_inst_t cmd_reset = {
7065 : : .f = cmd_reset_parsed,
7066 : : .data = NULL,
7067 : : .help_str = "set default: Reset default forwarding configuration",
7068 : : .tokens = {
7069 : : (void *)&cmd_reset_set,
7070 : : (void *)&cmd_reset_def,
7071 : : NULL,
7072 : : },
7073 : : };
7074 : :
7075 : : /* *** START FORWARDING *** */
7076 : : struct cmd_start_result {
7077 : : cmdline_fixed_string_t start;
7078 : : };
7079 : :
7080 : : static cmdline_parse_token_string_t cmd_start_start =
7081 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7082 : :
7083 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
7084 : : __rte_unused struct cmdline *cl,
7085 : : __rte_unused void *data)
7086 : : {
7087 : 0 : start_packet_forwarding(0);
7088 : 0 : }
7089 : :
7090 : : static cmdline_parse_inst_t cmd_start = {
7091 : : .f = cmd_start_parsed,
7092 : : .data = NULL,
7093 : : .help_str = "start: Start packet forwarding",
7094 : : .tokens = {
7095 : : (void *)&cmd_start_start,
7096 : : NULL,
7097 : : },
7098 : : };
7099 : :
7100 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7101 : : struct cmd_start_tx_first_result {
7102 : : cmdline_fixed_string_t start;
7103 : : cmdline_fixed_string_t tx_first;
7104 : : };
7105 : :
7106 : : static void
7107 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7108 : : __rte_unused struct cmdline *cl,
7109 : : __rte_unused void *data)
7110 : : {
7111 : 0 : start_packet_forwarding(1);
7112 : 0 : }
7113 : :
7114 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
7115 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7116 : : "start");
7117 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7118 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7119 : : tx_first, "tx_first");
7120 : :
7121 : : static cmdline_parse_inst_t cmd_start_tx_first = {
7122 : : .f = cmd_start_tx_first_parsed,
7123 : : .data = NULL,
7124 : : .help_str = "start tx_first: Start packet forwarding, "
7125 : : "after sending 1 burst of packets",
7126 : : .tokens = {
7127 : : (void *)&cmd_start_tx_first_start,
7128 : : (void *)&cmd_start_tx_first_tx_first,
7129 : : NULL,
7130 : : },
7131 : : };
7132 : :
7133 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
7134 : : struct cmd_start_tx_first_n_result {
7135 : : cmdline_fixed_string_t start;
7136 : : cmdline_fixed_string_t tx_first;
7137 : : uint32_t tx_num;
7138 : : };
7139 : :
7140 : : static void
7141 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
7142 : : __rte_unused struct cmdline *cl,
7143 : : __rte_unused void *data)
7144 : : {
7145 : : struct cmd_start_tx_first_n_result *res = parsed_result;
7146 : :
7147 : 0 : start_packet_forwarding(res->tx_num);
7148 : 0 : }
7149 : :
7150 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7151 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7152 : : start, "start");
7153 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7154 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7155 : : tx_first, "tx_first");
7156 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7157 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7158 : : tx_num, RTE_UINT32);
7159 : :
7160 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
7161 : : .f = cmd_start_tx_first_n_parsed,
7162 : : .data = NULL,
7163 : : .help_str = "start tx_first <num>: "
7164 : : "packet forwarding, after sending <num> bursts of packets",
7165 : : .tokens = {
7166 : : (void *)&cmd_start_tx_first_n_start,
7167 : : (void *)&cmd_start_tx_first_n_tx_first,
7168 : : (void *)&cmd_start_tx_first_n_tx_num,
7169 : : NULL,
7170 : : },
7171 : : };
7172 : :
7173 : : /* *** SET LINK UP *** */
7174 : : struct cmd_set_link_up_result {
7175 : : cmdline_fixed_string_t set;
7176 : : cmdline_fixed_string_t link_up;
7177 : : cmdline_fixed_string_t port;
7178 : : portid_t port_id;
7179 : : };
7180 : :
7181 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
7182 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7183 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7184 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7185 : : "link-up");
7186 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
7187 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7188 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7189 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7190 : : RTE_UINT16);
7191 : :
7192 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7193 : : __rte_unused struct cmdline *cl,
7194 : : __rte_unused void *data)
7195 : : {
7196 : : struct cmd_set_link_up_result *res = parsed_result;
7197 : 0 : dev_set_link_up(res->port_id);
7198 : 0 : }
7199 : :
7200 : : static cmdline_parse_inst_t cmd_set_link_up = {
7201 : : .f = cmd_set_link_up_parsed,
7202 : : .data = NULL,
7203 : : .help_str = "set link-up port <port id>",
7204 : : .tokens = {
7205 : : (void *)&cmd_set_link_up_set,
7206 : : (void *)&cmd_set_link_up_link_up,
7207 : : (void *)&cmd_set_link_up_port,
7208 : : (void *)&cmd_set_link_up_port_id,
7209 : : NULL,
7210 : : },
7211 : : };
7212 : :
7213 : : /* *** SET LINK DOWN *** */
7214 : : struct cmd_set_link_down_result {
7215 : : cmdline_fixed_string_t set;
7216 : : cmdline_fixed_string_t link_down;
7217 : : cmdline_fixed_string_t port;
7218 : : portid_t port_id;
7219 : : };
7220 : :
7221 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
7222 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7223 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
7224 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7225 : : "link-down");
7226 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
7227 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7228 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
7229 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7230 : : RTE_UINT16);
7231 : :
7232 : 0 : static void cmd_set_link_down_parsed(
7233 : : __rte_unused void *parsed_result,
7234 : : __rte_unused struct cmdline *cl,
7235 : : __rte_unused void *data)
7236 : : {
7237 : : struct cmd_set_link_down_result *res = parsed_result;
7238 : 0 : dev_set_link_down(res->port_id);
7239 : 0 : }
7240 : :
7241 : : static cmdline_parse_inst_t cmd_set_link_down = {
7242 : : .f = cmd_set_link_down_parsed,
7243 : : .data = NULL,
7244 : : .help_str = "set link-down port <port id>",
7245 : : .tokens = {
7246 : : (void *)&cmd_set_link_down_set,
7247 : : (void *)&cmd_set_link_down_link_down,
7248 : : (void *)&cmd_set_link_down_port,
7249 : : (void *)&cmd_set_link_down_port_id,
7250 : : NULL,
7251 : : },
7252 : : };
7253 : :
7254 : : /* *** SHOW CFG *** */
7255 : : struct cmd_showcfg_result {
7256 : : cmdline_fixed_string_t show;
7257 : : cmdline_fixed_string_t cfg;
7258 : : cmdline_fixed_string_t what;
7259 : : };
7260 : :
7261 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
7262 : : __rte_unused struct cmdline *cl,
7263 : : __rte_unused void *data)
7264 : : {
7265 : : struct cmd_showcfg_result *res = parsed_result;
7266 : 0 : if (!strcmp(res->what, "rxtx"))
7267 : 0 : rxtx_config_display();
7268 : 0 : else if (!strcmp(res->what, "cores"))
7269 : 0 : fwd_lcores_config_display();
7270 : 0 : else if (!strcmp(res->what, "fwd"))
7271 : 0 : pkt_fwd_config_display(&cur_fwd_config);
7272 : 0 : else if (!strcmp(res->what, "rxoffs"))
7273 : 0 : show_rx_pkt_offsets();
7274 : 0 : else if (!strcmp(res->what, "rxpkts"))
7275 : 0 : show_rx_pkt_segments();
7276 : 0 : else if (!strcmp(res->what, "rxhdrs"))
7277 : 0 : show_rx_pkt_hdrs();
7278 : 0 : else if (!strcmp(res->what, "txpkts"))
7279 : 0 : show_tx_pkt_segments();
7280 : 0 : else if (!strcmp(res->what, "txtimes"))
7281 : 0 : show_tx_pkt_times();
7282 : 0 : }
7283 : :
7284 : : static cmdline_parse_token_string_t cmd_showcfg_show =
7285 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7286 : : static cmdline_parse_token_string_t cmd_showcfg_port =
7287 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7288 : : static cmdline_parse_token_string_t cmd_showcfg_what =
7289 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7290 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
7291 : :
7292 : : static cmdline_parse_inst_t cmd_showcfg = {
7293 : : .f = cmd_showcfg_parsed,
7294 : : .data = NULL,
7295 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
7296 : : .tokens = {
7297 : : (void *)&cmd_showcfg_show,
7298 : : (void *)&cmd_showcfg_port,
7299 : : (void *)&cmd_showcfg_what,
7300 : : NULL,
7301 : : },
7302 : : };
7303 : :
7304 : : /* *** SHOW ALL PORT INFO *** */
7305 : : struct cmd_showportall_result {
7306 : : cmdline_fixed_string_t show;
7307 : : cmdline_fixed_string_t port;
7308 : : cmdline_fixed_string_t what;
7309 : : cmdline_fixed_string_t all;
7310 : : };
7311 : :
7312 : 0 : static void cmd_showportall_parsed(void *parsed_result,
7313 : : __rte_unused struct cmdline *cl,
7314 : : __rte_unused void *data)
7315 : : {
7316 : : portid_t i;
7317 : :
7318 : : struct cmd_showportall_result *res = parsed_result;
7319 : 0 : if (!strcmp(res->show, "clear")) {
7320 : 0 : if (!strcmp(res->what, "stats"))
7321 : 0 : RTE_ETH_FOREACH_DEV(i)
7322 : 0 : nic_stats_clear(i);
7323 : 0 : else if (!strcmp(res->what, "xstats"))
7324 : 0 : RTE_ETH_FOREACH_DEV(i)
7325 : 0 : nic_xstats_clear(i);
7326 : 0 : } else if (!strcmp(res->what, "info"))
7327 : 0 : RTE_ETH_FOREACH_DEV(i)
7328 : 0 : port_infos_display(i);
7329 : 0 : else if (!strcmp(res->what, "summary")) {
7330 : 0 : port_summary_header_display();
7331 : 0 : RTE_ETH_FOREACH_DEV(i)
7332 : 0 : port_summary_display(i);
7333 : : }
7334 : 0 : else if (!strcmp(res->what, "stats"))
7335 : 0 : RTE_ETH_FOREACH_DEV(i)
7336 : 0 : nic_stats_display(i);
7337 : 0 : else if (!strcmp(res->what, "xstats"))
7338 : 0 : RTE_ETH_FOREACH_DEV(i)
7339 : 0 : nic_xstats_display(i);
7340 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7341 : 0 : else if (!strcmp(res->what, "fdir"))
7342 : 0 : RTE_ETH_FOREACH_DEV(i)
7343 : 0 : fdir_get_infos(i);
7344 : : #endif
7345 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7346 : 0 : RTE_ETH_FOREACH_DEV(i)
7347 : 0 : port_dcb_info_display(i);
7348 : 0 : }
7349 : :
7350 : : static cmdline_parse_token_string_t cmd_showportall_show =
7351 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7352 : : "show#clear");
7353 : : static cmdline_parse_token_string_t cmd_showportall_port =
7354 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7355 : : static cmdline_parse_token_string_t cmd_showportall_what =
7356 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7357 : : "info#summary#stats#xstats#fdir#dcb_tc");
7358 : : static cmdline_parse_token_string_t cmd_showportall_all =
7359 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7360 : : static cmdline_parse_inst_t cmd_showportall = {
7361 : : .f = cmd_showportall_parsed,
7362 : : .data = NULL,
7363 : : .help_str = "show|clear port "
7364 : : "info|summary|stats|xstats|fdir|dcb_tc all",
7365 : : .tokens = {
7366 : : (void *)&cmd_showportall_show,
7367 : : (void *)&cmd_showportall_port,
7368 : : (void *)&cmd_showportall_what,
7369 : : (void *)&cmd_showportall_all,
7370 : : NULL,
7371 : : },
7372 : : };
7373 : :
7374 : : /* *** SHOW PORT INFO *** */
7375 : : struct cmd_showport_result {
7376 : : cmdline_fixed_string_t show;
7377 : : cmdline_fixed_string_t port;
7378 : : cmdline_fixed_string_t what;
7379 : : uint16_t portnum;
7380 : : };
7381 : :
7382 : 0 : static void cmd_showport_parsed(void *parsed_result,
7383 : : __rte_unused struct cmdline *cl,
7384 : : __rte_unused void *data)
7385 : : {
7386 : : struct cmd_showport_result *res = parsed_result;
7387 : 0 : if (!strcmp(res->show, "clear")) {
7388 : 0 : if (!strcmp(res->what, "stats"))
7389 : 0 : nic_stats_clear(res->portnum);
7390 : 0 : else if (!strcmp(res->what, "xstats"))
7391 : 0 : nic_xstats_clear(res->portnum);
7392 : 0 : } else if (!strcmp(res->what, "info"))
7393 : 0 : port_infos_display(res->portnum);
7394 : 0 : else if (!strcmp(res->what, "summary")) {
7395 : 0 : port_summary_header_display();
7396 : 0 : port_summary_display(res->portnum);
7397 : : }
7398 : 0 : else if (!strcmp(res->what, "stats"))
7399 : 0 : nic_stats_display(res->portnum);
7400 : 0 : else if (!strcmp(res->what, "xstats"))
7401 : 0 : nic_xstats_display(res->portnum);
7402 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7403 : 0 : else if (!strcmp(res->what, "fdir"))
7404 : 0 : fdir_get_infos(res->portnum);
7405 : : #endif
7406 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7407 : 0 : port_dcb_info_display(res->portnum);
7408 : 0 : }
7409 : :
7410 : : static cmdline_parse_token_string_t cmd_showport_show =
7411 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7412 : : "show#clear");
7413 : : static cmdline_parse_token_string_t cmd_showport_port =
7414 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7415 : : static cmdline_parse_token_string_t cmd_showport_what =
7416 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7417 : : "info#summary#stats#xstats#fdir#dcb_tc");
7418 : : static cmdline_parse_token_num_t cmd_showport_portnum =
7419 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7420 : :
7421 : : static cmdline_parse_inst_t cmd_showport = {
7422 : : .f = cmd_showport_parsed,
7423 : : .data = NULL,
7424 : : .help_str = "show|clear port "
7425 : : "info|summary|stats|xstats|fdir|dcb_tc "
7426 : : "<port_id>",
7427 : : .tokens = {
7428 : : (void *)&cmd_showport_show,
7429 : : (void *)&cmd_showport_port,
7430 : : (void *)&cmd_showport_what,
7431 : : (void *)&cmd_showport_portnum,
7432 : : NULL,
7433 : : },
7434 : : };
7435 : :
7436 : : /* *** show port representors information *** */
7437 : : struct cmd_representor_info_result {
7438 : : cmdline_fixed_string_t cmd_show;
7439 : : cmdline_fixed_string_t cmd_port;
7440 : : cmdline_fixed_string_t cmd_info;
7441 : : cmdline_fixed_string_t cmd_keyword;
7442 : : portid_t cmd_pid;
7443 : : };
7444 : :
7445 : : static void
7446 : 0 : cmd_representor_info_parsed(void *parsed_result,
7447 : : __rte_unused struct cmdline *cl,
7448 : : __rte_unused void *data)
7449 : : {
7450 : : struct cmd_representor_info_result *res = parsed_result;
7451 : : struct rte_eth_representor_info *info;
7452 : : struct rte_eth_representor_range *range;
7453 : : uint32_t range_diff;
7454 : : uint32_t i;
7455 : : int ret;
7456 : : int num;
7457 : :
7458 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7459 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7460 : 0 : return;
7461 : : }
7462 : :
7463 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7464 : 0 : if (ret < 0) {
7465 : 0 : fprintf(stderr,
7466 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7467 : 0 : res->cmd_pid, rte_strerror(-ret));
7468 : 0 : return;
7469 : : }
7470 : : num = ret;
7471 : :
7472 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7473 : 0 : if (info == NULL) {
7474 : 0 : fprintf(stderr,
7475 : : "Failed to allocate memory for representor info for port %hu\n",
7476 : 0 : res->cmd_pid);
7477 : 0 : return;
7478 : : }
7479 : 0 : info->nb_ranges_alloc = num;
7480 : :
7481 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7482 : 0 : if (ret < 0) {
7483 : 0 : fprintf(stderr,
7484 : : "Failed to get the representor info for port %hu: %s\n",
7485 : 0 : res->cmd_pid, rte_strerror(-ret));
7486 : 0 : free(info);
7487 : 0 : return;
7488 : : }
7489 : :
7490 : 0 : printf("Port controller: %hu\n", info->controller);
7491 : 0 : printf("Port PF: %hu\n", info->pf);
7492 : :
7493 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7494 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7495 : : range = &info->ranges[i];
7496 : 0 : range_diff = range->id_end - range->id_base;
7497 : :
7498 : 0 : printf("%u. ", i + 1);
7499 : 0 : printf("'%s' ", range->name);
7500 : 0 : if (range_diff > 0)
7501 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7502 : : else
7503 : 0 : printf("[%u]: ", range->id_base);
7504 : :
7505 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7506 : :
7507 : 0 : switch (range->type) {
7508 : : case RTE_ETH_REPRESENTOR_NONE:
7509 : : printf(", NONE\n");
7510 : : break;
7511 : 0 : case RTE_ETH_REPRESENTOR_VF:
7512 : 0 : if (range_diff > 0)
7513 : 0 : printf(", VF %d..%d\n", range->vf,
7514 : 0 : range->vf + range_diff);
7515 : : else
7516 : 0 : printf(", VF %d\n", range->vf);
7517 : : break;
7518 : 0 : case RTE_ETH_REPRESENTOR_SF:
7519 : 0 : printf(", SF %d\n", range->sf);
7520 : : break;
7521 : 0 : case RTE_ETH_REPRESENTOR_PF:
7522 : 0 : if (range_diff > 0)
7523 : 0 : printf("..%d\n", range->pf + range_diff);
7524 : : else
7525 : : printf("\n");
7526 : : break;
7527 : 0 : default:
7528 : : printf(", UNKNOWN TYPE %d\n", range->type);
7529 : : break;
7530 : : }
7531 : : }
7532 : :
7533 : 0 : free(info);
7534 : : }
7535 : :
7536 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7537 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7538 : : cmd_show, "show");
7539 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7540 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7541 : : cmd_port, "port");
7542 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7543 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7544 : : cmd_info, "info");
7545 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7546 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7547 : : cmd_pid, RTE_UINT16);
7548 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7549 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7550 : : cmd_keyword, "representor");
7551 : :
7552 : : static cmdline_parse_inst_t cmd_representor_info = {
7553 : : .f = cmd_representor_info_parsed,
7554 : : .data = NULL,
7555 : : .help_str = "show port info <port_id> representor",
7556 : : .tokens = {
7557 : : (void *)&cmd_representor_info_show,
7558 : : (void *)&cmd_representor_info_port,
7559 : : (void *)&cmd_representor_info_info,
7560 : : (void *)&cmd_representor_info_pid,
7561 : : (void *)&cmd_representor_info_keyword,
7562 : : NULL,
7563 : : },
7564 : : };
7565 : :
7566 : :
7567 : : /* *** SHOW DEVICE INFO *** */
7568 : : struct cmd_showdevice_result {
7569 : : cmdline_fixed_string_t show;
7570 : : cmdline_fixed_string_t device;
7571 : : cmdline_fixed_string_t what;
7572 : : cmdline_fixed_string_t identifier;
7573 : : };
7574 : :
7575 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7576 : : __rte_unused struct cmdline *cl,
7577 : : __rte_unused void *data)
7578 : : {
7579 : : struct cmd_showdevice_result *res = parsed_result;
7580 : 0 : if (!strcmp(res->what, "info")) {
7581 : 0 : if (!strcmp(res->identifier, "all"))
7582 : 0 : device_infos_display(NULL);
7583 : : else
7584 : 0 : device_infos_display(res->identifier);
7585 : : }
7586 : 0 : }
7587 : :
7588 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7589 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7590 : : "show");
7591 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7592 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7593 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7594 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7595 : : "info");
7596 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7597 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7598 : : identifier, NULL);
7599 : :
7600 : : static cmdline_parse_inst_t cmd_showdevice = {
7601 : : .f = cmd_showdevice_parsed,
7602 : : .data = NULL,
7603 : : .help_str = "show device info <identifier>|all",
7604 : : .tokens = {
7605 : : (void *)&cmd_showdevice_show,
7606 : : (void *)&cmd_showdevice_device,
7607 : : (void *)&cmd_showdevice_what,
7608 : : (void *)&cmd_showdevice_identifier,
7609 : : NULL,
7610 : : },
7611 : : };
7612 : :
7613 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7614 : : struct cmd_showeeprom_result {
7615 : : cmdline_fixed_string_t show;
7616 : : cmdline_fixed_string_t port;
7617 : : uint16_t portnum;
7618 : : cmdline_fixed_string_t type;
7619 : : };
7620 : :
7621 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7622 : : __rte_unused struct cmdline *cl,
7623 : : __rte_unused void *data)
7624 : : {
7625 : : struct cmd_showeeprom_result *res = parsed_result;
7626 : :
7627 : 0 : if (!strcmp(res->type, "eeprom"))
7628 : 0 : port_eeprom_display(res->portnum);
7629 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7630 : 0 : port_module_eeprom_display(res->portnum);
7631 : : else
7632 : 0 : fprintf(stderr, "Unknown argument\n");
7633 : 0 : }
7634 : :
7635 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7636 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7637 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7638 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7639 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7640 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7641 : : RTE_UINT16);
7642 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7643 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7644 : :
7645 : : static cmdline_parse_inst_t cmd_showeeprom = {
7646 : : .f = cmd_showeeprom_parsed,
7647 : : .data = NULL,
7648 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7649 : : .tokens = {
7650 : : (void *)&cmd_showeeprom_show,
7651 : : (void *)&cmd_showeeprom_port,
7652 : : (void *)&cmd_showeeprom_portnum,
7653 : : (void *)&cmd_showeeprom_type,
7654 : : NULL,
7655 : : },
7656 : : };
7657 : :
7658 : : /* *** SET PORT EEPROM *** */
7659 : : struct cmd_seteeprom_result {
7660 : : cmdline_fixed_string_t set;
7661 : : cmdline_fixed_string_t port;
7662 : : uint16_t portnum;
7663 : : cmdline_fixed_string_t eeprom;
7664 : : cmdline_fixed_string_t confirm_str;
7665 : : cmdline_fixed_string_t magic_str;
7666 : : uint32_t magic;
7667 : : cmdline_fixed_string_t value;
7668 : : cmdline_multi_string_t token_str;
7669 : : };
7670 : :
7671 : 0 : static void cmd_seteeprom_parsed(void *parsed_result,
7672 : : __rte_unused struct cmdline *cl,
7673 : : __rte_unused void *data)
7674 : : {
7675 : : struct cmd_seteeprom_result *res = parsed_result;
7676 : : uint32_t offset = 0;
7677 : : uint32_t length;
7678 : : uint8_t *value;
7679 : : char *token_str;
7680 : : char *token;
7681 : :
7682 : 0 : token_str = res->token_str;
7683 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7684 : :
7685 : : /* Parse Hex string to Byte data */
7686 : 0 : if (strlen(token) % 2 != 0) {
7687 : 0 : fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
7688 : : token);
7689 : 0 : return;
7690 : : }
7691 : :
7692 : 0 : length = strlen(token) / 2;
7693 : 0 : value = calloc(length, sizeof(uint8_t));
7694 : 0 : for (int count = 0; count < (int)(length); count++) {
7695 : 0 : if (sscanf(token, "%2hhx", &value[count]) != 1) {
7696 : 0 : fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
7697 : 0 : token - (count + 1));
7698 : 0 : goto out;
7699 : : }
7700 : 0 : token += 2;
7701 : : }
7702 : :
7703 : : /* Second token: offset string */
7704 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7705 : 0 : if (token != NULL) {
7706 : 0 : if (strcmp(token, "offset") == 0) {
7707 : : /* Third token: offset */
7708 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7709 : 0 : if (token == NULL) {
7710 : 0 : fprintf(stderr, "No offset specified\n");
7711 : 0 : goto out;
7712 : : }
7713 : :
7714 : : char *end;
7715 : 0 : offset = strtoul(token, &end, 10);
7716 : 0 : if (offset == 0 && strcmp(end, "") != 0) {
7717 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7718 : 0 : goto out;
7719 : : }
7720 : : } else {
7721 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7722 : 0 : goto out;
7723 : : }
7724 : : }
7725 : :
7726 : 0 : port_eeprom_set(res->portnum, res->magic, offset, length, value);
7727 : :
7728 : 0 : out:
7729 : 0 : free(value);
7730 : : }
7731 : :
7732 : : static cmdline_parse_token_string_t cmd_seteeprom_set =
7733 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
7734 : : static cmdline_parse_token_string_t cmd_seteeprom_port =
7735 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
7736 : : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
7737 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
7738 : : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
7739 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
7740 : : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
7741 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
7742 : : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
7743 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
7744 : : static cmdline_parse_token_num_t cmd_seteeprom_magic =
7745 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
7746 : : static cmdline_parse_token_string_t cmd_seteeprom_value =
7747 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
7748 : : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
7749 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
7750 : :
7751 : : static cmdline_parse_inst_t cmd_seteeprom = {
7752 : : .f = cmd_seteeprom_parsed,
7753 : : .data = NULL,
7754 : : .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
7755 : : "value <value> offset <offset>: Set eeprom value for port_id.\n"
7756 : : "Note:\n"
7757 : : "This is a high-risk command and its misuse may result in "
7758 : : "unexpected behaviour from the NIC.\n"
7759 : : "By inserting \"accept_risk\" into the command, the user is "
7760 : : "acknowledging and taking responsibility for this risk.",
7761 : : .tokens = {
7762 : : (void *)&cmd_seteeprom_set,
7763 : : (void *)&cmd_seteeprom_port,
7764 : : (void *)&cmd_seteeprom_portnum,
7765 : : (void *)&cmd_seteeprom_eeprom,
7766 : : (void *)&cmd_seteeprom_confirm_str,
7767 : : (void *)&cmd_seteeprom_magic_str,
7768 : : (void *)&cmd_seteeprom_magic,
7769 : : (void *)&cmd_seteeprom_value,
7770 : : (void *)&cmd_seteeprom_token_str,
7771 : : NULL,
7772 : : },
7773 : : };
7774 : :
7775 : : /* *** SHOW QUEUE INFO *** */
7776 : : struct cmd_showqueue_result {
7777 : : cmdline_fixed_string_t show;
7778 : : cmdline_fixed_string_t type;
7779 : : cmdline_fixed_string_t what;
7780 : : uint16_t portnum;
7781 : : uint16_t queuenum;
7782 : : };
7783 : :
7784 : : static void
7785 : 0 : cmd_showqueue_parsed(void *parsed_result,
7786 : : __rte_unused struct cmdline *cl,
7787 : : __rte_unused void *data)
7788 : : {
7789 : : struct cmd_showqueue_result *res = parsed_result;
7790 : :
7791 : 0 : if (!strcmp(res->type, "rxq"))
7792 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7793 : 0 : else if (!strcmp(res->type, "txq"))
7794 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7795 : 0 : }
7796 : :
7797 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7798 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7799 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7800 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7801 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7802 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7803 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7804 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7805 : : RTE_UINT16);
7806 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7807 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7808 : : RTE_UINT16);
7809 : :
7810 : : static cmdline_parse_inst_t cmd_showqueue = {
7811 : : .f = cmd_showqueue_parsed,
7812 : : .data = NULL,
7813 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7814 : : .tokens = {
7815 : : (void *)&cmd_showqueue_show,
7816 : : (void *)&cmd_showqueue_type,
7817 : : (void *)&cmd_showqueue_what,
7818 : : (void *)&cmd_showqueue_portnum,
7819 : : (void *)&cmd_showqueue_queuenum,
7820 : : NULL,
7821 : : },
7822 : : };
7823 : :
7824 : : /* show/clear fwd engine statistics */
7825 : : struct fwd_result {
7826 : : cmdline_fixed_string_t action;
7827 : : cmdline_fixed_string_t fwd;
7828 : : cmdline_fixed_string_t stats;
7829 : : cmdline_fixed_string_t all;
7830 : : };
7831 : :
7832 : : static cmdline_parse_token_string_t cmd_fwd_action =
7833 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7834 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
7835 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7836 : : static cmdline_parse_token_string_t cmd_fwd_stats =
7837 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7838 : : static cmdline_parse_token_string_t cmd_fwd_all =
7839 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7840 : :
7841 : : static void
7842 : 0 : cmd_showfwdall_parsed(void *parsed_result,
7843 : : __rte_unused struct cmdline *cl,
7844 : : __rte_unused void *data)
7845 : : {
7846 : : struct fwd_result *res = parsed_result;
7847 : :
7848 : 0 : if (!strcmp(res->action, "show"))
7849 : 0 : fwd_stats_display();
7850 : : else
7851 : 0 : fwd_stats_reset();
7852 : 0 : }
7853 : :
7854 : : static cmdline_parse_inst_t cmd_showfwdall = {
7855 : : .f = cmd_showfwdall_parsed,
7856 : : .data = NULL,
7857 : : .help_str = "show|clear fwd stats all",
7858 : : .tokens = {
7859 : : (void *)&cmd_fwd_action,
7860 : : (void *)&cmd_fwd_fwd,
7861 : : (void *)&cmd_fwd_stats,
7862 : : (void *)&cmd_fwd_all,
7863 : : NULL,
7864 : : },
7865 : : };
7866 : :
7867 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7868 : : struct cmd_read_rxd_txd_result {
7869 : : cmdline_fixed_string_t read;
7870 : : cmdline_fixed_string_t rxd_txd;
7871 : : portid_t port_id;
7872 : : uint16_t queue_id;
7873 : : uint16_t desc_id;
7874 : : };
7875 : :
7876 : : static void
7877 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
7878 : : __rte_unused struct cmdline *cl,
7879 : : __rte_unused void *data)
7880 : : {
7881 : : struct cmd_read_rxd_txd_result *res = parsed_result;
7882 : :
7883 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
7884 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7885 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
7886 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7887 : 0 : }
7888 : :
7889 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7890 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7891 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7892 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7893 : : "rxd#txd");
7894 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7895 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
7896 : : RTE_UINT16);
7897 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7898 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
7899 : : RTE_UINT16);
7900 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7901 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
7902 : : RTE_UINT16);
7903 : :
7904 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
7905 : : .f = cmd_read_rxd_txd_parsed,
7906 : : .data = NULL,
7907 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7908 : : .tokens = {
7909 : : (void *)&cmd_read_rxd_txd_read,
7910 : : (void *)&cmd_read_rxd_txd_rxd_txd,
7911 : : (void *)&cmd_read_rxd_txd_port_id,
7912 : : (void *)&cmd_read_rxd_txd_queue_id,
7913 : : (void *)&cmd_read_rxd_txd_desc_id,
7914 : : NULL,
7915 : : },
7916 : : };
7917 : :
7918 : : /* *** QUIT *** */
7919 : : struct cmd_quit_result {
7920 : : cmdline_fixed_string_t quit;
7921 : : };
7922 : :
7923 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
7924 : : struct cmdline *cl,
7925 : : __rte_unused void *data)
7926 : : {
7927 : 0 : cmdline_quit(cl);
7928 : 0 : cl_quit = 1;
7929 : 0 : }
7930 : :
7931 : : static cmdline_parse_token_string_t cmd_quit_quit =
7932 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7933 : :
7934 : : static cmdline_parse_inst_t cmd_quit = {
7935 : : .f = cmd_quit_parsed,
7936 : : .data = NULL,
7937 : : .help_str = "quit: Exit application",
7938 : : .tokens = {
7939 : : (void *)&cmd_quit_quit,
7940 : : NULL,
7941 : : },
7942 : : };
7943 : :
7944 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7945 : : struct cmd_mac_addr_result {
7946 : : cmdline_fixed_string_t mac_addr_cmd;
7947 : : cmdline_fixed_string_t what;
7948 : : uint16_t port_num;
7949 : : struct rte_ether_addr address;
7950 : : };
7951 : :
7952 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
7953 : : __rte_unused struct cmdline *cl,
7954 : : __rte_unused void *data)
7955 : : {
7956 : : struct cmd_mac_addr_result *res = parsed_result;
7957 : : int ret;
7958 : :
7959 : 0 : if (strcmp(res->what, "add") == 0)
7960 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7961 : 0 : else if (strcmp(res->what, "set") == 0)
7962 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7963 : : &res->address);
7964 : : else
7965 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7966 : :
7967 : : /* check the return value and print it if is < 0 */
7968 : 0 : if(ret < 0)
7969 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
7970 : :
7971 : 0 : }
7972 : :
7973 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
7974 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7975 : : "mac_addr");
7976 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
7977 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7978 : : "add#remove#set");
7979 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
7980 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7981 : : RTE_UINT16);
7982 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7983 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7984 : :
7985 : : static cmdline_parse_inst_t cmd_mac_addr = {
7986 : : .f = cmd_mac_addr_parsed,
7987 : : .data = (void *)0,
7988 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7989 : : "Add/Remove/Set MAC address on port_id",
7990 : : .tokens = {
7991 : : (void *)&cmd_mac_addr_cmd,
7992 : : (void *)&cmd_mac_addr_what,
7993 : : (void *)&cmd_mac_addr_portnum,
7994 : : (void *)&cmd_mac_addr_addr,
7995 : : NULL,
7996 : : },
7997 : : };
7998 : :
7999 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8000 : : struct cmd_eth_peer_result {
8001 : : cmdline_fixed_string_t set;
8002 : : cmdline_fixed_string_t eth_peer;
8003 : : portid_t port_id;
8004 : : cmdline_fixed_string_t peer_addr;
8005 : : };
8006 : :
8007 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
8008 : : __rte_unused struct cmdline *cl,
8009 : : __rte_unused void *data)
8010 : : {
8011 : : struct cmd_eth_peer_result *res = parsed_result;
8012 : :
8013 : 0 : if (test_done == 0) {
8014 : 0 : fprintf(stderr, "Please stop forwarding first\n");
8015 : 0 : return;
8016 : : }
8017 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
8018 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
8019 : 0 : fwd_config_setup();
8020 : : }
8021 : : }
8022 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
8023 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8024 : : static cmdline_parse_token_string_t cmd_eth_peer =
8025 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8026 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
8027 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8028 : : RTE_UINT16);
8029 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
8030 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8031 : :
8032 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8033 : : .f = cmd_set_eth_peer_parsed,
8034 : : .data = NULL,
8035 : : .help_str = "set eth-peer <port_id> <peer_mac>",
8036 : : .tokens = {
8037 : : (void *)&cmd_eth_peer_set,
8038 : : (void *)&cmd_eth_peer,
8039 : : (void *)&cmd_eth_peer_port_id,
8040 : : (void *)&cmd_eth_peer_addr,
8041 : : NULL,
8042 : : },
8043 : : };
8044 : :
8045 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8046 : : struct cmd_set_xstats_hide_zero_result {
8047 : : cmdline_fixed_string_t keyword;
8048 : : cmdline_fixed_string_t name;
8049 : : cmdline_fixed_string_t on_off;
8050 : : };
8051 : :
8052 : : static void
8053 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8054 : : __rte_unused struct cmdline *cl,
8055 : : __rte_unused void *data)
8056 : : {
8057 : : struct cmd_set_xstats_hide_zero_result *res;
8058 : : uint16_t on_off = 0;
8059 : :
8060 : : res = parsed_result;
8061 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8062 : 0 : set_xstats_hide_zero(on_off);
8063 : 0 : }
8064 : :
8065 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8066 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8067 : : keyword, "set");
8068 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8069 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8070 : : name, "xstats-hide-zero");
8071 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8072 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8073 : : on_off, "on#off");
8074 : :
8075 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8076 : : .f = cmd_set_xstats_hide_zero_parsed,
8077 : : .data = NULL,
8078 : : .help_str = "set xstats-hide-zero on|off",
8079 : : .tokens = {
8080 : : (void *)&cmd_set_xstats_hide_zero_keyword,
8081 : : (void *)&cmd_set_xstats_hide_zero_name,
8082 : : (void *)&cmd_set_xstats_hide_zero_on_off,
8083 : : NULL,
8084 : : },
8085 : : };
8086 : :
8087 : : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
8088 : : struct cmd_set_xstats_show_state_result {
8089 : : cmdline_fixed_string_t keyword;
8090 : : cmdline_fixed_string_t name;
8091 : : uint8_t on_off;
8092 : : };
8093 : : static void
8094 : 0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
8095 : : __rte_unused struct cmdline *cl,
8096 : : __rte_unused void *data)
8097 : : {
8098 : : struct cmd_set_xstats_show_state_result *res = parsed_result;
8099 : 0 : set_xstats_show_state(res->on_off);
8100 : 0 : }
8101 : :
8102 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
8103 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8104 : : keyword, "set");
8105 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
8106 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8107 : : name, "xstats-show-state");
8108 : : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
8109 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
8110 : : on_off);
8111 : :
8112 : : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
8113 : : .f = cmd_set_xstats_show_state_parsed,
8114 : : .data = NULL,
8115 : : .help_str = "set xstats-show-state on|off",
8116 : : .tokens = {
8117 : : (void *)&cmd_set_xstats_show_state_keyword,
8118 : : (void *)&cmd_set_xstats_show_state_name,
8119 : : (void *)&cmd_set_xstats_show_state_on_off,
8120 : : NULL,
8121 : : },
8122 : : };
8123 : :
8124 : : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
8125 : : struct cmd_set_xstats_hide_disabled_result {
8126 : : cmdline_fixed_string_t keyword;
8127 : : cmdline_fixed_string_t name;
8128 : : uint8_t on_off;
8129 : : };
8130 : :
8131 : : static void
8132 : 0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
8133 : : __rte_unused struct cmdline *cl,
8134 : : __rte_unused void *data)
8135 : : {
8136 : : struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
8137 : 0 : set_xstats_hide_disabled(res->on_off);
8138 : 0 : }
8139 : :
8140 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
8141 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8142 : : keyword, "set");
8143 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
8144 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8145 : : name, "xstats-hide-disabled");
8146 : : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
8147 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8148 : : on_off);
8149 : :
8150 : : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
8151 : : .f = cmd_set_xstats_hide_disabled_parsed,
8152 : : .data = NULL,
8153 : : .help_str = "set xstats-hide-disabled on|off",
8154 : : .tokens = {
8155 : : (void *)&cmd_set_xstats_hide_disabled_keyword,
8156 : : (void *)&cmd_set_xstats_hide_disabled_name,
8157 : : (void *)&cmd_set_xstats_hide_disabled_on_off,
8158 : : NULL,
8159 : : },
8160 : : };
8161 : :
8162 : : /* *** enable/disable counter by name *** */
8163 : : struct cmd_operate_set_counter_result {
8164 : : cmdline_fixed_string_t port;
8165 : : portid_t port_id;
8166 : : cmdline_fixed_string_t what;
8167 : : cmdline_multi_string_t counter_name;
8168 : : };
8169 : :
8170 : : static void
8171 : 0 : cmd_operate_set_counter_parsed(void *parsed_result,
8172 : : __rte_unused struct cmdline *cl,
8173 : : __rte_unused void *data)
8174 : : {
8175 : : struct cmd_operate_set_counter_result *res = parsed_result;
8176 : 0 : uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
8177 : :
8178 : 0 : if ((strcmp(res->port, "port") == 0))
8179 : 0 : nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
8180 : 0 : }
8181 : :
8182 : : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
8183 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8184 : : port, "port");
8185 : : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
8186 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
8187 : : port_id, RTE_UINT16);
8188 : : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
8189 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8190 : : what, "enable#disable");
8191 : : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
8192 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8193 : : counter_name, TOKEN_STRING_MULTI);
8194 : :
8195 : : static cmdline_parse_inst_t cmd_operate_set_counter = {
8196 : : .f = cmd_operate_set_counter_parsed,
8197 : : .data = NULL,
8198 : : .help_str = "port (port_id) enable|disable <counter_name>",
8199 : : .tokens = {
8200 : : (void *)&cmd_operate_set_counter_port,
8201 : : (void *)&cmd_operate_set_counter_port_id,
8202 : : (void *)&cmd_operate_set_counter_what,
8203 : : (void *)&cmd_operate_set_counter_name,
8204 : : NULL,
8205 : : },
8206 : : };
8207 : :
8208 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8209 : : struct cmd_set_record_core_cycles_result {
8210 : : cmdline_fixed_string_t keyword;
8211 : : cmdline_fixed_string_t name;
8212 : : cmdline_fixed_string_t on_off;
8213 : : };
8214 : :
8215 : : static void
8216 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
8217 : : __rte_unused struct cmdline *cl,
8218 : : __rte_unused void *data)
8219 : : {
8220 : : struct cmd_set_record_core_cycles_result *res;
8221 : : uint16_t on_off = 0;
8222 : :
8223 : : res = parsed_result;
8224 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8225 : 0 : set_record_core_cycles(on_off);
8226 : 0 : }
8227 : :
8228 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8229 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8230 : : keyword, "set");
8231 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8232 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8233 : : name, "record-core-cycles");
8234 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8235 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8236 : : on_off, "on#off");
8237 : :
8238 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
8239 : : .f = cmd_set_record_core_cycles_parsed,
8240 : : .data = NULL,
8241 : : .help_str = "set record-core-cycles on|off",
8242 : : .tokens = {
8243 : : (void *)&cmd_set_record_core_cycles_keyword,
8244 : : (void *)&cmd_set_record_core_cycles_name,
8245 : : (void *)&cmd_set_record_core_cycles_on_off,
8246 : : NULL,
8247 : : },
8248 : : };
8249 : :
8250 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8251 : : struct cmd_set_record_burst_stats_result {
8252 : : cmdline_fixed_string_t keyword;
8253 : : cmdline_fixed_string_t name;
8254 : : cmdline_fixed_string_t on_off;
8255 : : };
8256 : :
8257 : : static void
8258 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
8259 : : __rte_unused struct cmdline *cl,
8260 : : __rte_unused void *data)
8261 : : {
8262 : : struct cmd_set_record_burst_stats_result *res;
8263 : : uint16_t on_off = 0;
8264 : :
8265 : : res = parsed_result;
8266 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8267 : 0 : set_record_burst_stats(on_off);
8268 : 0 : }
8269 : :
8270 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8271 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8272 : : keyword, "set");
8273 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8274 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8275 : : name, "record-burst-stats");
8276 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8277 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8278 : : on_off, "on#off");
8279 : :
8280 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
8281 : : .f = cmd_set_record_burst_stats_parsed,
8282 : : .data = NULL,
8283 : : .help_str = "set record-burst-stats on|off",
8284 : : .tokens = {
8285 : : (void *)&cmd_set_record_burst_stats_keyword,
8286 : : (void *)&cmd_set_record_burst_stats_name,
8287 : : (void *)&cmd_set_record_burst_stats_on_off,
8288 : : NULL,
8289 : : },
8290 : : };
8291 : :
8292 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
8293 : : struct cmd_set_uc_hash_table {
8294 : : cmdline_fixed_string_t set;
8295 : : cmdline_fixed_string_t port;
8296 : : portid_t port_id;
8297 : : cmdline_fixed_string_t what;
8298 : : struct rte_ether_addr address;
8299 : : cmdline_fixed_string_t mode;
8300 : : };
8301 : :
8302 : : static void
8303 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
8304 : : __rte_unused struct cmdline *cl,
8305 : : __rte_unused void *data)
8306 : : {
8307 : : int ret=0;
8308 : : struct cmd_set_uc_hash_table *res = parsed_result;
8309 : :
8310 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8311 : :
8312 : 0 : if (strcmp(res->what, "uta") == 0)
8313 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8314 : : &res->address,(uint8_t)is_on);
8315 : 0 : if (ret < 0)
8316 : 0 : fprintf(stderr,
8317 : : "bad unicast hash table parameter, return code = %d\n",
8318 : : ret);
8319 : :
8320 : 0 : }
8321 : :
8322 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
8323 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8324 : : set, "set");
8325 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
8326 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8327 : : port, "port");
8328 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8329 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8330 : : port_id, RTE_UINT16);
8331 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
8332 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8333 : : what, "uta");
8334 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8335 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8336 : : address);
8337 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8338 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8339 : : mode, "on#off");
8340 : :
8341 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8342 : : .f = cmd_set_uc_hash_parsed,
8343 : : .data = NULL,
8344 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
8345 : : .tokens = {
8346 : : (void *)&cmd_set_uc_hash_set,
8347 : : (void *)&cmd_set_uc_hash_port,
8348 : : (void *)&cmd_set_uc_hash_portid,
8349 : : (void *)&cmd_set_uc_hash_what,
8350 : : (void *)&cmd_set_uc_hash_mac,
8351 : : (void *)&cmd_set_uc_hash_mode,
8352 : : NULL,
8353 : : },
8354 : : };
8355 : :
8356 : : struct cmd_set_uc_all_hash_table {
8357 : : cmdline_fixed_string_t set;
8358 : : cmdline_fixed_string_t port;
8359 : : portid_t port_id;
8360 : : cmdline_fixed_string_t what;
8361 : : cmdline_fixed_string_t value;
8362 : : cmdline_fixed_string_t mode;
8363 : : };
8364 : :
8365 : : static void
8366 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
8367 : : __rte_unused struct cmdline *cl,
8368 : : __rte_unused void *data)
8369 : : {
8370 : : int ret=0;
8371 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
8372 : :
8373 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8374 : :
8375 : 0 : if ((strcmp(res->what, "uta") == 0) &&
8376 : 0 : (strcmp(res->value, "all") == 0))
8377 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8378 : 0 : if (ret < 0)
8379 : 0 : fprintf(stderr,
8380 : : "bad unicast hash table parameter, return code = %d\n",
8381 : : ret);
8382 : 0 : }
8383 : :
8384 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8385 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8386 : : set, "set");
8387 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8388 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8389 : : port, "port");
8390 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8391 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8392 : : port_id, RTE_UINT16);
8393 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8394 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8395 : : what, "uta");
8396 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8397 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8398 : : value,"all");
8399 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8400 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8401 : : mode, "on#off");
8402 : :
8403 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8404 : : .f = cmd_set_uc_all_hash_parsed,
8405 : : .data = NULL,
8406 : : .help_str = "set port <port_id> uta all on|off",
8407 : : .tokens = {
8408 : : (void *)&cmd_set_uc_all_hash_set,
8409 : : (void *)&cmd_set_uc_all_hash_port,
8410 : : (void *)&cmd_set_uc_all_hash_portid,
8411 : : (void *)&cmd_set_uc_all_hash_what,
8412 : : (void *)&cmd_set_uc_all_hash_value,
8413 : : (void *)&cmd_set_uc_all_hash_mode,
8414 : : NULL,
8415 : : },
8416 : : };
8417 : :
8418 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8419 : : struct cmd_set_vf_traffic {
8420 : : cmdline_fixed_string_t set;
8421 : : cmdline_fixed_string_t port;
8422 : : portid_t port_id;
8423 : : cmdline_fixed_string_t vf;
8424 : : uint8_t vf_id;
8425 : : cmdline_fixed_string_t what;
8426 : : cmdline_fixed_string_t mode;
8427 : : };
8428 : :
8429 : : static void
8430 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
8431 : : __rte_unused struct cmdline *cl,
8432 : : __rte_unused void *data)
8433 : : {
8434 : : struct cmd_set_vf_traffic *res = parsed_result;
8435 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8436 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8437 : :
8438 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8439 : 0 : }
8440 : :
8441 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
8442 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8443 : : set, "set");
8444 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
8445 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8446 : : port, "port");
8447 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8448 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8449 : : port_id, RTE_UINT16);
8450 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8451 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8452 : : vf, "vf");
8453 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8454 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8455 : : vf_id, RTE_UINT8);
8456 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
8457 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8458 : : what, "tx#rx");
8459 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8460 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8461 : : mode, "on#off");
8462 : :
8463 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
8464 : : .f = cmd_set_vf_traffic_parsed,
8465 : : .data = NULL,
8466 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8467 : : .tokens = {
8468 : : (void *)&cmd_setvf_traffic_set,
8469 : : (void *)&cmd_setvf_traffic_port,
8470 : : (void *)&cmd_setvf_traffic_portid,
8471 : : (void *)&cmd_setvf_traffic_vf,
8472 : : (void *)&cmd_setvf_traffic_vfid,
8473 : : (void *)&cmd_setvf_traffic_what,
8474 : : (void *)&cmd_setvf_traffic_mode,
8475 : : NULL,
8476 : : },
8477 : : };
8478 : :
8479 : : /* *** CONFIGURE VF RECEIVE MODE *** */
8480 : : struct cmd_set_vf_rxmode {
8481 : : cmdline_fixed_string_t set;
8482 : : cmdline_fixed_string_t port;
8483 : : portid_t port_id;
8484 : : cmdline_fixed_string_t vf;
8485 : : uint8_t vf_id;
8486 : : cmdline_fixed_string_t what;
8487 : : cmdline_fixed_string_t mode;
8488 : : cmdline_fixed_string_t on;
8489 : : };
8490 : :
8491 : : static void
8492 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
8493 : : __rte_unused struct cmdline *cl,
8494 : : __rte_unused void *data)
8495 : : {
8496 : : int ret = -ENOTSUP;
8497 : : uint16_t vf_rxmode = 0;
8498 : : struct cmd_set_vf_rxmode *res = parsed_result;
8499 : :
8500 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8501 : 0 : if (!strcmp(res->what,"rxmode")) {
8502 : 0 : if (!strcmp(res->mode, "AUPE"))
8503 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
8504 : 0 : else if (!strcmp(res->mode, "ROPE"))
8505 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
8506 : 0 : else if (!strcmp(res->mode, "BAM"))
8507 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
8508 : 0 : else if (!strncmp(res->mode, "MPE",3))
8509 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
8510 : : }
8511 : :
8512 : : RTE_SET_USED(is_on);
8513 : : RTE_SET_USED(vf_rxmode);
8514 : :
8515 : : #ifdef RTE_NET_IXGBE
8516 : : if (ret == -ENOTSUP)
8517 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8518 : : vf_rxmode, (uint8_t)is_on);
8519 : : #endif
8520 : : #ifdef RTE_NET_BNXT
8521 : 0 : if (ret == -ENOTSUP)
8522 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8523 : : vf_rxmode, (uint8_t)is_on);
8524 : : #endif
8525 : 0 : if (ret < 0)
8526 : 0 : fprintf(stderr,
8527 : : "bad VF receive mode parameter, return code = %d\n",
8528 : : ret);
8529 : 0 : }
8530 : :
8531 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8532 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8533 : : set, "set");
8534 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8535 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8536 : : port, "port");
8537 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8538 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8539 : : port_id, RTE_UINT16);
8540 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8541 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8542 : : vf, "vf");
8543 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8544 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8545 : : vf_id, RTE_UINT8);
8546 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8547 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8548 : : what, "rxmode");
8549 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8550 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8551 : : mode, "AUPE#ROPE#BAM#MPE");
8552 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8553 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8554 : : on, "on#off");
8555 : :
8556 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
8557 : : .f = cmd_set_vf_rxmode_parsed,
8558 : : .data = NULL,
8559 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
8560 : : "AUPE|ROPE|BAM|MPE on|off",
8561 : : .tokens = {
8562 : : (void *)&cmd_set_vf_rxmode_set,
8563 : : (void *)&cmd_set_vf_rxmode_port,
8564 : : (void *)&cmd_set_vf_rxmode_portid,
8565 : : (void *)&cmd_set_vf_rxmode_vf,
8566 : : (void *)&cmd_set_vf_rxmode_vfid,
8567 : : (void *)&cmd_set_vf_rxmode_what,
8568 : : (void *)&cmd_set_vf_rxmode_mode,
8569 : : (void *)&cmd_set_vf_rxmode_on,
8570 : : NULL,
8571 : : },
8572 : : };
8573 : :
8574 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8575 : : struct cmd_vf_mac_addr_result {
8576 : : cmdline_fixed_string_t mac_addr_cmd;
8577 : : cmdline_fixed_string_t what;
8578 : : cmdline_fixed_string_t port;
8579 : : uint16_t port_num;
8580 : : cmdline_fixed_string_t vf;
8581 : : uint8_t vf_num;
8582 : : struct rte_ether_addr address;
8583 : : };
8584 : :
8585 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
8586 : : __rte_unused struct cmdline *cl,
8587 : : __rte_unused void *data)
8588 : : {
8589 : : struct cmd_vf_mac_addr_result *res = parsed_result;
8590 : : int ret = -ENOTSUP;
8591 : :
8592 : 0 : if (strcmp(res->what, "add") != 0)
8593 : : return;
8594 : :
8595 : : #ifdef RTE_NET_I40E
8596 : : if (ret == -ENOTSUP)
8597 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8598 : : &res->address);
8599 : : #endif
8600 : : #ifdef RTE_NET_BNXT
8601 : 0 : if (ret == -ENOTSUP)
8602 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8603 : 0 : res->vf_num);
8604 : : #endif
8605 : :
8606 : 0 : if(ret < 0)
8607 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8608 : :
8609 : : }
8610 : :
8611 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8612 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8613 : : mac_addr_cmd,"mac_addr");
8614 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8615 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8616 : : what,"add");
8617 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8618 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8619 : : port,"port");
8620 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8621 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8622 : : port_num, RTE_UINT16);
8623 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8624 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8625 : : vf,"vf");
8626 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8627 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8628 : : vf_num, RTE_UINT8);
8629 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8630 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8631 : : address);
8632 : :
8633 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8634 : : .f = cmd_vf_mac_addr_parsed,
8635 : : .data = (void *)0,
8636 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8637 : : "Add MAC address filtering for a VF on port_id",
8638 : : .tokens = {
8639 : : (void *)&cmd_vf_mac_addr_cmd,
8640 : : (void *)&cmd_vf_mac_addr_what,
8641 : : (void *)&cmd_vf_mac_addr_port,
8642 : : (void *)&cmd_vf_mac_addr_portnum,
8643 : : (void *)&cmd_vf_mac_addr_vf,
8644 : : (void *)&cmd_vf_mac_addr_vfnum,
8645 : : (void *)&cmd_vf_mac_addr_addr,
8646 : : NULL,
8647 : : },
8648 : : };
8649 : :
8650 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8651 : : struct cmd_vf_rx_vlan_filter {
8652 : : cmdline_fixed_string_t rx_vlan;
8653 : : cmdline_fixed_string_t what;
8654 : : uint16_t vlan_id;
8655 : : cmdline_fixed_string_t port;
8656 : : portid_t port_id;
8657 : : cmdline_fixed_string_t vf;
8658 : : uint64_t vf_mask;
8659 : : };
8660 : :
8661 : : static void
8662 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8663 : : __rte_unused struct cmdline *cl,
8664 : : __rte_unused void *data)
8665 : : {
8666 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8667 : : int ret = -ENOTSUP;
8668 : :
8669 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8670 : :
8671 : : #ifdef RTE_NET_IXGBE
8672 : : if (ret == -ENOTSUP)
8673 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8674 : 0 : res->vlan_id, res->vf_mask, is_add);
8675 : : #endif
8676 : : #ifdef RTE_NET_I40E
8677 : 0 : if (ret == -ENOTSUP)
8678 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8679 : 0 : res->vlan_id, res->vf_mask, is_add);
8680 : : #endif
8681 : : #ifdef RTE_NET_BNXT
8682 : 0 : if (ret == -ENOTSUP)
8683 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8684 : 0 : res->vlan_id, res->vf_mask, is_add);
8685 : : #endif
8686 : :
8687 : 0 : switch (ret) {
8688 : : case 0:
8689 : : break;
8690 : 0 : case -EINVAL:
8691 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8692 : 0 : res->vlan_id, res->vf_mask);
8693 : : break;
8694 : 0 : case -ENODEV:
8695 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8696 : : break;
8697 : 0 : case -ENOTSUP:
8698 : 0 : fprintf(stderr, "function not implemented or supported\n");
8699 : : break;
8700 : 0 : default:
8701 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8702 : : }
8703 : 0 : }
8704 : :
8705 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8706 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8707 : : rx_vlan, "rx_vlan");
8708 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8709 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8710 : : what, "add#rm");
8711 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8712 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8713 : : vlan_id, RTE_UINT16);
8714 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8715 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8716 : : port, "port");
8717 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8718 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8719 : : port_id, RTE_UINT16);
8720 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8721 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8722 : : vf, "vf");
8723 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8724 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8725 : : vf_mask, RTE_UINT64);
8726 : :
8727 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8728 : : .f = cmd_vf_rx_vlan_filter_parsed,
8729 : : .data = NULL,
8730 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8731 : : "(vf_mask = hexadecimal VF mask)",
8732 : : .tokens = {
8733 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8734 : : (void *)&cmd_vf_rx_vlan_filter_what,
8735 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8736 : : (void *)&cmd_vf_rx_vlan_filter_port,
8737 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8738 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8739 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8740 : : NULL,
8741 : : },
8742 : : };
8743 : :
8744 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8745 : : struct cmd_queue_rate_limit_result {
8746 : : cmdline_fixed_string_t set;
8747 : : cmdline_fixed_string_t port;
8748 : : uint16_t port_num;
8749 : : cmdline_fixed_string_t queue;
8750 : : uint8_t queue_num;
8751 : : cmdline_fixed_string_t rate;
8752 : : uint32_t rate_num;
8753 : : };
8754 : :
8755 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8756 : : __rte_unused struct cmdline *cl,
8757 : : __rte_unused void *data)
8758 : : {
8759 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8760 : : int ret = 0;
8761 : :
8762 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8763 : 0 : && (strcmp(res->queue, "queue") == 0)
8764 : 0 : && (strcmp(res->rate, "rate") == 0))
8765 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8766 : : res->rate_num);
8767 : 0 : if (ret < 0)
8768 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8769 : : strerror(-ret));
8770 : :
8771 : 0 : }
8772 : :
8773 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8774 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8775 : : set, "set");
8776 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8777 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8778 : : port, "port");
8779 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8780 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8781 : : port_num, RTE_UINT16);
8782 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8783 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8784 : : queue, "queue");
8785 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8786 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8787 : : queue_num, RTE_UINT8);
8788 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8789 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8790 : : rate, "rate");
8791 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8792 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8793 : : rate_num, RTE_UINT32);
8794 : :
8795 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8796 : : .f = cmd_queue_rate_limit_parsed,
8797 : : .data = (void *)0,
8798 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8799 : : "Set rate limit for a queue on port_id",
8800 : : .tokens = {
8801 : : (void *)&cmd_queue_rate_limit_set,
8802 : : (void *)&cmd_queue_rate_limit_port,
8803 : : (void *)&cmd_queue_rate_limit_portnum,
8804 : : (void *)&cmd_queue_rate_limit_queue,
8805 : : (void *)&cmd_queue_rate_limit_queuenum,
8806 : : (void *)&cmd_queue_rate_limit_rate,
8807 : : (void *)&cmd_queue_rate_limit_ratenum,
8808 : : NULL,
8809 : : },
8810 : : };
8811 : :
8812 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8813 : : struct cmd_vf_rate_limit_result {
8814 : : cmdline_fixed_string_t set;
8815 : : cmdline_fixed_string_t port;
8816 : : uint16_t port_num;
8817 : : cmdline_fixed_string_t vf;
8818 : : uint8_t vf_num;
8819 : : cmdline_fixed_string_t rate;
8820 : : uint32_t rate_num;
8821 : : cmdline_fixed_string_t q_msk;
8822 : : uint64_t q_msk_val;
8823 : : };
8824 : :
8825 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
8826 : : __rte_unused struct cmdline *cl,
8827 : : __rte_unused void *data)
8828 : : {
8829 : : struct cmd_vf_rate_limit_result *res = parsed_result;
8830 : : int ret = 0;
8831 : :
8832 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8833 : 0 : && (strcmp(res->vf, "vf") == 0)
8834 : 0 : && (strcmp(res->rate, "rate") == 0)
8835 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
8836 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
8837 : : res->rate_num, res->q_msk_val);
8838 : 0 : if (ret < 0)
8839 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
8840 : : strerror(-ret));
8841 : :
8842 : 0 : }
8843 : :
8844 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8845 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8846 : : set, "set");
8847 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8848 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8849 : : port, "port");
8850 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8851 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8852 : : port_num, RTE_UINT16);
8853 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8854 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8855 : : vf, "vf");
8856 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8857 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8858 : : vf_num, RTE_UINT8);
8859 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8860 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8861 : : rate, "rate");
8862 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8863 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8864 : : rate_num, RTE_UINT32);
8865 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8866 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8867 : : q_msk, "queue_mask");
8868 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8869 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8870 : : q_msk_val, RTE_UINT64);
8871 : :
8872 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
8873 : : .f = cmd_vf_rate_limit_parsed,
8874 : : .data = (void *)0,
8875 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8876 : : "queue_mask <queue_mask_value>: "
8877 : : "Set rate limit for queues of VF on port_id",
8878 : : .tokens = {
8879 : : (void *)&cmd_vf_rate_limit_set,
8880 : : (void *)&cmd_vf_rate_limit_port,
8881 : : (void *)&cmd_vf_rate_limit_portnum,
8882 : : (void *)&cmd_vf_rate_limit_vf,
8883 : : (void *)&cmd_vf_rate_limit_vfnum,
8884 : : (void *)&cmd_vf_rate_limit_rate,
8885 : : (void *)&cmd_vf_rate_limit_ratenum,
8886 : : (void *)&cmd_vf_rate_limit_q_msk,
8887 : : (void *)&cmd_vf_rate_limit_q_msk_val,
8888 : : NULL,
8889 : : },
8890 : : };
8891 : :
8892 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
8893 : : struct cmd_tunnel_udp_config {
8894 : : cmdline_fixed_string_t rx_vxlan_port;
8895 : : cmdline_fixed_string_t what;
8896 : : uint16_t udp_port;
8897 : : portid_t port_id;
8898 : : };
8899 : :
8900 : : static void
8901 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
8902 : : __rte_unused struct cmdline *cl,
8903 : : __rte_unused void *data)
8904 : : {
8905 : : struct cmd_tunnel_udp_config *res = parsed_result;
8906 : : struct rte_eth_udp_tunnel tunnel_udp;
8907 : : int ret;
8908 : :
8909 : 0 : tunnel_udp.udp_port = res->udp_port;
8910 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8911 : :
8912 : 0 : if (!strcmp(res->what, "add"))
8913 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8914 : : &tunnel_udp);
8915 : : else
8916 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8917 : : &tunnel_udp);
8918 : :
8919 : 0 : if (ret < 0)
8920 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
8921 : : strerror(-ret));
8922 : 0 : }
8923 : :
8924 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
8925 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8926 : : rx_vxlan_port, "rx_vxlan_port");
8927 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8928 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8929 : : what, "add#rm");
8930 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8931 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8932 : : udp_port, RTE_UINT16);
8933 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8934 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8935 : : port_id, RTE_UINT16);
8936 : :
8937 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
8938 : : .f = cmd_tunnel_udp_config_parsed,
8939 : : .data = (void *)0,
8940 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8941 : : "Add/Remove a tunneling UDP port filter",
8942 : : .tokens = {
8943 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
8944 : : (void *)&cmd_tunnel_udp_config_what,
8945 : : (void *)&cmd_tunnel_udp_config_udp_port,
8946 : : (void *)&cmd_tunnel_udp_config_port_id,
8947 : : NULL,
8948 : : },
8949 : : };
8950 : :
8951 : : struct cmd_config_tunnel_udp_port {
8952 : : cmdline_fixed_string_t port;
8953 : : cmdline_fixed_string_t config;
8954 : : portid_t port_id;
8955 : : cmdline_fixed_string_t udp_tunnel_port;
8956 : : cmdline_fixed_string_t action;
8957 : : cmdline_fixed_string_t tunnel_type;
8958 : : uint16_t udp_port;
8959 : : };
8960 : :
8961 : : static void
8962 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8963 : : __rte_unused struct cmdline *cl,
8964 : : __rte_unused void *data)
8965 : : {
8966 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
8967 : : struct rte_eth_udp_tunnel tunnel_udp;
8968 : : int ret = 0;
8969 : :
8970 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8971 : 0 : return;
8972 : :
8973 : 0 : tunnel_udp.udp_port = res->udp_port;
8974 : :
8975 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
8976 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8977 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
8978 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
8979 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
8980 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
8981 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
8982 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
8983 : : } else {
8984 : 0 : fprintf(stderr, "Invalid tunnel type\n");
8985 : 0 : return;
8986 : : }
8987 : :
8988 : 0 : if (!strcmp(res->action, "add"))
8989 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8990 : : &tunnel_udp);
8991 : : else
8992 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8993 : : &tunnel_udp);
8994 : :
8995 : 0 : if (ret < 0)
8996 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
8997 : : strerror(-ret));
8998 : : }
8999 : :
9000 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9001 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9002 : : "port");
9003 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9004 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9005 : : "config");
9006 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9007 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9008 : : RTE_UINT16);
9009 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9010 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9011 : : udp_tunnel_port,
9012 : : "udp_tunnel_port");
9013 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9014 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9015 : : "add#rm");
9016 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9017 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9018 : : "vxlan#geneve#vxlan-gpe#ecpri");
9019 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9020 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9021 : : RTE_UINT16);
9022 : :
9023 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9024 : : .f = cmd_cfg_tunnel_udp_port_parsed,
9025 : : .data = NULL,
9026 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9027 : : "geneve|vxlan-gpe|ecpri <udp_port>",
9028 : : .tokens = {
9029 : : (void *)&cmd_config_tunnel_udp_port_port,
9030 : : (void *)&cmd_config_tunnel_udp_port_config,
9031 : : (void *)&cmd_config_tunnel_udp_port_port_id,
9032 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9033 : : (void *)&cmd_config_tunnel_udp_port_action,
9034 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9035 : : (void *)&cmd_config_tunnel_udp_port_value,
9036 : : NULL,
9037 : : },
9038 : : };
9039 : :
9040 : : /* ******************************************************************************** */
9041 : :
9042 : : struct cmd_dump_simple_result {
9043 : : cmdline_fixed_string_t dump;
9044 : : cmdline_fixed_string_t obj;
9045 : : cmdline_fixed_string_t name;
9046 : : };
9047 : : static cmdline_parse_token_string_t cmd_dump_simple_dump =
9048 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, dump, "dump");
9049 : : static cmdline_parse_token_string_t cmd_dump_simple_obj =
9050 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9051 : : "physmem#"
9052 : : "socket_mem#"
9053 : : "memzone#"
9054 : : "struct_sizes#"
9055 : : "ring#"
9056 : : "mempool#"
9057 : : "devargs#"
9058 : : "lcores#"
9059 : : "trace#"
9060 : : "log_types"
9061 : : );
9062 : : static cmdline_parse_token_string_t cmd_dump_named_obj =
9063 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9064 : : "ring#"
9065 : : "mempool#"
9066 : : );
9067 : : static cmdline_parse_token_string_t cmd_dump_named_name =
9068 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, name, NULL);
9069 : :
9070 : : static void
9071 : 0 : dump_struct_sizes(void)
9072 : : {
9073 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9074 : : DUMP_SIZE(struct rte_mbuf);
9075 : : DUMP_SIZE(struct rte_mempool);
9076 : : DUMP_SIZE(struct rte_ring);
9077 : : #undef DUMP_SIZE
9078 : 0 : }
9079 : :
9080 : : /* Dump the socket memory statistics on console */
9081 : : static void
9082 : 0 : dump_socket_mem(FILE *f)
9083 : : {
9084 : : struct rte_malloc_socket_stats socket_stats;
9085 : : unsigned int i;
9086 : : size_t total = 0;
9087 : : size_t alloc = 0;
9088 : : size_t free = 0;
9089 : : unsigned int n_alloc = 0;
9090 : : unsigned int n_free = 0;
9091 : : static size_t last_allocs;
9092 : : static size_t last_total;
9093 : :
9094 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9095 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9096 : 0 : !socket_stats.heap_totalsz_bytes)
9097 : 0 : continue;
9098 : 0 : total += socket_stats.heap_totalsz_bytes;
9099 : 0 : alloc += socket_stats.heap_allocsz_bytes;
9100 : 0 : free += socket_stats.heap_freesz_bytes;
9101 : 0 : n_alloc += socket_stats.alloc_count;
9102 : 0 : n_free += socket_stats.free_count;
9103 : 0 : fprintf(f,
9104 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9105 : : i,
9106 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9107 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9108 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
9109 : 0 : (double)socket_stats.heap_totalsz_bytes,
9110 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9111 : : socket_stats.alloc_count,
9112 : : socket_stats.free_count);
9113 : : }
9114 : 0 : fprintf(f,
9115 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9116 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9117 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
9118 : 0 : (double)free / (1024 * 1024),
9119 : : n_alloc, n_free);
9120 : 0 : if (last_allocs)
9121 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9122 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
9123 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
9124 : 0 : last_allocs = alloc;
9125 : 0 : last_total = total;
9126 : 0 : }
9127 : :
9128 : 0 : static void cmd_dump_simple_parsed(void *parsed_result,
9129 : : struct cmdline *cl,
9130 : : __rte_unused void *data)
9131 : : {
9132 : : struct cmd_dump_simple_result *res = parsed_result;
9133 : :
9134 : 0 : if (strcmp(res->obj, "physmem") == 0)
9135 : 0 : rte_dump_physmem_layout(stdout);
9136 : 0 : else if (strcmp(res->obj, "socket_mem") == 0)
9137 : 0 : dump_socket_mem(stdout);
9138 : 0 : else if (strcmp(res->obj, "memzone") == 0)
9139 : 0 : rte_memzone_dump(stdout);
9140 : 0 : else if (strcmp(res->obj, "struct_sizes") == 0)
9141 : 0 : dump_struct_sizes();
9142 : 0 : else if (strcmp(res->obj, "ring") == 0) {
9143 : 0 : if (strcmp(res->name, "") == 0) {
9144 : 0 : rte_ring_list_dump(stdout);
9145 : : } else {
9146 : : struct rte_ring *r;
9147 : 0 : r = rte_ring_lookup(res->name);
9148 : 0 : if (r == NULL) {
9149 : 0 : cmdline_printf(cl, "Cannot find ring\n");
9150 : 0 : return;
9151 : : }
9152 : 0 : rte_ring_dump(stdout, r);
9153 : : }
9154 : 0 : } else if (strcmp(res->obj, "mempool") == 0) {
9155 : 0 : if (strcmp(res->name, "") == 0) {
9156 : 0 : rte_mempool_list_dump(stdout);
9157 : : } else {
9158 : : struct rte_mempool *mp;
9159 : 0 : mp = rte_mempool_lookup(res->name);
9160 : 0 : if (mp == NULL) {
9161 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
9162 : 0 : return;
9163 : : }
9164 : 0 : rte_mempool_dump(stdout, mp);
9165 : : }
9166 : 0 : } else if (strcmp(res->obj, "devargs") == 0)
9167 : 0 : rte_devargs_dump(stdout);
9168 : 0 : else if (strcmp(res->obj, "lcores") == 0)
9169 : 0 : rte_lcore_dump(stdout);
9170 : 0 : else if (strcmp(res->obj, "trace") == 0)
9171 : : #ifdef RTE_EXEC_ENV_WINDOWS
9172 : : cmdline_printf(cl, "trace is not supported on Windows\n");
9173 : : #else
9174 : 0 : rte_trace_save();
9175 : : #endif
9176 : 0 : else if (strcmp(res->obj, "log_types") == 0)
9177 : 0 : rte_log_dump(stdout);
9178 : : }
9179 : :
9180 : : static cmdline_parse_inst_t cmd_dump_simple = {
9181 : : .f = cmd_dump_simple_parsed,
9182 : : .help_str = "Dump objects",
9183 : : .tokens = {
9184 : : (void *)&cmd_dump_simple_dump,
9185 : : (void *)&cmd_dump_simple_obj,
9186 : : NULL,
9187 : : },
9188 : : };
9189 : : static cmdline_parse_inst_t cmd_dump_named = {
9190 : : .f = cmd_dump_simple_parsed,
9191 : : .help_str = "dump ring|mempool <name>: Dump one ring/mempool",
9192 : : .tokens = {
9193 : : (void *)&cmd_dump_simple_dump,
9194 : : (void *)&cmd_dump_named_obj,
9195 : : (void *)&cmd_dump_named_name,
9196 : : NULL,
9197 : : },
9198 : : };
9199 : :
9200 : : struct cmd_dump_mbuf_history_result {
9201 : : cmdline_fixed_string_t dump;
9202 : : cmdline_fixed_string_t mbuf;
9203 : : cmdline_fixed_string_t history;
9204 : : cmdline_fixed_string_t obj;
9205 : : cmdline_fixed_string_t name;
9206 : : cmdline_fixed_string_t addr;
9207 : : cmdline_fixed_string_t file;
9208 : : };
9209 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_dump =
9210 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, dump, "dump");
9211 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_mbuf =
9212 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, mbuf, "mbuf");
9213 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_history =
9214 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, history, "history");
9215 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_obj =
9216 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, NULL);
9217 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_pool =
9218 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, "pool");
9219 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_name =
9220 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, name, NULL);
9221 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_file =
9222 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, file, NULL);
9223 : :
9224 : 0 : static void cmd_dump_mbuf_history_parsed(void *parsed_result,
9225 : : struct cmdline *cl,
9226 : : __rte_unused void *data)
9227 : : {
9228 : : struct cmd_dump_mbuf_history_result *res = parsed_result;
9229 : 0 : FILE *out = stdout;
9230 : :
9231 : 0 : if (strcmp(res->file, "") != 0) {
9232 : 0 : out = fopen(res->file, "w");
9233 : 0 : if (out == NULL) {
9234 : 0 : cmdline_printf(cl,
9235 : : "Failed to open file '%s'\n",
9236 : : res->file);
9237 : 0 : return;
9238 : : }
9239 : : }
9240 : :
9241 : 0 : if (strcmp(res->obj, "all") == 0) {
9242 : 0 : rte_mbuf_history_dump_all(out);
9243 : 0 : if (out != stdout)
9244 : 0 : cmdline_printf(cl,
9245 : : "Dump written in '%s'\n",
9246 : 0 : res->file);
9247 : 0 : } else if (strcmp(res->obj, "pool") == 0) {
9248 : 0 : struct rte_mempool *mp = rte_mempool_lookup(res->name);
9249 : 0 : if (mp == NULL) {
9250 : 0 : cmdline_printf(cl,
9251 : : "Failed to find mempool '%s'\n",
9252 : : res->name);
9253 : 0 : return;
9254 : : }
9255 : 0 : rte_mbuf_history_dump_mempool(out, mp);
9256 : 0 : if (out != stdout)
9257 : 0 : cmdline_printf(cl,
9258 : : "Dump for mempool '%s' written in '%s'\n",
9259 : 0 : res->name, res->file);
9260 : : } else {
9261 : : struct rte_mbuf *mbuf;
9262 : : uintptr_t mbuf_addr;
9263 : 0 : if (sscanf(res->obj, "0x%" SCNxPTR, &mbuf_addr) != 1) {
9264 : 0 : cmdline_printf(cl,
9265 : : "Invalid mbuf pointer format. Use 0x<address>\n");
9266 : 0 : return;
9267 : : }
9268 : 0 : mbuf = (struct rte_mbuf *)mbuf_addr;
9269 : 0 : rte_mbuf_history_dump(out, mbuf);
9270 : 0 : if (out != stdout)
9271 : 0 : cmdline_printf(cl,
9272 : : "Dump for mbuf '%p' written in '%s'\n",
9273 : 0 : mbuf, res->file);
9274 : : }
9275 : :
9276 : 0 : if (out != stdout)
9277 : 0 : fclose(out);
9278 : : }
9279 : :
9280 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_stdout = {
9281 : : .f = cmd_dump_mbuf_history_parsed,
9282 : : .help_str = "dump mbuf history all|<address>",
9283 : : .tokens = {
9284 : : (void *)&cmd_dump_mbuf_history_dump,
9285 : : (void *)&cmd_dump_mbuf_history_mbuf,
9286 : : (void *)&cmd_dump_mbuf_history_history,
9287 : : (void *)&cmd_dump_mbuf_history_obj,
9288 : : NULL,
9289 : : },
9290 : : };
9291 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_to_file = {
9292 : : .f = cmd_dump_mbuf_history_parsed,
9293 : : .help_str = "dump mbuf history all|<address> [file]",
9294 : : .tokens = {
9295 : : (void *)&cmd_dump_mbuf_history_dump,
9296 : : (void *)&cmd_dump_mbuf_history_mbuf,
9297 : : (void *)&cmd_dump_mbuf_history_history,
9298 : : (void *)&cmd_dump_mbuf_history_obj,
9299 : : (void *)&cmd_dump_mbuf_history_file,
9300 : : NULL,
9301 : : },
9302 : : };
9303 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_stdout = {
9304 : : .f = cmd_dump_mbuf_history_parsed,
9305 : : .help_str = "dump mbuf pool history <name>",
9306 : : .tokens = {
9307 : : (void *)&cmd_dump_mbuf_history_dump,
9308 : : (void *)&cmd_dump_mbuf_history_mbuf,
9309 : : (void *)&cmd_dump_mbuf_history_pool,
9310 : : (void *)&cmd_dump_mbuf_history_history,
9311 : : (void *)&cmd_dump_mbuf_history_name,
9312 : : NULL,
9313 : : },
9314 : : };
9315 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_to_file = {
9316 : : .f = cmd_dump_mbuf_history_parsed,
9317 : : .help_str = "dump mbuf pool history <name> [file]",
9318 : : .tokens = {
9319 : : (void *)&cmd_dump_mbuf_history_dump,
9320 : : (void *)&cmd_dump_mbuf_history_mbuf,
9321 : : (void *)&cmd_dump_mbuf_history_pool,
9322 : : (void *)&cmd_dump_mbuf_history_history,
9323 : : (void *)&cmd_dump_mbuf_history_name,
9324 : : (void *)&cmd_dump_mbuf_history_file,
9325 : : NULL,
9326 : : },
9327 : : };
9328 : :
9329 : : /* *** Filters Control *** */
9330 : :
9331 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9332 : : do { \
9333 : : if ((ip_addr).family == AF_INET) \
9334 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
9335 : : else { \
9336 : : fprintf(stderr, "invalid parameter.\n"); \
9337 : : return; \
9338 : : } \
9339 : : } while (0)
9340 : :
9341 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9342 : : do { \
9343 : : if ((ip_addr).family == AF_INET6) \
9344 : : ip = ip_addr.addr.ipv6; \
9345 : : else { \
9346 : : fprintf(stderr, "invalid parameter.\n"); \
9347 : : return; \
9348 : : } \
9349 : : } while (0)
9350 : :
9351 : : /* Generic flow interface command. */
9352 : : extern cmdline_parse_inst_t cmd_flow;
9353 : :
9354 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9355 : : struct cmd_mcast_addr_result {
9356 : : cmdline_fixed_string_t mcast_addr_cmd;
9357 : : cmdline_fixed_string_t what;
9358 : : uint16_t port_num;
9359 : : struct rte_ether_addr mc_addr;
9360 : : };
9361 : :
9362 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
9363 : : __rte_unused struct cmdline *cl,
9364 : : __rte_unused void *data)
9365 : : {
9366 : : struct cmd_mcast_addr_result *res = parsed_result;
9367 : :
9368 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
9369 : 0 : fprintf(stderr,
9370 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
9371 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
9372 : 0 : return;
9373 : : }
9374 : 0 : if (strcmp(res->what, "add") == 0)
9375 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
9376 : : else
9377 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
9378 : : }
9379 : :
9380 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9381 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9382 : : mcast_addr_cmd, "mcast_addr");
9383 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
9384 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9385 : : "add#remove");
9386 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9387 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9388 : : RTE_UINT16);
9389 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9390 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9391 : :
9392 : : static cmdline_parse_inst_t cmd_mcast_addr = {
9393 : : .f = cmd_mcast_addr_parsed,
9394 : : .data = (void *)0,
9395 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
9396 : : "Add/Remove multicast MAC address on port_id",
9397 : : .tokens = {
9398 : : (void *)&cmd_mcast_addr_cmd,
9399 : : (void *)&cmd_mcast_addr_what,
9400 : : (void *)&cmd_mcast_addr_portnum,
9401 : : (void *)&cmd_mcast_addr_addr,
9402 : : NULL,
9403 : : },
9404 : : };
9405 : :
9406 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
9407 : : struct cmd_mcast_addr_flush_result {
9408 : : cmdline_fixed_string_t mcast_addr_cmd;
9409 : : cmdline_fixed_string_t what;
9410 : : uint16_t port_num;
9411 : : };
9412 : :
9413 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
9414 : : __rte_unused struct cmdline *cl,
9415 : : __rte_unused void *data)
9416 : : {
9417 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
9418 : :
9419 : 0 : mcast_addr_flush(res->port_num);
9420 : 0 : }
9421 : :
9422 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
9423 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9424 : : mcast_addr_cmd, "mcast_addr");
9425 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
9426 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9427 : : "flush");
9428 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
9429 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9430 : : RTE_UINT16);
9431 : :
9432 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
9433 : : .f = cmd_mcast_addr_flush_parsed,
9434 : : .data = (void *)0,
9435 : : .help_str = "mcast_addr flush <port_id> : "
9436 : : "flush all multicast MAC addresses on port_id",
9437 : : .tokens = {
9438 : : (void *)&cmd_mcast_addr_flush_cmd,
9439 : : (void *)&cmd_mcast_addr_flush_what,
9440 : : (void *)&cmd_mcast_addr_flush_portnum,
9441 : : NULL,
9442 : : },
9443 : : };
9444 : :
9445 : : /* vf vlan anti spoof configuration */
9446 : :
9447 : : /* Common result structure for vf vlan anti spoof */
9448 : : struct cmd_vf_vlan_anti_spoof_result {
9449 : : cmdline_fixed_string_t set;
9450 : : cmdline_fixed_string_t vf;
9451 : : cmdline_fixed_string_t vlan;
9452 : : cmdline_fixed_string_t antispoof;
9453 : : portid_t port_id;
9454 : : uint32_t vf_id;
9455 : : cmdline_fixed_string_t on_off;
9456 : : };
9457 : :
9458 : : /* Common CLI fields for vf vlan anti spoof enable disable */
9459 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
9460 : : TOKEN_STRING_INITIALIZER
9461 : : (struct cmd_vf_vlan_anti_spoof_result,
9462 : : set, "set");
9463 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
9464 : : TOKEN_STRING_INITIALIZER
9465 : : (struct cmd_vf_vlan_anti_spoof_result,
9466 : : vf, "vf");
9467 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
9468 : : TOKEN_STRING_INITIALIZER
9469 : : (struct cmd_vf_vlan_anti_spoof_result,
9470 : : vlan, "vlan");
9471 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
9472 : : TOKEN_STRING_INITIALIZER
9473 : : (struct cmd_vf_vlan_anti_spoof_result,
9474 : : antispoof, "antispoof");
9475 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
9476 : : TOKEN_NUM_INITIALIZER
9477 : : (struct cmd_vf_vlan_anti_spoof_result,
9478 : : port_id, RTE_UINT16);
9479 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
9480 : : TOKEN_NUM_INITIALIZER
9481 : : (struct cmd_vf_vlan_anti_spoof_result,
9482 : : vf_id, RTE_UINT32);
9483 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
9484 : : TOKEN_STRING_INITIALIZER
9485 : : (struct cmd_vf_vlan_anti_spoof_result,
9486 : : on_off, "on#off");
9487 : :
9488 : : static void
9489 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
9490 : : void *parsed_result,
9491 : : __rte_unused struct cmdline *cl,
9492 : : __rte_unused void *data)
9493 : : {
9494 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
9495 : : int ret = -ENOTSUP;
9496 : :
9497 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9498 : :
9499 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9500 : : return;
9501 : :
9502 : : #ifdef RTE_NET_IXGBE
9503 : : if (ret == -ENOTSUP)
9504 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
9505 : 0 : res->vf_id, is_on);
9506 : : #endif
9507 : : #ifdef RTE_NET_I40E
9508 : 0 : if (ret == -ENOTSUP)
9509 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
9510 : 0 : res->vf_id, is_on);
9511 : : #endif
9512 : : #ifdef RTE_NET_BNXT
9513 : 0 : if (ret == -ENOTSUP)
9514 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
9515 : 0 : res->vf_id, is_on);
9516 : : #endif
9517 : :
9518 : 0 : switch (ret) {
9519 : : case 0:
9520 : : break;
9521 : 0 : case -EINVAL:
9522 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
9523 : : break;
9524 : 0 : case -ENODEV:
9525 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9526 : : break;
9527 : 0 : case -ENOTSUP:
9528 : 0 : fprintf(stderr, "function not implemented\n");
9529 : : break;
9530 : 0 : default:
9531 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9532 : : }
9533 : : }
9534 : :
9535 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
9536 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
9537 : : .data = NULL,
9538 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
9539 : : .tokens = {
9540 : : (void *)&cmd_vf_vlan_anti_spoof_set,
9541 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
9542 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
9543 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
9544 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
9545 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
9546 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
9547 : : NULL,
9548 : : },
9549 : : };
9550 : :
9551 : : /* vf mac anti spoof configuration */
9552 : :
9553 : : /* Common result structure for vf mac anti spoof */
9554 : : struct cmd_vf_mac_anti_spoof_result {
9555 : : cmdline_fixed_string_t set;
9556 : : cmdline_fixed_string_t vf;
9557 : : cmdline_fixed_string_t mac;
9558 : : cmdline_fixed_string_t antispoof;
9559 : : portid_t port_id;
9560 : : uint32_t vf_id;
9561 : : cmdline_fixed_string_t on_off;
9562 : : };
9563 : :
9564 : : /* Common CLI fields for vf mac anti spoof enable disable */
9565 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
9566 : : TOKEN_STRING_INITIALIZER
9567 : : (struct cmd_vf_mac_anti_spoof_result,
9568 : : set, "set");
9569 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
9570 : : TOKEN_STRING_INITIALIZER
9571 : : (struct cmd_vf_mac_anti_spoof_result,
9572 : : vf, "vf");
9573 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
9574 : : TOKEN_STRING_INITIALIZER
9575 : : (struct cmd_vf_mac_anti_spoof_result,
9576 : : mac, "mac");
9577 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
9578 : : TOKEN_STRING_INITIALIZER
9579 : : (struct cmd_vf_mac_anti_spoof_result,
9580 : : antispoof, "antispoof");
9581 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
9582 : : TOKEN_NUM_INITIALIZER
9583 : : (struct cmd_vf_mac_anti_spoof_result,
9584 : : port_id, RTE_UINT16);
9585 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
9586 : : TOKEN_NUM_INITIALIZER
9587 : : (struct cmd_vf_mac_anti_spoof_result,
9588 : : vf_id, RTE_UINT32);
9589 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
9590 : : TOKEN_STRING_INITIALIZER
9591 : : (struct cmd_vf_mac_anti_spoof_result,
9592 : : on_off, "on#off");
9593 : :
9594 : : static void
9595 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
9596 : : void *parsed_result,
9597 : : __rte_unused struct cmdline *cl,
9598 : : __rte_unused void *data)
9599 : : {
9600 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
9601 : : int ret = -ENOTSUP;
9602 : :
9603 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9604 : :
9605 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9606 : : return;
9607 : :
9608 : : #ifdef RTE_NET_IXGBE
9609 : : if (ret == -ENOTSUP)
9610 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
9611 : 0 : res->vf_id, is_on);
9612 : : #endif
9613 : : #ifdef RTE_NET_I40E
9614 : 0 : if (ret == -ENOTSUP)
9615 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
9616 : 0 : res->vf_id, is_on);
9617 : : #endif
9618 : : #ifdef RTE_NET_BNXT
9619 : 0 : if (ret == -ENOTSUP)
9620 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
9621 : 0 : res->vf_id, is_on);
9622 : : #endif
9623 : :
9624 : 0 : switch (ret) {
9625 : : case 0:
9626 : : break;
9627 : 0 : case -EINVAL:
9628 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9629 : : res->vf_id, is_on);
9630 : : break;
9631 : 0 : case -ENODEV:
9632 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9633 : : break;
9634 : 0 : case -ENOTSUP:
9635 : 0 : fprintf(stderr, "function not implemented\n");
9636 : : break;
9637 : 0 : default:
9638 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9639 : : }
9640 : : }
9641 : :
9642 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
9643 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
9644 : : .data = NULL,
9645 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
9646 : : .tokens = {
9647 : : (void *)&cmd_vf_mac_anti_spoof_set,
9648 : : (void *)&cmd_vf_mac_anti_spoof_vf,
9649 : : (void *)&cmd_vf_mac_anti_spoof_mac,
9650 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
9651 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
9652 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
9653 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
9654 : : NULL,
9655 : : },
9656 : : };
9657 : :
9658 : : /* vf vlan strip queue configuration */
9659 : :
9660 : : /* Common result structure for vf mac anti spoof */
9661 : : struct cmd_vf_vlan_stripq_result {
9662 : : cmdline_fixed_string_t set;
9663 : : cmdline_fixed_string_t vf;
9664 : : cmdline_fixed_string_t vlan;
9665 : : cmdline_fixed_string_t stripq;
9666 : : portid_t port_id;
9667 : : uint16_t vf_id;
9668 : : cmdline_fixed_string_t on_off;
9669 : : };
9670 : :
9671 : : /* Common CLI fields for vf vlan strip enable disable */
9672 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
9673 : : TOKEN_STRING_INITIALIZER
9674 : : (struct cmd_vf_vlan_stripq_result,
9675 : : set, "set");
9676 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
9677 : : TOKEN_STRING_INITIALIZER
9678 : : (struct cmd_vf_vlan_stripq_result,
9679 : : vf, "vf");
9680 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
9681 : : TOKEN_STRING_INITIALIZER
9682 : : (struct cmd_vf_vlan_stripq_result,
9683 : : vlan, "vlan");
9684 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
9685 : : TOKEN_STRING_INITIALIZER
9686 : : (struct cmd_vf_vlan_stripq_result,
9687 : : stripq, "stripq");
9688 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
9689 : : TOKEN_NUM_INITIALIZER
9690 : : (struct cmd_vf_vlan_stripq_result,
9691 : : port_id, RTE_UINT16);
9692 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
9693 : : TOKEN_NUM_INITIALIZER
9694 : : (struct cmd_vf_vlan_stripq_result,
9695 : : vf_id, RTE_UINT16);
9696 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
9697 : : TOKEN_STRING_INITIALIZER
9698 : : (struct cmd_vf_vlan_stripq_result,
9699 : : on_off, "on#off");
9700 : :
9701 : : static void
9702 : 0 : cmd_set_vf_vlan_stripq_parsed(
9703 : : void *parsed_result,
9704 : : __rte_unused struct cmdline *cl,
9705 : : __rte_unused void *data)
9706 : : {
9707 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
9708 : : int ret = -ENOTSUP;
9709 : :
9710 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9711 : :
9712 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9713 : : return;
9714 : :
9715 : : #ifdef RTE_NET_IXGBE
9716 : : if (ret == -ENOTSUP)
9717 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
9718 : 0 : res->vf_id, is_on);
9719 : : #endif
9720 : : #ifdef RTE_NET_I40E
9721 : 0 : if (ret == -ENOTSUP)
9722 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
9723 : 0 : res->vf_id, is_on);
9724 : : #endif
9725 : : #ifdef RTE_NET_BNXT
9726 : 0 : if (ret == -ENOTSUP)
9727 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
9728 : 0 : res->vf_id, is_on);
9729 : : #endif
9730 : :
9731 : 0 : switch (ret) {
9732 : : case 0:
9733 : : break;
9734 : 0 : case -EINVAL:
9735 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9736 : 0 : res->vf_id, is_on);
9737 : : break;
9738 : 0 : case -ENODEV:
9739 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9740 : : break;
9741 : 0 : case -ENOTSUP:
9742 : 0 : fprintf(stderr, "function not implemented\n");
9743 : : break;
9744 : 0 : default:
9745 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9746 : : }
9747 : : }
9748 : :
9749 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
9750 : : .f = cmd_set_vf_vlan_stripq_parsed,
9751 : : .data = NULL,
9752 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
9753 : : .tokens = {
9754 : : (void *)&cmd_vf_vlan_stripq_set,
9755 : : (void *)&cmd_vf_vlan_stripq_vf,
9756 : : (void *)&cmd_vf_vlan_stripq_vlan,
9757 : : (void *)&cmd_vf_vlan_stripq_stripq,
9758 : : (void *)&cmd_vf_vlan_stripq_port_id,
9759 : : (void *)&cmd_vf_vlan_stripq_vf_id,
9760 : : (void *)&cmd_vf_vlan_stripq_on_off,
9761 : : NULL,
9762 : : },
9763 : : };
9764 : :
9765 : : /* vf vlan insert configuration */
9766 : :
9767 : : /* Common result structure for vf vlan insert */
9768 : : struct cmd_vf_vlan_insert_result {
9769 : : cmdline_fixed_string_t set;
9770 : : cmdline_fixed_string_t vf;
9771 : : cmdline_fixed_string_t vlan;
9772 : : cmdline_fixed_string_t insert;
9773 : : portid_t port_id;
9774 : : uint16_t vf_id;
9775 : : uint16_t vlan_id;
9776 : : };
9777 : :
9778 : : /* Common CLI fields for vf vlan insert enable disable */
9779 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
9780 : : TOKEN_STRING_INITIALIZER
9781 : : (struct cmd_vf_vlan_insert_result,
9782 : : set, "set");
9783 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
9784 : : TOKEN_STRING_INITIALIZER
9785 : : (struct cmd_vf_vlan_insert_result,
9786 : : vf, "vf");
9787 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
9788 : : TOKEN_STRING_INITIALIZER
9789 : : (struct cmd_vf_vlan_insert_result,
9790 : : vlan, "vlan");
9791 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
9792 : : TOKEN_STRING_INITIALIZER
9793 : : (struct cmd_vf_vlan_insert_result,
9794 : : insert, "insert");
9795 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
9796 : : TOKEN_NUM_INITIALIZER
9797 : : (struct cmd_vf_vlan_insert_result,
9798 : : port_id, RTE_UINT16);
9799 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
9800 : : TOKEN_NUM_INITIALIZER
9801 : : (struct cmd_vf_vlan_insert_result,
9802 : : vf_id, RTE_UINT16);
9803 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
9804 : : TOKEN_NUM_INITIALIZER
9805 : : (struct cmd_vf_vlan_insert_result,
9806 : : vlan_id, RTE_UINT16);
9807 : :
9808 : : static void
9809 : 0 : cmd_set_vf_vlan_insert_parsed(
9810 : : void *parsed_result,
9811 : : __rte_unused struct cmdline *cl,
9812 : : __rte_unused void *data)
9813 : : {
9814 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
9815 : : int ret = -ENOTSUP;
9816 : :
9817 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9818 : : return;
9819 : :
9820 : : #ifdef RTE_NET_IXGBE
9821 : : if (ret == -ENOTSUP)
9822 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
9823 : 0 : res->vlan_id);
9824 : : #endif
9825 : : #ifdef RTE_NET_I40E
9826 : 0 : if (ret == -ENOTSUP)
9827 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
9828 : 0 : res->vlan_id);
9829 : : #endif
9830 : : #ifdef RTE_NET_BNXT
9831 : 0 : if (ret == -ENOTSUP)
9832 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
9833 : 0 : res->vlan_id);
9834 : : #endif
9835 : :
9836 : 0 : switch (ret) {
9837 : : case 0:
9838 : : break;
9839 : 0 : case -EINVAL:
9840 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
9841 : 0 : res->vf_id, res->vlan_id);
9842 : : break;
9843 : 0 : case -ENODEV:
9844 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9845 : : break;
9846 : 0 : case -ENOTSUP:
9847 : 0 : fprintf(stderr, "function not implemented\n");
9848 : : break;
9849 : 0 : default:
9850 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9851 : : }
9852 : : }
9853 : :
9854 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
9855 : : .f = cmd_set_vf_vlan_insert_parsed,
9856 : : .data = NULL,
9857 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
9858 : : .tokens = {
9859 : : (void *)&cmd_vf_vlan_insert_set,
9860 : : (void *)&cmd_vf_vlan_insert_vf,
9861 : : (void *)&cmd_vf_vlan_insert_vlan,
9862 : : (void *)&cmd_vf_vlan_insert_insert,
9863 : : (void *)&cmd_vf_vlan_insert_port_id,
9864 : : (void *)&cmd_vf_vlan_insert_vf_id,
9865 : : (void *)&cmd_vf_vlan_insert_vlan_id,
9866 : : NULL,
9867 : : },
9868 : : };
9869 : :
9870 : : /* tx loopback configuration */
9871 : :
9872 : : /* Common result structure for tx loopback */
9873 : : struct cmd_tx_loopback_result {
9874 : : cmdline_fixed_string_t set;
9875 : : cmdline_fixed_string_t tx;
9876 : : cmdline_fixed_string_t loopback;
9877 : : portid_t port_id;
9878 : : cmdline_fixed_string_t on_off;
9879 : : };
9880 : :
9881 : : /* Common CLI fields for tx loopback enable disable */
9882 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
9883 : : TOKEN_STRING_INITIALIZER
9884 : : (struct cmd_tx_loopback_result,
9885 : : set, "set");
9886 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
9887 : : TOKEN_STRING_INITIALIZER
9888 : : (struct cmd_tx_loopback_result,
9889 : : tx, "tx");
9890 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
9891 : : TOKEN_STRING_INITIALIZER
9892 : : (struct cmd_tx_loopback_result,
9893 : : loopback, "loopback");
9894 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
9895 : : TOKEN_NUM_INITIALIZER
9896 : : (struct cmd_tx_loopback_result,
9897 : : port_id, RTE_UINT16);
9898 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
9899 : : TOKEN_STRING_INITIALIZER
9900 : : (struct cmd_tx_loopback_result,
9901 : : on_off, "on#off");
9902 : :
9903 : : static void
9904 : 0 : cmd_set_tx_loopback_parsed(
9905 : : void *parsed_result,
9906 : : __rte_unused struct cmdline *cl,
9907 : : __rte_unused void *data)
9908 : : {
9909 : : struct cmd_tx_loopback_result *res = parsed_result;
9910 : : int ret = -ENOTSUP;
9911 : :
9912 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9913 : :
9914 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9915 : : return;
9916 : :
9917 : : #ifdef RTE_NET_IXGBE
9918 : : if (ret == -ENOTSUP)
9919 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
9920 : : #endif
9921 : : #ifdef RTE_NET_I40E
9922 : 0 : if (ret == -ENOTSUP)
9923 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
9924 : : #endif
9925 : : #ifdef RTE_NET_BNXT
9926 : 0 : if (ret == -ENOTSUP)
9927 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
9928 : : #endif
9929 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
9930 : 0 : if (ret == -ENOTSUP)
9931 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
9932 : : #endif
9933 : :
9934 : 0 : switch (ret) {
9935 : : case 0:
9936 : : break;
9937 : 0 : case -EINVAL:
9938 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9939 : : break;
9940 : 0 : case -ENODEV:
9941 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9942 : : break;
9943 : 0 : case -ENOTSUP:
9944 : 0 : fprintf(stderr, "function not implemented\n");
9945 : : break;
9946 : 0 : default:
9947 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9948 : : }
9949 : : }
9950 : :
9951 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
9952 : : .f = cmd_set_tx_loopback_parsed,
9953 : : .data = NULL,
9954 : : .help_str = "set tx loopback <port_id> on|off",
9955 : : .tokens = {
9956 : : (void *)&cmd_tx_loopback_set,
9957 : : (void *)&cmd_tx_loopback_tx,
9958 : : (void *)&cmd_tx_loopback_loopback,
9959 : : (void *)&cmd_tx_loopback_port_id,
9960 : : (void *)&cmd_tx_loopback_on_off,
9961 : : NULL,
9962 : : },
9963 : : };
9964 : :
9965 : : /* all queues drop enable configuration */
9966 : :
9967 : : /* Common result structure for all queues drop enable */
9968 : : struct cmd_all_queues_drop_en_result {
9969 : : cmdline_fixed_string_t set;
9970 : : cmdline_fixed_string_t all;
9971 : : cmdline_fixed_string_t queues;
9972 : : cmdline_fixed_string_t drop;
9973 : : portid_t port_id;
9974 : : cmdline_fixed_string_t on_off;
9975 : : };
9976 : :
9977 : : /* Common CLI fields for tx loopback enable disable */
9978 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
9979 : : TOKEN_STRING_INITIALIZER
9980 : : (struct cmd_all_queues_drop_en_result,
9981 : : set, "set");
9982 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
9983 : : TOKEN_STRING_INITIALIZER
9984 : : (struct cmd_all_queues_drop_en_result,
9985 : : all, "all");
9986 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
9987 : : TOKEN_STRING_INITIALIZER
9988 : : (struct cmd_all_queues_drop_en_result,
9989 : : queues, "queues");
9990 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
9991 : : TOKEN_STRING_INITIALIZER
9992 : : (struct cmd_all_queues_drop_en_result,
9993 : : drop, "drop");
9994 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
9995 : : TOKEN_NUM_INITIALIZER
9996 : : (struct cmd_all_queues_drop_en_result,
9997 : : port_id, RTE_UINT16);
9998 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
9999 : : TOKEN_STRING_INITIALIZER
10000 : : (struct cmd_all_queues_drop_en_result,
10001 : : on_off, "on#off");
10002 : :
10003 : : static void
10004 : 0 : cmd_set_all_queues_drop_en_parsed(
10005 : : void *parsed_result,
10006 : : __rte_unused struct cmdline *cl,
10007 : : __rte_unused void *data)
10008 : : {
10009 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
10010 : : int ret = -ENOTSUP;
10011 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10012 : :
10013 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10014 : : return;
10015 : :
10016 : : #ifdef RTE_NET_IXGBE
10017 : : if (ret == -ENOTSUP)
10018 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
10019 : : #endif
10020 : : #ifdef RTE_NET_BNXT
10021 : 0 : if (ret == -ENOTSUP)
10022 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
10023 : : #endif
10024 : 0 : switch (ret) {
10025 : : case 0:
10026 : : break;
10027 : 0 : case -EINVAL:
10028 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10029 : : break;
10030 : 0 : case -ENODEV:
10031 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10032 : : break;
10033 : 0 : case -ENOTSUP:
10034 : 0 : fprintf(stderr, "function not implemented\n");
10035 : : break;
10036 : 0 : default:
10037 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10038 : : }
10039 : : }
10040 : :
10041 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
10042 : : .f = cmd_set_all_queues_drop_en_parsed,
10043 : : .data = NULL,
10044 : : .help_str = "set all queues drop <port_id> on|off",
10045 : : .tokens = {
10046 : : (void *)&cmd_all_queues_drop_en_set,
10047 : : (void *)&cmd_all_queues_drop_en_all,
10048 : : (void *)&cmd_all_queues_drop_en_queues,
10049 : : (void *)&cmd_all_queues_drop_en_drop,
10050 : : (void *)&cmd_all_queues_drop_en_port_id,
10051 : : (void *)&cmd_all_queues_drop_en_on_off,
10052 : : NULL,
10053 : : },
10054 : : };
10055 : :
10056 : : /* vf mac address configuration */
10057 : :
10058 : : /* Common result structure for vf mac address */
10059 : : struct cmd_set_vf_mac_addr_result {
10060 : : cmdline_fixed_string_t set;
10061 : : cmdline_fixed_string_t vf;
10062 : : cmdline_fixed_string_t mac;
10063 : : cmdline_fixed_string_t addr;
10064 : : portid_t port_id;
10065 : : uint16_t vf_id;
10066 : : struct rte_ether_addr mac_addr;
10067 : :
10068 : : };
10069 : :
10070 : : /* Common CLI fields for vf split drop enable disable */
10071 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
10072 : : TOKEN_STRING_INITIALIZER
10073 : : (struct cmd_set_vf_mac_addr_result,
10074 : : set, "set");
10075 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
10076 : : TOKEN_STRING_INITIALIZER
10077 : : (struct cmd_set_vf_mac_addr_result,
10078 : : vf, "vf");
10079 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
10080 : : TOKEN_STRING_INITIALIZER
10081 : : (struct cmd_set_vf_mac_addr_result,
10082 : : mac, "mac");
10083 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
10084 : : TOKEN_STRING_INITIALIZER
10085 : : (struct cmd_set_vf_mac_addr_result,
10086 : : addr, "addr");
10087 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
10088 : : TOKEN_NUM_INITIALIZER
10089 : : (struct cmd_set_vf_mac_addr_result,
10090 : : port_id, RTE_UINT16);
10091 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
10092 : : TOKEN_NUM_INITIALIZER
10093 : : (struct cmd_set_vf_mac_addr_result,
10094 : : vf_id, RTE_UINT16);
10095 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
10096 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
10097 : : mac_addr);
10098 : :
10099 : : static void
10100 : 0 : cmd_set_vf_mac_addr_parsed(
10101 : : void *parsed_result,
10102 : : __rte_unused struct cmdline *cl,
10103 : : __rte_unused void *data)
10104 : : {
10105 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
10106 : : int ret = -ENOTSUP;
10107 : :
10108 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10109 : : return;
10110 : :
10111 : : #ifdef RTE_NET_IXGBE
10112 : : if (ret == -ENOTSUP)
10113 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
10114 : : &res->mac_addr);
10115 : : #endif
10116 : : #ifdef RTE_NET_I40E
10117 : 0 : if (ret == -ENOTSUP)
10118 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
10119 : : &res->mac_addr);
10120 : : #endif
10121 : : #ifdef RTE_NET_BNXT
10122 : 0 : if (ret == -ENOTSUP)
10123 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
10124 : : &res->mac_addr);
10125 : : #endif
10126 : :
10127 : 0 : switch (ret) {
10128 : : case 0:
10129 : : break;
10130 : 0 : case -EINVAL:
10131 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
10132 : : break;
10133 : 0 : case -ENODEV:
10134 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10135 : : break;
10136 : 0 : case -ENOTSUP:
10137 : 0 : fprintf(stderr, "function not implemented\n");
10138 : : break;
10139 : 0 : default:
10140 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10141 : : }
10142 : : }
10143 : :
10144 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
10145 : : .f = cmd_set_vf_mac_addr_parsed,
10146 : : .data = NULL,
10147 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
10148 : : .tokens = {
10149 : : (void *)&cmd_set_vf_mac_addr_set,
10150 : : (void *)&cmd_set_vf_mac_addr_vf,
10151 : : (void *)&cmd_set_vf_mac_addr_mac,
10152 : : (void *)&cmd_set_vf_mac_addr_addr,
10153 : : (void *)&cmd_set_vf_mac_addr_port_id,
10154 : : (void *)&cmd_set_vf_mac_addr_vf_id,
10155 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
10156 : : NULL,
10157 : : },
10158 : : };
10159 : :
10160 : : /** Set VXLAN encapsulation details */
10161 : : struct cmd_set_vxlan_result {
10162 : : cmdline_fixed_string_t set;
10163 : : cmdline_fixed_string_t vxlan;
10164 : : cmdline_fixed_string_t pos_token;
10165 : : cmdline_fixed_string_t ip_version;
10166 : : uint32_t vlan_present:1;
10167 : : uint32_t vni;
10168 : : uint16_t udp_src;
10169 : : uint16_t udp_dst;
10170 : : cmdline_ipaddr_t ip_src;
10171 : : cmdline_ipaddr_t ip_dst;
10172 : : uint16_t tci;
10173 : : uint8_t tos;
10174 : : uint8_t ttl;
10175 : : struct rte_ether_addr eth_src;
10176 : : struct rte_ether_addr eth_dst;
10177 : : };
10178 : :
10179 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
10180 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
10181 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
10182 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
10183 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
10184 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10185 : : "vxlan-tos-ttl");
10186 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
10187 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10188 : : "vxlan-with-vlan");
10189 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
10190 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10191 : : "ip-version");
10192 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
10193 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
10194 : : "ipv4#ipv6");
10195 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
10196 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10197 : : "vni");
10198 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
10199 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
10200 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
10201 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10202 : : "udp-src");
10203 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
10204 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
10205 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
10206 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10207 : : "udp-dst");
10208 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
10209 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
10210 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
10211 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10212 : : "ip-tos");
10213 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
10214 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
10215 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
10216 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10217 : : "ip-ttl");
10218 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
10219 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
10220 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
10221 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10222 : : "ip-src");
10223 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
10224 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
10225 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
10226 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10227 : : "ip-dst");
10228 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
10229 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
10230 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
10231 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10232 : : "vlan-tci");
10233 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
10234 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
10235 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
10236 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10237 : : "eth-src");
10238 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
10239 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
10240 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
10241 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10242 : : "eth-dst");
10243 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
10244 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
10245 : :
10246 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
10247 : : __rte_unused struct cmdline *cl,
10248 : : __rte_unused void *data)
10249 : : {
10250 : : struct cmd_set_vxlan_result *res = parsed_result;
10251 : : union {
10252 : : uint32_t vxlan_id;
10253 : : uint8_t vni[4];
10254 : 0 : } id = {
10255 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
10256 : : };
10257 : :
10258 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
10259 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
10260 : 0 : vxlan_encap_conf.select_vlan = 0;
10261 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
10262 : 0 : vxlan_encap_conf.select_vlan = 1;
10263 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
10264 : 0 : vxlan_encap_conf.select_vlan = 0;
10265 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
10266 : : }
10267 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10268 : 0 : vxlan_encap_conf.select_ipv4 = 1;
10269 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10270 : 0 : vxlan_encap_conf.select_ipv4 = 0;
10271 : : else
10272 : 0 : return;
10273 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
10274 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10275 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10276 : 0 : vxlan_encap_conf.ip_tos = res->tos;
10277 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
10278 : 0 : if (vxlan_encap_conf.select_ipv4) {
10279 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
10280 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
10281 : : } else {
10282 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
10283 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
10284 : : }
10285 : 0 : if (vxlan_encap_conf.select_vlan)
10286 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10287 : 0 : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
10288 : : RTE_ETHER_ADDR_LEN);
10289 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10290 : : RTE_ETHER_ADDR_LEN);
10291 : : }
10292 : :
10293 : : static cmdline_parse_inst_t cmd_set_vxlan = {
10294 : : .f = cmd_set_vxlan_parsed,
10295 : : .data = NULL,
10296 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
10297 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
10298 : : " eth-src <eth-src> eth-dst <eth-dst>",
10299 : : .tokens = {
10300 : : (void *)&cmd_set_vxlan_set,
10301 : : (void *)&cmd_set_vxlan_vxlan,
10302 : : (void *)&cmd_set_vxlan_ip_version,
10303 : : (void *)&cmd_set_vxlan_ip_version_value,
10304 : : (void *)&cmd_set_vxlan_vni,
10305 : : (void *)&cmd_set_vxlan_vni_value,
10306 : : (void *)&cmd_set_vxlan_udp_src,
10307 : : (void *)&cmd_set_vxlan_udp_src_value,
10308 : : (void *)&cmd_set_vxlan_udp_dst,
10309 : : (void *)&cmd_set_vxlan_udp_dst_value,
10310 : : (void *)&cmd_set_vxlan_ip_src,
10311 : : (void *)&cmd_set_vxlan_ip_src_value,
10312 : : (void *)&cmd_set_vxlan_ip_dst,
10313 : : (void *)&cmd_set_vxlan_ip_dst_value,
10314 : : (void *)&cmd_set_vxlan_eth_src,
10315 : : (void *)&cmd_set_vxlan_eth_src_value,
10316 : : (void *)&cmd_set_vxlan_eth_dst,
10317 : : (void *)&cmd_set_vxlan_eth_dst_value,
10318 : : NULL,
10319 : : },
10320 : : };
10321 : :
10322 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
10323 : : .f = cmd_set_vxlan_parsed,
10324 : : .data = NULL,
10325 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
10326 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
10327 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10328 : : " eth-dst <eth-dst>",
10329 : : .tokens = {
10330 : : (void *)&cmd_set_vxlan_set,
10331 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
10332 : : (void *)&cmd_set_vxlan_ip_version,
10333 : : (void *)&cmd_set_vxlan_ip_version_value,
10334 : : (void *)&cmd_set_vxlan_vni,
10335 : : (void *)&cmd_set_vxlan_vni_value,
10336 : : (void *)&cmd_set_vxlan_udp_src,
10337 : : (void *)&cmd_set_vxlan_udp_src_value,
10338 : : (void *)&cmd_set_vxlan_udp_dst,
10339 : : (void *)&cmd_set_vxlan_udp_dst_value,
10340 : : (void *)&cmd_set_vxlan_ip_tos,
10341 : : (void *)&cmd_set_vxlan_ip_tos_value,
10342 : : (void *)&cmd_set_vxlan_ip_ttl,
10343 : : (void *)&cmd_set_vxlan_ip_ttl_value,
10344 : : (void *)&cmd_set_vxlan_ip_src,
10345 : : (void *)&cmd_set_vxlan_ip_src_value,
10346 : : (void *)&cmd_set_vxlan_ip_dst,
10347 : : (void *)&cmd_set_vxlan_ip_dst_value,
10348 : : (void *)&cmd_set_vxlan_eth_src,
10349 : : (void *)&cmd_set_vxlan_eth_src_value,
10350 : : (void *)&cmd_set_vxlan_eth_dst,
10351 : : (void *)&cmd_set_vxlan_eth_dst_value,
10352 : : NULL,
10353 : : },
10354 : : };
10355 : :
10356 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
10357 : : .f = cmd_set_vxlan_parsed,
10358 : : .data = NULL,
10359 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
10360 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
10361 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
10362 : : " <eth-dst>",
10363 : : .tokens = {
10364 : : (void *)&cmd_set_vxlan_set,
10365 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
10366 : : (void *)&cmd_set_vxlan_ip_version,
10367 : : (void *)&cmd_set_vxlan_ip_version_value,
10368 : : (void *)&cmd_set_vxlan_vni,
10369 : : (void *)&cmd_set_vxlan_vni_value,
10370 : : (void *)&cmd_set_vxlan_udp_src,
10371 : : (void *)&cmd_set_vxlan_udp_src_value,
10372 : : (void *)&cmd_set_vxlan_udp_dst,
10373 : : (void *)&cmd_set_vxlan_udp_dst_value,
10374 : : (void *)&cmd_set_vxlan_ip_src,
10375 : : (void *)&cmd_set_vxlan_ip_src_value,
10376 : : (void *)&cmd_set_vxlan_ip_dst,
10377 : : (void *)&cmd_set_vxlan_ip_dst_value,
10378 : : (void *)&cmd_set_vxlan_vlan,
10379 : : (void *)&cmd_set_vxlan_vlan_value,
10380 : : (void *)&cmd_set_vxlan_eth_src,
10381 : : (void *)&cmd_set_vxlan_eth_src_value,
10382 : : (void *)&cmd_set_vxlan_eth_dst,
10383 : : (void *)&cmd_set_vxlan_eth_dst_value,
10384 : : NULL,
10385 : : },
10386 : : };
10387 : :
10388 : : /** Set NVGRE encapsulation details */
10389 : : struct cmd_set_nvgre_result {
10390 : : cmdline_fixed_string_t set;
10391 : : cmdline_fixed_string_t nvgre;
10392 : : cmdline_fixed_string_t pos_token;
10393 : : cmdline_fixed_string_t ip_version;
10394 : : uint32_t tni;
10395 : : cmdline_ipaddr_t ip_src;
10396 : : cmdline_ipaddr_t ip_dst;
10397 : : uint16_t tci;
10398 : : struct rte_ether_addr eth_src;
10399 : : struct rte_ether_addr eth_dst;
10400 : : };
10401 : :
10402 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
10403 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
10404 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
10405 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
10406 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
10407 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
10408 : : "nvgre-with-vlan");
10409 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
10410 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10411 : : "ip-version");
10412 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
10413 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
10414 : : "ipv4#ipv6");
10415 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
10416 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10417 : : "tni");
10418 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
10419 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
10420 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
10421 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10422 : : "ip-src");
10423 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
10424 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
10425 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
10426 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10427 : : "ip-dst");
10428 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
10429 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
10430 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
10431 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10432 : : "vlan-tci");
10433 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
10434 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
10435 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
10436 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10437 : : "eth-src");
10438 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
10439 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
10440 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
10441 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10442 : : "eth-dst");
10443 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
10444 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
10445 : :
10446 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
10447 : : __rte_unused struct cmdline *cl,
10448 : : __rte_unused void *data)
10449 : : {
10450 : : struct cmd_set_nvgre_result *res = parsed_result;
10451 : : union {
10452 : : uint32_t nvgre_tni;
10453 : : uint8_t tni[4];
10454 : 0 : } id = {
10455 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
10456 : : };
10457 : :
10458 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
10459 : 0 : nvgre_encap_conf.select_vlan = 0;
10460 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
10461 : 0 : nvgre_encap_conf.select_vlan = 1;
10462 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10463 : 0 : nvgre_encap_conf.select_ipv4 = 1;
10464 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10465 : 0 : nvgre_encap_conf.select_ipv4 = 0;
10466 : : else
10467 : 0 : return;
10468 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
10469 : 0 : if (nvgre_encap_conf.select_ipv4) {
10470 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
10471 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
10472 : : } else {
10473 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
10474 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
10475 : : }
10476 : 0 : if (nvgre_encap_conf.select_vlan)
10477 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10478 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
10479 : : RTE_ETHER_ADDR_LEN);
10480 : 0 : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10481 : : RTE_ETHER_ADDR_LEN);
10482 : : }
10483 : :
10484 : : static cmdline_parse_inst_t cmd_set_nvgre = {
10485 : : .f = cmd_set_nvgre_parsed,
10486 : : .data = NULL,
10487 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
10488 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10489 : : " eth-dst <eth-dst>",
10490 : : .tokens = {
10491 : : (void *)&cmd_set_nvgre_set,
10492 : : (void *)&cmd_set_nvgre_nvgre,
10493 : : (void *)&cmd_set_nvgre_ip_version,
10494 : : (void *)&cmd_set_nvgre_ip_version_value,
10495 : : (void *)&cmd_set_nvgre_tni,
10496 : : (void *)&cmd_set_nvgre_tni_value,
10497 : : (void *)&cmd_set_nvgre_ip_src,
10498 : : (void *)&cmd_set_nvgre_ip_src_value,
10499 : : (void *)&cmd_set_nvgre_ip_dst,
10500 : : (void *)&cmd_set_nvgre_ip_dst_value,
10501 : : (void *)&cmd_set_nvgre_eth_src,
10502 : : (void *)&cmd_set_nvgre_eth_src_value,
10503 : : (void *)&cmd_set_nvgre_eth_dst,
10504 : : (void *)&cmd_set_nvgre_eth_dst_value,
10505 : : NULL,
10506 : : },
10507 : : };
10508 : :
10509 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
10510 : : .f = cmd_set_nvgre_parsed,
10511 : : .data = NULL,
10512 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
10513 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10514 : : " eth-src <eth-src> eth-dst <eth-dst>",
10515 : : .tokens = {
10516 : : (void *)&cmd_set_nvgre_set,
10517 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
10518 : : (void *)&cmd_set_nvgre_ip_version,
10519 : : (void *)&cmd_set_nvgre_ip_version_value,
10520 : : (void *)&cmd_set_nvgre_tni,
10521 : : (void *)&cmd_set_nvgre_tni_value,
10522 : : (void *)&cmd_set_nvgre_ip_src,
10523 : : (void *)&cmd_set_nvgre_ip_src_value,
10524 : : (void *)&cmd_set_nvgre_ip_dst,
10525 : : (void *)&cmd_set_nvgre_ip_dst_value,
10526 : : (void *)&cmd_set_nvgre_vlan,
10527 : : (void *)&cmd_set_nvgre_vlan_value,
10528 : : (void *)&cmd_set_nvgre_eth_src,
10529 : : (void *)&cmd_set_nvgre_eth_src_value,
10530 : : (void *)&cmd_set_nvgre_eth_dst,
10531 : : (void *)&cmd_set_nvgre_eth_dst_value,
10532 : : NULL,
10533 : : },
10534 : : };
10535 : :
10536 : : /** Set L2 encapsulation details */
10537 : : struct cmd_set_l2_encap_result {
10538 : : cmdline_fixed_string_t set;
10539 : : cmdline_fixed_string_t l2_encap;
10540 : : cmdline_fixed_string_t pos_token;
10541 : : cmdline_fixed_string_t ip_version;
10542 : : uint32_t vlan_present:1;
10543 : : uint16_t tci;
10544 : : struct rte_ether_addr eth_src;
10545 : : struct rte_ether_addr eth_dst;
10546 : : };
10547 : :
10548 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
10549 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
10550 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
10551 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
10552 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
10553 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
10554 : : "l2_encap-with-vlan");
10555 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
10556 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10557 : : "ip-version");
10558 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
10559 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
10560 : : "ipv4#ipv6");
10561 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
10562 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10563 : : "vlan-tci");
10564 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
10565 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
10566 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
10567 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10568 : : "eth-src");
10569 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
10570 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
10571 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
10572 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10573 : : "eth-dst");
10574 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
10575 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
10576 : :
10577 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
10578 : : __rte_unused struct cmdline *cl,
10579 : : __rte_unused void *data)
10580 : : {
10581 : : struct cmd_set_l2_encap_result *res = parsed_result;
10582 : :
10583 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
10584 : 0 : l2_encap_conf.select_vlan = 0;
10585 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
10586 : 0 : l2_encap_conf.select_vlan = 1;
10587 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10588 : 0 : l2_encap_conf.select_ipv4 = 1;
10589 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10590 : 0 : l2_encap_conf.select_ipv4 = 0;
10591 : : else
10592 : : return;
10593 : 0 : if (l2_encap_conf.select_vlan)
10594 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10595 : 0 : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
10596 : : RTE_ETHER_ADDR_LEN);
10597 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10598 : : RTE_ETHER_ADDR_LEN);
10599 : : }
10600 : :
10601 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
10602 : : .f = cmd_set_l2_encap_parsed,
10603 : : .data = NULL,
10604 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
10605 : : " eth-src <eth-src> eth-dst <eth-dst>",
10606 : : .tokens = {
10607 : : (void *)&cmd_set_l2_encap_set,
10608 : : (void *)&cmd_set_l2_encap_l2_encap,
10609 : : (void *)&cmd_set_l2_encap_ip_version,
10610 : : (void *)&cmd_set_l2_encap_ip_version_value,
10611 : : (void *)&cmd_set_l2_encap_eth_src,
10612 : : (void *)&cmd_set_l2_encap_eth_src_value,
10613 : : (void *)&cmd_set_l2_encap_eth_dst,
10614 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10615 : : NULL,
10616 : : },
10617 : : };
10618 : :
10619 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
10620 : : .f = cmd_set_l2_encap_parsed,
10621 : : .data = NULL,
10622 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
10623 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10624 : : .tokens = {
10625 : : (void *)&cmd_set_l2_encap_set,
10626 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
10627 : : (void *)&cmd_set_l2_encap_ip_version,
10628 : : (void *)&cmd_set_l2_encap_ip_version_value,
10629 : : (void *)&cmd_set_l2_encap_vlan,
10630 : : (void *)&cmd_set_l2_encap_vlan_value,
10631 : : (void *)&cmd_set_l2_encap_eth_src,
10632 : : (void *)&cmd_set_l2_encap_eth_src_value,
10633 : : (void *)&cmd_set_l2_encap_eth_dst,
10634 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10635 : : NULL,
10636 : : },
10637 : : };
10638 : :
10639 : : /** Set L2 decapsulation details */
10640 : : struct cmd_set_l2_decap_result {
10641 : : cmdline_fixed_string_t set;
10642 : : cmdline_fixed_string_t l2_decap;
10643 : : cmdline_fixed_string_t pos_token;
10644 : : uint32_t vlan_present:1;
10645 : : };
10646 : :
10647 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
10648 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
10649 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
10650 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10651 : : "l2_decap");
10652 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
10653 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10654 : : "l2_decap-with-vlan");
10655 : :
10656 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
10657 : : __rte_unused struct cmdline *cl,
10658 : : __rte_unused void *data)
10659 : : {
10660 : : struct cmd_set_l2_decap_result *res = parsed_result;
10661 : :
10662 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
10663 : 0 : l2_decap_conf.select_vlan = 0;
10664 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
10665 : 0 : l2_decap_conf.select_vlan = 1;
10666 : 0 : }
10667 : :
10668 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
10669 : : .f = cmd_set_l2_decap_parsed,
10670 : : .data = NULL,
10671 : : .help_str = "set l2_decap",
10672 : : .tokens = {
10673 : : (void *)&cmd_set_l2_decap_set,
10674 : : (void *)&cmd_set_l2_decap_l2_decap,
10675 : : NULL,
10676 : : },
10677 : : };
10678 : :
10679 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
10680 : : .f = cmd_set_l2_decap_parsed,
10681 : : .data = NULL,
10682 : : .help_str = "set l2_decap-with-vlan",
10683 : : .tokens = {
10684 : : (void *)&cmd_set_l2_decap_set,
10685 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
10686 : : NULL,
10687 : : },
10688 : : };
10689 : :
10690 : : /** Set MPLSoGRE encapsulation details */
10691 : : struct cmd_set_mplsogre_encap_result {
10692 : : cmdline_fixed_string_t set;
10693 : : cmdline_fixed_string_t mplsogre;
10694 : : cmdline_fixed_string_t pos_token;
10695 : : cmdline_fixed_string_t ip_version;
10696 : : uint32_t vlan_present:1;
10697 : : uint32_t label;
10698 : : cmdline_ipaddr_t ip_src;
10699 : : cmdline_ipaddr_t ip_dst;
10700 : : uint16_t tci;
10701 : : struct rte_ether_addr eth_src;
10702 : : struct rte_ether_addr eth_dst;
10703 : : };
10704 : :
10705 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
10706 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
10707 : : "set");
10708 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
10709 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
10710 : : "mplsogre_encap");
10711 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
10712 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10713 : : mplsogre, "mplsogre_encap-with-vlan");
10714 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
10715 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10716 : : pos_token, "ip-version");
10717 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
10718 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10719 : : ip_version, "ipv4#ipv6");
10720 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
10721 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10722 : : pos_token, "label");
10723 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
10724 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
10725 : : RTE_UINT32);
10726 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
10727 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10728 : : pos_token, "ip-src");
10729 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
10730 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
10731 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
10732 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10733 : : pos_token, "ip-dst");
10734 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
10735 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
10736 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
10737 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10738 : : pos_token, "vlan-tci");
10739 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
10740 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
10741 : : RTE_UINT16);
10742 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
10743 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10744 : : pos_token, "eth-src");
10745 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
10746 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10747 : : eth_src);
10748 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
10749 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10750 : : pos_token, "eth-dst");
10751 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
10752 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10753 : : eth_dst);
10754 : :
10755 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
10756 : : __rte_unused struct cmdline *cl,
10757 : : __rte_unused void *data)
10758 : : {
10759 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
10760 : : union {
10761 : : uint32_t mplsogre_label;
10762 : : uint8_t label[4];
10763 : 0 : } id = {
10764 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
10765 : : };
10766 : :
10767 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
10768 : 0 : mplsogre_encap_conf.select_vlan = 0;
10769 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
10770 : 0 : mplsogre_encap_conf.select_vlan = 1;
10771 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10772 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
10773 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10774 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
10775 : : else
10776 : 0 : return;
10777 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
10778 : 0 : if (mplsogre_encap_conf.select_ipv4) {
10779 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
10780 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
10781 : : } else {
10782 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
10783 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
10784 : : }
10785 : 0 : if (mplsogre_encap_conf.select_vlan)
10786 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10787 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
10788 : : RTE_ETHER_ADDR_LEN);
10789 : 0 : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10790 : : RTE_ETHER_ADDR_LEN);
10791 : : }
10792 : :
10793 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
10794 : : .f = cmd_set_mplsogre_encap_parsed,
10795 : : .data = NULL,
10796 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
10797 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10798 : : " eth-dst <eth-dst>",
10799 : : .tokens = {
10800 : : (void *)&cmd_set_mplsogre_encap_set,
10801 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
10802 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10803 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10804 : : (void *)&cmd_set_mplsogre_encap_label,
10805 : : (void *)&cmd_set_mplsogre_encap_label_value,
10806 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10807 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10808 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10809 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10810 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10811 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10812 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10813 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10814 : : NULL,
10815 : : },
10816 : : };
10817 : :
10818 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
10819 : : .f = cmd_set_mplsogre_encap_parsed,
10820 : : .data = NULL,
10821 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
10822 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
10823 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10824 : : .tokens = {
10825 : : (void *)&cmd_set_mplsogre_encap_set,
10826 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
10827 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10828 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10829 : : (void *)&cmd_set_mplsogre_encap_label,
10830 : : (void *)&cmd_set_mplsogre_encap_label_value,
10831 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10832 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10833 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10834 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10835 : : (void *)&cmd_set_mplsogre_encap_vlan,
10836 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
10837 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10838 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10839 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10840 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10841 : : NULL,
10842 : : },
10843 : : };
10844 : :
10845 : : /** Set MPLSoGRE decapsulation details */
10846 : : struct cmd_set_mplsogre_decap_result {
10847 : : cmdline_fixed_string_t set;
10848 : : cmdline_fixed_string_t mplsogre;
10849 : : cmdline_fixed_string_t pos_token;
10850 : : cmdline_fixed_string_t ip_version;
10851 : : uint32_t vlan_present:1;
10852 : : };
10853 : :
10854 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
10855 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
10856 : : "set");
10857 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
10858 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
10859 : : "mplsogre_decap");
10860 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
10861 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10862 : : mplsogre, "mplsogre_decap-with-vlan");
10863 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
10864 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10865 : : pos_token, "ip-version");
10866 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
10867 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10868 : : ip_version, "ipv4#ipv6");
10869 : :
10870 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
10871 : : __rte_unused struct cmdline *cl,
10872 : : __rte_unused void *data)
10873 : : {
10874 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
10875 : :
10876 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
10877 : 0 : mplsogre_decap_conf.select_vlan = 0;
10878 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
10879 : 0 : mplsogre_decap_conf.select_vlan = 1;
10880 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10881 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
10882 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10883 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
10884 : 0 : }
10885 : :
10886 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
10887 : : .f = cmd_set_mplsogre_decap_parsed,
10888 : : .data = NULL,
10889 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
10890 : : .tokens = {
10891 : : (void *)&cmd_set_mplsogre_decap_set,
10892 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
10893 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10894 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10895 : : NULL,
10896 : : },
10897 : : };
10898 : :
10899 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
10900 : : .f = cmd_set_mplsogre_decap_parsed,
10901 : : .data = NULL,
10902 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
10903 : : .tokens = {
10904 : : (void *)&cmd_set_mplsogre_decap_set,
10905 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
10906 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10907 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10908 : : NULL,
10909 : : },
10910 : : };
10911 : :
10912 : : /** Set MPLSoUDP encapsulation details */
10913 : : struct cmd_set_mplsoudp_encap_result {
10914 : : cmdline_fixed_string_t set;
10915 : : cmdline_fixed_string_t mplsoudp;
10916 : : cmdline_fixed_string_t pos_token;
10917 : : cmdline_fixed_string_t ip_version;
10918 : : uint32_t vlan_present:1;
10919 : : uint32_t label;
10920 : : uint16_t udp_src;
10921 : : uint16_t udp_dst;
10922 : : cmdline_ipaddr_t ip_src;
10923 : : cmdline_ipaddr_t ip_dst;
10924 : : uint16_t tci;
10925 : : struct rte_ether_addr eth_src;
10926 : : struct rte_ether_addr eth_dst;
10927 : : };
10928 : :
10929 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
10930 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
10931 : : "set");
10932 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
10933 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
10934 : : "mplsoudp_encap");
10935 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
10936 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10937 : : mplsoudp, "mplsoudp_encap-with-vlan");
10938 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
10939 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10940 : : pos_token, "ip-version");
10941 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
10942 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10943 : : ip_version, "ipv4#ipv6");
10944 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
10945 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10946 : : pos_token, "label");
10947 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
10948 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
10949 : : RTE_UINT32);
10950 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
10951 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10952 : : pos_token, "udp-src");
10953 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
10954 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
10955 : : RTE_UINT16);
10956 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
10957 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10958 : : pos_token, "udp-dst");
10959 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
10960 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
10961 : : RTE_UINT16);
10962 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
10963 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10964 : : pos_token, "ip-src");
10965 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
10966 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
10967 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
10968 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10969 : : pos_token, "ip-dst");
10970 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
10971 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
10972 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
10973 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10974 : : pos_token, "vlan-tci");
10975 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
10976 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
10977 : : RTE_UINT16);
10978 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
10979 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10980 : : pos_token, "eth-src");
10981 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
10982 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10983 : : eth_src);
10984 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
10985 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10986 : : pos_token, "eth-dst");
10987 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
10988 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10989 : : eth_dst);
10990 : :
10991 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
10992 : : __rte_unused struct cmdline *cl,
10993 : : __rte_unused void *data)
10994 : : {
10995 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
10996 : : union {
10997 : : uint32_t mplsoudp_label;
10998 : : uint8_t label[4];
10999 : 0 : } id = {
11000 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
11001 : : };
11002 : :
11003 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
11004 : 0 : mplsoudp_encap_conf.select_vlan = 0;
11005 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
11006 : 0 : mplsoudp_encap_conf.select_vlan = 1;
11007 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11008 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
11009 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11010 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
11011 : : else
11012 : 0 : return;
11013 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
11014 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
11015 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
11016 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
11017 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
11018 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
11019 : : } else {
11020 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
11021 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
11022 : : }
11023 : 0 : if (mplsoudp_encap_conf.select_vlan)
11024 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11025 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
11026 : : RTE_ETHER_ADDR_LEN);
11027 : 0 : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11028 : : RTE_ETHER_ADDR_LEN);
11029 : : }
11030 : :
11031 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
11032 : : .f = cmd_set_mplsoudp_encap_parsed,
11033 : : .data = NULL,
11034 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
11035 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
11036 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
11037 : : .tokens = {
11038 : : (void *)&cmd_set_mplsoudp_encap_set,
11039 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
11040 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11041 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11042 : : (void *)&cmd_set_mplsoudp_encap_label,
11043 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11044 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11045 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11046 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11047 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11048 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11049 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11050 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11051 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11052 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11053 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11054 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11055 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11056 : : NULL,
11057 : : },
11058 : : };
11059 : :
11060 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
11061 : : .f = cmd_set_mplsoudp_encap_parsed,
11062 : : .data = NULL,
11063 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
11064 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
11065 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
11066 : : " eth-src <eth-src> eth-dst <eth-dst>",
11067 : : .tokens = {
11068 : : (void *)&cmd_set_mplsoudp_encap_set,
11069 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
11070 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11071 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11072 : : (void *)&cmd_set_mplsoudp_encap_label,
11073 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11074 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11075 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11076 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11077 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11078 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11079 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11080 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11081 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11082 : : (void *)&cmd_set_mplsoudp_encap_vlan,
11083 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
11084 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11085 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11086 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11087 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11088 : : NULL,
11089 : : },
11090 : : };
11091 : :
11092 : : /** Set MPLSoUDP decapsulation details */
11093 : : struct cmd_set_mplsoudp_decap_result {
11094 : : cmdline_fixed_string_t set;
11095 : : cmdline_fixed_string_t mplsoudp;
11096 : : cmdline_fixed_string_t pos_token;
11097 : : cmdline_fixed_string_t ip_version;
11098 : : uint32_t vlan_present:1;
11099 : : };
11100 : :
11101 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
11102 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
11103 : : "set");
11104 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
11105 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
11106 : : "mplsoudp_decap");
11107 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
11108 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11109 : : mplsoudp, "mplsoudp_decap-with-vlan");
11110 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
11111 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11112 : : pos_token, "ip-version");
11113 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
11114 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11115 : : ip_version, "ipv4#ipv6");
11116 : :
11117 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
11118 : : __rte_unused struct cmdline *cl,
11119 : : __rte_unused void *data)
11120 : : {
11121 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
11122 : :
11123 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
11124 : 0 : mplsoudp_decap_conf.select_vlan = 0;
11125 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
11126 : 0 : mplsoudp_decap_conf.select_vlan = 1;
11127 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11128 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
11129 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11130 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
11131 : 0 : }
11132 : :
11133 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
11134 : : .f = cmd_set_mplsoudp_decap_parsed,
11135 : : .data = NULL,
11136 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
11137 : : .tokens = {
11138 : : (void *)&cmd_set_mplsoudp_decap_set,
11139 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
11140 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11141 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11142 : : NULL,
11143 : : },
11144 : : };
11145 : :
11146 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
11147 : : .f = cmd_set_mplsoudp_decap_parsed,
11148 : : .data = NULL,
11149 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
11150 : : .tokens = {
11151 : : (void *)&cmd_set_mplsoudp_decap_set,
11152 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
11153 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11154 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11155 : : NULL,
11156 : : },
11157 : : };
11158 : :
11159 : : /** Set connection tracking object common details */
11160 : : struct cmd_set_conntrack_common_result {
11161 : : cmdline_fixed_string_t set;
11162 : : cmdline_fixed_string_t conntrack;
11163 : : cmdline_fixed_string_t common;
11164 : : cmdline_fixed_string_t peer;
11165 : : cmdline_fixed_string_t is_orig;
11166 : : cmdline_fixed_string_t enable;
11167 : : cmdline_fixed_string_t live;
11168 : : cmdline_fixed_string_t sack;
11169 : : cmdline_fixed_string_t cack;
11170 : : cmdline_fixed_string_t last_dir;
11171 : : cmdline_fixed_string_t liberal;
11172 : : cmdline_fixed_string_t state;
11173 : : cmdline_fixed_string_t max_ack_win;
11174 : : cmdline_fixed_string_t retrans;
11175 : : cmdline_fixed_string_t last_win;
11176 : : cmdline_fixed_string_t last_seq;
11177 : : cmdline_fixed_string_t last_ack;
11178 : : cmdline_fixed_string_t last_end;
11179 : : cmdline_fixed_string_t last_index;
11180 : : uint8_t stat;
11181 : : uint8_t factor;
11182 : : uint16_t peer_port;
11183 : : uint32_t is_original;
11184 : : uint32_t en;
11185 : : uint32_t is_live;
11186 : : uint32_t s_ack;
11187 : : uint32_t c_ack;
11188 : : uint32_t ld;
11189 : : uint32_t lb;
11190 : : uint8_t re_num;
11191 : : uint8_t li;
11192 : : uint16_t lw;
11193 : : uint32_t ls;
11194 : : uint32_t la;
11195 : : uint32_t le;
11196 : : };
11197 : :
11198 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
11199 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11200 : : set, "set");
11201 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
11202 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11203 : : conntrack, "conntrack");
11204 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
11205 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11206 : : common, "com");
11207 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
11208 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11209 : : peer, "peer");
11210 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
11211 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11212 : : peer_port, RTE_UINT16);
11213 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
11214 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11215 : : is_orig, "is_orig");
11216 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
11217 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11218 : : is_original, RTE_UINT32);
11219 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
11220 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11221 : : enable, "enable");
11222 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
11223 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11224 : : en, RTE_UINT32);
11225 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
11226 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11227 : : live, "live");
11228 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
11229 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11230 : : is_live, RTE_UINT32);
11231 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
11232 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11233 : : sack, "sack");
11234 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
11235 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11236 : : s_ack, RTE_UINT32);
11237 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
11238 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11239 : : cack, "cack");
11240 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
11241 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11242 : : c_ack, RTE_UINT32);
11243 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
11244 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11245 : : last_dir, "last_dir");
11246 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
11247 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11248 : : ld, RTE_UINT32);
11249 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
11250 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11251 : : liberal, "liberal");
11252 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
11253 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11254 : : lb, RTE_UINT32);
11255 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
11256 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11257 : : state, "state");
11258 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
11259 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11260 : : stat, RTE_UINT8);
11261 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
11262 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11263 : : max_ack_win, "max_ack_win");
11264 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
11265 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11266 : : factor, RTE_UINT8);
11267 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
11268 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11269 : : retrans, "r_lim");
11270 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
11271 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11272 : : re_num, RTE_UINT8);
11273 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
11274 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11275 : : last_win, "last_win");
11276 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
11277 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11278 : : lw, RTE_UINT16);
11279 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
11280 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11281 : : last_seq, "last_seq");
11282 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
11283 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11284 : : ls, RTE_UINT32);
11285 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
11286 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11287 : : last_ack, "last_ack");
11288 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
11289 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11290 : : la, RTE_UINT32);
11291 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
11292 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11293 : : last_end, "last_end");
11294 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
11295 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11296 : : le, RTE_UINT32);
11297 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
11298 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11299 : : last_index, "last_index");
11300 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
11301 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11302 : : li, RTE_UINT8);
11303 : :
11304 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
11305 : : __rte_unused struct cmdline *cl,
11306 : : __rte_unused void *data)
11307 : : {
11308 : : struct cmd_set_conntrack_common_result *res = parsed_result;
11309 : :
11310 : : /* No need to swap to big endian. */
11311 : 0 : conntrack_context.peer_port = res->peer_port;
11312 : 0 : conntrack_context.is_original_dir = res->is_original;
11313 : 0 : conntrack_context.enable = res->en;
11314 : 0 : conntrack_context.live_connection = res->is_live;
11315 : 0 : conntrack_context.selective_ack = res->s_ack;
11316 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
11317 : 0 : conntrack_context.last_direction = res->ld;
11318 : 0 : conntrack_context.liberal_mode = res->lb;
11319 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
11320 : 0 : conntrack_context.max_ack_window = res->factor;
11321 : 0 : conntrack_context.retransmission_limit = res->re_num;
11322 : 0 : conntrack_context.last_window = res->lw;
11323 : 0 : conntrack_context.last_index =
11324 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
11325 : 0 : conntrack_context.last_seq = res->ls;
11326 : 0 : conntrack_context.last_ack = res->la;
11327 : 0 : conntrack_context.last_end = res->le;
11328 : 0 : }
11329 : :
11330 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
11331 : : .f = cmd_set_conntrack_common_parsed,
11332 : : .data = NULL,
11333 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
11334 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
11335 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
11336 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
11337 : : " last_index <flag>",
11338 : : .tokens = {
11339 : : (void *)&cmd_set_conntrack_set,
11340 : : (void *)&cmd_set_conntrack_conntrack,
11341 : : (void *)&cmd_set_conntrack_common_com,
11342 : : (void *)&cmd_set_conntrack_common_peer,
11343 : : (void *)&cmd_set_conntrack_common_peer_value,
11344 : : (void *)&cmd_set_conntrack_common_is_orig,
11345 : : (void *)&cmd_set_conntrack_common_is_orig_value,
11346 : : (void *)&cmd_set_conntrack_common_enable,
11347 : : (void *)&cmd_set_conntrack_common_enable_value,
11348 : : (void *)&cmd_set_conntrack_common_live,
11349 : : (void *)&cmd_set_conntrack_common_live_value,
11350 : : (void *)&cmd_set_conntrack_common_sack,
11351 : : (void *)&cmd_set_conntrack_common_sack_value,
11352 : : (void *)&cmd_set_conntrack_common_cack,
11353 : : (void *)&cmd_set_conntrack_common_cack_value,
11354 : : (void *)&cmd_set_conntrack_common_last_dir,
11355 : : (void *)&cmd_set_conntrack_common_last_dir_value,
11356 : : (void *)&cmd_set_conntrack_common_liberal,
11357 : : (void *)&cmd_set_conntrack_common_liberal_value,
11358 : : (void *)&cmd_set_conntrack_common_state,
11359 : : (void *)&cmd_set_conntrack_common_state_value,
11360 : : (void *)&cmd_set_conntrack_common_max_ackwin,
11361 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
11362 : : (void *)&cmd_set_conntrack_common_retrans,
11363 : : (void *)&cmd_set_conntrack_common_retrans_value,
11364 : : (void *)&cmd_set_conntrack_common_last_win,
11365 : : (void *)&cmd_set_conntrack_common_last_win_value,
11366 : : (void *)&cmd_set_conntrack_common_last_seq,
11367 : : (void *)&cmd_set_conntrack_common_last_seq_value,
11368 : : (void *)&cmd_set_conntrack_common_last_ack,
11369 : : (void *)&cmd_set_conntrack_common_last_ack_value,
11370 : : (void *)&cmd_set_conntrack_common_last_end,
11371 : : (void *)&cmd_set_conntrack_common_last_end_value,
11372 : : (void *)&cmd_set_conntrack_common_last_index,
11373 : : (void *)&cmd_set_conntrack_common_last_index_value,
11374 : : NULL,
11375 : : },
11376 : : };
11377 : :
11378 : : /** Set connection tracking object both directions' details */
11379 : : struct cmd_set_conntrack_dir_result {
11380 : : cmdline_fixed_string_t set;
11381 : : cmdline_fixed_string_t conntrack;
11382 : : cmdline_fixed_string_t dir;
11383 : : cmdline_fixed_string_t scale;
11384 : : cmdline_fixed_string_t fin;
11385 : : cmdline_fixed_string_t ack_seen;
11386 : : cmdline_fixed_string_t unack;
11387 : : cmdline_fixed_string_t sent_end;
11388 : : cmdline_fixed_string_t reply_end;
11389 : : cmdline_fixed_string_t max_win;
11390 : : cmdline_fixed_string_t max_ack;
11391 : : uint32_t factor;
11392 : : uint32_t f;
11393 : : uint32_t as;
11394 : : uint32_t un;
11395 : : uint32_t se;
11396 : : uint32_t re;
11397 : : uint32_t mw;
11398 : : uint32_t ma;
11399 : : };
11400 : :
11401 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
11402 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11403 : : dir, "orig#rply");
11404 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
11405 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11406 : : scale, "scale");
11407 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
11408 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11409 : : factor, RTE_UINT32);
11410 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
11411 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11412 : : fin, "fin");
11413 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
11414 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11415 : : f, RTE_UINT32);
11416 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
11417 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11418 : : ack_seen, "acked");
11419 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
11420 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11421 : : as, RTE_UINT32);
11422 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
11423 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11424 : : unack, "unack_data");
11425 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
11426 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11427 : : un, RTE_UINT32);
11428 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
11429 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11430 : : sent_end, "sent_end");
11431 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
11432 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11433 : : se, RTE_UINT32);
11434 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
11435 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11436 : : reply_end, "reply_end");
11437 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
11438 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11439 : : re, RTE_UINT32);
11440 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
11441 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11442 : : max_win, "max_win");
11443 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
11444 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11445 : : mw, RTE_UINT32);
11446 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
11447 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11448 : : max_ack, "max_ack");
11449 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
11450 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11451 : : ma, RTE_UINT32);
11452 : :
11453 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
11454 : : __rte_unused struct cmdline *cl,
11455 : : __rte_unused void *data)
11456 : : {
11457 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
11458 : : struct rte_flow_tcp_dir_param *dir = NULL;
11459 : :
11460 : 0 : if (strcmp(res->dir, "orig") == 0)
11461 : : dir = &conntrack_context.original_dir;
11462 : 0 : else if (strcmp(res->dir, "rply") == 0)
11463 : : dir = &conntrack_context.reply_dir;
11464 : : else
11465 : : return;
11466 : 0 : dir->scale = res->factor;
11467 : 0 : dir->close_initiated = res->f;
11468 : 0 : dir->last_ack_seen = res->as;
11469 : 0 : dir->data_unacked = res->un;
11470 : 0 : dir->sent_end = res->se;
11471 : 0 : dir->reply_end = res->re;
11472 : 0 : dir->max_ack = res->ma;
11473 : 0 : dir->max_win = res->mw;
11474 : : }
11475 : :
11476 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
11477 : : .f = cmd_set_conntrack_dir_parsed,
11478 : : .data = NULL,
11479 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
11480 : : " acked <seen> unack_data <unack> sent_end <sent>"
11481 : : " reply_end <reply> max_win <win> max_ack <ack>",
11482 : : .tokens = {
11483 : : (void *)&cmd_set_conntrack_set,
11484 : : (void *)&cmd_set_conntrack_conntrack,
11485 : : (void *)&cmd_set_conntrack_dir_dir,
11486 : : (void *)&cmd_set_conntrack_dir_scale,
11487 : : (void *)&cmd_set_conntrack_dir_scale_value,
11488 : : (void *)&cmd_set_conntrack_dir_fin,
11489 : : (void *)&cmd_set_conntrack_dir_fin_value,
11490 : : (void *)&cmd_set_conntrack_dir_ack,
11491 : : (void *)&cmd_set_conntrack_dir_ack_value,
11492 : : (void *)&cmd_set_conntrack_dir_unack_data,
11493 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
11494 : : (void *)&cmd_set_conntrack_dir_sent_end,
11495 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
11496 : : (void *)&cmd_set_conntrack_dir_reply_end,
11497 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
11498 : : (void *)&cmd_set_conntrack_dir_max_win,
11499 : : (void *)&cmd_set_conntrack_dir_max_win_value,
11500 : : (void *)&cmd_set_conntrack_dir_max_ack,
11501 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
11502 : : NULL,
11503 : : },
11504 : : };
11505 : :
11506 : : /* show vf stats */
11507 : :
11508 : : /* Common result structure for show vf stats */
11509 : : struct cmd_show_vf_stats_result {
11510 : : cmdline_fixed_string_t show;
11511 : : cmdline_fixed_string_t vf;
11512 : : cmdline_fixed_string_t stats;
11513 : : portid_t port_id;
11514 : : uint16_t vf_id;
11515 : : };
11516 : :
11517 : : /* Common CLI fields show vf stats*/
11518 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
11519 : : TOKEN_STRING_INITIALIZER
11520 : : (struct cmd_show_vf_stats_result,
11521 : : show, "show");
11522 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
11523 : : TOKEN_STRING_INITIALIZER
11524 : : (struct cmd_show_vf_stats_result,
11525 : : vf, "vf");
11526 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
11527 : : TOKEN_STRING_INITIALIZER
11528 : : (struct cmd_show_vf_stats_result,
11529 : : stats, "stats");
11530 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
11531 : : TOKEN_NUM_INITIALIZER
11532 : : (struct cmd_show_vf_stats_result,
11533 : : port_id, RTE_UINT16);
11534 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
11535 : : TOKEN_NUM_INITIALIZER
11536 : : (struct cmd_show_vf_stats_result,
11537 : : vf_id, RTE_UINT16);
11538 : :
11539 : : static void
11540 : 0 : cmd_show_vf_stats_parsed(
11541 : : void *parsed_result,
11542 : : __rte_unused struct cmdline *cl,
11543 : : __rte_unused void *data)
11544 : : {
11545 : : struct cmd_show_vf_stats_result *res = parsed_result;
11546 : : struct rte_eth_stats stats;
11547 : : int ret = -ENOTSUP;
11548 : : static const char *nic_stats_border = "########################";
11549 : :
11550 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11551 : 0 : return;
11552 : :
11553 : : memset(&stats, 0, sizeof(stats));
11554 : :
11555 : : #ifdef RTE_NET_I40E
11556 : : if (ret == -ENOTSUP)
11557 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
11558 : 0 : res->vf_id,
11559 : : &stats);
11560 : : #endif
11561 : : #ifdef RTE_NET_BNXT
11562 : 0 : if (ret == -ENOTSUP)
11563 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
11564 : 0 : res->vf_id,
11565 : : &stats);
11566 : : #endif
11567 : :
11568 : 0 : switch (ret) {
11569 : : case 0:
11570 : : break;
11571 : 0 : case -EINVAL:
11572 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11573 : : break;
11574 : 0 : case -ENODEV:
11575 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11576 : : break;
11577 : 0 : case -ENOTSUP:
11578 : 0 : fprintf(stderr, "function not implemented\n");
11579 : : break;
11580 : 0 : default:
11581 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11582 : : }
11583 : :
11584 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
11585 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
11586 : :
11587 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
11588 : : "%-"PRIu64"\n",
11589 : : stats.ipackets, stats.imissed, stats.ibytes);
11590 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
11591 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
11592 : : stats.rx_nombuf);
11593 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
11594 : : "%-"PRIu64"\n",
11595 : : stats.opackets, stats.oerrors, stats.obytes);
11596 : :
11597 : 0 : printf(" %s############################%s\n",
11598 : : nic_stats_border, nic_stats_border);
11599 : : }
11600 : :
11601 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
11602 : : .f = cmd_show_vf_stats_parsed,
11603 : : .data = NULL,
11604 : : .help_str = "show vf stats <port_id> <vf_id>",
11605 : : .tokens = {
11606 : : (void *)&cmd_show_vf_stats_show,
11607 : : (void *)&cmd_show_vf_stats_vf,
11608 : : (void *)&cmd_show_vf_stats_stats,
11609 : : (void *)&cmd_show_vf_stats_port_id,
11610 : : (void *)&cmd_show_vf_stats_vf_id,
11611 : : NULL,
11612 : : },
11613 : : };
11614 : :
11615 : : /* clear vf stats */
11616 : :
11617 : : /* Common result structure for clear vf stats */
11618 : : struct cmd_clear_vf_stats_result {
11619 : : cmdline_fixed_string_t clear;
11620 : : cmdline_fixed_string_t vf;
11621 : : cmdline_fixed_string_t stats;
11622 : : portid_t port_id;
11623 : : uint16_t vf_id;
11624 : : };
11625 : :
11626 : : /* Common CLI fields clear vf stats*/
11627 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
11628 : : TOKEN_STRING_INITIALIZER
11629 : : (struct cmd_clear_vf_stats_result,
11630 : : clear, "clear");
11631 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
11632 : : TOKEN_STRING_INITIALIZER
11633 : : (struct cmd_clear_vf_stats_result,
11634 : : vf, "vf");
11635 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
11636 : : TOKEN_STRING_INITIALIZER
11637 : : (struct cmd_clear_vf_stats_result,
11638 : : stats, "stats");
11639 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
11640 : : TOKEN_NUM_INITIALIZER
11641 : : (struct cmd_clear_vf_stats_result,
11642 : : port_id, RTE_UINT16);
11643 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
11644 : : TOKEN_NUM_INITIALIZER
11645 : : (struct cmd_clear_vf_stats_result,
11646 : : vf_id, RTE_UINT16);
11647 : :
11648 : : static void
11649 : 0 : cmd_clear_vf_stats_parsed(
11650 : : void *parsed_result,
11651 : : __rte_unused struct cmdline *cl,
11652 : : __rte_unused void *data)
11653 : : {
11654 : : struct cmd_clear_vf_stats_result *res = parsed_result;
11655 : : int ret = -ENOTSUP;
11656 : :
11657 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11658 : : return;
11659 : :
11660 : : #ifdef RTE_NET_I40E
11661 : : if (ret == -ENOTSUP)
11662 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
11663 : 0 : res->vf_id);
11664 : : #endif
11665 : : #ifdef RTE_NET_BNXT
11666 : 0 : if (ret == -ENOTSUP)
11667 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
11668 : 0 : res->vf_id);
11669 : : #endif
11670 : :
11671 : 0 : switch (ret) {
11672 : : case 0:
11673 : : break;
11674 : 0 : case -EINVAL:
11675 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11676 : : break;
11677 : 0 : case -ENODEV:
11678 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11679 : : break;
11680 : 0 : case -ENOTSUP:
11681 : 0 : fprintf(stderr, "function not implemented\n");
11682 : : break;
11683 : 0 : default:
11684 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11685 : : }
11686 : : }
11687 : :
11688 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
11689 : : .f = cmd_clear_vf_stats_parsed,
11690 : : .data = NULL,
11691 : : .help_str = "clear vf stats <port_id> <vf_id>",
11692 : : .tokens = {
11693 : : (void *)&cmd_clear_vf_stats_clear,
11694 : : (void *)&cmd_clear_vf_stats_vf,
11695 : : (void *)&cmd_clear_vf_stats_stats,
11696 : : (void *)&cmd_clear_vf_stats_port_id,
11697 : : (void *)&cmd_clear_vf_stats_vf_id,
11698 : : NULL,
11699 : : },
11700 : : };
11701 : :
11702 : : /* Common result structure for file commands */
11703 : : struct cmd_cmdfile_result {
11704 : : cmdline_fixed_string_t load;
11705 : : cmdline_fixed_string_t filename;
11706 : : };
11707 : :
11708 : : /* Common CLI fields for file commands */
11709 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
11710 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
11711 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
11712 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
11713 : :
11714 : : static void
11715 : 0 : cmd_load_from_file_parsed(
11716 : : void *parsed_result,
11717 : : __rte_unused struct cmdline *cl,
11718 : : __rte_unused void *data)
11719 : : {
11720 : : struct cmd_cmdfile_result *res = parsed_result;
11721 : :
11722 : 0 : if (cmdline_read_from_file(res->filename, false) != 0) {
11723 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
11724 : : }
11725 : 0 : }
11726 : :
11727 : : static cmdline_parse_inst_t cmd_load_from_file = {
11728 : : .f = cmd_load_from_file_parsed,
11729 : : .data = NULL,
11730 : : .help_str = "load <filename>",
11731 : : .tokens = {
11732 : : (void *)&cmd_load_cmdfile,
11733 : : (void *)&cmd_load_cmdfile_filename,
11734 : : NULL,
11735 : : },
11736 : : };
11737 : :
11738 : : /* command to load a file with echoing commands */
11739 : : struct cmd_load_echo_result {
11740 : : cmdline_fixed_string_t load_echo;
11741 : : cmdline_fixed_string_t filename;
11742 : : };
11743 : :
11744 : : /* CLI fields for file load with echo command */
11745 : : static cmdline_parse_token_string_t cmd_load_echo =
11746 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, load_echo, "load_echo");
11747 : : static cmdline_parse_token_string_t cmd_load_echo_filename =
11748 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, filename, NULL);
11749 : :
11750 : : static void
11751 : 0 : cmd_load_echo_file_parsed(
11752 : : void *parsed_result,
11753 : : __rte_unused struct cmdline *cl,
11754 : : __rte_unused void *data)
11755 : : {
11756 : : struct cmd_load_echo_result *res = parsed_result;
11757 : :
11758 : 0 : if (cmdline_read_from_file(res->filename, true) != 0)
11759 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
11760 : 0 : }
11761 : :
11762 : : static cmdline_parse_inst_t cmd_load_echo_file = {
11763 : : .f = cmd_load_echo_file_parsed,
11764 : : .data = NULL,
11765 : : .help_str = "load_echo <filename>",
11766 : : .tokens = {
11767 : : (void *)&cmd_load_echo,
11768 : : (void *)&cmd_load_echo_filename,
11769 : : NULL,
11770 : : },
11771 : : };
11772 : :
11773 : : /* Get Rx offloads capabilities */
11774 : : struct cmd_rx_offload_get_capa_result {
11775 : : cmdline_fixed_string_t show;
11776 : : cmdline_fixed_string_t port;
11777 : : portid_t port_id;
11778 : : cmdline_fixed_string_t rx_offload;
11779 : : cmdline_fixed_string_t capabilities;
11780 : : };
11781 : :
11782 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
11783 : : TOKEN_STRING_INITIALIZER
11784 : : (struct cmd_rx_offload_get_capa_result,
11785 : : show, "show");
11786 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
11787 : : TOKEN_STRING_INITIALIZER
11788 : : (struct cmd_rx_offload_get_capa_result,
11789 : : port, "port");
11790 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
11791 : : TOKEN_NUM_INITIALIZER
11792 : : (struct cmd_rx_offload_get_capa_result,
11793 : : port_id, RTE_UINT16);
11794 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
11795 : : TOKEN_STRING_INITIALIZER
11796 : : (struct cmd_rx_offload_get_capa_result,
11797 : : rx_offload, "rx_offload");
11798 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
11799 : : TOKEN_STRING_INITIALIZER
11800 : : (struct cmd_rx_offload_get_capa_result,
11801 : : capabilities, "capabilities");
11802 : :
11803 : : static void
11804 : 0 : print_rx_offloads(uint64_t offloads)
11805 : : {
11806 : : uint64_t single_offload;
11807 : : int begin;
11808 : : int end;
11809 : : int bit;
11810 : :
11811 : 0 : if (offloads == 0)
11812 : : return;
11813 : :
11814 : : begin = rte_ctz64(offloads);
11815 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11816 : :
11817 : 0 : single_offload = 1ULL << begin;
11818 : 0 : for (bit = begin; bit < end; bit++) {
11819 : 0 : if (offloads & single_offload)
11820 : 0 : printf(" %s",
11821 : : rte_eth_dev_rx_offload_name(single_offload));
11822 : 0 : single_offload <<= 1;
11823 : : }
11824 : : }
11825 : :
11826 : : static void
11827 : 0 : cmd_rx_offload_get_capa_parsed(
11828 : : void *parsed_result,
11829 : : __rte_unused struct cmdline *cl,
11830 : : __rte_unused void *data)
11831 : : {
11832 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
11833 : : struct rte_eth_dev_info dev_info;
11834 : 0 : portid_t port_id = res->port_id;
11835 : : uint64_t queue_offloads;
11836 : : uint64_t port_offloads;
11837 : : int ret;
11838 : :
11839 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11840 : 0 : if (ret != 0)
11841 : 0 : return;
11842 : :
11843 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
11844 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
11845 : :
11846 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
11847 : : printf(" Per Queue :");
11848 : 0 : print_rx_offloads(queue_offloads);
11849 : :
11850 : : printf("\n");
11851 : : printf(" Per Port :");
11852 : 0 : print_rx_offloads(port_offloads);
11853 : : printf("\n\n");
11854 : : }
11855 : :
11856 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
11857 : : .f = cmd_rx_offload_get_capa_parsed,
11858 : : .data = NULL,
11859 : : .help_str = "show port <port_id> rx_offload capabilities",
11860 : : .tokens = {
11861 : : (void *)&cmd_rx_offload_get_capa_show,
11862 : : (void *)&cmd_rx_offload_get_capa_port,
11863 : : (void *)&cmd_rx_offload_get_capa_port_id,
11864 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
11865 : : (void *)&cmd_rx_offload_get_capa_capabilities,
11866 : : NULL,
11867 : : }
11868 : : };
11869 : :
11870 : : /* Get Rx offloads configuration */
11871 : : struct cmd_rx_offload_get_configuration_result {
11872 : : cmdline_fixed_string_t show;
11873 : : cmdline_fixed_string_t port;
11874 : : portid_t port_id;
11875 : : cmdline_fixed_string_t rx_offload;
11876 : : cmdline_fixed_string_t configuration;
11877 : : };
11878 : :
11879 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
11880 : : TOKEN_STRING_INITIALIZER
11881 : : (struct cmd_rx_offload_get_configuration_result,
11882 : : show, "show");
11883 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
11884 : : TOKEN_STRING_INITIALIZER
11885 : : (struct cmd_rx_offload_get_configuration_result,
11886 : : port, "port");
11887 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
11888 : : TOKEN_NUM_INITIALIZER
11889 : : (struct cmd_rx_offload_get_configuration_result,
11890 : : port_id, RTE_UINT16);
11891 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
11892 : : TOKEN_STRING_INITIALIZER
11893 : : (struct cmd_rx_offload_get_configuration_result,
11894 : : rx_offload, "rx_offload");
11895 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
11896 : : TOKEN_STRING_INITIALIZER
11897 : : (struct cmd_rx_offload_get_configuration_result,
11898 : : configuration, "configuration");
11899 : :
11900 : : static void
11901 : 0 : cmd_rx_offload_get_configuration_parsed(
11902 : : void *parsed_result,
11903 : : __rte_unused struct cmdline *cl,
11904 : : __rte_unused void *data)
11905 : : {
11906 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
11907 : : struct rte_eth_dev_info dev_info;
11908 : 0 : portid_t port_id = res->port_id;
11909 : : struct rte_port *port;
11910 : : struct rte_eth_conf dev_conf;
11911 : : uint64_t port_offloads;
11912 : : uint64_t queue_offloads;
11913 : : uint16_t nb_rx_queues;
11914 : : int q;
11915 : : int ret;
11916 : :
11917 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11918 : 0 : if (ret != 0)
11919 : 0 : return;
11920 : :
11921 : 0 : port = &ports[port_id];
11922 : : printf("Rx Offloading Configuration of port %d :\n", port_id);
11923 : :
11924 : 0 : port_offloads = dev_conf.rxmode.offloads;
11925 : : printf(" Port :");
11926 : 0 : print_rx_offloads(port_offloads);
11927 : : printf("\n");
11928 : :
11929 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11930 : 0 : if (ret != 0)
11931 : : return;
11932 : :
11933 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11934 : 0 : for (q = 0; q < nb_rx_queues; q++) {
11935 : 0 : queue_offloads = port->rxq[q].conf.offloads;
11936 : : printf(" Queue[%2d] :", q);
11937 : 0 : print_rx_offloads(queue_offloads);
11938 : : printf("\n");
11939 : : }
11940 : : printf("\n");
11941 : : }
11942 : :
11943 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
11944 : : .f = cmd_rx_offload_get_configuration_parsed,
11945 : : .data = NULL,
11946 : : .help_str = "show port <port_id> rx_offload configuration",
11947 : : .tokens = {
11948 : : (void *)&cmd_rx_offload_get_configuration_show,
11949 : : (void *)&cmd_rx_offload_get_configuration_port,
11950 : : (void *)&cmd_rx_offload_get_configuration_port_id,
11951 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
11952 : : (void *)&cmd_rx_offload_get_configuration_configuration,
11953 : : NULL,
11954 : : }
11955 : : };
11956 : :
11957 : : /* Enable/Disable a per port offloading */
11958 : : struct cmd_config_per_port_rx_offload_result {
11959 : : cmdline_fixed_string_t port;
11960 : : cmdline_fixed_string_t config;
11961 : : portid_t port_id;
11962 : : cmdline_fixed_string_t rx_offload;
11963 : : cmdline_fixed_string_t offload;
11964 : : cmdline_fixed_string_t on_off;
11965 : : };
11966 : :
11967 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
11968 : : TOKEN_STRING_INITIALIZER
11969 : : (struct cmd_config_per_port_rx_offload_result,
11970 : : port, "port");
11971 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
11972 : : TOKEN_STRING_INITIALIZER
11973 : : (struct cmd_config_per_port_rx_offload_result,
11974 : : config, "config");
11975 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
11976 : : TOKEN_NUM_INITIALIZER
11977 : : (struct cmd_config_per_port_rx_offload_result,
11978 : : port_id, RTE_UINT16);
11979 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
11980 : : TOKEN_STRING_INITIALIZER
11981 : : (struct cmd_config_per_port_rx_offload_result,
11982 : : rx_offload, "rx_offload");
11983 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
11984 : : TOKEN_STRING_INITIALIZER
11985 : : (struct cmd_config_per_port_rx_offload_result,
11986 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11987 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11988 : : "vlan_filter#vlan_extend#"
11989 : : "scatter#buffer_split#timestamp#security#"
11990 : : "keep_crc#rss_hash");
11991 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
11992 : : TOKEN_STRING_INITIALIZER
11993 : : (struct cmd_config_per_port_rx_offload_result,
11994 : : on_off, "on#off");
11995 : :
11996 : : static uint64_t
11997 : 0 : search_rx_offload(const char *name)
11998 : : {
11999 : : uint64_t single_offload;
12000 : : const char *single_name;
12001 : : int found = 0;
12002 : : unsigned int bit;
12003 : :
12004 : : single_offload = 1;
12005 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12006 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
12007 : 0 : if (!strcasecmp(single_name, name)) {
12008 : : found = 1;
12009 : : break;
12010 : : }
12011 : 0 : single_offload <<= 1;
12012 : : }
12013 : :
12014 : 0 : if (found)
12015 : 0 : return single_offload;
12016 : :
12017 : : return 0;
12018 : : }
12019 : :
12020 : : static void
12021 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
12022 : : {
12023 : : struct rte_eth_dev_info dev_info;
12024 : : struct rte_port *port;
12025 : : uint16_t nb_rx_queues;
12026 : : uint64_t offload;
12027 : : int q;
12028 : : int ret;
12029 : :
12030 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12031 : 0 : if (ret != 0)
12032 : 0 : return;
12033 : :
12034 : 0 : port = &ports[port_id];
12035 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12036 : 0 : fprintf(stderr,
12037 : : "Error: Can't config offload when Port %d is not stopped\n",
12038 : : port_id);
12039 : 0 : return;
12040 : : }
12041 : :
12042 : 0 : if (!strcmp(name, "all")) {
12043 : 0 : offload = dev_info.rx_offload_capa;
12044 : : } else {
12045 : 0 : offload = search_rx_offload(name);
12046 : 0 : if (offload == 0) {
12047 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12048 : 0 : return;
12049 : : }
12050 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
12051 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12052 : : port_id, name);
12053 : 0 : return;
12054 : : }
12055 : : }
12056 : :
12057 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12058 : 0 : if (on) {
12059 : 0 : port->dev_conf.rxmode.offloads |= offload;
12060 : 0 : for (q = 0; q < nb_rx_queues; q++)
12061 : 0 : port->rxq[q].conf.offloads |= offload;
12062 : : } else {
12063 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
12064 : 0 : for (q = 0; q < nb_rx_queues; q++)
12065 : 0 : port->rxq[q].conf.offloads &= ~offload;
12066 : : }
12067 : :
12068 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12069 : : }
12070 : :
12071 : : static void
12072 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
12073 : : __rte_unused struct cmdline *cl,
12074 : : __rte_unused void *data)
12075 : : {
12076 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
12077 : : bool on;
12078 : :
12079 : 0 : on = strcmp(res->on_off, "on") == 0;
12080 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
12081 : 0 : }
12082 : :
12083 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
12084 : : .f = cmd_config_per_port_rx_offload_parsed,
12085 : : .data = NULL,
12086 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
12087 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12088 : : "macsec_strip|vlan_filter|vlan_extend|"
12089 : : "scatter|buffer_split|timestamp|security|"
12090 : : "keep_crc|rss_hash on|off",
12091 : : .tokens = {
12092 : : (void *)&cmd_config_per_port_rx_offload_result_port,
12093 : : (void *)&cmd_config_per_port_rx_offload_result_config,
12094 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
12095 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
12096 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
12097 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
12098 : : NULL,
12099 : : }
12100 : : };
12101 : :
12102 : : /* Enable/Disable all port Rx offloading */
12103 : : struct cmd_config_all_port_rx_offload_result {
12104 : : cmdline_fixed_string_t port;
12105 : : cmdline_fixed_string_t config;
12106 : : cmdline_fixed_string_t port_all;
12107 : : cmdline_fixed_string_t rx_offload;
12108 : : cmdline_fixed_string_t offload;
12109 : : cmdline_fixed_string_t on_off;
12110 : : };
12111 : :
12112 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
12113 : : TOKEN_STRING_INITIALIZER
12114 : : (struct cmd_config_all_port_rx_offload_result,
12115 : : port, "port");
12116 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
12117 : : TOKEN_STRING_INITIALIZER
12118 : : (struct cmd_config_all_port_rx_offload_result,
12119 : : config, "config");
12120 : :
12121 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
12122 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
12123 : : port_all, "all");
12124 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
12125 : : TOKEN_STRING_INITIALIZER
12126 : : (struct cmd_config_all_port_rx_offload_result,
12127 : : rx_offload, "rx_offload");
12128 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
12129 : : TOKEN_STRING_INITIALIZER
12130 : : (struct cmd_config_all_port_rx_offload_result,
12131 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12132 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12133 : : "vlan_filter#vlan_extend#"
12134 : : "scatter#buffer_split#timestamp#security#"
12135 : : "keep_crc#rss_hash");
12136 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
12137 : : TOKEN_STRING_INITIALIZER
12138 : : (struct cmd_config_all_port_rx_offload_result,
12139 : : on_off, "on#off");
12140 : :
12141 : : static void
12142 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
12143 : : __rte_unused struct cmdline *cl,
12144 : : __rte_unused void *data)
12145 : : {
12146 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
12147 : : bool on_off;
12148 : : portid_t i;
12149 : :
12150 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12151 : 0 : RTE_ETH_FOREACH_DEV(i)
12152 : 0 : config_port_rx_offload(i, res->offload, on_off);
12153 : :
12154 : 0 : }
12155 : :
12156 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
12157 : : .f = cmd_config_all_port_rx_offload_parsed,
12158 : : .data = NULL,
12159 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
12160 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12161 : : "macsec_strip|vlan_filter|vlan_extend|"
12162 : : "scatter|buffer_split|timestamp|security|"
12163 : : "keep_crc|rss_hash on|off",
12164 : : .tokens = {
12165 : : (void *)&cmd_config_all_port_rx_offload_result_port,
12166 : : (void *)&cmd_config_all_port_rx_offload_result_config,
12167 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
12168 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
12169 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
12170 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
12171 : : NULL,
12172 : : }
12173 : : };
12174 : :
12175 : : /* Enable/Disable a per queue offloading */
12176 : : struct cmd_config_per_queue_rx_offload_result {
12177 : : cmdline_fixed_string_t port;
12178 : : portid_t port_id;
12179 : : cmdline_fixed_string_t rxq;
12180 : : uint16_t queue_id;
12181 : : cmdline_fixed_string_t rx_offload;
12182 : : cmdline_fixed_string_t offload;
12183 : : cmdline_fixed_string_t on_off;
12184 : : };
12185 : :
12186 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
12187 : : TOKEN_STRING_INITIALIZER
12188 : : (struct cmd_config_per_queue_rx_offload_result,
12189 : : port, "port");
12190 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
12191 : : TOKEN_NUM_INITIALIZER
12192 : : (struct cmd_config_per_queue_rx_offload_result,
12193 : : port_id, RTE_UINT16);
12194 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
12195 : : TOKEN_STRING_INITIALIZER
12196 : : (struct cmd_config_per_queue_rx_offload_result,
12197 : : rxq, "rxq");
12198 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
12199 : : TOKEN_NUM_INITIALIZER
12200 : : (struct cmd_config_per_queue_rx_offload_result,
12201 : : queue_id, RTE_UINT16);
12202 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
12203 : : TOKEN_STRING_INITIALIZER
12204 : : (struct cmd_config_per_queue_rx_offload_result,
12205 : : rx_offload, "rx_offload");
12206 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
12207 : : TOKEN_STRING_INITIALIZER
12208 : : (struct cmd_config_per_queue_rx_offload_result,
12209 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12210 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12211 : : "vlan_filter#vlan_extend#"
12212 : : "scatter#buffer_split#timestamp#security#keep_crc");
12213 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
12214 : : TOKEN_STRING_INITIALIZER
12215 : : (struct cmd_config_per_queue_rx_offload_result,
12216 : : on_off, "on#off");
12217 : :
12218 : : static void
12219 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
12220 : : __rte_unused struct cmdline *cl,
12221 : : __rte_unused void *data)
12222 : : {
12223 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
12224 : : struct rte_eth_dev_info dev_info;
12225 : 0 : portid_t port_id = res->port_id;
12226 : 0 : uint16_t queue_id = res->queue_id;
12227 : : struct rte_port *port;
12228 : : uint64_t offload;
12229 : : int ret;
12230 : :
12231 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12232 : 0 : if (ret != 0)
12233 : 0 : return;
12234 : :
12235 : 0 : port = &ports[port_id];
12236 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12237 : 0 : fprintf(stderr,
12238 : : "Error: Can't config offload when Port %d is not stopped\n",
12239 : : port_id);
12240 : 0 : return;
12241 : : }
12242 : :
12243 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
12244 : 0 : fprintf(stderr,
12245 : : "Error: input queue_id should be 0 ... %d\n",
12246 : 0 : dev_info.nb_rx_queues - 1);
12247 : 0 : return;
12248 : : }
12249 : :
12250 : 0 : if (!strcmp(res->offload, "all")) {
12251 : 0 : offload = dev_info.rx_queue_offload_capa;
12252 : : } else {
12253 : 0 : offload = search_rx_offload(res->offload);
12254 : 0 : if (offload == 0) {
12255 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12256 : 0 : return;
12257 : : }
12258 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
12259 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12260 : : port_id, res->offload);
12261 : 0 : return;
12262 : : }
12263 : : }
12264 : :
12265 : 0 : if (!strcmp(res->on_off, "on"))
12266 : 0 : port->rxq[queue_id].conf.offloads |= offload;
12267 : : else
12268 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
12269 : :
12270 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12271 : : }
12272 : :
12273 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
12274 : : .f = cmd_config_per_queue_rx_offload_parsed,
12275 : : .data = NULL,
12276 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
12277 : : "all|vlan_strip|ipv4_cksum|"
12278 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12279 : : "macsec_strip|vlan_filter|vlan_extend|"
12280 : : "scatter|buffer_split|timestamp|security|"
12281 : : "keep_crc on|off",
12282 : : .tokens = {
12283 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
12284 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
12285 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
12286 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
12287 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
12288 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
12289 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
12290 : : NULL,
12291 : : }
12292 : : };
12293 : :
12294 : : /* Get Tx offloads capabilities */
12295 : : struct cmd_tx_offload_get_capa_result {
12296 : : cmdline_fixed_string_t show;
12297 : : cmdline_fixed_string_t port;
12298 : : portid_t port_id;
12299 : : cmdline_fixed_string_t tx_offload;
12300 : : cmdline_fixed_string_t capabilities;
12301 : : };
12302 : :
12303 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
12304 : : TOKEN_STRING_INITIALIZER
12305 : : (struct cmd_tx_offload_get_capa_result,
12306 : : show, "show");
12307 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
12308 : : TOKEN_STRING_INITIALIZER
12309 : : (struct cmd_tx_offload_get_capa_result,
12310 : : port, "port");
12311 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
12312 : : TOKEN_NUM_INITIALIZER
12313 : : (struct cmd_tx_offload_get_capa_result,
12314 : : port_id, RTE_UINT16);
12315 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
12316 : : TOKEN_STRING_INITIALIZER
12317 : : (struct cmd_tx_offload_get_capa_result,
12318 : : tx_offload, "tx_offload");
12319 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
12320 : : TOKEN_STRING_INITIALIZER
12321 : : (struct cmd_tx_offload_get_capa_result,
12322 : : capabilities, "capabilities");
12323 : :
12324 : : static void
12325 : 0 : print_tx_offloads(uint64_t offloads)
12326 : : {
12327 : : uint64_t single_offload;
12328 : : int begin;
12329 : : int end;
12330 : : int bit;
12331 : :
12332 : 0 : if (offloads == 0)
12333 : : return;
12334 : :
12335 : : begin = rte_ctz64(offloads);
12336 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12337 : :
12338 : 0 : single_offload = 1ULL << begin;
12339 : 0 : for (bit = begin; bit < end; bit++) {
12340 : 0 : if (offloads & single_offload)
12341 : 0 : printf(" %s",
12342 : : rte_eth_dev_tx_offload_name(single_offload));
12343 : 0 : single_offload <<= 1;
12344 : : }
12345 : : }
12346 : :
12347 : : static void
12348 : 0 : cmd_tx_offload_get_capa_parsed(
12349 : : void *parsed_result,
12350 : : __rte_unused struct cmdline *cl,
12351 : : __rte_unused void *data)
12352 : : {
12353 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
12354 : : struct rte_eth_dev_info dev_info;
12355 : 0 : portid_t port_id = res->port_id;
12356 : : uint64_t queue_offloads;
12357 : : uint64_t port_offloads;
12358 : : int ret;
12359 : :
12360 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12361 : 0 : if (ret != 0)
12362 : 0 : return;
12363 : :
12364 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
12365 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
12366 : :
12367 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
12368 : : printf(" Per Queue :");
12369 : 0 : print_tx_offloads(queue_offloads);
12370 : :
12371 : : printf("\n");
12372 : : printf(" Per Port :");
12373 : 0 : print_tx_offloads(port_offloads);
12374 : : printf("\n\n");
12375 : : }
12376 : :
12377 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
12378 : : .f = cmd_tx_offload_get_capa_parsed,
12379 : : .data = NULL,
12380 : : .help_str = "show port <port_id> tx_offload capabilities",
12381 : : .tokens = {
12382 : : (void *)&cmd_tx_offload_get_capa_show,
12383 : : (void *)&cmd_tx_offload_get_capa_port,
12384 : : (void *)&cmd_tx_offload_get_capa_port_id,
12385 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
12386 : : (void *)&cmd_tx_offload_get_capa_capabilities,
12387 : : NULL,
12388 : : }
12389 : : };
12390 : :
12391 : : /* Get Tx offloads configuration */
12392 : : struct cmd_tx_offload_get_configuration_result {
12393 : : cmdline_fixed_string_t show;
12394 : : cmdline_fixed_string_t port;
12395 : : portid_t port_id;
12396 : : cmdline_fixed_string_t tx_offload;
12397 : : cmdline_fixed_string_t configuration;
12398 : : };
12399 : :
12400 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
12401 : : TOKEN_STRING_INITIALIZER
12402 : : (struct cmd_tx_offload_get_configuration_result,
12403 : : show, "show");
12404 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
12405 : : TOKEN_STRING_INITIALIZER
12406 : : (struct cmd_tx_offload_get_configuration_result,
12407 : : port, "port");
12408 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
12409 : : TOKEN_NUM_INITIALIZER
12410 : : (struct cmd_tx_offload_get_configuration_result,
12411 : : port_id, RTE_UINT16);
12412 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
12413 : : TOKEN_STRING_INITIALIZER
12414 : : (struct cmd_tx_offload_get_configuration_result,
12415 : : tx_offload, "tx_offload");
12416 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
12417 : : TOKEN_STRING_INITIALIZER
12418 : : (struct cmd_tx_offload_get_configuration_result,
12419 : : configuration, "configuration");
12420 : :
12421 : : static void
12422 : 0 : cmd_tx_offload_get_configuration_parsed(
12423 : : void *parsed_result,
12424 : : __rte_unused struct cmdline *cl,
12425 : : __rte_unused void *data)
12426 : : {
12427 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
12428 : : struct rte_eth_dev_info dev_info;
12429 : 0 : portid_t port_id = res->port_id;
12430 : : struct rte_port *port;
12431 : : struct rte_eth_conf dev_conf;
12432 : : uint64_t port_offloads;
12433 : : uint64_t queue_offloads;
12434 : : uint16_t nb_tx_queues;
12435 : : int q;
12436 : : int ret;
12437 : :
12438 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12439 : 0 : if (ret != 0)
12440 : 0 : return;
12441 : :
12442 : : printf("Tx Offloading Configuration of port %d :\n", port_id);
12443 : 0 : port = &ports[port_id];
12444 : 0 : port_offloads = dev_conf.txmode.offloads;
12445 : : printf(" Port :");
12446 : 0 : print_tx_offloads(port_offloads);
12447 : : printf("\n");
12448 : :
12449 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12450 : 0 : if (ret != 0)
12451 : : return;
12452 : :
12453 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12454 : 0 : for (q = 0; q < nb_tx_queues; q++) {
12455 : 0 : queue_offloads = port->txq[q].conf.offloads;
12456 : : printf(" Queue[%2d] :", q);
12457 : 0 : print_tx_offloads(queue_offloads);
12458 : : printf("\n");
12459 : : }
12460 : : printf("\n");
12461 : : }
12462 : :
12463 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
12464 : : .f = cmd_tx_offload_get_configuration_parsed,
12465 : : .data = NULL,
12466 : : .help_str = "show port <port_id> tx_offload configuration",
12467 : : .tokens = {
12468 : : (void *)&cmd_tx_offload_get_configuration_show,
12469 : : (void *)&cmd_tx_offload_get_configuration_port,
12470 : : (void *)&cmd_tx_offload_get_configuration_port_id,
12471 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
12472 : : (void *)&cmd_tx_offload_get_configuration_configuration,
12473 : : NULL,
12474 : : }
12475 : : };
12476 : :
12477 : : /* Enable/Disable a per port offloading */
12478 : : struct cmd_config_per_port_tx_offload_result {
12479 : : cmdline_fixed_string_t port;
12480 : : cmdline_fixed_string_t config;
12481 : : portid_t port_id;
12482 : : cmdline_fixed_string_t tx_offload;
12483 : : cmdline_fixed_string_t offload;
12484 : : cmdline_fixed_string_t on_off;
12485 : : };
12486 : :
12487 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
12488 : : TOKEN_STRING_INITIALIZER
12489 : : (struct cmd_config_per_port_tx_offload_result,
12490 : : port, "port");
12491 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
12492 : : TOKEN_STRING_INITIALIZER
12493 : : (struct cmd_config_per_port_tx_offload_result,
12494 : : config, "config");
12495 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
12496 : : TOKEN_NUM_INITIALIZER
12497 : : (struct cmd_config_per_port_tx_offload_result,
12498 : : port_id, RTE_UINT16);
12499 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
12500 : : TOKEN_STRING_INITIALIZER
12501 : : (struct cmd_config_per_port_tx_offload_result,
12502 : : tx_offload, "tx_offload");
12503 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
12504 : : TOKEN_STRING_INITIALIZER
12505 : : (struct cmd_config_per_port_tx_offload_result,
12506 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12507 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12508 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12509 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12510 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12511 : : "send_on_timestamp");
12512 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
12513 : : TOKEN_STRING_INITIALIZER
12514 : : (struct cmd_config_per_port_tx_offload_result,
12515 : : on_off, "on#off");
12516 : :
12517 : : static uint64_t
12518 : 0 : search_tx_offload(const char *name)
12519 : : {
12520 : : uint64_t single_offload;
12521 : : const char *single_name;
12522 : : int found = 0;
12523 : : unsigned int bit;
12524 : :
12525 : : single_offload = 1;
12526 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12527 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
12528 : 0 : if (single_name == NULL)
12529 : : break;
12530 : 0 : if (!strcasecmp(single_name, name)) {
12531 : : found = 1;
12532 : : break;
12533 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
12534 : : break;
12535 : 0 : single_offload <<= 1;
12536 : : }
12537 : :
12538 : 0 : if (found)
12539 : 0 : return single_offload;
12540 : :
12541 : : return 0;
12542 : : }
12543 : :
12544 : : static void
12545 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
12546 : : {
12547 : : struct rte_eth_dev_info dev_info;
12548 : : struct rte_port *port;
12549 : : uint16_t nb_tx_queues;
12550 : : uint64_t offload;
12551 : : int q;
12552 : : int ret;
12553 : :
12554 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12555 : 0 : if (ret != 0)
12556 : 0 : return;
12557 : :
12558 : 0 : port = &ports[port_id];
12559 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12560 : 0 : fprintf(stderr,
12561 : : "Error: Can't config offload when Port %d is not stopped\n",
12562 : : port_id);
12563 : 0 : return;
12564 : : }
12565 : :
12566 : 0 : if (!strcmp(name, "all")) {
12567 : 0 : offload = dev_info.tx_offload_capa;
12568 : : } else {
12569 : 0 : offload = search_tx_offload(name);
12570 : 0 : if (offload == 0) {
12571 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12572 : 0 : return;
12573 : : }
12574 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
12575 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12576 : : port_id, name);
12577 : 0 : return;
12578 : : }
12579 : : }
12580 : :
12581 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12582 : 0 : if (on) {
12583 : 0 : port->dev_conf.txmode.offloads |= offload;
12584 : 0 : for (q = 0; q < nb_tx_queues; q++)
12585 : 0 : port->txq[q].conf.offloads |= offload;
12586 : : } else {
12587 : 0 : port->dev_conf.txmode.offloads &= ~offload;
12588 : 0 : for (q = 0; q < nb_tx_queues; q++)
12589 : 0 : port->txq[q].conf.offloads &= ~offload;
12590 : : }
12591 : :
12592 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12593 : : }
12594 : :
12595 : : static void
12596 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
12597 : : __rte_unused struct cmdline *cl,
12598 : : __rte_unused void *data)
12599 : : {
12600 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
12601 : : bool on;
12602 : :
12603 : 0 : on = strcmp(res->on_off, "on") == 0;
12604 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
12605 : 0 : }
12606 : :
12607 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
12608 : : .f = cmd_config_per_port_tx_offload_parsed,
12609 : : .data = NULL,
12610 : : .help_str = "port config <port_id> tx_offload "
12611 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12612 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12613 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12614 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12615 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12616 : : "send_on_timestamp on|off",
12617 : : .tokens = {
12618 : : (void *)&cmd_config_per_port_tx_offload_result_port,
12619 : : (void *)&cmd_config_per_port_tx_offload_result_config,
12620 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
12621 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
12622 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
12623 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
12624 : : NULL,
12625 : : }
12626 : : };
12627 : :
12628 : : /* Enable/Disable all port Tx offloading */
12629 : : struct cmd_config_all_port_tx_offload_result {
12630 : : cmdline_fixed_string_t port;
12631 : : cmdline_fixed_string_t config;
12632 : : cmdline_fixed_string_t port_all;
12633 : : cmdline_fixed_string_t tx_offload;
12634 : : cmdline_fixed_string_t offload;
12635 : : cmdline_fixed_string_t on_off;
12636 : : };
12637 : :
12638 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
12639 : : TOKEN_STRING_INITIALIZER
12640 : : (struct cmd_config_all_port_tx_offload_result,
12641 : : port, "port");
12642 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
12643 : : TOKEN_STRING_INITIALIZER
12644 : : (struct cmd_config_all_port_tx_offload_result,
12645 : : config, "config");
12646 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
12647 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
12648 : : port_all, "all");
12649 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
12650 : : TOKEN_STRING_INITIALIZER
12651 : : (struct cmd_config_all_port_tx_offload_result,
12652 : : tx_offload, "tx_offload");
12653 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
12654 : : TOKEN_STRING_INITIALIZER
12655 : : (struct cmd_config_all_port_tx_offload_result,
12656 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12657 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12658 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12659 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12660 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12661 : : "send_on_timestamp");
12662 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
12663 : : TOKEN_STRING_INITIALIZER
12664 : : (struct cmd_config_all_port_tx_offload_result,
12665 : : on_off, "on#off");
12666 : :
12667 : : static void
12668 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
12669 : : __rte_unused struct cmdline *cl,
12670 : : __rte_unused void *data)
12671 : : {
12672 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
12673 : : portid_t i;
12674 : : bool on_off;
12675 : :
12676 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12677 : 0 : RTE_ETH_FOREACH_DEV(i)
12678 : 0 : config_port_tx_offload(i, res->offload, on_off);
12679 : 0 : }
12680 : :
12681 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
12682 : : .f = cmd_config_all_port_tx_offload_parsed,
12683 : : .data = NULL,
12684 : : .help_str = "port config all tx_offload "
12685 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12686 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12687 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12688 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12689 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12690 : : "send_on_timestamp on|off",
12691 : : .tokens = {
12692 : : (void *)&cmd_config_all_port_tx_offload_result_port,
12693 : : (void *)&cmd_config_all_port_tx_offload_result_config,
12694 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
12695 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
12696 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
12697 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
12698 : : NULL,
12699 : : }
12700 : : };
12701 : :
12702 : : /* Enable/Disable a per queue offloading */
12703 : : struct cmd_config_per_queue_tx_offload_result {
12704 : : cmdline_fixed_string_t port;
12705 : : portid_t port_id;
12706 : : cmdline_fixed_string_t txq;
12707 : : uint16_t queue_id;
12708 : : cmdline_fixed_string_t tx_offload;
12709 : : cmdline_fixed_string_t offload;
12710 : : cmdline_fixed_string_t on_off;
12711 : : };
12712 : :
12713 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
12714 : : TOKEN_STRING_INITIALIZER
12715 : : (struct cmd_config_per_queue_tx_offload_result,
12716 : : port, "port");
12717 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
12718 : : TOKEN_NUM_INITIALIZER
12719 : : (struct cmd_config_per_queue_tx_offload_result,
12720 : : port_id, RTE_UINT16);
12721 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
12722 : : TOKEN_STRING_INITIALIZER
12723 : : (struct cmd_config_per_queue_tx_offload_result,
12724 : : txq, "txq");
12725 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
12726 : : TOKEN_NUM_INITIALIZER
12727 : : (struct cmd_config_per_queue_tx_offload_result,
12728 : : queue_id, RTE_UINT16);
12729 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
12730 : : TOKEN_STRING_INITIALIZER
12731 : : (struct cmd_config_per_queue_tx_offload_result,
12732 : : tx_offload, "tx_offload");
12733 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
12734 : : TOKEN_STRING_INITIALIZER
12735 : : (struct cmd_config_per_queue_tx_offload_result,
12736 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12737 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12738 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12739 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12740 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
12741 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
12742 : : TOKEN_STRING_INITIALIZER
12743 : : (struct cmd_config_per_queue_tx_offload_result,
12744 : : on_off, "on#off");
12745 : :
12746 : : static void
12747 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
12748 : : __rte_unused struct cmdline *cl,
12749 : : __rte_unused void *data)
12750 : : {
12751 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
12752 : : struct rte_eth_dev_info dev_info;
12753 : 0 : portid_t port_id = res->port_id;
12754 : 0 : uint16_t queue_id = res->queue_id;
12755 : : struct rte_port *port;
12756 : : uint64_t offload;
12757 : : int ret;
12758 : :
12759 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12760 : 0 : if (ret != 0)
12761 : 0 : return;
12762 : :
12763 : 0 : port = &ports[port_id];
12764 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12765 : 0 : fprintf(stderr,
12766 : : "Error: Can't config offload when Port %d is not stopped\n",
12767 : : port_id);
12768 : 0 : return;
12769 : : }
12770 : :
12771 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
12772 : 0 : fprintf(stderr,
12773 : : "Error: input queue_id should be 0 ... %d\n",
12774 : 0 : dev_info.nb_tx_queues - 1);
12775 : 0 : return;
12776 : : }
12777 : :
12778 : 0 : if (!strcmp(res->offload, "all")) {
12779 : 0 : offload = dev_info.tx_queue_offload_capa;
12780 : : } else {
12781 : 0 : offload = search_tx_offload(res->offload);
12782 : 0 : if (offload == 0) {
12783 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12784 : 0 : return;
12785 : : }
12786 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
12787 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12788 : : port_id, res->offload);
12789 : 0 : return;
12790 : : }
12791 : : }
12792 : :
12793 : 0 : if (!strcmp(res->on_off, "on"))
12794 : 0 : port->txq[queue_id].conf.offloads |= offload;
12795 : : else
12796 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
12797 : :
12798 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12799 : : }
12800 : :
12801 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
12802 : : .f = cmd_config_per_queue_tx_offload_parsed,
12803 : : .data = NULL,
12804 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
12805 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12806 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12807 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12808 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12809 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
12810 : : "on|off",
12811 : : .tokens = {
12812 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
12813 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
12814 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
12815 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
12816 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
12817 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
12818 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
12819 : : NULL,
12820 : : }
12821 : : };
12822 : :
12823 : : /* *** configure tx_metadata for specific port *** */
12824 : : struct cmd_config_tx_metadata_specific_result {
12825 : : cmdline_fixed_string_t port;
12826 : : cmdline_fixed_string_t keyword;
12827 : : uint16_t port_id;
12828 : : cmdline_fixed_string_t item;
12829 : : uint32_t value;
12830 : : };
12831 : :
12832 : : static void
12833 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
12834 : : __rte_unused struct cmdline *cl,
12835 : : __rte_unused void *data)
12836 : : {
12837 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
12838 : :
12839 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12840 : : return;
12841 : 0 : ports[res->port_id].tx_metadata = res->value;
12842 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
12843 : 0 : if (ports[res->port_id].tx_metadata)
12844 : 0 : add_tx_md_callback(res->port_id);
12845 : : else
12846 : 0 : remove_tx_md_callback(res->port_id);
12847 : 0 : rte_flow_dynf_metadata_register();
12848 : : }
12849 : :
12850 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
12851 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12852 : : port, "port");
12853 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
12854 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12855 : : keyword, "config");
12856 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
12857 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12858 : : port_id, RTE_UINT16);
12859 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
12860 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12861 : : item, "tx_metadata");
12862 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
12863 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12864 : : value, RTE_UINT32);
12865 : :
12866 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
12867 : : .f = cmd_config_tx_metadata_specific_parsed,
12868 : : .data = NULL,
12869 : : .help_str = "port config <port_id> tx_metadata <value>",
12870 : : .tokens = {
12871 : : (void *)&cmd_config_tx_metadata_specific_port,
12872 : : (void *)&cmd_config_tx_metadata_specific_keyword,
12873 : : (void *)&cmd_config_tx_metadata_specific_id,
12874 : : (void *)&cmd_config_tx_metadata_specific_item,
12875 : : (void *)&cmd_config_tx_metadata_specific_value,
12876 : : NULL,
12877 : : },
12878 : : };
12879 : :
12880 : : /* *** set dynf *** */
12881 : : struct cmd_config_tx_dynf_specific_result {
12882 : : cmdline_fixed_string_t port;
12883 : : cmdline_fixed_string_t keyword;
12884 : : uint16_t port_id;
12885 : : cmdline_fixed_string_t item;
12886 : : cmdline_fixed_string_t name;
12887 : : cmdline_fixed_string_t value;
12888 : : };
12889 : :
12890 : : static void
12891 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
12892 : : __rte_unused struct cmdline *cl,
12893 : : __rte_unused void *data)
12894 : : {
12895 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
12896 : : struct rte_mbuf_dynflag desc_flag;
12897 : : int flag;
12898 : : uint64_t old_port_flags;
12899 : :
12900 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12901 : 0 : return;
12902 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
12903 : 0 : if (flag <= 0) {
12904 : 0 : if (strlcpy(desc_flag.name, res->name,
12905 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
12906 : 0 : fprintf(stderr, "Flag name too long\n");
12907 : 0 : return;
12908 : : }
12909 : 0 : desc_flag.flags = 0;
12910 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
12911 : 0 : if (flag < 0) {
12912 : 0 : fprintf(stderr, "Can't register flag\n");
12913 : 0 : return;
12914 : : }
12915 : 0 : strcpy(dynf_names[flag], desc_flag.name);
12916 : : }
12917 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
12918 : 0 : if (!strcmp(res->value, "set")) {
12919 : 0 : ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
12920 : 0 : if (old_port_flags == 0)
12921 : 0 : add_tx_dynf_callback(res->port_id);
12922 : : } else {
12923 : 0 : ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
12924 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
12925 : 0 : remove_tx_dynf_callback(res->port_id);
12926 : : }
12927 : : }
12928 : :
12929 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
12930 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12931 : : keyword, "port");
12932 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
12933 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12934 : : keyword, "config");
12935 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
12936 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12937 : : port_id, RTE_UINT16);
12938 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
12939 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12940 : : item, "dynf");
12941 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
12942 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12943 : : name, NULL);
12944 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
12945 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12946 : : value, "set#clear");
12947 : :
12948 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
12949 : : .f = cmd_config_dynf_specific_parsed,
12950 : : .data = NULL,
12951 : : .help_str = "port config <port id> dynf <name> set|clear",
12952 : : .tokens = {
12953 : : (void *)&cmd_config_tx_dynf_specific_port,
12954 : : (void *)&cmd_config_tx_dynf_specific_keyword,
12955 : : (void *)&cmd_config_tx_dynf_specific_port_id,
12956 : : (void *)&cmd_config_tx_dynf_specific_item,
12957 : : (void *)&cmd_config_tx_dynf_specific_name,
12958 : : (void *)&cmd_config_tx_dynf_specific_value,
12959 : : NULL,
12960 : : },
12961 : : };
12962 : :
12963 : : /* *** display tx_metadata per port configuration *** */
12964 : : struct cmd_show_tx_metadata_result {
12965 : : cmdline_fixed_string_t cmd_show;
12966 : : cmdline_fixed_string_t cmd_port;
12967 : : cmdline_fixed_string_t cmd_keyword;
12968 : : portid_t cmd_pid;
12969 : : };
12970 : :
12971 : : static void
12972 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
12973 : : __rte_unused struct cmdline *cl,
12974 : : __rte_unused void *data)
12975 : : {
12976 : : struct cmd_show_tx_metadata_result *res = parsed_result;
12977 : :
12978 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12979 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
12980 : 0 : return;
12981 : : }
12982 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
12983 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
12984 : 0 : ports[res->cmd_pid].tx_metadata);
12985 : : }
12986 : : }
12987 : :
12988 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
12989 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12990 : : cmd_show, "show");
12991 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
12992 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12993 : : cmd_port, "port");
12994 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
12995 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
12996 : : cmd_pid, RTE_UINT16);
12997 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
12998 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12999 : : cmd_keyword, "tx_metadata");
13000 : :
13001 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
13002 : : .f = cmd_show_tx_metadata_parsed,
13003 : : .data = NULL,
13004 : : .help_str = "show port <port_id> tx_metadata",
13005 : : .tokens = {
13006 : : (void *)&cmd_show_tx_metadata_show,
13007 : : (void *)&cmd_show_tx_metadata_port,
13008 : : (void *)&cmd_show_tx_metadata_pid,
13009 : : (void *)&cmd_show_tx_metadata_keyword,
13010 : : NULL,
13011 : : },
13012 : : };
13013 : :
13014 : : /* *** show fec capability per port configuration *** */
13015 : : struct cmd_show_fec_capability_result {
13016 : : cmdline_fixed_string_t cmd_show;
13017 : : cmdline_fixed_string_t cmd_port;
13018 : : cmdline_fixed_string_t cmd_fec;
13019 : : cmdline_fixed_string_t cmd_keyword;
13020 : : portid_t cmd_pid;
13021 : : };
13022 : :
13023 : : static void
13024 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
13025 : : __rte_unused struct cmdline *cl,
13026 : : __rte_unused void *data)
13027 : : {
13028 : : struct cmd_show_fec_capability_result *res = parsed_result;
13029 : : struct rte_eth_fec_capa *speed_fec_capa;
13030 : : unsigned int num;
13031 : : int ret;
13032 : :
13033 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13034 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13035 : 0 : return;
13036 : : }
13037 : :
13038 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
13039 : 0 : if (ret == -ENOTSUP) {
13040 : 0 : fprintf(stderr, "Function not implemented\n");
13041 : 0 : return;
13042 : 0 : } else if (ret < 0) {
13043 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
13044 : 0 : return;
13045 : : }
13046 : :
13047 : 0 : num = (unsigned int)ret;
13048 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
13049 : 0 : if (speed_fec_capa == NULL) {
13050 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
13051 : 0 : return;
13052 : : }
13053 : :
13054 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
13055 : 0 : if (ret < 0) {
13056 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
13057 : 0 : goto out;
13058 : : }
13059 : :
13060 : 0 : show_fec_capability(num, speed_fec_capa);
13061 : 0 : out:
13062 : 0 : free(speed_fec_capa);
13063 : : }
13064 : :
13065 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
13066 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13067 : : cmd_show, "show");
13068 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
13069 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13070 : : cmd_port, "port");
13071 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
13072 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
13073 : : cmd_pid, RTE_UINT16);
13074 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
13075 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13076 : : cmd_fec, "fec");
13077 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
13078 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13079 : : cmd_keyword, "capabilities");
13080 : :
13081 : : static cmdline_parse_inst_t cmd_show_capability = {
13082 : : .f = cmd_show_fec_capability_parsed,
13083 : : .data = NULL,
13084 : : .help_str = "show port <port_id> fec capabilities",
13085 : : .tokens = {
13086 : : (void *)&cmd_show_fec_capability_show,
13087 : : (void *)&cmd_show_fec_capability_port,
13088 : : (void *)&cmd_show_fec_capability_pid,
13089 : : (void *)&cmd_show_fec_capability_fec,
13090 : : (void *)&cmd_show_fec_capability_keyword,
13091 : : NULL,
13092 : : },
13093 : : };
13094 : :
13095 : : /* *** show fec mode per port configuration *** */
13096 : : struct cmd_show_fec_metadata_result {
13097 : : cmdline_fixed_string_t cmd_show;
13098 : : cmdline_fixed_string_t cmd_port;
13099 : : cmdline_fixed_string_t cmd_keyword;
13100 : : portid_t cmd_pid;
13101 : : };
13102 : :
13103 : : static void
13104 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
13105 : : __rte_unused struct cmdline *cl,
13106 : : __rte_unused void *data)
13107 : : {
13108 : : #define FEC_NAME_SIZE 16
13109 : : struct cmd_show_fec_metadata_result *res = parsed_result;
13110 : : uint32_t mode;
13111 : : char buf[FEC_NAME_SIZE];
13112 : : int ret;
13113 : :
13114 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13115 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13116 : 0 : return;
13117 : : }
13118 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
13119 : 0 : if (ret == -ENOTSUP) {
13120 : 0 : fprintf(stderr, "Function not implemented\n");
13121 : 0 : return;
13122 : 0 : } else if (ret < 0) {
13123 : 0 : fprintf(stderr, "Get FEC mode failed\n");
13124 : 0 : return;
13125 : : }
13126 : :
13127 : 0 : switch (mode) {
13128 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
13129 : : strlcpy(buf, "off", sizeof(buf));
13130 : : break;
13131 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
13132 : : strlcpy(buf, "auto", sizeof(buf));
13133 : : break;
13134 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
13135 : : strlcpy(buf, "baser", sizeof(buf));
13136 : : break;
13137 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
13138 : : strlcpy(buf, "rs", sizeof(buf));
13139 : : break;
13140 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
13141 : : strlcpy(buf, "llrs", sizeof(buf));
13142 : : break;
13143 : : default:
13144 : : return;
13145 : : }
13146 : :
13147 : : printf("%s\n", buf);
13148 : : }
13149 : :
13150 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
13151 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13152 : : cmd_show, "show");
13153 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
13154 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13155 : : cmd_port, "port");
13156 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
13157 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
13158 : : cmd_pid, RTE_UINT16);
13159 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
13160 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13161 : : cmd_keyword, "fec_mode");
13162 : :
13163 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
13164 : : .f = cmd_show_fec_mode_parsed,
13165 : : .data = NULL,
13166 : : .help_str = "show port <port_id> fec_mode",
13167 : : .tokens = {
13168 : : (void *)&cmd_show_fec_mode_show,
13169 : : (void *)&cmd_show_fec_mode_port,
13170 : : (void *)&cmd_show_fec_mode_pid,
13171 : : (void *)&cmd_show_fec_mode_keyword,
13172 : : NULL,
13173 : : },
13174 : : };
13175 : :
13176 : : /* *** set fec mode per port configuration *** */
13177 : : struct cmd_set_port_fec_mode {
13178 : : cmdline_fixed_string_t set;
13179 : : cmdline_fixed_string_t port;
13180 : : portid_t port_id;
13181 : : cmdline_fixed_string_t fec_mode;
13182 : : cmdline_fixed_string_t fec_value;
13183 : : };
13184 : :
13185 : : /* Common CLI fields for set fec mode */
13186 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
13187 : : TOKEN_STRING_INITIALIZER
13188 : : (struct cmd_set_port_fec_mode,
13189 : : set, "set");
13190 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
13191 : : TOKEN_STRING_INITIALIZER
13192 : : (struct cmd_set_port_fec_mode,
13193 : : port, "port");
13194 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
13195 : : TOKEN_NUM_INITIALIZER
13196 : : (struct cmd_set_port_fec_mode,
13197 : : port_id, RTE_UINT16);
13198 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
13199 : : TOKEN_STRING_INITIALIZER
13200 : : (struct cmd_set_port_fec_mode,
13201 : : fec_mode, "fec_mode");
13202 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
13203 : : TOKEN_STRING_INITIALIZER
13204 : : (struct cmd_set_port_fec_mode,
13205 : : fec_value, NULL);
13206 : :
13207 : : static void
13208 : 0 : cmd_set_port_fec_mode_parsed(
13209 : : void *parsed_result,
13210 : : __rte_unused struct cmdline *cl,
13211 : : __rte_unused void *data)
13212 : : {
13213 : : struct cmd_set_port_fec_mode *res = parsed_result;
13214 : 0 : uint16_t port_id = res->port_id;
13215 : : uint32_t fec_capa;
13216 : : int ret;
13217 : :
13218 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
13219 : 0 : if (ret < 0) {
13220 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
13221 : : res->fec_value, port_id);
13222 : 0 : return;
13223 : : }
13224 : :
13225 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
13226 : 0 : if (ret == -ENOTSUP) {
13227 : 0 : fprintf(stderr, "Function not implemented\n");
13228 : 0 : return;
13229 : 0 : } else if (ret < 0) {
13230 : 0 : fprintf(stderr, "Set FEC mode failed\n");
13231 : 0 : return;
13232 : : }
13233 : : }
13234 : :
13235 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
13236 : : .f = cmd_set_port_fec_mode_parsed,
13237 : : .data = NULL,
13238 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
13239 : : .tokens = {
13240 : : (void *)&cmd_set_port_fec_mode_set,
13241 : : (void *)&cmd_set_port_fec_mode_port,
13242 : : (void *)&cmd_set_port_fec_mode_port_id,
13243 : : (void *)&cmd_set_port_fec_mode_str,
13244 : : (void *)&cmd_set_port_fec_mode_value,
13245 : : NULL,
13246 : : },
13247 : : };
13248 : :
13249 : : /* *** set available descriptors threshold for an RxQ of a port *** */
13250 : : struct cmd_set_rxq_avail_thresh_result {
13251 : : cmdline_fixed_string_t set;
13252 : : cmdline_fixed_string_t port;
13253 : : uint16_t port_num;
13254 : : cmdline_fixed_string_t rxq;
13255 : : uint16_t rxq_num;
13256 : : cmdline_fixed_string_t avail_thresh;
13257 : : uint8_t avail_thresh_num;
13258 : : };
13259 : :
13260 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
13261 : : __rte_unused struct cmdline *cl,
13262 : : __rte_unused void *data)
13263 : : {
13264 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
13265 : : int ret = 0;
13266 : :
13267 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
13268 : 0 : && (strcmp(res->rxq, "rxq") == 0)
13269 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
13270 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
13271 : 0 : res->avail_thresh_num);
13272 : 0 : if (ret < 0)
13273 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
13274 : :
13275 : 0 : }
13276 : :
13277 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
13278 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13279 : : set, "set");
13280 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
13281 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13282 : : port, "port");
13283 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
13284 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13285 : : port_num, RTE_UINT16);
13286 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
13287 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13288 : : rxq, "rxq");
13289 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
13290 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13291 : : rxq_num, RTE_UINT16);
13292 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
13293 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13294 : : avail_thresh, "avail_thresh");
13295 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
13296 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13297 : : avail_thresh_num, RTE_UINT8);
13298 : :
13299 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
13300 : : .f = cmd_set_rxq_avail_thresh_parsed,
13301 : : .data = (void *)0,
13302 : : .help_str =
13303 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
13304 : : "Set available descriptors threshold for Rx queue",
13305 : : .tokens = {
13306 : : (void *)&cmd_set_rxq_avail_thresh_set,
13307 : : (void *)&cmd_set_rxq_avail_thresh_port,
13308 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
13309 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
13310 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
13311 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
13312 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
13313 : : NULL,
13314 : : },
13315 : : };
13316 : :
13317 : : /* show port supported ptypes */
13318 : :
13319 : : /* Common result structure for show port ptypes */
13320 : : struct cmd_show_port_supported_ptypes_result {
13321 : : cmdline_fixed_string_t show;
13322 : : cmdline_fixed_string_t port;
13323 : : portid_t port_id;
13324 : : cmdline_fixed_string_t ptypes;
13325 : : };
13326 : :
13327 : : /* Common CLI fields for show port ptypes */
13328 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
13329 : : TOKEN_STRING_INITIALIZER
13330 : : (struct cmd_show_port_supported_ptypes_result,
13331 : : show, "show");
13332 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
13333 : : TOKEN_STRING_INITIALIZER
13334 : : (struct cmd_show_port_supported_ptypes_result,
13335 : : port, "port");
13336 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
13337 : : TOKEN_NUM_INITIALIZER
13338 : : (struct cmd_show_port_supported_ptypes_result,
13339 : : port_id, RTE_UINT16);
13340 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
13341 : : TOKEN_STRING_INITIALIZER
13342 : : (struct cmd_show_port_supported_ptypes_result,
13343 : : ptypes, "ptypes");
13344 : :
13345 : : static void
13346 : 0 : cmd_show_port_supported_ptypes_parsed(
13347 : : void *parsed_result,
13348 : : __rte_unused struct cmdline *cl,
13349 : : __rte_unused void *data)
13350 : : {
13351 : : #define RSVD_PTYPE_MASK 0xf0000000
13352 : : #define MAX_PTYPES_PER_LAYER 16
13353 : : #define LTYPE_NAMESIZE 32
13354 : : #define PTYPE_NAMESIZE 256
13355 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
13356 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
13357 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
13358 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
13359 : 0 : uint16_t port_id = res->port_id;
13360 : : int ret, i;
13361 : :
13362 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
13363 : 0 : if (ret < 0)
13364 : 0 : return;
13365 : :
13366 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
13367 : :
13368 : 0 : switch (ptype_mask) {
13369 : : case RTE_PTYPE_L2_MASK:
13370 : : strlcpy(ltype, "L2", sizeof(ltype));
13371 : : break;
13372 : : case RTE_PTYPE_L3_MASK:
13373 : : strlcpy(ltype, "L3", sizeof(ltype));
13374 : : break;
13375 : : case RTE_PTYPE_L4_MASK:
13376 : : strlcpy(ltype, "L4", sizeof(ltype));
13377 : : break;
13378 : : case RTE_PTYPE_TUNNEL_MASK:
13379 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
13380 : : break;
13381 : : case RTE_PTYPE_INNER_L2_MASK:
13382 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
13383 : : break;
13384 : : case RTE_PTYPE_INNER_L3_MASK:
13385 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
13386 : : break;
13387 : : case RTE_PTYPE_INNER_L4_MASK:
13388 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
13389 : : break;
13390 : : default:
13391 : : return;
13392 : : }
13393 : :
13394 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
13395 : : ptype_mask, ptypes,
13396 : : MAX_PTYPES_PER_LAYER);
13397 : :
13398 : 0 : if (ret > 0)
13399 : : printf("Supported %s ptypes:\n", ltype);
13400 : : else
13401 : : printf("%s ptypes unsupported\n", ltype);
13402 : :
13403 : 0 : for (i = 0; i < ret; ++i) {
13404 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
13405 : : printf("%s\n", buf);
13406 : : }
13407 : :
13408 : 0 : ptype_mask <<= 4;
13409 : : }
13410 : : }
13411 : :
13412 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
13413 : : .f = cmd_show_port_supported_ptypes_parsed,
13414 : : .data = NULL,
13415 : : .help_str = "show port <port_id> ptypes",
13416 : : .tokens = {
13417 : : (void *)&cmd_show_port_supported_ptypes_show,
13418 : : (void *)&cmd_show_port_supported_ptypes_port,
13419 : : (void *)&cmd_show_port_supported_ptypes_port_id,
13420 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
13421 : : NULL,
13422 : : },
13423 : : };
13424 : :
13425 : : /* *** display rx/tx descriptor status *** */
13426 : : struct cmd_show_rx_tx_desc_status_result {
13427 : : cmdline_fixed_string_t cmd_show;
13428 : : cmdline_fixed_string_t cmd_port;
13429 : : cmdline_fixed_string_t cmd_keyword;
13430 : : cmdline_fixed_string_t cmd_desc;
13431 : : cmdline_fixed_string_t cmd_status;
13432 : : portid_t cmd_pid;
13433 : : portid_t cmd_qid;
13434 : : portid_t cmd_did;
13435 : : };
13436 : :
13437 : : static void
13438 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
13439 : : __rte_unused struct cmdline *cl,
13440 : : __rte_unused void *data)
13441 : : {
13442 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
13443 : : int rc;
13444 : :
13445 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
13446 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13447 : 0 : fprintf(stderr,
13448 : : "Invalid input: port id = %d, queue id = %d\n",
13449 : 0 : res->cmd_pid, res->cmd_qid);
13450 : 0 : return;
13451 : : }
13452 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
13453 : 0 : res->cmd_did);
13454 : 0 : if (rc < 0) {
13455 : 0 : fprintf(stderr,
13456 : : "Invalid input: queue id = %d, desc id = %d\n",
13457 : 0 : res->cmd_qid, res->cmd_did);
13458 : 0 : return;
13459 : : }
13460 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
13461 : : printf("Desc status = AVAILABLE\n");
13462 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
13463 : : printf("Desc status = DONE\n");
13464 : : else
13465 : : printf("Desc status = UNAVAILABLE\n");
13466 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
13467 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13468 : 0 : fprintf(stderr,
13469 : : "Invalid input: port id = %d, queue id = %d\n",
13470 : 0 : res->cmd_pid, res->cmd_qid);
13471 : 0 : return;
13472 : : }
13473 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
13474 : 0 : res->cmd_did);
13475 : 0 : if (rc < 0) {
13476 : 0 : fprintf(stderr,
13477 : : "Invalid input: queue id = %d, desc id = %d\n",
13478 : 0 : res->cmd_qid, res->cmd_did);
13479 : 0 : return;
13480 : : }
13481 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
13482 : : printf("Desc status = FULL\n");
13483 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
13484 : : printf("Desc status = DONE\n");
13485 : : else
13486 : : printf("Desc status = UNAVAILABLE\n");
13487 : : }
13488 : : }
13489 : :
13490 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
13491 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13492 : : cmd_show, "show");
13493 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
13494 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13495 : : cmd_port, "port");
13496 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
13497 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13498 : : cmd_pid, RTE_UINT16);
13499 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
13500 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13501 : : cmd_keyword, "rxq#txq");
13502 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
13503 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13504 : : cmd_qid, RTE_UINT16);
13505 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
13506 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13507 : : cmd_desc, "desc");
13508 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
13509 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13510 : : cmd_did, RTE_UINT16);
13511 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
13512 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13513 : : cmd_status, "status");
13514 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
13515 : : .f = cmd_show_rx_tx_desc_status_parsed,
13516 : : .data = NULL,
13517 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
13518 : : "status",
13519 : : .tokens = {
13520 : : (void *)&cmd_show_rx_tx_desc_status_show,
13521 : : (void *)&cmd_show_rx_tx_desc_status_port,
13522 : : (void *)&cmd_show_rx_tx_desc_status_pid,
13523 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
13524 : : (void *)&cmd_show_rx_tx_desc_status_qid,
13525 : : (void *)&cmd_show_rx_tx_desc_status_desc,
13526 : : (void *)&cmd_show_rx_tx_desc_status_did,
13527 : : (void *)&cmd_show_rx_tx_desc_status_status,
13528 : : NULL,
13529 : : },
13530 : : };
13531 : :
13532 : : /* *** display rx/tx queue descriptor used count *** */
13533 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
13534 : : cmdline_fixed_string_t cmd_show;
13535 : : cmdline_fixed_string_t cmd_port;
13536 : : cmdline_fixed_string_t cmd_dir;
13537 : : cmdline_fixed_string_t cmd_desc;
13538 : : cmdline_fixed_string_t cmd_used;
13539 : : cmdline_fixed_string_t cmd_count;
13540 : : portid_t cmd_pid;
13541 : : portid_t cmd_qid;
13542 : : };
13543 : :
13544 : : static void
13545 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
13546 : : __rte_unused void *data)
13547 : : {
13548 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
13549 : : int rc;
13550 : :
13551 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
13552 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13553 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13554 : 0 : res->cmd_pid, res->cmd_qid);
13555 : 0 : return;
13556 : : }
13557 : :
13558 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
13559 : 0 : if (rc < 0) {
13560 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
13561 : 0 : res->cmd_qid);
13562 : 0 : return;
13563 : : }
13564 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
13565 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
13566 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13567 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13568 : 0 : res->cmd_pid, res->cmd_qid);
13569 : 0 : return;
13570 : : }
13571 : :
13572 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
13573 : 0 : if (rc < 0) {
13574 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
13575 : 0 : res->cmd_qid);
13576 : 0 : return;
13577 : : }
13578 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
13579 : : }
13580 : : }
13581 : :
13582 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
13583 : : TOKEN_STRING_INITIALIZER
13584 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13585 : : cmd_show, "show");
13586 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
13587 : : TOKEN_STRING_INITIALIZER
13588 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13589 : : cmd_port, "port");
13590 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
13591 : : TOKEN_NUM_INITIALIZER
13592 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13593 : : cmd_pid, RTE_UINT16);
13594 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
13595 : : TOKEN_STRING_INITIALIZER
13596 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13597 : : cmd_dir, "rxq#txq");
13598 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
13599 : : TOKEN_NUM_INITIALIZER
13600 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13601 : : cmd_qid, RTE_UINT16);
13602 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
13603 : : TOKEN_STRING_INITIALIZER
13604 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13605 : : cmd_desc, "desc");
13606 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
13607 : : TOKEN_STRING_INITIALIZER
13608 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13609 : : cmd_count, "used");
13610 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
13611 : : TOKEN_STRING_INITIALIZER
13612 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13613 : : cmd_count, "count");
13614 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
13615 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
13616 : : .data = NULL,
13617 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
13618 : : .tokens = {
13619 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
13620 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
13621 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
13622 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
13623 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
13624 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
13625 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
13626 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
13627 : : NULL,
13628 : : },
13629 : : };
13630 : :
13631 : : /* Common result structure for set port ptypes */
13632 : : struct cmd_set_port_ptypes_result {
13633 : : cmdline_fixed_string_t set;
13634 : : cmdline_fixed_string_t port;
13635 : : portid_t port_id;
13636 : : cmdline_fixed_string_t ptype_mask;
13637 : : uint32_t mask;
13638 : : };
13639 : :
13640 : : /* Common CLI fields for set port ptypes */
13641 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
13642 : : TOKEN_STRING_INITIALIZER
13643 : : (struct cmd_set_port_ptypes_result,
13644 : : set, "set");
13645 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
13646 : : TOKEN_STRING_INITIALIZER
13647 : : (struct cmd_set_port_ptypes_result,
13648 : : port, "port");
13649 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
13650 : : TOKEN_NUM_INITIALIZER
13651 : : (struct cmd_set_port_ptypes_result,
13652 : : port_id, RTE_UINT16);
13653 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
13654 : : TOKEN_STRING_INITIALIZER
13655 : : (struct cmd_set_port_ptypes_result,
13656 : : ptype_mask, "ptype_mask");
13657 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
13658 : : TOKEN_NUM_INITIALIZER
13659 : : (struct cmd_set_port_ptypes_result,
13660 : : mask, RTE_UINT32);
13661 : :
13662 : : static void
13663 : 0 : cmd_set_port_ptypes_parsed(
13664 : : void *parsed_result,
13665 : : __rte_unused struct cmdline *cl,
13666 : : __rte_unused void *data)
13667 : : {
13668 : : struct cmd_set_port_ptypes_result *res = parsed_result;
13669 : : #define PTYPE_NAMESIZE 256
13670 : : char ptype_name[PTYPE_NAMESIZE];
13671 : 0 : uint16_t port_id = res->port_id;
13672 : 0 : uint32_t ptype_mask = res->mask;
13673 : : int ret, i;
13674 : :
13675 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
13676 : : NULL, 0);
13677 : 0 : if (ret <= 0) {
13678 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
13679 : : port_id);
13680 : 0 : return;
13681 : : }
13682 : :
13683 : 0 : uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
13684 : :
13685 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
13686 : 0 : if (ret < 0) {
13687 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
13688 : : port_id);
13689 : 0 : return;
13690 : : }
13691 : :
13692 : : printf("Successfully set following ptypes for Port %d\n", port_id);
13693 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
13694 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
13695 : : printf("%s\n", ptype_name);
13696 : : }
13697 : :
13698 : 0 : clear_ptypes = false;
13699 : : }
13700 : :
13701 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
13702 : : .f = cmd_set_port_ptypes_parsed,
13703 : : .data = NULL,
13704 : : .help_str = "set port <port_id> ptype_mask <mask>",
13705 : : .tokens = {
13706 : : (void *)&cmd_set_port_ptypes_set,
13707 : : (void *)&cmd_set_port_ptypes_port,
13708 : : (void *)&cmd_set_port_ptypes_port_id,
13709 : : (void *)&cmd_set_port_ptypes_mask_str,
13710 : : (void *)&cmd_set_port_ptypes_mask_u32,
13711 : : NULL,
13712 : : },
13713 : : };
13714 : :
13715 : : /* *** display mac addresses added to a port *** */
13716 : : struct cmd_showport_macs_result {
13717 : : cmdline_fixed_string_t cmd_show;
13718 : : cmdline_fixed_string_t cmd_port;
13719 : : cmdline_fixed_string_t cmd_keyword;
13720 : : portid_t cmd_pid;
13721 : : };
13722 : :
13723 : : static void
13724 : 0 : cmd_showport_macs_parsed(void *parsed_result,
13725 : : __rte_unused struct cmdline *cl,
13726 : : __rte_unused void *data)
13727 : : {
13728 : : struct cmd_showport_macs_result *res = parsed_result;
13729 : :
13730 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
13731 : : return;
13732 : :
13733 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
13734 : 0 : show_macs(res->cmd_pid);
13735 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
13736 : 0 : show_mcast_macs(res->cmd_pid);
13737 : : }
13738 : :
13739 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
13740 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13741 : : cmd_show, "show");
13742 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
13743 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13744 : : cmd_port, "port");
13745 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
13746 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
13747 : : cmd_pid, RTE_UINT16);
13748 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
13749 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13750 : : cmd_keyword, "macs#mcast_macs");
13751 : :
13752 : : static cmdline_parse_inst_t cmd_showport_macs = {
13753 : : .f = cmd_showport_macs_parsed,
13754 : : .data = NULL,
13755 : : .help_str = "show port <port_id> macs|mcast_macs",
13756 : : .tokens = {
13757 : : (void *)&cmd_showport_macs_show,
13758 : : (void *)&cmd_showport_macs_port,
13759 : : (void *)&cmd_showport_macs_pid,
13760 : : (void *)&cmd_showport_macs_keyword,
13761 : : NULL,
13762 : : },
13763 : : };
13764 : :
13765 : : /* *** show flow transfer proxy port ID for the given port *** */
13766 : : struct cmd_show_port_flow_transfer_proxy_result {
13767 : : cmdline_fixed_string_t show;
13768 : : cmdline_fixed_string_t port;
13769 : : portid_t port_id;
13770 : : cmdline_fixed_string_t flow;
13771 : : cmdline_fixed_string_t transfer;
13772 : : cmdline_fixed_string_t proxy;
13773 : : };
13774 : :
13775 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
13776 : : TOKEN_STRING_INITIALIZER
13777 : : (struct cmd_show_port_flow_transfer_proxy_result,
13778 : : show, "show");
13779 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
13780 : : TOKEN_STRING_INITIALIZER
13781 : : (struct cmd_show_port_flow_transfer_proxy_result,
13782 : : port, "port");
13783 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
13784 : : TOKEN_NUM_INITIALIZER
13785 : : (struct cmd_show_port_flow_transfer_proxy_result,
13786 : : port_id, RTE_UINT16);
13787 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
13788 : : TOKEN_STRING_INITIALIZER
13789 : : (struct cmd_show_port_flow_transfer_proxy_result,
13790 : : flow, "flow");
13791 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
13792 : : TOKEN_STRING_INITIALIZER
13793 : : (struct cmd_show_port_flow_transfer_proxy_result,
13794 : : transfer, "transfer");
13795 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
13796 : : TOKEN_STRING_INITIALIZER
13797 : : (struct cmd_show_port_flow_transfer_proxy_result,
13798 : : proxy, "proxy");
13799 : :
13800 : : static void
13801 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
13802 : : __rte_unused struct cmdline *cl,
13803 : : __rte_unused void *data)
13804 : : {
13805 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
13806 : : portid_t proxy_port_id;
13807 : : int ret;
13808 : :
13809 : : printf("\n");
13810 : :
13811 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
13812 : 0 : if (ret != 0) {
13813 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
13814 : : rte_strerror(-ret));
13815 : 0 : return;
13816 : : }
13817 : :
13818 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
13819 : : }
13820 : :
13821 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
13822 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
13823 : : .data = NULL,
13824 : : .help_str = "show port <port_id> flow transfer proxy",
13825 : : .tokens = {
13826 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
13827 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
13828 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
13829 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
13830 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
13831 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
13832 : : NULL,
13833 : : }
13834 : : };
13835 : :
13836 : : /* *** configure port txq affinity value *** */
13837 : : struct cmd_config_tx_affinity_map {
13838 : : cmdline_fixed_string_t port;
13839 : : cmdline_fixed_string_t config;
13840 : : portid_t portid;
13841 : : cmdline_fixed_string_t txq;
13842 : : uint16_t qid;
13843 : : cmdline_fixed_string_t affinity;
13844 : : uint8_t value;
13845 : : };
13846 : :
13847 : : static void
13848 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
13849 : : __rte_unused struct cmdline *cl,
13850 : : __rte_unused void *data)
13851 : : {
13852 : : struct cmd_config_tx_affinity_map *res = parsed_result;
13853 : : int ret;
13854 : :
13855 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
13856 : : return;
13857 : :
13858 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
13859 : : printf("Invalid port id\n");
13860 : 0 : return;
13861 : : }
13862 : :
13863 : 0 : if (strcmp(res->txq, "txq")) {
13864 : : printf("Unknown parameter\n");
13865 : 0 : return;
13866 : : }
13867 : 0 : if (tx_queue_id_is_invalid(res->qid))
13868 : : return;
13869 : :
13870 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
13871 : 0 : if (ret < 0) {
13872 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
13873 : : strerror(-ret));
13874 : 0 : return;
13875 : : }
13876 : :
13877 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
13878 : 0 : if (ret != 0) {
13879 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
13880 : : rte_strerror(-ret));
13881 : 0 : return;
13882 : : }
13883 : : }
13884 : :
13885 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
13886 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13887 : : port, "port");
13888 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
13889 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13890 : : config, "config");
13891 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
13892 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13893 : : portid, RTE_UINT16);
13894 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
13895 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13896 : : txq, "txq");
13897 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
13898 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13899 : : qid, RTE_UINT16);
13900 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
13901 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13902 : : affinity, "affinity");
13903 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
13904 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13905 : : value, RTE_UINT8);
13906 : :
13907 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
13908 : : .f = cmd_config_tx_affinity_map_parsed,
13909 : : .data = (void *)0,
13910 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
13911 : : .tokens = {
13912 : : (void *)&cmd_config_tx_affinity_map_port,
13913 : : (void *)&cmd_config_tx_affinity_map_config,
13914 : : (void *)&cmd_config_tx_affinity_map_portid,
13915 : : (void *)&cmd_config_tx_affinity_map_txq,
13916 : : (void *)&cmd_config_tx_affinity_map_qid,
13917 : : (void *)&cmd_config_tx_affinity_map_affinity,
13918 : : (void *)&cmd_config_tx_affinity_map_value,
13919 : : NULL,
13920 : : },
13921 : : };
13922 : :
13923 : : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
13924 : : struct cmd_dev_led_result {
13925 : : cmdline_fixed_string_t set;
13926 : : cmdline_fixed_string_t port;
13927 : : portid_t port_id;
13928 : : cmdline_fixed_string_t led;
13929 : : cmdline_fixed_string_t state;
13930 : : };
13931 : :
13932 : : static void
13933 : 0 : cmd_set_dev_led_parsed(void *parsed_result,
13934 : : __rte_unused struct cmdline *cl,
13935 : : __rte_unused void *data)
13936 : : {
13937 : : struct cmd_dev_led_result *res = parsed_result;
13938 : :
13939 : 0 : if (strcmp(res->state, "on") == 0)
13940 : 0 : set_dev_led(res->port_id, true);
13941 : : else
13942 : 0 : set_dev_led(res->port_id, false);
13943 : 0 : }
13944 : :
13945 : : static cmdline_parse_token_string_t cmd_dev_led_set =
13946 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
13947 : : static cmdline_parse_token_string_t cmd_dev_led_port =
13948 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
13949 : : static cmdline_parse_token_num_t cmd_dev_led_port_id =
13950 : : TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
13951 : : static cmdline_parse_token_string_t cmd_dev_led =
13952 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
13953 : : static cmdline_parse_token_string_t cmd_dev_state =
13954 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
13955 : :
13956 : : static cmdline_parse_inst_t cmd_set_dev_led = {
13957 : : .f = cmd_set_dev_led_parsed,
13958 : : .data = NULL,
13959 : : .help_str = "set port <port_id> led <on/off>",
13960 : : .tokens = {
13961 : : (void *)&cmd_dev_led_set,
13962 : : (void *)&cmd_dev_led_port,
13963 : : (void *)&cmd_dev_led_port_id,
13964 : : (void *)&cmd_dev_led,
13965 : : (void *)&cmd_dev_state,
13966 : : NULL,
13967 : : },
13968 : : };
13969 : :
13970 : : /* ******************************************************************************** */
13971 : :
13972 : : /* list of instructions */
13973 : : static cmdline_parse_ctx_t builtin_ctx[] = {
13974 : : &cmd_help_brief,
13975 : : &cmd_help_long,
13976 : : &cmd_quit,
13977 : : &cmd_load_from_file,
13978 : : &cmd_load_echo_file,
13979 : : &cmd_showport,
13980 : : &cmd_showqueue,
13981 : : &cmd_showeeprom,
13982 : : &cmd_seteeprom,
13983 : : &cmd_showportall,
13984 : : &cmd_representor_info,
13985 : : &cmd_showdevice,
13986 : : &cmd_showcfg,
13987 : : &cmd_showfwdall,
13988 : : &cmd_start,
13989 : : &cmd_start_tx_first,
13990 : : &cmd_start_tx_first_n,
13991 : : &cmd_set_link_up,
13992 : : &cmd_set_link_down,
13993 : : &cmd_reset,
13994 : : &cmd_set_numbers,
13995 : : &cmd_set_log,
13996 : : &cmd_set_rxoffs,
13997 : : &cmd_set_rxpkts,
13998 : : &cmd_set_rxhdrs,
13999 : : &cmd_set_txpkts,
14000 : : &cmd_set_txsplit,
14001 : : &cmd_set_txtimes,
14002 : : &cmd_set_fwd_list,
14003 : : &cmd_set_fwd_mask,
14004 : : &cmd_set_fwd_mode,
14005 : : &cmd_set_fwd_retry_mode,
14006 : : &cmd_set_burst_tx_retry,
14007 : : &cmd_set_promisc_mode_one,
14008 : : &cmd_set_promisc_mode_all,
14009 : : &cmd_set_allmulti_mode_one,
14010 : : &cmd_set_allmulti_mode_all,
14011 : : &cmd_set_flush_rx,
14012 : : &cmd_set_link_check,
14013 : : &cmd_vlan_offload,
14014 : : &cmd_vlan_tpid,
14015 : : &cmd_rx_vlan_filter_all,
14016 : : &cmd_rx_vlan_filter,
14017 : : &cmd_tx_vlan_set,
14018 : : &cmd_tx_vlan_set_qinq,
14019 : : &cmd_tx_vlan_reset,
14020 : : &cmd_tx_vlan_set_pvid,
14021 : : &cmd_csum_set,
14022 : : &cmd_csum_show,
14023 : : &cmd_csum_tunnel,
14024 : : &cmd_csum_mac_swap,
14025 : : &cmd_tso_set,
14026 : : &cmd_tso_show,
14027 : : &cmd_tunnel_tso_set,
14028 : : &cmd_tunnel_tso_show,
14029 : : #ifdef RTE_LIB_GRO
14030 : : &cmd_gro_enable,
14031 : : &cmd_gro_flush,
14032 : : &cmd_gro_show,
14033 : : #endif
14034 : : #ifdef RTE_LIB_GSO
14035 : : &cmd_gso_enable,
14036 : : &cmd_gso_size,
14037 : : &cmd_gso_show,
14038 : : #endif
14039 : : &cmd_link_flow_control_set,
14040 : : &cmd_link_flow_control_set_rx,
14041 : : &cmd_link_flow_control_set_tx,
14042 : : &cmd_link_flow_control_set_hw,
14043 : : &cmd_link_flow_control_set_lw,
14044 : : &cmd_link_flow_control_set_pt,
14045 : : &cmd_link_flow_control_set_xon,
14046 : : &cmd_link_flow_control_set_macfwd,
14047 : : &cmd_link_flow_control_set_autoneg,
14048 : : &cmd_link_flow_control_show,
14049 : : &cmd_priority_flow_control_set,
14050 : : &cmd_queue_priority_flow_control_set,
14051 : : &cmd_config_dcb,
14052 : : &cmd_read_rxd_txd,
14053 : : &cmd_stop,
14054 : : &cmd_mac_addr,
14055 : : &cmd_set_fwd_eth_peer,
14056 : : &cmd_set_xstats_hide_zero,
14057 : : &cmd_set_xstats_show_state,
14058 : : &cmd_set_xstats_hide_disabled,
14059 : : &cmd_operate_set_counter,
14060 : : &cmd_set_record_core_cycles,
14061 : : &cmd_set_record_burst_stats,
14062 : : &cmd_operate_port,
14063 : : &cmd_operate_specific_port,
14064 : : &cmd_operate_attach_port,
14065 : : &cmd_operate_detach_port,
14066 : : &cmd_operate_detach_device,
14067 : : &cmd_set_port_setup_on,
14068 : : &cmd_config_speed_all,
14069 : : &cmd_config_speed_specific,
14070 : : &cmd_config_speed_lanes_all,
14071 : : &cmd_config_speed_lanes_specific,
14072 : : &cmd_show_speed_lanes,
14073 : : &cmd_config_loopback_all,
14074 : : &cmd_config_loopback_specific,
14075 : : &cmd_config_rx_tx,
14076 : : &cmd_config_mtu,
14077 : : &cmd_config_max_pkt_len,
14078 : : &cmd_config_max_lro_pkt_size,
14079 : : &cmd_config_rx_mode_flag,
14080 : : &cmd_config_rss,
14081 : : &cmd_config_rxtx_ring_size,
14082 : : &cmd_config_rxtx_queue,
14083 : : &cmd_config_deferred_start_rxtx_queue,
14084 : : &cmd_setup_rxtx_queue,
14085 : : &cmd_config_rss_reta,
14086 : : &cmd_showport_reta,
14087 : : &cmd_showport_macs,
14088 : : &cmd_show_port_flow_transfer_proxy,
14089 : : &cmd_config_burst,
14090 : : &cmd_config_thresh,
14091 : : &cmd_config_threshold,
14092 : : &cmd_set_uc_hash_filter,
14093 : : &cmd_set_uc_all_hash_filter,
14094 : : &cmd_vf_mac_addr_filter,
14095 : : &cmd_queue_rate_limit,
14096 : : &cmd_tunnel_udp_config,
14097 : : &cmd_showport_rss_hash,
14098 : : &cmd_showport_rss_hash_key,
14099 : : &cmd_showport_rss_hash_algo,
14100 : : &cmd_config_rss_hash_key,
14101 : : &cmd_config_rss_hash_algo,
14102 : : &cmd_cleanup_txq_mbufs,
14103 : : &cmd_dump_simple,
14104 : : &cmd_dump_named,
14105 : : &cmd_dump_mbuf_history_stdout,
14106 : : &cmd_dump_mbuf_history_to_file,
14107 : : &cmd_dump_mbuf_pool_history_stdout,
14108 : : &cmd_dump_mbuf_pool_history_to_file,
14109 : : &cmd_flow,
14110 : : &cmd_show_port_meter_cap,
14111 : : &cmd_add_port_meter_profile_srtcm,
14112 : : &cmd_add_port_meter_profile_trtcm,
14113 : : &cmd_add_port_meter_profile_trtcm_rfc4115,
14114 : : &cmd_del_port_meter_profile,
14115 : : &cmd_create_port_meter,
14116 : : &cmd_enable_port_meter,
14117 : : &cmd_disable_port_meter,
14118 : : &cmd_del_port_meter,
14119 : : &cmd_del_port_meter_policy,
14120 : : &cmd_set_port_meter_profile,
14121 : : &cmd_set_port_meter_dscp_table,
14122 : : &cmd_set_port_meter_vlan_table,
14123 : : &cmd_set_port_meter_in_proto,
14124 : : &cmd_get_port_meter_in_proto,
14125 : : &cmd_get_port_meter_in_proto_prio,
14126 : : &cmd_set_port_meter_stats_mask,
14127 : : &cmd_show_port_meter_stats,
14128 : : &cmd_mcast_addr,
14129 : : &cmd_mcast_addr_flush,
14130 : : &cmd_set_vf_vlan_anti_spoof,
14131 : : &cmd_set_vf_mac_anti_spoof,
14132 : : &cmd_set_vf_vlan_stripq,
14133 : : &cmd_set_vf_vlan_insert,
14134 : : &cmd_set_tx_loopback,
14135 : : &cmd_set_all_queues_drop_en,
14136 : : &cmd_set_vf_traffic,
14137 : : &cmd_set_vf_rxmode,
14138 : : &cmd_vf_rate_limit,
14139 : : &cmd_vf_rxvlan_filter,
14140 : : &cmd_set_vf_mac_addr,
14141 : : &cmd_set_vxlan,
14142 : : &cmd_set_vxlan_tos_ttl,
14143 : : &cmd_set_vxlan_with_vlan,
14144 : : &cmd_set_nvgre,
14145 : : &cmd_set_nvgre_with_vlan,
14146 : : &cmd_set_l2_encap,
14147 : : &cmd_set_l2_encap_with_vlan,
14148 : : &cmd_set_l2_decap,
14149 : : &cmd_set_l2_decap_with_vlan,
14150 : : &cmd_set_mplsogre_encap,
14151 : : &cmd_set_mplsogre_encap_with_vlan,
14152 : : &cmd_set_mplsogre_decap,
14153 : : &cmd_set_mplsogre_decap_with_vlan,
14154 : : &cmd_set_mplsoudp_encap,
14155 : : &cmd_set_mplsoudp_encap_with_vlan,
14156 : : &cmd_set_mplsoudp_decap,
14157 : : &cmd_set_mplsoudp_decap_with_vlan,
14158 : : &cmd_set_conntrack_common,
14159 : : &cmd_set_conntrack_dir,
14160 : : &cmd_show_vf_stats,
14161 : : &cmd_clear_vf_stats,
14162 : : &cmd_show_port_supported_ptypes,
14163 : : &cmd_set_port_ptypes,
14164 : : &cmd_show_port_tm_cap,
14165 : : &cmd_show_port_tm_level_cap,
14166 : : &cmd_show_port_tm_node,
14167 : : &cmd_show_port_tm_node_cap,
14168 : : &cmd_show_port_tm_node_type,
14169 : : &cmd_show_port_tm_node_stats,
14170 : : &cmd_add_port_tm_node_shaper_profile,
14171 : : &cmd_del_port_tm_node_shaper_profile,
14172 : : &cmd_add_port_tm_node_shared_shaper,
14173 : : &cmd_del_port_tm_node_shared_shaper,
14174 : : &cmd_add_port_tm_node_wred_profile,
14175 : : &cmd_del_port_tm_node_wred_profile,
14176 : : &cmd_set_port_tm_node_shaper_profile,
14177 : : &cmd_add_port_tm_nonleaf_node,
14178 : : &cmd_add_port_tm_nonleaf_node_pmode,
14179 : : &cmd_add_port_tm_leaf_node,
14180 : : &cmd_del_port_tm_node,
14181 : : &cmd_set_port_tm_node_parent,
14182 : : &cmd_suspend_port_tm_node,
14183 : : &cmd_resume_port_tm_node,
14184 : : &cmd_port_tm_hierarchy_commit,
14185 : : &cmd_port_tm_mark_ip_ecn,
14186 : : &cmd_port_tm_mark_ip_dscp,
14187 : : &cmd_port_tm_mark_vlan_dei,
14188 : : &cmd_cfg_tunnel_udp_port,
14189 : : &cmd_rx_offload_get_capa,
14190 : : &cmd_rx_offload_get_configuration,
14191 : : &cmd_config_per_port_rx_offload,
14192 : : &cmd_config_all_port_rx_offload,
14193 : : &cmd_config_per_queue_rx_offload,
14194 : : &cmd_tx_offload_get_capa,
14195 : : &cmd_tx_offload_get_configuration,
14196 : : &cmd_config_per_port_tx_offload,
14197 : : &cmd_config_all_port_tx_offload,
14198 : : &cmd_config_per_queue_tx_offload,
14199 : : #ifdef RTE_LIB_BPF
14200 : : &cmd_operate_bpf_ld_parse,
14201 : : &cmd_operate_bpf_unld_parse,
14202 : : #endif
14203 : : &cmd_config_tx_metadata_specific,
14204 : : &cmd_show_tx_metadata,
14205 : : &cmd_show_rx_tx_desc_status,
14206 : : &cmd_show_rx_tx_queue_desc_used_count,
14207 : : &cmd_set_raw,
14208 : : &cmd_show_set_raw,
14209 : : &cmd_show_set_raw_all,
14210 : : &cmd_config_tx_dynf_specific,
14211 : : &cmd_show_fec_mode,
14212 : : &cmd_set_fec_mode,
14213 : : &cmd_set_rxq_avail_thresh,
14214 : : &cmd_show_capability,
14215 : : &cmd_set_flex_is_pattern,
14216 : : &cmd_set_flex_spec_pattern,
14217 : : &cmd_show_port_cman_capa,
14218 : : &cmd_show_port_cman_config,
14219 : : &cmd_set_port_cman_config,
14220 : : &cmd_config_tx_affinity_map,
14221 : : &cmd_set_dev_led,
14222 : : NULL,
14223 : : };
14224 : :
14225 : : void
14226 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
14227 : : {
14228 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
14229 : 0 : }
14230 : :
14231 : : int
14232 : 0 : init_cmdline(void)
14233 : : {
14234 : : struct testpmd_driver_commands *c;
14235 : : unsigned int count;
14236 : : unsigned int i;
14237 : :
14238 : : /* initialize non-constant commands */
14239 : 0 : cmd_set_fwd_mode_init();
14240 : 0 : cmd_set_fwd_retry_mode_init();
14241 : :
14242 : : count = 0;
14243 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
14244 : 0 : count++;
14245 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14246 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
14247 : 0 : count++;
14248 : : }
14249 : :
14250 : : /* cmdline expects a NULL terminated array */
14251 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
14252 : 0 : if (main_ctx == NULL)
14253 : : return -1;
14254 : :
14255 : : count = 0;
14256 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
14257 : 0 : main_ctx[count] = builtin_ctx[i];
14258 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14259 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
14260 : 0 : main_ctx[count] = c->commands[i].ctx;
14261 : : }
14262 : :
14263 : : return 0;
14264 : : }
14265 : :
14266 : : /* read cmdline commands from file */
14267 : : int
14268 : 0 : cmdline_read_from_file(const char *filename, bool echo)
14269 : : {
14270 : : struct cmdline *cl;
14271 : : int fd = -1;
14272 : : int ret = 0;
14273 : :
14274 : : /* cmdline_file_new does not produce any output
14275 : : * so when echoing is requested we open filename directly
14276 : : * and then pass that to cmdline_new with stdout as the output path.
14277 : : */
14278 : 0 : if (!echo) {
14279 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14280 : : } else {
14281 : : /* use basename(filename) as prompt */
14282 : 0 : char prompt[32] = "[] ";
14283 : :
14284 : 0 : rte_basename(filename, &prompt[1], sizeof(prompt) - strlen(prompt));
14285 : 0 : strlcat(prompt, "] ", sizeof(prompt));
14286 : :
14287 : : fd = open(filename, O_RDONLY);
14288 : 0 : if (fd < 0) {
14289 : 0 : fprintf(stderr, "Failed to open file %s: %s\n",
14290 : 0 : filename, strerror(errno));
14291 : 0 : return -1;
14292 : : }
14293 : :
14294 : 0 : cl = cmdline_new(main_ctx, prompt, fd, STDOUT_FILENO);
14295 : : }
14296 : 0 : if (cl == NULL) {
14297 : 0 : fprintf(stderr,
14298 : : "Failed to create file based cmdline context: %s\n",
14299 : : filename);
14300 : : ret = -1;
14301 : 0 : goto end;
14302 : : }
14303 : :
14304 : 0 : cmdline_interact(cl);
14305 : : /* when done, if we have echo, we only need to print end of file,
14306 : : * but if no echo, we need to use printf and include the filename.
14307 : : */
14308 : 0 : if (echo)
14309 : 0 : cmdline_printf(cl, "<End-Of-File>\n");
14310 : : else
14311 : : printf("Finished reading CLI commands from %s\n", filename);
14312 : :
14313 : 0 : cmdline_quit(cl);
14314 : 0 : cmdline_free(cl);
14315 : :
14316 : :
14317 : 0 : end:
14318 : 0 : if (fd >= 0)
14319 : 0 : close(fd);
14320 : : return ret;
14321 : : }
14322 : :
14323 : : void
14324 : 0 : prompt_exit(void)
14325 : : {
14326 : 0 : cmdline_quit(testpmd_cl);
14327 : 0 : }
14328 : :
14329 : : /* prompt function, called from main on MAIN lcore */
14330 : : void
14331 : 0 : prompt(void)
14332 : : {
14333 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14334 : 0 : if (testpmd_cl == NULL) {
14335 : 0 : fprintf(stderr,
14336 : : "Failed to create stdin based cmdline context\n");
14337 : 0 : return;
14338 : : }
14339 : :
14340 : 0 : cmdline_interact(testpmd_cl);
14341 : 0 : cmdline_stdin_exit(testpmd_cl);
14342 : : }
14343 : :
14344 : : void
14345 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14346 : : {
14347 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
14348 : : portid_t pid;
14349 : :
14350 : 0 : RTE_ETH_FOREACH_DEV(pid) {
14351 : : /* check if need_reconfig has been set to 1 */
14352 : 0 : if (ports[pid].need_reconfig == 0)
14353 : 0 : ports[pid].need_reconfig = dev;
14354 : : /* check if need_reconfig_queues has been set to 1 */
14355 : 0 : if (ports[pid].need_reconfig_queues == 0)
14356 : 0 : ports[pid].need_reconfig_queues = queue;
14357 : : }
14358 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14359 : : /* check if need_reconfig has been set to 1 */
14360 : 0 : if (ports[id].need_reconfig == 0)
14361 : 0 : ports[id].need_reconfig = dev;
14362 : : /* check if need_reconfig_queues has been set to 1 */
14363 : 0 : if (ports[id].need_reconfig_queues == 0)
14364 : 0 : ports[id].need_reconfig_queues = queue;
14365 : : }
14366 : 0 : }
|