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|txtimes|dcbfwdtc)\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 txflows (N)\n"
388 : : " Set the number of flows per lcore in"
389 : : " txonly multi-flow mode (1-64)\n\n"
390 : :
391 : : "set corelist (x[,y]*)\n"
392 : : " Set the list of forwarding cores.\n\n"
393 : :
394 : : "set portlist (x[,y]*)\n"
395 : : " Set the list of forwarding ports.\n\n"
396 : :
397 : : "set port setup on (iterator|event)\n"
398 : : " Select how attached port is retrieved for setup.\n\n"
399 : :
400 : : "set tx loopback (port_id) (on|off)\n"
401 : : " Enable or disable tx loopback.\n\n"
402 : :
403 : : "set all queues drop (port_id) (on|off)\n"
404 : : " Set drop enable bit for all queues.\n\n"
405 : :
406 : : "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
407 : : " Set MAC antispoof for a VF from the PF.\n\n"
408 : :
409 : : "vlan set stripq (on|off) (port_id,queue_id)\n"
410 : : " Set the VLAN strip for a queue on a port.\n\n"
411 : :
412 : : "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
413 : : " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
414 : :
415 : : "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
416 : : " Set VLAN insert for a VF from the PF.\n\n"
417 : :
418 : : "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
419 : : " Set VLAN antispoof for a VF from the PF.\n\n"
420 : :
421 : : "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
422 : : " Set the VLAN strip or filter or qinq strip or extend\n\n"
423 : :
424 : : "vlan set (inner|outer) tpid (value) (port_id)\n"
425 : : " Set the VLAN TPID for Packet Filtering on"
426 : : " a port\n\n"
427 : :
428 : : "rx_vlan add (vlan_id|all) (port_id)\n"
429 : : " Add a vlan_id, or all identifiers, to the set"
430 : : " of VLAN identifiers filtered by port_id.\n\n"
431 : :
432 : : "rx_vlan rm (vlan_id|all) (port_id)\n"
433 : : " Remove a vlan_id, or all identifiers, from the set"
434 : : " of VLAN identifiers filtered by port_id.\n\n"
435 : :
436 : : "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
437 : : " Add a vlan_id, to the set of VLAN identifiers"
438 : : "filtered for VF(s) from port_id.\n\n"
439 : :
440 : : "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
441 : : " Remove a vlan_id, to the set of VLAN identifiers"
442 : : "filtered for VF(s) from port_id.\n\n"
443 : :
444 : : "rx_vxlan_port add (udp_port) (port_id)\n"
445 : : " Add an UDP port for VXLAN packet filter on a port\n\n"
446 : :
447 : : "rx_vxlan_port rm (udp_port) (port_id)\n"
448 : : " Remove an UDP port for VXLAN packet filter on a port\n\n"
449 : :
450 : : "tx_vlan set (port_id) vlan_tci[, vlan_tci_outer]\n"
451 : : " Set hardware insertion of VLAN TCI (single or double VLAN "
452 : : "depends on the number of VLAN TCIs) in packets sent on a port.\n\n"
453 : :
454 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
455 : : " Set port based TX VLAN insertion.\n\n"
456 : :
457 : : "tx_vlan reset (port_id)\n"
458 : : " Disable hardware insertion of a VLAN header in"
459 : : " packets sent on a port.\n\n"
460 : :
461 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
462 : : " Select hardware or software calculation of the"
463 : : " checksum when transmitting a packet using the"
464 : : " csum forward engine.\n"
465 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
466 : : " outer-ip concerns the outer IP layer in"
467 : : " outer-udp concerns the outer UDP layer in"
468 : : " case the packet is recognized as a tunnel packet by"
469 : : " the forward engine (vxlan, gre and ipip are supported)\n"
470 : : " Please check the NIC datasheet for HW limits.\n\n"
471 : :
472 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
473 : : " If disabled, treat tunnel packets as non-tunneled"
474 : : " packets (treat inner headers as payload). The port\n"
475 : : " argument is the port used for TX in csum forward"
476 : : " engine.\n\n"
477 : :
478 : : "csum show (port_id)\n"
479 : : " Display tx checksum offload configuration\n\n"
480 : :
481 : : "tso set (segsize) (portid)\n"
482 : : " Enable TCP Segmentation Offload in csum forward"
483 : : " engine.\n"
484 : : " Please check the NIC datasheet for HW limits.\n\n"
485 : :
486 : : "tso show (portid)"
487 : : " Display the status of TCP Segmentation Offload.\n\n"
488 : :
489 : : #ifdef RTE_LIB_GRO
490 : : "set port (port_id) gro on|off\n"
491 : : " Enable or disable Generic Receive Offload in"
492 : : " csum forwarding engine.\n\n"
493 : :
494 : : "show port (port_id) gro\n"
495 : : " Display GRO configuration.\n\n"
496 : :
497 : : "set gro flush (cycles)\n"
498 : : " Set the cycle to flush GROed packets from"
499 : : " reassembly tables.\n\n"
500 : : #endif
501 : :
502 : : #ifdef RTE_LIB_GSO
503 : : "set port (port_id) gso (on|off)"
504 : : " Enable or disable Generic Segmentation Offload in"
505 : : " csum forwarding engine.\n\n"
506 : :
507 : : "set gso segsz (length)\n"
508 : : " Set max packet length for output GSO segments,"
509 : : " including packet header and payload.\n\n"
510 : :
511 : : "show port (port_id) gso\n"
512 : : " Show GSO configuration.\n\n"
513 : : #endif
514 : :
515 : : "set fwd (%s)\n"
516 : : " Set packet forwarding mode.\n\n"
517 : :
518 : : "set dcb fwd_tc (tc_mask)\n"
519 : : " Set DCB forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled\n\n"
520 : :
521 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
522 : : " Add a MAC address on port_id.\n\n"
523 : :
524 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
525 : : " Remove a MAC address from port_id.\n\n"
526 : :
527 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
528 : : " Set the default MAC address for port_id.\n\n"
529 : :
530 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
531 : : " Add a MAC address for a VF on the port.\n\n"
532 : :
533 : : "mcast_addr add (port_id) (mcast_addr)\n"
534 : : " Add a multicast MAC addresses on port_id.\n\n"
535 : :
536 : : "mcast_addr remove (port_id) (mcast_addr)\n"
537 : : " Remove a multicast MAC address from port_id.\n\n"
538 : :
539 : : "mcast_addr flush (port_id)\n"
540 : : " Flush all multicast MAC addresses on port_id.\n\n"
541 : :
542 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
543 : : " Set the MAC address for a VF from the PF.\n\n"
544 : :
545 : : "set eth-peer (port_id) (peer_addr)\n"
546 : : " set the peer address for certain port.\n\n"
547 : :
548 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
549 : : " Add/Remove a or all unicast hash filter(s)"
550 : : "from port X.\n\n"
551 : :
552 : : "set promisc (port_id|all) (on|off)\n"
553 : : " Set the promiscuous mode on port_id, or all.\n\n"
554 : :
555 : : "set allmulti (port_id|all) (on|off)\n"
556 : : " Set the allmulti mode on port_id, or all.\n\n"
557 : :
558 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
559 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
560 : : " (on|off) autoneg (on|off) (port_id)\n"
561 : : "set flow_ctrl rx (on|off) (portid)\n"
562 : : "set flow_ctrl tx (on|off) (portid)\n"
563 : : "set flow_ctrl high_water (high_water) (portid)\n"
564 : : "set flow_ctrl low_water (low_water) (portid)\n"
565 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
566 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
567 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
568 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
569 : : " Set the link flow control parameter on a port.\n\n"
570 : :
571 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
572 : : " (low_water) (pause_time) (priority) (port_id)\n"
573 : : " Set the priority flow control parameter on a"
574 : : " port.\n\n"
575 : :
576 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
577 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
578 : : " Set the queue priority flow control parameter on a"
579 : : " given Rx and Tx queues of a port.\n\n"
580 : :
581 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
582 : : " set available descriptors threshold for Rx queue\n\n"
583 : :
584 : : "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
585 : : " Set statistics mapping (qmapping 0..15) for RX/TX"
586 : : " queue on port.\n"
587 : : " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
588 : : " on port 0 to mapping 5.\n\n"
589 : :
590 : : "set xstats-hide-zero on|off\n"
591 : : " Set the option to hide the zero values"
592 : : " for xstats display.\n"
593 : :
594 : : "set record-core-cycles on|off\n"
595 : : " Set the option to enable measurement of CPU cycles.\n"
596 : :
597 : : "set record-burst-stats on|off\n"
598 : : " Set the option to enable display of RX and TX bursts.\n"
599 : :
600 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
601 : : " Enable/Disable a VF receive/transmit from a port\n\n"
602 : :
603 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
604 : : "|MPE) (on|off)\n"
605 : : " AUPE:accepts untagged VLAN;"
606 : : "ROPE:accept unicast hash\n\n"
607 : : " BAM:accepts broadcast packets;"
608 : : "MPE:accepts all multicast packets\n\n"
609 : : " Enable/Disable a VF receive mode of a port\n\n"
610 : :
611 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
612 : : " Set rate limit for a queue of a port\n\n"
613 : :
614 : : "set port (port_id) vf (vf_id) rate (rate_num) "
615 : : "queue_mask (queue_mask_value)\n"
616 : : " Set rate limit for queues in VF of a port\n\n"
617 : :
618 : : "set flush_rx (on|off)\n"
619 : : " Flush (default) or don't flush RX streams before"
620 : : " forwarding. Mainly used with PCAP drivers.\n\n"
621 : :
622 : : "set link-up port (port_id)\n"
623 : : " Set link up for a port.\n\n"
624 : :
625 : : "set link-down port (port_id)\n"
626 : : " Set link down for a port.\n\n"
627 : :
628 : : "set port (port_id) ptype_mask (ptype_mask)\n"
629 : : " set packet types classification for a specific port\n\n"
630 : :
631 : : "show port meter cap (port_id)\n"
632 : : " Show port meter capability information\n\n"
633 : :
634 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
635 : : " meter profile add - srtcm rfc 2697\n\n"
636 : :
637 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
638 : : " meter profile add - trtcm rfc 2698\n\n"
639 : :
640 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
641 : : " meter profile add - trtcm rfc 4115\n\n"
642 : :
643 : : "del port meter profile (port_id) (profile_id)\n"
644 : : " meter profile delete\n\n"
645 : :
646 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
647 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
648 : : "(dscp_tbl_entry63)]\n"
649 : : " meter create\n\n"
650 : :
651 : : "enable port meter (port_id) (mtr_id)\n"
652 : : " meter enable\n\n"
653 : :
654 : : "disable port meter (port_id) (mtr_id)\n"
655 : : " meter disable\n\n"
656 : :
657 : : "del port meter (port_id) (mtr_id)\n"
658 : : " meter delete\n\n"
659 : :
660 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
661 : : "y_actions (actions) r_actions (actions)\n"
662 : : " meter policy add\n\n"
663 : :
664 : : "del port meter policy (port_id) (policy_id)\n"
665 : : " meter policy delete\n\n"
666 : :
667 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
668 : : " meter update meter profile\n\n"
669 : :
670 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
671 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
672 : : " update meter dscp table entries\n\n"
673 : :
674 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
675 : : "(action0) [(action1) (action2)]\n"
676 : : " meter update policer action\n\n"
677 : :
678 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
679 : : " meter update stats\n\n"
680 : :
681 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
682 : : " set fec mode for a specific port\n\n"
683 : :
684 : : "show port cman capa (port_id)\n"
685 : : " Show congestion management capabilities\n\n"
686 : :
687 : : "show port cman config (port_id)\n"
688 : : " Show congestion management configuration\n\n"
689 : :
690 : : "set port cman config (port_id) (queue_id) default | "
691 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
692 : : "(max_thresh) (prob_inv)]\n"
693 : : " Set congestion management configuration\n\n"
694 : :
695 : : "set port (port_id) led (on|off)\n"
696 : : " Set a controllable LED associated with a certain"
697 : : " port on or off.\n\n"
698 : :
699 : : , list_pkt_forwarding_modes()
700 : : );
701 : : }
702 : :
703 : 0 : if (show_all || !strcmp(res->section, "ports")) {
704 : :
705 : 0 : cmdline_printf(
706 : : cl,
707 : : "\n"
708 : : "Port Operations:\n"
709 : : "----------------\n\n"
710 : :
711 : : "port start (port_id|all)\n"
712 : : " Start all ports or port_id.\n\n"
713 : :
714 : : "port stop (port_id|all)\n"
715 : : " Stop all ports or port_id.\n\n"
716 : :
717 : : "port close (port_id|all)\n"
718 : : " Close all ports or port_id.\n\n"
719 : :
720 : : "port reset (port_id|all)\n"
721 : : " Reset all ports or port_id.\n\n"
722 : :
723 : : "port attach (ident)\n"
724 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
725 : :
726 : : "port detach (port_id)\n"
727 : : " Detach physical or virtual dev by port_id\n\n"
728 : :
729 : : "port config (port_id|all)"
730 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|"
731 : : "100000|200000|400000|800000|auto)"
732 : : " duplex (half|full|auto)\n"
733 : : " Set speed and duplex for all ports or port_id\n\n"
734 : :
735 : : "port config (port_id|all) loopback (mode)\n"
736 : : " Set loopback mode for all ports or port_id\n\n"
737 : :
738 : : "port config all (rxq|txq|rxd|txd) (value)\n"
739 : : " Set number for rxq/txq/rxd/txd.\n\n"
740 : :
741 : : "port config all max-pkt-len (value)\n"
742 : : " Set the max packet length.\n\n"
743 : :
744 : : "port config all max-lro-pkt-size (value)\n"
745 : : " Set the max LRO aggregated packet size.\n\n"
746 : :
747 : : "port config all drop-en (on|off)\n"
748 : : " Enable or disable packet drop on all RX queues of all ports when no "
749 : : "receive buffers available.\n\n"
750 : :
751 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
752 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
753 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
754 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
755 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
756 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
757 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
758 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
759 : : " Set the RSS mode.\n\n"
760 : :
761 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
762 : : " Set the RSS redirection table.\n\n"
763 : :
764 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
765 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
766 : : " Set the RSS hash algorithm.\n\n"
767 : :
768 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
769 : : " pfc (on|off)\n"
770 : : " Set the DCB mode.\n\n"
771 : :
772 : : "port config all burst (value)\n"
773 : : " Set the number of packets per burst.\n\n"
774 : :
775 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
776 : : " (value)\n"
777 : : " Set the ring prefetch/host/writeback threshold"
778 : : " for tx/rx queue.\n\n"
779 : :
780 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
781 : : " Set free threshold for rx/tx, or set"
782 : : " tx rs bit threshold.\n\n"
783 : : "port config mtu X value\n"
784 : : " Set the MTU of port X to a given value\n\n"
785 : :
786 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
787 : : " Set a rx/tx queue's ring size configuration, the new"
788 : : " value will take effect after command that (re-)start the port"
789 : : " or command that setup the specific queue\n\n"
790 : :
791 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
792 : : " Start/stop a rx/tx queue of port X. Only take effect"
793 : : " when port X is started\n\n"
794 : :
795 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
796 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
797 : : " take effect when port X is stopped.\n\n"
798 : :
799 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
800 : : " Setup a rx/tx queue of port X.\n\n"
801 : :
802 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
803 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
804 : :
805 : : "port config (port_id|all) rx_offload all|vlan_strip|"
806 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
807 : : "outer_ipv4_cksum|macsec_strip|"
808 : : "vlan_filter|vlan_extend|scatter|"
809 : : "buffer_split|timestamp|security|keep_crc on|off\n"
810 : : " Enable or disable a per port Rx offloading"
811 : : " on all Rx queues of a port\n\n"
812 : :
813 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
814 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
815 : : "outer_ipv4_cksum|macsec_strip|"
816 : : "vlan_filter|vlan_extend|scatter|"
817 : : "buffer_split|timestamp|security|keep_crc on|off\n"
818 : : " Enable or disable a per queue Rx offloading"
819 : : " only on a specific Rx queue\n\n"
820 : :
821 : : "port config (port_id|all) tx_offload all|vlan_insert|"
822 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
823 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
824 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
825 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
826 : : "security on|off\n"
827 : : " Enable or disable a per port Tx offloading"
828 : : " on all Tx queues of a port\n\n"
829 : :
830 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
831 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
832 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
833 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
834 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
835 : : " on|off\n"
836 : : " Enable or disable a per queue Tx offloading"
837 : : " only on a specific Tx queue\n\n"
838 : :
839 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
840 : : " Load an eBPF program as a callback"
841 : : " for particular RX/TX queue\n\n"
842 : :
843 : : "bpf-unload rx|tx (port) (queue)\n"
844 : : " Unload previously loaded eBPF program"
845 : : " for particular RX/TX queue\n\n"
846 : :
847 : : "port config (port_id) tx_metadata (value)\n"
848 : : " Set Tx metadata value per port. Testpmd will add this value"
849 : : " to any Tx packet sent from this port\n\n"
850 : :
851 : : "port config (port_id) dynf (name) set|clear\n"
852 : : " Register a dynf and Set/clear this flag on Tx. "
853 : : "Testpmd will set this value to any Tx packet "
854 : : "sent from this port\n\n"
855 : :
856 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
857 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
858 : :
859 : : "port config (port_id) txq (queue_id) affinity (value)\n"
860 : : " Map a Tx queue with an aggregated port "
861 : : "of the DPDK port\n\n"
862 : :
863 : : "port config (port_id|all) speed_lanes (value)\n"
864 : : " Set number of lanes for all ports or port_id for a forced speed\n\n"
865 : : );
866 : : }
867 : :
868 : 0 : if (show_all || !strcmp(res->section, "filters")) {
869 : :
870 : 0 : cmdline_printf(
871 : : cl,
872 : : "\n"
873 : : "filters:\n"
874 : : "--------\n\n"
875 : :
876 : : "flow validate {port_id}"
877 : : " [group {group_id}] [priority {level}]"
878 : : " [ingress] [egress]"
879 : : " pattern {item} [/ {item} [...]] / end"
880 : : " actions {action} [/ {action} [...]] / end\n"
881 : : " Check whether a flow rule can be created.\n\n"
882 : :
883 : : "flow create {port_id}"
884 : : " [group {group_id}] [priority {level}]"
885 : : " [ingress] [egress]"
886 : : " pattern {item} [/ {item} [...]] / end"
887 : : " actions {action} [/ {action} [...]] / end\n"
888 : : " Create a flow rule.\n\n"
889 : :
890 : : "flow destroy {port_id} rule {rule_id} [...]\n"
891 : : " Destroy specific flow rules.\n\n"
892 : :
893 : : "flow update {port_id} {rule_id}"
894 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
895 : : " Update a flow rule with new actions.\n\n"
896 : :
897 : : "flow flush {port_id}\n"
898 : : " Destroy all flow rules.\n\n"
899 : :
900 : : "flow query {port_id} {rule_id} {action}\n"
901 : : " Query an existing flow rule.\n\n"
902 : :
903 : : "flow list {port_id} [group {group_id}] [...]\n"
904 : : " List existing flow rules sorted by priority,"
905 : : " filtered by group identifiers.\n\n"
906 : :
907 : : "flow isolate {port_id} {boolean}\n"
908 : : " Restrict ingress traffic to the defined"
909 : : " flow rules\n\n"
910 : :
911 : : "flow aged {port_id} [destroy]\n"
912 : : " List and destroy aged flows"
913 : : " flow rules\n\n"
914 : :
915 : : "flow indirect_action {port_id} create"
916 : : " [action_id {indirect_action_id}]"
917 : : " [ingress] [egress]"
918 : : " action {action} / end\n"
919 : : " Create indirect action.\n\n"
920 : :
921 : : "flow indirect_action {port_id} update"
922 : : " {indirect_action_id} action {action} / end\n"
923 : : " Update indirect action.\n\n"
924 : :
925 : : "flow indirect_action {port_id} destroy"
926 : : " action_id {indirect_action_id} [...]\n"
927 : : " Destroy specific indirect actions.\n\n"
928 : :
929 : : "flow indirect_action {port_id} query"
930 : : " {indirect_action_id}\n"
931 : : " Query an existing indirect action.\n\n"
932 : :
933 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
934 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
935 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
936 : : " Configure the VXLAN encapsulation for flows.\n\n"
937 : :
938 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
939 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
940 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
941 : : " eth-dst (eth-dst)\n"
942 : : " Configure the VXLAN encapsulation for flows.\n\n"
943 : :
944 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
945 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
946 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
947 : : " eth-dst (eth-dst)\n"
948 : : " Configure the VXLAN encapsulation for flows.\n\n"
949 : :
950 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
951 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
952 : : " (eth-dst)\n"
953 : : " Configure the NVGRE encapsulation for flows.\n\n"
954 : :
955 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
956 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
957 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
958 : : " Configure the NVGRE encapsulation for flows.\n\n"
959 : :
960 : : "set raw_encap {flow items}\n"
961 : : " Configure the encapsulation with raw data.\n\n"
962 : :
963 : : "set raw_decap {flow items}\n"
964 : : " Configure the decapsulation with raw data.\n\n"
965 : :
966 : : );
967 : : }
968 : :
969 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
970 : 0 : cmdline_printf(
971 : : cl,
972 : : "\n"
973 : : "Traffic Management:\n"
974 : : "--------------\n"
975 : : "show port tm cap (port_id)\n"
976 : : " Display the port TM capability.\n\n"
977 : :
978 : : "show port tm level cap (port_id) (level_id)\n"
979 : : " Display the port TM hierarchical level capability.\n\n"
980 : :
981 : : "show port tm node cap (port_id) (node_id)\n"
982 : : " Display the port TM node capability.\n\n"
983 : :
984 : : "show port tm node type (port_id) (node_id)\n"
985 : : " Display the port TM node type.\n\n"
986 : :
987 : : "show port tm node stats (port_id) (node_id) (clear)\n"
988 : : " Display the port TM node stats.\n\n"
989 : :
990 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
991 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
992 : : " (packet_length_adjust) (packet_mode)\n"
993 : : " Add port tm node private shaper profile.\n\n"
994 : :
995 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
996 : : " Delete port tm node private shaper profile.\n\n"
997 : :
998 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
999 : : " (shaper_profile_id)\n"
1000 : : " Add/update port tm node shared shaper.\n\n"
1001 : :
1002 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1003 : : " Delete port tm node shared shaper.\n\n"
1004 : :
1005 : : "set port tm node shaper profile (port_id) (node_id)"
1006 : : " (shaper_profile_id)\n"
1007 : : " Set port tm node shaper profile.\n\n"
1008 : :
1009 : : "add port tm node wred profile (port_id) (wred_profile_id)"
1010 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1011 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1012 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1013 : : " Add port tm node wred profile.\n\n"
1014 : :
1015 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
1016 : : " Delete port tm node wred profile.\n\n"
1017 : :
1018 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1019 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1020 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1021 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1022 : : " Add port tm nonleaf node.\n\n"
1023 : :
1024 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1025 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1026 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1027 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1028 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
1029 : :
1030 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1031 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1032 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1033 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1034 : : " Add port tm leaf node.\n\n"
1035 : :
1036 : : "del port tm node (port_id) (node_id)\n"
1037 : : " Delete port tm node.\n\n"
1038 : :
1039 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1040 : : " (priority) (weight)\n"
1041 : : " Set port tm node parent.\n\n"
1042 : :
1043 : : "suspend port tm node (port_id) (node_id)"
1044 : : " Suspend tm node.\n\n"
1045 : :
1046 : : "resume port tm node (port_id) (node_id)"
1047 : : " Resume tm node.\n\n"
1048 : :
1049 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1050 : : " Commit tm hierarchy.\n\n"
1051 : :
1052 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1053 : : " (red)\n"
1054 : : " Enables/Disables the traffic management marking"
1055 : : " for IP ECN (Explicit Congestion Notification)"
1056 : : " packets on a given port\n\n"
1057 : :
1058 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1059 : : " (red)\n"
1060 : : " Enables/Disables the traffic management marking"
1061 : : " on the port for IP dscp packets\n\n"
1062 : :
1063 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1064 : : " (red)\n"
1065 : : " Enables/Disables the traffic management marking"
1066 : : " on the port for VLAN packets with DEI enabled\n\n"
1067 : : );
1068 : : }
1069 : :
1070 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1071 : 0 : cmdline_printf(
1072 : : cl,
1073 : : "\n"
1074 : : "Device Operations:\n"
1075 : : "--------------\n"
1076 : : "device detach (identifier)\n"
1077 : : " Detach device by identifier.\n\n"
1078 : : );
1079 : : }
1080 : :
1081 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1082 : : struct testpmd_driver_commands *c;
1083 : : unsigned int i;
1084 : :
1085 : 0 : cmdline_printf(
1086 : : cl,
1087 : : "\n"
1088 : : "Driver specific:\n"
1089 : : "----------------\n"
1090 : : );
1091 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1092 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1093 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1094 : : }
1095 : : }
1096 : 0 : }
1097 : :
1098 : : static cmdline_parse_token_string_t cmd_help_long_help =
1099 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1100 : :
1101 : : static cmdline_parse_token_string_t cmd_help_long_section =
1102 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1103 : : "all#control#display#config#ports#"
1104 : : "filters#traffic_management#devices#drivers");
1105 : :
1106 : : static cmdline_parse_inst_t cmd_help_long = {
1107 : : .f = cmd_help_long_parsed,
1108 : : .data = NULL,
1109 : : .help_str = "help all|control|display|config|ports|"
1110 : : "filters|traffic_management|devices|drivers: "
1111 : : "Show help",
1112 : : .tokens = {
1113 : : (void *)&cmd_help_long_help,
1114 : : (void *)&cmd_help_long_section,
1115 : : NULL,
1116 : : },
1117 : : };
1118 : :
1119 : :
1120 : : /* *** start/stop/close all ports *** */
1121 : : struct cmd_operate_port_result {
1122 : : cmdline_fixed_string_t keyword;
1123 : : cmdline_fixed_string_t name;
1124 : : cmdline_fixed_string_t value;
1125 : : };
1126 : :
1127 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1128 : : __rte_unused struct cmdline *cl,
1129 : : __rte_unused void *data)
1130 : : {
1131 : : struct cmd_operate_port_result *res = parsed_result;
1132 : :
1133 : 0 : if (!strcmp(res->name, "start"))
1134 : 0 : start_port(RTE_PORT_ALL);
1135 : 0 : else if (!strcmp(res->name, "stop"))
1136 : 0 : stop_port(RTE_PORT_ALL);
1137 : 0 : else if (!strcmp(res->name, "close"))
1138 : 0 : close_port(RTE_PORT_ALL);
1139 : 0 : else if (!strcmp(res->name, "reset"))
1140 : 0 : reset_port(RTE_PORT_ALL);
1141 : : else
1142 : 0 : fprintf(stderr, "Unknown parameter\n");
1143 : 0 : }
1144 : :
1145 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1146 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1147 : : "port");
1148 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1149 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1150 : : "start#stop#close#reset");
1151 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1152 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1153 : :
1154 : : static cmdline_parse_inst_t cmd_operate_port = {
1155 : : .f = cmd_operate_port_parsed,
1156 : : .data = NULL,
1157 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1158 : : .tokens = {
1159 : : (void *)&cmd_operate_port_all_cmd,
1160 : : (void *)&cmd_operate_port_all_port,
1161 : : (void *)&cmd_operate_port_all_all,
1162 : : NULL,
1163 : : },
1164 : : };
1165 : :
1166 : : /* *** start/stop/close specific port *** */
1167 : : struct cmd_operate_specific_port_result {
1168 : : cmdline_fixed_string_t keyword;
1169 : : cmdline_fixed_string_t name;
1170 : : uint8_t value;
1171 : : };
1172 : :
1173 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1174 : : __rte_unused struct cmdline *cl,
1175 : : __rte_unused void *data)
1176 : : {
1177 : : struct cmd_operate_specific_port_result *res = parsed_result;
1178 : :
1179 : 0 : if (!strcmp(res->name, "start"))
1180 : 0 : start_port(res->value);
1181 : 0 : else if (!strcmp(res->name, "stop"))
1182 : 0 : stop_port(res->value);
1183 : 0 : else if (!strcmp(res->name, "close"))
1184 : 0 : close_port(res->value);
1185 : 0 : else if (!strcmp(res->name, "reset"))
1186 : 0 : reset_port(res->value);
1187 : : else
1188 : 0 : fprintf(stderr, "Unknown parameter\n");
1189 : 0 : }
1190 : :
1191 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1192 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1193 : : keyword, "port");
1194 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1195 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1196 : : name, "start#stop#close#reset");
1197 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1198 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1199 : : value, RTE_UINT8);
1200 : :
1201 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1202 : : .f = cmd_operate_specific_port_parsed,
1203 : : .data = NULL,
1204 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1205 : : .tokens = {
1206 : : (void *)&cmd_operate_specific_port_cmd,
1207 : : (void *)&cmd_operate_specific_port_port,
1208 : : (void *)&cmd_operate_specific_port_id,
1209 : : NULL,
1210 : : },
1211 : : };
1212 : :
1213 : : /* *** enable port setup (after attach) via iterator or event *** */
1214 : : struct cmd_set_port_setup_on_result {
1215 : : cmdline_fixed_string_t set;
1216 : : cmdline_fixed_string_t port;
1217 : : cmdline_fixed_string_t setup;
1218 : : cmdline_fixed_string_t on;
1219 : : cmdline_fixed_string_t mode;
1220 : : };
1221 : :
1222 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1223 : : __rte_unused struct cmdline *cl,
1224 : : __rte_unused void *data)
1225 : : {
1226 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1227 : :
1228 : 0 : if (strcmp(res->mode, "event") == 0)
1229 : 0 : setup_on_probe_event = true;
1230 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1231 : 0 : setup_on_probe_event = false;
1232 : : else
1233 : 0 : fprintf(stderr, "Unknown mode\n");
1234 : 0 : }
1235 : :
1236 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1237 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1238 : : set, "set");
1239 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1240 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1241 : : port, "port");
1242 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1243 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1244 : : setup, "setup");
1245 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1246 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1247 : : on, "on");
1248 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1249 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1250 : : mode, "iterator#event");
1251 : :
1252 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1253 : : .f = cmd_set_port_setup_on_parsed,
1254 : : .data = NULL,
1255 : : .help_str = "set port setup on iterator|event",
1256 : : .tokens = {
1257 : : (void *)&cmd_set_port_setup_on_set,
1258 : : (void *)&cmd_set_port_setup_on_port,
1259 : : (void *)&cmd_set_port_setup_on_setup,
1260 : : (void *)&cmd_set_port_setup_on_on,
1261 : : (void *)&cmd_set_port_setup_on_mode,
1262 : : NULL,
1263 : : },
1264 : : };
1265 : :
1266 : : /* *** attach a specified port *** */
1267 : : struct cmd_operate_attach_port_result {
1268 : : cmdline_fixed_string_t port;
1269 : : cmdline_fixed_string_t keyword;
1270 : : cmdline_multi_string_t identifier;
1271 : : };
1272 : :
1273 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1274 : : __rte_unused struct cmdline *cl,
1275 : : __rte_unused void *data)
1276 : : {
1277 : : struct cmd_operate_attach_port_result *res = parsed_result;
1278 : :
1279 : 0 : if (!strcmp(res->keyword, "attach"))
1280 : 0 : attach_port(res->identifier);
1281 : : else
1282 : 0 : fprintf(stderr, "Unknown parameter\n");
1283 : 0 : }
1284 : :
1285 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1286 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1287 : : port, "port");
1288 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1289 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1290 : : keyword, "attach");
1291 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1292 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1293 : : identifier, TOKEN_STRING_MULTI);
1294 : :
1295 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1296 : : .f = cmd_operate_attach_port_parsed,
1297 : : .data = NULL,
1298 : : .help_str = "port attach <identifier>: "
1299 : : "(identifier: pci address or virtual dev name)",
1300 : : .tokens = {
1301 : : (void *)&cmd_operate_attach_port_port,
1302 : : (void *)&cmd_operate_attach_port_keyword,
1303 : : (void *)&cmd_operate_attach_port_identifier,
1304 : : NULL,
1305 : : },
1306 : : };
1307 : :
1308 : : /* *** detach a specified port *** */
1309 : : struct cmd_operate_detach_port_result {
1310 : : cmdline_fixed_string_t port;
1311 : : cmdline_fixed_string_t keyword;
1312 : : portid_t port_id;
1313 : : };
1314 : :
1315 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1316 : : __rte_unused struct cmdline *cl,
1317 : : __rte_unused void *data)
1318 : : {
1319 : : struct cmd_operate_detach_port_result *res = parsed_result;
1320 : :
1321 : 0 : if (!strcmp(res->keyword, "detach")) {
1322 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1323 : 0 : detach_port_device(res->port_id);
1324 : : } else {
1325 : 0 : fprintf(stderr, "Unknown parameter\n");
1326 : : }
1327 : : }
1328 : :
1329 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1330 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1331 : : port, "port");
1332 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1333 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1334 : : keyword, "detach");
1335 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1336 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1337 : : port_id, RTE_UINT16);
1338 : :
1339 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1340 : : .f = cmd_operate_detach_port_parsed,
1341 : : .data = NULL,
1342 : : .help_str = "port detach <port_id>",
1343 : : .tokens = {
1344 : : (void *)&cmd_operate_detach_port_port,
1345 : : (void *)&cmd_operate_detach_port_keyword,
1346 : : (void *)&cmd_operate_detach_port_port_id,
1347 : : NULL,
1348 : : },
1349 : : };
1350 : :
1351 : : /* *** detach device by identifier *** */
1352 : : struct cmd_operate_detach_device_result {
1353 : : cmdline_fixed_string_t device;
1354 : : cmdline_fixed_string_t keyword;
1355 : : cmdline_fixed_string_t identifier;
1356 : : };
1357 : :
1358 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1359 : : __rte_unused struct cmdline *cl,
1360 : : __rte_unused void *data)
1361 : : {
1362 : : struct cmd_operate_detach_device_result *res = parsed_result;
1363 : :
1364 : 0 : if (!strcmp(res->keyword, "detach"))
1365 : 0 : detach_devargs(res->identifier);
1366 : : else
1367 : 0 : fprintf(stderr, "Unknown parameter\n");
1368 : 0 : }
1369 : :
1370 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1371 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1372 : : device, "device");
1373 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1374 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1375 : : keyword, "detach");
1376 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1377 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1378 : : identifier, NULL);
1379 : :
1380 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1381 : : .f = cmd_operate_detach_device_parsed,
1382 : : .data = NULL,
1383 : : .help_str = "device detach <identifier>:"
1384 : : "(identifier: pci address or virtual dev name)",
1385 : : .tokens = {
1386 : : (void *)&cmd_operate_detach_device_device,
1387 : : (void *)&cmd_operate_detach_device_keyword,
1388 : : (void *)&cmd_operate_detach_device_identifier,
1389 : : NULL,
1390 : : },
1391 : : };
1392 : : /* *** configure speed for all ports *** */
1393 : : struct cmd_config_speed_all {
1394 : : cmdline_fixed_string_t port;
1395 : : cmdline_fixed_string_t keyword;
1396 : : cmdline_fixed_string_t all;
1397 : : cmdline_fixed_string_t item1;
1398 : : cmdline_fixed_string_t item2;
1399 : : cmdline_fixed_string_t value1;
1400 : : cmdline_fixed_string_t value2;
1401 : : };
1402 : :
1403 : : static int
1404 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1405 : : {
1406 : :
1407 : : int duplex;
1408 : :
1409 : 0 : if (!strcmp(duplexstr, "half")) {
1410 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1411 : 0 : } else if (!strcmp(duplexstr, "full")) {
1412 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1413 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1414 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1415 : : } else {
1416 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1417 : 0 : return -1;
1418 : : }
1419 : :
1420 : 0 : if (!strcmp(speedstr, "10")) {
1421 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1422 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1423 : 0 : } else if (!strcmp(speedstr, "100")) {
1424 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1425 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1426 : : } else {
1427 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1428 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1429 : 0 : return -1;
1430 : : }
1431 : 0 : if (!strcmp(speedstr, "1000")) {
1432 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1433 : 0 : } else if (!strcmp(speedstr, "2500")) {
1434 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1435 : 0 : } else if (!strcmp(speedstr, "5000")) {
1436 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1437 : 0 : } else if (!strcmp(speedstr, "10000")) {
1438 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1439 : 0 : } else if (!strcmp(speedstr, "25000")) {
1440 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1441 : 0 : } else if (!strcmp(speedstr, "40000")) {
1442 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1443 : 0 : } else if (!strcmp(speedstr, "50000")) {
1444 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1445 : 0 : } else if (!strcmp(speedstr, "100000")) {
1446 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1447 : 0 : } else if (!strcmp(speedstr, "200000")) {
1448 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1449 : 0 : } else if (!strcmp(speedstr, "400000")) {
1450 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1451 : 0 : } else if (!strcmp(speedstr, "800000")) {
1452 : 0 : *speed = RTE_ETH_LINK_SPEED_800G;
1453 : 0 : } else if (!strcmp(speedstr, "auto")) {
1454 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1455 : : } else {
1456 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1457 : 0 : return -1;
1458 : : }
1459 : : }
1460 : :
1461 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1462 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1463 : :
1464 : : return 0;
1465 : : }
1466 : :
1467 : : static void
1468 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1469 : : __rte_unused struct cmdline *cl,
1470 : : __rte_unused void *data)
1471 : : {
1472 : : struct cmd_config_speed_all *res = parsed_result;
1473 : : uint32_t link_speed;
1474 : : portid_t pid;
1475 : :
1476 : 0 : if (!all_ports_stopped()) {
1477 : 0 : fprintf(stderr, "Please stop all ports first\n");
1478 : 0 : return;
1479 : : }
1480 : :
1481 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1482 : : &link_speed) < 0)
1483 : : return;
1484 : :
1485 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1486 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1487 : : }
1488 : :
1489 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1490 : : }
1491 : :
1492 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1493 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1494 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1495 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1496 : : "config");
1497 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1498 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1499 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1500 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1501 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1502 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1503 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1504 : : "100000#200000#400000#800000#auto");
1505 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1506 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1507 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1508 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1509 : : "half#full#auto");
1510 : :
1511 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1512 : : .f = cmd_config_speed_all_parsed,
1513 : : .data = NULL,
1514 : : .help_str = "port config all speed "
1515 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1516 : : "100000|200000|400000|800000|auto "
1517 : : "duplex half|full|auto",
1518 : : .tokens = {
1519 : : (void *)&cmd_config_speed_all_port,
1520 : : (void *)&cmd_config_speed_all_keyword,
1521 : : (void *)&cmd_config_speed_all_all,
1522 : : (void *)&cmd_config_speed_all_item1,
1523 : : (void *)&cmd_config_speed_all_value1,
1524 : : (void *)&cmd_config_speed_all_item2,
1525 : : (void *)&cmd_config_speed_all_value2,
1526 : : NULL,
1527 : : },
1528 : : };
1529 : :
1530 : : /* *** configure speed for specific port *** */
1531 : : struct cmd_config_speed_specific {
1532 : : cmdline_fixed_string_t port;
1533 : : cmdline_fixed_string_t keyword;
1534 : : portid_t id;
1535 : : cmdline_fixed_string_t item1;
1536 : : cmdline_fixed_string_t item2;
1537 : : cmdline_fixed_string_t value1;
1538 : : cmdline_fixed_string_t value2;
1539 : : };
1540 : :
1541 : : static void
1542 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1543 : : __rte_unused struct cmdline *cl,
1544 : : __rte_unused void *data)
1545 : : {
1546 : : struct cmd_config_speed_specific *res = parsed_result;
1547 : : uint32_t link_speed;
1548 : :
1549 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1550 : 0 : return;
1551 : :
1552 : 0 : if (!port_is_stopped(res->id)) {
1553 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1554 : 0 : return;
1555 : : }
1556 : :
1557 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1558 : : &link_speed) < 0)
1559 : : return;
1560 : :
1561 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1562 : :
1563 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1564 : : }
1565 : :
1566 : :
1567 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1568 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1569 : : "port");
1570 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1571 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1572 : : "config");
1573 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1574 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1575 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1576 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1577 : : "speed");
1578 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1579 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1580 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1581 : : "100000#200000#400000#800000#auto");
1582 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1583 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1584 : : "duplex");
1585 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1586 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1587 : : "half#full#auto");
1588 : :
1589 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1590 : : .f = cmd_config_speed_specific_parsed,
1591 : : .data = NULL,
1592 : : .help_str = "port config <port_id> speed "
1593 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1594 : : "100000|200000|400000|800000|auto "
1595 : : "duplex half|full|auto",
1596 : : .tokens = {
1597 : : (void *)&cmd_config_speed_specific_port,
1598 : : (void *)&cmd_config_speed_specific_keyword,
1599 : : (void *)&cmd_config_speed_specific_id,
1600 : : (void *)&cmd_config_speed_specific_item1,
1601 : : (void *)&cmd_config_speed_specific_value1,
1602 : : (void *)&cmd_config_speed_specific_item2,
1603 : : (void *)&cmd_config_speed_specific_value2,
1604 : : NULL,
1605 : : },
1606 : : };
1607 : :
1608 : : static int
1609 : 0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
1610 : : {
1611 : : int ret;
1612 : :
1613 : 0 : ret = rte_eth_speed_lanes_set(pid, lanes);
1614 : 0 : if (ret == -ENOTSUP) {
1615 : 0 : fprintf(stderr, "Function not implemented\n");
1616 : 0 : return -1;
1617 : 0 : } else if (ret < 0) {
1618 : 0 : fprintf(stderr, "Set speed lanes failed\n");
1619 : 0 : return -1;
1620 : : }
1621 : :
1622 : : return 0;
1623 : : }
1624 : :
1625 : : static void
1626 : 0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
1627 : : {
1628 : : unsigned int i;
1629 : : uint32_t capa;
1630 : :
1631 : : printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
1632 : : printf("\n-----------------------------------\n");
1633 : 0 : for (i = 0; i < num; i++) {
1634 : 0 : printf("%-17s ",
1635 : 0 : rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
1636 : 0 : capa = speed_lanes_capa[i].capa;
1637 : : int s = 0;
1638 : :
1639 : 0 : while (capa) {
1640 : 0 : if (capa & 0x1)
1641 : : printf("%-2d ", s);
1642 : 0 : s++;
1643 : 0 : capa = capa >> 1;
1644 : : }
1645 : : printf("\n");
1646 : : }
1647 : 0 : }
1648 : :
1649 : : /* *** display speed lanes per port capabilities *** */
1650 : : struct cmd_show_speed_lanes_result {
1651 : : cmdline_fixed_string_t cmd_show;
1652 : : cmdline_fixed_string_t cmd_port;
1653 : : cmdline_fixed_string_t cmd_keyword;
1654 : : portid_t cmd_pid;
1655 : : };
1656 : :
1657 : : static void
1658 : 0 : cmd_show_speed_lanes_parsed(void *parsed_result,
1659 : : __rte_unused struct cmdline *cl,
1660 : : __rte_unused void *data)
1661 : : {
1662 : : struct cmd_show_speed_lanes_result *res = parsed_result;
1663 : : struct rte_eth_speed_lanes_capa *speed_lanes_capa;
1664 : : unsigned int num;
1665 : : int ret;
1666 : :
1667 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
1668 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
1669 : 0 : return;
1670 : : }
1671 : :
1672 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
1673 : 0 : if (ret == -ENOTSUP) {
1674 : 0 : fprintf(stderr, "Function not implemented\n");
1675 : 0 : return;
1676 : 0 : } else if (ret < 0) {
1677 : 0 : fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
1678 : 0 : return;
1679 : : }
1680 : :
1681 : 0 : num = (unsigned int)ret;
1682 : 0 : speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
1683 : 0 : if (speed_lanes_capa == NULL) {
1684 : 0 : fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
1685 : 0 : return;
1686 : : }
1687 : :
1688 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
1689 : 0 : if (ret < 0) {
1690 : 0 : fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
1691 : 0 : goto out;
1692 : : }
1693 : :
1694 : 0 : show_speed_lanes_capability(num, speed_lanes_capa);
1695 : 0 : out:
1696 : 0 : free(speed_lanes_capa);
1697 : : }
1698 : :
1699 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
1700 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1701 : : cmd_show, "show");
1702 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
1703 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1704 : : cmd_port, "port");
1705 : : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
1706 : : TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
1707 : : cmd_pid, RTE_UINT16);
1708 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
1709 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1710 : : cmd_keyword, "speed_lanes");
1711 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
1712 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1713 : : cmd_keyword, "capabilities");
1714 : :
1715 : : static cmdline_parse_inst_t cmd_show_speed_lanes = {
1716 : : .f = cmd_show_speed_lanes_parsed,
1717 : : .data = NULL,
1718 : : .help_str = "show port <port_id> speed_lanes capabilities",
1719 : : .tokens = {
1720 : : (void *)&cmd_show_speed_lanes_show,
1721 : : (void *)&cmd_show_speed_lanes_port,
1722 : : (void *)&cmd_show_speed_lanes_pid,
1723 : : (void *)&cmd_show_speed_lanes_keyword,
1724 : : (void *)&cmd_show_speed_lanes_cap_keyword,
1725 : : NULL,
1726 : : },
1727 : : };
1728 : :
1729 : : /* *** configure speed_lanes for all ports *** */
1730 : : struct cmd_config_speed_lanes_all {
1731 : : cmdline_fixed_string_t port;
1732 : : cmdline_fixed_string_t keyword;
1733 : : cmdline_fixed_string_t all;
1734 : : cmdline_fixed_string_t item;
1735 : : uint32_t lanes;
1736 : : };
1737 : :
1738 : : static void
1739 : 0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
1740 : : __rte_unused struct cmdline *cl,
1741 : : __rte_unused void *data)
1742 : : {
1743 : : struct cmd_config_speed_lanes_all *res = parsed_result;
1744 : : portid_t pid;
1745 : :
1746 : 0 : if (!all_ports_stopped()) {
1747 : 0 : fprintf(stderr, "Please stop all ports first\n");
1748 : 0 : return;
1749 : : }
1750 : :
1751 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1752 : 0 : if (parse_speed_lanes_cfg(pid, res->lanes))
1753 : : return;
1754 : : }
1755 : :
1756 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1757 : : }
1758 : :
1759 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
1760 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
1761 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
1762 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
1763 : : "config");
1764 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
1765 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
1766 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
1767 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
1768 : : "speed_lanes");
1769 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
1770 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
1771 : :
1772 : : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
1773 : : .f = cmd_config_speed_lanes_all_parsed,
1774 : : .data = NULL,
1775 : : .help_str = "port config all speed_lanes <value>",
1776 : : .tokens = {
1777 : : (void *)&cmd_config_speed_lanes_all_port,
1778 : : (void *)&cmd_config_speed_lanes_all_keyword,
1779 : : (void *)&cmd_config_speed_lanes_all_all,
1780 : : (void *)&cmd_config_speed_lanes_all_item,
1781 : : (void *)&cmd_config_speed_lanes_all_lanes,
1782 : : NULL,
1783 : : },
1784 : : };
1785 : :
1786 : : /* *** configure speed_lanes for specific port *** */
1787 : : struct cmd_config_speed_lanes_specific {
1788 : : cmdline_fixed_string_t port;
1789 : : cmdline_fixed_string_t keyword;
1790 : : uint16_t port_id;
1791 : : cmdline_fixed_string_t item;
1792 : : uint32_t lanes;
1793 : : };
1794 : :
1795 : : static void
1796 : 0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
1797 : : __rte_unused struct cmdline *cl,
1798 : : __rte_unused void *data)
1799 : : {
1800 : : struct cmd_config_speed_lanes_specific *res = parsed_result;
1801 : :
1802 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1803 : : return;
1804 : :
1805 : 0 : if (!port_is_stopped(res->port_id)) {
1806 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1807 : 0 : return;
1808 : : }
1809 : :
1810 : 0 : if (parse_speed_lanes_cfg(res->port_id, res->lanes))
1811 : : return;
1812 : :
1813 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1814 : : }
1815 : :
1816 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
1817 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
1818 : : "port");
1819 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
1820 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
1821 : : "config");
1822 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
1823 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
1824 : : RTE_UINT16);
1825 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
1826 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
1827 : : "speed_lanes");
1828 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
1829 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
1830 : : RTE_UINT32);
1831 : :
1832 : : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
1833 : : .f = cmd_config_speed_lanes_specific_parsed,
1834 : : .data = NULL,
1835 : : .help_str = "port config <port_id> speed_lanes <value>",
1836 : : .tokens = {
1837 : : (void *)&cmd_config_speed_lanes_specific_port,
1838 : : (void *)&cmd_config_speed_lanes_specific_keyword,
1839 : : (void *)&cmd_config_speed_lanes_specific_id,
1840 : : (void *)&cmd_config_speed_lanes_specific_item,
1841 : : (void *)&cmd_config_speed_lanes_specific_lanes,
1842 : : NULL,
1843 : : },
1844 : : };
1845 : :
1846 : : /* *** configure loopback for all ports *** */
1847 : : struct cmd_config_loopback_all {
1848 : : cmdline_fixed_string_t port;
1849 : : cmdline_fixed_string_t keyword;
1850 : : cmdline_fixed_string_t all;
1851 : : cmdline_fixed_string_t item;
1852 : : uint32_t mode;
1853 : : };
1854 : :
1855 : : static void
1856 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1857 : : __rte_unused struct cmdline *cl,
1858 : : __rte_unused void *data)
1859 : : {
1860 : : struct cmd_config_loopback_all *res = parsed_result;
1861 : : portid_t pid;
1862 : :
1863 : 0 : if (!all_ports_stopped()) {
1864 : 0 : fprintf(stderr, "Please stop all ports first\n");
1865 : 0 : return;
1866 : : }
1867 : :
1868 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1869 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1870 : : }
1871 : :
1872 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1873 : : }
1874 : :
1875 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1876 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1877 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1878 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1879 : : "config");
1880 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1881 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1882 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1883 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1884 : : "loopback");
1885 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1886 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1887 : :
1888 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1889 : : .f = cmd_config_loopback_all_parsed,
1890 : : .data = NULL,
1891 : : .help_str = "port config all loopback <mode>",
1892 : : .tokens = {
1893 : : (void *)&cmd_config_loopback_all_port,
1894 : : (void *)&cmd_config_loopback_all_keyword,
1895 : : (void *)&cmd_config_loopback_all_all,
1896 : : (void *)&cmd_config_loopback_all_item,
1897 : : (void *)&cmd_config_loopback_all_mode,
1898 : : NULL,
1899 : : },
1900 : : };
1901 : :
1902 : : /* *** configure loopback for specific port *** */
1903 : : struct cmd_config_loopback_specific {
1904 : : cmdline_fixed_string_t port;
1905 : : cmdline_fixed_string_t keyword;
1906 : : uint16_t port_id;
1907 : : cmdline_fixed_string_t item;
1908 : : uint32_t mode;
1909 : : };
1910 : :
1911 : : static void
1912 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1913 : : __rte_unused struct cmdline *cl,
1914 : : __rte_unused void *data)
1915 : : {
1916 : : struct cmd_config_loopback_specific *res = parsed_result;
1917 : :
1918 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1919 : : return;
1920 : :
1921 : 0 : if (!port_is_stopped(res->port_id)) {
1922 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1923 : 0 : return;
1924 : : }
1925 : :
1926 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1927 : :
1928 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1929 : : }
1930 : :
1931 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1932 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1933 : : "port");
1934 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1935 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1936 : : "config");
1937 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1938 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1939 : : RTE_UINT16);
1940 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1941 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1942 : : "loopback");
1943 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1944 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1945 : : RTE_UINT32);
1946 : :
1947 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1948 : : .f = cmd_config_loopback_specific_parsed,
1949 : : .data = NULL,
1950 : : .help_str = "port config <port_id> loopback <mode>",
1951 : : .tokens = {
1952 : : (void *)&cmd_config_loopback_specific_port,
1953 : : (void *)&cmd_config_loopback_specific_keyword,
1954 : : (void *)&cmd_config_loopback_specific_id,
1955 : : (void *)&cmd_config_loopback_specific_item,
1956 : : (void *)&cmd_config_loopback_specific_mode,
1957 : : NULL,
1958 : : },
1959 : : };
1960 : :
1961 : : /* *** configure txq/rxq, txd/rxd *** */
1962 : : struct cmd_config_rx_tx {
1963 : : cmdline_fixed_string_t port;
1964 : : cmdline_fixed_string_t keyword;
1965 : : cmdline_fixed_string_t all;
1966 : : cmdline_fixed_string_t name;
1967 : : uint16_t value;
1968 : : };
1969 : :
1970 : : static void
1971 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1972 : : __rte_unused struct cmdline *cl,
1973 : : __rte_unused void *data)
1974 : : {
1975 : : struct cmd_config_rx_tx *res = parsed_result;
1976 : :
1977 : 0 : if (!all_ports_stopped()) {
1978 : 0 : fprintf(stderr, "Please stop all ports first\n");
1979 : 0 : return;
1980 : : }
1981 : 0 : if (!strcmp(res->name, "rxq")) {
1982 : 0 : if (!res->value && !nb_txq) {
1983 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1984 : 0 : return;
1985 : : }
1986 : 0 : if (check_nb_rxq(res->value) != 0)
1987 : : return;
1988 : 0 : nb_rxq = res->value;
1989 : : }
1990 : 0 : else if (!strcmp(res->name, "txq")) {
1991 : 0 : if (!res->value && !nb_rxq) {
1992 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1993 : 0 : return;
1994 : : }
1995 : 0 : if (check_nb_txq(res->value) != 0)
1996 : : return;
1997 : 0 : nb_txq = res->value;
1998 : : }
1999 : 0 : else if (!strcmp(res->name, "rxd")) {
2000 : 0 : if (check_nb_rxd(res->value) != 0)
2001 : : return;
2002 : 0 : nb_rxd = res->value;
2003 : 0 : } else if (!strcmp(res->name, "txd")) {
2004 : 0 : if (check_nb_txd(res->value) != 0)
2005 : : return;
2006 : :
2007 : 0 : nb_txd = res->value;
2008 : : } else {
2009 : 0 : fprintf(stderr, "Unknown parameter\n");
2010 : 0 : return;
2011 : : }
2012 : :
2013 : 0 : fwd_config_setup();
2014 : :
2015 : 0 : init_port_config();
2016 : :
2017 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2018 : : }
2019 : :
2020 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
2021 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2022 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2023 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2024 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
2025 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2026 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
2027 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2028 : : "rxq#txq#rxd#txd");
2029 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
2030 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
2031 : :
2032 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
2033 : : .f = cmd_config_rx_tx_parsed,
2034 : : .data = NULL,
2035 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
2036 : : .tokens = {
2037 : : (void *)&cmd_config_rx_tx_port,
2038 : : (void *)&cmd_config_rx_tx_keyword,
2039 : : (void *)&cmd_config_rx_tx_all,
2040 : : (void *)&cmd_config_rx_tx_name,
2041 : : (void *)&cmd_config_rx_tx_value,
2042 : : NULL,
2043 : : },
2044 : : };
2045 : :
2046 : : /* *** config max packet length *** */
2047 : : struct cmd_config_max_pkt_len_result {
2048 : : cmdline_fixed_string_t port;
2049 : : cmdline_fixed_string_t keyword;
2050 : : cmdline_fixed_string_t all;
2051 : : cmdline_fixed_string_t name;
2052 : : uint32_t value;
2053 : : };
2054 : :
2055 : : static void
2056 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
2057 : : __rte_unused struct cmdline *cl,
2058 : : __rte_unused void *data)
2059 : : {
2060 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
2061 : : portid_t port_id;
2062 : : int ret;
2063 : :
2064 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
2065 : : printf("Unknown parameter\n");
2066 : 0 : return;
2067 : : }
2068 : :
2069 : 0 : if (!all_ports_stopped()) {
2070 : 0 : fprintf(stderr, "Please stop all ports first\n");
2071 : 0 : return;
2072 : : }
2073 : :
2074 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
2075 : 0 : struct rte_port *port = &ports[port_id];
2076 : :
2077 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
2078 : 0 : fprintf(stderr,
2079 : : "max-pkt-len can not be less than %d\n",
2080 : : RTE_ETHER_MIN_LEN);
2081 : 0 : return;
2082 : : }
2083 : :
2084 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
2085 : 0 : if (ret != 0) {
2086 : 0 : fprintf(stderr,
2087 : : "rte_eth_dev_info_get() failed for port %u\n",
2088 : : port_id);
2089 : 0 : return;
2090 : : }
2091 : :
2092 : 0 : update_mtu_from_frame_size(port_id, res->value);
2093 : : }
2094 : :
2095 : 0 : init_port_config();
2096 : :
2097 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2098 : : }
2099 : :
2100 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2101 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2102 : : "port");
2103 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2104 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2105 : : "config");
2106 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2107 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2108 : : "all");
2109 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2110 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2111 : : "max-pkt-len");
2112 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2113 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2114 : : RTE_UINT32);
2115 : :
2116 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
2117 : : .f = cmd_config_max_pkt_len_parsed,
2118 : : .data = NULL,
2119 : : .help_str = "port config all max-pkt-len <value>",
2120 : : .tokens = {
2121 : : (void *)&cmd_config_max_pkt_len_port,
2122 : : (void *)&cmd_config_max_pkt_len_keyword,
2123 : : (void *)&cmd_config_max_pkt_len_all,
2124 : : (void *)&cmd_config_max_pkt_len_name,
2125 : : (void *)&cmd_config_max_pkt_len_value,
2126 : : NULL,
2127 : : },
2128 : : };
2129 : :
2130 : : /* *** config max LRO aggregated packet size *** */
2131 : : struct cmd_config_max_lro_pkt_size_result {
2132 : : cmdline_fixed_string_t port;
2133 : : cmdline_fixed_string_t keyword;
2134 : : cmdline_fixed_string_t all;
2135 : : cmdline_fixed_string_t name;
2136 : : uint32_t value;
2137 : : };
2138 : :
2139 : : static void
2140 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2141 : : __rte_unused struct cmdline *cl,
2142 : : __rte_unused void *data)
2143 : : {
2144 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2145 : : portid_t pid;
2146 : :
2147 : 0 : if (!all_ports_stopped()) {
2148 : 0 : fprintf(stderr, "Please stop all ports first\n");
2149 : 0 : return;
2150 : : }
2151 : :
2152 : 0 : RTE_ETH_FOREACH_DEV(pid) {
2153 : 0 : struct rte_port *port = &ports[pid];
2154 : :
2155 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
2156 : 0 : if (res->value ==
2157 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
2158 : : return;
2159 : :
2160 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2161 : : } else {
2162 : 0 : fprintf(stderr, "Unknown parameter\n");
2163 : 0 : return;
2164 : : }
2165 : : }
2166 : :
2167 : 0 : init_port_config();
2168 : :
2169 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2170 : : }
2171 : :
2172 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2173 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2174 : : port, "port");
2175 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2176 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2177 : : keyword, "config");
2178 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2179 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2180 : : all, "all");
2181 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2182 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2183 : : name, "max-lro-pkt-size");
2184 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2185 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2186 : : value, RTE_UINT32);
2187 : :
2188 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2189 : : .f = cmd_config_max_lro_pkt_size_parsed,
2190 : : .data = NULL,
2191 : : .help_str = "port config all max-lro-pkt-size <value>",
2192 : : .tokens = {
2193 : : (void *)&cmd_config_max_lro_pkt_size_port,
2194 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
2195 : : (void *)&cmd_config_max_lro_pkt_size_all,
2196 : : (void *)&cmd_config_max_lro_pkt_size_name,
2197 : : (void *)&cmd_config_max_lro_pkt_size_value,
2198 : : NULL,
2199 : : },
2200 : : };
2201 : :
2202 : : /* *** configure port MTU *** */
2203 : : struct cmd_config_mtu_result {
2204 : : cmdline_fixed_string_t port;
2205 : : cmdline_fixed_string_t keyword;
2206 : : cmdline_fixed_string_t mtu;
2207 : : portid_t port_id;
2208 : : uint16_t value;
2209 : : };
2210 : :
2211 : : static void
2212 : 0 : cmd_config_mtu_parsed(void *parsed_result,
2213 : : __rte_unused struct cmdline *cl,
2214 : : __rte_unused void *data)
2215 : : {
2216 : : struct cmd_config_mtu_result *res = parsed_result;
2217 : :
2218 : 0 : port_mtu_set(res->port_id, res->value);
2219 : 0 : }
2220 : :
2221 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
2222 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2223 : : "port");
2224 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2225 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2226 : : "config");
2227 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2228 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2229 : : "mtu");
2230 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2231 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2232 : : RTE_UINT16);
2233 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
2234 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2235 : : RTE_UINT16);
2236 : :
2237 : : static cmdline_parse_inst_t cmd_config_mtu = {
2238 : : .f = cmd_config_mtu_parsed,
2239 : : .data = NULL,
2240 : : .help_str = "port config mtu <port_id> <value>",
2241 : : .tokens = {
2242 : : (void *)&cmd_config_mtu_port,
2243 : : (void *)&cmd_config_mtu_keyword,
2244 : : (void *)&cmd_config_mtu_mtu,
2245 : : (void *)&cmd_config_mtu_port_id,
2246 : : (void *)&cmd_config_mtu_value,
2247 : : NULL,
2248 : : },
2249 : : };
2250 : :
2251 : : /* *** configure rx mode *** */
2252 : : struct cmd_config_rx_mode_flag {
2253 : : cmdline_fixed_string_t port;
2254 : : cmdline_fixed_string_t keyword;
2255 : : cmdline_fixed_string_t all;
2256 : : cmdline_fixed_string_t name;
2257 : : cmdline_fixed_string_t value;
2258 : : };
2259 : :
2260 : : static void
2261 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
2262 : : __rte_unused struct cmdline *cl,
2263 : : __rte_unused void *data)
2264 : : {
2265 : : struct cmd_config_rx_mode_flag *res = parsed_result;
2266 : :
2267 : 0 : if (!all_ports_stopped()) {
2268 : 0 : fprintf(stderr, "Please stop all ports first\n");
2269 : 0 : return;
2270 : : }
2271 : :
2272 : 0 : if (!strcmp(res->name, "drop-en")) {
2273 : 0 : if (!strcmp(res->value, "on"))
2274 : 0 : rx_drop_en = 1;
2275 : 0 : else if (!strcmp(res->value, "off"))
2276 : 0 : rx_drop_en = 0;
2277 : : else {
2278 : 0 : fprintf(stderr, "Unknown parameter\n");
2279 : 0 : return;
2280 : : }
2281 : : } else {
2282 : 0 : fprintf(stderr, "Unknown parameter\n");
2283 : 0 : return;
2284 : : }
2285 : :
2286 : 0 : init_port_config();
2287 : :
2288 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2289 : : }
2290 : :
2291 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2292 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2293 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2294 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2295 : : "config");
2296 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2297 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2298 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2299 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2300 : : "drop-en");
2301 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2302 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2303 : : "on#off");
2304 : :
2305 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2306 : : .f = cmd_config_rx_mode_flag_parsed,
2307 : : .data = NULL,
2308 : : .help_str = "port config all drop-en on|off",
2309 : : .tokens = {
2310 : : (void *)&cmd_config_rx_mode_flag_port,
2311 : : (void *)&cmd_config_rx_mode_flag_keyword,
2312 : : (void *)&cmd_config_rx_mode_flag_all,
2313 : : (void *)&cmd_config_rx_mode_flag_name,
2314 : : (void *)&cmd_config_rx_mode_flag_value,
2315 : : NULL,
2316 : : },
2317 : : };
2318 : :
2319 : : /* *** configure rss *** */
2320 : : struct cmd_config_rss {
2321 : : cmdline_fixed_string_t port;
2322 : : cmdline_fixed_string_t keyword;
2323 : : cmdline_fixed_string_t all;
2324 : : cmdline_fixed_string_t name;
2325 : : cmdline_fixed_string_t value;
2326 : : };
2327 : :
2328 : : static void
2329 : 0 : cmd_config_rss_parsed(void *parsed_result,
2330 : : __rte_unused struct cmdline *cl,
2331 : : __rte_unused void *data)
2332 : : {
2333 : : struct cmd_config_rss *res = parsed_result;
2334 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2335 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2336 : : int use_default = 0;
2337 : : int all_updated = 1;
2338 : : int diag;
2339 : : uint16_t i;
2340 : : int ret;
2341 : :
2342 : 0 : if (!strcmp(res->value, "level-default")) {
2343 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2344 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2345 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2346 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2347 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2348 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2349 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2350 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2351 : 0 : } else if (!strcmp(res->value, "default")) {
2352 : : use_default = 1;
2353 : 0 : } else if (isdigit(res->value[0])) {
2354 : : int value = atoi(res->value);
2355 : 0 : if (value > 0 && value < 64)
2356 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2357 : : else {
2358 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2359 : 0 : return;
2360 : : }
2361 : 0 : } else if (!strcmp(res->value, "none")) {
2362 : : rss_conf.rss_hf = 0;
2363 : : } else {
2364 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2365 : 0 : if (rss_conf.rss_hf == 0) {
2366 : 0 : fprintf(stderr, "Unknown parameter\n");
2367 : 0 : return;
2368 : : }
2369 : : }
2370 : : rss_conf.rss_key = NULL;
2371 : : /* Update global configuration for RSS types. */
2372 : 0 : RTE_ETH_FOREACH_DEV(i) {
2373 : : struct rte_eth_rss_conf local_rss_conf;
2374 : :
2375 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2376 : 0 : if (ret != 0)
2377 : 0 : return;
2378 : :
2379 : 0 : if (use_default)
2380 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2381 : :
2382 : 0 : local_rss_conf = rss_conf;
2383 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2384 : 0 : dev_info.flow_type_rss_offloads;
2385 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2386 : : printf("Port %u modified RSS hash function based on hardware support,"
2387 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2388 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2389 : : }
2390 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2391 : 0 : if (diag < 0) {
2392 : : all_updated = 0;
2393 : 0 : fprintf(stderr,
2394 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2395 : : i, -diag, strerror(-diag));
2396 : : }
2397 : : }
2398 : 0 : if (all_updated && !use_default) {
2399 : 0 : rss_hf = rss_conf.rss_hf;
2400 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2401 : : }
2402 : : }
2403 : :
2404 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2405 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2406 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2407 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2408 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2409 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2410 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2411 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2412 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2413 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2414 : :
2415 : : static cmdline_parse_inst_t cmd_config_rss = {
2416 : : .f = cmd_config_rss_parsed,
2417 : : .data = NULL,
2418 : : .help_str = "port config all rss "
2419 : : "all|default|level-default|level-outer|level-inner|"
2420 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2421 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2422 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2423 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2424 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2425 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2426 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2427 : : .tokens = {
2428 : : (void *)&cmd_config_rss_port,
2429 : : (void *)&cmd_config_rss_keyword,
2430 : : (void *)&cmd_config_rss_all,
2431 : : (void *)&cmd_config_rss_name,
2432 : : (void *)&cmd_config_rss_value,
2433 : : NULL,
2434 : : },
2435 : : };
2436 : :
2437 : : /* *** configure rss hash key *** */
2438 : : struct cmd_config_rss_hash_key {
2439 : : cmdline_fixed_string_t port;
2440 : : cmdline_fixed_string_t config;
2441 : : portid_t port_id;
2442 : : cmdline_fixed_string_t rss_hash_key;
2443 : : cmdline_fixed_string_t rss_type;
2444 : : cmdline_fixed_string_t key;
2445 : : };
2446 : :
2447 : : static uint8_t
2448 : : hexa_digit_to_value(char hexa_digit)
2449 : : {
2450 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2451 : : return (uint8_t) (hexa_digit - '0');
2452 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2453 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2454 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2455 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2456 : : /* Invalid hexa digit */
2457 : : return 0xFF;
2458 : : }
2459 : :
2460 : : static uint8_t
2461 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2462 : : {
2463 : : uint8_t hexa_v;
2464 : :
2465 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2466 : : if (hexa_v == 0xFF)
2467 : 0 : fprintf(stderr,
2468 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2469 : : key[idx], idx);
2470 : 0 : return hexa_v;
2471 : : }
2472 : :
2473 : : static void
2474 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2475 : : __rte_unused struct cmdline *cl,
2476 : : __rte_unused void *data)
2477 : : {
2478 : : struct cmd_config_rss_hash_key *res = parsed_result;
2479 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2480 : : uint8_t xdgt0;
2481 : : uint8_t xdgt1;
2482 : : int i;
2483 : : struct rte_eth_dev_info dev_info;
2484 : : uint8_t hash_key_size;
2485 : : uint32_t key_len;
2486 : : int ret;
2487 : :
2488 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2489 : 0 : if (ret != 0)
2490 : 0 : return;
2491 : :
2492 : 0 : if (dev_info.hash_key_size > 0 &&
2493 : : dev_info.hash_key_size <= sizeof(hash_key))
2494 : : hash_key_size = dev_info.hash_key_size;
2495 : : else {
2496 : 0 : fprintf(stderr,
2497 : : "dev_info did not provide a valid hash key size\n");
2498 : 0 : return;
2499 : : }
2500 : : /* Check the length of the RSS hash key */
2501 : 0 : key_len = strlen(res->key);
2502 : 0 : if (key_len != (hash_key_size * 2)) {
2503 : 0 : fprintf(stderr,
2504 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2505 : : (int)key_len, hash_key_size * 2);
2506 : 0 : return;
2507 : : }
2508 : : /* Translate RSS hash key into binary representation */
2509 : 0 : for (i = 0; i < hash_key_size; i++) {
2510 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2511 : 0 : if (xdgt0 == 0xFF)
2512 : : return;
2513 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2514 : 0 : if (xdgt1 == 0xFF)
2515 : : return;
2516 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2517 : : }
2518 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2519 : : hash_key_size);
2520 : : }
2521 : :
2522 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2523 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2524 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2525 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2526 : : "config");
2527 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2528 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2529 : : RTE_UINT16);
2530 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2531 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2532 : : rss_hash_key, "rss-hash-key");
2533 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2534 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2535 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2536 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2537 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2538 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2539 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2540 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2541 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2542 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2543 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2544 : :
2545 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2546 : : .f = cmd_config_rss_hash_key_parsed,
2547 : : .data = NULL,
2548 : : .help_str = "port config <port_id> rss-hash-key "
2549 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2550 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2551 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2552 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2553 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2554 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2555 : : "<string of hex digits (variable length, NIC dependent)>",
2556 : : .tokens = {
2557 : : (void *)&cmd_config_rss_hash_key_port,
2558 : : (void *)&cmd_config_rss_hash_key_config,
2559 : : (void *)&cmd_config_rss_hash_key_port_id,
2560 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2561 : : (void *)&cmd_config_rss_hash_key_rss_type,
2562 : : (void *)&cmd_config_rss_hash_key_value,
2563 : : NULL,
2564 : : },
2565 : : };
2566 : :
2567 : : /* *** configure rss hash algorithm *** */
2568 : : struct cmd_config_rss_hash_algo {
2569 : : cmdline_fixed_string_t port;
2570 : : cmdline_fixed_string_t config;
2571 : : portid_t port_id;
2572 : : cmdline_fixed_string_t rss_hash_algo;
2573 : : cmdline_fixed_string_t algo;
2574 : : };
2575 : :
2576 : : static void
2577 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2578 : : __rte_unused struct cmdline *cl,
2579 : : __rte_unused void *data)
2580 : : {
2581 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2582 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2583 : : struct rte_eth_rss_conf rss_conf;
2584 : : uint32_t algorithm;
2585 : : int ret;
2586 : :
2587 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2588 : 0 : rss_conf.rss_key = rss_key;
2589 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2590 : 0 : if (ret != 0) {
2591 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2592 : 0 : res->port_id);
2593 : 0 : return;
2594 : : }
2595 : :
2596 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2597 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2598 : 0 : if (ret != 0) {
2599 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2600 : 0 : res->port_id, res->algo);
2601 : 0 : return;
2602 : : }
2603 : :
2604 : 0 : rss_conf.algorithm = algorithm;
2605 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2606 : 0 : if (ret != 0) {
2607 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2608 : 0 : res->port_id);
2609 : 0 : return;
2610 : : }
2611 : : }
2612 : :
2613 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2614 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2615 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2616 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2617 : : "config");
2618 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2619 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2620 : : RTE_UINT16);
2621 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2622 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2623 : : rss_hash_algo, "rss-hash-algo");
2624 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2625 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2626 : : "default#simple_xor#toeplitz#"
2627 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2628 : :
2629 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2630 : : .f = cmd_config_rss_hash_algo_parsed,
2631 : : .data = NULL,
2632 : : .help_str = "port config <port_id> rss-hash-algo "
2633 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2634 : : .tokens = {
2635 : : (void *)&cmd_config_rss_hash_algo_port,
2636 : : (void *)&cmd_config_rss_hash_algo_config,
2637 : : (void *)&cmd_config_rss_hash_algo_port_id,
2638 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2639 : : (void *)&cmd_config_rss_hash_algo_algo,
2640 : : NULL,
2641 : : },
2642 : : };
2643 : :
2644 : : /* *** cleanup txq mbufs *** */
2645 : : struct cmd_cleanup_txq_mbufs_result {
2646 : : cmdline_fixed_string_t port;
2647 : : cmdline_fixed_string_t keyword;
2648 : : cmdline_fixed_string_t name;
2649 : : uint16_t port_id;
2650 : : uint16_t queue_id;
2651 : : uint32_t free_cnt;
2652 : : };
2653 : :
2654 : : static void
2655 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2656 : : __rte_unused struct cmdline *cl,
2657 : : __rte_unused void *data)
2658 : : {
2659 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2660 : 0 : uint16_t port_id = res->port_id;
2661 : 0 : uint16_t queue_id = res->queue_id;
2662 : 0 : uint32_t free_cnt = res->free_cnt;
2663 : : struct rte_eth_txq_info qinfo;
2664 : : int ret;
2665 : :
2666 : 0 : if (test_done == 0) {
2667 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2668 : 0 : return;
2669 : : }
2670 : :
2671 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2672 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2673 : : port_id, queue_id);
2674 : 0 : return;
2675 : : }
2676 : :
2677 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2678 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2679 : 0 : return;
2680 : : }
2681 : :
2682 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2683 : 0 : if (ret < 0) {
2684 : 0 : fprintf(stderr,
2685 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2686 : : port_id, queue_id, strerror(-ret), ret);
2687 : 0 : return;
2688 : : }
2689 : :
2690 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2691 : : port_id, queue_id, ret);
2692 : : }
2693 : :
2694 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2695 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2696 : : "port");
2697 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2698 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2699 : : "cleanup");
2700 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2701 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2702 : : RTE_UINT16);
2703 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2704 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2705 : : "txq");
2706 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2707 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2708 : : RTE_UINT16);
2709 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2710 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2711 : : RTE_UINT32);
2712 : :
2713 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2714 : : .f = cmd_cleanup_txq_mbufs_parsed,
2715 : : .data = NULL,
2716 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2717 : : .tokens = {
2718 : : (void *)&cmd_cleanup_txq_mbufs_port,
2719 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2720 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2721 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2722 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2723 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2724 : : NULL,
2725 : : },
2726 : : };
2727 : :
2728 : : /* *** configure port rxq/txq ring size *** */
2729 : : struct cmd_config_rxtx_ring_size {
2730 : : cmdline_fixed_string_t port;
2731 : : cmdline_fixed_string_t config;
2732 : : portid_t portid;
2733 : : cmdline_fixed_string_t rxtxq;
2734 : : uint16_t qid;
2735 : : cmdline_fixed_string_t rsize;
2736 : : uint16_t size;
2737 : : };
2738 : :
2739 : : static void
2740 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2741 : : __rte_unused struct cmdline *cl,
2742 : : __rte_unused void *data)
2743 : : {
2744 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2745 : : struct rte_port *port;
2746 : : uint8_t isrx;
2747 : :
2748 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2749 : : return;
2750 : :
2751 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2752 : 0 : fprintf(stderr, "Invalid port id\n");
2753 : 0 : return;
2754 : : }
2755 : :
2756 : 0 : port = &ports[res->portid];
2757 : :
2758 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2759 : : isrx = 1;
2760 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2761 : : isrx = 0;
2762 : : else {
2763 : 0 : fprintf(stderr, "Unknown parameter\n");
2764 : 0 : return;
2765 : : }
2766 : :
2767 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2768 : : return;
2769 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2770 : : return;
2771 : :
2772 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2773 : 0 : fprintf(stderr,
2774 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2775 : : rx_free_thresh);
2776 : 0 : return;
2777 : : }
2778 : :
2779 : 0 : if (isrx)
2780 : 0 : port->nb_rx_desc[res->qid] = res->size;
2781 : : else
2782 : 0 : port->nb_tx_desc[res->qid] = res->size;
2783 : :
2784 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2785 : : }
2786 : :
2787 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2788 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2789 : : port, "port");
2790 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2791 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2792 : : config, "config");
2793 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2794 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2795 : : portid, RTE_UINT16);
2796 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2797 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2798 : : rxtxq, "rxq#txq");
2799 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2800 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2801 : : qid, RTE_UINT16);
2802 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2803 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2804 : : rsize, "ring_size");
2805 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2806 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2807 : : size, RTE_UINT16);
2808 : :
2809 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2810 : : .f = cmd_config_rxtx_ring_size_parsed,
2811 : : .data = NULL,
2812 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2813 : : .tokens = {
2814 : : (void *)&cmd_config_rxtx_ring_size_port,
2815 : : (void *)&cmd_config_rxtx_ring_size_config,
2816 : : (void *)&cmd_config_rxtx_ring_size_portid,
2817 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2818 : : (void *)&cmd_config_rxtx_ring_size_qid,
2819 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2820 : : (void *)&cmd_config_rxtx_ring_size_size,
2821 : : NULL,
2822 : : },
2823 : : };
2824 : :
2825 : : /* *** configure port rxq/txq start/stop *** */
2826 : : struct cmd_config_rxtx_queue {
2827 : : cmdline_fixed_string_t port;
2828 : : portid_t portid;
2829 : : cmdline_fixed_string_t rxtxq;
2830 : : uint16_t qid;
2831 : : cmdline_fixed_string_t opname;
2832 : : };
2833 : :
2834 : : static void
2835 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2836 : : __rte_unused struct cmdline *cl,
2837 : : __rte_unused void *data)
2838 : : {
2839 : : struct cmd_config_rxtx_queue *res = parsed_result;
2840 : : struct rte_port *port;
2841 : : uint8_t isrx;
2842 : : uint8_t isstart;
2843 : : uint8_t *state;
2844 : : int ret = 0;
2845 : :
2846 : 0 : if (test_done == 0) {
2847 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2848 : 0 : return;
2849 : : }
2850 : :
2851 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2852 : : return;
2853 : :
2854 : 0 : if (port_is_started(res->portid) != 1) {
2855 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2856 : 0 : return;
2857 : : }
2858 : :
2859 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2860 : : isrx = 1;
2861 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2862 : : isrx = 0;
2863 : : else {
2864 : 0 : fprintf(stderr, "Unknown parameter\n");
2865 : 0 : return;
2866 : : }
2867 : :
2868 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2869 : : return;
2870 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2871 : : return;
2872 : :
2873 : 0 : if (!strcmp(res->opname, "start"))
2874 : : isstart = 1;
2875 : 0 : else if (!strcmp(res->opname, "stop"))
2876 : : isstart = 0;
2877 : : else {
2878 : 0 : fprintf(stderr, "Unknown parameter\n");
2879 : 0 : return;
2880 : : }
2881 : :
2882 : 0 : if (isstart && isrx)
2883 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2884 : 0 : else if (!isstart && isrx)
2885 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2886 : 0 : else if (isstart && !isrx)
2887 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2888 : : else
2889 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2890 : :
2891 : 0 : if (ret == -ENOTSUP) {
2892 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2893 : 0 : return;
2894 : : }
2895 : :
2896 : 0 : port = &ports[res->portid];
2897 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2898 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2899 : : RTE_ETH_QUEUE_STATE_STOPPED;
2900 : : }
2901 : :
2902 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2903 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2904 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2905 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2906 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2907 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2908 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2909 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2910 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2911 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2912 : : "start#stop");
2913 : :
2914 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2915 : : .f = cmd_config_rxtx_queue_parsed,
2916 : : .data = NULL,
2917 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2918 : : .tokens = {
2919 : : (void *)&cmd_config_rxtx_queue_port,
2920 : : (void *)&cmd_config_rxtx_queue_portid,
2921 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2922 : : (void *)&cmd_config_rxtx_queue_qid,
2923 : : (void *)&cmd_config_rxtx_queue_opname,
2924 : : NULL,
2925 : : },
2926 : : };
2927 : :
2928 : : /* *** configure port rxq/txq deferred start on/off *** */
2929 : : struct cmd_config_deferred_start_rxtx_queue {
2930 : : cmdline_fixed_string_t port;
2931 : : portid_t port_id;
2932 : : cmdline_fixed_string_t rxtxq;
2933 : : uint16_t qid;
2934 : : cmdline_fixed_string_t opname;
2935 : : cmdline_fixed_string_t state;
2936 : : };
2937 : :
2938 : : static void
2939 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2940 : : __rte_unused struct cmdline *cl,
2941 : : __rte_unused void *data)
2942 : : {
2943 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2944 : : struct rte_port *port;
2945 : : uint8_t isrx;
2946 : : uint8_t ison;
2947 : : uint8_t needreconfig = 0;
2948 : :
2949 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2950 : : return;
2951 : :
2952 : 0 : if (port_is_started(res->port_id) != 0) {
2953 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2954 : 0 : return;
2955 : : }
2956 : :
2957 : 0 : port = &ports[res->port_id];
2958 : :
2959 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2960 : :
2961 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2962 : : return;
2963 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2964 : : return;
2965 : :
2966 : 0 : ison = !strcmp(res->state, "on");
2967 : :
2968 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2969 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2970 : : needreconfig = 1;
2971 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2972 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2973 : : needreconfig = 1;
2974 : : }
2975 : :
2976 : : if (needreconfig)
2977 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2978 : : }
2979 : :
2980 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2981 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2982 : : port, "port");
2983 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2984 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2985 : : port_id, RTE_UINT16);
2986 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2987 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2988 : : rxtxq, "rxq#txq");
2989 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2990 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2991 : : qid, RTE_UINT16);
2992 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2993 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2994 : : opname, "deferred_start");
2995 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2996 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2997 : : state, "on#off");
2998 : :
2999 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
3000 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
3001 : : .data = NULL,
3002 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
3003 : : .tokens = {
3004 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
3005 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
3006 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
3007 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
3008 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
3009 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
3010 : : NULL,
3011 : : },
3012 : : };
3013 : :
3014 : : /* *** configure port rxq/txq setup *** */
3015 : : struct cmd_setup_rxtx_queue {
3016 : : cmdline_fixed_string_t port;
3017 : : portid_t portid;
3018 : : cmdline_fixed_string_t rxtxq;
3019 : : uint16_t qid;
3020 : : cmdline_fixed_string_t setup;
3021 : : };
3022 : :
3023 : : /* Common CLI fields for queue setup */
3024 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
3025 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
3026 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
3027 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
3028 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
3029 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
3030 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
3031 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
3032 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
3033 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
3034 : :
3035 : : static void
3036 : 0 : cmd_setup_rxtx_queue_parsed(
3037 : : void *parsed_result,
3038 : : __rte_unused struct cmdline *cl,
3039 : : __rte_unused void *data)
3040 : : {
3041 : : struct cmd_setup_rxtx_queue *res = parsed_result;
3042 : : struct rte_port *port;
3043 : : struct rte_mempool *mp;
3044 : : unsigned int socket_id;
3045 : : uint8_t isrx = 0;
3046 : : int ret;
3047 : :
3048 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
3049 : : return;
3050 : :
3051 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
3052 : 0 : fprintf(stderr, "Invalid port id\n");
3053 : 0 : return;
3054 : : }
3055 : :
3056 : 0 : if (!strcmp(res->rxtxq, "rxq"))
3057 : : isrx = 1;
3058 : 0 : else if (!strcmp(res->rxtxq, "txq"))
3059 : : isrx = 0;
3060 : : else {
3061 : 0 : fprintf(stderr, "Unknown parameter\n");
3062 : 0 : return;
3063 : : }
3064 : :
3065 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
3066 : 0 : fprintf(stderr, "Invalid rx queue\n");
3067 : 0 : return;
3068 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
3069 : 0 : fprintf(stderr, "Invalid tx queue\n");
3070 : 0 : return;
3071 : : }
3072 : :
3073 : 0 : port = &ports[res->portid];
3074 : 0 : if (isrx) {
3075 : 0 : socket_id = rxring_numa[res->portid];
3076 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3077 : 0 : socket_id = port->socket_id;
3078 : :
3079 : 0 : mp = mbuf_pool_find_first(socket_id);
3080 : 0 : if (mp == NULL) {
3081 : : char buf[16];
3082 : :
3083 : 0 : fprintf(stderr,
3084 : : "Failed to setup RX queue: No mempool allocation on the socket %s\n",
3085 : : socket_id_str(socket_id, buf, sizeof(buf)));
3086 : : return;
3087 : : }
3088 : 0 : ret = rx_queue_setup(res->portid,
3089 : : res->qid,
3090 : 0 : port->nb_rx_desc[res->qid],
3091 : : socket_id,
3092 : 0 : &port->rxq[res->qid].conf,
3093 : : mp);
3094 : 0 : if (ret)
3095 : 0 : fprintf(stderr, "Failed to setup RX queue: %s\n",
3096 : : rte_strerror(-ret));
3097 : : } else {
3098 : 0 : socket_id = txring_numa[res->portid];
3099 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3100 : 0 : socket_id = port->socket_id;
3101 : :
3102 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
3103 : 0 : fprintf(stderr,
3104 : : "Failed to setup TX queue: not enough descriptors\n");
3105 : 0 : return;
3106 : : }
3107 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
3108 : : res->qid,
3109 : : port->nb_tx_desc[res->qid],
3110 : : socket_id,
3111 : 0 : &port->txq[res->qid].conf);
3112 : 0 : if (ret)
3113 : 0 : fprintf(stderr, "Failed to setup TX queue: %s\n",
3114 : : rte_strerror(-ret));
3115 : : }
3116 : : }
3117 : :
3118 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
3119 : : .f = cmd_setup_rxtx_queue_parsed,
3120 : : .data = NULL,
3121 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
3122 : : .tokens = {
3123 : : (void *)&cmd_setup_rxtx_queue_port,
3124 : : (void *)&cmd_setup_rxtx_queue_portid,
3125 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
3126 : : (void *)&cmd_setup_rxtx_queue_qid,
3127 : : (void *)&cmd_setup_rxtx_queue_setup,
3128 : : NULL,
3129 : : },
3130 : : };
3131 : :
3132 : :
3133 : : /* *** Configure RSS RETA *** */
3134 : : struct cmd_config_rss_reta {
3135 : : cmdline_fixed_string_t port;
3136 : : cmdline_fixed_string_t keyword;
3137 : : portid_t port_id;
3138 : : cmdline_fixed_string_t name;
3139 : : cmdline_fixed_string_t list_name;
3140 : : cmdline_fixed_string_t list_of_items;
3141 : : };
3142 : :
3143 : : static int
3144 : 0 : parse_reta_config(const char *str,
3145 : : struct rte_eth_rss_reta_entry64 *reta_conf,
3146 : : uint16_t nb_entries)
3147 : : {
3148 : : int i;
3149 : : unsigned size;
3150 : : uint16_t hash_index, idx, shift;
3151 : : uint16_t nb_queue;
3152 : : char s[256];
3153 : : const char *p, *p0 = str;
3154 : : char *end;
3155 : : enum fieldnames {
3156 : : FLD_HASH_INDEX = 0,
3157 : : FLD_QUEUE,
3158 : : _NUM_FLD
3159 : : };
3160 : : unsigned long int_fld[_NUM_FLD];
3161 : : char *str_fld[_NUM_FLD];
3162 : :
3163 : 0 : while ((p = strchr(p0,'(')) != NULL) {
3164 : 0 : ++p;
3165 : 0 : if((p0 = strchr(p,')')) == NULL)
3166 : : return -1;
3167 : :
3168 : 0 : size = p0 - p;
3169 : 0 : if(size >= sizeof(s))
3170 : : return -1;
3171 : :
3172 : : snprintf(s, sizeof(s), "%.*s", size, p);
3173 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3174 : : return -1;
3175 : 0 : for (i = 0; i < _NUM_FLD; i++) {
3176 : 0 : errno = 0;
3177 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
3178 : 0 : if (errno != 0 || end == str_fld[i] ||
3179 : : int_fld[i] > 65535)
3180 : : return -1;
3181 : : }
3182 : :
3183 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3184 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3185 : :
3186 : 0 : if (hash_index >= nb_entries) {
3187 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
3188 : : hash_index);
3189 : 0 : return -1;
3190 : : }
3191 : :
3192 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3193 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3194 : 0 : reta_conf[idx].mask |= (1ULL << shift);
3195 : 0 : reta_conf[idx].reta[shift] = nb_queue;
3196 : : }
3197 : :
3198 : : return 0;
3199 : : }
3200 : :
3201 : : static void
3202 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
3203 : : __rte_unused struct cmdline *cl,
3204 : : __rte_unused void *data)
3205 : : {
3206 : : int ret;
3207 : : struct rte_eth_dev_info dev_info;
3208 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3209 : : struct cmd_config_rss_reta *res = parsed_result;
3210 : :
3211 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3212 : 0 : if (ret != 0)
3213 : 0 : return;
3214 : :
3215 : 0 : if (dev_info.reta_size == 0) {
3216 : 0 : fprintf(stderr,
3217 : : "Redirection table size is 0 which is invalid for RSS\n");
3218 : 0 : return;
3219 : : } else
3220 : 0 : printf("The reta size of port %d is %u\n",
3221 : 0 : res->port_id, dev_info.reta_size);
3222 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3223 : 0 : fprintf(stderr,
3224 : : "Currently do not support more than %u entries of redirection table\n",
3225 : : RTE_ETH_RSS_RETA_SIZE_512);
3226 : 0 : return;
3227 : : }
3228 : :
3229 : : memset(reta_conf, 0, sizeof(reta_conf));
3230 : 0 : if (!strcmp(res->list_name, "reta")) {
3231 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
3232 : : dev_info.reta_size)) {
3233 : 0 : fprintf(stderr,
3234 : : "Invalid RSS Redirection Table config entered\n");
3235 : 0 : return;
3236 : : }
3237 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
3238 : 0 : reta_conf, dev_info.reta_size);
3239 : 0 : if (ret != 0)
3240 : 0 : fprintf(stderr,
3241 : : "Bad redirection table parameter, return code = %d\n",
3242 : : ret);
3243 : : }
3244 : : }
3245 : :
3246 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3247 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3248 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3249 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3250 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3251 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3252 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3253 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3254 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3255 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3256 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3257 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3258 : : NULL);
3259 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
3260 : : .f = cmd_set_rss_reta_parsed,
3261 : : .data = NULL,
3262 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3263 : : .tokens = {
3264 : : (void *)&cmd_config_rss_reta_port,
3265 : : (void *)&cmd_config_rss_reta_keyword,
3266 : : (void *)&cmd_config_rss_reta_port_id,
3267 : : (void *)&cmd_config_rss_reta_name,
3268 : : (void *)&cmd_config_rss_reta_list_name,
3269 : : (void *)&cmd_config_rss_reta_list_of_items,
3270 : : NULL,
3271 : : },
3272 : : };
3273 : :
3274 : : /* *** SHOW PORT RETA INFO *** */
3275 : : struct cmd_showport_reta {
3276 : : cmdline_fixed_string_t show;
3277 : : cmdline_fixed_string_t port;
3278 : : portid_t port_id;
3279 : : cmdline_fixed_string_t rss;
3280 : : cmdline_fixed_string_t reta;
3281 : : uint16_t size;
3282 : : cmdline_fixed_string_t list_of_items;
3283 : : };
3284 : :
3285 : : static int
3286 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3287 : : uint16_t nb_entries,
3288 : : char *str)
3289 : : {
3290 : : uint32_t size;
3291 : : const char *p, *p0 = str;
3292 : : char s[256];
3293 : : char *end;
3294 : : char *str_fld[8];
3295 : : uint16_t i;
3296 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3297 : : RTE_ETH_RETA_GROUP_SIZE;
3298 : : int ret;
3299 : :
3300 : 0 : p = strchr(p0, '(');
3301 : 0 : if (p == NULL)
3302 : : return -1;
3303 : 0 : p++;
3304 : 0 : p0 = strchr(p, ')');
3305 : 0 : if (p0 == NULL)
3306 : : return -1;
3307 : 0 : size = p0 - p;
3308 : 0 : if (size >= sizeof(s)) {
3309 : 0 : fprintf(stderr,
3310 : : "The string size exceeds the internal buffer size\n");
3311 : 0 : return -1;
3312 : : }
3313 : : snprintf(s, sizeof(s), "%.*s", size, p);
3314 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3315 : 0 : if (ret <= 0 || ret != num) {
3316 : 0 : fprintf(stderr,
3317 : : "The bits of masks do not match the number of reta entries: %u\n",
3318 : : num);
3319 : 0 : return -1;
3320 : : }
3321 : 0 : for (i = 0; i < ret; i++)
3322 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3323 : :
3324 : : return 0;
3325 : : }
3326 : :
3327 : : static void
3328 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3329 : : __rte_unused struct cmdline *cl,
3330 : : __rte_unused void *data)
3331 : : {
3332 : : struct cmd_showport_reta *res = parsed_result;
3333 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3334 : : struct rte_eth_dev_info dev_info;
3335 : : uint16_t max_reta_size;
3336 : : int ret;
3337 : :
3338 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3339 : 0 : if (ret != 0)
3340 : 0 : return;
3341 : :
3342 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3343 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3344 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3345 : : res->size, max_reta_size);
3346 : 0 : return;
3347 : : }
3348 : :
3349 : : memset(reta_conf, 0, sizeof(reta_conf));
3350 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3351 : 0 : res->list_of_items) < 0) {
3352 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3353 : : res->list_of_items);
3354 : 0 : return;
3355 : : }
3356 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3357 : : }
3358 : :
3359 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3360 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3361 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3362 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3363 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3364 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3365 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3366 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3367 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3368 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3369 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3370 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3371 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3372 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3373 : : list_of_items, NULL);
3374 : :
3375 : : static cmdline_parse_inst_t cmd_showport_reta = {
3376 : : .f = cmd_showport_reta_parsed,
3377 : : .data = NULL,
3378 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3379 : : .tokens = {
3380 : : (void *)&cmd_showport_reta_show,
3381 : : (void *)&cmd_showport_reta_port,
3382 : : (void *)&cmd_showport_reta_port_id,
3383 : : (void *)&cmd_showport_reta_rss,
3384 : : (void *)&cmd_showport_reta_reta,
3385 : : (void *)&cmd_showport_reta_size,
3386 : : (void *)&cmd_showport_reta_list_of_items,
3387 : : NULL,
3388 : : },
3389 : : };
3390 : :
3391 : : /* *** Show RSS hash configuration *** */
3392 : : struct cmd_showport_rss_hash {
3393 : : cmdline_fixed_string_t show;
3394 : : cmdline_fixed_string_t port;
3395 : : portid_t port_id;
3396 : : cmdline_fixed_string_t rss_hash;
3397 : : cmdline_fixed_string_t rss_type;
3398 : : cmdline_fixed_string_t key; /* optional argument */
3399 : : cmdline_fixed_string_t algorithm; /* optional argument */
3400 : : };
3401 : :
3402 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3403 : : __rte_unused struct cmdline *cl,
3404 : : __rte_unused void *data)
3405 : : {
3406 : : struct cmd_showport_rss_hash *res = parsed_result;
3407 : :
3408 : 0 : port_rss_hash_conf_show(res->port_id,
3409 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3410 : 0 : }
3411 : :
3412 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3413 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3414 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3415 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3416 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3417 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3418 : : RTE_UINT16);
3419 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3420 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3421 : : "rss-hash");
3422 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3423 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3424 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3425 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3426 : :
3427 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3428 : : .f = cmd_showport_rss_hash_parsed,
3429 : : .data = NULL,
3430 : : .help_str = "show port <port_id> rss-hash",
3431 : : .tokens = {
3432 : : (void *)&cmd_showport_rss_hash_show,
3433 : : (void *)&cmd_showport_rss_hash_port,
3434 : : (void *)&cmd_showport_rss_hash_port_id,
3435 : : (void *)&cmd_showport_rss_hash_rss_hash,
3436 : : NULL,
3437 : : },
3438 : : };
3439 : :
3440 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3441 : : .f = cmd_showport_rss_hash_parsed,
3442 : : .data = NULL,
3443 : : .help_str = "show port <port_id> rss-hash key",
3444 : : .tokens = {
3445 : : (void *)&cmd_showport_rss_hash_show,
3446 : : (void *)&cmd_showport_rss_hash_port,
3447 : : (void *)&cmd_showport_rss_hash_port_id,
3448 : : (void *)&cmd_showport_rss_hash_rss_hash,
3449 : : (void *)&cmd_showport_rss_hash_rss_key,
3450 : : NULL,
3451 : : },
3452 : : };
3453 : :
3454 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3455 : : .f = cmd_showport_rss_hash_parsed,
3456 : : .data = NULL,
3457 : : .help_str = "show port <port_id> rss-hash algorithm",
3458 : : .tokens = {
3459 : : (void *)&cmd_showport_rss_hash_show,
3460 : : (void *)&cmd_showport_rss_hash_port,
3461 : : (void *)&cmd_showport_rss_hash_port_id,
3462 : : (void *)&cmd_showport_rss_hash_rss_hash,
3463 : : (void *)&cmd_showport_rss_hash_rss_algo,
3464 : : NULL,
3465 : : },
3466 : : };
3467 : :
3468 : : /* *** Configure DCB *** */
3469 : : struct cmd_config_dcb {
3470 : : cmdline_fixed_string_t port;
3471 : : cmdline_fixed_string_t config;
3472 : : portid_t port_id;
3473 : : cmdline_fixed_string_t dcb;
3474 : : cmdline_fixed_string_t vt;
3475 : : cmdline_fixed_string_t vt_en;
3476 : : uint8_t num_tcs;
3477 : : cmdline_fixed_string_t pfc;
3478 : : cmdline_multi_string_t token_str;
3479 : : };
3480 : :
3481 : : static int
3482 : 0 : parse_dcb_token_prio_tc(char *param_str[], int param_num,
3483 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3484 : : uint8_t *prio_tc_en)
3485 : : {
3486 : : unsigned long prio, tc;
3487 : : int prio_tc_maps = 0;
3488 : : char *param, *end;
3489 : : int i;
3490 : :
3491 : 0 : for (i = 0; i < param_num; i++) {
3492 : 0 : param = param_str[i];
3493 : 0 : prio = strtoul(param, &end, 10);
3494 : 0 : if (prio >= RTE_ETH_DCB_NUM_USER_PRIORITIES) {
3495 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO %lu\n", prio);
3496 : 0 : return -1;
3497 : : }
3498 : 0 : if ((*end != ':') || (strlen(end + 1) == 0)) {
3499 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3500 : 0 : return -1;
3501 : : }
3502 : 0 : tc = strtoul(end + 1, &end, 10);
3503 : 0 : if (tc >= RTE_ETH_8_TCS) {
3504 : 0 : fprintf(stderr, "Bad Argument: invalid TC %lu\n", tc);
3505 : 0 : return -1;
3506 : : }
3507 : 0 : if (*end != '\0') {
3508 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3509 : 0 : return -1;
3510 : : }
3511 : 0 : prio_tc[prio] = tc;
3512 : 0 : prio_tc_maps++;
3513 : : } while (0);
3514 : :
3515 : 0 : if (prio_tc_maps == 0) {
3516 : 0 : fprintf(stderr, "Bad Argument: no PRIO:TC provided\n");
3517 : 0 : return -1;
3518 : : }
3519 : 0 : *prio_tc_en = 1;
3520 : :
3521 : 0 : return 0;
3522 : : }
3523 : :
3524 : : #define DCB_TOKEN_PRIO_TC "prio-tc"
3525 : : #define DCB_TOKEN_KEEP_QNUM "keep-qnum"
3526 : :
3527 : : static int
3528 : 0 : parse_dcb_token_find(char *split_str[], int split_num, int *param_num)
3529 : : {
3530 : : int i;
3531 : :
3532 : 0 : if (strcmp(split_str[0], DCB_TOKEN_KEEP_QNUM) == 0) {
3533 : 0 : *param_num = 0;
3534 : 0 : return 0;
3535 : : }
3536 : :
3537 : 0 : if (strcmp(split_str[0], DCB_TOKEN_PRIO_TC) != 0) {
3538 : 0 : fprintf(stderr, "Bad Argument: unknown token %s\n", split_str[0]);
3539 : 0 : return -EINVAL;
3540 : : }
3541 : :
3542 : 0 : for (i = 1; i < split_num; i++) {
3543 : 0 : if ((strcmp(split_str[i], DCB_TOKEN_PRIO_TC) != 0) &&
3544 : 0 : (strcmp(split_str[i], DCB_TOKEN_KEEP_QNUM) != 0))
3545 : : continue;
3546 : : /* find another optional parameter, then exit. */
3547 : : break;
3548 : : }
3549 : :
3550 : 0 : *param_num = i - 1;
3551 : :
3552 : 0 : return 0;
3553 : : }
3554 : :
3555 : : static int
3556 : 0 : parse_dcb_token_value(char *token_str,
3557 : : uint8_t *pfc_en,
3558 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3559 : : uint8_t *prio_tc_en,
3560 : : uint8_t *keep_qnum)
3561 : : {
3562 : : #define MAX_TOKEN_NUM 128
3563 : : char *split_str[MAX_TOKEN_NUM];
3564 : : int param_num, start, ret;
3565 : : int split_num = 0;
3566 : : char *token;
3567 : :
3568 : : /* split multiple token to split str. */
3569 : : do {
3570 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
3571 : 0 : if (token == NULL)
3572 : : break;
3573 : 0 : if (split_num >= MAX_TOKEN_NUM) {
3574 : 0 : fprintf(stderr, "Bad Argument: too much argument\n");
3575 : 0 : return -1;
3576 : : }
3577 : 0 : split_str[split_num++] = token;
3578 : : } while (1);
3579 : :
3580 : : /* parse fixed parameter "pfc-en" first. */
3581 : 0 : token = split_str[0];
3582 : 0 : if (strcmp(token, "on") == 0)
3583 : 0 : *pfc_en = 1;
3584 : 0 : else if (strcmp(token, "off") == 0)
3585 : 0 : *pfc_en = 0;
3586 : : else {
3587 : 0 : fprintf(stderr, "Bad Argument: pfc-en must be on or off\n");
3588 : 0 : return -EINVAL;
3589 : : }
3590 : :
3591 : 0 : if (split_num == 1)
3592 : : return 0;
3593 : :
3594 : : /* start parse optional parameter. */
3595 : : start = 1;
3596 : : do {
3597 : 0 : param_num = 0;
3598 : 0 : ret = parse_dcb_token_find(&split_str[start], split_num - start, ¶m_num);
3599 : 0 : if (ret != 0)
3600 : 0 : return ret;
3601 : :
3602 : 0 : token = split_str[start];
3603 : 0 : if (strcmp(token, DCB_TOKEN_PRIO_TC) == 0) {
3604 : 0 : if (*prio_tc_en == 1) {
3605 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3606 : : DCB_TOKEN_PRIO_TC);
3607 : 0 : return -1;
3608 : : }
3609 : 0 : ret = parse_dcb_token_prio_tc(&split_str[start + 1], param_num, prio_tc,
3610 : : prio_tc_en);
3611 : 0 : if (ret != 0)
3612 : 0 : return ret;
3613 : : } else {
3614 : : /* this must be keep-qnum. */
3615 : 0 : if (*keep_qnum == 1) {
3616 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3617 : : DCB_TOKEN_KEEP_QNUM);
3618 : 0 : return -1;
3619 : : }
3620 : 0 : *keep_qnum = 1;
3621 : : }
3622 : :
3623 : 0 : start += param_num + 1;
3624 : 0 : if (start >= split_num)
3625 : : break;
3626 : : } while (1);
3627 : :
3628 : : return 0;
3629 : : }
3630 : :
3631 : : static void
3632 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3633 : : __rte_unused struct cmdline *cl,
3634 : : __rte_unused void *data)
3635 : : {
3636 : 0 : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES] = {0};
3637 : : struct cmd_config_dcb *res = parsed_result;
3638 : : struct rte_eth_dcb_info dcb_info;
3639 : 0 : portid_t port_id = res->port_id;
3640 : 0 : uint8_t prio_tc_en = 0;
3641 : 0 : uint8_t keep_qnum = 0;
3642 : : struct rte_port *port;
3643 : 0 : uint8_t pfc_en = 0;
3644 : : int ret;
3645 : :
3646 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
3647 : 0 : return;
3648 : :
3649 : 0 : port = &ports[port_id];
3650 : : /** Check if the port is not started **/
3651 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3652 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3653 : 0 : return;
3654 : : }
3655 : :
3656 : 0 : if (res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS) {
3657 : 0 : fprintf(stderr,
3658 : : "The invalid number of traffic class, only 1~8 allowed.\n");
3659 : 0 : return;
3660 : : }
3661 : :
3662 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3663 : 0 : fprintf(stderr,
3664 : : "nb_cores shouldn't be less than number of TCs.\n");
3665 : 0 : return;
3666 : : }
3667 : :
3668 : : /* Check whether the port supports the report of DCB info. */
3669 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3670 : 0 : if (ret == -ENOTSUP) {
3671 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3672 : 0 : return;
3673 : : }
3674 : :
3675 : 0 : ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en, &keep_qnum);
3676 : 0 : if (ret != 0)
3677 : : return;
3678 : :
3679 : : /* DCB in VT mode */
3680 : 0 : if (!strncmp(res->vt_en, "on", 2))
3681 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3682 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3683 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3684 : : else
3685 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3686 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3687 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3688 : 0 : if (ret != 0) {
3689 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3690 : 0 : return;
3691 : : }
3692 : :
3693 : 0 : fwd_config_setup();
3694 : :
3695 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3696 : : }
3697 : :
3698 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3699 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3700 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3701 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3702 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3703 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3704 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3705 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3706 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3707 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3708 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3709 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3710 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3711 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3712 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3713 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3714 : : static cmdline_parse_token_string_t cmd_config_dcb_token_str =
3715 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, token_str, TOKEN_STRING_MULTI);
3716 : :
3717 : : static cmdline_parse_inst_t cmd_config_dcb = {
3718 : : .f = cmd_config_dcb_parsed,
3719 : : .data = NULL,
3720 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP keep-qnum\n"
3721 : : "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
3722 : : " PRIO-MAPPING := PRIO:TC\n"
3723 : : " PRIO: { 0 .. 7 }\n"
3724 : : " TC: { 0 .. 7 }",
3725 : : .tokens = {
3726 : : (void *)&cmd_config_dcb_port,
3727 : : (void *)&cmd_config_dcb_config,
3728 : : (void *)&cmd_config_dcb_port_id,
3729 : : (void *)&cmd_config_dcb_dcb,
3730 : : (void *)&cmd_config_dcb_vt,
3731 : : (void *)&cmd_config_dcb_vt_en,
3732 : : (void *)&cmd_config_dcb_num_tcs,
3733 : : (void *)&cmd_config_dcb_pfc,
3734 : : (void *)&cmd_config_dcb_token_str,
3735 : : NULL,
3736 : : },
3737 : : };
3738 : :
3739 : : /* *** configure number of packets per burst *** */
3740 : : struct cmd_config_burst {
3741 : : cmdline_fixed_string_t port;
3742 : : cmdline_fixed_string_t keyword;
3743 : : cmdline_fixed_string_t all;
3744 : : cmdline_fixed_string_t name;
3745 : : uint16_t value;
3746 : : };
3747 : :
3748 : : static void
3749 : 0 : cmd_config_burst_parsed(void *parsed_result,
3750 : : __rte_unused struct cmdline *cl,
3751 : : __rte_unused void *data)
3752 : : {
3753 : : struct cmd_config_burst *res = parsed_result;
3754 : : struct rte_eth_dev_info dev_info;
3755 : : uint16_t rec_nb_pkts;
3756 : : int ret;
3757 : :
3758 : 0 : if (!all_ports_stopped()) {
3759 : 0 : fprintf(stderr, "Please stop all ports first\n");
3760 : 0 : return;
3761 : : }
3762 : :
3763 : 0 : if (!strcmp(res->name, "burst")) {
3764 : 0 : if (res->value == 0) {
3765 : : /* If user gives a value of zero, query the PMD for
3766 : : * its recommended Rx burst size. Testpmd uses a single
3767 : : * size for all ports, so assume all ports are the same
3768 : : * NIC model and use the values from Port 0.
3769 : : */
3770 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3771 : 0 : if (ret != 0)
3772 : : return;
3773 : :
3774 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3775 : :
3776 : 0 : if (rec_nb_pkts == 0) {
3777 : : printf("PMD does not recommend a burst size.\n"
3778 : : "User provided value must be between"
3779 : : " 1 and %d\n", MAX_PKT_BURST);
3780 : 0 : return;
3781 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3782 : 0 : printf("PMD recommended burst size of %d"
3783 : : " exceeds maximum value of %d\n",
3784 : : rec_nb_pkts, MAX_PKT_BURST);
3785 : 0 : return;
3786 : : }
3787 : 0 : printf("Using PMD-provided burst value of %d\n",
3788 : : rec_nb_pkts);
3789 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3790 : 0 : } else if (res->value > MAX_PKT_BURST) {
3791 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3792 : : MAX_PKT_BURST);
3793 : 0 : return;
3794 : : } else
3795 : 0 : nb_pkt_per_burst = res->value;
3796 : : } else {
3797 : 0 : fprintf(stderr, "Unknown parameter\n");
3798 : 0 : return;
3799 : : }
3800 : :
3801 : 0 : init_port_config();
3802 : :
3803 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3804 : : }
3805 : :
3806 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3807 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3808 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3809 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3810 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3811 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3812 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3813 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3814 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3815 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3816 : :
3817 : : static cmdline_parse_inst_t cmd_config_burst = {
3818 : : .f = cmd_config_burst_parsed,
3819 : : .data = NULL,
3820 : : .help_str = "port config all burst <value>",
3821 : : .tokens = {
3822 : : (void *)&cmd_config_burst_port,
3823 : : (void *)&cmd_config_burst_keyword,
3824 : : (void *)&cmd_config_burst_all,
3825 : : (void *)&cmd_config_burst_name,
3826 : : (void *)&cmd_config_burst_value,
3827 : : NULL,
3828 : : },
3829 : : };
3830 : :
3831 : : /* *** configure rx/tx queues *** */
3832 : : struct cmd_config_thresh {
3833 : : cmdline_fixed_string_t port;
3834 : : cmdline_fixed_string_t keyword;
3835 : : cmdline_fixed_string_t all;
3836 : : cmdline_fixed_string_t name;
3837 : : uint8_t value;
3838 : : };
3839 : :
3840 : : static void
3841 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3842 : : __rte_unused struct cmdline *cl,
3843 : : __rte_unused void *data)
3844 : : {
3845 : : struct cmd_config_thresh *res = parsed_result;
3846 : :
3847 : 0 : if (!all_ports_stopped()) {
3848 : 0 : fprintf(stderr, "Please stop all ports first\n");
3849 : 0 : return;
3850 : : }
3851 : :
3852 : 0 : if (!strcmp(res->name, "txpt"))
3853 : 0 : tx_pthresh = res->value;
3854 : 0 : else if(!strcmp(res->name, "txht"))
3855 : 0 : tx_hthresh = res->value;
3856 : 0 : else if(!strcmp(res->name, "txwt"))
3857 : 0 : tx_wthresh = res->value;
3858 : 0 : else if(!strcmp(res->name, "rxpt"))
3859 : 0 : rx_pthresh = res->value;
3860 : 0 : else if(!strcmp(res->name, "rxht"))
3861 : 0 : rx_hthresh = res->value;
3862 : 0 : else if(!strcmp(res->name, "rxwt"))
3863 : 0 : rx_wthresh = res->value;
3864 : : else {
3865 : 0 : fprintf(stderr, "Unknown parameter\n");
3866 : 0 : return;
3867 : : }
3868 : :
3869 : 0 : init_port_config();
3870 : :
3871 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3872 : : }
3873 : :
3874 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3875 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3876 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3877 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3878 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3879 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3880 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3881 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3882 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3883 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3884 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3885 : :
3886 : : static cmdline_parse_inst_t cmd_config_thresh = {
3887 : : .f = cmd_config_thresh_parsed,
3888 : : .data = NULL,
3889 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3890 : : .tokens = {
3891 : : (void *)&cmd_config_thresh_port,
3892 : : (void *)&cmd_config_thresh_keyword,
3893 : : (void *)&cmd_config_thresh_all,
3894 : : (void *)&cmd_config_thresh_name,
3895 : : (void *)&cmd_config_thresh_value,
3896 : : NULL,
3897 : : },
3898 : : };
3899 : :
3900 : : /* *** configure free/rs threshold *** */
3901 : : struct cmd_config_threshold {
3902 : : cmdline_fixed_string_t port;
3903 : : cmdline_fixed_string_t keyword;
3904 : : cmdline_fixed_string_t all;
3905 : : cmdline_fixed_string_t name;
3906 : : uint16_t value;
3907 : : };
3908 : :
3909 : : static void
3910 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3911 : : __rte_unused struct cmdline *cl,
3912 : : __rte_unused void *data)
3913 : : {
3914 : : struct cmd_config_threshold *res = parsed_result;
3915 : :
3916 : 0 : if (!all_ports_stopped()) {
3917 : 0 : fprintf(stderr, "Please stop all ports first\n");
3918 : 0 : return;
3919 : : }
3920 : :
3921 : 0 : if (!strcmp(res->name, "txfreet"))
3922 : 0 : tx_free_thresh = res->value;
3923 : 0 : else if (!strcmp(res->name, "txrst"))
3924 : 0 : tx_rs_thresh = res->value;
3925 : 0 : else if (!strcmp(res->name, "rxfreet"))
3926 : 0 : rx_free_thresh = res->value;
3927 : : else {
3928 : 0 : fprintf(stderr, "Unknown parameter\n");
3929 : 0 : return;
3930 : : }
3931 : :
3932 : 0 : init_port_config();
3933 : :
3934 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3935 : : }
3936 : :
3937 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3938 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3939 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3940 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3941 : : "config");
3942 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3943 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3944 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3945 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3946 : : "txfreet#txrst#rxfreet");
3947 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3948 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3949 : :
3950 : : static cmdline_parse_inst_t cmd_config_threshold = {
3951 : : .f = cmd_config_threshold_parsed,
3952 : : .data = NULL,
3953 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3954 : : .tokens = {
3955 : : (void *)&cmd_config_threshold_port,
3956 : : (void *)&cmd_config_threshold_keyword,
3957 : : (void *)&cmd_config_threshold_all,
3958 : : (void *)&cmd_config_threshold_name,
3959 : : (void *)&cmd_config_threshold_value,
3960 : : NULL,
3961 : : },
3962 : : };
3963 : :
3964 : : /* *** stop *** */
3965 : : struct cmd_stop_result {
3966 : : cmdline_fixed_string_t stop;
3967 : : };
3968 : :
3969 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3970 : : __rte_unused struct cmdline *cl,
3971 : : __rte_unused void *data)
3972 : : {
3973 : 0 : stop_packet_forwarding();
3974 : 0 : }
3975 : :
3976 : : static cmdline_parse_token_string_t cmd_stop_stop =
3977 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3978 : :
3979 : : static cmdline_parse_inst_t cmd_stop = {
3980 : : .f = cmd_stop_parsed,
3981 : : .data = NULL,
3982 : : .help_str = "stop: Stop packet forwarding",
3983 : : .tokens = {
3984 : : (void *)&cmd_stop_stop,
3985 : : NULL,
3986 : : },
3987 : : };
3988 : :
3989 : : static unsigned int
3990 : 0 : get_ptype(char *value)
3991 : : {
3992 : : uint32_t protocol;
3993 : :
3994 : 0 : if (!strcmp(value, "eth"))
3995 : : protocol = RTE_PTYPE_L2_ETHER;
3996 : 0 : else if (!strcmp(value, "ipv4"))
3997 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3998 : 0 : else if (!strcmp(value, "ipv6"))
3999 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
4000 : 0 : else if (!strcmp(value, "ipv4-tcp"))
4001 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
4002 : 0 : else if (!strcmp(value, "ipv4-udp"))
4003 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
4004 : 0 : else if (!strcmp(value, "ipv4-sctp"))
4005 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4006 : 0 : else if (!strcmp(value, "ipv6-tcp"))
4007 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
4008 : 0 : else if (!strcmp(value, "ipv6-udp"))
4009 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
4010 : 0 : else if (!strcmp(value, "ipv6-sctp"))
4011 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4012 : 0 : else if (!strcmp(value, "grenat"))
4013 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
4014 : 0 : else if (!strcmp(value, "inner-eth"))
4015 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
4016 : 0 : else if (!strcmp(value, "inner-ipv4"))
4017 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4018 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
4019 : 0 : else if (!strcmp(value, "inner-ipv6"))
4020 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4021 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
4022 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
4023 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4024 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4025 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
4026 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4027 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4028 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
4029 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4030 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4031 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
4032 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4033 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4034 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
4035 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4036 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4037 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
4038 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4039 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4040 : : else {
4041 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
4042 : : protocol = RTE_PTYPE_UNKNOWN;
4043 : : }
4044 : :
4045 : 0 : return protocol;
4046 : : }
4047 : :
4048 : : /* *** SET RXHDRSLIST *** */
4049 : :
4050 : : unsigned int
4051 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
4052 : : unsigned int *parsed_items)
4053 : : {
4054 : : unsigned int nb_item;
4055 : : char *cur;
4056 : : char *tmp;
4057 : :
4058 : : nb_item = 0;
4059 : 0 : char *str2 = strdup(str);
4060 : 0 : if (str2 == NULL)
4061 : : return nb_item;
4062 : 0 : cur = strtok_r(str2, ",", &tmp);
4063 : 0 : while (cur != NULL) {
4064 : 0 : parsed_items[nb_item] = get_ptype(cur);
4065 : 0 : cur = strtok_r(NULL, ",", &tmp);
4066 : 0 : nb_item++;
4067 : : }
4068 : 0 : if (nb_item > max_items)
4069 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4070 : : item_name, nb_item + 1, max_items);
4071 : 0 : free(str2);
4072 : 0 : return nb_item;
4073 : : }
4074 : :
4075 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
4076 : :
4077 : : unsigned int
4078 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
4079 : : unsigned int *parsed_items, int check_unique_values)
4080 : : {
4081 : : unsigned int nb_item;
4082 : : unsigned int value;
4083 : : unsigned int i;
4084 : : unsigned int j;
4085 : : int value_ok;
4086 : : char c;
4087 : :
4088 : : /*
4089 : : * First parse all items in the list and store their value.
4090 : : */
4091 : : value = 0;
4092 : : nb_item = 0;
4093 : : value_ok = 0;
4094 : 0 : for (i = 0; i < strnlen(str, STR_MULTI_TOKEN_SIZE); i++) {
4095 : 0 : c = str[i];
4096 : 0 : if ((c >= '0') && (c <= '9')) {
4097 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
4098 : : value_ok = 1;
4099 : 0 : continue;
4100 : : }
4101 : 0 : if (c != ',') {
4102 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
4103 : 0 : return 0;
4104 : : }
4105 : 0 : if (! value_ok) {
4106 : 0 : fprintf(stderr, "No valid value before comma\n");
4107 : 0 : return 0;
4108 : : }
4109 : 0 : if (nb_item < max_items) {
4110 : 0 : parsed_items[nb_item] = value;
4111 : : value_ok = 0;
4112 : : value = 0;
4113 : : }
4114 : 0 : nb_item++;
4115 : : }
4116 : 0 : if (nb_item >= max_items) {
4117 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4118 : : item_name, nb_item + 1, max_items);
4119 : 0 : return 0;
4120 : : }
4121 : 0 : parsed_items[nb_item++] = value;
4122 : 0 : if (! check_unique_values)
4123 : : return nb_item;
4124 : :
4125 : : /*
4126 : : * Then, check that all values in the list are different.
4127 : : * No optimization here...
4128 : : */
4129 : 0 : for (i = 0; i < nb_item; i++) {
4130 : 0 : for (j = i + 1; j < nb_item; j++) {
4131 : 0 : if (parsed_items[j] == parsed_items[i]) {
4132 : 0 : fprintf(stderr,
4133 : : "duplicated %s %u at index %u and %u\n",
4134 : : item_name, parsed_items[i], i, j);
4135 : 0 : return 0;
4136 : : }
4137 : : }
4138 : : }
4139 : : return nb_item;
4140 : : }
4141 : :
4142 : : struct cmd_set_list_result {
4143 : : cmdline_fixed_string_t cmd_keyword;
4144 : : cmdline_fixed_string_t list_name;
4145 : : cmdline_multi_string_t list_of_items;
4146 : : };
4147 : :
4148 : 0 : static void cmd_set_list_parsed(void *parsed_result,
4149 : : __rte_unused struct cmdline *cl,
4150 : : __rte_unused void *data)
4151 : : {
4152 : : struct cmd_set_list_result *res;
4153 : : union {
4154 : : unsigned int lcorelist[RTE_MAX_LCORE];
4155 : : unsigned int portlist[RTE_MAX_ETHPORTS];
4156 : : } parsed_items;
4157 : : unsigned int nb_item;
4158 : :
4159 : 0 : if (test_done == 0) {
4160 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4161 : 0 : return;
4162 : : }
4163 : :
4164 : : res = parsed_result;
4165 : 0 : if (!strcmp(res->list_name, "corelist")) {
4166 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
4167 : : RTE_MAX_LCORE,
4168 : : parsed_items.lcorelist, 1);
4169 : 0 : if (nb_item > 0) {
4170 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
4171 : 0 : fwd_config_setup();
4172 : : }
4173 : 0 : return;
4174 : : }
4175 : 0 : if (!strcmp(res->list_name, "portlist")) {
4176 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
4177 : : RTE_MAX_ETHPORTS,
4178 : : parsed_items.portlist, 1);
4179 : 0 : if (nb_item > 0) {
4180 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
4181 : 0 : fwd_config_setup();
4182 : : }
4183 : : }
4184 : : }
4185 : :
4186 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
4187 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
4188 : : "set");
4189 : : static cmdline_parse_token_string_t cmd_set_list_name =
4190 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
4191 : : "corelist#portlist");
4192 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
4193 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
4194 : : TOKEN_STRING_MULTI);
4195 : :
4196 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
4197 : : .f = cmd_set_list_parsed,
4198 : : .data = NULL,
4199 : : .help_str = "set corelist|portlist <list0[,list1]*>",
4200 : : .tokens = {
4201 : : (void *)&cmd_set_list_keyword,
4202 : : (void *)&cmd_set_list_name,
4203 : : (void *)&cmd_set_list_of_items,
4204 : : NULL,
4205 : : },
4206 : : };
4207 : :
4208 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
4209 : :
4210 : : struct cmd_setmask_result {
4211 : : cmdline_fixed_string_t set;
4212 : : cmdline_fixed_string_t mask;
4213 : : uint64_t hexavalue;
4214 : : };
4215 : :
4216 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
4217 : : __rte_unused struct cmdline *cl,
4218 : : __rte_unused void *data)
4219 : : {
4220 : : struct cmd_setmask_result *res = parsed_result;
4221 : :
4222 : 0 : if (test_done == 0) {
4223 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4224 : 0 : return;
4225 : : }
4226 : 0 : if (!strcmp(res->mask, "coremask")) {
4227 : 0 : set_fwd_lcores_mask(res->hexavalue);
4228 : 0 : fwd_config_setup();
4229 : 0 : } else if (!strcmp(res->mask, "portmask")) {
4230 : 0 : set_fwd_ports_mask(res->hexavalue);
4231 : 0 : fwd_config_setup();
4232 : : }
4233 : : }
4234 : :
4235 : : static cmdline_parse_token_string_t cmd_setmask_set =
4236 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
4237 : : static cmdline_parse_token_string_t cmd_setmask_mask =
4238 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
4239 : : "coremask#portmask");
4240 : : static cmdline_parse_token_num_t cmd_setmask_value =
4241 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
4242 : :
4243 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
4244 : : .f = cmd_set_mask_parsed,
4245 : : .data = NULL,
4246 : : .help_str = "set coremask|portmask <hexadecimal value>",
4247 : : .tokens = {
4248 : : (void *)&cmd_setmask_set,
4249 : : (void *)&cmd_setmask_mask,
4250 : : (void *)&cmd_setmask_value,
4251 : : NULL,
4252 : : },
4253 : : };
4254 : :
4255 : : /*
4256 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
4257 : : */
4258 : : struct cmd_set_result {
4259 : : cmdline_fixed_string_t set;
4260 : : cmdline_fixed_string_t what;
4261 : : uint16_t value;
4262 : : };
4263 : :
4264 : 0 : static void cmd_set_parsed(void *parsed_result,
4265 : : __rte_unused struct cmdline *cl,
4266 : : __rte_unused void *data)
4267 : : {
4268 : : struct cmd_set_result *res = parsed_result;
4269 : 0 : if (!strcmp(res->what, "nbport")) {
4270 : 0 : set_fwd_ports_number(res->value);
4271 : 0 : fwd_config_setup();
4272 : 0 : } else if (!strcmp(res->what, "nbcore")) {
4273 : 0 : set_fwd_lcores_number(res->value);
4274 : 0 : fwd_config_setup();
4275 : 0 : } else if (!strcmp(res->what, "burst"))
4276 : 0 : set_nb_pkt_per_burst(res->value);
4277 : 0 : else if (!strcmp(res->what, "verbose"))
4278 : 0 : set_verbose_level(res->value);
4279 : 0 : }
4280 : :
4281 : : static cmdline_parse_token_string_t cmd_set_set =
4282 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
4283 : : static cmdline_parse_token_string_t cmd_set_what =
4284 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
4285 : : "nbport#nbcore#burst#verbose");
4286 : : static cmdline_parse_token_num_t cmd_set_value =
4287 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
4288 : :
4289 : : static cmdline_parse_inst_t cmd_set_numbers = {
4290 : : .f = cmd_set_parsed,
4291 : : .data = NULL,
4292 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
4293 : : .tokens = {
4294 : : (void *)&cmd_set_set,
4295 : : (void *)&cmd_set_what,
4296 : : (void *)&cmd_set_value,
4297 : : NULL,
4298 : : },
4299 : : };
4300 : :
4301 : : /* *** SET LOG LEVEL CONFIGURATION *** */
4302 : :
4303 : : struct cmd_set_log_result {
4304 : : cmdline_fixed_string_t set;
4305 : : cmdline_fixed_string_t log;
4306 : : cmdline_fixed_string_t type;
4307 : : uint32_t level;
4308 : : };
4309 : :
4310 : : static void
4311 : 0 : cmd_set_log_parsed(void *parsed_result,
4312 : : __rte_unused struct cmdline *cl,
4313 : : __rte_unused void *data)
4314 : : {
4315 : : struct cmd_set_log_result *res;
4316 : : int ret;
4317 : :
4318 : : res = parsed_result;
4319 : 0 : if (!strcmp(res->type, "global"))
4320 : 0 : rte_log_set_global_level(res->level);
4321 : : else {
4322 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
4323 : 0 : if (ret < 0)
4324 : 0 : fprintf(stderr, "Unable to set log level\n");
4325 : : }
4326 : 0 : }
4327 : :
4328 : : static cmdline_parse_token_string_t cmd_set_log_set =
4329 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
4330 : : static cmdline_parse_token_string_t cmd_set_log_log =
4331 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
4332 : : static cmdline_parse_token_string_t cmd_set_log_type =
4333 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
4334 : : static cmdline_parse_token_num_t cmd_set_log_level =
4335 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
4336 : :
4337 : : static cmdline_parse_inst_t cmd_set_log = {
4338 : : .f = cmd_set_log_parsed,
4339 : : .data = NULL,
4340 : : .help_str = "set log global|<type> <level>",
4341 : : .tokens = {
4342 : : (void *)&cmd_set_log_set,
4343 : : (void *)&cmd_set_log_log,
4344 : : (void *)&cmd_set_log_type,
4345 : : (void *)&cmd_set_log_level,
4346 : : NULL,
4347 : : },
4348 : : };
4349 : :
4350 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
4351 : :
4352 : : struct cmd_set_rxoffs_result {
4353 : : cmdline_fixed_string_t cmd_keyword;
4354 : : cmdline_fixed_string_t rxoffs;
4355 : : cmdline_fixed_string_t seg_offsets;
4356 : : };
4357 : :
4358 : : static void
4359 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
4360 : : __rte_unused struct cmdline *cl,
4361 : : __rte_unused void *data)
4362 : : {
4363 : : struct cmd_set_rxoffs_result *res;
4364 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
4365 : : unsigned int nb_segs;
4366 : :
4367 : : res = parsed_result;
4368 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
4369 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
4370 : 0 : if (nb_segs > 0)
4371 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
4372 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4373 : 0 : }
4374 : :
4375 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
4376 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4377 : : cmd_keyword, "set");
4378 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
4379 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4380 : : rxoffs, "rxoffs");
4381 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
4382 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4383 : : seg_offsets, NULL);
4384 : :
4385 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
4386 : : .f = cmd_set_rxoffs_parsed,
4387 : : .data = NULL,
4388 : : .help_str = "set rxoffs <len0[,len1]*>",
4389 : : .tokens = {
4390 : : (void *)&cmd_set_rxoffs_keyword,
4391 : : (void *)&cmd_set_rxoffs_name,
4392 : : (void *)&cmd_set_rxoffs_offsets,
4393 : : NULL,
4394 : : },
4395 : : };
4396 : :
4397 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
4398 : :
4399 : : struct cmd_set_rxpkts_result {
4400 : : cmdline_fixed_string_t cmd_keyword;
4401 : : cmdline_fixed_string_t rxpkts;
4402 : : cmdline_fixed_string_t seg_lengths;
4403 : : };
4404 : :
4405 : : static void
4406 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
4407 : : __rte_unused struct cmdline *cl,
4408 : : __rte_unused void *data)
4409 : : {
4410 : : struct cmd_set_rxpkts_result *res;
4411 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
4412 : : unsigned int nb_segs;
4413 : :
4414 : : res = parsed_result;
4415 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4416 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
4417 : 0 : if (nb_segs > 0)
4418 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
4419 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4420 : 0 : }
4421 : :
4422 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
4423 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4424 : : cmd_keyword, "set");
4425 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
4426 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4427 : : rxpkts, "rxpkts");
4428 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4429 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4430 : : seg_lengths, NULL);
4431 : :
4432 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
4433 : : .f = cmd_set_rxpkts_parsed,
4434 : : .data = NULL,
4435 : : .help_str = "set rxpkts <len0[,len1]*>",
4436 : : .tokens = {
4437 : : (void *)&cmd_set_rxpkts_keyword,
4438 : : (void *)&cmd_set_rxpkts_name,
4439 : : (void *)&cmd_set_rxpkts_lengths,
4440 : : NULL,
4441 : : },
4442 : : };
4443 : :
4444 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4445 : : struct cmd_set_rxhdrs_result {
4446 : : cmdline_fixed_string_t set;
4447 : : cmdline_fixed_string_t rxhdrs;
4448 : : cmdline_fixed_string_t values;
4449 : : };
4450 : :
4451 : : static void
4452 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4453 : : __rte_unused struct cmdline *cl,
4454 : : __rte_unused void *data)
4455 : : {
4456 : : struct cmd_set_rxhdrs_result *res;
4457 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4458 : : unsigned int nb_segs;
4459 : :
4460 : : res = parsed_result;
4461 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4462 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4463 : 0 : if (nb_segs > 0)
4464 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4465 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4466 : 0 : }
4467 : :
4468 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4469 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4470 : : set, "set");
4471 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4472 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4473 : : rxhdrs, "rxhdrs");
4474 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4475 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4476 : : values, NULL);
4477 : :
4478 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4479 : : .f = cmd_set_rxhdrs_parsed,
4480 : : .data = NULL,
4481 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4482 : : .tokens = {
4483 : : (void *)&cmd_set_rxhdrs_set,
4484 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4485 : : (void *)&cmd_set_rxhdrs_values,
4486 : : NULL,
4487 : : },
4488 : : };
4489 : :
4490 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4491 : :
4492 : : struct cmd_set_txpkts_result {
4493 : : cmdline_fixed_string_t cmd_keyword;
4494 : : cmdline_fixed_string_t txpkts;
4495 : : cmdline_fixed_string_t seg_lengths;
4496 : : };
4497 : :
4498 : : static void
4499 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4500 : : __rte_unused struct cmdline *cl,
4501 : : __rte_unused void *data)
4502 : : {
4503 : : struct cmd_set_txpkts_result *res;
4504 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4505 : : unsigned int nb_segs;
4506 : :
4507 : : res = parsed_result;
4508 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4509 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4510 : 0 : if (nb_segs > 0)
4511 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4512 : 0 : }
4513 : :
4514 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4515 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4516 : : cmd_keyword, "set");
4517 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4518 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4519 : : txpkts, "txpkts");
4520 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4521 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4522 : : seg_lengths, NULL);
4523 : :
4524 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4525 : : .f = cmd_set_txpkts_parsed,
4526 : : .data = NULL,
4527 : : .help_str = "set txpkts <len0[,len1]*>",
4528 : : .tokens = {
4529 : : (void *)&cmd_set_txpkts_keyword,
4530 : : (void *)&cmd_set_txpkts_name,
4531 : : (void *)&cmd_set_txpkts_lengths,
4532 : : NULL,
4533 : : },
4534 : : };
4535 : :
4536 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4537 : :
4538 : : struct cmd_set_txsplit_result {
4539 : : cmdline_fixed_string_t cmd_keyword;
4540 : : cmdline_fixed_string_t txsplit;
4541 : : cmdline_fixed_string_t mode;
4542 : : };
4543 : :
4544 : : static void
4545 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4546 : : __rte_unused struct cmdline *cl,
4547 : : __rte_unused void *data)
4548 : : {
4549 : : struct cmd_set_txsplit_result *res;
4550 : :
4551 : : res = parsed_result;
4552 : 0 : set_tx_pkt_split(res->mode);
4553 : 0 : }
4554 : :
4555 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4556 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4557 : : cmd_keyword, "set");
4558 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4559 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4560 : : txsplit, "txsplit");
4561 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4562 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4563 : : mode, NULL);
4564 : :
4565 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4566 : : .f = cmd_set_txsplit_parsed,
4567 : : .data = NULL,
4568 : : .help_str = "set txsplit on|off|rand",
4569 : : .tokens = {
4570 : : (void *)&cmd_set_txsplit_keyword,
4571 : : (void *)&cmd_set_txsplit_name,
4572 : : (void *)&cmd_set_txsplit_mode,
4573 : : NULL,
4574 : : },
4575 : : };
4576 : :
4577 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4578 : :
4579 : : struct cmd_set_txtimes_result {
4580 : : cmdline_fixed_string_t cmd_keyword;
4581 : : cmdline_fixed_string_t txtimes;
4582 : : cmdline_fixed_string_t tx_times;
4583 : : };
4584 : :
4585 : : static void
4586 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4587 : : __rte_unused struct cmdline *cl,
4588 : : __rte_unused void *data)
4589 : : {
4590 : : struct cmd_set_txtimes_result *res;
4591 : 0 : unsigned int tx_times[2] = {0, 0};
4592 : : unsigned int n_times;
4593 : :
4594 : : res = parsed_result;
4595 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4596 : : 2, tx_times, 0);
4597 : 0 : if (n_times == 2)
4598 : 0 : set_tx_pkt_times(tx_times);
4599 : 0 : }
4600 : :
4601 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4602 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4603 : : cmd_keyword, "set");
4604 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4605 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4606 : : txtimes, "txtimes");
4607 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4608 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4609 : : tx_times, NULL);
4610 : :
4611 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4612 : : .f = cmd_set_txtimes_parsed,
4613 : : .data = NULL,
4614 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4615 : : .tokens = {
4616 : : (void *)&cmd_set_txtimes_keyword,
4617 : : (void *)&cmd_set_txtimes_name,
4618 : : (void *)&cmd_set_txtimes_value,
4619 : : NULL,
4620 : : },
4621 : : };
4622 : :
4623 : : /* *** SET NUMBER OF FLOWS IN TXONLY MULTI-FLOW MODE *** */
4624 : :
4625 : : struct cmd_set_txflows_result {
4626 : : cmdline_fixed_string_t cmd_keyword;
4627 : : cmdline_fixed_string_t name;
4628 : : uint16_t value;
4629 : : };
4630 : :
4631 : : static void
4632 : 0 : cmd_set_txflows_parsed(void *parsed_result,
4633 : : __rte_unused struct cmdline *cl,
4634 : : __rte_unused void *data)
4635 : : {
4636 : : struct cmd_set_txflows_result *res = parsed_result;
4637 : :
4638 : 0 : if (res->value < 1 || res->value > 64) {
4639 : 0 : fprintf(stderr, "txonly-flows must be >= 1 and <= 64\n");
4640 : 0 : return;
4641 : : }
4642 : 0 : txonly_flows = res->value;
4643 : : }
4644 : :
4645 : : static cmdline_parse_token_string_t cmd_set_txflows_keyword =
4646 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txflows_result,
4647 : : cmd_keyword, "set");
4648 : : static cmdline_parse_token_string_t cmd_set_txflows_name =
4649 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txflows_result,
4650 : : name, "txonly-flows");
4651 : : static cmdline_parse_token_num_t cmd_set_txflows_value =
4652 : : TOKEN_NUM_INITIALIZER(struct cmd_set_txflows_result,
4653 : : value, RTE_UINT16);
4654 : :
4655 : : static cmdline_parse_inst_t cmd_set_txflows = {
4656 : : .f = cmd_set_txflows_parsed,
4657 : : .data = NULL,
4658 : : .help_str = "set txonly-flows <N>",
4659 : : .tokens = {
4660 : : (void *)&cmd_set_txflows_keyword,
4661 : : (void *)&cmd_set_txflows_name,
4662 : : (void *)&cmd_set_txflows_value,
4663 : : NULL,
4664 : : },
4665 : : };
4666 : :
4667 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4668 : : struct cmd_rx_vlan_filter_all_result {
4669 : : cmdline_fixed_string_t rx_vlan;
4670 : : cmdline_fixed_string_t what;
4671 : : cmdline_fixed_string_t all;
4672 : : portid_t port_id;
4673 : : };
4674 : :
4675 : : static void
4676 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4677 : : __rte_unused struct cmdline *cl,
4678 : : __rte_unused void *data)
4679 : : {
4680 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4681 : :
4682 : 0 : if (!strcmp(res->what, "add"))
4683 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4684 : : else
4685 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4686 : 0 : }
4687 : :
4688 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4689 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4690 : : rx_vlan, "rx_vlan");
4691 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4692 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4693 : : what, "add#rm");
4694 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4695 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4696 : : all, "all");
4697 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4698 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4699 : : port_id, RTE_UINT16);
4700 : :
4701 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4702 : : .f = cmd_rx_vlan_filter_all_parsed,
4703 : : .data = NULL,
4704 : : .help_str = "rx_vlan add|rm all <port_id>: "
4705 : : "Add/Remove all identifiers to/from the set of VLAN "
4706 : : "identifiers filtered by a port",
4707 : : .tokens = {
4708 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4709 : : (void *)&cmd_rx_vlan_filter_all_what,
4710 : : (void *)&cmd_rx_vlan_filter_all_all,
4711 : : (void *)&cmd_rx_vlan_filter_all_portid,
4712 : : NULL,
4713 : : },
4714 : : };
4715 : :
4716 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4717 : : struct cmd_vlan_offload_result {
4718 : : cmdline_fixed_string_t vlan;
4719 : : cmdline_fixed_string_t set;
4720 : : cmdline_fixed_string_t vlan_type;
4721 : : cmdline_fixed_string_t what;
4722 : : cmdline_fixed_string_t on;
4723 : : cmdline_fixed_string_t port_id;
4724 : : };
4725 : :
4726 : : static void
4727 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4728 : : __rte_unused struct cmdline *cl,
4729 : : __rte_unused void *data)
4730 : : {
4731 : : int on;
4732 : : struct cmd_vlan_offload_result *res = parsed_result;
4733 : : char *str;
4734 : : int i, len = 0;
4735 : : portid_t port_id = 0;
4736 : : unsigned int tmp;
4737 : :
4738 : 0 : str = res->port_id;
4739 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4740 : : i = 0;
4741 : : /* Get port_id first */
4742 : 0 : while(i < len){
4743 : 0 : if(str[i] == ',')
4744 : : break;
4745 : :
4746 : 0 : i++;
4747 : : }
4748 : 0 : str[i]='\0';
4749 : 0 : tmp = strtoul(str, NULL, 0);
4750 : : /* If port_id greater that what portid_t can represent, return */
4751 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4752 : : return;
4753 : 0 : port_id = (portid_t)tmp;
4754 : :
4755 : 0 : if (!strcmp(res->on, "on"))
4756 : : on = 1;
4757 : : else
4758 : : on = 0;
4759 : :
4760 : 0 : if (!strcmp(res->what, "strip"))
4761 : 0 : rx_vlan_strip_set(port_id, on);
4762 : 0 : else if(!strcmp(res->what, "stripq")){
4763 : : uint16_t queue_id = 0;
4764 : :
4765 : : /* No queue_id, return */
4766 : 0 : if(i + 1 >= len) {
4767 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4768 : 0 : return;
4769 : : }
4770 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4771 : : /* If queue_id greater that what 16-bits can represent, return */
4772 : 0 : if(tmp > 0xffff)
4773 : : return;
4774 : :
4775 : 0 : queue_id = (uint16_t)tmp;
4776 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4777 : : }
4778 : 0 : else if (!strcmp(res->what, "filter"))
4779 : 0 : rx_vlan_filter_set(port_id, on);
4780 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4781 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4782 : : else
4783 : 0 : vlan_extend_set(port_id, on);
4784 : :
4785 : : return;
4786 : : }
4787 : :
4788 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4789 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4790 : : vlan, "vlan");
4791 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4792 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4793 : : set, "set");
4794 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4795 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4796 : : what, "strip#filter#qinq_strip#extend#stripq");
4797 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4798 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4799 : : on, "on#off");
4800 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4801 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4802 : : port_id, NULL);
4803 : :
4804 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4805 : : .f = cmd_vlan_offload_parsed,
4806 : : .data = NULL,
4807 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4808 : : "<port_id[,queue_id]>: "
4809 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4810 : : .tokens = {
4811 : : (void *)&cmd_vlan_offload_vlan,
4812 : : (void *)&cmd_vlan_offload_set,
4813 : : (void *)&cmd_vlan_offload_what,
4814 : : (void *)&cmd_vlan_offload_on,
4815 : : (void *)&cmd_vlan_offload_portid,
4816 : : NULL,
4817 : : },
4818 : : };
4819 : :
4820 : : /* *** VLAN TPID SET ON A PORT *** */
4821 : : struct cmd_vlan_tpid_result {
4822 : : cmdline_fixed_string_t vlan;
4823 : : cmdline_fixed_string_t set;
4824 : : cmdline_fixed_string_t vlan_type;
4825 : : cmdline_fixed_string_t what;
4826 : : uint16_t tp_id;
4827 : : portid_t port_id;
4828 : : };
4829 : :
4830 : : static void
4831 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4832 : : __rte_unused struct cmdline *cl,
4833 : : __rte_unused void *data)
4834 : : {
4835 : : struct cmd_vlan_tpid_result *res = parsed_result;
4836 : : enum rte_vlan_type vlan_type;
4837 : :
4838 : 0 : if (!strcmp(res->vlan_type, "inner"))
4839 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4840 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4841 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4842 : : else {
4843 : 0 : fprintf(stderr, "Unknown vlan type\n");
4844 : 0 : return;
4845 : : }
4846 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4847 : : }
4848 : :
4849 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4850 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4851 : : vlan, "vlan");
4852 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4853 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4854 : : set, "set");
4855 : : static cmdline_parse_token_string_t cmd_vlan_type =
4856 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4857 : : vlan_type, "inner#outer");
4858 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4859 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4860 : : what, "tpid");
4861 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4862 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4863 : : tp_id, RTE_UINT16);
4864 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4865 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4866 : : port_id, RTE_UINT16);
4867 : :
4868 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4869 : : .f = cmd_vlan_tpid_parsed,
4870 : : .data = NULL,
4871 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4872 : : "Set the VLAN Ether type",
4873 : : .tokens = {
4874 : : (void *)&cmd_vlan_tpid_vlan,
4875 : : (void *)&cmd_vlan_tpid_set,
4876 : : (void *)&cmd_vlan_type,
4877 : : (void *)&cmd_vlan_tpid_what,
4878 : : (void *)&cmd_vlan_tpid_tpid,
4879 : : (void *)&cmd_vlan_tpid_portid,
4880 : : NULL,
4881 : : },
4882 : : };
4883 : :
4884 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4885 : : struct cmd_rx_vlan_filter_result {
4886 : : cmdline_fixed_string_t rx_vlan;
4887 : : cmdline_fixed_string_t what;
4888 : : uint16_t vlan_id;
4889 : : portid_t port_id;
4890 : : };
4891 : :
4892 : : static void
4893 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4894 : : __rte_unused struct cmdline *cl,
4895 : : __rte_unused void *data)
4896 : : {
4897 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4898 : :
4899 : 0 : if (!strcmp(res->what, "add"))
4900 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4901 : : else
4902 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4903 : 0 : }
4904 : :
4905 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4906 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4907 : : rx_vlan, "rx_vlan");
4908 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4909 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4910 : : what, "add#rm");
4911 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4912 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4913 : : vlan_id, RTE_UINT16);
4914 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4915 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4916 : : port_id, RTE_UINT16);
4917 : :
4918 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4919 : : .f = cmd_rx_vlan_filter_parsed,
4920 : : .data = NULL,
4921 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4922 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4923 : : "identifiers filtered by a port",
4924 : : .tokens = {
4925 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4926 : : (void *)&cmd_rx_vlan_filter_what,
4927 : : (void *)&cmd_rx_vlan_filter_vlanid,
4928 : : (void *)&cmd_rx_vlan_filter_portid,
4929 : : NULL,
4930 : : },
4931 : : };
4932 : :
4933 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4934 : : struct cmd_tx_vlan_set_result {
4935 : : cmdline_fixed_string_t tx_vlan;
4936 : : cmdline_fixed_string_t set;
4937 : : portid_t port_id;
4938 : : uint16_t vlan_tci;
4939 : : };
4940 : :
4941 : : static void
4942 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4943 : : __rte_unused struct cmdline *cl,
4944 : : __rte_unused void *data)
4945 : : {
4946 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4947 : :
4948 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4949 : : return;
4950 : :
4951 : 0 : if (!port_is_stopped(res->port_id)) {
4952 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4953 : 0 : return;
4954 : : }
4955 : :
4956 : 0 : tx_vlan_set(res->port_id, res->vlan_tci);
4957 : :
4958 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4959 : : }
4960 : :
4961 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4962 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4963 : : tx_vlan, "tx_vlan");
4964 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4965 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4966 : : set, "set");
4967 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4968 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4969 : : port_id, RTE_UINT16);
4970 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlantci =
4971 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4972 : : vlan_tci, RTE_UINT16);
4973 : :
4974 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4975 : : .f = cmd_tx_vlan_set_parsed,
4976 : : .data = NULL,
4977 : : .help_str = "tx_vlan set <port_id> <vlan_tci>: "
4978 : : "Enable hardware insertion of a single VLAN header "
4979 : : "with a given TCI in packets sent on a port",
4980 : : .tokens = {
4981 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4982 : : (void *)&cmd_tx_vlan_set_set,
4983 : : (void *)&cmd_tx_vlan_set_portid,
4984 : : (void *)&cmd_tx_vlan_set_vlantci,
4985 : : NULL,
4986 : : },
4987 : : };
4988 : :
4989 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4990 : : struct cmd_tx_vlan_set_qinq_result {
4991 : : cmdline_fixed_string_t tx_vlan;
4992 : : cmdline_fixed_string_t set;
4993 : : portid_t port_id;
4994 : : uint16_t vlan_tci;
4995 : : uint16_t vlan_tci_outer;
4996 : : };
4997 : :
4998 : : static void
4999 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
5000 : : __rte_unused struct cmdline *cl,
5001 : : __rte_unused void *data)
5002 : : {
5003 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
5004 : :
5005 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5006 : : return;
5007 : :
5008 : 0 : if (!port_is_stopped(res->port_id)) {
5009 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5010 : 0 : return;
5011 : : }
5012 : :
5013 : 0 : tx_qinq_set(res->port_id, res->vlan_tci, res->vlan_tci_outer);
5014 : :
5015 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5016 : : }
5017 : :
5018 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
5019 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5020 : : tx_vlan, "tx_vlan");
5021 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
5022 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5023 : : set, "set");
5024 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
5025 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5026 : : port_id, RTE_UINT16);
5027 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlantci =
5028 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5029 : : vlan_tci, RTE_UINT16);
5030 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlantci_outer =
5031 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5032 : : vlan_tci_outer, RTE_UINT16);
5033 : :
5034 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
5035 : : .f = cmd_tx_vlan_set_qinq_parsed,
5036 : : .data = NULL,
5037 : : .help_str = "tx_vlan set <port_id> <vlan_tci> <vlan_tci_outer>: "
5038 : : "Enable hardware insertion of double VLAN header "
5039 : : "with given TCIs in packets sent on a port",
5040 : : .tokens = {
5041 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
5042 : : (void *)&cmd_tx_vlan_set_qinq_set,
5043 : : (void *)&cmd_tx_vlan_set_qinq_portid,
5044 : : (void *)&cmd_tx_vlan_set_qinq_vlantci,
5045 : : (void *)&cmd_tx_vlan_set_qinq_vlantci_outer,
5046 : : NULL,
5047 : : },
5048 : : };
5049 : :
5050 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
5051 : : struct cmd_tx_vlan_set_pvid_result {
5052 : : cmdline_fixed_string_t tx_vlan;
5053 : : cmdline_fixed_string_t set;
5054 : : cmdline_fixed_string_t pvid;
5055 : : portid_t port_id;
5056 : : uint16_t vlan_id;
5057 : : cmdline_fixed_string_t mode;
5058 : : };
5059 : :
5060 : : static void
5061 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
5062 : : __rte_unused struct cmdline *cl,
5063 : : __rte_unused void *data)
5064 : : {
5065 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
5066 : :
5067 : 0 : if (strcmp(res->mode, "on") == 0)
5068 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
5069 : : else
5070 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
5071 : 0 : }
5072 : :
5073 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
5074 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5075 : : tx_vlan, "tx_vlan");
5076 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
5077 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5078 : : set, "set");
5079 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
5080 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5081 : : pvid, "pvid");
5082 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
5083 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5084 : : port_id, RTE_UINT16);
5085 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
5086 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5087 : : vlan_id, RTE_UINT16);
5088 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
5089 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5090 : : mode, "on#off");
5091 : :
5092 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
5093 : : .f = cmd_tx_vlan_set_pvid_parsed,
5094 : : .data = NULL,
5095 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
5096 : : .tokens = {
5097 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
5098 : : (void *)&cmd_tx_vlan_set_pvid_set,
5099 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
5100 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
5101 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
5102 : : (void *)&cmd_tx_vlan_set_pvid_mode,
5103 : : NULL,
5104 : : },
5105 : : };
5106 : :
5107 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
5108 : : struct cmd_tx_vlan_reset_result {
5109 : : cmdline_fixed_string_t tx_vlan;
5110 : : cmdline_fixed_string_t reset;
5111 : : portid_t port_id;
5112 : : };
5113 : :
5114 : : static void
5115 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
5116 : : __rte_unused struct cmdline *cl,
5117 : : __rte_unused void *data)
5118 : : {
5119 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
5120 : :
5121 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5122 : : return;
5123 : :
5124 : 0 : if (!port_is_stopped(res->port_id)) {
5125 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5126 : 0 : return;
5127 : : }
5128 : :
5129 : 0 : tx_vlan_reset(res->port_id);
5130 : :
5131 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5132 : : }
5133 : :
5134 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
5135 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5136 : : tx_vlan, "tx_vlan");
5137 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
5138 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5139 : : reset, "reset");
5140 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
5141 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
5142 : : port_id, RTE_UINT16);
5143 : :
5144 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
5145 : : .f = cmd_tx_vlan_reset_parsed,
5146 : : .data = NULL,
5147 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
5148 : : "VLAN header in packets sent on a port",
5149 : : .tokens = {
5150 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
5151 : : (void *)&cmd_tx_vlan_reset_reset,
5152 : : (void *)&cmd_tx_vlan_reset_portid,
5153 : : NULL,
5154 : : },
5155 : : };
5156 : :
5157 : :
5158 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
5159 : : struct cmd_csum_result {
5160 : : cmdline_fixed_string_t csum;
5161 : : cmdline_fixed_string_t mode;
5162 : : cmdline_fixed_string_t proto;
5163 : : cmdline_fixed_string_t hwsw;
5164 : : portid_t port_id;
5165 : : };
5166 : :
5167 : : static void
5168 : 0 : csum_show(int port_id)
5169 : : {
5170 : : struct rte_eth_dev_info dev_info;
5171 : : uint64_t tx_offloads;
5172 : : int ret;
5173 : :
5174 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
5175 : 0 : printf("Parse tunnel is %s\n",
5176 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
5177 : 0 : printf("IP checksum offload is %s\n",
5178 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
5179 : 0 : printf("UDP checksum offload is %s\n",
5180 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
5181 : 0 : printf("TCP checksum offload is %s\n",
5182 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
5183 : 0 : printf("SCTP checksum offload is %s\n",
5184 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
5185 : 0 : printf("Outer-Ip checksum offload is %s\n",
5186 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
5187 : 0 : printf("Outer-Udp checksum offload is %s\n",
5188 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
5189 : :
5190 : : /* display warnings if configuration is not supported by the NIC */
5191 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
5192 : 0 : if (ret != 0)
5193 : 0 : return;
5194 : :
5195 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
5196 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
5197 : 0 : fprintf(stderr,
5198 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
5199 : : port_id);
5200 : : }
5201 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
5202 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
5203 : 0 : fprintf(stderr,
5204 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
5205 : : port_id);
5206 : : }
5207 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
5208 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
5209 : 0 : fprintf(stderr,
5210 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
5211 : : port_id);
5212 : : }
5213 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
5214 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
5215 : 0 : fprintf(stderr,
5216 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
5217 : : port_id);
5218 : : }
5219 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
5220 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
5221 : 0 : fprintf(stderr,
5222 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
5223 : : port_id);
5224 : : }
5225 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
5226 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
5227 : : == 0) {
5228 : 0 : fprintf(stderr,
5229 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
5230 : : port_id);
5231 : : }
5232 : : }
5233 : :
5234 : : static void
5235 : : cmd_config_queue_tx_offloads(struct rte_port *port)
5236 : : {
5237 : : int k;
5238 : :
5239 : : /* Apply queue tx offloads configuration */
5240 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
5241 : 0 : port->txq[k].conf.offloads =
5242 : 0 : port->dev_conf.txmode.offloads;
5243 : : }
5244 : :
5245 : : static void
5246 : 0 : cmd_csum_parsed(void *parsed_result,
5247 : : __rte_unused struct cmdline *cl,
5248 : : __rte_unused void *data)
5249 : : {
5250 : : struct cmd_csum_result *res = parsed_result;
5251 : : int hw = 0;
5252 : : uint64_t csum_offloads = 0;
5253 : : struct rte_eth_dev_info dev_info;
5254 : : int ret;
5255 : :
5256 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
5257 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
5258 : 0 : return;
5259 : : }
5260 : 0 : if (!port_is_stopped(res->port_id)) {
5261 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5262 : 0 : return;
5263 : : }
5264 : :
5265 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5266 : 0 : if (ret != 0)
5267 : : return;
5268 : :
5269 : 0 : if (!strcmp(res->mode, "set")) {
5270 : :
5271 : 0 : if (!strcmp(res->hwsw, "hw"))
5272 : : hw = 1;
5273 : :
5274 : 0 : if (!strcmp(res->proto, "ip")) {
5275 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5276 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
5277 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
5278 : : } else {
5279 : 0 : fprintf(stderr,
5280 : : "IP checksum offload is not supported by port %u\n",
5281 : 0 : res->port_id);
5282 : : }
5283 : 0 : } else if (!strcmp(res->proto, "udp")) {
5284 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5285 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
5286 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
5287 : : } else {
5288 : 0 : fprintf(stderr,
5289 : : "UDP checksum offload is not supported by port %u\n",
5290 : 0 : res->port_id);
5291 : : }
5292 : 0 : } else if (!strcmp(res->proto, "tcp")) {
5293 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5294 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
5295 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
5296 : : } else {
5297 : 0 : fprintf(stderr,
5298 : : "TCP checksum offload is not supported by port %u\n",
5299 : 0 : res->port_id);
5300 : : }
5301 : 0 : } else if (!strcmp(res->proto, "sctp")) {
5302 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5303 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
5304 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
5305 : : } else {
5306 : 0 : fprintf(stderr,
5307 : : "SCTP checksum offload is not supported by port %u\n",
5308 : 0 : res->port_id);
5309 : : }
5310 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
5311 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5312 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5313 : : csum_offloads |=
5314 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
5315 : : } else {
5316 : 0 : fprintf(stderr,
5317 : : "Outer IP checksum offload is not supported by port %u\n",
5318 : 0 : res->port_id);
5319 : : }
5320 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
5321 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5322 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
5323 : : csum_offloads |=
5324 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
5325 : : } else {
5326 : 0 : fprintf(stderr,
5327 : : "Outer UDP checksum offload is not supported by port %u\n",
5328 : 0 : res->port_id);
5329 : : }
5330 : : }
5331 : :
5332 : 0 : if (hw) {
5333 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5334 : : csum_offloads;
5335 : : } else {
5336 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5337 : 0 : (~csum_offloads);
5338 : : }
5339 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5340 : : }
5341 : 0 : csum_show(res->port_id);
5342 : :
5343 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5344 : : }
5345 : :
5346 : : static cmdline_parse_token_string_t cmd_csum_csum =
5347 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5348 : : csum, "csum");
5349 : : static cmdline_parse_token_string_t cmd_csum_mode =
5350 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5351 : : mode, "set");
5352 : : static cmdline_parse_token_string_t cmd_csum_proto =
5353 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5354 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
5355 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
5356 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5357 : : hwsw, "hw#sw");
5358 : : static cmdline_parse_token_num_t cmd_csum_portid =
5359 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
5360 : : port_id, RTE_UINT16);
5361 : :
5362 : : static cmdline_parse_inst_t cmd_csum_set = {
5363 : : .f = cmd_csum_parsed,
5364 : : .data = NULL,
5365 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
5366 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
5367 : : "using csum forward engine",
5368 : : .tokens = {
5369 : : (void *)&cmd_csum_csum,
5370 : : (void *)&cmd_csum_mode,
5371 : : (void *)&cmd_csum_proto,
5372 : : (void *)&cmd_csum_hwsw,
5373 : : (void *)&cmd_csum_portid,
5374 : : NULL,
5375 : : },
5376 : : };
5377 : :
5378 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
5379 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5380 : : mode, "show");
5381 : :
5382 : : static cmdline_parse_inst_t cmd_csum_show = {
5383 : : .f = cmd_csum_parsed,
5384 : : .data = NULL,
5385 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
5386 : : .tokens = {
5387 : : (void *)&cmd_csum_csum,
5388 : : (void *)&cmd_csum_mode_show,
5389 : : (void *)&cmd_csum_portid,
5390 : : NULL,
5391 : : },
5392 : : };
5393 : :
5394 : : /* Enable/disable tunnel parsing */
5395 : : struct cmd_csum_tunnel_result {
5396 : : cmdline_fixed_string_t csum;
5397 : : cmdline_fixed_string_t parse;
5398 : : cmdline_fixed_string_t onoff;
5399 : : portid_t port_id;
5400 : : };
5401 : :
5402 : : static void
5403 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
5404 : : __rte_unused struct cmdline *cl,
5405 : : __rte_unused void *data)
5406 : : {
5407 : : struct cmd_csum_tunnel_result *res = parsed_result;
5408 : :
5409 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5410 : : return;
5411 : :
5412 : 0 : if (!strcmp(res->onoff, "on"))
5413 : 0 : ports[res->port_id].parse_tunnel = 1;
5414 : : else
5415 : 0 : ports[res->port_id].parse_tunnel = 0;
5416 : :
5417 : 0 : csum_show(res->port_id);
5418 : : }
5419 : :
5420 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
5421 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5422 : : csum, "csum");
5423 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
5424 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5425 : : parse, "parse-tunnel");
5426 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
5427 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5428 : : onoff, "on#off");
5429 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
5430 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
5431 : : port_id, RTE_UINT16);
5432 : :
5433 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
5434 : : .f = cmd_csum_tunnel_parsed,
5435 : : .data = NULL,
5436 : : .help_str = "csum parse-tunnel on|off <port_id>: "
5437 : : "Enable/Disable parsing of tunnels for csum engine",
5438 : : .tokens = {
5439 : : (void *)&cmd_csum_tunnel_csum,
5440 : : (void *)&cmd_csum_tunnel_parse,
5441 : : (void *)&cmd_csum_tunnel_onoff,
5442 : : (void *)&cmd_csum_tunnel_portid,
5443 : : NULL,
5444 : : },
5445 : : };
5446 : :
5447 : : struct cmd_csum_mac_swap_result {
5448 : : cmdline_fixed_string_t csum;
5449 : : cmdline_fixed_string_t parse;
5450 : : cmdline_fixed_string_t onoff;
5451 : : portid_t port_id;
5452 : : };
5453 : :
5454 : : static void
5455 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
5456 : : __rte_unused struct cmdline *cl,
5457 : : __rte_unused void *data)
5458 : : {
5459 : : struct cmd_csum_mac_swap_result *res = parsed_result;
5460 : :
5461 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5462 : : return;
5463 : 0 : if (strcmp(res->onoff, "on") == 0)
5464 : 0 : ports[res->port_id].fwd_mac_swap = 1;
5465 : : else
5466 : 0 : ports[res->port_id].fwd_mac_swap = 0;
5467 : : }
5468 : :
5469 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
5470 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5471 : : csum, "csum");
5472 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
5473 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5474 : : parse, "mac-swap");
5475 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
5476 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5477 : : onoff, "on#off");
5478 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
5479 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
5480 : : port_id, RTE_UINT16);
5481 : :
5482 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
5483 : : .f = cmd_csum_mac_swap_parsed,
5484 : : .data = NULL,
5485 : : .help_str = "csum mac-swap on|off <port_id>: "
5486 : : "Enable/Disable forward mac address swap",
5487 : : .tokens = {
5488 : : (void *)&cmd_csum_mac_swap_csum,
5489 : : (void *)&cmd_csum_mac_swap_parse,
5490 : : (void *)&cmd_csum_mac_swap_onoff,
5491 : : (void *)&cmd_csum_mac_swap_portid,
5492 : : NULL,
5493 : : },
5494 : : };
5495 : :
5496 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5497 : : struct cmd_tso_set_result {
5498 : : cmdline_fixed_string_t tso;
5499 : : cmdline_fixed_string_t mode;
5500 : : uint16_t tso_segsz;
5501 : : portid_t port_id;
5502 : : };
5503 : :
5504 : : static void
5505 : 0 : cmd_tso_set_parsed(void *parsed_result,
5506 : : __rte_unused struct cmdline *cl,
5507 : : __rte_unused void *data)
5508 : : {
5509 : : struct cmd_tso_set_result *res = parsed_result;
5510 : : struct rte_eth_dev_info dev_info;
5511 : : uint64_t offloads;
5512 : : int ret;
5513 : :
5514 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5515 : 0 : return;
5516 : 0 : if (!port_is_stopped(res->port_id)) {
5517 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5518 : 0 : return;
5519 : : }
5520 : :
5521 : 0 : if (!strcmp(res->mode, "set"))
5522 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5523 : :
5524 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5525 : 0 : if (ret != 0)
5526 : : return;
5527 : :
5528 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5529 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5530 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5531 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5532 : : res->port_id);
5533 : 0 : return;
5534 : : }
5535 : : /* display warnings if configuration is not supported by the NIC */
5536 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5537 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5538 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5539 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5540 : : }
5541 : :
5542 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5543 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5544 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5545 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5546 : : } else {
5547 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5548 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5549 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5550 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5551 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5552 : 0 : printf("segment size for non-tunneled packets is %d\n",
5553 : : ports[res->port_id].tso_segsz);
5554 : : }
5555 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5556 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5557 : : }
5558 : :
5559 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5560 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5561 : : tso, "tso");
5562 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5563 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5564 : : mode, "set");
5565 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5566 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5567 : : tso_segsz, RTE_UINT16);
5568 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5569 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5570 : : port_id, RTE_UINT16);
5571 : :
5572 : : static cmdline_parse_inst_t cmd_tso_set = {
5573 : : .f = cmd_tso_set_parsed,
5574 : : .data = NULL,
5575 : : .help_str = "tso set <tso_segsz> <port_id>: "
5576 : : "Set TSO segment size of non-tunneled packets for csum engine "
5577 : : "(0 to disable)",
5578 : : .tokens = {
5579 : : (void *)&cmd_tso_set_tso,
5580 : : (void *)&cmd_tso_set_mode,
5581 : : (void *)&cmd_tso_set_tso_segsz,
5582 : : (void *)&cmd_tso_set_portid,
5583 : : NULL,
5584 : : },
5585 : : };
5586 : :
5587 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5588 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5589 : : mode, "show");
5590 : :
5591 : :
5592 : : static cmdline_parse_inst_t cmd_tso_show = {
5593 : : .f = cmd_tso_set_parsed,
5594 : : .data = NULL,
5595 : : .help_str = "tso show <port_id>: "
5596 : : "Show TSO segment size of non-tunneled packets for csum engine",
5597 : : .tokens = {
5598 : : (void *)&cmd_tso_set_tso,
5599 : : (void *)&cmd_tso_show_mode,
5600 : : (void *)&cmd_tso_set_portid,
5601 : : NULL,
5602 : : },
5603 : : };
5604 : :
5605 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5606 : : struct cmd_tunnel_tso_set_result {
5607 : : cmdline_fixed_string_t tso;
5608 : : cmdline_fixed_string_t mode;
5609 : : uint16_t tso_segsz;
5610 : : portid_t port_id;
5611 : : };
5612 : :
5613 : : static void
5614 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5615 : : {
5616 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5617 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5618 : : port_id);
5619 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5620 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5621 : : port_id);
5622 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5623 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5624 : : port_id);
5625 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5626 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5627 : : port_id);
5628 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5629 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5630 : : port_id);
5631 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5632 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5633 : : port_id);
5634 : 0 : }
5635 : :
5636 : : static void
5637 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5638 : : __rte_unused struct cmdline *cl,
5639 : : __rte_unused void *data)
5640 : : {
5641 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5642 : : struct rte_eth_dev_info dev_info;
5643 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5644 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5645 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5646 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5647 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5648 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5649 : : int ret;
5650 : :
5651 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5652 : 0 : return;
5653 : 0 : if (!port_is_stopped(res->port_id)) {
5654 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5655 : 0 : return;
5656 : : }
5657 : :
5658 : 0 : if (!strcmp(res->mode, "set"))
5659 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5660 : :
5661 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5662 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5663 : : printf("TSO for tunneled packets is disabled\n");
5664 : : } else {
5665 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5666 : 0 : if (ret != 0)
5667 : : return;
5668 : :
5669 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5670 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5671 : 0 : res->port_id);
5672 : 0 : return;
5673 : : }
5674 : :
5675 : : /* Below conditions are needed to make it work:
5676 : : * (1) tunnel TSO is supported by the NIC;
5677 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5678 : : * are recognized;
5679 : : * (3) for tunneled pkts with outer L3 of IPv4,
5680 : : * "csum set outer-ip" must be set to hw, because after tso,
5681 : : * total_len of outer IP header is changed, and the checksum
5682 : : * of outer IP header calculated by sw should be wrong; that
5683 : : * is not necessary for IPv6 tunneled pkts because there's no
5684 : : * checksum in IP header anymore.
5685 : : */
5686 : 0 : if (!ports[res->port_id].parse_tunnel) {
5687 : 0 : fprintf(stderr,
5688 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5689 : 0 : return;
5690 : : }
5691 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5692 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5693 : 0 : fprintf(stderr,
5694 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5695 : 0 : return;
5696 : : }
5697 : :
5698 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5699 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5700 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5701 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5702 : 0 : ports[res->port_id].tunnel_tso_segsz);
5703 : : }
5704 : :
5705 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5706 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5707 : : }
5708 : :
5709 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5710 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5711 : : tso, "tunnel_tso");
5712 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5713 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5714 : : mode, "set");
5715 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5716 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5717 : : tso_segsz, RTE_UINT16);
5718 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5719 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5720 : : port_id, RTE_UINT16);
5721 : :
5722 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5723 : : .f = cmd_tunnel_tso_set_parsed,
5724 : : .data = NULL,
5725 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5726 : : "Set TSO segment size of tunneled packets for csum engine "
5727 : : "(0 to disable)",
5728 : : .tokens = {
5729 : : (void *)&cmd_tunnel_tso_set_tso,
5730 : : (void *)&cmd_tunnel_tso_set_mode,
5731 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5732 : : (void *)&cmd_tunnel_tso_set_portid,
5733 : : NULL,
5734 : : },
5735 : : };
5736 : :
5737 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5738 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5739 : : mode, "show");
5740 : :
5741 : :
5742 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5743 : : .f = cmd_tunnel_tso_set_parsed,
5744 : : .data = NULL,
5745 : : .help_str = "tunnel_tso show <port_id> "
5746 : : "Show TSO segment size of tunneled packets for csum engine",
5747 : : .tokens = {
5748 : : (void *)&cmd_tunnel_tso_set_tso,
5749 : : (void *)&cmd_tunnel_tso_show_mode,
5750 : : (void *)&cmd_tunnel_tso_set_portid,
5751 : : NULL,
5752 : : },
5753 : : };
5754 : :
5755 : : #ifdef RTE_LIB_GRO
5756 : : /* *** SET GRO FOR A PORT *** */
5757 : : struct cmd_gro_enable_result {
5758 : : cmdline_fixed_string_t cmd_set;
5759 : : cmdline_fixed_string_t cmd_port;
5760 : : cmdline_fixed_string_t cmd_keyword;
5761 : : cmdline_fixed_string_t cmd_onoff;
5762 : : portid_t cmd_pid;
5763 : : };
5764 : :
5765 : : static void
5766 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5767 : : __rte_unused struct cmdline *cl,
5768 : : __rte_unused void *data)
5769 : : {
5770 : : struct cmd_gro_enable_result *res;
5771 : :
5772 : : res = parsed_result;
5773 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5774 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5775 : 0 : }
5776 : :
5777 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5778 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5779 : : cmd_set, "set");
5780 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5781 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5782 : : cmd_keyword, "port");
5783 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5784 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5785 : : cmd_pid, RTE_UINT16);
5786 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5787 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5788 : : cmd_keyword, "gro");
5789 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5790 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5791 : : cmd_onoff, "on#off");
5792 : :
5793 : : static cmdline_parse_inst_t cmd_gro_enable = {
5794 : : .f = cmd_gro_enable_parsed,
5795 : : .data = NULL,
5796 : : .help_str = "set port <port_id> gro on|off",
5797 : : .tokens = {
5798 : : (void *)&cmd_gro_enable_set,
5799 : : (void *)&cmd_gro_enable_port,
5800 : : (void *)&cmd_gro_enable_pid,
5801 : : (void *)&cmd_gro_enable_keyword,
5802 : : (void *)&cmd_gro_enable_onoff,
5803 : : NULL,
5804 : : },
5805 : : };
5806 : :
5807 : : /* *** DISPLAY GRO CONFIGURATION *** */
5808 : : struct cmd_gro_show_result {
5809 : : cmdline_fixed_string_t cmd_show;
5810 : : cmdline_fixed_string_t cmd_port;
5811 : : cmdline_fixed_string_t cmd_keyword;
5812 : : portid_t cmd_pid;
5813 : : };
5814 : :
5815 : : static void
5816 : 0 : cmd_gro_show_parsed(void *parsed_result,
5817 : : __rte_unused struct cmdline *cl,
5818 : : __rte_unused void *data)
5819 : : {
5820 : : struct cmd_gro_show_result *res;
5821 : :
5822 : : res = parsed_result;
5823 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5824 : 0 : show_gro(res->cmd_pid);
5825 : 0 : }
5826 : :
5827 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5828 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5829 : : cmd_show, "show");
5830 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5831 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5832 : : cmd_port, "port");
5833 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5834 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5835 : : cmd_pid, RTE_UINT16);
5836 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5837 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5838 : : cmd_keyword, "gro");
5839 : :
5840 : : static cmdline_parse_inst_t cmd_gro_show = {
5841 : : .f = cmd_gro_show_parsed,
5842 : : .data = NULL,
5843 : : .help_str = "show port <port_id> gro",
5844 : : .tokens = {
5845 : : (void *)&cmd_gro_show_show,
5846 : : (void *)&cmd_gro_show_port,
5847 : : (void *)&cmd_gro_show_pid,
5848 : : (void *)&cmd_gro_show_keyword,
5849 : : NULL,
5850 : : },
5851 : : };
5852 : :
5853 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5854 : : struct cmd_gro_flush_result {
5855 : : cmdline_fixed_string_t cmd_set;
5856 : : cmdline_fixed_string_t cmd_keyword;
5857 : : cmdline_fixed_string_t cmd_flush;
5858 : : uint8_t cmd_cycles;
5859 : : };
5860 : :
5861 : : static void
5862 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5863 : : __rte_unused struct cmdline *cl,
5864 : : __rte_unused void *data)
5865 : : {
5866 : : struct cmd_gro_flush_result *res;
5867 : :
5868 : : res = parsed_result;
5869 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5870 : 0 : (!strcmp(res->cmd_flush, "flush")))
5871 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5872 : 0 : }
5873 : :
5874 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5875 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5876 : : cmd_set, "set");
5877 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5878 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5879 : : cmd_keyword, "gro");
5880 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5881 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5882 : : cmd_flush, "flush");
5883 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5884 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5885 : : cmd_cycles, RTE_UINT8);
5886 : :
5887 : : static cmdline_parse_inst_t cmd_gro_flush = {
5888 : : .f = cmd_gro_flush_parsed,
5889 : : .data = NULL,
5890 : : .help_str = "set gro flush <cycles>",
5891 : : .tokens = {
5892 : : (void *)&cmd_gro_flush_set,
5893 : : (void *)&cmd_gro_flush_keyword,
5894 : : (void *)&cmd_gro_flush_flush,
5895 : : (void *)&cmd_gro_flush_cycles,
5896 : : NULL,
5897 : : },
5898 : : };
5899 : : #endif /* RTE_LIB_GRO */
5900 : :
5901 : : #ifdef RTE_LIB_GSO
5902 : : /* *** ENABLE/DISABLE GSO *** */
5903 : : struct cmd_gso_enable_result {
5904 : : cmdline_fixed_string_t cmd_set;
5905 : : cmdline_fixed_string_t cmd_port;
5906 : : cmdline_fixed_string_t cmd_keyword;
5907 : : cmdline_fixed_string_t cmd_mode;
5908 : : portid_t cmd_pid;
5909 : : };
5910 : :
5911 : : static void
5912 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5913 : : __rte_unused struct cmdline *cl,
5914 : : __rte_unused void *data)
5915 : : {
5916 : : struct cmd_gso_enable_result *res;
5917 : :
5918 : : res = parsed_result;
5919 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5920 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5921 : 0 : }
5922 : :
5923 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5924 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5925 : : cmd_set, "set");
5926 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5927 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5928 : : cmd_port, "port");
5929 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5930 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5931 : : cmd_keyword, "gso");
5932 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5933 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5934 : : cmd_mode, "on#off");
5935 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5936 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5937 : : cmd_pid, RTE_UINT16);
5938 : :
5939 : : static cmdline_parse_inst_t cmd_gso_enable = {
5940 : : .f = cmd_gso_enable_parsed,
5941 : : .data = NULL,
5942 : : .help_str = "set port <port_id> gso on|off",
5943 : : .tokens = {
5944 : : (void *)&cmd_gso_enable_set,
5945 : : (void *)&cmd_gso_enable_port,
5946 : : (void *)&cmd_gso_enable_pid,
5947 : : (void *)&cmd_gso_enable_keyword,
5948 : : (void *)&cmd_gso_enable_mode,
5949 : : NULL,
5950 : : },
5951 : : };
5952 : :
5953 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5954 : : struct cmd_gso_size_result {
5955 : : cmdline_fixed_string_t cmd_set;
5956 : : cmdline_fixed_string_t cmd_keyword;
5957 : : cmdline_fixed_string_t cmd_segsz;
5958 : : uint16_t cmd_size;
5959 : : };
5960 : :
5961 : : static void
5962 : 0 : cmd_gso_size_parsed(void *parsed_result,
5963 : : __rte_unused struct cmdline *cl,
5964 : : __rte_unused void *data)
5965 : : {
5966 : : struct cmd_gso_size_result *res = parsed_result;
5967 : :
5968 : 0 : if (test_done == 0) {
5969 : 0 : fprintf(stderr,
5970 : : "Before setting GSO segsz, please first stop forwarding\n");
5971 : 0 : return;
5972 : : }
5973 : :
5974 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5975 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5976 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5977 : 0 : fprintf(stderr,
5978 : : "gso_size should be larger than %zu. Please input a legal value\n",
5979 : : RTE_GSO_SEG_SIZE_MIN);
5980 : : else
5981 : 0 : gso_max_segment_size = res->cmd_size;
5982 : : }
5983 : : }
5984 : :
5985 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5986 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5987 : : cmd_set, "set");
5988 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5989 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5990 : : cmd_keyword, "gso");
5991 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5992 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5993 : : cmd_segsz, "segsz");
5994 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5995 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5996 : : cmd_size, RTE_UINT16);
5997 : :
5998 : : static cmdline_parse_inst_t cmd_gso_size = {
5999 : : .f = cmd_gso_size_parsed,
6000 : : .data = NULL,
6001 : : .help_str = "set gso segsz <length>",
6002 : : .tokens = {
6003 : : (void *)&cmd_gso_size_set,
6004 : : (void *)&cmd_gso_size_keyword,
6005 : : (void *)&cmd_gso_size_segsz,
6006 : : (void *)&cmd_gso_size_size,
6007 : : NULL,
6008 : : },
6009 : : };
6010 : :
6011 : : /* *** SHOW GSO CONFIGURATION *** */
6012 : : struct cmd_gso_show_result {
6013 : : cmdline_fixed_string_t cmd_show;
6014 : : cmdline_fixed_string_t cmd_port;
6015 : : cmdline_fixed_string_t cmd_keyword;
6016 : : portid_t cmd_pid;
6017 : : };
6018 : :
6019 : : static void
6020 : 0 : cmd_gso_show_parsed(void *parsed_result,
6021 : : __rte_unused struct cmdline *cl,
6022 : : __rte_unused void *data)
6023 : : {
6024 : : struct cmd_gso_show_result *res = parsed_result;
6025 : :
6026 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
6027 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
6028 : 0 : return;
6029 : : }
6030 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
6031 : 0 : if (gso_ports[res->cmd_pid].enable) {
6032 : 0 : printf("Max GSO'd packet size: %uB\n"
6033 : : "Supported GSO types: TCP/IPv4, "
6034 : : "UDP/IPv4, VxLAN with inner "
6035 : : "TCP/IPv4 packet, GRE with inner "
6036 : : "TCP/IPv4 packet\n",
6037 : : gso_max_segment_size);
6038 : : } else
6039 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
6040 : : }
6041 : : }
6042 : :
6043 : : static cmdline_parse_token_string_t cmd_gso_show_show =
6044 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6045 : : cmd_show, "show");
6046 : : static cmdline_parse_token_string_t cmd_gso_show_port =
6047 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6048 : : cmd_port, "port");
6049 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
6050 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6051 : : cmd_keyword, "gso");
6052 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
6053 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
6054 : : cmd_pid, RTE_UINT16);
6055 : :
6056 : : static cmdline_parse_inst_t cmd_gso_show = {
6057 : : .f = cmd_gso_show_parsed,
6058 : : .data = NULL,
6059 : : .help_str = "show port <port_id> gso",
6060 : : .tokens = {
6061 : : (void *)&cmd_gso_show_show,
6062 : : (void *)&cmd_gso_show_port,
6063 : : (void *)&cmd_gso_show_pid,
6064 : : (void *)&cmd_gso_show_keyword,
6065 : : NULL,
6066 : : },
6067 : : };
6068 : : #endif /* RTE_LIB_GSO */
6069 : :
6070 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
6071 : : struct cmd_set_flush_rx {
6072 : : cmdline_fixed_string_t set;
6073 : : cmdline_fixed_string_t flush_rx;
6074 : : cmdline_fixed_string_t mode;
6075 : : };
6076 : :
6077 : : static void
6078 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
6079 : : __rte_unused struct cmdline *cl,
6080 : : __rte_unused void *data)
6081 : : {
6082 : : struct cmd_set_flush_rx *res = parsed_result;
6083 : :
6084 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
6085 : : printf("multi-process doesn't support to flush Rx queues.\n");
6086 : 0 : return;
6087 : : }
6088 : :
6089 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6090 : : }
6091 : :
6092 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
6093 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6094 : : set, "set");
6095 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
6096 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6097 : : flush_rx, "flush_rx");
6098 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
6099 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6100 : : mode, "on#off");
6101 : :
6102 : :
6103 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
6104 : : .f = cmd_set_flush_rx_parsed,
6105 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
6106 : : .data = NULL,
6107 : : .tokens = {
6108 : : (void *)&cmd_setflushrx_set,
6109 : : (void *)&cmd_setflushrx_flush_rx,
6110 : : (void *)&cmd_setflushrx_mode,
6111 : : NULL,
6112 : : },
6113 : : };
6114 : :
6115 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
6116 : : struct cmd_set_link_check {
6117 : : cmdline_fixed_string_t set;
6118 : : cmdline_fixed_string_t link_check;
6119 : : cmdline_fixed_string_t mode;
6120 : : };
6121 : :
6122 : : static void
6123 : 0 : cmd_set_link_check_parsed(void *parsed_result,
6124 : : __rte_unused struct cmdline *cl,
6125 : : __rte_unused void *data)
6126 : : {
6127 : : struct cmd_set_link_check *res = parsed_result;
6128 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6129 : 0 : }
6130 : :
6131 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
6132 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6133 : : set, "set");
6134 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
6135 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6136 : : link_check, "link_check");
6137 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
6138 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6139 : : mode, "on#off");
6140 : :
6141 : :
6142 : : static cmdline_parse_inst_t cmd_set_link_check = {
6143 : : .f = cmd_set_link_check_parsed,
6144 : : .help_str = "set link_check on|off: Enable/Disable link status check "
6145 : : "when starting/stopping a port",
6146 : : .data = NULL,
6147 : : .tokens = {
6148 : : (void *)&cmd_setlinkcheck_set,
6149 : : (void *)&cmd_setlinkcheck_link_check,
6150 : : (void *)&cmd_setlinkcheck_mode,
6151 : : NULL,
6152 : : },
6153 : : };
6154 : :
6155 : : /* *** SET FORWARDING MODE *** */
6156 : : struct cmd_set_fwd_mode_result {
6157 : : cmdline_fixed_string_t set;
6158 : : cmdline_fixed_string_t fwd;
6159 : : cmdline_fixed_string_t mode;
6160 : : };
6161 : :
6162 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
6163 : : __rte_unused struct cmdline *cl,
6164 : : __rte_unused void *data)
6165 : : {
6166 : : struct cmd_set_fwd_mode_result *res = parsed_result;
6167 : :
6168 : 0 : retry_enabled = 0;
6169 : 0 : set_pkt_forwarding_mode(res->mode);
6170 : 0 : }
6171 : :
6172 : : static cmdline_parse_token_string_t cmd_setfwd_set =
6173 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6174 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
6175 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6176 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
6177 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6178 : : "" /* defined at init */);
6179 : :
6180 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
6181 : : .f = cmd_set_fwd_mode_parsed,
6182 : : .data = NULL,
6183 : : .help_str = NULL, /* defined at init */
6184 : : .tokens = {
6185 : : (void *)&cmd_setfwd_set,
6186 : : (void *)&cmd_setfwd_fwd,
6187 : : (void *)&cmd_setfwd_mode,
6188 : : NULL,
6189 : : },
6190 : : };
6191 : :
6192 : 0 : static void cmd_set_fwd_mode_init(void)
6193 : : {
6194 : : char *modes, *c;
6195 : : static char token[128];
6196 : : static char help[256];
6197 : : cmdline_parse_token_string_t *token_struct;
6198 : :
6199 : 0 : modes = list_pkt_forwarding_modes();
6200 : : snprintf(help, sizeof(help), "set fwd %s: "
6201 : : "Set packet forwarding mode", modes);
6202 : 0 : cmd_set_fwd_mode.help_str = help;
6203 : :
6204 : : /* string token separator is # */
6205 : 0 : for (c = token; *modes != '\0'; modes++)
6206 : 0 : if (*modes == '|')
6207 : 0 : *c++ = '#';
6208 : : else
6209 : 0 : *c++ = *modes;
6210 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6211 : 0 : token_struct->string_data.str = token;
6212 : 0 : }
6213 : :
6214 : : /* *** SET RETRY FORWARDING MODE *** */
6215 : : struct cmd_set_fwd_retry_mode_result {
6216 : : cmdline_fixed_string_t set;
6217 : : cmdline_fixed_string_t fwd;
6218 : : cmdline_fixed_string_t mode;
6219 : : cmdline_fixed_string_t retry;
6220 : : };
6221 : :
6222 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6223 : : __rte_unused struct cmdline *cl,
6224 : : __rte_unused void *data)
6225 : : {
6226 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6227 : :
6228 : 0 : retry_enabled = 1;
6229 : 0 : set_pkt_forwarding_mode(res->mode);
6230 : 0 : }
6231 : :
6232 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6233 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6234 : : set, "set");
6235 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6236 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6237 : : fwd, "fwd");
6238 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6239 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6240 : : mode,
6241 : : "" /* defined at init */);
6242 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6243 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6244 : : retry, "retry");
6245 : :
6246 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6247 : : .f = cmd_set_fwd_retry_mode_parsed,
6248 : : .data = NULL,
6249 : : .help_str = NULL, /* defined at init */
6250 : : .tokens = {
6251 : : (void *)&cmd_setfwd_retry_set,
6252 : : (void *)&cmd_setfwd_retry_fwd,
6253 : : (void *)&cmd_setfwd_retry_mode,
6254 : : (void *)&cmd_setfwd_retry_retry,
6255 : : NULL,
6256 : : },
6257 : : };
6258 : :
6259 : 0 : static void cmd_set_fwd_retry_mode_init(void)
6260 : : {
6261 : : char *modes, *c;
6262 : : static char token[128];
6263 : : static char help[256];
6264 : : cmdline_parse_token_string_t *token_struct;
6265 : :
6266 : 0 : modes = list_pkt_forwarding_retry_modes();
6267 : : snprintf(help, sizeof(help), "set fwd %s retry: "
6268 : : "Set packet forwarding mode with retry", modes);
6269 : 0 : cmd_set_fwd_retry_mode.help_str = help;
6270 : :
6271 : : /* string token separator is # */
6272 : 0 : for (c = token; *modes != '\0'; modes++)
6273 : 0 : if (*modes == '|')
6274 : 0 : *c++ = '#';
6275 : : else
6276 : 0 : *c++ = *modes;
6277 : 0 : token_struct = (cmdline_parse_token_string_t *)
6278 : : cmd_set_fwd_retry_mode.tokens[2];
6279 : 0 : token_struct->string_data.str = token;
6280 : 0 : }
6281 : :
6282 : 0 : static void show_dcb_fwd_tc_config(void)
6283 : : {
6284 : : int i;
6285 : : printf("DCB forwarding TC list:");
6286 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6287 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6288 : : printf(" %d", i);
6289 : : }
6290 : : printf("\n");
6291 : 0 : printf("DCB forwarding cores per-TC: %u\n", dcb_fwd_tc_cores);
6292 : 0 : }
6293 : :
6294 : : /* *** set DCB forward TCs *** */
6295 : : struct cmd_set_dcb_fwd_tc_result {
6296 : : cmdline_fixed_string_t set;
6297 : : cmdline_fixed_string_t dcb;
6298 : : cmdline_fixed_string_t fwd_tc;
6299 : : uint8_t tc_mask;
6300 : : };
6301 : :
6302 : 0 : static void cmd_set_dcb_fwd_tc_parsed(void *parsed_result,
6303 : : __rte_unused struct cmdline *cl,
6304 : : __rte_unused void *data)
6305 : : {
6306 : : struct cmd_set_dcb_fwd_tc_result *res = parsed_result;
6307 : : int i;
6308 : 0 : if (test_done == 0) {
6309 : 0 : fprintf(stderr, "Please stop forwarding first\n");
6310 : 0 : return;
6311 : : }
6312 : 0 : if (res->tc_mask == 0) {
6313 : 0 : fprintf(stderr, "TC mask should not be zero!\n");
6314 : 0 : return;
6315 : : }
6316 : : printf("Enabled DCB forwarding TC list:");
6317 : 0 : dcb_fwd_tc_mask = res->tc_mask;
6318 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6319 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6320 : : printf(" %d", i);
6321 : : }
6322 : : printf("\n");
6323 : : }
6324 : :
6325 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_set =
6326 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6327 : : set, "set");
6328 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_dcb =
6329 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6330 : : dcb, "dcb");
6331 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_fwdtc =
6332 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6333 : : fwd_tc, "fwd_tc");
6334 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_tcmask =
6335 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6336 : : tc_mask, RTE_UINT8);
6337 : :
6338 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc = {
6339 : : .f = cmd_set_dcb_fwd_tc_parsed,
6340 : : .data = NULL,
6341 : : .help_str = "config DCB forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled, and vice versa.",
6342 : : .tokens = {
6343 : : (void *)&cmd_set_dcb_fwd_tc_set,
6344 : : (void *)&cmd_set_dcb_fwd_tc_dcb,
6345 : : (void *)&cmd_set_dcb_fwd_tc_fwdtc,
6346 : : (void *)&cmd_set_dcb_fwd_tc_tcmask,
6347 : : NULL,
6348 : : },
6349 : : };
6350 : :
6351 : : /* *** set DCB forward cores per TC *** */
6352 : : struct cmd_set_dcb_fwd_tc_cores_result {
6353 : : cmdline_fixed_string_t set;
6354 : : cmdline_fixed_string_t dcb;
6355 : : cmdline_fixed_string_t fwd_tc_cores;
6356 : : uint8_t tc_cores;
6357 : : };
6358 : :
6359 : 0 : static void cmd_set_dcb_fwd_tc_cores_parsed(void *parsed_result,
6360 : : __rte_unused struct cmdline *cl,
6361 : : __rte_unused void *data)
6362 : : {
6363 : : struct cmd_set_dcb_fwd_tc_cores_result *res = parsed_result;
6364 : 0 : if (test_done == 0) {
6365 : 0 : fprintf(stderr, "Please stop forwarding first\n");
6366 : 0 : return;
6367 : : }
6368 : 0 : if (res->tc_cores == 0) {
6369 : 0 : fprintf(stderr, "Cores per-TC should not be zero!\n");
6370 : 0 : return;
6371 : : }
6372 : 0 : dcb_fwd_tc_cores = res->tc_cores;
6373 : 0 : printf("Set cores-per-TC: %u\n", dcb_fwd_tc_cores);
6374 : : }
6375 : :
6376 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_set =
6377 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6378 : : set, "set");
6379 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_dcb =
6380 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6381 : : dcb, "dcb");
6382 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_fwdtccores =
6383 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6384 : : fwd_tc_cores, "fwd_tc_cores");
6385 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_cores_tccores =
6386 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6387 : : tc_cores, RTE_UINT8);
6388 : :
6389 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc_cores = {
6390 : : .f = cmd_set_dcb_fwd_tc_cores_parsed,
6391 : : .data = NULL,
6392 : : .help_str = "config DCB forwarding cores per-TC, 1-means one core process all queues of a TC.",
6393 : : .tokens = {
6394 : : (void *)&cmd_set_dcb_fwd_tc_cores_set,
6395 : : (void *)&cmd_set_dcb_fwd_tc_cores_dcb,
6396 : : (void *)&cmd_set_dcb_fwd_tc_cores_fwdtccores,
6397 : : (void *)&cmd_set_dcb_fwd_tc_cores_tccores,
6398 : : NULL,
6399 : : },
6400 : : };
6401 : :
6402 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6403 : : struct cmd_set_burst_tx_retry_result {
6404 : : cmdline_fixed_string_t set;
6405 : : cmdline_fixed_string_t burst;
6406 : : cmdline_fixed_string_t tx;
6407 : : cmdline_fixed_string_t delay;
6408 : : uint32_t time;
6409 : : cmdline_fixed_string_t retry;
6410 : : uint32_t retry_num;
6411 : : };
6412 : :
6413 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6414 : : __rte_unused struct cmdline *cl,
6415 : : __rte_unused void *data)
6416 : : {
6417 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
6418 : :
6419 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6420 : 0 : && !strcmp(res->tx, "tx")) {
6421 : 0 : if (!strcmp(res->delay, "delay"))
6422 : 0 : burst_tx_delay_time = res->time;
6423 : 0 : if (!strcmp(res->retry, "retry"))
6424 : 0 : burst_tx_retry_num = res->retry_num;
6425 : : }
6426 : :
6427 : 0 : }
6428 : :
6429 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6430 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6431 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6432 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6433 : : "burst");
6434 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6435 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6436 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6437 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6438 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6439 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6440 : : RTE_UINT32);
6441 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6442 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6443 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6444 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6445 : : RTE_UINT32);
6446 : :
6447 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6448 : : .f = cmd_set_burst_tx_retry_parsed,
6449 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6450 : : .tokens = {
6451 : : (void *)&cmd_set_burst_tx_retry_set,
6452 : : (void *)&cmd_set_burst_tx_retry_burst,
6453 : : (void *)&cmd_set_burst_tx_retry_tx,
6454 : : (void *)&cmd_set_burst_tx_retry_delay,
6455 : : (void *)&cmd_set_burst_tx_retry_time,
6456 : : (void *)&cmd_set_burst_tx_retry_retry,
6457 : : (void *)&cmd_set_burst_tx_retry_retry_num,
6458 : : NULL,
6459 : : },
6460 : : };
6461 : :
6462 : : /* *** SET PROMISC MODE *** */
6463 : : struct cmd_set_promisc_mode_result {
6464 : : cmdline_fixed_string_t set;
6465 : : cmdline_fixed_string_t promisc;
6466 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6467 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6468 : : cmdline_fixed_string_t mode;
6469 : : };
6470 : :
6471 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
6472 : : __rte_unused struct cmdline *cl,
6473 : : void *allports)
6474 : : {
6475 : : struct cmd_set_promisc_mode_result *res = parsed_result;
6476 : : int enable;
6477 : : portid_t i;
6478 : :
6479 : 0 : if (!strcmp(res->mode, "on"))
6480 : : enable = 1;
6481 : : else
6482 : : enable = 0;
6483 : :
6484 : : /* all ports */
6485 : 0 : if (allports) {
6486 : 0 : RTE_ETH_FOREACH_DEV(i)
6487 : 0 : eth_set_promisc_mode(i, enable);
6488 : : } else {
6489 : 0 : eth_set_promisc_mode(res->port_num, enable);
6490 : : }
6491 : 0 : }
6492 : :
6493 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
6494 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6495 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
6496 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6497 : : "promisc");
6498 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
6499 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6500 : : "all");
6501 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
6502 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6503 : : RTE_UINT16);
6504 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
6505 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6506 : : "on#off");
6507 : :
6508 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6509 : : .f = cmd_set_promisc_mode_parsed,
6510 : : .data = (void *)1,
6511 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
6512 : : .tokens = {
6513 : : (void *)&cmd_setpromisc_set,
6514 : : (void *)&cmd_setpromisc_promisc,
6515 : : (void *)&cmd_setpromisc_portall,
6516 : : (void *)&cmd_setpromisc_mode,
6517 : : NULL,
6518 : : },
6519 : : };
6520 : :
6521 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6522 : : .f = cmd_set_promisc_mode_parsed,
6523 : : .data = (void *)0,
6524 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6525 : : .tokens = {
6526 : : (void *)&cmd_setpromisc_set,
6527 : : (void *)&cmd_setpromisc_promisc,
6528 : : (void *)&cmd_setpromisc_portnum,
6529 : : (void *)&cmd_setpromisc_mode,
6530 : : NULL,
6531 : : },
6532 : : };
6533 : :
6534 : : /* *** SET ALLMULTI MODE *** */
6535 : : struct cmd_set_allmulti_mode_result {
6536 : : cmdline_fixed_string_t set;
6537 : : cmdline_fixed_string_t allmulti;
6538 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6539 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6540 : : cmdline_fixed_string_t mode;
6541 : : };
6542 : :
6543 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6544 : : __rte_unused struct cmdline *cl,
6545 : : void *allports)
6546 : : {
6547 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
6548 : : int enable;
6549 : : portid_t i;
6550 : :
6551 : 0 : if (!strcmp(res->mode, "on"))
6552 : : enable = 1;
6553 : : else
6554 : : enable = 0;
6555 : :
6556 : : /* all ports */
6557 : 0 : if (allports) {
6558 : 0 : RTE_ETH_FOREACH_DEV(i) {
6559 : 0 : eth_set_allmulticast_mode(i, enable);
6560 : : }
6561 : : }
6562 : : else {
6563 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
6564 : : }
6565 : 0 : }
6566 : :
6567 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
6568 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6569 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6570 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6571 : : "allmulti");
6572 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
6573 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6574 : : "all");
6575 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
6576 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6577 : : RTE_UINT16);
6578 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
6579 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6580 : : "on#off");
6581 : :
6582 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6583 : : .f = cmd_set_allmulti_mode_parsed,
6584 : : .data = (void *)1,
6585 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6586 : : .tokens = {
6587 : : (void *)&cmd_setallmulti_set,
6588 : : (void *)&cmd_setallmulti_allmulti,
6589 : : (void *)&cmd_setallmulti_portall,
6590 : : (void *)&cmd_setallmulti_mode,
6591 : : NULL,
6592 : : },
6593 : : };
6594 : :
6595 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6596 : : .f = cmd_set_allmulti_mode_parsed,
6597 : : .data = (void *)0,
6598 : : .help_str = "set allmulti <port_id> on|off: "
6599 : : "Set allmulti mode on port_id",
6600 : : .tokens = {
6601 : : (void *)&cmd_setallmulti_set,
6602 : : (void *)&cmd_setallmulti_allmulti,
6603 : : (void *)&cmd_setallmulti_portnum,
6604 : : (void *)&cmd_setallmulti_mode,
6605 : : NULL,
6606 : : },
6607 : : };
6608 : :
6609 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6610 : : struct cmd_link_flow_ctrl_show {
6611 : : cmdline_fixed_string_t show;
6612 : : cmdline_fixed_string_t port;
6613 : : portid_t port_id;
6614 : : cmdline_fixed_string_t flow_ctrl;
6615 : : };
6616 : :
6617 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6618 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6619 : : show, "show");
6620 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6621 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6622 : : port, "port");
6623 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6624 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6625 : : port_id, RTE_UINT16);
6626 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6627 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6628 : : flow_ctrl, "flow_ctrl");
6629 : :
6630 : : static void
6631 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6632 : : __rte_unused struct cmdline *cl,
6633 : : __rte_unused void *data)
6634 : : {
6635 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6636 : : static const char *info_border = "*********************";
6637 : : struct rte_eth_fc_conf fc_conf;
6638 : : bool rx_fc_en = false;
6639 : : bool tx_fc_en = false;
6640 : : int ret;
6641 : :
6642 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6643 : 0 : if (ret != 0) {
6644 : 0 : fprintf(stderr,
6645 : : "Failed to get current flow ctrl information: err = %d\n",
6646 : : ret);
6647 : 0 : return;
6648 : : }
6649 : :
6650 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6651 : : rx_fc_en = true;
6652 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6653 : : tx_fc_en = true;
6654 : :
6655 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6656 : 0 : info_border, res->port_id, info_border);
6657 : : printf("FC mode:\n");
6658 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6659 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6660 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6661 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6662 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6663 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6664 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6665 : 0 : printf("Forward MAC control frames: %s\n",
6666 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6667 : 0 : printf("\n%s************** End ***********%s\n",
6668 : : info_border, info_border);
6669 : : }
6670 : :
6671 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6672 : : .f = cmd_link_flow_ctrl_show_parsed,
6673 : : .data = NULL,
6674 : : .help_str = "show port <port_id> flow_ctrl",
6675 : : .tokens = {
6676 : : (void *)&cmd_lfc_show_show,
6677 : : (void *)&cmd_lfc_show_port,
6678 : : (void *)&cmd_lfc_show_portid,
6679 : : (void *)&cmd_lfc_show_flow_ctrl,
6680 : : NULL,
6681 : : },
6682 : : };
6683 : :
6684 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6685 : : struct cmd_link_flow_ctrl_set_result {
6686 : : cmdline_fixed_string_t set;
6687 : : cmdline_fixed_string_t flow_ctrl;
6688 : : cmdline_fixed_string_t rx;
6689 : : cmdline_fixed_string_t rx_lfc_mode;
6690 : : cmdline_fixed_string_t tx;
6691 : : cmdline_fixed_string_t tx_lfc_mode;
6692 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6693 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6694 : : cmdline_fixed_string_t autoneg_str;
6695 : : cmdline_fixed_string_t autoneg;
6696 : : cmdline_fixed_string_t hw_str;
6697 : : uint32_t high_water;
6698 : : cmdline_fixed_string_t lw_str;
6699 : : uint32_t low_water;
6700 : : cmdline_fixed_string_t pt_str;
6701 : : uint16_t pause_time;
6702 : : cmdline_fixed_string_t xon_str;
6703 : : uint16_t send_xon;
6704 : : portid_t port_id;
6705 : : };
6706 : :
6707 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6708 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6709 : : set, "set");
6710 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6711 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6712 : : flow_ctrl, "flow_ctrl");
6713 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6714 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6715 : : rx, "rx");
6716 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6717 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6718 : : rx_lfc_mode, "on#off");
6719 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6720 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6721 : : tx, "tx");
6722 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6723 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6724 : : tx_lfc_mode, "on#off");
6725 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6726 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6727 : : hw_str, "high_water");
6728 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6729 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6730 : : high_water, RTE_UINT32);
6731 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6732 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6733 : : lw_str, "low_water");
6734 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6735 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6736 : : low_water, RTE_UINT32);
6737 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6738 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6739 : : pt_str, "pause_time");
6740 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6741 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6742 : : pause_time, RTE_UINT16);
6743 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6744 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6745 : : xon_str, "send_xon");
6746 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6747 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6748 : : send_xon, RTE_UINT16);
6749 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6750 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6751 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6752 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6753 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6754 : : mac_ctrl_frame_fwd_mode, "on#off");
6755 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6756 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6757 : : autoneg_str, "autoneg");
6758 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6759 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6760 : : autoneg, "on#off");
6761 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6762 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6763 : : port_id, RTE_UINT16);
6764 : :
6765 : : /* forward declaration */
6766 : : static void
6767 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6768 : : void *data);
6769 : :
6770 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6771 : : .f = cmd_link_flow_ctrl_set_parsed,
6772 : : .data = NULL,
6773 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6774 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6775 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6776 : : .tokens = {
6777 : : (void *)&cmd_lfc_set_set,
6778 : : (void *)&cmd_lfc_set_flow_ctrl,
6779 : : (void *)&cmd_lfc_set_rx,
6780 : : (void *)&cmd_lfc_set_rx_mode,
6781 : : (void *)&cmd_lfc_set_tx,
6782 : : (void *)&cmd_lfc_set_tx_mode,
6783 : : (void *)&cmd_lfc_set_high_water,
6784 : : (void *)&cmd_lfc_set_low_water,
6785 : : (void *)&cmd_lfc_set_pause_time,
6786 : : (void *)&cmd_lfc_set_send_xon,
6787 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6788 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6789 : : (void *)&cmd_lfc_set_autoneg_str,
6790 : : (void *)&cmd_lfc_set_autoneg,
6791 : : (void *)&cmd_lfc_set_portid,
6792 : : NULL,
6793 : : },
6794 : : };
6795 : :
6796 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6797 : : .f = cmd_link_flow_ctrl_set_parsed,
6798 : : .data = (void *)&cmd_link_flow_control_set_rx,
6799 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6800 : : "Change rx flow control parameter",
6801 : : .tokens = {
6802 : : (void *)&cmd_lfc_set_set,
6803 : : (void *)&cmd_lfc_set_flow_ctrl,
6804 : : (void *)&cmd_lfc_set_rx,
6805 : : (void *)&cmd_lfc_set_rx_mode,
6806 : : (void *)&cmd_lfc_set_portid,
6807 : : NULL,
6808 : : },
6809 : : };
6810 : :
6811 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6812 : : .f = cmd_link_flow_ctrl_set_parsed,
6813 : : .data = (void *)&cmd_link_flow_control_set_tx,
6814 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6815 : : "Change tx flow control parameter",
6816 : : .tokens = {
6817 : : (void *)&cmd_lfc_set_set,
6818 : : (void *)&cmd_lfc_set_flow_ctrl,
6819 : : (void *)&cmd_lfc_set_tx,
6820 : : (void *)&cmd_lfc_set_tx_mode,
6821 : : (void *)&cmd_lfc_set_portid,
6822 : : NULL,
6823 : : },
6824 : : };
6825 : :
6826 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6827 : : .f = cmd_link_flow_ctrl_set_parsed,
6828 : : .data = (void *)&cmd_link_flow_control_set_hw,
6829 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6830 : : "Change high water flow control parameter",
6831 : : .tokens = {
6832 : : (void *)&cmd_lfc_set_set,
6833 : : (void *)&cmd_lfc_set_flow_ctrl,
6834 : : (void *)&cmd_lfc_set_high_water_str,
6835 : : (void *)&cmd_lfc_set_high_water,
6836 : : (void *)&cmd_lfc_set_portid,
6837 : : NULL,
6838 : : },
6839 : : };
6840 : :
6841 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6842 : : .f = cmd_link_flow_ctrl_set_parsed,
6843 : : .data = (void *)&cmd_link_flow_control_set_lw,
6844 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6845 : : "Change low water flow control parameter",
6846 : : .tokens = {
6847 : : (void *)&cmd_lfc_set_set,
6848 : : (void *)&cmd_lfc_set_flow_ctrl,
6849 : : (void *)&cmd_lfc_set_low_water_str,
6850 : : (void *)&cmd_lfc_set_low_water,
6851 : : (void *)&cmd_lfc_set_portid,
6852 : : NULL,
6853 : : },
6854 : : };
6855 : :
6856 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6857 : : .f = cmd_link_flow_ctrl_set_parsed,
6858 : : .data = (void *)&cmd_link_flow_control_set_pt,
6859 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6860 : : "Change pause time flow control parameter",
6861 : : .tokens = {
6862 : : (void *)&cmd_lfc_set_set,
6863 : : (void *)&cmd_lfc_set_flow_ctrl,
6864 : : (void *)&cmd_lfc_set_pause_time_str,
6865 : : (void *)&cmd_lfc_set_pause_time,
6866 : : (void *)&cmd_lfc_set_portid,
6867 : : NULL,
6868 : : },
6869 : : };
6870 : :
6871 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6872 : : .f = cmd_link_flow_ctrl_set_parsed,
6873 : : .data = (void *)&cmd_link_flow_control_set_xon,
6874 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6875 : : "Change send_xon flow control parameter",
6876 : : .tokens = {
6877 : : (void *)&cmd_lfc_set_set,
6878 : : (void *)&cmd_lfc_set_flow_ctrl,
6879 : : (void *)&cmd_lfc_set_send_xon_str,
6880 : : (void *)&cmd_lfc_set_send_xon,
6881 : : (void *)&cmd_lfc_set_portid,
6882 : : NULL,
6883 : : },
6884 : : };
6885 : :
6886 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6887 : : .f = cmd_link_flow_ctrl_set_parsed,
6888 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6889 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6890 : : "Change mac ctrl fwd flow control parameter",
6891 : : .tokens = {
6892 : : (void *)&cmd_lfc_set_set,
6893 : : (void *)&cmd_lfc_set_flow_ctrl,
6894 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6895 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6896 : : (void *)&cmd_lfc_set_portid,
6897 : : NULL,
6898 : : },
6899 : : };
6900 : :
6901 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6902 : : .f = cmd_link_flow_ctrl_set_parsed,
6903 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6904 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6905 : : "Change autoneg flow control parameter",
6906 : : .tokens = {
6907 : : (void *)&cmd_lfc_set_set,
6908 : : (void *)&cmd_lfc_set_flow_ctrl,
6909 : : (void *)&cmd_lfc_set_autoneg_str,
6910 : : (void *)&cmd_lfc_set_autoneg,
6911 : : (void *)&cmd_lfc_set_portid,
6912 : : NULL,
6913 : : },
6914 : : };
6915 : :
6916 : : static void
6917 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6918 : : __rte_unused struct cmdline *cl,
6919 : : void *data)
6920 : : {
6921 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6922 : : cmdline_parse_inst_t *cmd = data;
6923 : : struct rte_eth_fc_conf fc_conf;
6924 : : int rx_fc_en = 0;
6925 : : int tx_fc_en = 0;
6926 : : int ret;
6927 : :
6928 : : /*
6929 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6930 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6931 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6932 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6933 : : */
6934 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6935 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6936 : : };
6937 : :
6938 : : /* Partial command line, retrieve current configuration */
6939 : 0 : if (cmd) {
6940 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6941 : 0 : if (ret != 0) {
6942 : 0 : fprintf(stderr,
6943 : : "cannot get current flow ctrl parameters, return code = %d\n",
6944 : : ret);
6945 : 0 : return;
6946 : : }
6947 : :
6948 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6949 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6950 : : rx_fc_en = 1;
6951 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6952 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6953 : : tx_fc_en = 1;
6954 : : }
6955 : :
6956 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6957 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6958 : :
6959 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6960 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6961 : :
6962 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6963 : :
6964 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6965 : 0 : fc_conf.high_water = res->high_water;
6966 : :
6967 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6968 : 0 : fc_conf.low_water = res->low_water;
6969 : :
6970 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6971 : 0 : fc_conf.pause_time = res->pause_time;
6972 : :
6973 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6974 : 0 : fc_conf.send_xon = res->send_xon;
6975 : :
6976 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6977 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6978 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6979 : : else
6980 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6981 : : }
6982 : :
6983 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6984 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6985 : :
6986 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6987 : 0 : if (ret != 0)
6988 : 0 : fprintf(stderr,
6989 : : "bad flow control parameter, return code = %d\n",
6990 : : ret);
6991 : : }
6992 : :
6993 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6994 : : struct cmd_priority_flow_ctrl_set_result {
6995 : : cmdline_fixed_string_t set;
6996 : : cmdline_fixed_string_t pfc_ctrl;
6997 : : cmdline_fixed_string_t rx;
6998 : : cmdline_fixed_string_t rx_pfc_mode;
6999 : : cmdline_fixed_string_t tx;
7000 : : cmdline_fixed_string_t tx_pfc_mode;
7001 : : uint32_t high_water;
7002 : : uint32_t low_water;
7003 : : uint16_t pause_time;
7004 : : uint8_t priority;
7005 : : portid_t port_id;
7006 : : };
7007 : :
7008 : : static void
7009 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7010 : : __rte_unused struct cmdline *cl,
7011 : : __rte_unused void *data)
7012 : : {
7013 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7014 : : struct rte_eth_pfc_conf pfc_conf;
7015 : : int rx_fc_enable, tx_fc_enable;
7016 : : int ret;
7017 : :
7018 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
7019 : 0 : return;
7020 : :
7021 : : /*
7022 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7023 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7024 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7025 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7026 : : */
7027 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7028 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7029 : : };
7030 : :
7031 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7032 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7033 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7034 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7035 : 0 : pfc_conf.fc.high_water = res->high_water;
7036 : 0 : pfc_conf.fc.low_water = res->low_water;
7037 : 0 : pfc_conf.fc.pause_time = res->pause_time;
7038 : 0 : pfc_conf.priority = res->priority;
7039 : :
7040 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7041 : 0 : if (ret != 0)
7042 : 0 : fprintf(stderr,
7043 : : "bad priority flow control parameter, return code = %d\n",
7044 : : ret);
7045 : : }
7046 : :
7047 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
7048 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7049 : : set, "set");
7050 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7051 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7052 : : pfc_ctrl, "pfc_ctrl");
7053 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
7054 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7055 : : rx, "rx");
7056 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7057 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7058 : : rx_pfc_mode, "on#off");
7059 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
7060 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7061 : : tx, "tx");
7062 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7063 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7064 : : tx_pfc_mode, "on#off");
7065 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
7066 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7067 : : high_water, RTE_UINT32);
7068 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
7069 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7070 : : low_water, RTE_UINT32);
7071 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7072 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7073 : : pause_time, RTE_UINT16);
7074 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
7075 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7076 : : priority, RTE_UINT8);
7077 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
7078 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7079 : : port_id, RTE_UINT16);
7080 : :
7081 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
7082 : : .f = cmd_priority_flow_ctrl_set_parsed,
7083 : : .data = NULL,
7084 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7085 : : "<pause_time> <priority> <port_id>: "
7086 : : "Configure the Ethernet priority flow control",
7087 : : .tokens = {
7088 : : (void *)&cmd_pfc_set_set,
7089 : : (void *)&cmd_pfc_set_flow_ctrl,
7090 : : (void *)&cmd_pfc_set_rx,
7091 : : (void *)&cmd_pfc_set_rx_mode,
7092 : : (void *)&cmd_pfc_set_tx,
7093 : : (void *)&cmd_pfc_set_tx_mode,
7094 : : (void *)&cmd_pfc_set_high_water,
7095 : : (void *)&cmd_pfc_set_low_water,
7096 : : (void *)&cmd_pfc_set_pause_time,
7097 : : (void *)&cmd_pfc_set_priority,
7098 : : (void *)&cmd_pfc_set_portid,
7099 : : NULL,
7100 : : },
7101 : : };
7102 : :
7103 : : struct cmd_queue_priority_flow_ctrl_set_result {
7104 : : cmdline_fixed_string_t set;
7105 : : cmdline_fixed_string_t pfc_queue_ctrl;
7106 : : portid_t port_id;
7107 : : cmdline_fixed_string_t rx;
7108 : : cmdline_fixed_string_t rx_pfc_mode;
7109 : : uint16_t tx_qid;
7110 : : uint8_t tx_tc;
7111 : : cmdline_fixed_string_t tx;
7112 : : cmdline_fixed_string_t tx_pfc_mode;
7113 : : uint16_t rx_qid;
7114 : : uint8_t rx_tc;
7115 : : uint16_t pause_time;
7116 : : };
7117 : :
7118 : : static void
7119 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7120 : : __rte_unused struct cmdline *cl,
7121 : : __rte_unused void *data)
7122 : : {
7123 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7124 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
7125 : : int rx_fc_enable, tx_fc_enable;
7126 : : int ret;
7127 : :
7128 : : /*
7129 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
7130 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7131 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
7132 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7133 : : * the Tx side.
7134 : : */
7135 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7136 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7137 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7138 : : };
7139 : :
7140 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7141 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7142 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7143 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7144 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
7145 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7146 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
7147 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7148 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7149 : :
7150 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7151 : : &pfc_queue_conf);
7152 : 0 : if (ret != 0) {
7153 : 0 : fprintf(stderr,
7154 : : "bad queue priority flow control parameter, rc = %d\n",
7155 : : ret);
7156 : : }
7157 : 0 : }
7158 : :
7159 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
7160 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7161 : : set, "set");
7162 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7163 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7164 : : pfc_queue_ctrl, "pfc_queue_ctrl");
7165 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7166 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7167 : : port_id, RTE_UINT16);
7168 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7169 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7170 : : rx, "rx");
7171 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7172 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7173 : : rx_pfc_mode, "on#off");
7174 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7175 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7176 : : tx_qid, RTE_UINT16);
7177 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7178 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7179 : : tx_tc, RTE_UINT8);
7180 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7181 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7182 : : tx, "tx");
7183 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7184 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7185 : : tx_pfc_mode, "on#off");
7186 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7187 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7188 : : rx_qid, RTE_UINT16);
7189 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7190 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7191 : : rx_tc, RTE_UINT8);
7192 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7193 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7194 : : pause_time, RTE_UINT16);
7195 : :
7196 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7197 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
7198 : : .data = NULL,
7199 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7200 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7201 : : "Configure the Ethernet queue priority flow control",
7202 : : .tokens = {
7203 : : (void *)&cmd_q_pfc_set_set,
7204 : : (void *)&cmd_q_pfc_set_flow_ctrl,
7205 : : (void *)&cmd_q_pfc_set_portid,
7206 : : (void *)&cmd_q_pfc_set_rx,
7207 : : (void *)&cmd_q_pfc_set_rx_mode,
7208 : : (void *)&cmd_q_pfc_set_tx_qid,
7209 : : (void *)&cmd_q_pfc_set_tx_tc,
7210 : : (void *)&cmd_q_pfc_set_tx,
7211 : : (void *)&cmd_q_pfc_set_tx_mode,
7212 : : (void *)&cmd_q_pfc_set_rx_qid,
7213 : : (void *)&cmd_q_pfc_set_rx_tc,
7214 : : (void *)&cmd_q_pfc_set_pause_time,
7215 : : NULL,
7216 : : },
7217 : : };
7218 : :
7219 : : /* *** RESET CONFIGURATION *** */
7220 : : struct cmd_reset_result {
7221 : : cmdline_fixed_string_t reset;
7222 : : cmdline_fixed_string_t def;
7223 : : };
7224 : :
7225 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
7226 : : struct cmdline *cl,
7227 : : __rte_unused void *data)
7228 : : {
7229 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7230 : 0 : set_def_fwd_config();
7231 : 0 : }
7232 : :
7233 : : static cmdline_parse_token_string_t cmd_reset_set =
7234 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7235 : : static cmdline_parse_token_string_t cmd_reset_def =
7236 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7237 : : "default");
7238 : :
7239 : : static cmdline_parse_inst_t cmd_reset = {
7240 : : .f = cmd_reset_parsed,
7241 : : .data = NULL,
7242 : : .help_str = "set default: Reset default forwarding configuration",
7243 : : .tokens = {
7244 : : (void *)&cmd_reset_set,
7245 : : (void *)&cmd_reset_def,
7246 : : NULL,
7247 : : },
7248 : : };
7249 : :
7250 : : /* *** START FORWARDING *** */
7251 : : struct cmd_start_result {
7252 : : cmdline_fixed_string_t start;
7253 : : };
7254 : :
7255 : : static cmdline_parse_token_string_t cmd_start_start =
7256 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7257 : :
7258 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
7259 : : __rte_unused struct cmdline *cl,
7260 : : __rte_unused void *data)
7261 : : {
7262 : 0 : start_packet_forwarding(0);
7263 : 0 : }
7264 : :
7265 : : static cmdline_parse_inst_t cmd_start = {
7266 : : .f = cmd_start_parsed,
7267 : : .data = NULL,
7268 : : .help_str = "start: Start packet forwarding",
7269 : : .tokens = {
7270 : : (void *)&cmd_start_start,
7271 : : NULL,
7272 : : },
7273 : : };
7274 : :
7275 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7276 : : struct cmd_start_tx_first_result {
7277 : : cmdline_fixed_string_t start;
7278 : : cmdline_fixed_string_t tx_first;
7279 : : };
7280 : :
7281 : : static void
7282 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7283 : : __rte_unused struct cmdline *cl,
7284 : : __rte_unused void *data)
7285 : : {
7286 : 0 : start_packet_forwarding(1);
7287 : 0 : }
7288 : :
7289 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
7290 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7291 : : "start");
7292 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7293 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7294 : : tx_first, "tx_first");
7295 : :
7296 : : static cmdline_parse_inst_t cmd_start_tx_first = {
7297 : : .f = cmd_start_tx_first_parsed,
7298 : : .data = NULL,
7299 : : .help_str = "start tx_first: Start packet forwarding, "
7300 : : "after sending 1 burst of packets",
7301 : : .tokens = {
7302 : : (void *)&cmd_start_tx_first_start,
7303 : : (void *)&cmd_start_tx_first_tx_first,
7304 : : NULL,
7305 : : },
7306 : : };
7307 : :
7308 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
7309 : : struct cmd_start_tx_first_n_result {
7310 : : cmdline_fixed_string_t start;
7311 : : cmdline_fixed_string_t tx_first;
7312 : : uint32_t tx_num;
7313 : : };
7314 : :
7315 : : static void
7316 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
7317 : : __rte_unused struct cmdline *cl,
7318 : : __rte_unused void *data)
7319 : : {
7320 : : struct cmd_start_tx_first_n_result *res = parsed_result;
7321 : :
7322 : 0 : start_packet_forwarding(res->tx_num);
7323 : 0 : }
7324 : :
7325 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7326 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7327 : : start, "start");
7328 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7329 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7330 : : tx_first, "tx_first");
7331 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7332 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7333 : : tx_num, RTE_UINT32);
7334 : :
7335 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
7336 : : .f = cmd_start_tx_first_n_parsed,
7337 : : .data = NULL,
7338 : : .help_str = "start tx_first <num>: "
7339 : : "packet forwarding, after sending <num> bursts of packets",
7340 : : .tokens = {
7341 : : (void *)&cmd_start_tx_first_n_start,
7342 : : (void *)&cmd_start_tx_first_n_tx_first,
7343 : : (void *)&cmd_start_tx_first_n_tx_num,
7344 : : NULL,
7345 : : },
7346 : : };
7347 : :
7348 : : /* *** SET LINK UP *** */
7349 : : struct cmd_set_link_up_result {
7350 : : cmdline_fixed_string_t set;
7351 : : cmdline_fixed_string_t link_up;
7352 : : cmdline_fixed_string_t port;
7353 : : portid_t port_id;
7354 : : };
7355 : :
7356 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
7357 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7358 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7359 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7360 : : "link-up");
7361 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
7362 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7363 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7364 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7365 : : RTE_UINT16);
7366 : :
7367 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7368 : : __rte_unused struct cmdline *cl,
7369 : : __rte_unused void *data)
7370 : : {
7371 : : struct cmd_set_link_up_result *res = parsed_result;
7372 : 0 : dev_set_link_up(res->port_id);
7373 : 0 : }
7374 : :
7375 : : static cmdline_parse_inst_t cmd_set_link_up = {
7376 : : .f = cmd_set_link_up_parsed,
7377 : : .data = NULL,
7378 : : .help_str = "set link-up port <port id>",
7379 : : .tokens = {
7380 : : (void *)&cmd_set_link_up_set,
7381 : : (void *)&cmd_set_link_up_link_up,
7382 : : (void *)&cmd_set_link_up_port,
7383 : : (void *)&cmd_set_link_up_port_id,
7384 : : NULL,
7385 : : },
7386 : : };
7387 : :
7388 : : /* *** SET LINK DOWN *** */
7389 : : struct cmd_set_link_down_result {
7390 : : cmdline_fixed_string_t set;
7391 : : cmdline_fixed_string_t link_down;
7392 : : cmdline_fixed_string_t port;
7393 : : portid_t port_id;
7394 : : };
7395 : :
7396 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
7397 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7398 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
7399 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7400 : : "link-down");
7401 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
7402 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7403 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
7404 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7405 : : RTE_UINT16);
7406 : :
7407 : 0 : static void cmd_set_link_down_parsed(
7408 : : __rte_unused void *parsed_result,
7409 : : __rte_unused struct cmdline *cl,
7410 : : __rte_unused void *data)
7411 : : {
7412 : : struct cmd_set_link_down_result *res = parsed_result;
7413 : 0 : dev_set_link_down(res->port_id);
7414 : 0 : }
7415 : :
7416 : : static cmdline_parse_inst_t cmd_set_link_down = {
7417 : : .f = cmd_set_link_down_parsed,
7418 : : .data = NULL,
7419 : : .help_str = "set link-down port <port id>",
7420 : : .tokens = {
7421 : : (void *)&cmd_set_link_down_set,
7422 : : (void *)&cmd_set_link_down_link_down,
7423 : : (void *)&cmd_set_link_down_port,
7424 : : (void *)&cmd_set_link_down_port_id,
7425 : : NULL,
7426 : : },
7427 : : };
7428 : :
7429 : : /* *** SHOW CFG *** */
7430 : : struct cmd_showcfg_result {
7431 : : cmdline_fixed_string_t show;
7432 : : cmdline_fixed_string_t cfg;
7433 : : cmdline_fixed_string_t what;
7434 : : };
7435 : :
7436 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
7437 : : __rte_unused struct cmdline *cl,
7438 : : __rte_unused void *data)
7439 : : {
7440 : : struct cmd_showcfg_result *res = parsed_result;
7441 : 0 : if (!strcmp(res->what, "rxtx"))
7442 : 0 : rxtx_config_display();
7443 : 0 : else if (!strcmp(res->what, "cores"))
7444 : 0 : fwd_lcores_config_display();
7445 : 0 : else if (!strcmp(res->what, "fwd"))
7446 : 0 : pkt_fwd_config_display(&cur_fwd_config);
7447 : 0 : else if (!strcmp(res->what, "rxoffs"))
7448 : 0 : show_rx_pkt_offsets();
7449 : 0 : else if (!strcmp(res->what, "rxpkts"))
7450 : 0 : show_rx_pkt_segments();
7451 : 0 : else if (!strcmp(res->what, "rxhdrs"))
7452 : 0 : show_rx_pkt_hdrs();
7453 : 0 : else if (!strcmp(res->what, "txpkts"))
7454 : 0 : show_tx_pkt_segments();
7455 : 0 : else if (!strcmp(res->what, "txtimes"))
7456 : 0 : show_tx_pkt_times();
7457 : 0 : else if (!strcmp(res->what, "dcbfwdtc"))
7458 : 0 : show_dcb_fwd_tc_config();
7459 : 0 : }
7460 : :
7461 : : static cmdline_parse_token_string_t cmd_showcfg_show =
7462 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7463 : : static cmdline_parse_token_string_t cmd_showcfg_port =
7464 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7465 : : static cmdline_parse_token_string_t cmd_showcfg_what =
7466 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7467 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes#dcbfwdtc");
7468 : :
7469 : : static cmdline_parse_inst_t cmd_showcfg = {
7470 : : .f = cmd_showcfg_parsed,
7471 : : .data = NULL,
7472 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes|dcbfwdtc",
7473 : : .tokens = {
7474 : : (void *)&cmd_showcfg_show,
7475 : : (void *)&cmd_showcfg_port,
7476 : : (void *)&cmd_showcfg_what,
7477 : : NULL,
7478 : : },
7479 : : };
7480 : :
7481 : : /* *** SHOW ALL PORT INFO *** */
7482 : : struct cmd_showportall_result {
7483 : : cmdline_fixed_string_t show;
7484 : : cmdline_fixed_string_t port;
7485 : : cmdline_fixed_string_t what;
7486 : : cmdline_fixed_string_t all;
7487 : : };
7488 : :
7489 : 0 : static void cmd_showportall_parsed(void *parsed_result,
7490 : : __rte_unused struct cmdline *cl,
7491 : : __rte_unused void *data)
7492 : : {
7493 : : portid_t i;
7494 : :
7495 : : struct cmd_showportall_result *res = parsed_result;
7496 : 0 : if (!strcmp(res->show, "clear")) {
7497 : 0 : if (!strcmp(res->what, "stats"))
7498 : 0 : RTE_ETH_FOREACH_DEV(i)
7499 : 0 : nic_stats_clear(i);
7500 : 0 : else if (!strcmp(res->what, "xstats"))
7501 : 0 : RTE_ETH_FOREACH_DEV(i)
7502 : 0 : nic_xstats_clear(i);
7503 : 0 : } else if (!strcmp(res->what, "info"))
7504 : 0 : RTE_ETH_FOREACH_DEV(i)
7505 : 0 : port_infos_display(i);
7506 : 0 : else if (!strcmp(res->what, "summary")) {
7507 : 0 : port_summary_header_display();
7508 : 0 : RTE_ETH_FOREACH_DEV(i)
7509 : 0 : port_summary_display(i);
7510 : : }
7511 : 0 : else if (!strcmp(res->what, "stats"))
7512 : 0 : RTE_ETH_FOREACH_DEV(i)
7513 : 0 : nic_stats_display(i);
7514 : 0 : else if (!strcmp(res->what, "xstats"))
7515 : 0 : RTE_ETH_FOREACH_DEV(i)
7516 : 0 : nic_xstats_display(i);
7517 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7518 : 0 : else if (!strcmp(res->what, "fdir"))
7519 : 0 : RTE_ETH_FOREACH_DEV(i)
7520 : 0 : fdir_get_infos(i);
7521 : : #endif
7522 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7523 : 0 : RTE_ETH_FOREACH_DEV(i)
7524 : 0 : port_dcb_info_display(i);
7525 : 0 : }
7526 : :
7527 : : static cmdline_parse_token_string_t cmd_showportall_show =
7528 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7529 : : "show#clear");
7530 : : static cmdline_parse_token_string_t cmd_showportall_port =
7531 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7532 : : static cmdline_parse_token_string_t cmd_showportall_what =
7533 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7534 : : "info#summary#stats#xstats#fdir#dcb_tc");
7535 : : static cmdline_parse_token_string_t cmd_showportall_all =
7536 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7537 : : static cmdline_parse_inst_t cmd_showportall = {
7538 : : .f = cmd_showportall_parsed,
7539 : : .data = NULL,
7540 : : .help_str = "show|clear port "
7541 : : "info|summary|stats|xstats|fdir|dcb_tc all",
7542 : : .tokens = {
7543 : : (void *)&cmd_showportall_show,
7544 : : (void *)&cmd_showportall_port,
7545 : : (void *)&cmd_showportall_what,
7546 : : (void *)&cmd_showportall_all,
7547 : : NULL,
7548 : : },
7549 : : };
7550 : :
7551 : : /* *** SHOW PORT INFO *** */
7552 : : struct cmd_showport_result {
7553 : : cmdline_fixed_string_t show;
7554 : : cmdline_fixed_string_t port;
7555 : : cmdline_fixed_string_t what;
7556 : : uint16_t portnum;
7557 : : };
7558 : :
7559 : 0 : static void cmd_showport_parsed(void *parsed_result,
7560 : : __rte_unused struct cmdline *cl,
7561 : : __rte_unused void *data)
7562 : : {
7563 : : struct cmd_showport_result *res = parsed_result;
7564 : 0 : if (!strcmp(res->show, "clear")) {
7565 : 0 : if (!strcmp(res->what, "stats"))
7566 : 0 : nic_stats_clear(res->portnum);
7567 : 0 : else if (!strcmp(res->what, "xstats"))
7568 : 0 : nic_xstats_clear(res->portnum);
7569 : 0 : } else if (!strcmp(res->what, "info"))
7570 : 0 : port_infos_display(res->portnum);
7571 : 0 : else if (!strcmp(res->what, "summary")) {
7572 : 0 : port_summary_header_display();
7573 : 0 : port_summary_display(res->portnum);
7574 : : }
7575 : 0 : else if (!strcmp(res->what, "stats"))
7576 : 0 : nic_stats_display(res->portnum);
7577 : 0 : else if (!strcmp(res->what, "xstats"))
7578 : 0 : nic_xstats_display(res->portnum);
7579 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7580 : 0 : else if (!strcmp(res->what, "fdir"))
7581 : 0 : fdir_get_infos(res->portnum);
7582 : : #endif
7583 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7584 : 0 : port_dcb_info_display(res->portnum);
7585 : 0 : }
7586 : :
7587 : : static cmdline_parse_token_string_t cmd_showport_show =
7588 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7589 : : "show#clear");
7590 : : static cmdline_parse_token_string_t cmd_showport_port =
7591 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7592 : : static cmdline_parse_token_string_t cmd_showport_what =
7593 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7594 : : "info#summary#stats#xstats#fdir#dcb_tc");
7595 : : static cmdline_parse_token_num_t cmd_showport_portnum =
7596 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7597 : :
7598 : : static cmdline_parse_inst_t cmd_showport = {
7599 : : .f = cmd_showport_parsed,
7600 : : .data = NULL,
7601 : : .help_str = "show|clear port "
7602 : : "info|summary|stats|xstats|fdir|dcb_tc "
7603 : : "<port_id>",
7604 : : .tokens = {
7605 : : (void *)&cmd_showport_show,
7606 : : (void *)&cmd_showport_port,
7607 : : (void *)&cmd_showport_what,
7608 : : (void *)&cmd_showport_portnum,
7609 : : NULL,
7610 : : },
7611 : : };
7612 : :
7613 : : /* *** show port representors information *** */
7614 : : struct cmd_representor_info_result {
7615 : : cmdline_fixed_string_t cmd_show;
7616 : : cmdline_fixed_string_t cmd_port;
7617 : : cmdline_fixed_string_t cmd_info;
7618 : : cmdline_fixed_string_t cmd_keyword;
7619 : : portid_t cmd_pid;
7620 : : };
7621 : :
7622 : : static void
7623 : 0 : cmd_representor_info_parsed(void *parsed_result,
7624 : : __rte_unused struct cmdline *cl,
7625 : : __rte_unused void *data)
7626 : : {
7627 : : struct cmd_representor_info_result *res = parsed_result;
7628 : : struct rte_eth_representor_info *info;
7629 : : struct rte_eth_representor_range *range;
7630 : : uint32_t range_diff;
7631 : : uint32_t i;
7632 : : int ret;
7633 : : int num;
7634 : :
7635 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7636 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7637 : 0 : return;
7638 : : }
7639 : :
7640 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7641 : 0 : if (ret < 0) {
7642 : 0 : fprintf(stderr,
7643 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7644 : 0 : res->cmd_pid, rte_strerror(-ret));
7645 : 0 : return;
7646 : : }
7647 : : num = ret;
7648 : :
7649 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7650 : 0 : if (info == NULL) {
7651 : 0 : fprintf(stderr,
7652 : : "Failed to allocate memory for representor info for port %hu\n",
7653 : 0 : res->cmd_pid);
7654 : 0 : return;
7655 : : }
7656 : 0 : info->nb_ranges_alloc = num;
7657 : :
7658 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7659 : 0 : if (ret < 0) {
7660 : 0 : fprintf(stderr,
7661 : : "Failed to get the representor info for port %hu: %s\n",
7662 : 0 : res->cmd_pid, rte_strerror(-ret));
7663 : 0 : free(info);
7664 : 0 : return;
7665 : : }
7666 : :
7667 : 0 : printf("Port controller: %hu\n", info->controller);
7668 : 0 : printf("Port PF: %hu\n", info->pf);
7669 : :
7670 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7671 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7672 : : range = &info->ranges[i];
7673 : 0 : range_diff = range->id_end - range->id_base;
7674 : :
7675 : 0 : printf("%u. ", i + 1);
7676 : 0 : printf("'%s' ", range->name);
7677 : 0 : if (range_diff > 0)
7678 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7679 : : else
7680 : 0 : printf("[%u]: ", range->id_base);
7681 : :
7682 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7683 : :
7684 : 0 : switch (range->type) {
7685 : : case RTE_ETH_REPRESENTOR_NONE:
7686 : : printf(", NONE\n");
7687 : : break;
7688 : 0 : case RTE_ETH_REPRESENTOR_VF:
7689 : 0 : if (range_diff > 0)
7690 : 0 : printf(", VF %d..%d\n", range->vf,
7691 : 0 : range->vf + range_diff);
7692 : : else
7693 : 0 : printf(", VF %d\n", range->vf);
7694 : : break;
7695 : 0 : case RTE_ETH_REPRESENTOR_SF:
7696 : 0 : printf(", SF %d\n", range->sf);
7697 : : break;
7698 : 0 : case RTE_ETH_REPRESENTOR_PF:
7699 : 0 : if (range_diff > 0)
7700 : 0 : printf("..%d\n", range->pf + range_diff);
7701 : : else
7702 : : printf("\n");
7703 : : break;
7704 : 0 : default:
7705 : : printf(", UNKNOWN TYPE %d\n", range->type);
7706 : : break;
7707 : : }
7708 : : }
7709 : :
7710 : 0 : free(info);
7711 : : }
7712 : :
7713 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7714 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7715 : : cmd_show, "show");
7716 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7717 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7718 : : cmd_port, "port");
7719 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7720 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7721 : : cmd_info, "info");
7722 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7723 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7724 : : cmd_pid, RTE_UINT16);
7725 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7726 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7727 : : cmd_keyword, "representor");
7728 : :
7729 : : static cmdline_parse_inst_t cmd_representor_info = {
7730 : : .f = cmd_representor_info_parsed,
7731 : : .data = NULL,
7732 : : .help_str = "show port info <port_id> representor",
7733 : : .tokens = {
7734 : : (void *)&cmd_representor_info_show,
7735 : : (void *)&cmd_representor_info_port,
7736 : : (void *)&cmd_representor_info_info,
7737 : : (void *)&cmd_representor_info_pid,
7738 : : (void *)&cmd_representor_info_keyword,
7739 : : NULL,
7740 : : },
7741 : : };
7742 : :
7743 : :
7744 : : /* *** SHOW DEVICE INFO *** */
7745 : : struct cmd_showdevice_result {
7746 : : cmdline_fixed_string_t show;
7747 : : cmdline_fixed_string_t device;
7748 : : cmdline_fixed_string_t what;
7749 : : cmdline_fixed_string_t identifier;
7750 : : };
7751 : :
7752 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7753 : : __rte_unused struct cmdline *cl,
7754 : : __rte_unused void *data)
7755 : : {
7756 : : struct cmd_showdevice_result *res = parsed_result;
7757 : 0 : if (!strcmp(res->what, "info")) {
7758 : 0 : if (!strcmp(res->identifier, "all"))
7759 : 0 : device_infos_display(NULL);
7760 : : else
7761 : 0 : device_infos_display(res->identifier);
7762 : : }
7763 : 0 : }
7764 : :
7765 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7766 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7767 : : "show");
7768 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7769 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7770 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7771 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7772 : : "info");
7773 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7774 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7775 : : identifier, NULL);
7776 : :
7777 : : static cmdline_parse_inst_t cmd_showdevice = {
7778 : : .f = cmd_showdevice_parsed,
7779 : : .data = NULL,
7780 : : .help_str = "show device info <identifier>|all",
7781 : : .tokens = {
7782 : : (void *)&cmd_showdevice_show,
7783 : : (void *)&cmd_showdevice_device,
7784 : : (void *)&cmd_showdevice_what,
7785 : : (void *)&cmd_showdevice_identifier,
7786 : : NULL,
7787 : : },
7788 : : };
7789 : :
7790 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7791 : : struct cmd_showeeprom_result {
7792 : : cmdline_fixed_string_t show;
7793 : : cmdline_fixed_string_t port;
7794 : : uint16_t portnum;
7795 : : cmdline_fixed_string_t type;
7796 : : };
7797 : :
7798 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7799 : : __rte_unused struct cmdline *cl,
7800 : : __rte_unused void *data)
7801 : : {
7802 : : struct cmd_showeeprom_result *res = parsed_result;
7803 : :
7804 : 0 : if (!strcmp(res->type, "eeprom"))
7805 : 0 : port_eeprom_display(res->portnum);
7806 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7807 : 0 : port_module_eeprom_display(res->portnum);
7808 : : else
7809 : 0 : fprintf(stderr, "Unknown argument\n");
7810 : 0 : }
7811 : :
7812 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7813 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7814 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7815 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7816 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7817 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7818 : : RTE_UINT16);
7819 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7820 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7821 : :
7822 : : static cmdline_parse_inst_t cmd_showeeprom = {
7823 : : .f = cmd_showeeprom_parsed,
7824 : : .data = NULL,
7825 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7826 : : .tokens = {
7827 : : (void *)&cmd_showeeprom_show,
7828 : : (void *)&cmd_showeeprom_port,
7829 : : (void *)&cmd_showeeprom_portnum,
7830 : : (void *)&cmd_showeeprom_type,
7831 : : NULL,
7832 : : },
7833 : : };
7834 : :
7835 : : /* *** SET PORT EEPROM *** */
7836 : : struct cmd_seteeprom_result {
7837 : : cmdline_fixed_string_t set;
7838 : : cmdline_fixed_string_t port;
7839 : : uint16_t portnum;
7840 : : cmdline_fixed_string_t eeprom;
7841 : : cmdline_fixed_string_t confirm_str;
7842 : : cmdline_fixed_string_t magic_str;
7843 : : uint32_t magic;
7844 : : cmdline_fixed_string_t value;
7845 : : cmdline_multi_string_t token_str;
7846 : : };
7847 : :
7848 : 0 : static void cmd_seteeprom_parsed(void *parsed_result,
7849 : : __rte_unused struct cmdline *cl,
7850 : : __rte_unused void *data)
7851 : : {
7852 : : struct cmd_seteeprom_result *res = parsed_result;
7853 : : uint32_t offset = 0;
7854 : : uint32_t length;
7855 : : uint8_t *value;
7856 : : char *token_str;
7857 : : char *token;
7858 : :
7859 : 0 : token_str = res->token_str;
7860 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7861 : :
7862 : : /* Parse Hex string to Byte data */
7863 : 0 : if (strlen(token) % 2 != 0) {
7864 : 0 : fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
7865 : : token);
7866 : 0 : return;
7867 : : }
7868 : :
7869 : 0 : length = strlen(token) / 2;
7870 : 0 : value = calloc(length, sizeof(uint8_t));
7871 : 0 : for (int count = 0; count < (int)(length); count++) {
7872 : 0 : if (sscanf(token, "%2hhx", &value[count]) != 1) {
7873 : 0 : fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
7874 : 0 : token - (count + 1));
7875 : 0 : goto out;
7876 : : }
7877 : 0 : token += 2;
7878 : : }
7879 : :
7880 : : /* Second token: offset string */
7881 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7882 : 0 : if (token != NULL) {
7883 : 0 : if (strcmp(token, "offset") == 0) {
7884 : : /* Third token: offset */
7885 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7886 : 0 : if (token == NULL) {
7887 : 0 : fprintf(stderr, "No offset specified\n");
7888 : 0 : goto out;
7889 : : }
7890 : :
7891 : : char *end;
7892 : 0 : offset = strtoul(token, &end, 10);
7893 : 0 : if (offset == 0 && strcmp(end, "") != 0) {
7894 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7895 : 0 : goto out;
7896 : : }
7897 : : } else {
7898 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7899 : 0 : goto out;
7900 : : }
7901 : : }
7902 : :
7903 : 0 : port_eeprom_set(res->portnum, res->magic, offset, length, value);
7904 : :
7905 : 0 : out:
7906 : 0 : free(value);
7907 : : }
7908 : :
7909 : : static cmdline_parse_token_string_t cmd_seteeprom_set =
7910 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
7911 : : static cmdline_parse_token_string_t cmd_seteeprom_port =
7912 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
7913 : : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
7914 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
7915 : : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
7916 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
7917 : : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
7918 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
7919 : : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
7920 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
7921 : : static cmdline_parse_token_num_t cmd_seteeprom_magic =
7922 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
7923 : : static cmdline_parse_token_string_t cmd_seteeprom_value =
7924 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
7925 : : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
7926 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
7927 : :
7928 : : static cmdline_parse_inst_t cmd_seteeprom = {
7929 : : .f = cmd_seteeprom_parsed,
7930 : : .data = NULL,
7931 : : .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
7932 : : "value <value> offset <offset>: Set eeprom value for port_id.\n"
7933 : : "Note:\n"
7934 : : "This is a high-risk command and its misuse may result in "
7935 : : "unexpected behaviour from the NIC.\n"
7936 : : "By inserting \"accept_risk\" into the command, the user is "
7937 : : "acknowledging and taking responsibility for this risk.",
7938 : : .tokens = {
7939 : : (void *)&cmd_seteeprom_set,
7940 : : (void *)&cmd_seteeprom_port,
7941 : : (void *)&cmd_seteeprom_portnum,
7942 : : (void *)&cmd_seteeprom_eeprom,
7943 : : (void *)&cmd_seteeprom_confirm_str,
7944 : : (void *)&cmd_seteeprom_magic_str,
7945 : : (void *)&cmd_seteeprom_magic,
7946 : : (void *)&cmd_seteeprom_value,
7947 : : (void *)&cmd_seteeprom_token_str,
7948 : : NULL,
7949 : : },
7950 : : };
7951 : :
7952 : : /* *** SHOW QUEUE INFO *** */
7953 : : struct cmd_showqueue_result {
7954 : : cmdline_fixed_string_t show;
7955 : : cmdline_fixed_string_t type;
7956 : : cmdline_fixed_string_t what;
7957 : : uint16_t portnum;
7958 : : uint16_t queuenum;
7959 : : };
7960 : :
7961 : : static void
7962 : 0 : cmd_showqueue_parsed(void *parsed_result,
7963 : : __rte_unused struct cmdline *cl,
7964 : : __rte_unused void *data)
7965 : : {
7966 : : struct cmd_showqueue_result *res = parsed_result;
7967 : :
7968 : 0 : if (!strcmp(res->type, "rxq"))
7969 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7970 : 0 : else if (!strcmp(res->type, "txq"))
7971 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7972 : 0 : }
7973 : :
7974 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7975 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7976 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7977 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7978 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7979 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7980 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7981 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7982 : : RTE_UINT16);
7983 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7984 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7985 : : RTE_UINT16);
7986 : :
7987 : : static cmdline_parse_inst_t cmd_showqueue = {
7988 : : .f = cmd_showqueue_parsed,
7989 : : .data = NULL,
7990 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7991 : : .tokens = {
7992 : : (void *)&cmd_showqueue_show,
7993 : : (void *)&cmd_showqueue_type,
7994 : : (void *)&cmd_showqueue_what,
7995 : : (void *)&cmd_showqueue_portnum,
7996 : : (void *)&cmd_showqueue_queuenum,
7997 : : NULL,
7998 : : },
7999 : : };
8000 : :
8001 : : /* show/clear fwd engine statistics */
8002 : : struct fwd_result {
8003 : : cmdline_fixed_string_t action;
8004 : : cmdline_fixed_string_t fwd;
8005 : : cmdline_fixed_string_t stats;
8006 : : cmdline_fixed_string_t all;
8007 : : };
8008 : :
8009 : : static cmdline_parse_token_string_t cmd_fwd_action =
8010 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8011 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
8012 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8013 : : static cmdline_parse_token_string_t cmd_fwd_stats =
8014 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8015 : : static cmdline_parse_token_string_t cmd_fwd_all =
8016 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8017 : :
8018 : : static void
8019 : 0 : cmd_showfwdall_parsed(void *parsed_result,
8020 : : __rte_unused struct cmdline *cl,
8021 : : __rte_unused void *data)
8022 : : {
8023 : : struct fwd_result *res = parsed_result;
8024 : :
8025 : 0 : if (!strcmp(res->action, "show"))
8026 : 0 : fwd_stats_display();
8027 : : else
8028 : 0 : fwd_stats_reset();
8029 : 0 : }
8030 : :
8031 : : static cmdline_parse_inst_t cmd_showfwdall = {
8032 : : .f = cmd_showfwdall_parsed,
8033 : : .data = NULL,
8034 : : .help_str = "show|clear fwd stats all",
8035 : : .tokens = {
8036 : : (void *)&cmd_fwd_action,
8037 : : (void *)&cmd_fwd_fwd,
8038 : : (void *)&cmd_fwd_stats,
8039 : : (void *)&cmd_fwd_all,
8040 : : NULL,
8041 : : },
8042 : : };
8043 : :
8044 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8045 : : struct cmd_read_rxd_txd_result {
8046 : : cmdline_fixed_string_t read;
8047 : : cmdline_fixed_string_t rxd_txd;
8048 : : portid_t port_id;
8049 : : uint16_t queue_id;
8050 : : uint16_t desc_id;
8051 : : };
8052 : :
8053 : : static void
8054 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
8055 : : __rte_unused struct cmdline *cl,
8056 : : __rte_unused void *data)
8057 : : {
8058 : : struct cmd_read_rxd_txd_result *res = parsed_result;
8059 : :
8060 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
8061 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8062 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
8063 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8064 : 0 : }
8065 : :
8066 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8067 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8068 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8069 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8070 : : "rxd#txd");
8071 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8072 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8073 : : RTE_UINT16);
8074 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8075 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8076 : : RTE_UINT16);
8077 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8078 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8079 : : RTE_UINT16);
8080 : :
8081 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
8082 : : .f = cmd_read_rxd_txd_parsed,
8083 : : .data = NULL,
8084 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8085 : : .tokens = {
8086 : : (void *)&cmd_read_rxd_txd_read,
8087 : : (void *)&cmd_read_rxd_txd_rxd_txd,
8088 : : (void *)&cmd_read_rxd_txd_port_id,
8089 : : (void *)&cmd_read_rxd_txd_queue_id,
8090 : : (void *)&cmd_read_rxd_txd_desc_id,
8091 : : NULL,
8092 : : },
8093 : : };
8094 : :
8095 : : /* *** QUIT *** */
8096 : : struct cmd_quit_result {
8097 : : cmdline_fixed_string_t quit;
8098 : : };
8099 : :
8100 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
8101 : : struct cmdline *cl,
8102 : : __rte_unused void *data)
8103 : : {
8104 : 0 : cmdline_quit(cl);
8105 : 0 : cl_quit = 1;
8106 : 0 : }
8107 : :
8108 : : static cmdline_parse_token_string_t cmd_quit_quit =
8109 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8110 : :
8111 : : static cmdline_parse_inst_t cmd_quit = {
8112 : : .f = cmd_quit_parsed,
8113 : : .data = NULL,
8114 : : .help_str = "quit: Exit application",
8115 : : .tokens = {
8116 : : (void *)&cmd_quit_quit,
8117 : : NULL,
8118 : : },
8119 : : };
8120 : :
8121 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8122 : : struct cmd_mac_addr_result {
8123 : : cmdline_fixed_string_t mac_addr_cmd;
8124 : : cmdline_fixed_string_t what;
8125 : : uint16_t port_num;
8126 : : struct rte_ether_addr address;
8127 : : };
8128 : :
8129 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
8130 : : __rte_unused struct cmdline *cl,
8131 : : __rte_unused void *data)
8132 : : {
8133 : : struct cmd_mac_addr_result *res = parsed_result;
8134 : : int ret;
8135 : :
8136 : 0 : if (strcmp(res->what, "add") == 0)
8137 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8138 : 0 : else if (strcmp(res->what, "set") == 0)
8139 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8140 : : &res->address);
8141 : : else
8142 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8143 : :
8144 : : /* check the return value and print it if is < 0 */
8145 : 0 : if(ret < 0)
8146 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8147 : :
8148 : 0 : }
8149 : :
8150 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
8151 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8152 : : "mac_addr");
8153 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
8154 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8155 : : "add#remove#set");
8156 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
8157 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8158 : : RTE_UINT16);
8159 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8160 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8161 : :
8162 : : static cmdline_parse_inst_t cmd_mac_addr = {
8163 : : .f = cmd_mac_addr_parsed,
8164 : : .data = (void *)0,
8165 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8166 : : "Add/Remove/Set MAC address on port_id",
8167 : : .tokens = {
8168 : : (void *)&cmd_mac_addr_cmd,
8169 : : (void *)&cmd_mac_addr_what,
8170 : : (void *)&cmd_mac_addr_portnum,
8171 : : (void *)&cmd_mac_addr_addr,
8172 : : NULL,
8173 : : },
8174 : : };
8175 : :
8176 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8177 : : struct cmd_eth_peer_result {
8178 : : cmdline_fixed_string_t set;
8179 : : cmdline_fixed_string_t eth_peer;
8180 : : portid_t port_id;
8181 : : cmdline_fixed_string_t peer_addr;
8182 : : };
8183 : :
8184 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
8185 : : __rte_unused struct cmdline *cl,
8186 : : __rte_unused void *data)
8187 : : {
8188 : : struct cmd_eth_peer_result *res = parsed_result;
8189 : :
8190 : 0 : if (test_done == 0) {
8191 : 0 : fprintf(stderr, "Please stop forwarding first\n");
8192 : 0 : return;
8193 : : }
8194 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
8195 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
8196 : 0 : fwd_config_setup();
8197 : : }
8198 : : }
8199 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
8200 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8201 : : static cmdline_parse_token_string_t cmd_eth_peer =
8202 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8203 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
8204 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8205 : : RTE_UINT16);
8206 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
8207 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8208 : :
8209 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8210 : : .f = cmd_set_eth_peer_parsed,
8211 : : .data = NULL,
8212 : : .help_str = "set eth-peer <port_id> <peer_mac>",
8213 : : .tokens = {
8214 : : (void *)&cmd_eth_peer_set,
8215 : : (void *)&cmd_eth_peer,
8216 : : (void *)&cmd_eth_peer_port_id,
8217 : : (void *)&cmd_eth_peer_addr,
8218 : : NULL,
8219 : : },
8220 : : };
8221 : :
8222 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8223 : : struct cmd_set_xstats_hide_zero_result {
8224 : : cmdline_fixed_string_t keyword;
8225 : : cmdline_fixed_string_t name;
8226 : : cmdline_fixed_string_t on_off;
8227 : : };
8228 : :
8229 : : static void
8230 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8231 : : __rte_unused struct cmdline *cl,
8232 : : __rte_unused void *data)
8233 : : {
8234 : : struct cmd_set_xstats_hide_zero_result *res;
8235 : : uint16_t on_off = 0;
8236 : :
8237 : : res = parsed_result;
8238 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8239 : 0 : set_xstats_hide_zero(on_off);
8240 : 0 : }
8241 : :
8242 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8243 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8244 : : keyword, "set");
8245 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8246 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8247 : : name, "xstats-hide-zero");
8248 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8249 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8250 : : on_off, "on#off");
8251 : :
8252 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8253 : : .f = cmd_set_xstats_hide_zero_parsed,
8254 : : .data = NULL,
8255 : : .help_str = "set xstats-hide-zero on|off",
8256 : : .tokens = {
8257 : : (void *)&cmd_set_xstats_hide_zero_keyword,
8258 : : (void *)&cmd_set_xstats_hide_zero_name,
8259 : : (void *)&cmd_set_xstats_hide_zero_on_off,
8260 : : NULL,
8261 : : },
8262 : : };
8263 : :
8264 : : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
8265 : : struct cmd_set_xstats_show_state_result {
8266 : : cmdline_fixed_string_t keyword;
8267 : : cmdline_fixed_string_t name;
8268 : : uint8_t on_off;
8269 : : };
8270 : : static void
8271 : 0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
8272 : : __rte_unused struct cmdline *cl,
8273 : : __rte_unused void *data)
8274 : : {
8275 : : struct cmd_set_xstats_show_state_result *res = parsed_result;
8276 : 0 : set_xstats_show_state(res->on_off);
8277 : 0 : }
8278 : :
8279 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
8280 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8281 : : keyword, "set");
8282 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
8283 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8284 : : name, "xstats-show-state");
8285 : : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
8286 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
8287 : : on_off);
8288 : :
8289 : : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
8290 : : .f = cmd_set_xstats_show_state_parsed,
8291 : : .data = NULL,
8292 : : .help_str = "set xstats-show-state on|off",
8293 : : .tokens = {
8294 : : (void *)&cmd_set_xstats_show_state_keyword,
8295 : : (void *)&cmd_set_xstats_show_state_name,
8296 : : (void *)&cmd_set_xstats_show_state_on_off,
8297 : : NULL,
8298 : : },
8299 : : };
8300 : :
8301 : : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
8302 : : struct cmd_set_xstats_hide_disabled_result {
8303 : : cmdline_fixed_string_t keyword;
8304 : : cmdline_fixed_string_t name;
8305 : : uint8_t on_off;
8306 : : };
8307 : :
8308 : : static void
8309 : 0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
8310 : : __rte_unused struct cmdline *cl,
8311 : : __rte_unused void *data)
8312 : : {
8313 : : struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
8314 : 0 : set_xstats_hide_disabled(res->on_off);
8315 : 0 : }
8316 : :
8317 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
8318 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8319 : : keyword, "set");
8320 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
8321 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8322 : : name, "xstats-hide-disabled");
8323 : : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
8324 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8325 : : on_off);
8326 : :
8327 : : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
8328 : : .f = cmd_set_xstats_hide_disabled_parsed,
8329 : : .data = NULL,
8330 : : .help_str = "set xstats-hide-disabled on|off",
8331 : : .tokens = {
8332 : : (void *)&cmd_set_xstats_hide_disabled_keyword,
8333 : : (void *)&cmd_set_xstats_hide_disabled_name,
8334 : : (void *)&cmd_set_xstats_hide_disabled_on_off,
8335 : : NULL,
8336 : : },
8337 : : };
8338 : :
8339 : : /* *** enable/disable counter by name *** */
8340 : : struct cmd_operate_set_counter_result {
8341 : : cmdline_fixed_string_t port;
8342 : : portid_t port_id;
8343 : : cmdline_fixed_string_t what;
8344 : : cmdline_multi_string_t counter_name;
8345 : : };
8346 : :
8347 : : static void
8348 : 0 : cmd_operate_set_counter_parsed(void *parsed_result,
8349 : : __rte_unused struct cmdline *cl,
8350 : : __rte_unused void *data)
8351 : : {
8352 : : struct cmd_operate_set_counter_result *res = parsed_result;
8353 : 0 : uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
8354 : :
8355 : 0 : if ((strcmp(res->port, "port") == 0))
8356 : 0 : nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
8357 : 0 : }
8358 : :
8359 : : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
8360 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8361 : : port, "port");
8362 : : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
8363 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
8364 : : port_id, RTE_UINT16);
8365 : : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
8366 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8367 : : what, "enable#disable");
8368 : : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
8369 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8370 : : counter_name, TOKEN_STRING_MULTI);
8371 : :
8372 : : static cmdline_parse_inst_t cmd_operate_set_counter = {
8373 : : .f = cmd_operate_set_counter_parsed,
8374 : : .data = NULL,
8375 : : .help_str = "port (port_id) enable|disable <counter_name>",
8376 : : .tokens = {
8377 : : (void *)&cmd_operate_set_counter_port,
8378 : : (void *)&cmd_operate_set_counter_port_id,
8379 : : (void *)&cmd_operate_set_counter_what,
8380 : : (void *)&cmd_operate_set_counter_name,
8381 : : NULL,
8382 : : },
8383 : : };
8384 : :
8385 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8386 : : struct cmd_set_record_core_cycles_result {
8387 : : cmdline_fixed_string_t keyword;
8388 : : cmdline_fixed_string_t name;
8389 : : cmdline_fixed_string_t on_off;
8390 : : };
8391 : :
8392 : : static void
8393 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
8394 : : __rte_unused struct cmdline *cl,
8395 : : __rte_unused void *data)
8396 : : {
8397 : : struct cmd_set_record_core_cycles_result *res;
8398 : : uint16_t on_off = 0;
8399 : :
8400 : : res = parsed_result;
8401 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8402 : 0 : set_record_core_cycles(on_off);
8403 : 0 : }
8404 : :
8405 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8406 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8407 : : keyword, "set");
8408 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8409 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8410 : : name, "record-core-cycles");
8411 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8412 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8413 : : on_off, "on#off");
8414 : :
8415 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
8416 : : .f = cmd_set_record_core_cycles_parsed,
8417 : : .data = NULL,
8418 : : .help_str = "set record-core-cycles on|off",
8419 : : .tokens = {
8420 : : (void *)&cmd_set_record_core_cycles_keyword,
8421 : : (void *)&cmd_set_record_core_cycles_name,
8422 : : (void *)&cmd_set_record_core_cycles_on_off,
8423 : : NULL,
8424 : : },
8425 : : };
8426 : :
8427 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8428 : : struct cmd_set_record_burst_stats_result {
8429 : : cmdline_fixed_string_t keyword;
8430 : : cmdline_fixed_string_t name;
8431 : : cmdline_fixed_string_t on_off;
8432 : : };
8433 : :
8434 : : static void
8435 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
8436 : : __rte_unused struct cmdline *cl,
8437 : : __rte_unused void *data)
8438 : : {
8439 : : struct cmd_set_record_burst_stats_result *res;
8440 : : uint16_t on_off = 0;
8441 : :
8442 : : res = parsed_result;
8443 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8444 : 0 : set_record_burst_stats(on_off);
8445 : 0 : }
8446 : :
8447 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8448 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8449 : : keyword, "set");
8450 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8451 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8452 : : name, "record-burst-stats");
8453 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8454 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8455 : : on_off, "on#off");
8456 : :
8457 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
8458 : : .f = cmd_set_record_burst_stats_parsed,
8459 : : .data = NULL,
8460 : : .help_str = "set record-burst-stats on|off",
8461 : : .tokens = {
8462 : : (void *)&cmd_set_record_burst_stats_keyword,
8463 : : (void *)&cmd_set_record_burst_stats_name,
8464 : : (void *)&cmd_set_record_burst_stats_on_off,
8465 : : NULL,
8466 : : },
8467 : : };
8468 : :
8469 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
8470 : : struct cmd_set_uc_hash_table {
8471 : : cmdline_fixed_string_t set;
8472 : : cmdline_fixed_string_t port;
8473 : : portid_t port_id;
8474 : : cmdline_fixed_string_t what;
8475 : : struct rte_ether_addr address;
8476 : : cmdline_fixed_string_t mode;
8477 : : };
8478 : :
8479 : : static void
8480 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
8481 : : __rte_unused struct cmdline *cl,
8482 : : __rte_unused void *data)
8483 : : {
8484 : : int ret=0;
8485 : : struct cmd_set_uc_hash_table *res = parsed_result;
8486 : :
8487 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8488 : :
8489 : 0 : if (strcmp(res->what, "uta") == 0)
8490 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8491 : : &res->address,(uint8_t)is_on);
8492 : 0 : if (ret < 0)
8493 : 0 : fprintf(stderr,
8494 : : "bad unicast hash table parameter, return code = %d\n",
8495 : : ret);
8496 : :
8497 : 0 : }
8498 : :
8499 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
8500 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8501 : : set, "set");
8502 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
8503 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8504 : : port, "port");
8505 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8506 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8507 : : port_id, RTE_UINT16);
8508 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
8509 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8510 : : what, "uta");
8511 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8512 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8513 : : address);
8514 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8515 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8516 : : mode, "on#off");
8517 : :
8518 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8519 : : .f = cmd_set_uc_hash_parsed,
8520 : : .data = NULL,
8521 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
8522 : : .tokens = {
8523 : : (void *)&cmd_set_uc_hash_set,
8524 : : (void *)&cmd_set_uc_hash_port,
8525 : : (void *)&cmd_set_uc_hash_portid,
8526 : : (void *)&cmd_set_uc_hash_what,
8527 : : (void *)&cmd_set_uc_hash_mac,
8528 : : (void *)&cmd_set_uc_hash_mode,
8529 : : NULL,
8530 : : },
8531 : : };
8532 : :
8533 : : struct cmd_set_uc_all_hash_table {
8534 : : cmdline_fixed_string_t set;
8535 : : cmdline_fixed_string_t port;
8536 : : portid_t port_id;
8537 : : cmdline_fixed_string_t what;
8538 : : cmdline_fixed_string_t value;
8539 : : cmdline_fixed_string_t mode;
8540 : : };
8541 : :
8542 : : static void
8543 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
8544 : : __rte_unused struct cmdline *cl,
8545 : : __rte_unused void *data)
8546 : : {
8547 : : int ret=0;
8548 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
8549 : :
8550 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8551 : :
8552 : 0 : if ((strcmp(res->what, "uta") == 0) &&
8553 : 0 : (strcmp(res->value, "all") == 0))
8554 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8555 : 0 : if (ret < 0)
8556 : 0 : fprintf(stderr,
8557 : : "bad unicast hash table parameter, return code = %d\n",
8558 : : ret);
8559 : 0 : }
8560 : :
8561 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8562 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8563 : : set, "set");
8564 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8565 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8566 : : port, "port");
8567 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8568 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8569 : : port_id, RTE_UINT16);
8570 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8571 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8572 : : what, "uta");
8573 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8574 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8575 : : value,"all");
8576 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8577 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8578 : : mode, "on#off");
8579 : :
8580 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8581 : : .f = cmd_set_uc_all_hash_parsed,
8582 : : .data = NULL,
8583 : : .help_str = "set port <port_id> uta all on|off",
8584 : : .tokens = {
8585 : : (void *)&cmd_set_uc_all_hash_set,
8586 : : (void *)&cmd_set_uc_all_hash_port,
8587 : : (void *)&cmd_set_uc_all_hash_portid,
8588 : : (void *)&cmd_set_uc_all_hash_what,
8589 : : (void *)&cmd_set_uc_all_hash_value,
8590 : : (void *)&cmd_set_uc_all_hash_mode,
8591 : : NULL,
8592 : : },
8593 : : };
8594 : :
8595 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8596 : : struct cmd_set_vf_traffic {
8597 : : cmdline_fixed_string_t set;
8598 : : cmdline_fixed_string_t port;
8599 : : portid_t port_id;
8600 : : cmdline_fixed_string_t vf;
8601 : : uint8_t vf_id;
8602 : : cmdline_fixed_string_t what;
8603 : : cmdline_fixed_string_t mode;
8604 : : };
8605 : :
8606 : : static void
8607 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
8608 : : __rte_unused struct cmdline *cl,
8609 : : __rte_unused void *data)
8610 : : {
8611 : : struct cmd_set_vf_traffic *res = parsed_result;
8612 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8613 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8614 : :
8615 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8616 : 0 : }
8617 : :
8618 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
8619 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8620 : : set, "set");
8621 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
8622 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8623 : : port, "port");
8624 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8625 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8626 : : port_id, RTE_UINT16);
8627 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8628 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8629 : : vf, "vf");
8630 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8631 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8632 : : vf_id, RTE_UINT8);
8633 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
8634 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8635 : : what, "tx#rx");
8636 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8637 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8638 : : mode, "on#off");
8639 : :
8640 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
8641 : : .f = cmd_set_vf_traffic_parsed,
8642 : : .data = NULL,
8643 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8644 : : .tokens = {
8645 : : (void *)&cmd_setvf_traffic_set,
8646 : : (void *)&cmd_setvf_traffic_port,
8647 : : (void *)&cmd_setvf_traffic_portid,
8648 : : (void *)&cmd_setvf_traffic_vf,
8649 : : (void *)&cmd_setvf_traffic_vfid,
8650 : : (void *)&cmd_setvf_traffic_what,
8651 : : (void *)&cmd_setvf_traffic_mode,
8652 : : NULL,
8653 : : },
8654 : : };
8655 : :
8656 : : /* *** CONFIGURE VF RECEIVE MODE *** */
8657 : : struct cmd_set_vf_rxmode {
8658 : : cmdline_fixed_string_t set;
8659 : : cmdline_fixed_string_t port;
8660 : : portid_t port_id;
8661 : : cmdline_fixed_string_t vf;
8662 : : uint8_t vf_id;
8663 : : cmdline_fixed_string_t what;
8664 : : cmdline_fixed_string_t mode;
8665 : : cmdline_fixed_string_t on;
8666 : : };
8667 : :
8668 : : static void
8669 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
8670 : : __rte_unused struct cmdline *cl,
8671 : : __rte_unused void *data)
8672 : : {
8673 : : int ret = -ENOTSUP;
8674 : : uint16_t vf_rxmode = 0;
8675 : : struct cmd_set_vf_rxmode *res = parsed_result;
8676 : :
8677 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8678 : 0 : if (!strcmp(res->what,"rxmode")) {
8679 : 0 : if (!strcmp(res->mode, "AUPE"))
8680 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
8681 : 0 : else if (!strcmp(res->mode, "ROPE"))
8682 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
8683 : 0 : else if (!strcmp(res->mode, "BAM"))
8684 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
8685 : 0 : else if (!strncmp(res->mode, "MPE",3))
8686 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
8687 : : }
8688 : :
8689 : : RTE_SET_USED(is_on);
8690 : : RTE_SET_USED(vf_rxmode);
8691 : :
8692 : : #ifdef RTE_NET_IXGBE
8693 : : if (ret == -ENOTSUP)
8694 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8695 : : vf_rxmode, (uint8_t)is_on);
8696 : : #endif
8697 : : #ifdef RTE_NET_BNXT
8698 : 0 : if (ret == -ENOTSUP)
8699 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8700 : : vf_rxmode, (uint8_t)is_on);
8701 : : #endif
8702 : 0 : if (ret < 0)
8703 : 0 : fprintf(stderr,
8704 : : "bad VF receive mode parameter, return code = %d\n",
8705 : : ret);
8706 : 0 : }
8707 : :
8708 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8709 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8710 : : set, "set");
8711 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8712 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8713 : : port, "port");
8714 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8715 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8716 : : port_id, RTE_UINT16);
8717 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8718 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8719 : : vf, "vf");
8720 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8721 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8722 : : vf_id, RTE_UINT8);
8723 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8724 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8725 : : what, "rxmode");
8726 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8727 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8728 : : mode, "AUPE#ROPE#BAM#MPE");
8729 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8730 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8731 : : on, "on#off");
8732 : :
8733 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
8734 : : .f = cmd_set_vf_rxmode_parsed,
8735 : : .data = NULL,
8736 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
8737 : : "AUPE|ROPE|BAM|MPE on|off",
8738 : : .tokens = {
8739 : : (void *)&cmd_set_vf_rxmode_set,
8740 : : (void *)&cmd_set_vf_rxmode_port,
8741 : : (void *)&cmd_set_vf_rxmode_portid,
8742 : : (void *)&cmd_set_vf_rxmode_vf,
8743 : : (void *)&cmd_set_vf_rxmode_vfid,
8744 : : (void *)&cmd_set_vf_rxmode_what,
8745 : : (void *)&cmd_set_vf_rxmode_mode,
8746 : : (void *)&cmd_set_vf_rxmode_on,
8747 : : NULL,
8748 : : },
8749 : : };
8750 : :
8751 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8752 : : struct cmd_vf_mac_addr_result {
8753 : : cmdline_fixed_string_t mac_addr_cmd;
8754 : : cmdline_fixed_string_t what;
8755 : : cmdline_fixed_string_t port;
8756 : : uint16_t port_num;
8757 : : cmdline_fixed_string_t vf;
8758 : : uint8_t vf_num;
8759 : : struct rte_ether_addr address;
8760 : : };
8761 : :
8762 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
8763 : : __rte_unused struct cmdline *cl,
8764 : : __rte_unused void *data)
8765 : : {
8766 : : struct cmd_vf_mac_addr_result *res = parsed_result;
8767 : : int ret = -ENOTSUP;
8768 : :
8769 : 0 : if (strcmp(res->what, "add") != 0)
8770 : : return;
8771 : :
8772 : : #ifdef RTE_NET_I40E
8773 : : if (ret == -ENOTSUP)
8774 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8775 : : &res->address);
8776 : : #endif
8777 : : #ifdef RTE_NET_BNXT
8778 : 0 : if (ret == -ENOTSUP)
8779 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8780 : 0 : res->vf_num);
8781 : : #endif
8782 : :
8783 : 0 : if(ret < 0)
8784 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8785 : :
8786 : : }
8787 : :
8788 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8789 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8790 : : mac_addr_cmd,"mac_addr");
8791 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8792 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8793 : : what,"add");
8794 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8795 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8796 : : port,"port");
8797 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8798 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8799 : : port_num, RTE_UINT16);
8800 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8801 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8802 : : vf,"vf");
8803 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8804 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8805 : : vf_num, RTE_UINT8);
8806 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8807 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8808 : : address);
8809 : :
8810 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8811 : : .f = cmd_vf_mac_addr_parsed,
8812 : : .data = (void *)0,
8813 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8814 : : "Add MAC address filtering for a VF on port_id",
8815 : : .tokens = {
8816 : : (void *)&cmd_vf_mac_addr_cmd,
8817 : : (void *)&cmd_vf_mac_addr_what,
8818 : : (void *)&cmd_vf_mac_addr_port,
8819 : : (void *)&cmd_vf_mac_addr_portnum,
8820 : : (void *)&cmd_vf_mac_addr_vf,
8821 : : (void *)&cmd_vf_mac_addr_vfnum,
8822 : : (void *)&cmd_vf_mac_addr_addr,
8823 : : NULL,
8824 : : },
8825 : : };
8826 : :
8827 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8828 : : struct cmd_vf_rx_vlan_filter {
8829 : : cmdline_fixed_string_t rx_vlan;
8830 : : cmdline_fixed_string_t what;
8831 : : uint16_t vlan_id;
8832 : : cmdline_fixed_string_t port;
8833 : : portid_t port_id;
8834 : : cmdline_fixed_string_t vf;
8835 : : uint64_t vf_mask;
8836 : : };
8837 : :
8838 : : static void
8839 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8840 : : __rte_unused struct cmdline *cl,
8841 : : __rte_unused void *data)
8842 : : {
8843 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8844 : : int ret = -ENOTSUP;
8845 : :
8846 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8847 : :
8848 : : #ifdef RTE_NET_IXGBE
8849 : : if (ret == -ENOTSUP)
8850 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8851 : 0 : res->vlan_id, res->vf_mask, is_add);
8852 : : #endif
8853 : : #ifdef RTE_NET_I40E
8854 : 0 : if (ret == -ENOTSUP)
8855 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8856 : 0 : res->vlan_id, res->vf_mask, is_add);
8857 : : #endif
8858 : : #ifdef RTE_NET_BNXT
8859 : 0 : if (ret == -ENOTSUP)
8860 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8861 : 0 : res->vlan_id, res->vf_mask, is_add);
8862 : : #endif
8863 : :
8864 : 0 : switch (ret) {
8865 : : case 0:
8866 : : break;
8867 : 0 : case -EINVAL:
8868 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8869 : 0 : res->vlan_id, res->vf_mask);
8870 : : break;
8871 : 0 : case -ENODEV:
8872 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8873 : : break;
8874 : 0 : case -ENOTSUP:
8875 : 0 : fprintf(stderr, "function not implemented or supported\n");
8876 : : break;
8877 : 0 : default:
8878 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8879 : : }
8880 : 0 : }
8881 : :
8882 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8883 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8884 : : rx_vlan, "rx_vlan");
8885 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8886 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8887 : : what, "add#rm");
8888 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8889 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8890 : : vlan_id, RTE_UINT16);
8891 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8892 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8893 : : port, "port");
8894 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8895 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8896 : : port_id, RTE_UINT16);
8897 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8898 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8899 : : vf, "vf");
8900 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8901 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8902 : : vf_mask, RTE_UINT64);
8903 : :
8904 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8905 : : .f = cmd_vf_rx_vlan_filter_parsed,
8906 : : .data = NULL,
8907 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8908 : : "(vf_mask = hexadecimal VF mask)",
8909 : : .tokens = {
8910 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8911 : : (void *)&cmd_vf_rx_vlan_filter_what,
8912 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8913 : : (void *)&cmd_vf_rx_vlan_filter_port,
8914 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8915 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8916 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8917 : : NULL,
8918 : : },
8919 : : };
8920 : :
8921 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8922 : : struct cmd_queue_rate_limit_result {
8923 : : cmdline_fixed_string_t set;
8924 : : cmdline_fixed_string_t port;
8925 : : uint16_t port_num;
8926 : : cmdline_fixed_string_t queue;
8927 : : uint8_t queue_num;
8928 : : cmdline_fixed_string_t rate;
8929 : : uint32_t rate_num;
8930 : : };
8931 : :
8932 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8933 : : __rte_unused struct cmdline *cl,
8934 : : __rte_unused void *data)
8935 : : {
8936 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8937 : : int ret = 0;
8938 : :
8939 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8940 : 0 : && (strcmp(res->queue, "queue") == 0)
8941 : 0 : && (strcmp(res->rate, "rate") == 0))
8942 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8943 : : res->rate_num);
8944 : 0 : if (ret < 0)
8945 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8946 : : strerror(-ret));
8947 : :
8948 : 0 : }
8949 : :
8950 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8951 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8952 : : set, "set");
8953 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8954 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8955 : : port, "port");
8956 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8957 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8958 : : port_num, RTE_UINT16);
8959 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8960 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8961 : : queue, "queue");
8962 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8963 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8964 : : queue_num, RTE_UINT8);
8965 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8966 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8967 : : rate, "rate");
8968 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8969 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8970 : : rate_num, RTE_UINT32);
8971 : :
8972 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8973 : : .f = cmd_queue_rate_limit_parsed,
8974 : : .data = (void *)0,
8975 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8976 : : "Set rate limit for a queue on port_id",
8977 : : .tokens = {
8978 : : (void *)&cmd_queue_rate_limit_set,
8979 : : (void *)&cmd_queue_rate_limit_port,
8980 : : (void *)&cmd_queue_rate_limit_portnum,
8981 : : (void *)&cmd_queue_rate_limit_queue,
8982 : : (void *)&cmd_queue_rate_limit_queuenum,
8983 : : (void *)&cmd_queue_rate_limit_rate,
8984 : : (void *)&cmd_queue_rate_limit_ratenum,
8985 : : NULL,
8986 : : },
8987 : : };
8988 : :
8989 : : /* *** SHOW RATE LIMIT FOR A QUEUE OF A PORT *** */
8990 : : struct cmd_show_queue_rate_limit_result {
8991 : : cmdline_fixed_string_t show;
8992 : : cmdline_fixed_string_t port;
8993 : : uint16_t port_num;
8994 : : cmdline_fixed_string_t queue;
8995 : : uint16_t queue_num;
8996 : : cmdline_fixed_string_t rate;
8997 : : };
8998 : :
8999 : 0 : static void cmd_show_queue_rate_limit_parsed(void *parsed_result,
9000 : : __rte_unused struct cmdline *cl,
9001 : : __rte_unused void *data)
9002 : : {
9003 : : struct cmd_show_queue_rate_limit_result *res = parsed_result;
9004 : 0 : uint32_t tx_rate = 0;
9005 : : int ret;
9006 : :
9007 : 0 : ret = rte_eth_get_queue_rate_limit(res->port_num, res->queue_num,
9008 : : &tx_rate);
9009 : 0 : if (ret) {
9010 : 0 : fprintf(stderr, "Get queue rate limit failed: %s\n",
9011 : : rte_strerror(-ret));
9012 : 0 : return;
9013 : : }
9014 : 0 : if (tx_rate)
9015 : 0 : printf("Port %u Queue %u rate limit: %u Mbps\n",
9016 : 0 : res->port_num, res->queue_num, tx_rate);
9017 : : else
9018 : 0 : printf("Port %u Queue %u rate limit: disabled\n",
9019 : 0 : res->port_num, res->queue_num);
9020 : : }
9021 : :
9022 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_show =
9023 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9024 : : show, "show");
9025 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_port =
9026 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9027 : : port, "port");
9028 : : static cmdline_parse_token_num_t cmd_show_queue_rate_limit_portnum =
9029 : : TOKEN_NUM_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9030 : : port_num, RTE_UINT16);
9031 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_queue =
9032 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9033 : : queue, "queue");
9034 : : static cmdline_parse_token_num_t cmd_show_queue_rate_limit_queuenum =
9035 : : TOKEN_NUM_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9036 : : queue_num, RTE_UINT16);
9037 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_rate =
9038 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9039 : : rate, "rate");
9040 : :
9041 : : static cmdline_parse_inst_t cmd_show_queue_rate_limit = {
9042 : : .f = cmd_show_queue_rate_limit_parsed,
9043 : : .data = NULL,
9044 : : .help_str = "show port <port_id> queue <queue_id> rate: "
9045 : : "Show rate limit for a queue on port_id",
9046 : : .tokens = {
9047 : : (void *)&cmd_show_queue_rate_limit_show,
9048 : : (void *)&cmd_show_queue_rate_limit_port,
9049 : : (void *)&cmd_show_queue_rate_limit_portnum,
9050 : : (void *)&cmd_show_queue_rate_limit_queue,
9051 : : (void *)&cmd_show_queue_rate_limit_queuenum,
9052 : : (void *)&cmd_show_queue_rate_limit_rate,
9053 : : NULL,
9054 : : },
9055 : : };
9056 : :
9057 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9058 : : struct cmd_vf_rate_limit_result {
9059 : : cmdline_fixed_string_t set;
9060 : : cmdline_fixed_string_t port;
9061 : : uint16_t port_num;
9062 : : cmdline_fixed_string_t vf;
9063 : : uint8_t vf_num;
9064 : : cmdline_fixed_string_t rate;
9065 : : uint32_t rate_num;
9066 : : cmdline_fixed_string_t q_msk;
9067 : : uint64_t q_msk_val;
9068 : : };
9069 : :
9070 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
9071 : : __rte_unused struct cmdline *cl,
9072 : : __rte_unused void *data)
9073 : : {
9074 : : struct cmd_vf_rate_limit_result *res = parsed_result;
9075 : : int ret = 0;
9076 : :
9077 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9078 : 0 : && (strcmp(res->vf, "vf") == 0)
9079 : 0 : && (strcmp(res->rate, "rate") == 0)
9080 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
9081 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
9082 : : res->rate_num, res->q_msk_val);
9083 : 0 : if (ret < 0)
9084 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9085 : : strerror(-ret));
9086 : :
9087 : 0 : }
9088 : :
9089 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9090 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9091 : : set, "set");
9092 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9093 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9094 : : port, "port");
9095 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9096 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9097 : : port_num, RTE_UINT16);
9098 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9099 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9100 : : vf, "vf");
9101 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9102 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9103 : : vf_num, RTE_UINT8);
9104 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9105 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9106 : : rate, "rate");
9107 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9108 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9109 : : rate_num, RTE_UINT32);
9110 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9111 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9112 : : q_msk, "queue_mask");
9113 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9114 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9115 : : q_msk_val, RTE_UINT64);
9116 : :
9117 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
9118 : : .f = cmd_vf_rate_limit_parsed,
9119 : : .data = (void *)0,
9120 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9121 : : "queue_mask <queue_mask_value>: "
9122 : : "Set rate limit for queues of VF on port_id",
9123 : : .tokens = {
9124 : : (void *)&cmd_vf_rate_limit_set,
9125 : : (void *)&cmd_vf_rate_limit_port,
9126 : : (void *)&cmd_vf_rate_limit_portnum,
9127 : : (void *)&cmd_vf_rate_limit_vf,
9128 : : (void *)&cmd_vf_rate_limit_vfnum,
9129 : : (void *)&cmd_vf_rate_limit_rate,
9130 : : (void *)&cmd_vf_rate_limit_ratenum,
9131 : : (void *)&cmd_vf_rate_limit_q_msk,
9132 : : (void *)&cmd_vf_rate_limit_q_msk_val,
9133 : : NULL,
9134 : : },
9135 : : };
9136 : :
9137 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
9138 : : struct cmd_tunnel_udp_config {
9139 : : cmdline_fixed_string_t rx_vxlan_port;
9140 : : cmdline_fixed_string_t what;
9141 : : uint16_t udp_port;
9142 : : portid_t port_id;
9143 : : };
9144 : :
9145 : : static void
9146 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
9147 : : __rte_unused struct cmdline *cl,
9148 : : __rte_unused void *data)
9149 : : {
9150 : : struct cmd_tunnel_udp_config *res = parsed_result;
9151 : : struct rte_eth_udp_tunnel tunnel_udp;
9152 : : int ret;
9153 : :
9154 : 0 : tunnel_udp.udp_port = res->udp_port;
9155 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9156 : :
9157 : 0 : if (!strcmp(res->what, "add"))
9158 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9159 : : &tunnel_udp);
9160 : : else
9161 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9162 : : &tunnel_udp);
9163 : :
9164 : 0 : if (ret < 0)
9165 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
9166 : : strerror(-ret));
9167 : 0 : }
9168 : :
9169 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9170 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9171 : : rx_vxlan_port, "rx_vxlan_port");
9172 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9173 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9174 : : what, "add#rm");
9175 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9176 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9177 : : udp_port, RTE_UINT16);
9178 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9179 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9180 : : port_id, RTE_UINT16);
9181 : :
9182 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
9183 : : .f = cmd_tunnel_udp_config_parsed,
9184 : : .data = (void *)0,
9185 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9186 : : "Add/Remove a tunneling UDP port filter",
9187 : : .tokens = {
9188 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9189 : : (void *)&cmd_tunnel_udp_config_what,
9190 : : (void *)&cmd_tunnel_udp_config_udp_port,
9191 : : (void *)&cmd_tunnel_udp_config_port_id,
9192 : : NULL,
9193 : : },
9194 : : };
9195 : :
9196 : : struct cmd_config_tunnel_udp_port {
9197 : : cmdline_fixed_string_t port;
9198 : : cmdline_fixed_string_t config;
9199 : : portid_t port_id;
9200 : : cmdline_fixed_string_t udp_tunnel_port;
9201 : : cmdline_fixed_string_t action;
9202 : : cmdline_fixed_string_t tunnel_type;
9203 : : uint16_t udp_port;
9204 : : };
9205 : :
9206 : : static void
9207 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9208 : : __rte_unused struct cmdline *cl,
9209 : : __rte_unused void *data)
9210 : : {
9211 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
9212 : : struct rte_eth_udp_tunnel tunnel_udp;
9213 : : int ret = 0;
9214 : :
9215 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9216 : 0 : return;
9217 : :
9218 : 0 : tunnel_udp.udp_port = res->udp_port;
9219 : :
9220 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
9221 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9222 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
9223 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9224 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9225 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9226 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
9227 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9228 : : } else {
9229 : 0 : fprintf(stderr, "Invalid tunnel type\n");
9230 : 0 : return;
9231 : : }
9232 : :
9233 : 0 : if (!strcmp(res->action, "add"))
9234 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9235 : : &tunnel_udp);
9236 : : else
9237 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9238 : : &tunnel_udp);
9239 : :
9240 : 0 : if (ret < 0)
9241 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
9242 : : strerror(-ret));
9243 : : }
9244 : :
9245 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9246 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9247 : : "port");
9248 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9249 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9250 : : "config");
9251 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9252 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9253 : : RTE_UINT16);
9254 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9255 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9256 : : udp_tunnel_port,
9257 : : "udp_tunnel_port");
9258 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9259 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9260 : : "add#rm");
9261 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9262 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9263 : : "vxlan#geneve#vxlan-gpe#ecpri");
9264 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9265 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9266 : : RTE_UINT16);
9267 : :
9268 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9269 : : .f = cmd_cfg_tunnel_udp_port_parsed,
9270 : : .data = NULL,
9271 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9272 : : "geneve|vxlan-gpe|ecpri <udp_port>",
9273 : : .tokens = {
9274 : : (void *)&cmd_config_tunnel_udp_port_port,
9275 : : (void *)&cmd_config_tunnel_udp_port_config,
9276 : : (void *)&cmd_config_tunnel_udp_port_port_id,
9277 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9278 : : (void *)&cmd_config_tunnel_udp_port_action,
9279 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9280 : : (void *)&cmd_config_tunnel_udp_port_value,
9281 : : NULL,
9282 : : },
9283 : : };
9284 : :
9285 : : /* ******************************************************************************** */
9286 : :
9287 : : struct cmd_dump_simple_result {
9288 : : cmdline_fixed_string_t dump;
9289 : : cmdline_fixed_string_t obj;
9290 : : cmdline_fixed_string_t name;
9291 : : };
9292 : : static cmdline_parse_token_string_t cmd_dump_simple_dump =
9293 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, dump, "dump");
9294 : : static cmdline_parse_token_string_t cmd_dump_simple_obj =
9295 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9296 : : "physmem#"
9297 : : "socket_mem#"
9298 : : "memzone#"
9299 : : "struct_sizes#"
9300 : : "ring#"
9301 : : "mempool#"
9302 : : "devargs#"
9303 : : "lcores#"
9304 : : "trace#"
9305 : : "log_types"
9306 : : );
9307 : : static cmdline_parse_token_string_t cmd_dump_named_obj =
9308 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9309 : : "ring#"
9310 : : "mempool#"
9311 : : );
9312 : : static cmdline_parse_token_string_t cmd_dump_named_name =
9313 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, name, NULL);
9314 : :
9315 : : static void
9316 : 0 : dump_struct_sizes(void)
9317 : : {
9318 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9319 : : DUMP_SIZE(struct rte_mbuf);
9320 : : DUMP_SIZE(struct rte_mempool);
9321 : : DUMP_SIZE(struct rte_ring);
9322 : : #undef DUMP_SIZE
9323 : 0 : }
9324 : :
9325 : : /* Dump the socket memory statistics on console */
9326 : : static void
9327 : 0 : dump_socket_mem(FILE *f)
9328 : : {
9329 : : struct rte_malloc_socket_stats socket_stats;
9330 : : unsigned int i;
9331 : : size_t total = 0;
9332 : : size_t alloc = 0;
9333 : : size_t free = 0;
9334 : : unsigned int n_alloc = 0;
9335 : : unsigned int n_free = 0;
9336 : : static size_t last_allocs;
9337 : : static size_t last_total;
9338 : :
9339 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9340 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9341 : 0 : !socket_stats.heap_totalsz_bytes)
9342 : 0 : continue;
9343 : 0 : total += socket_stats.heap_totalsz_bytes;
9344 : 0 : alloc += socket_stats.heap_allocsz_bytes;
9345 : 0 : free += socket_stats.heap_freesz_bytes;
9346 : 0 : n_alloc += socket_stats.alloc_count;
9347 : 0 : n_free += socket_stats.free_count;
9348 : 0 : fprintf(f,
9349 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9350 : : i,
9351 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9352 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9353 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
9354 : 0 : (double)socket_stats.heap_totalsz_bytes,
9355 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9356 : : socket_stats.alloc_count,
9357 : : socket_stats.free_count);
9358 : : }
9359 : 0 : fprintf(f,
9360 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9361 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9362 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
9363 : 0 : (double)free / (1024 * 1024),
9364 : : n_alloc, n_free);
9365 : 0 : if (last_allocs)
9366 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9367 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
9368 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
9369 : 0 : last_allocs = alloc;
9370 : 0 : last_total = total;
9371 : 0 : }
9372 : :
9373 : 0 : static void cmd_dump_simple_parsed(void *parsed_result,
9374 : : struct cmdline *cl,
9375 : : __rte_unused void *data)
9376 : : {
9377 : : struct cmd_dump_simple_result *res = parsed_result;
9378 : :
9379 : 0 : if (strcmp(res->obj, "physmem") == 0)
9380 : 0 : rte_dump_physmem_layout(stdout);
9381 : 0 : else if (strcmp(res->obj, "socket_mem") == 0)
9382 : 0 : dump_socket_mem(stdout);
9383 : 0 : else if (strcmp(res->obj, "memzone") == 0)
9384 : 0 : rte_memzone_dump(stdout);
9385 : 0 : else if (strcmp(res->obj, "struct_sizes") == 0)
9386 : 0 : dump_struct_sizes();
9387 : 0 : else if (strcmp(res->obj, "ring") == 0) {
9388 : 0 : if (strcmp(res->name, "") == 0) {
9389 : 0 : rte_ring_list_dump(stdout);
9390 : : } else {
9391 : : struct rte_ring *r;
9392 : 0 : r = rte_ring_lookup(res->name);
9393 : 0 : if (r == NULL) {
9394 : 0 : cmdline_printf(cl, "Cannot find ring\n");
9395 : 0 : return;
9396 : : }
9397 : 0 : rte_ring_dump(stdout, r);
9398 : : }
9399 : 0 : } else if (strcmp(res->obj, "mempool") == 0) {
9400 : 0 : if (strcmp(res->name, "") == 0) {
9401 : 0 : rte_mempool_list_dump(stdout);
9402 : : } else {
9403 : : struct rte_mempool *mp;
9404 : 0 : mp = rte_mempool_lookup(res->name);
9405 : 0 : if (mp == NULL) {
9406 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
9407 : 0 : return;
9408 : : }
9409 : 0 : rte_mempool_dump(stdout, mp);
9410 : : }
9411 : 0 : } else if (strcmp(res->obj, "devargs") == 0)
9412 : 0 : rte_devargs_dump(stdout);
9413 : 0 : else if (strcmp(res->obj, "lcores") == 0)
9414 : 0 : rte_lcore_dump(stdout);
9415 : 0 : else if (strcmp(res->obj, "trace") == 0)
9416 : : #ifdef RTE_EXEC_ENV_WINDOWS
9417 : : cmdline_printf(cl, "trace is not supported on Windows\n");
9418 : : #else
9419 : 0 : rte_trace_save();
9420 : : #endif
9421 : 0 : else if (strcmp(res->obj, "log_types") == 0)
9422 : 0 : rte_log_dump(stdout);
9423 : : }
9424 : :
9425 : : static cmdline_parse_inst_t cmd_dump_simple = {
9426 : : .f = cmd_dump_simple_parsed,
9427 : : .help_str = "Dump objects",
9428 : : .tokens = {
9429 : : (void *)&cmd_dump_simple_dump,
9430 : : (void *)&cmd_dump_simple_obj,
9431 : : NULL,
9432 : : },
9433 : : };
9434 : : static cmdline_parse_inst_t cmd_dump_named = {
9435 : : .f = cmd_dump_simple_parsed,
9436 : : .help_str = "dump ring|mempool <name>: Dump one ring/mempool",
9437 : : .tokens = {
9438 : : (void *)&cmd_dump_simple_dump,
9439 : : (void *)&cmd_dump_named_obj,
9440 : : (void *)&cmd_dump_named_name,
9441 : : NULL,
9442 : : },
9443 : : };
9444 : :
9445 : : struct cmd_dump_mbuf_history_result {
9446 : : cmdline_fixed_string_t dump;
9447 : : cmdline_fixed_string_t mbuf;
9448 : : cmdline_fixed_string_t history;
9449 : : cmdline_fixed_string_t obj;
9450 : : cmdline_fixed_string_t name;
9451 : : cmdline_fixed_string_t addr;
9452 : : cmdline_fixed_string_t file;
9453 : : };
9454 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_dump =
9455 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, dump, "dump");
9456 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_mbuf =
9457 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, mbuf, "mbuf");
9458 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_history =
9459 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, history, "history");
9460 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_obj =
9461 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, NULL);
9462 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_pool =
9463 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, "pool");
9464 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_name =
9465 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, name, NULL);
9466 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_file =
9467 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, file, NULL);
9468 : :
9469 : 0 : static void cmd_dump_mbuf_history_parsed(void *parsed_result,
9470 : : struct cmdline *cl,
9471 : : __rte_unused void *data)
9472 : : {
9473 : : struct cmd_dump_mbuf_history_result *res = parsed_result;
9474 : 0 : FILE *out = stdout;
9475 : :
9476 : 0 : if (strcmp(res->file, "") != 0) {
9477 : 0 : out = fopen(res->file, "w");
9478 : 0 : if (out == NULL) {
9479 : 0 : cmdline_printf(cl,
9480 : : "Failed to open file '%s'\n",
9481 : : res->file);
9482 : 0 : return;
9483 : : }
9484 : : }
9485 : :
9486 : 0 : if (strcmp(res->obj, "all") == 0) {
9487 : 0 : rte_mbuf_history_dump_all(out);
9488 : 0 : if (out != stdout)
9489 : 0 : cmdline_printf(cl,
9490 : : "Dump written in '%s'\n",
9491 : 0 : res->file);
9492 : 0 : } else if (strcmp(res->obj, "pool") == 0) {
9493 : 0 : struct rte_mempool *mp = rte_mempool_lookup(res->name);
9494 : 0 : if (mp == NULL) {
9495 : 0 : cmdline_printf(cl,
9496 : : "Failed to find mempool '%s'\n",
9497 : : res->name);
9498 : 0 : goto out_close;
9499 : : }
9500 : 0 : rte_mbuf_history_dump_mempool(out, mp);
9501 : 0 : if (out != stdout)
9502 : 0 : cmdline_printf(cl,
9503 : : "Dump for mempool '%s' written in '%s'\n",
9504 : 0 : res->name, res->file);
9505 : : } else {
9506 : : struct rte_mbuf *mbuf;
9507 : : uintptr_t mbuf_addr;
9508 : 0 : if (sscanf(res->obj, "0x%" SCNxPTR, &mbuf_addr) != 1) {
9509 : 0 : cmdline_printf(cl,
9510 : : "Invalid mbuf pointer format. Use 0x<address>\n");
9511 : 0 : goto out_close;
9512 : : }
9513 : 0 : mbuf = (struct rte_mbuf *)mbuf_addr;
9514 : 0 : rte_mbuf_history_dump(out, mbuf);
9515 : 0 : if (out != stdout)
9516 : 0 : cmdline_printf(cl,
9517 : : "Dump for mbuf '%p' written in '%s'\n",
9518 : 0 : mbuf, res->file);
9519 : : }
9520 : :
9521 : 0 : out_close:
9522 : 0 : if (out != stdout)
9523 : 0 : fclose(out);
9524 : : }
9525 : :
9526 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_stdout = {
9527 : : .f = cmd_dump_mbuf_history_parsed,
9528 : : .help_str = "dump mbuf history all|<address>",
9529 : : .tokens = {
9530 : : (void *)&cmd_dump_mbuf_history_dump,
9531 : : (void *)&cmd_dump_mbuf_history_mbuf,
9532 : : (void *)&cmd_dump_mbuf_history_history,
9533 : : (void *)&cmd_dump_mbuf_history_obj,
9534 : : NULL,
9535 : : },
9536 : : };
9537 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_to_file = {
9538 : : .f = cmd_dump_mbuf_history_parsed,
9539 : : .help_str = "dump mbuf history all|<address> [file]",
9540 : : .tokens = {
9541 : : (void *)&cmd_dump_mbuf_history_dump,
9542 : : (void *)&cmd_dump_mbuf_history_mbuf,
9543 : : (void *)&cmd_dump_mbuf_history_history,
9544 : : (void *)&cmd_dump_mbuf_history_obj,
9545 : : (void *)&cmd_dump_mbuf_history_file,
9546 : : NULL,
9547 : : },
9548 : : };
9549 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_stdout = {
9550 : : .f = cmd_dump_mbuf_history_parsed,
9551 : : .help_str = "dump mbuf pool history <name>",
9552 : : .tokens = {
9553 : : (void *)&cmd_dump_mbuf_history_dump,
9554 : : (void *)&cmd_dump_mbuf_history_mbuf,
9555 : : (void *)&cmd_dump_mbuf_history_pool,
9556 : : (void *)&cmd_dump_mbuf_history_history,
9557 : : (void *)&cmd_dump_mbuf_history_name,
9558 : : NULL,
9559 : : },
9560 : : };
9561 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_to_file = {
9562 : : .f = cmd_dump_mbuf_history_parsed,
9563 : : .help_str = "dump mbuf pool history <name> [file]",
9564 : : .tokens = {
9565 : : (void *)&cmd_dump_mbuf_history_dump,
9566 : : (void *)&cmd_dump_mbuf_history_mbuf,
9567 : : (void *)&cmd_dump_mbuf_history_pool,
9568 : : (void *)&cmd_dump_mbuf_history_history,
9569 : : (void *)&cmd_dump_mbuf_history_name,
9570 : : (void *)&cmd_dump_mbuf_history_file,
9571 : : NULL,
9572 : : },
9573 : : };
9574 : :
9575 : : /* *** Filters Control *** */
9576 : :
9577 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9578 : : do { \
9579 : : if ((ip_addr).family == AF_INET) \
9580 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
9581 : : else { \
9582 : : fprintf(stderr, "invalid parameter.\n"); \
9583 : : return; \
9584 : : } \
9585 : : } while (0)
9586 : :
9587 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9588 : : do { \
9589 : : if ((ip_addr).family == AF_INET6) \
9590 : : ip = ip_addr.addr.ipv6; \
9591 : : else { \
9592 : : fprintf(stderr, "invalid parameter.\n"); \
9593 : : return; \
9594 : : } \
9595 : : } while (0)
9596 : :
9597 : : /* Generic flow interface command. */
9598 : : extern cmdline_parse_inst_t cmd_flow;
9599 : :
9600 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9601 : : struct cmd_mcast_addr_result {
9602 : : cmdline_fixed_string_t mcast_addr_cmd;
9603 : : cmdline_fixed_string_t what;
9604 : : uint16_t port_num;
9605 : : struct rte_ether_addr mc_addr;
9606 : : };
9607 : :
9608 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
9609 : : __rte_unused struct cmdline *cl,
9610 : : __rte_unused void *data)
9611 : : {
9612 : : struct cmd_mcast_addr_result *res = parsed_result;
9613 : :
9614 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
9615 : 0 : fprintf(stderr,
9616 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
9617 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
9618 : 0 : return;
9619 : : }
9620 : 0 : if (strcmp(res->what, "add") == 0)
9621 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
9622 : : else
9623 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
9624 : : }
9625 : :
9626 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9627 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9628 : : mcast_addr_cmd, "mcast_addr");
9629 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
9630 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9631 : : "add#remove");
9632 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9633 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9634 : : RTE_UINT16);
9635 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9636 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9637 : :
9638 : : static cmdline_parse_inst_t cmd_mcast_addr = {
9639 : : .f = cmd_mcast_addr_parsed,
9640 : : .data = (void *)0,
9641 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
9642 : : "Add/Remove multicast MAC address on port_id",
9643 : : .tokens = {
9644 : : (void *)&cmd_mcast_addr_cmd,
9645 : : (void *)&cmd_mcast_addr_what,
9646 : : (void *)&cmd_mcast_addr_portnum,
9647 : : (void *)&cmd_mcast_addr_addr,
9648 : : NULL,
9649 : : },
9650 : : };
9651 : :
9652 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
9653 : : struct cmd_mcast_addr_flush_result {
9654 : : cmdline_fixed_string_t mcast_addr_cmd;
9655 : : cmdline_fixed_string_t what;
9656 : : uint16_t port_num;
9657 : : };
9658 : :
9659 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
9660 : : __rte_unused struct cmdline *cl,
9661 : : __rte_unused void *data)
9662 : : {
9663 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
9664 : :
9665 : 0 : mcast_addr_flush(res->port_num);
9666 : 0 : }
9667 : :
9668 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
9669 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9670 : : mcast_addr_cmd, "mcast_addr");
9671 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
9672 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9673 : : "flush");
9674 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
9675 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9676 : : RTE_UINT16);
9677 : :
9678 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
9679 : : .f = cmd_mcast_addr_flush_parsed,
9680 : : .data = (void *)0,
9681 : : .help_str = "mcast_addr flush <port_id> : "
9682 : : "flush all multicast MAC addresses on port_id",
9683 : : .tokens = {
9684 : : (void *)&cmd_mcast_addr_flush_cmd,
9685 : : (void *)&cmd_mcast_addr_flush_what,
9686 : : (void *)&cmd_mcast_addr_flush_portnum,
9687 : : NULL,
9688 : : },
9689 : : };
9690 : :
9691 : : /* vf vlan anti spoof configuration */
9692 : :
9693 : : /* Common result structure for vf vlan anti spoof */
9694 : : struct cmd_vf_vlan_anti_spoof_result {
9695 : : cmdline_fixed_string_t set;
9696 : : cmdline_fixed_string_t vf;
9697 : : cmdline_fixed_string_t vlan;
9698 : : cmdline_fixed_string_t antispoof;
9699 : : portid_t port_id;
9700 : : uint32_t vf_id;
9701 : : cmdline_fixed_string_t on_off;
9702 : : };
9703 : :
9704 : : /* Common CLI fields for vf vlan anti spoof enable disable */
9705 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
9706 : : TOKEN_STRING_INITIALIZER
9707 : : (struct cmd_vf_vlan_anti_spoof_result,
9708 : : set, "set");
9709 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
9710 : : TOKEN_STRING_INITIALIZER
9711 : : (struct cmd_vf_vlan_anti_spoof_result,
9712 : : vf, "vf");
9713 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
9714 : : TOKEN_STRING_INITIALIZER
9715 : : (struct cmd_vf_vlan_anti_spoof_result,
9716 : : vlan, "vlan");
9717 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
9718 : : TOKEN_STRING_INITIALIZER
9719 : : (struct cmd_vf_vlan_anti_spoof_result,
9720 : : antispoof, "antispoof");
9721 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
9722 : : TOKEN_NUM_INITIALIZER
9723 : : (struct cmd_vf_vlan_anti_spoof_result,
9724 : : port_id, RTE_UINT16);
9725 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
9726 : : TOKEN_NUM_INITIALIZER
9727 : : (struct cmd_vf_vlan_anti_spoof_result,
9728 : : vf_id, RTE_UINT32);
9729 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
9730 : : TOKEN_STRING_INITIALIZER
9731 : : (struct cmd_vf_vlan_anti_spoof_result,
9732 : : on_off, "on#off");
9733 : :
9734 : : static void
9735 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
9736 : : void *parsed_result,
9737 : : __rte_unused struct cmdline *cl,
9738 : : __rte_unused void *data)
9739 : : {
9740 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
9741 : : int ret = -ENOTSUP;
9742 : :
9743 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9744 : :
9745 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9746 : : return;
9747 : :
9748 : : #ifdef RTE_NET_IXGBE
9749 : : if (ret == -ENOTSUP)
9750 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
9751 : 0 : res->vf_id, is_on);
9752 : : #endif
9753 : : #ifdef RTE_NET_I40E
9754 : 0 : if (ret == -ENOTSUP)
9755 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
9756 : 0 : res->vf_id, is_on);
9757 : : #endif
9758 : : #ifdef RTE_NET_BNXT
9759 : 0 : if (ret == -ENOTSUP)
9760 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
9761 : 0 : res->vf_id, is_on);
9762 : : #endif
9763 : :
9764 : 0 : switch (ret) {
9765 : : case 0:
9766 : : break;
9767 : 0 : case -EINVAL:
9768 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
9769 : : break;
9770 : 0 : case -ENODEV:
9771 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9772 : : break;
9773 : 0 : case -ENOTSUP:
9774 : 0 : fprintf(stderr, "function not implemented\n");
9775 : : break;
9776 : 0 : default:
9777 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9778 : : }
9779 : : }
9780 : :
9781 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
9782 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
9783 : : .data = NULL,
9784 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
9785 : : .tokens = {
9786 : : (void *)&cmd_vf_vlan_anti_spoof_set,
9787 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
9788 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
9789 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
9790 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
9791 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
9792 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
9793 : : NULL,
9794 : : },
9795 : : };
9796 : :
9797 : : /* vf mac anti spoof configuration */
9798 : :
9799 : : /* Common result structure for vf mac anti spoof */
9800 : : struct cmd_vf_mac_anti_spoof_result {
9801 : : cmdline_fixed_string_t set;
9802 : : cmdline_fixed_string_t vf;
9803 : : cmdline_fixed_string_t mac;
9804 : : cmdline_fixed_string_t antispoof;
9805 : : portid_t port_id;
9806 : : uint32_t vf_id;
9807 : : cmdline_fixed_string_t on_off;
9808 : : };
9809 : :
9810 : : /* Common CLI fields for vf mac anti spoof enable disable */
9811 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
9812 : : TOKEN_STRING_INITIALIZER
9813 : : (struct cmd_vf_mac_anti_spoof_result,
9814 : : set, "set");
9815 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
9816 : : TOKEN_STRING_INITIALIZER
9817 : : (struct cmd_vf_mac_anti_spoof_result,
9818 : : vf, "vf");
9819 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
9820 : : TOKEN_STRING_INITIALIZER
9821 : : (struct cmd_vf_mac_anti_spoof_result,
9822 : : mac, "mac");
9823 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
9824 : : TOKEN_STRING_INITIALIZER
9825 : : (struct cmd_vf_mac_anti_spoof_result,
9826 : : antispoof, "antispoof");
9827 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
9828 : : TOKEN_NUM_INITIALIZER
9829 : : (struct cmd_vf_mac_anti_spoof_result,
9830 : : port_id, RTE_UINT16);
9831 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
9832 : : TOKEN_NUM_INITIALIZER
9833 : : (struct cmd_vf_mac_anti_spoof_result,
9834 : : vf_id, RTE_UINT32);
9835 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
9836 : : TOKEN_STRING_INITIALIZER
9837 : : (struct cmd_vf_mac_anti_spoof_result,
9838 : : on_off, "on#off");
9839 : :
9840 : : static void
9841 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
9842 : : void *parsed_result,
9843 : : __rte_unused struct cmdline *cl,
9844 : : __rte_unused void *data)
9845 : : {
9846 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
9847 : : int ret = -ENOTSUP;
9848 : :
9849 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9850 : :
9851 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9852 : : return;
9853 : :
9854 : : #ifdef RTE_NET_IXGBE
9855 : : if (ret == -ENOTSUP)
9856 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
9857 : 0 : res->vf_id, is_on);
9858 : : #endif
9859 : : #ifdef RTE_NET_I40E
9860 : 0 : if (ret == -ENOTSUP)
9861 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
9862 : 0 : res->vf_id, is_on);
9863 : : #endif
9864 : : #ifdef RTE_NET_BNXT
9865 : 0 : if (ret == -ENOTSUP)
9866 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
9867 : 0 : res->vf_id, is_on);
9868 : : #endif
9869 : :
9870 : 0 : switch (ret) {
9871 : : case 0:
9872 : : break;
9873 : 0 : case -EINVAL:
9874 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9875 : : res->vf_id, is_on);
9876 : : break;
9877 : 0 : case -ENODEV:
9878 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9879 : : break;
9880 : 0 : case -ENOTSUP:
9881 : 0 : fprintf(stderr, "function not implemented\n");
9882 : : break;
9883 : 0 : default:
9884 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9885 : : }
9886 : : }
9887 : :
9888 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
9889 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
9890 : : .data = NULL,
9891 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
9892 : : .tokens = {
9893 : : (void *)&cmd_vf_mac_anti_spoof_set,
9894 : : (void *)&cmd_vf_mac_anti_spoof_vf,
9895 : : (void *)&cmd_vf_mac_anti_spoof_mac,
9896 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
9897 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
9898 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
9899 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
9900 : : NULL,
9901 : : },
9902 : : };
9903 : :
9904 : : /* vf vlan strip queue configuration */
9905 : :
9906 : : /* Common result structure for vf mac anti spoof */
9907 : : struct cmd_vf_vlan_stripq_result {
9908 : : cmdline_fixed_string_t set;
9909 : : cmdline_fixed_string_t vf;
9910 : : cmdline_fixed_string_t vlan;
9911 : : cmdline_fixed_string_t stripq;
9912 : : portid_t port_id;
9913 : : uint16_t vf_id;
9914 : : cmdline_fixed_string_t on_off;
9915 : : };
9916 : :
9917 : : /* Common CLI fields for vf vlan strip enable disable */
9918 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
9919 : : TOKEN_STRING_INITIALIZER
9920 : : (struct cmd_vf_vlan_stripq_result,
9921 : : set, "set");
9922 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
9923 : : TOKEN_STRING_INITIALIZER
9924 : : (struct cmd_vf_vlan_stripq_result,
9925 : : vf, "vf");
9926 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
9927 : : TOKEN_STRING_INITIALIZER
9928 : : (struct cmd_vf_vlan_stripq_result,
9929 : : vlan, "vlan");
9930 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
9931 : : TOKEN_STRING_INITIALIZER
9932 : : (struct cmd_vf_vlan_stripq_result,
9933 : : stripq, "stripq");
9934 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
9935 : : TOKEN_NUM_INITIALIZER
9936 : : (struct cmd_vf_vlan_stripq_result,
9937 : : port_id, RTE_UINT16);
9938 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
9939 : : TOKEN_NUM_INITIALIZER
9940 : : (struct cmd_vf_vlan_stripq_result,
9941 : : vf_id, RTE_UINT16);
9942 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
9943 : : TOKEN_STRING_INITIALIZER
9944 : : (struct cmd_vf_vlan_stripq_result,
9945 : : on_off, "on#off");
9946 : :
9947 : : static void
9948 : 0 : cmd_set_vf_vlan_stripq_parsed(
9949 : : void *parsed_result,
9950 : : __rte_unused struct cmdline *cl,
9951 : : __rte_unused void *data)
9952 : : {
9953 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
9954 : : int ret = -ENOTSUP;
9955 : :
9956 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9957 : :
9958 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9959 : : return;
9960 : :
9961 : : #ifdef RTE_NET_IXGBE
9962 : : if (ret == -ENOTSUP)
9963 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
9964 : 0 : res->vf_id, is_on);
9965 : : #endif
9966 : : #ifdef RTE_NET_I40E
9967 : 0 : if (ret == -ENOTSUP)
9968 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
9969 : 0 : res->vf_id, is_on);
9970 : : #endif
9971 : : #ifdef RTE_NET_BNXT
9972 : 0 : if (ret == -ENOTSUP)
9973 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
9974 : 0 : res->vf_id, is_on);
9975 : : #endif
9976 : :
9977 : 0 : switch (ret) {
9978 : : case 0:
9979 : : break;
9980 : 0 : case -EINVAL:
9981 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9982 : 0 : res->vf_id, is_on);
9983 : : break;
9984 : 0 : case -ENODEV:
9985 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9986 : : break;
9987 : 0 : case -ENOTSUP:
9988 : 0 : fprintf(stderr, "function not implemented\n");
9989 : : break;
9990 : 0 : default:
9991 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9992 : : }
9993 : : }
9994 : :
9995 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
9996 : : .f = cmd_set_vf_vlan_stripq_parsed,
9997 : : .data = NULL,
9998 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
9999 : : .tokens = {
10000 : : (void *)&cmd_vf_vlan_stripq_set,
10001 : : (void *)&cmd_vf_vlan_stripq_vf,
10002 : : (void *)&cmd_vf_vlan_stripq_vlan,
10003 : : (void *)&cmd_vf_vlan_stripq_stripq,
10004 : : (void *)&cmd_vf_vlan_stripq_port_id,
10005 : : (void *)&cmd_vf_vlan_stripq_vf_id,
10006 : : (void *)&cmd_vf_vlan_stripq_on_off,
10007 : : NULL,
10008 : : },
10009 : : };
10010 : :
10011 : : /* vf vlan insert configuration */
10012 : :
10013 : : /* Common result structure for vf vlan insert */
10014 : : struct cmd_vf_vlan_insert_result {
10015 : : cmdline_fixed_string_t set;
10016 : : cmdline_fixed_string_t vf;
10017 : : cmdline_fixed_string_t vlan;
10018 : : cmdline_fixed_string_t insert;
10019 : : portid_t port_id;
10020 : : uint16_t vf_id;
10021 : : uint16_t vlan_id;
10022 : : };
10023 : :
10024 : : /* Common CLI fields for vf vlan insert enable disable */
10025 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
10026 : : TOKEN_STRING_INITIALIZER
10027 : : (struct cmd_vf_vlan_insert_result,
10028 : : set, "set");
10029 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
10030 : : TOKEN_STRING_INITIALIZER
10031 : : (struct cmd_vf_vlan_insert_result,
10032 : : vf, "vf");
10033 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
10034 : : TOKEN_STRING_INITIALIZER
10035 : : (struct cmd_vf_vlan_insert_result,
10036 : : vlan, "vlan");
10037 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
10038 : : TOKEN_STRING_INITIALIZER
10039 : : (struct cmd_vf_vlan_insert_result,
10040 : : insert, "insert");
10041 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
10042 : : TOKEN_NUM_INITIALIZER
10043 : : (struct cmd_vf_vlan_insert_result,
10044 : : port_id, RTE_UINT16);
10045 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
10046 : : TOKEN_NUM_INITIALIZER
10047 : : (struct cmd_vf_vlan_insert_result,
10048 : : vf_id, RTE_UINT16);
10049 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
10050 : : TOKEN_NUM_INITIALIZER
10051 : : (struct cmd_vf_vlan_insert_result,
10052 : : vlan_id, RTE_UINT16);
10053 : :
10054 : : static void
10055 : 0 : cmd_set_vf_vlan_insert_parsed(
10056 : : void *parsed_result,
10057 : : __rte_unused struct cmdline *cl,
10058 : : __rte_unused void *data)
10059 : : {
10060 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
10061 : : int ret = -ENOTSUP;
10062 : :
10063 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10064 : : return;
10065 : :
10066 : : #ifdef RTE_NET_IXGBE
10067 : : if (ret == -ENOTSUP)
10068 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
10069 : 0 : res->vlan_id);
10070 : : #endif
10071 : : #ifdef RTE_NET_I40E
10072 : 0 : if (ret == -ENOTSUP)
10073 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
10074 : 0 : res->vlan_id);
10075 : : #endif
10076 : : #ifdef RTE_NET_BNXT
10077 : 0 : if (ret == -ENOTSUP)
10078 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
10079 : 0 : res->vlan_id);
10080 : : #endif
10081 : :
10082 : 0 : switch (ret) {
10083 : : case 0:
10084 : : break;
10085 : 0 : case -EINVAL:
10086 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
10087 : 0 : res->vf_id, res->vlan_id);
10088 : : break;
10089 : 0 : case -ENODEV:
10090 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10091 : : break;
10092 : 0 : case -ENOTSUP:
10093 : 0 : fprintf(stderr, "function not implemented\n");
10094 : : break;
10095 : 0 : default:
10096 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10097 : : }
10098 : : }
10099 : :
10100 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
10101 : : .f = cmd_set_vf_vlan_insert_parsed,
10102 : : .data = NULL,
10103 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
10104 : : .tokens = {
10105 : : (void *)&cmd_vf_vlan_insert_set,
10106 : : (void *)&cmd_vf_vlan_insert_vf,
10107 : : (void *)&cmd_vf_vlan_insert_vlan,
10108 : : (void *)&cmd_vf_vlan_insert_insert,
10109 : : (void *)&cmd_vf_vlan_insert_port_id,
10110 : : (void *)&cmd_vf_vlan_insert_vf_id,
10111 : : (void *)&cmd_vf_vlan_insert_vlan_id,
10112 : : NULL,
10113 : : },
10114 : : };
10115 : :
10116 : : /* tx loopback configuration */
10117 : :
10118 : : /* Common result structure for tx loopback */
10119 : : struct cmd_tx_loopback_result {
10120 : : cmdline_fixed_string_t set;
10121 : : cmdline_fixed_string_t tx;
10122 : : cmdline_fixed_string_t loopback;
10123 : : portid_t port_id;
10124 : : cmdline_fixed_string_t on_off;
10125 : : };
10126 : :
10127 : : /* Common CLI fields for tx loopback enable disable */
10128 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
10129 : : TOKEN_STRING_INITIALIZER
10130 : : (struct cmd_tx_loopback_result,
10131 : : set, "set");
10132 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
10133 : : TOKEN_STRING_INITIALIZER
10134 : : (struct cmd_tx_loopback_result,
10135 : : tx, "tx");
10136 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
10137 : : TOKEN_STRING_INITIALIZER
10138 : : (struct cmd_tx_loopback_result,
10139 : : loopback, "loopback");
10140 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
10141 : : TOKEN_NUM_INITIALIZER
10142 : : (struct cmd_tx_loopback_result,
10143 : : port_id, RTE_UINT16);
10144 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
10145 : : TOKEN_STRING_INITIALIZER
10146 : : (struct cmd_tx_loopback_result,
10147 : : on_off, "on#off");
10148 : :
10149 : : static void
10150 : 0 : cmd_set_tx_loopback_parsed(
10151 : : void *parsed_result,
10152 : : __rte_unused struct cmdline *cl,
10153 : : __rte_unused void *data)
10154 : : {
10155 : : struct cmd_tx_loopback_result *res = parsed_result;
10156 : : int ret = -ENOTSUP;
10157 : :
10158 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10159 : :
10160 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10161 : : return;
10162 : :
10163 : : #ifdef RTE_NET_IXGBE
10164 : : if (ret == -ENOTSUP)
10165 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
10166 : : #endif
10167 : : #ifdef RTE_NET_I40E
10168 : 0 : if (ret == -ENOTSUP)
10169 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
10170 : : #endif
10171 : : #ifdef RTE_NET_BNXT
10172 : 0 : if (ret == -ENOTSUP)
10173 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
10174 : : #endif
10175 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
10176 : 0 : if (ret == -ENOTSUP)
10177 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
10178 : : #endif
10179 : :
10180 : 0 : switch (ret) {
10181 : : case 0:
10182 : : break;
10183 : 0 : case -EINVAL:
10184 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10185 : : break;
10186 : 0 : case -ENODEV:
10187 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10188 : : break;
10189 : 0 : case -ENOTSUP:
10190 : 0 : fprintf(stderr, "function not implemented\n");
10191 : : break;
10192 : 0 : default:
10193 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10194 : : }
10195 : : }
10196 : :
10197 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
10198 : : .f = cmd_set_tx_loopback_parsed,
10199 : : .data = NULL,
10200 : : .help_str = "set tx loopback <port_id> on|off",
10201 : : .tokens = {
10202 : : (void *)&cmd_tx_loopback_set,
10203 : : (void *)&cmd_tx_loopback_tx,
10204 : : (void *)&cmd_tx_loopback_loopback,
10205 : : (void *)&cmd_tx_loopback_port_id,
10206 : : (void *)&cmd_tx_loopback_on_off,
10207 : : NULL,
10208 : : },
10209 : : };
10210 : :
10211 : : /* all queues drop enable configuration */
10212 : :
10213 : : /* Common result structure for all queues drop enable */
10214 : : struct cmd_all_queues_drop_en_result {
10215 : : cmdline_fixed_string_t set;
10216 : : cmdline_fixed_string_t all;
10217 : : cmdline_fixed_string_t queues;
10218 : : cmdline_fixed_string_t drop;
10219 : : portid_t port_id;
10220 : : cmdline_fixed_string_t on_off;
10221 : : };
10222 : :
10223 : : /* Common CLI fields for tx loopback enable disable */
10224 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
10225 : : TOKEN_STRING_INITIALIZER
10226 : : (struct cmd_all_queues_drop_en_result,
10227 : : set, "set");
10228 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
10229 : : TOKEN_STRING_INITIALIZER
10230 : : (struct cmd_all_queues_drop_en_result,
10231 : : all, "all");
10232 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
10233 : : TOKEN_STRING_INITIALIZER
10234 : : (struct cmd_all_queues_drop_en_result,
10235 : : queues, "queues");
10236 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
10237 : : TOKEN_STRING_INITIALIZER
10238 : : (struct cmd_all_queues_drop_en_result,
10239 : : drop, "drop");
10240 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
10241 : : TOKEN_NUM_INITIALIZER
10242 : : (struct cmd_all_queues_drop_en_result,
10243 : : port_id, RTE_UINT16);
10244 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
10245 : : TOKEN_STRING_INITIALIZER
10246 : : (struct cmd_all_queues_drop_en_result,
10247 : : on_off, "on#off");
10248 : :
10249 : : static void
10250 : 0 : cmd_set_all_queues_drop_en_parsed(
10251 : : void *parsed_result,
10252 : : __rte_unused struct cmdline *cl,
10253 : : __rte_unused void *data)
10254 : : {
10255 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
10256 : : int ret = -ENOTSUP;
10257 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10258 : :
10259 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10260 : : return;
10261 : :
10262 : : #ifdef RTE_NET_IXGBE
10263 : : if (ret == -ENOTSUP)
10264 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
10265 : : #endif
10266 : : #ifdef RTE_NET_BNXT
10267 : 0 : if (ret == -ENOTSUP)
10268 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
10269 : : #endif
10270 : 0 : switch (ret) {
10271 : : case 0:
10272 : : break;
10273 : 0 : case -EINVAL:
10274 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10275 : : break;
10276 : 0 : case -ENODEV:
10277 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10278 : : break;
10279 : 0 : case -ENOTSUP:
10280 : 0 : fprintf(stderr, "function not implemented\n");
10281 : : break;
10282 : 0 : default:
10283 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10284 : : }
10285 : : }
10286 : :
10287 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
10288 : : .f = cmd_set_all_queues_drop_en_parsed,
10289 : : .data = NULL,
10290 : : .help_str = "set all queues drop <port_id> on|off",
10291 : : .tokens = {
10292 : : (void *)&cmd_all_queues_drop_en_set,
10293 : : (void *)&cmd_all_queues_drop_en_all,
10294 : : (void *)&cmd_all_queues_drop_en_queues,
10295 : : (void *)&cmd_all_queues_drop_en_drop,
10296 : : (void *)&cmd_all_queues_drop_en_port_id,
10297 : : (void *)&cmd_all_queues_drop_en_on_off,
10298 : : NULL,
10299 : : },
10300 : : };
10301 : :
10302 : : /* vf mac address configuration */
10303 : :
10304 : : /* Common result structure for vf mac address */
10305 : : struct cmd_set_vf_mac_addr_result {
10306 : : cmdline_fixed_string_t set;
10307 : : cmdline_fixed_string_t vf;
10308 : : cmdline_fixed_string_t mac;
10309 : : cmdline_fixed_string_t addr;
10310 : : portid_t port_id;
10311 : : uint16_t vf_id;
10312 : : struct rte_ether_addr mac_addr;
10313 : :
10314 : : };
10315 : :
10316 : : /* Common CLI fields for vf split drop enable disable */
10317 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
10318 : : TOKEN_STRING_INITIALIZER
10319 : : (struct cmd_set_vf_mac_addr_result,
10320 : : set, "set");
10321 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
10322 : : TOKEN_STRING_INITIALIZER
10323 : : (struct cmd_set_vf_mac_addr_result,
10324 : : vf, "vf");
10325 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
10326 : : TOKEN_STRING_INITIALIZER
10327 : : (struct cmd_set_vf_mac_addr_result,
10328 : : mac, "mac");
10329 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
10330 : : TOKEN_STRING_INITIALIZER
10331 : : (struct cmd_set_vf_mac_addr_result,
10332 : : addr, "addr");
10333 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
10334 : : TOKEN_NUM_INITIALIZER
10335 : : (struct cmd_set_vf_mac_addr_result,
10336 : : port_id, RTE_UINT16);
10337 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
10338 : : TOKEN_NUM_INITIALIZER
10339 : : (struct cmd_set_vf_mac_addr_result,
10340 : : vf_id, RTE_UINT16);
10341 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
10342 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
10343 : : mac_addr);
10344 : :
10345 : : static void
10346 : 0 : cmd_set_vf_mac_addr_parsed(
10347 : : void *parsed_result,
10348 : : __rte_unused struct cmdline *cl,
10349 : : __rte_unused void *data)
10350 : : {
10351 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
10352 : : int ret = -ENOTSUP;
10353 : :
10354 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10355 : : return;
10356 : :
10357 : : #ifdef RTE_NET_IXGBE
10358 : : if (ret == -ENOTSUP)
10359 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
10360 : : &res->mac_addr);
10361 : : #endif
10362 : : #ifdef RTE_NET_I40E
10363 : 0 : if (ret == -ENOTSUP)
10364 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
10365 : : &res->mac_addr);
10366 : : #endif
10367 : : #ifdef RTE_NET_BNXT
10368 : 0 : if (ret == -ENOTSUP)
10369 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
10370 : : &res->mac_addr);
10371 : : #endif
10372 : :
10373 : 0 : switch (ret) {
10374 : : case 0:
10375 : : break;
10376 : 0 : case -EINVAL:
10377 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
10378 : : break;
10379 : 0 : case -ENODEV:
10380 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10381 : : break;
10382 : 0 : case -ENOTSUP:
10383 : 0 : fprintf(stderr, "function not implemented\n");
10384 : : break;
10385 : 0 : default:
10386 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10387 : : }
10388 : : }
10389 : :
10390 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
10391 : : .f = cmd_set_vf_mac_addr_parsed,
10392 : : .data = NULL,
10393 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
10394 : : .tokens = {
10395 : : (void *)&cmd_set_vf_mac_addr_set,
10396 : : (void *)&cmd_set_vf_mac_addr_vf,
10397 : : (void *)&cmd_set_vf_mac_addr_mac,
10398 : : (void *)&cmd_set_vf_mac_addr_addr,
10399 : : (void *)&cmd_set_vf_mac_addr_port_id,
10400 : : (void *)&cmd_set_vf_mac_addr_vf_id,
10401 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
10402 : : NULL,
10403 : : },
10404 : : };
10405 : :
10406 : : /** Set VXLAN encapsulation details */
10407 : : struct cmd_set_vxlan_result {
10408 : : cmdline_fixed_string_t set;
10409 : : cmdline_fixed_string_t vxlan;
10410 : : cmdline_fixed_string_t pos_token;
10411 : : cmdline_fixed_string_t ip_version;
10412 : : uint32_t vlan_present:1;
10413 : : uint32_t vni;
10414 : : uint16_t udp_src;
10415 : : uint16_t udp_dst;
10416 : : cmdline_ipaddr_t ip_src;
10417 : : cmdline_ipaddr_t ip_dst;
10418 : : uint16_t tci;
10419 : : uint8_t tos;
10420 : : uint8_t ttl;
10421 : : struct rte_ether_addr eth_src;
10422 : : struct rte_ether_addr eth_dst;
10423 : : };
10424 : :
10425 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
10426 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
10427 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
10428 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
10429 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
10430 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10431 : : "vxlan-tos-ttl");
10432 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
10433 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10434 : : "vxlan-with-vlan");
10435 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
10436 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10437 : : "ip-version");
10438 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
10439 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
10440 : : "ipv4#ipv6");
10441 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
10442 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10443 : : "vni");
10444 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
10445 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
10446 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
10447 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10448 : : "udp-src");
10449 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
10450 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
10451 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
10452 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10453 : : "udp-dst");
10454 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
10455 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
10456 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
10457 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10458 : : "ip-tos");
10459 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
10460 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
10461 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
10462 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10463 : : "ip-ttl");
10464 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
10465 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
10466 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
10467 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10468 : : "ip-src");
10469 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
10470 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
10471 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
10472 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10473 : : "ip-dst");
10474 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
10475 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
10476 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
10477 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10478 : : "vlan-tci");
10479 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
10480 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
10481 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
10482 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10483 : : "eth-src");
10484 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
10485 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
10486 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
10487 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10488 : : "eth-dst");
10489 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
10490 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
10491 : :
10492 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
10493 : : __rte_unused struct cmdline *cl,
10494 : : __rte_unused void *data)
10495 : : {
10496 : : struct cmd_set_vxlan_result *res = parsed_result;
10497 : : union {
10498 : : uint32_t vxlan_id;
10499 : : uint8_t vni[4];
10500 : : } id = {
10501 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
10502 : : };
10503 : :
10504 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
10505 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
10506 : 0 : vxlan_encap_conf.select_vlan = 0;
10507 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
10508 : 0 : vxlan_encap_conf.select_vlan = 1;
10509 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
10510 : 0 : vxlan_encap_conf.select_vlan = 0;
10511 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
10512 : : }
10513 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10514 : 0 : vxlan_encap_conf.select_ipv4 = 1;
10515 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10516 : 0 : vxlan_encap_conf.select_ipv4 = 0;
10517 : : else
10518 : : return;
10519 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
10520 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10521 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10522 : 0 : vxlan_encap_conf.ip_tos = res->tos;
10523 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
10524 : 0 : if (vxlan_encap_conf.select_ipv4) {
10525 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
10526 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
10527 : : } else {
10528 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
10529 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
10530 : : }
10531 : 0 : if (vxlan_encap_conf.select_vlan)
10532 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10533 : : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
10534 : : RTE_ETHER_ADDR_LEN);
10535 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10536 : : RTE_ETHER_ADDR_LEN);
10537 : : }
10538 : :
10539 : : static cmdline_parse_inst_t cmd_set_vxlan = {
10540 : : .f = cmd_set_vxlan_parsed,
10541 : : .data = NULL,
10542 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
10543 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
10544 : : " eth-src <eth-src> eth-dst <eth-dst>",
10545 : : .tokens = {
10546 : : (void *)&cmd_set_vxlan_set,
10547 : : (void *)&cmd_set_vxlan_vxlan,
10548 : : (void *)&cmd_set_vxlan_ip_version,
10549 : : (void *)&cmd_set_vxlan_ip_version_value,
10550 : : (void *)&cmd_set_vxlan_vni,
10551 : : (void *)&cmd_set_vxlan_vni_value,
10552 : : (void *)&cmd_set_vxlan_udp_src,
10553 : : (void *)&cmd_set_vxlan_udp_src_value,
10554 : : (void *)&cmd_set_vxlan_udp_dst,
10555 : : (void *)&cmd_set_vxlan_udp_dst_value,
10556 : : (void *)&cmd_set_vxlan_ip_src,
10557 : : (void *)&cmd_set_vxlan_ip_src_value,
10558 : : (void *)&cmd_set_vxlan_ip_dst,
10559 : : (void *)&cmd_set_vxlan_ip_dst_value,
10560 : : (void *)&cmd_set_vxlan_eth_src,
10561 : : (void *)&cmd_set_vxlan_eth_src_value,
10562 : : (void *)&cmd_set_vxlan_eth_dst,
10563 : : (void *)&cmd_set_vxlan_eth_dst_value,
10564 : : NULL,
10565 : : },
10566 : : };
10567 : :
10568 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
10569 : : .f = cmd_set_vxlan_parsed,
10570 : : .data = NULL,
10571 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
10572 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
10573 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10574 : : " eth-dst <eth-dst>",
10575 : : .tokens = {
10576 : : (void *)&cmd_set_vxlan_set,
10577 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
10578 : : (void *)&cmd_set_vxlan_ip_version,
10579 : : (void *)&cmd_set_vxlan_ip_version_value,
10580 : : (void *)&cmd_set_vxlan_vni,
10581 : : (void *)&cmd_set_vxlan_vni_value,
10582 : : (void *)&cmd_set_vxlan_udp_src,
10583 : : (void *)&cmd_set_vxlan_udp_src_value,
10584 : : (void *)&cmd_set_vxlan_udp_dst,
10585 : : (void *)&cmd_set_vxlan_udp_dst_value,
10586 : : (void *)&cmd_set_vxlan_ip_tos,
10587 : : (void *)&cmd_set_vxlan_ip_tos_value,
10588 : : (void *)&cmd_set_vxlan_ip_ttl,
10589 : : (void *)&cmd_set_vxlan_ip_ttl_value,
10590 : : (void *)&cmd_set_vxlan_ip_src,
10591 : : (void *)&cmd_set_vxlan_ip_src_value,
10592 : : (void *)&cmd_set_vxlan_ip_dst,
10593 : : (void *)&cmd_set_vxlan_ip_dst_value,
10594 : : (void *)&cmd_set_vxlan_eth_src,
10595 : : (void *)&cmd_set_vxlan_eth_src_value,
10596 : : (void *)&cmd_set_vxlan_eth_dst,
10597 : : (void *)&cmd_set_vxlan_eth_dst_value,
10598 : : NULL,
10599 : : },
10600 : : };
10601 : :
10602 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
10603 : : .f = cmd_set_vxlan_parsed,
10604 : : .data = NULL,
10605 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
10606 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
10607 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
10608 : : " <eth-dst>",
10609 : : .tokens = {
10610 : : (void *)&cmd_set_vxlan_set,
10611 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
10612 : : (void *)&cmd_set_vxlan_ip_version,
10613 : : (void *)&cmd_set_vxlan_ip_version_value,
10614 : : (void *)&cmd_set_vxlan_vni,
10615 : : (void *)&cmd_set_vxlan_vni_value,
10616 : : (void *)&cmd_set_vxlan_udp_src,
10617 : : (void *)&cmd_set_vxlan_udp_src_value,
10618 : : (void *)&cmd_set_vxlan_udp_dst,
10619 : : (void *)&cmd_set_vxlan_udp_dst_value,
10620 : : (void *)&cmd_set_vxlan_ip_src,
10621 : : (void *)&cmd_set_vxlan_ip_src_value,
10622 : : (void *)&cmd_set_vxlan_ip_dst,
10623 : : (void *)&cmd_set_vxlan_ip_dst_value,
10624 : : (void *)&cmd_set_vxlan_vlan,
10625 : : (void *)&cmd_set_vxlan_vlan_value,
10626 : : (void *)&cmd_set_vxlan_eth_src,
10627 : : (void *)&cmd_set_vxlan_eth_src_value,
10628 : : (void *)&cmd_set_vxlan_eth_dst,
10629 : : (void *)&cmd_set_vxlan_eth_dst_value,
10630 : : NULL,
10631 : : },
10632 : : };
10633 : :
10634 : : /** Set NVGRE encapsulation details */
10635 : : struct cmd_set_nvgre_result {
10636 : : cmdline_fixed_string_t set;
10637 : : cmdline_fixed_string_t nvgre;
10638 : : cmdline_fixed_string_t pos_token;
10639 : : cmdline_fixed_string_t ip_version;
10640 : : uint32_t tni;
10641 : : cmdline_ipaddr_t ip_src;
10642 : : cmdline_ipaddr_t ip_dst;
10643 : : uint16_t tci;
10644 : : struct rte_ether_addr eth_src;
10645 : : struct rte_ether_addr eth_dst;
10646 : : };
10647 : :
10648 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
10649 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
10650 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
10651 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
10652 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
10653 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
10654 : : "nvgre-with-vlan");
10655 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
10656 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10657 : : "ip-version");
10658 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
10659 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
10660 : : "ipv4#ipv6");
10661 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
10662 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10663 : : "tni");
10664 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
10665 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
10666 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
10667 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10668 : : "ip-src");
10669 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
10670 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
10671 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
10672 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10673 : : "ip-dst");
10674 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
10675 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
10676 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
10677 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10678 : : "vlan-tci");
10679 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
10680 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
10681 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
10682 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10683 : : "eth-src");
10684 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
10685 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
10686 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
10687 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10688 : : "eth-dst");
10689 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
10690 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
10691 : :
10692 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
10693 : : __rte_unused struct cmdline *cl,
10694 : : __rte_unused void *data)
10695 : : {
10696 : : struct cmd_set_nvgre_result *res = parsed_result;
10697 : : union {
10698 : : uint32_t nvgre_tni;
10699 : : uint8_t tni[4];
10700 : : } id = {
10701 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
10702 : : };
10703 : :
10704 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
10705 : 0 : nvgre_encap_conf.select_vlan = 0;
10706 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
10707 : 0 : nvgre_encap_conf.select_vlan = 1;
10708 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10709 : 0 : nvgre_encap_conf.select_ipv4 = 1;
10710 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10711 : 0 : nvgre_encap_conf.select_ipv4 = 0;
10712 : : else
10713 : : return;
10714 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
10715 : 0 : if (nvgre_encap_conf.select_ipv4) {
10716 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
10717 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
10718 : : } else {
10719 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
10720 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
10721 : : }
10722 : 0 : if (nvgre_encap_conf.select_vlan)
10723 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10724 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
10725 : : RTE_ETHER_ADDR_LEN);
10726 : : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10727 : : RTE_ETHER_ADDR_LEN);
10728 : : }
10729 : :
10730 : : static cmdline_parse_inst_t cmd_set_nvgre = {
10731 : : .f = cmd_set_nvgre_parsed,
10732 : : .data = NULL,
10733 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
10734 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10735 : : " eth-dst <eth-dst>",
10736 : : .tokens = {
10737 : : (void *)&cmd_set_nvgre_set,
10738 : : (void *)&cmd_set_nvgre_nvgre,
10739 : : (void *)&cmd_set_nvgre_ip_version,
10740 : : (void *)&cmd_set_nvgre_ip_version_value,
10741 : : (void *)&cmd_set_nvgre_tni,
10742 : : (void *)&cmd_set_nvgre_tni_value,
10743 : : (void *)&cmd_set_nvgre_ip_src,
10744 : : (void *)&cmd_set_nvgre_ip_src_value,
10745 : : (void *)&cmd_set_nvgre_ip_dst,
10746 : : (void *)&cmd_set_nvgre_ip_dst_value,
10747 : : (void *)&cmd_set_nvgre_eth_src,
10748 : : (void *)&cmd_set_nvgre_eth_src_value,
10749 : : (void *)&cmd_set_nvgre_eth_dst,
10750 : : (void *)&cmd_set_nvgre_eth_dst_value,
10751 : : NULL,
10752 : : },
10753 : : };
10754 : :
10755 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
10756 : : .f = cmd_set_nvgre_parsed,
10757 : : .data = NULL,
10758 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
10759 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10760 : : " eth-src <eth-src> eth-dst <eth-dst>",
10761 : : .tokens = {
10762 : : (void *)&cmd_set_nvgre_set,
10763 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
10764 : : (void *)&cmd_set_nvgre_ip_version,
10765 : : (void *)&cmd_set_nvgre_ip_version_value,
10766 : : (void *)&cmd_set_nvgre_tni,
10767 : : (void *)&cmd_set_nvgre_tni_value,
10768 : : (void *)&cmd_set_nvgre_ip_src,
10769 : : (void *)&cmd_set_nvgre_ip_src_value,
10770 : : (void *)&cmd_set_nvgre_ip_dst,
10771 : : (void *)&cmd_set_nvgre_ip_dst_value,
10772 : : (void *)&cmd_set_nvgre_vlan,
10773 : : (void *)&cmd_set_nvgre_vlan_value,
10774 : : (void *)&cmd_set_nvgre_eth_src,
10775 : : (void *)&cmd_set_nvgre_eth_src_value,
10776 : : (void *)&cmd_set_nvgre_eth_dst,
10777 : : (void *)&cmd_set_nvgre_eth_dst_value,
10778 : : NULL,
10779 : : },
10780 : : };
10781 : :
10782 : : /** Set L2 encapsulation details */
10783 : : struct cmd_set_l2_encap_result {
10784 : : cmdline_fixed_string_t set;
10785 : : cmdline_fixed_string_t l2_encap;
10786 : : cmdline_fixed_string_t pos_token;
10787 : : cmdline_fixed_string_t ip_version;
10788 : : uint32_t vlan_present:1;
10789 : : uint16_t tci;
10790 : : struct rte_ether_addr eth_src;
10791 : : struct rte_ether_addr eth_dst;
10792 : : };
10793 : :
10794 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
10795 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
10796 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
10797 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
10798 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
10799 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
10800 : : "l2_encap-with-vlan");
10801 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
10802 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10803 : : "ip-version");
10804 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
10805 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
10806 : : "ipv4#ipv6");
10807 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
10808 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10809 : : "vlan-tci");
10810 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
10811 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
10812 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
10813 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10814 : : "eth-src");
10815 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
10816 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
10817 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
10818 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10819 : : "eth-dst");
10820 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
10821 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
10822 : :
10823 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
10824 : : __rte_unused struct cmdline *cl,
10825 : : __rte_unused void *data)
10826 : : {
10827 : : struct cmd_set_l2_encap_result *res = parsed_result;
10828 : :
10829 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
10830 : 0 : l2_encap_conf.select_vlan = 0;
10831 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
10832 : 0 : l2_encap_conf.select_vlan = 1;
10833 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10834 : 0 : l2_encap_conf.select_ipv4 = 1;
10835 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10836 : 0 : l2_encap_conf.select_ipv4 = 0;
10837 : : else
10838 : : return;
10839 : 0 : if (l2_encap_conf.select_vlan)
10840 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10841 : : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
10842 : : RTE_ETHER_ADDR_LEN);
10843 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10844 : : RTE_ETHER_ADDR_LEN);
10845 : : }
10846 : :
10847 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
10848 : : .f = cmd_set_l2_encap_parsed,
10849 : : .data = NULL,
10850 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
10851 : : " eth-src <eth-src> eth-dst <eth-dst>",
10852 : : .tokens = {
10853 : : (void *)&cmd_set_l2_encap_set,
10854 : : (void *)&cmd_set_l2_encap_l2_encap,
10855 : : (void *)&cmd_set_l2_encap_ip_version,
10856 : : (void *)&cmd_set_l2_encap_ip_version_value,
10857 : : (void *)&cmd_set_l2_encap_eth_src,
10858 : : (void *)&cmd_set_l2_encap_eth_src_value,
10859 : : (void *)&cmd_set_l2_encap_eth_dst,
10860 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10861 : : NULL,
10862 : : },
10863 : : };
10864 : :
10865 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
10866 : : .f = cmd_set_l2_encap_parsed,
10867 : : .data = NULL,
10868 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
10869 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10870 : : .tokens = {
10871 : : (void *)&cmd_set_l2_encap_set,
10872 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
10873 : : (void *)&cmd_set_l2_encap_ip_version,
10874 : : (void *)&cmd_set_l2_encap_ip_version_value,
10875 : : (void *)&cmd_set_l2_encap_vlan,
10876 : : (void *)&cmd_set_l2_encap_vlan_value,
10877 : : (void *)&cmd_set_l2_encap_eth_src,
10878 : : (void *)&cmd_set_l2_encap_eth_src_value,
10879 : : (void *)&cmd_set_l2_encap_eth_dst,
10880 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10881 : : NULL,
10882 : : },
10883 : : };
10884 : :
10885 : : /** Set L2 decapsulation details */
10886 : : struct cmd_set_l2_decap_result {
10887 : : cmdline_fixed_string_t set;
10888 : : cmdline_fixed_string_t l2_decap;
10889 : : cmdline_fixed_string_t pos_token;
10890 : : uint32_t vlan_present:1;
10891 : : };
10892 : :
10893 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
10894 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
10895 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
10896 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10897 : : "l2_decap");
10898 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
10899 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10900 : : "l2_decap-with-vlan");
10901 : :
10902 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
10903 : : __rte_unused struct cmdline *cl,
10904 : : __rte_unused void *data)
10905 : : {
10906 : : struct cmd_set_l2_decap_result *res = parsed_result;
10907 : :
10908 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
10909 : 0 : l2_decap_conf.select_vlan = 0;
10910 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
10911 : 0 : l2_decap_conf.select_vlan = 1;
10912 : 0 : }
10913 : :
10914 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
10915 : : .f = cmd_set_l2_decap_parsed,
10916 : : .data = NULL,
10917 : : .help_str = "set l2_decap",
10918 : : .tokens = {
10919 : : (void *)&cmd_set_l2_decap_set,
10920 : : (void *)&cmd_set_l2_decap_l2_decap,
10921 : : NULL,
10922 : : },
10923 : : };
10924 : :
10925 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
10926 : : .f = cmd_set_l2_decap_parsed,
10927 : : .data = NULL,
10928 : : .help_str = "set l2_decap-with-vlan",
10929 : : .tokens = {
10930 : : (void *)&cmd_set_l2_decap_set,
10931 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
10932 : : NULL,
10933 : : },
10934 : : };
10935 : :
10936 : : /** Set MPLSoGRE encapsulation details */
10937 : : struct cmd_set_mplsogre_encap_result {
10938 : : cmdline_fixed_string_t set;
10939 : : cmdline_fixed_string_t mplsogre;
10940 : : cmdline_fixed_string_t pos_token;
10941 : : cmdline_fixed_string_t ip_version;
10942 : : uint32_t vlan_present:1;
10943 : : uint32_t label;
10944 : : cmdline_ipaddr_t ip_src;
10945 : : cmdline_ipaddr_t ip_dst;
10946 : : uint16_t tci;
10947 : : struct rte_ether_addr eth_src;
10948 : : struct rte_ether_addr eth_dst;
10949 : : };
10950 : :
10951 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
10952 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
10953 : : "set");
10954 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
10955 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
10956 : : "mplsogre_encap");
10957 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
10958 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10959 : : mplsogre, "mplsogre_encap-with-vlan");
10960 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
10961 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10962 : : pos_token, "ip-version");
10963 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
10964 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10965 : : ip_version, "ipv4#ipv6");
10966 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
10967 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10968 : : pos_token, "label");
10969 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
10970 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
10971 : : RTE_UINT32);
10972 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
10973 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10974 : : pos_token, "ip-src");
10975 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
10976 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
10977 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
10978 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10979 : : pos_token, "ip-dst");
10980 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
10981 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
10982 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
10983 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10984 : : pos_token, "vlan-tci");
10985 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
10986 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
10987 : : RTE_UINT16);
10988 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
10989 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10990 : : pos_token, "eth-src");
10991 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
10992 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10993 : : eth_src);
10994 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
10995 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10996 : : pos_token, "eth-dst");
10997 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
10998 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10999 : : eth_dst);
11000 : :
11001 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
11002 : : __rte_unused struct cmdline *cl,
11003 : : __rte_unused void *data)
11004 : : {
11005 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
11006 : : union {
11007 : : uint32_t mplsogre_label;
11008 : : uint8_t label[4];
11009 : : } id = {
11010 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
11011 : : };
11012 : :
11013 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
11014 : 0 : mplsogre_encap_conf.select_vlan = 0;
11015 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
11016 : 0 : mplsogre_encap_conf.select_vlan = 1;
11017 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11018 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
11019 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11020 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
11021 : : else
11022 : : return;
11023 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
11024 : 0 : if (mplsogre_encap_conf.select_ipv4) {
11025 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
11026 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
11027 : : } else {
11028 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
11029 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
11030 : : }
11031 : 0 : if (mplsogre_encap_conf.select_vlan)
11032 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11033 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
11034 : : RTE_ETHER_ADDR_LEN);
11035 : : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11036 : : RTE_ETHER_ADDR_LEN);
11037 : : }
11038 : :
11039 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
11040 : : .f = cmd_set_mplsogre_encap_parsed,
11041 : : .data = NULL,
11042 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
11043 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
11044 : : " eth-dst <eth-dst>",
11045 : : .tokens = {
11046 : : (void *)&cmd_set_mplsogre_encap_set,
11047 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
11048 : : (void *)&cmd_set_mplsogre_encap_ip_version,
11049 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
11050 : : (void *)&cmd_set_mplsogre_encap_label,
11051 : : (void *)&cmd_set_mplsogre_encap_label_value,
11052 : : (void *)&cmd_set_mplsogre_encap_ip_src,
11053 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
11054 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
11055 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
11056 : : (void *)&cmd_set_mplsogre_encap_eth_src,
11057 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
11058 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
11059 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
11060 : : NULL,
11061 : : },
11062 : : };
11063 : :
11064 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
11065 : : .f = cmd_set_mplsogre_encap_parsed,
11066 : : .data = NULL,
11067 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
11068 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
11069 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
11070 : : .tokens = {
11071 : : (void *)&cmd_set_mplsogre_encap_set,
11072 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
11073 : : (void *)&cmd_set_mplsogre_encap_ip_version,
11074 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
11075 : : (void *)&cmd_set_mplsogre_encap_label,
11076 : : (void *)&cmd_set_mplsogre_encap_label_value,
11077 : : (void *)&cmd_set_mplsogre_encap_ip_src,
11078 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
11079 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
11080 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
11081 : : (void *)&cmd_set_mplsogre_encap_vlan,
11082 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
11083 : : (void *)&cmd_set_mplsogre_encap_eth_src,
11084 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
11085 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
11086 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
11087 : : NULL,
11088 : : },
11089 : : };
11090 : :
11091 : : /** Set MPLSoGRE decapsulation details */
11092 : : struct cmd_set_mplsogre_decap_result {
11093 : : cmdline_fixed_string_t set;
11094 : : cmdline_fixed_string_t mplsogre;
11095 : : cmdline_fixed_string_t pos_token;
11096 : : cmdline_fixed_string_t ip_version;
11097 : : uint32_t vlan_present:1;
11098 : : };
11099 : :
11100 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
11101 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
11102 : : "set");
11103 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
11104 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
11105 : : "mplsogre_decap");
11106 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
11107 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11108 : : mplsogre, "mplsogre_decap-with-vlan");
11109 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
11110 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11111 : : pos_token, "ip-version");
11112 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
11113 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11114 : : ip_version, "ipv4#ipv6");
11115 : :
11116 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
11117 : : __rte_unused struct cmdline *cl,
11118 : : __rte_unused void *data)
11119 : : {
11120 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
11121 : :
11122 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
11123 : 0 : mplsogre_decap_conf.select_vlan = 0;
11124 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
11125 : 0 : mplsogre_decap_conf.select_vlan = 1;
11126 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11127 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
11128 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11129 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
11130 : 0 : }
11131 : :
11132 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
11133 : : .f = cmd_set_mplsogre_decap_parsed,
11134 : : .data = NULL,
11135 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
11136 : : .tokens = {
11137 : : (void *)&cmd_set_mplsogre_decap_set,
11138 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
11139 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11140 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11141 : : NULL,
11142 : : },
11143 : : };
11144 : :
11145 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
11146 : : .f = cmd_set_mplsogre_decap_parsed,
11147 : : .data = NULL,
11148 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
11149 : : .tokens = {
11150 : : (void *)&cmd_set_mplsogre_decap_set,
11151 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
11152 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11153 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11154 : : NULL,
11155 : : },
11156 : : };
11157 : :
11158 : : /** Set MPLSoUDP encapsulation details */
11159 : : struct cmd_set_mplsoudp_encap_result {
11160 : : cmdline_fixed_string_t set;
11161 : : cmdline_fixed_string_t mplsoudp;
11162 : : cmdline_fixed_string_t pos_token;
11163 : : cmdline_fixed_string_t ip_version;
11164 : : uint32_t vlan_present:1;
11165 : : uint32_t label;
11166 : : uint16_t udp_src;
11167 : : uint16_t udp_dst;
11168 : : cmdline_ipaddr_t ip_src;
11169 : : cmdline_ipaddr_t ip_dst;
11170 : : uint16_t tci;
11171 : : struct rte_ether_addr eth_src;
11172 : : struct rte_ether_addr eth_dst;
11173 : : };
11174 : :
11175 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
11176 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
11177 : : "set");
11178 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
11179 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
11180 : : "mplsoudp_encap");
11181 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
11182 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11183 : : mplsoudp, "mplsoudp_encap-with-vlan");
11184 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
11185 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11186 : : pos_token, "ip-version");
11187 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
11188 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11189 : : ip_version, "ipv4#ipv6");
11190 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
11191 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11192 : : pos_token, "label");
11193 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
11194 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
11195 : : RTE_UINT32);
11196 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
11197 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11198 : : pos_token, "udp-src");
11199 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
11200 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
11201 : : RTE_UINT16);
11202 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
11203 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11204 : : pos_token, "udp-dst");
11205 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
11206 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
11207 : : RTE_UINT16);
11208 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
11209 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11210 : : pos_token, "ip-src");
11211 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
11212 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
11213 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
11214 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11215 : : pos_token, "ip-dst");
11216 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
11217 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
11218 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
11219 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11220 : : pos_token, "vlan-tci");
11221 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
11222 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
11223 : : RTE_UINT16);
11224 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
11225 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11226 : : pos_token, "eth-src");
11227 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
11228 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11229 : : eth_src);
11230 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
11231 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11232 : : pos_token, "eth-dst");
11233 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
11234 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11235 : : eth_dst);
11236 : :
11237 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
11238 : : __rte_unused struct cmdline *cl,
11239 : : __rte_unused void *data)
11240 : : {
11241 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
11242 : : union {
11243 : : uint32_t mplsoudp_label;
11244 : : uint8_t label[4];
11245 : : } id = {
11246 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
11247 : : };
11248 : :
11249 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
11250 : 0 : mplsoudp_encap_conf.select_vlan = 0;
11251 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
11252 : 0 : mplsoudp_encap_conf.select_vlan = 1;
11253 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11254 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
11255 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11256 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
11257 : : else
11258 : : return;
11259 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
11260 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
11261 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
11262 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
11263 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
11264 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
11265 : : } else {
11266 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
11267 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
11268 : : }
11269 : 0 : if (mplsoudp_encap_conf.select_vlan)
11270 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11271 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
11272 : : RTE_ETHER_ADDR_LEN);
11273 : : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11274 : : RTE_ETHER_ADDR_LEN);
11275 : : }
11276 : :
11277 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
11278 : : .f = cmd_set_mplsoudp_encap_parsed,
11279 : : .data = NULL,
11280 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
11281 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
11282 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
11283 : : .tokens = {
11284 : : (void *)&cmd_set_mplsoudp_encap_set,
11285 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
11286 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11287 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11288 : : (void *)&cmd_set_mplsoudp_encap_label,
11289 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11290 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11291 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11292 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11293 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11294 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11295 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11296 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11297 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11298 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11299 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11300 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11301 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11302 : : NULL,
11303 : : },
11304 : : };
11305 : :
11306 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
11307 : : .f = cmd_set_mplsoudp_encap_parsed,
11308 : : .data = NULL,
11309 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
11310 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
11311 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
11312 : : " eth-src <eth-src> eth-dst <eth-dst>",
11313 : : .tokens = {
11314 : : (void *)&cmd_set_mplsoudp_encap_set,
11315 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
11316 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11317 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11318 : : (void *)&cmd_set_mplsoudp_encap_label,
11319 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11320 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11321 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11322 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11323 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11324 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11325 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11326 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11327 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11328 : : (void *)&cmd_set_mplsoudp_encap_vlan,
11329 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
11330 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11331 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11332 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11333 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11334 : : NULL,
11335 : : },
11336 : : };
11337 : :
11338 : : /** Set MPLSoUDP decapsulation details */
11339 : : struct cmd_set_mplsoudp_decap_result {
11340 : : cmdline_fixed_string_t set;
11341 : : cmdline_fixed_string_t mplsoudp;
11342 : : cmdline_fixed_string_t pos_token;
11343 : : cmdline_fixed_string_t ip_version;
11344 : : uint32_t vlan_present:1;
11345 : : };
11346 : :
11347 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
11348 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
11349 : : "set");
11350 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
11351 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
11352 : : "mplsoudp_decap");
11353 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
11354 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11355 : : mplsoudp, "mplsoudp_decap-with-vlan");
11356 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
11357 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11358 : : pos_token, "ip-version");
11359 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
11360 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11361 : : ip_version, "ipv4#ipv6");
11362 : :
11363 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
11364 : : __rte_unused struct cmdline *cl,
11365 : : __rte_unused void *data)
11366 : : {
11367 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
11368 : :
11369 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
11370 : 0 : mplsoudp_decap_conf.select_vlan = 0;
11371 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
11372 : 0 : mplsoudp_decap_conf.select_vlan = 1;
11373 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11374 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
11375 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11376 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
11377 : 0 : }
11378 : :
11379 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
11380 : : .f = cmd_set_mplsoudp_decap_parsed,
11381 : : .data = NULL,
11382 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
11383 : : .tokens = {
11384 : : (void *)&cmd_set_mplsoudp_decap_set,
11385 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
11386 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11387 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11388 : : NULL,
11389 : : },
11390 : : };
11391 : :
11392 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
11393 : : .f = cmd_set_mplsoudp_decap_parsed,
11394 : : .data = NULL,
11395 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
11396 : : .tokens = {
11397 : : (void *)&cmd_set_mplsoudp_decap_set,
11398 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
11399 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11400 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11401 : : NULL,
11402 : : },
11403 : : };
11404 : :
11405 : : /** Set connection tracking object common details */
11406 : : struct cmd_set_conntrack_common_result {
11407 : : cmdline_fixed_string_t set;
11408 : : cmdline_fixed_string_t conntrack;
11409 : : cmdline_fixed_string_t common;
11410 : : cmdline_fixed_string_t peer;
11411 : : cmdline_fixed_string_t is_orig;
11412 : : cmdline_fixed_string_t enable;
11413 : : cmdline_fixed_string_t live;
11414 : : cmdline_fixed_string_t sack;
11415 : : cmdline_fixed_string_t cack;
11416 : : cmdline_fixed_string_t last_dir;
11417 : : cmdline_fixed_string_t liberal;
11418 : : cmdline_fixed_string_t state;
11419 : : cmdline_fixed_string_t max_ack_win;
11420 : : cmdline_fixed_string_t retrans;
11421 : : cmdline_fixed_string_t last_win;
11422 : : cmdline_fixed_string_t last_seq;
11423 : : cmdline_fixed_string_t last_ack;
11424 : : cmdline_fixed_string_t last_end;
11425 : : cmdline_fixed_string_t last_index;
11426 : : uint8_t stat;
11427 : : uint8_t factor;
11428 : : uint16_t peer_port;
11429 : : uint32_t is_original;
11430 : : uint32_t en;
11431 : : uint32_t is_live;
11432 : : uint32_t s_ack;
11433 : : uint32_t c_ack;
11434 : : uint32_t ld;
11435 : : uint32_t lb;
11436 : : uint8_t re_num;
11437 : : uint8_t li;
11438 : : uint16_t lw;
11439 : : uint32_t ls;
11440 : : uint32_t la;
11441 : : uint32_t le;
11442 : : };
11443 : :
11444 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
11445 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11446 : : set, "set");
11447 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
11448 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11449 : : conntrack, "conntrack");
11450 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
11451 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11452 : : common, "com");
11453 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
11454 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11455 : : peer, "peer");
11456 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
11457 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11458 : : peer_port, RTE_UINT16);
11459 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
11460 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11461 : : is_orig, "is_orig");
11462 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
11463 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11464 : : is_original, RTE_UINT32);
11465 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
11466 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11467 : : enable, "enable");
11468 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
11469 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11470 : : en, RTE_UINT32);
11471 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
11472 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11473 : : live, "live");
11474 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
11475 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11476 : : is_live, RTE_UINT32);
11477 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
11478 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11479 : : sack, "sack");
11480 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
11481 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11482 : : s_ack, RTE_UINT32);
11483 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
11484 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11485 : : cack, "cack");
11486 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
11487 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11488 : : c_ack, RTE_UINT32);
11489 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
11490 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11491 : : last_dir, "last_dir");
11492 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
11493 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11494 : : ld, RTE_UINT32);
11495 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
11496 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11497 : : liberal, "liberal");
11498 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
11499 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11500 : : lb, RTE_UINT32);
11501 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
11502 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11503 : : state, "state");
11504 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
11505 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11506 : : stat, RTE_UINT8);
11507 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
11508 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11509 : : max_ack_win, "max_ack_win");
11510 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
11511 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11512 : : factor, RTE_UINT8);
11513 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
11514 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11515 : : retrans, "r_lim");
11516 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
11517 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11518 : : re_num, RTE_UINT8);
11519 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
11520 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11521 : : last_win, "last_win");
11522 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
11523 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11524 : : lw, RTE_UINT16);
11525 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
11526 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11527 : : last_seq, "last_seq");
11528 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
11529 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11530 : : ls, RTE_UINT32);
11531 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
11532 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11533 : : last_ack, "last_ack");
11534 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
11535 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11536 : : la, RTE_UINT32);
11537 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
11538 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11539 : : last_end, "last_end");
11540 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
11541 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11542 : : le, RTE_UINT32);
11543 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
11544 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11545 : : last_index, "last_index");
11546 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
11547 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11548 : : li, RTE_UINT8);
11549 : :
11550 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
11551 : : __rte_unused struct cmdline *cl,
11552 : : __rte_unused void *data)
11553 : : {
11554 : : struct cmd_set_conntrack_common_result *res = parsed_result;
11555 : :
11556 : : /* No need to swap to big endian. */
11557 : 0 : conntrack_context.peer_port = res->peer_port;
11558 : 0 : conntrack_context.is_original_dir = res->is_original;
11559 : 0 : conntrack_context.enable = res->en;
11560 : 0 : conntrack_context.live_connection = res->is_live;
11561 : 0 : conntrack_context.selective_ack = res->s_ack;
11562 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
11563 : 0 : conntrack_context.last_direction = res->ld;
11564 : 0 : conntrack_context.liberal_mode = res->lb;
11565 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
11566 : 0 : conntrack_context.max_ack_window = res->factor;
11567 : 0 : conntrack_context.retransmission_limit = res->re_num;
11568 : 0 : conntrack_context.last_window = res->lw;
11569 : 0 : conntrack_context.last_index =
11570 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
11571 : 0 : conntrack_context.last_seq = res->ls;
11572 : 0 : conntrack_context.last_ack = res->la;
11573 : 0 : conntrack_context.last_end = res->le;
11574 : 0 : }
11575 : :
11576 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
11577 : : .f = cmd_set_conntrack_common_parsed,
11578 : : .data = NULL,
11579 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
11580 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
11581 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
11582 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
11583 : : " last_index <flag>",
11584 : : .tokens = {
11585 : : (void *)&cmd_set_conntrack_set,
11586 : : (void *)&cmd_set_conntrack_conntrack,
11587 : : (void *)&cmd_set_conntrack_common_com,
11588 : : (void *)&cmd_set_conntrack_common_peer,
11589 : : (void *)&cmd_set_conntrack_common_peer_value,
11590 : : (void *)&cmd_set_conntrack_common_is_orig,
11591 : : (void *)&cmd_set_conntrack_common_is_orig_value,
11592 : : (void *)&cmd_set_conntrack_common_enable,
11593 : : (void *)&cmd_set_conntrack_common_enable_value,
11594 : : (void *)&cmd_set_conntrack_common_live,
11595 : : (void *)&cmd_set_conntrack_common_live_value,
11596 : : (void *)&cmd_set_conntrack_common_sack,
11597 : : (void *)&cmd_set_conntrack_common_sack_value,
11598 : : (void *)&cmd_set_conntrack_common_cack,
11599 : : (void *)&cmd_set_conntrack_common_cack_value,
11600 : : (void *)&cmd_set_conntrack_common_last_dir,
11601 : : (void *)&cmd_set_conntrack_common_last_dir_value,
11602 : : (void *)&cmd_set_conntrack_common_liberal,
11603 : : (void *)&cmd_set_conntrack_common_liberal_value,
11604 : : (void *)&cmd_set_conntrack_common_state,
11605 : : (void *)&cmd_set_conntrack_common_state_value,
11606 : : (void *)&cmd_set_conntrack_common_max_ackwin,
11607 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
11608 : : (void *)&cmd_set_conntrack_common_retrans,
11609 : : (void *)&cmd_set_conntrack_common_retrans_value,
11610 : : (void *)&cmd_set_conntrack_common_last_win,
11611 : : (void *)&cmd_set_conntrack_common_last_win_value,
11612 : : (void *)&cmd_set_conntrack_common_last_seq,
11613 : : (void *)&cmd_set_conntrack_common_last_seq_value,
11614 : : (void *)&cmd_set_conntrack_common_last_ack,
11615 : : (void *)&cmd_set_conntrack_common_last_ack_value,
11616 : : (void *)&cmd_set_conntrack_common_last_end,
11617 : : (void *)&cmd_set_conntrack_common_last_end_value,
11618 : : (void *)&cmd_set_conntrack_common_last_index,
11619 : : (void *)&cmd_set_conntrack_common_last_index_value,
11620 : : NULL,
11621 : : },
11622 : : };
11623 : :
11624 : : /** Set connection tracking object both directions' details */
11625 : : struct cmd_set_conntrack_dir_result {
11626 : : cmdline_fixed_string_t set;
11627 : : cmdline_fixed_string_t conntrack;
11628 : : cmdline_fixed_string_t dir;
11629 : : cmdline_fixed_string_t scale;
11630 : : cmdline_fixed_string_t fin;
11631 : : cmdline_fixed_string_t ack_seen;
11632 : : cmdline_fixed_string_t unack;
11633 : : cmdline_fixed_string_t sent_end;
11634 : : cmdline_fixed_string_t reply_end;
11635 : : cmdline_fixed_string_t max_win;
11636 : : cmdline_fixed_string_t max_ack;
11637 : : uint32_t factor;
11638 : : uint32_t f;
11639 : : uint32_t as;
11640 : : uint32_t un;
11641 : : uint32_t se;
11642 : : uint32_t re;
11643 : : uint32_t mw;
11644 : : uint32_t ma;
11645 : : };
11646 : :
11647 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
11648 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11649 : : dir, "orig#rply");
11650 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
11651 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11652 : : scale, "scale");
11653 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
11654 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11655 : : factor, RTE_UINT32);
11656 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
11657 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11658 : : fin, "fin");
11659 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
11660 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11661 : : f, RTE_UINT32);
11662 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
11663 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11664 : : ack_seen, "acked");
11665 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
11666 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11667 : : as, RTE_UINT32);
11668 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
11669 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11670 : : unack, "unack_data");
11671 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
11672 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11673 : : un, RTE_UINT32);
11674 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
11675 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11676 : : sent_end, "sent_end");
11677 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
11678 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11679 : : se, RTE_UINT32);
11680 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
11681 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11682 : : reply_end, "reply_end");
11683 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
11684 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11685 : : re, RTE_UINT32);
11686 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
11687 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11688 : : max_win, "max_win");
11689 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
11690 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11691 : : mw, RTE_UINT32);
11692 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
11693 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11694 : : max_ack, "max_ack");
11695 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
11696 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11697 : : ma, RTE_UINT32);
11698 : :
11699 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
11700 : : __rte_unused struct cmdline *cl,
11701 : : __rte_unused void *data)
11702 : : {
11703 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
11704 : : struct rte_flow_tcp_dir_param *dir = NULL;
11705 : :
11706 : 0 : if (strcmp(res->dir, "orig") == 0)
11707 : : dir = &conntrack_context.original_dir;
11708 : 0 : else if (strcmp(res->dir, "rply") == 0)
11709 : : dir = &conntrack_context.reply_dir;
11710 : : else
11711 : : return;
11712 : 0 : dir->scale = res->factor;
11713 : 0 : dir->close_initiated = res->f;
11714 : 0 : dir->last_ack_seen = res->as;
11715 : 0 : dir->data_unacked = res->un;
11716 : 0 : dir->sent_end = res->se;
11717 : 0 : dir->reply_end = res->re;
11718 : 0 : dir->max_ack = res->ma;
11719 : 0 : dir->max_win = res->mw;
11720 : : }
11721 : :
11722 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
11723 : : .f = cmd_set_conntrack_dir_parsed,
11724 : : .data = NULL,
11725 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
11726 : : " acked <seen> unack_data <unack> sent_end <sent>"
11727 : : " reply_end <reply> max_win <win> max_ack <ack>",
11728 : : .tokens = {
11729 : : (void *)&cmd_set_conntrack_set,
11730 : : (void *)&cmd_set_conntrack_conntrack,
11731 : : (void *)&cmd_set_conntrack_dir_dir,
11732 : : (void *)&cmd_set_conntrack_dir_scale,
11733 : : (void *)&cmd_set_conntrack_dir_scale_value,
11734 : : (void *)&cmd_set_conntrack_dir_fin,
11735 : : (void *)&cmd_set_conntrack_dir_fin_value,
11736 : : (void *)&cmd_set_conntrack_dir_ack,
11737 : : (void *)&cmd_set_conntrack_dir_ack_value,
11738 : : (void *)&cmd_set_conntrack_dir_unack_data,
11739 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
11740 : : (void *)&cmd_set_conntrack_dir_sent_end,
11741 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
11742 : : (void *)&cmd_set_conntrack_dir_reply_end,
11743 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
11744 : : (void *)&cmd_set_conntrack_dir_max_win,
11745 : : (void *)&cmd_set_conntrack_dir_max_win_value,
11746 : : (void *)&cmd_set_conntrack_dir_max_ack,
11747 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
11748 : : NULL,
11749 : : },
11750 : : };
11751 : :
11752 : : /* show vf stats */
11753 : :
11754 : : /* Common result structure for show vf stats */
11755 : : struct cmd_show_vf_stats_result {
11756 : : cmdline_fixed_string_t show;
11757 : : cmdline_fixed_string_t vf;
11758 : : cmdline_fixed_string_t stats;
11759 : : portid_t port_id;
11760 : : uint16_t vf_id;
11761 : : };
11762 : :
11763 : : /* Common CLI fields show vf stats*/
11764 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
11765 : : TOKEN_STRING_INITIALIZER
11766 : : (struct cmd_show_vf_stats_result,
11767 : : show, "show");
11768 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
11769 : : TOKEN_STRING_INITIALIZER
11770 : : (struct cmd_show_vf_stats_result,
11771 : : vf, "vf");
11772 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
11773 : : TOKEN_STRING_INITIALIZER
11774 : : (struct cmd_show_vf_stats_result,
11775 : : stats, "stats");
11776 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
11777 : : TOKEN_NUM_INITIALIZER
11778 : : (struct cmd_show_vf_stats_result,
11779 : : port_id, RTE_UINT16);
11780 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
11781 : : TOKEN_NUM_INITIALIZER
11782 : : (struct cmd_show_vf_stats_result,
11783 : : vf_id, RTE_UINT16);
11784 : :
11785 : : static void
11786 : 0 : cmd_show_vf_stats_parsed(
11787 : : void *parsed_result,
11788 : : __rte_unused struct cmdline *cl,
11789 : : __rte_unused void *data)
11790 : : {
11791 : : struct cmd_show_vf_stats_result *res = parsed_result;
11792 : : struct rte_eth_stats stats;
11793 : : int ret = -ENOTSUP;
11794 : : static const char *nic_stats_border = "########################";
11795 : :
11796 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11797 : 0 : return;
11798 : :
11799 : : memset(&stats, 0, sizeof(stats));
11800 : :
11801 : : #ifdef RTE_NET_I40E
11802 : : if (ret == -ENOTSUP)
11803 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
11804 : 0 : res->vf_id,
11805 : : &stats);
11806 : : #endif
11807 : : #ifdef RTE_NET_BNXT
11808 : 0 : if (ret == -ENOTSUP)
11809 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
11810 : 0 : res->vf_id,
11811 : : &stats);
11812 : : #endif
11813 : :
11814 : 0 : switch (ret) {
11815 : : case 0:
11816 : : break;
11817 : 0 : case -EINVAL:
11818 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11819 : : break;
11820 : 0 : case -ENODEV:
11821 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11822 : : break;
11823 : 0 : case -ENOTSUP:
11824 : 0 : fprintf(stderr, "function not implemented\n");
11825 : : break;
11826 : 0 : default:
11827 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11828 : : }
11829 : :
11830 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
11831 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
11832 : :
11833 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
11834 : : "%-"PRIu64"\n",
11835 : : stats.ipackets, stats.imissed, stats.ibytes);
11836 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
11837 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
11838 : : stats.rx_nombuf);
11839 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
11840 : : "%-"PRIu64"\n",
11841 : : stats.opackets, stats.oerrors, stats.obytes);
11842 : :
11843 : 0 : printf(" %s############################%s\n",
11844 : : nic_stats_border, nic_stats_border);
11845 : : }
11846 : :
11847 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
11848 : : .f = cmd_show_vf_stats_parsed,
11849 : : .data = NULL,
11850 : : .help_str = "show vf stats <port_id> <vf_id>",
11851 : : .tokens = {
11852 : : (void *)&cmd_show_vf_stats_show,
11853 : : (void *)&cmd_show_vf_stats_vf,
11854 : : (void *)&cmd_show_vf_stats_stats,
11855 : : (void *)&cmd_show_vf_stats_port_id,
11856 : : (void *)&cmd_show_vf_stats_vf_id,
11857 : : NULL,
11858 : : },
11859 : : };
11860 : :
11861 : : /* clear vf stats */
11862 : :
11863 : : /* Common result structure for clear vf stats */
11864 : : struct cmd_clear_vf_stats_result {
11865 : : cmdline_fixed_string_t clear;
11866 : : cmdline_fixed_string_t vf;
11867 : : cmdline_fixed_string_t stats;
11868 : : portid_t port_id;
11869 : : uint16_t vf_id;
11870 : : };
11871 : :
11872 : : /* Common CLI fields clear vf stats*/
11873 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
11874 : : TOKEN_STRING_INITIALIZER
11875 : : (struct cmd_clear_vf_stats_result,
11876 : : clear, "clear");
11877 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
11878 : : TOKEN_STRING_INITIALIZER
11879 : : (struct cmd_clear_vf_stats_result,
11880 : : vf, "vf");
11881 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
11882 : : TOKEN_STRING_INITIALIZER
11883 : : (struct cmd_clear_vf_stats_result,
11884 : : stats, "stats");
11885 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
11886 : : TOKEN_NUM_INITIALIZER
11887 : : (struct cmd_clear_vf_stats_result,
11888 : : port_id, RTE_UINT16);
11889 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
11890 : : TOKEN_NUM_INITIALIZER
11891 : : (struct cmd_clear_vf_stats_result,
11892 : : vf_id, RTE_UINT16);
11893 : :
11894 : : static void
11895 : 0 : cmd_clear_vf_stats_parsed(
11896 : : void *parsed_result,
11897 : : __rte_unused struct cmdline *cl,
11898 : : __rte_unused void *data)
11899 : : {
11900 : : struct cmd_clear_vf_stats_result *res = parsed_result;
11901 : : int ret = -ENOTSUP;
11902 : :
11903 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11904 : : return;
11905 : :
11906 : : #ifdef RTE_NET_I40E
11907 : : if (ret == -ENOTSUP)
11908 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
11909 : 0 : res->vf_id);
11910 : : #endif
11911 : : #ifdef RTE_NET_BNXT
11912 : 0 : if (ret == -ENOTSUP)
11913 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
11914 : 0 : res->vf_id);
11915 : : #endif
11916 : :
11917 : 0 : switch (ret) {
11918 : : case 0:
11919 : : break;
11920 : 0 : case -EINVAL:
11921 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11922 : : break;
11923 : 0 : case -ENODEV:
11924 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11925 : : break;
11926 : 0 : case -ENOTSUP:
11927 : 0 : fprintf(stderr, "function not implemented\n");
11928 : : break;
11929 : 0 : default:
11930 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11931 : : }
11932 : : }
11933 : :
11934 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
11935 : : .f = cmd_clear_vf_stats_parsed,
11936 : : .data = NULL,
11937 : : .help_str = "clear vf stats <port_id> <vf_id>",
11938 : : .tokens = {
11939 : : (void *)&cmd_clear_vf_stats_clear,
11940 : : (void *)&cmd_clear_vf_stats_vf,
11941 : : (void *)&cmd_clear_vf_stats_stats,
11942 : : (void *)&cmd_clear_vf_stats_port_id,
11943 : : (void *)&cmd_clear_vf_stats_vf_id,
11944 : : NULL,
11945 : : },
11946 : : };
11947 : :
11948 : : /* Common result structure for file commands */
11949 : : struct cmd_cmdfile_result {
11950 : : cmdline_fixed_string_t load;
11951 : : cmdline_fixed_string_t filename;
11952 : : };
11953 : :
11954 : : /* Common CLI fields for file commands */
11955 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
11956 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
11957 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
11958 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
11959 : :
11960 : : static void
11961 : 0 : cmd_load_from_file_parsed(
11962 : : void *parsed_result,
11963 : : __rte_unused struct cmdline *cl,
11964 : : __rte_unused void *data)
11965 : : {
11966 : : struct cmd_cmdfile_result *res = parsed_result;
11967 : :
11968 : 0 : if (cmdline_read_from_file(res->filename, false) != 0) {
11969 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
11970 : : }
11971 : 0 : }
11972 : :
11973 : : static cmdline_parse_inst_t cmd_load_from_file = {
11974 : : .f = cmd_load_from_file_parsed,
11975 : : .data = NULL,
11976 : : .help_str = "load <filename>",
11977 : : .tokens = {
11978 : : (void *)&cmd_load_cmdfile,
11979 : : (void *)&cmd_load_cmdfile_filename,
11980 : : NULL,
11981 : : },
11982 : : };
11983 : :
11984 : : /* command to load a file with echoing commands */
11985 : : struct cmd_load_echo_result {
11986 : : cmdline_fixed_string_t load_echo;
11987 : : cmdline_fixed_string_t filename;
11988 : : };
11989 : :
11990 : : /* CLI fields for file load with echo command */
11991 : : static cmdline_parse_token_string_t cmd_load_echo =
11992 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, load_echo, "load_echo");
11993 : : static cmdline_parse_token_string_t cmd_load_echo_filename =
11994 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, filename, NULL);
11995 : :
11996 : : static void
11997 : 0 : cmd_load_echo_file_parsed(
11998 : : void *parsed_result,
11999 : : __rte_unused struct cmdline *cl,
12000 : : __rte_unused void *data)
12001 : : {
12002 : : struct cmd_load_echo_result *res = parsed_result;
12003 : :
12004 : 0 : if (cmdline_read_from_file(res->filename, true) != 0)
12005 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
12006 : 0 : }
12007 : :
12008 : : static cmdline_parse_inst_t cmd_load_echo_file = {
12009 : : .f = cmd_load_echo_file_parsed,
12010 : : .data = NULL,
12011 : : .help_str = "load_echo <filename>",
12012 : : .tokens = {
12013 : : (void *)&cmd_load_echo,
12014 : : (void *)&cmd_load_echo_filename,
12015 : : NULL,
12016 : : },
12017 : : };
12018 : :
12019 : : /* Get Rx offloads capabilities */
12020 : : struct cmd_rx_offload_get_capa_result {
12021 : : cmdline_fixed_string_t show;
12022 : : cmdline_fixed_string_t port;
12023 : : portid_t port_id;
12024 : : cmdline_fixed_string_t rx_offload;
12025 : : cmdline_fixed_string_t capabilities;
12026 : : };
12027 : :
12028 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
12029 : : TOKEN_STRING_INITIALIZER
12030 : : (struct cmd_rx_offload_get_capa_result,
12031 : : show, "show");
12032 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
12033 : : TOKEN_STRING_INITIALIZER
12034 : : (struct cmd_rx_offload_get_capa_result,
12035 : : port, "port");
12036 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
12037 : : TOKEN_NUM_INITIALIZER
12038 : : (struct cmd_rx_offload_get_capa_result,
12039 : : port_id, RTE_UINT16);
12040 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
12041 : : TOKEN_STRING_INITIALIZER
12042 : : (struct cmd_rx_offload_get_capa_result,
12043 : : rx_offload, "rx_offload");
12044 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
12045 : : TOKEN_STRING_INITIALIZER
12046 : : (struct cmd_rx_offload_get_capa_result,
12047 : : capabilities, "capabilities");
12048 : :
12049 : : static void
12050 : 0 : print_rx_offloads(uint64_t offloads)
12051 : : {
12052 : : uint64_t single_offload;
12053 : : int begin;
12054 : : int end;
12055 : : int bit;
12056 : :
12057 : 0 : if (offloads == 0)
12058 : : return;
12059 : :
12060 : : begin = rte_ctz64(offloads);
12061 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12062 : :
12063 : 0 : single_offload = 1ULL << begin;
12064 : 0 : for (bit = begin; bit < end; bit++) {
12065 : 0 : if (offloads & single_offload)
12066 : 0 : printf(" %s",
12067 : : rte_eth_dev_rx_offload_name(single_offload));
12068 : 0 : single_offload <<= 1;
12069 : : }
12070 : : }
12071 : :
12072 : : static void
12073 : 0 : cmd_rx_offload_get_capa_parsed(
12074 : : void *parsed_result,
12075 : : __rte_unused struct cmdline *cl,
12076 : : __rte_unused void *data)
12077 : : {
12078 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
12079 : : struct rte_eth_dev_info dev_info;
12080 : 0 : portid_t port_id = res->port_id;
12081 : : uint64_t queue_offloads;
12082 : : uint64_t port_offloads;
12083 : : int ret;
12084 : :
12085 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12086 : 0 : if (ret != 0)
12087 : 0 : return;
12088 : :
12089 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
12090 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
12091 : :
12092 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
12093 : : printf(" Per Queue :");
12094 : 0 : print_rx_offloads(queue_offloads);
12095 : :
12096 : : printf("\n");
12097 : : printf(" Per Port :");
12098 : 0 : print_rx_offloads(port_offloads);
12099 : : printf("\n\n");
12100 : : }
12101 : :
12102 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
12103 : : .f = cmd_rx_offload_get_capa_parsed,
12104 : : .data = NULL,
12105 : : .help_str = "show port <port_id> rx_offload capabilities",
12106 : : .tokens = {
12107 : : (void *)&cmd_rx_offload_get_capa_show,
12108 : : (void *)&cmd_rx_offload_get_capa_port,
12109 : : (void *)&cmd_rx_offload_get_capa_port_id,
12110 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
12111 : : (void *)&cmd_rx_offload_get_capa_capabilities,
12112 : : NULL,
12113 : : }
12114 : : };
12115 : :
12116 : : /* Get Rx offloads configuration */
12117 : : struct cmd_rx_offload_get_configuration_result {
12118 : : cmdline_fixed_string_t show;
12119 : : cmdline_fixed_string_t port;
12120 : : portid_t port_id;
12121 : : cmdline_fixed_string_t rx_offload;
12122 : : cmdline_fixed_string_t configuration;
12123 : : };
12124 : :
12125 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
12126 : : TOKEN_STRING_INITIALIZER
12127 : : (struct cmd_rx_offload_get_configuration_result,
12128 : : show, "show");
12129 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
12130 : : TOKEN_STRING_INITIALIZER
12131 : : (struct cmd_rx_offload_get_configuration_result,
12132 : : port, "port");
12133 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
12134 : : TOKEN_NUM_INITIALIZER
12135 : : (struct cmd_rx_offload_get_configuration_result,
12136 : : port_id, RTE_UINT16);
12137 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
12138 : : TOKEN_STRING_INITIALIZER
12139 : : (struct cmd_rx_offload_get_configuration_result,
12140 : : rx_offload, "rx_offload");
12141 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
12142 : : TOKEN_STRING_INITIALIZER
12143 : : (struct cmd_rx_offload_get_configuration_result,
12144 : : configuration, "configuration");
12145 : :
12146 : : static void
12147 : 0 : cmd_rx_offload_get_configuration_parsed(
12148 : : void *parsed_result,
12149 : : __rte_unused struct cmdline *cl,
12150 : : __rte_unused void *data)
12151 : : {
12152 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
12153 : : struct rte_eth_dev_info dev_info;
12154 : 0 : portid_t port_id = res->port_id;
12155 : : struct rte_port *port;
12156 : : struct rte_eth_conf dev_conf;
12157 : : uint64_t port_offloads;
12158 : : uint64_t queue_offloads;
12159 : : uint16_t nb_rx_queues;
12160 : : int q;
12161 : : int ret;
12162 : :
12163 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12164 : 0 : if (ret != 0)
12165 : 0 : return;
12166 : :
12167 : 0 : port = &ports[port_id];
12168 : : printf("Rx Offloading Configuration of port %d :\n", port_id);
12169 : :
12170 : 0 : port_offloads = dev_conf.rxmode.offloads;
12171 : : printf(" Port :");
12172 : 0 : print_rx_offloads(port_offloads);
12173 : : printf("\n");
12174 : :
12175 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12176 : 0 : if (ret != 0)
12177 : : return;
12178 : :
12179 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12180 : 0 : for (q = 0; q < nb_rx_queues; q++) {
12181 : 0 : queue_offloads = port->rxq[q].conf.offloads;
12182 : : printf(" Queue[%2d] :", q);
12183 : 0 : print_rx_offloads(queue_offloads);
12184 : : printf("\n");
12185 : : }
12186 : : printf("\n");
12187 : : }
12188 : :
12189 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
12190 : : .f = cmd_rx_offload_get_configuration_parsed,
12191 : : .data = NULL,
12192 : : .help_str = "show port <port_id> rx_offload configuration",
12193 : : .tokens = {
12194 : : (void *)&cmd_rx_offload_get_configuration_show,
12195 : : (void *)&cmd_rx_offload_get_configuration_port,
12196 : : (void *)&cmd_rx_offload_get_configuration_port_id,
12197 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
12198 : : (void *)&cmd_rx_offload_get_configuration_configuration,
12199 : : NULL,
12200 : : }
12201 : : };
12202 : :
12203 : : /* Enable/Disable a per port offloading */
12204 : : struct cmd_config_per_port_rx_offload_result {
12205 : : cmdline_fixed_string_t port;
12206 : : cmdline_fixed_string_t config;
12207 : : portid_t port_id;
12208 : : cmdline_fixed_string_t rx_offload;
12209 : : cmdline_fixed_string_t offload;
12210 : : cmdline_fixed_string_t on_off;
12211 : : };
12212 : :
12213 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
12214 : : TOKEN_STRING_INITIALIZER
12215 : : (struct cmd_config_per_port_rx_offload_result,
12216 : : port, "port");
12217 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
12218 : : TOKEN_STRING_INITIALIZER
12219 : : (struct cmd_config_per_port_rx_offload_result,
12220 : : config, "config");
12221 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
12222 : : TOKEN_NUM_INITIALIZER
12223 : : (struct cmd_config_per_port_rx_offload_result,
12224 : : port_id, RTE_UINT16);
12225 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
12226 : : TOKEN_STRING_INITIALIZER
12227 : : (struct cmd_config_per_port_rx_offload_result,
12228 : : rx_offload, "rx_offload");
12229 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
12230 : : TOKEN_STRING_INITIALIZER
12231 : : (struct cmd_config_per_port_rx_offload_result,
12232 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12233 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12234 : : "vlan_filter#vlan_extend#"
12235 : : "scatter#buffer_split#timestamp#security#"
12236 : : "keep_crc#rss_hash");
12237 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
12238 : : TOKEN_STRING_INITIALIZER
12239 : : (struct cmd_config_per_port_rx_offload_result,
12240 : : on_off, "on#off");
12241 : :
12242 : : static uint64_t
12243 : 0 : search_rx_offload(const char *name)
12244 : : {
12245 : : uint64_t single_offload;
12246 : : const char *single_name;
12247 : : int found = 0;
12248 : : unsigned int bit;
12249 : :
12250 : : single_offload = 1;
12251 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12252 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
12253 : 0 : if (!strcasecmp(single_name, name)) {
12254 : : found = 1;
12255 : : break;
12256 : : }
12257 : 0 : single_offload <<= 1;
12258 : : }
12259 : :
12260 : 0 : if (found)
12261 : 0 : return single_offload;
12262 : :
12263 : : return 0;
12264 : : }
12265 : :
12266 : : static void
12267 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
12268 : : {
12269 : : struct rte_eth_dev_info dev_info;
12270 : : struct rte_port *port;
12271 : : uint16_t nb_rx_queues;
12272 : : uint64_t offload;
12273 : : int q;
12274 : : int ret;
12275 : :
12276 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12277 : 0 : if (ret != 0)
12278 : 0 : return;
12279 : :
12280 : 0 : port = &ports[port_id];
12281 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12282 : 0 : fprintf(stderr,
12283 : : "Error: Can't config offload when Port %d is not stopped\n",
12284 : : port_id);
12285 : 0 : return;
12286 : : }
12287 : :
12288 : 0 : if (!strcmp(name, "all")) {
12289 : 0 : offload = dev_info.rx_offload_capa;
12290 : : } else {
12291 : 0 : offload = search_rx_offload(name);
12292 : 0 : if (offload == 0) {
12293 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12294 : 0 : return;
12295 : : }
12296 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
12297 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12298 : : port_id, name);
12299 : 0 : return;
12300 : : }
12301 : : }
12302 : :
12303 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12304 : 0 : if (on) {
12305 : 0 : port->dev_conf.rxmode.offloads |= offload;
12306 : 0 : for (q = 0; q < nb_rx_queues; q++)
12307 : 0 : port->rxq[q].conf.offloads |= offload;
12308 : : } else {
12309 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
12310 : 0 : for (q = 0; q < nb_rx_queues; q++)
12311 : 0 : port->rxq[q].conf.offloads &= ~offload;
12312 : : }
12313 : :
12314 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12315 : : }
12316 : :
12317 : : static void
12318 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
12319 : : __rte_unused struct cmdline *cl,
12320 : : __rte_unused void *data)
12321 : : {
12322 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
12323 : : bool on;
12324 : :
12325 : 0 : on = strcmp(res->on_off, "on") == 0;
12326 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
12327 : 0 : }
12328 : :
12329 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
12330 : : .f = cmd_config_per_port_rx_offload_parsed,
12331 : : .data = NULL,
12332 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
12333 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12334 : : "macsec_strip|vlan_filter|vlan_extend|"
12335 : : "scatter|buffer_split|timestamp|security|"
12336 : : "keep_crc|rss_hash on|off",
12337 : : .tokens = {
12338 : : (void *)&cmd_config_per_port_rx_offload_result_port,
12339 : : (void *)&cmd_config_per_port_rx_offload_result_config,
12340 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
12341 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
12342 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
12343 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
12344 : : NULL,
12345 : : }
12346 : : };
12347 : :
12348 : : /* Enable/Disable all port Rx offloading */
12349 : : struct cmd_config_all_port_rx_offload_result {
12350 : : cmdline_fixed_string_t port;
12351 : : cmdline_fixed_string_t config;
12352 : : cmdline_fixed_string_t port_all;
12353 : : cmdline_fixed_string_t rx_offload;
12354 : : cmdline_fixed_string_t offload;
12355 : : cmdline_fixed_string_t on_off;
12356 : : };
12357 : :
12358 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
12359 : : TOKEN_STRING_INITIALIZER
12360 : : (struct cmd_config_all_port_rx_offload_result,
12361 : : port, "port");
12362 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
12363 : : TOKEN_STRING_INITIALIZER
12364 : : (struct cmd_config_all_port_rx_offload_result,
12365 : : config, "config");
12366 : :
12367 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
12368 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
12369 : : port_all, "all");
12370 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
12371 : : TOKEN_STRING_INITIALIZER
12372 : : (struct cmd_config_all_port_rx_offload_result,
12373 : : rx_offload, "rx_offload");
12374 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
12375 : : TOKEN_STRING_INITIALIZER
12376 : : (struct cmd_config_all_port_rx_offload_result,
12377 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12378 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12379 : : "vlan_filter#vlan_extend#"
12380 : : "scatter#buffer_split#timestamp#security#"
12381 : : "keep_crc#rss_hash");
12382 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
12383 : : TOKEN_STRING_INITIALIZER
12384 : : (struct cmd_config_all_port_rx_offload_result,
12385 : : on_off, "on#off");
12386 : :
12387 : : static void
12388 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
12389 : : __rte_unused struct cmdline *cl,
12390 : : __rte_unused void *data)
12391 : : {
12392 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
12393 : : bool on_off;
12394 : : portid_t i;
12395 : :
12396 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12397 : 0 : RTE_ETH_FOREACH_DEV(i)
12398 : 0 : config_port_rx_offload(i, res->offload, on_off);
12399 : :
12400 : 0 : }
12401 : :
12402 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
12403 : : .f = cmd_config_all_port_rx_offload_parsed,
12404 : : .data = NULL,
12405 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
12406 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12407 : : "macsec_strip|vlan_filter|vlan_extend|"
12408 : : "scatter|buffer_split|timestamp|security|"
12409 : : "keep_crc|rss_hash on|off",
12410 : : .tokens = {
12411 : : (void *)&cmd_config_all_port_rx_offload_result_port,
12412 : : (void *)&cmd_config_all_port_rx_offload_result_config,
12413 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
12414 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
12415 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
12416 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
12417 : : NULL,
12418 : : }
12419 : : };
12420 : :
12421 : : /* Enable/Disable a per queue offloading */
12422 : : struct cmd_config_per_queue_rx_offload_result {
12423 : : cmdline_fixed_string_t port;
12424 : : portid_t port_id;
12425 : : cmdline_fixed_string_t rxq;
12426 : : uint16_t queue_id;
12427 : : cmdline_fixed_string_t rx_offload;
12428 : : cmdline_fixed_string_t offload;
12429 : : cmdline_fixed_string_t on_off;
12430 : : };
12431 : :
12432 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
12433 : : TOKEN_STRING_INITIALIZER
12434 : : (struct cmd_config_per_queue_rx_offload_result,
12435 : : port, "port");
12436 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
12437 : : TOKEN_NUM_INITIALIZER
12438 : : (struct cmd_config_per_queue_rx_offload_result,
12439 : : port_id, RTE_UINT16);
12440 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
12441 : : TOKEN_STRING_INITIALIZER
12442 : : (struct cmd_config_per_queue_rx_offload_result,
12443 : : rxq, "rxq");
12444 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
12445 : : TOKEN_NUM_INITIALIZER
12446 : : (struct cmd_config_per_queue_rx_offload_result,
12447 : : queue_id, RTE_UINT16);
12448 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
12449 : : TOKEN_STRING_INITIALIZER
12450 : : (struct cmd_config_per_queue_rx_offload_result,
12451 : : rx_offload, "rx_offload");
12452 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
12453 : : TOKEN_STRING_INITIALIZER
12454 : : (struct cmd_config_per_queue_rx_offload_result,
12455 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12456 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12457 : : "vlan_filter#vlan_extend#"
12458 : : "scatter#buffer_split#timestamp#security#keep_crc");
12459 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
12460 : : TOKEN_STRING_INITIALIZER
12461 : : (struct cmd_config_per_queue_rx_offload_result,
12462 : : on_off, "on#off");
12463 : :
12464 : : static void
12465 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
12466 : : __rte_unused struct cmdline *cl,
12467 : : __rte_unused void *data)
12468 : : {
12469 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
12470 : : struct rte_eth_dev_info dev_info;
12471 : 0 : portid_t port_id = res->port_id;
12472 : 0 : uint16_t queue_id = res->queue_id;
12473 : : struct rte_port *port;
12474 : : uint64_t offload;
12475 : : int ret;
12476 : :
12477 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12478 : 0 : if (ret != 0)
12479 : 0 : return;
12480 : :
12481 : 0 : port = &ports[port_id];
12482 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12483 : 0 : fprintf(stderr,
12484 : : "Error: Can't config offload when Port %d is not stopped\n",
12485 : : port_id);
12486 : 0 : return;
12487 : : }
12488 : :
12489 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
12490 : 0 : fprintf(stderr,
12491 : : "Error: input queue_id should be 0 ... %d\n",
12492 : 0 : dev_info.nb_rx_queues - 1);
12493 : 0 : return;
12494 : : }
12495 : :
12496 : 0 : if (!strcmp(res->offload, "all")) {
12497 : 0 : offload = dev_info.rx_queue_offload_capa;
12498 : : } else {
12499 : 0 : offload = search_rx_offload(res->offload);
12500 : 0 : if (offload == 0) {
12501 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12502 : 0 : return;
12503 : : }
12504 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
12505 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12506 : : port_id, res->offload);
12507 : 0 : return;
12508 : : }
12509 : : }
12510 : :
12511 : 0 : if (!strcmp(res->on_off, "on"))
12512 : 0 : port->rxq[queue_id].conf.offloads |= offload;
12513 : : else
12514 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
12515 : :
12516 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12517 : : }
12518 : :
12519 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
12520 : : .f = cmd_config_per_queue_rx_offload_parsed,
12521 : : .data = NULL,
12522 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
12523 : : "all|vlan_strip|ipv4_cksum|"
12524 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12525 : : "macsec_strip|vlan_filter|vlan_extend|"
12526 : : "scatter|buffer_split|timestamp|security|"
12527 : : "keep_crc on|off",
12528 : : .tokens = {
12529 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
12530 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
12531 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
12532 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
12533 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
12534 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
12535 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
12536 : : NULL,
12537 : : }
12538 : : };
12539 : :
12540 : : /* Get Tx offloads capabilities */
12541 : : struct cmd_tx_offload_get_capa_result {
12542 : : cmdline_fixed_string_t show;
12543 : : cmdline_fixed_string_t port;
12544 : : portid_t port_id;
12545 : : cmdline_fixed_string_t tx_offload;
12546 : : cmdline_fixed_string_t capabilities;
12547 : : };
12548 : :
12549 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
12550 : : TOKEN_STRING_INITIALIZER
12551 : : (struct cmd_tx_offload_get_capa_result,
12552 : : show, "show");
12553 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
12554 : : TOKEN_STRING_INITIALIZER
12555 : : (struct cmd_tx_offload_get_capa_result,
12556 : : port, "port");
12557 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
12558 : : TOKEN_NUM_INITIALIZER
12559 : : (struct cmd_tx_offload_get_capa_result,
12560 : : port_id, RTE_UINT16);
12561 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
12562 : : TOKEN_STRING_INITIALIZER
12563 : : (struct cmd_tx_offload_get_capa_result,
12564 : : tx_offload, "tx_offload");
12565 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
12566 : : TOKEN_STRING_INITIALIZER
12567 : : (struct cmd_tx_offload_get_capa_result,
12568 : : capabilities, "capabilities");
12569 : :
12570 : : static void
12571 : 0 : print_tx_offloads(uint64_t offloads)
12572 : : {
12573 : : uint64_t single_offload;
12574 : : int begin;
12575 : : int end;
12576 : : int bit;
12577 : :
12578 : 0 : if (offloads == 0)
12579 : : return;
12580 : :
12581 : : begin = rte_ctz64(offloads);
12582 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12583 : :
12584 : 0 : single_offload = 1ULL << begin;
12585 : 0 : for (bit = begin; bit < end; bit++) {
12586 : 0 : if (offloads & single_offload)
12587 : 0 : printf(" %s",
12588 : : rte_eth_dev_tx_offload_name(single_offload));
12589 : 0 : single_offload <<= 1;
12590 : : }
12591 : : }
12592 : :
12593 : : static void
12594 : 0 : cmd_tx_offload_get_capa_parsed(
12595 : : void *parsed_result,
12596 : : __rte_unused struct cmdline *cl,
12597 : : __rte_unused void *data)
12598 : : {
12599 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
12600 : : struct rte_eth_dev_info dev_info;
12601 : 0 : portid_t port_id = res->port_id;
12602 : : uint64_t queue_offloads;
12603 : : uint64_t port_offloads;
12604 : : int ret;
12605 : :
12606 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12607 : 0 : if (ret != 0)
12608 : 0 : return;
12609 : :
12610 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
12611 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
12612 : :
12613 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
12614 : : printf(" Per Queue :");
12615 : 0 : print_tx_offloads(queue_offloads);
12616 : :
12617 : : printf("\n");
12618 : : printf(" Per Port :");
12619 : 0 : print_tx_offloads(port_offloads);
12620 : : printf("\n\n");
12621 : : }
12622 : :
12623 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
12624 : : .f = cmd_tx_offload_get_capa_parsed,
12625 : : .data = NULL,
12626 : : .help_str = "show port <port_id> tx_offload capabilities",
12627 : : .tokens = {
12628 : : (void *)&cmd_tx_offload_get_capa_show,
12629 : : (void *)&cmd_tx_offload_get_capa_port,
12630 : : (void *)&cmd_tx_offload_get_capa_port_id,
12631 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
12632 : : (void *)&cmd_tx_offload_get_capa_capabilities,
12633 : : NULL,
12634 : : }
12635 : : };
12636 : :
12637 : : /* Get Tx offloads configuration */
12638 : : struct cmd_tx_offload_get_configuration_result {
12639 : : cmdline_fixed_string_t show;
12640 : : cmdline_fixed_string_t port;
12641 : : portid_t port_id;
12642 : : cmdline_fixed_string_t tx_offload;
12643 : : cmdline_fixed_string_t configuration;
12644 : : };
12645 : :
12646 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
12647 : : TOKEN_STRING_INITIALIZER
12648 : : (struct cmd_tx_offload_get_configuration_result,
12649 : : show, "show");
12650 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
12651 : : TOKEN_STRING_INITIALIZER
12652 : : (struct cmd_tx_offload_get_configuration_result,
12653 : : port, "port");
12654 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
12655 : : TOKEN_NUM_INITIALIZER
12656 : : (struct cmd_tx_offload_get_configuration_result,
12657 : : port_id, RTE_UINT16);
12658 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
12659 : : TOKEN_STRING_INITIALIZER
12660 : : (struct cmd_tx_offload_get_configuration_result,
12661 : : tx_offload, "tx_offload");
12662 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
12663 : : TOKEN_STRING_INITIALIZER
12664 : : (struct cmd_tx_offload_get_configuration_result,
12665 : : configuration, "configuration");
12666 : :
12667 : : static void
12668 : 0 : cmd_tx_offload_get_configuration_parsed(
12669 : : void *parsed_result,
12670 : : __rte_unused struct cmdline *cl,
12671 : : __rte_unused void *data)
12672 : : {
12673 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
12674 : : struct rte_eth_dev_info dev_info;
12675 : 0 : portid_t port_id = res->port_id;
12676 : : struct rte_port *port;
12677 : : struct rte_eth_conf dev_conf;
12678 : : uint64_t port_offloads;
12679 : : uint64_t queue_offloads;
12680 : : uint16_t nb_tx_queues;
12681 : : int q;
12682 : : int ret;
12683 : :
12684 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12685 : 0 : if (ret != 0)
12686 : 0 : return;
12687 : :
12688 : : printf("Tx Offloading Configuration of port %d :\n", port_id);
12689 : 0 : port = &ports[port_id];
12690 : 0 : port_offloads = dev_conf.txmode.offloads;
12691 : : printf(" Port :");
12692 : 0 : print_tx_offloads(port_offloads);
12693 : : printf("\n");
12694 : :
12695 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12696 : 0 : if (ret != 0)
12697 : : return;
12698 : :
12699 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12700 : 0 : for (q = 0; q < nb_tx_queues; q++) {
12701 : 0 : queue_offloads = port->txq[q].conf.offloads;
12702 : : printf(" Queue[%2d] :", q);
12703 : 0 : print_tx_offloads(queue_offloads);
12704 : : printf("\n");
12705 : : }
12706 : : printf("\n");
12707 : : }
12708 : :
12709 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
12710 : : .f = cmd_tx_offload_get_configuration_parsed,
12711 : : .data = NULL,
12712 : : .help_str = "show port <port_id> tx_offload configuration",
12713 : : .tokens = {
12714 : : (void *)&cmd_tx_offload_get_configuration_show,
12715 : : (void *)&cmd_tx_offload_get_configuration_port,
12716 : : (void *)&cmd_tx_offload_get_configuration_port_id,
12717 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
12718 : : (void *)&cmd_tx_offload_get_configuration_configuration,
12719 : : NULL,
12720 : : }
12721 : : };
12722 : :
12723 : : /* Enable/Disable a per port offloading */
12724 : : struct cmd_config_per_port_tx_offload_result {
12725 : : cmdline_fixed_string_t port;
12726 : : cmdline_fixed_string_t config;
12727 : : portid_t port_id;
12728 : : cmdline_fixed_string_t tx_offload;
12729 : : cmdline_fixed_string_t offload;
12730 : : cmdline_fixed_string_t on_off;
12731 : : };
12732 : :
12733 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
12734 : : TOKEN_STRING_INITIALIZER
12735 : : (struct cmd_config_per_port_tx_offload_result,
12736 : : port, "port");
12737 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
12738 : : TOKEN_STRING_INITIALIZER
12739 : : (struct cmd_config_per_port_tx_offload_result,
12740 : : config, "config");
12741 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
12742 : : TOKEN_NUM_INITIALIZER
12743 : : (struct cmd_config_per_port_tx_offload_result,
12744 : : port_id, RTE_UINT16);
12745 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
12746 : : TOKEN_STRING_INITIALIZER
12747 : : (struct cmd_config_per_port_tx_offload_result,
12748 : : tx_offload, "tx_offload");
12749 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
12750 : : TOKEN_STRING_INITIALIZER
12751 : : (struct cmd_config_per_port_tx_offload_result,
12752 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12753 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12754 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12755 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12756 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12757 : : "send_on_timestamp");
12758 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
12759 : : TOKEN_STRING_INITIALIZER
12760 : : (struct cmd_config_per_port_tx_offload_result,
12761 : : on_off, "on#off");
12762 : :
12763 : : static uint64_t
12764 : 0 : search_tx_offload(const char *name)
12765 : : {
12766 : : uint64_t single_offload;
12767 : : const char *single_name;
12768 : : int found = 0;
12769 : : unsigned int bit;
12770 : :
12771 : : single_offload = 1;
12772 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12773 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
12774 : 0 : if (single_name == NULL)
12775 : : break;
12776 : 0 : if (!strcasecmp(single_name, name)) {
12777 : : found = 1;
12778 : : break;
12779 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
12780 : : break;
12781 : 0 : single_offload <<= 1;
12782 : : }
12783 : :
12784 : 0 : if (found)
12785 : 0 : return single_offload;
12786 : :
12787 : : return 0;
12788 : : }
12789 : :
12790 : : static void
12791 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
12792 : : {
12793 : : struct rte_eth_dev_info dev_info;
12794 : : struct rte_port *port;
12795 : : uint16_t nb_tx_queues;
12796 : : uint64_t offload;
12797 : : int q;
12798 : : int ret;
12799 : :
12800 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12801 : 0 : if (ret != 0)
12802 : 0 : return;
12803 : :
12804 : 0 : port = &ports[port_id];
12805 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12806 : 0 : fprintf(stderr,
12807 : : "Error: Can't config offload when Port %d is not stopped\n",
12808 : : port_id);
12809 : 0 : return;
12810 : : }
12811 : :
12812 : 0 : if (!strcmp(name, "all")) {
12813 : 0 : offload = dev_info.tx_offload_capa;
12814 : : } else {
12815 : 0 : offload = search_tx_offload(name);
12816 : 0 : if (offload == 0) {
12817 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12818 : 0 : return;
12819 : : }
12820 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
12821 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12822 : : port_id, name);
12823 : 0 : return;
12824 : : }
12825 : : }
12826 : :
12827 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12828 : 0 : if (on) {
12829 : 0 : port->dev_conf.txmode.offloads |= offload;
12830 : 0 : for (q = 0; q < nb_tx_queues; q++)
12831 : 0 : port->txq[q].conf.offloads |= offload;
12832 : : } else {
12833 : 0 : port->dev_conf.txmode.offloads &= ~offload;
12834 : 0 : for (q = 0; q < nb_tx_queues; q++)
12835 : 0 : port->txq[q].conf.offloads &= ~offload;
12836 : : }
12837 : :
12838 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12839 : : }
12840 : :
12841 : : static void
12842 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
12843 : : __rte_unused struct cmdline *cl,
12844 : : __rte_unused void *data)
12845 : : {
12846 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
12847 : : bool on;
12848 : :
12849 : 0 : on = strcmp(res->on_off, "on") == 0;
12850 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
12851 : 0 : }
12852 : :
12853 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
12854 : : .f = cmd_config_per_port_tx_offload_parsed,
12855 : : .data = NULL,
12856 : : .help_str = "port config <port_id> tx_offload "
12857 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12858 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12859 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12860 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12861 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12862 : : "send_on_timestamp on|off",
12863 : : .tokens = {
12864 : : (void *)&cmd_config_per_port_tx_offload_result_port,
12865 : : (void *)&cmd_config_per_port_tx_offload_result_config,
12866 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
12867 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
12868 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
12869 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
12870 : : NULL,
12871 : : }
12872 : : };
12873 : :
12874 : : /* Enable/Disable all port Tx offloading */
12875 : : struct cmd_config_all_port_tx_offload_result {
12876 : : cmdline_fixed_string_t port;
12877 : : cmdline_fixed_string_t config;
12878 : : cmdline_fixed_string_t port_all;
12879 : : cmdline_fixed_string_t tx_offload;
12880 : : cmdline_fixed_string_t offload;
12881 : : cmdline_fixed_string_t on_off;
12882 : : };
12883 : :
12884 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
12885 : : TOKEN_STRING_INITIALIZER
12886 : : (struct cmd_config_all_port_tx_offload_result,
12887 : : port, "port");
12888 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
12889 : : TOKEN_STRING_INITIALIZER
12890 : : (struct cmd_config_all_port_tx_offload_result,
12891 : : config, "config");
12892 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
12893 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
12894 : : port_all, "all");
12895 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
12896 : : TOKEN_STRING_INITIALIZER
12897 : : (struct cmd_config_all_port_tx_offload_result,
12898 : : tx_offload, "tx_offload");
12899 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
12900 : : TOKEN_STRING_INITIALIZER
12901 : : (struct cmd_config_all_port_tx_offload_result,
12902 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12903 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12904 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12905 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12906 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12907 : : "send_on_timestamp");
12908 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
12909 : : TOKEN_STRING_INITIALIZER
12910 : : (struct cmd_config_all_port_tx_offload_result,
12911 : : on_off, "on#off");
12912 : :
12913 : : static void
12914 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
12915 : : __rte_unused struct cmdline *cl,
12916 : : __rte_unused void *data)
12917 : : {
12918 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
12919 : : portid_t i;
12920 : : bool on_off;
12921 : :
12922 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12923 : 0 : RTE_ETH_FOREACH_DEV(i)
12924 : 0 : config_port_tx_offload(i, res->offload, on_off);
12925 : 0 : }
12926 : :
12927 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
12928 : : .f = cmd_config_all_port_tx_offload_parsed,
12929 : : .data = NULL,
12930 : : .help_str = "port config all tx_offload "
12931 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12932 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12933 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12934 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12935 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12936 : : "send_on_timestamp on|off",
12937 : : .tokens = {
12938 : : (void *)&cmd_config_all_port_tx_offload_result_port,
12939 : : (void *)&cmd_config_all_port_tx_offload_result_config,
12940 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
12941 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
12942 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
12943 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
12944 : : NULL,
12945 : : }
12946 : : };
12947 : :
12948 : : /* Enable/Disable a per queue offloading */
12949 : : struct cmd_config_per_queue_tx_offload_result {
12950 : : cmdline_fixed_string_t port;
12951 : : portid_t port_id;
12952 : : cmdline_fixed_string_t txq;
12953 : : uint16_t queue_id;
12954 : : cmdline_fixed_string_t tx_offload;
12955 : : cmdline_fixed_string_t offload;
12956 : : cmdline_fixed_string_t on_off;
12957 : : };
12958 : :
12959 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
12960 : : TOKEN_STRING_INITIALIZER
12961 : : (struct cmd_config_per_queue_tx_offload_result,
12962 : : port, "port");
12963 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
12964 : : TOKEN_NUM_INITIALIZER
12965 : : (struct cmd_config_per_queue_tx_offload_result,
12966 : : port_id, RTE_UINT16);
12967 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
12968 : : TOKEN_STRING_INITIALIZER
12969 : : (struct cmd_config_per_queue_tx_offload_result,
12970 : : txq, "txq");
12971 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
12972 : : TOKEN_NUM_INITIALIZER
12973 : : (struct cmd_config_per_queue_tx_offload_result,
12974 : : queue_id, RTE_UINT16);
12975 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
12976 : : TOKEN_STRING_INITIALIZER
12977 : : (struct cmd_config_per_queue_tx_offload_result,
12978 : : tx_offload, "tx_offload");
12979 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
12980 : : TOKEN_STRING_INITIALIZER
12981 : : (struct cmd_config_per_queue_tx_offload_result,
12982 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12983 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12984 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12985 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12986 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
12987 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
12988 : : TOKEN_STRING_INITIALIZER
12989 : : (struct cmd_config_per_queue_tx_offload_result,
12990 : : on_off, "on#off");
12991 : :
12992 : : static void
12993 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
12994 : : __rte_unused struct cmdline *cl,
12995 : : __rte_unused void *data)
12996 : : {
12997 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
12998 : : struct rte_eth_dev_info dev_info;
12999 : 0 : portid_t port_id = res->port_id;
13000 : 0 : uint16_t queue_id = res->queue_id;
13001 : : struct rte_port *port;
13002 : : uint64_t offload;
13003 : : int ret;
13004 : :
13005 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
13006 : 0 : if (ret != 0)
13007 : 0 : return;
13008 : :
13009 : 0 : port = &ports[port_id];
13010 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
13011 : 0 : fprintf(stderr,
13012 : : "Error: Can't config offload when Port %d is not stopped\n",
13013 : : port_id);
13014 : 0 : return;
13015 : : }
13016 : :
13017 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
13018 : 0 : fprintf(stderr,
13019 : : "Error: input queue_id should be 0 ... %d\n",
13020 : 0 : dev_info.nb_tx_queues - 1);
13021 : 0 : return;
13022 : : }
13023 : :
13024 : 0 : if (!strcmp(res->offload, "all")) {
13025 : 0 : offload = dev_info.tx_queue_offload_capa;
13026 : : } else {
13027 : 0 : offload = search_tx_offload(res->offload);
13028 : 0 : if (offload == 0) {
13029 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
13030 : 0 : return;
13031 : : }
13032 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
13033 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
13034 : : port_id, res->offload);
13035 : 0 : return;
13036 : : }
13037 : : }
13038 : :
13039 : 0 : if (!strcmp(res->on_off, "on"))
13040 : 0 : port->txq[queue_id].conf.offloads |= offload;
13041 : : else
13042 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
13043 : :
13044 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
13045 : : }
13046 : :
13047 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
13048 : : .f = cmd_config_per_queue_tx_offload_parsed,
13049 : : .data = NULL,
13050 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
13051 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
13052 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
13053 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
13054 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
13055 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
13056 : : "on|off",
13057 : : .tokens = {
13058 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
13059 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
13060 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
13061 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
13062 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
13063 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
13064 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
13065 : : NULL,
13066 : : }
13067 : : };
13068 : :
13069 : : /* *** configure tx_metadata for specific port *** */
13070 : : struct cmd_config_tx_metadata_specific_result {
13071 : : cmdline_fixed_string_t port;
13072 : : cmdline_fixed_string_t keyword;
13073 : : uint16_t port_id;
13074 : : cmdline_fixed_string_t item;
13075 : : uint32_t value;
13076 : : };
13077 : :
13078 : : static void
13079 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
13080 : : __rte_unused struct cmdline *cl,
13081 : : __rte_unused void *data)
13082 : : {
13083 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
13084 : :
13085 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13086 : : return;
13087 : 0 : ports[res->port_id].tx_metadata = res->value;
13088 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
13089 : 0 : if (ports[res->port_id].tx_metadata)
13090 : 0 : add_tx_md_callback(res->port_id);
13091 : : else
13092 : 0 : remove_tx_md_callback(res->port_id);
13093 : 0 : rte_flow_dynf_metadata_register();
13094 : : }
13095 : :
13096 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
13097 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13098 : : port, "port");
13099 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
13100 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13101 : : keyword, "config");
13102 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
13103 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13104 : : port_id, RTE_UINT16);
13105 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
13106 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13107 : : item, "tx_metadata");
13108 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
13109 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13110 : : value, RTE_UINT32);
13111 : :
13112 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
13113 : : .f = cmd_config_tx_metadata_specific_parsed,
13114 : : .data = NULL,
13115 : : .help_str = "port config <port_id> tx_metadata <value>",
13116 : : .tokens = {
13117 : : (void *)&cmd_config_tx_metadata_specific_port,
13118 : : (void *)&cmd_config_tx_metadata_specific_keyword,
13119 : : (void *)&cmd_config_tx_metadata_specific_id,
13120 : : (void *)&cmd_config_tx_metadata_specific_item,
13121 : : (void *)&cmd_config_tx_metadata_specific_value,
13122 : : NULL,
13123 : : },
13124 : : };
13125 : :
13126 : : /* *** set dynf *** */
13127 : : struct cmd_config_tx_dynf_specific_result {
13128 : : cmdline_fixed_string_t port;
13129 : : cmdline_fixed_string_t keyword;
13130 : : uint16_t port_id;
13131 : : cmdline_fixed_string_t item;
13132 : : cmdline_fixed_string_t name;
13133 : : cmdline_fixed_string_t value;
13134 : : };
13135 : :
13136 : : static void
13137 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
13138 : : __rte_unused struct cmdline *cl,
13139 : : __rte_unused void *data)
13140 : : {
13141 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
13142 : : struct rte_mbuf_dynflag desc_flag;
13143 : : int flag;
13144 : : uint64_t old_port_flags;
13145 : :
13146 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13147 : 0 : return;
13148 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
13149 : 0 : if (flag <= 0) {
13150 : 0 : if (strlcpy(desc_flag.name, res->name,
13151 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
13152 : 0 : fprintf(stderr, "Flag name too long\n");
13153 : 0 : return;
13154 : : }
13155 : 0 : desc_flag.flags = 0;
13156 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
13157 : 0 : if (flag < 0) {
13158 : 0 : fprintf(stderr, "Can't register flag\n");
13159 : 0 : return;
13160 : : }
13161 : 0 : strcpy(dynf_names[flag], desc_flag.name);
13162 : : }
13163 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
13164 : 0 : if (!strcmp(res->value, "set")) {
13165 : 0 : ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
13166 : 0 : if (old_port_flags == 0)
13167 : 0 : add_tx_dynf_callback(res->port_id);
13168 : : } else {
13169 : 0 : ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
13170 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
13171 : 0 : remove_tx_dynf_callback(res->port_id);
13172 : : }
13173 : : }
13174 : :
13175 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
13176 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13177 : : keyword, "port");
13178 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
13179 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13180 : : keyword, "config");
13181 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
13182 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13183 : : port_id, RTE_UINT16);
13184 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
13185 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13186 : : item, "dynf");
13187 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
13188 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13189 : : name, NULL);
13190 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
13191 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13192 : : value, "set#clear");
13193 : :
13194 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
13195 : : .f = cmd_config_dynf_specific_parsed,
13196 : : .data = NULL,
13197 : : .help_str = "port config <port id> dynf <name> set|clear",
13198 : : .tokens = {
13199 : : (void *)&cmd_config_tx_dynf_specific_port,
13200 : : (void *)&cmd_config_tx_dynf_specific_keyword,
13201 : : (void *)&cmd_config_tx_dynf_specific_port_id,
13202 : : (void *)&cmd_config_tx_dynf_specific_item,
13203 : : (void *)&cmd_config_tx_dynf_specific_name,
13204 : : (void *)&cmd_config_tx_dynf_specific_value,
13205 : : NULL,
13206 : : },
13207 : : };
13208 : :
13209 : : /* *** display tx_metadata per port configuration *** */
13210 : : struct cmd_show_tx_metadata_result {
13211 : : cmdline_fixed_string_t cmd_show;
13212 : : cmdline_fixed_string_t cmd_port;
13213 : : cmdline_fixed_string_t cmd_keyword;
13214 : : portid_t cmd_pid;
13215 : : };
13216 : :
13217 : : static void
13218 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
13219 : : __rte_unused struct cmdline *cl,
13220 : : __rte_unused void *data)
13221 : : {
13222 : : struct cmd_show_tx_metadata_result *res = parsed_result;
13223 : :
13224 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13225 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
13226 : 0 : return;
13227 : : }
13228 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
13229 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
13230 : 0 : ports[res->cmd_pid].tx_metadata);
13231 : : }
13232 : : }
13233 : :
13234 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
13235 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13236 : : cmd_show, "show");
13237 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
13238 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13239 : : cmd_port, "port");
13240 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
13241 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
13242 : : cmd_pid, RTE_UINT16);
13243 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
13244 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13245 : : cmd_keyword, "tx_metadata");
13246 : :
13247 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
13248 : : .f = cmd_show_tx_metadata_parsed,
13249 : : .data = NULL,
13250 : : .help_str = "show port <port_id> tx_metadata",
13251 : : .tokens = {
13252 : : (void *)&cmd_show_tx_metadata_show,
13253 : : (void *)&cmd_show_tx_metadata_port,
13254 : : (void *)&cmd_show_tx_metadata_pid,
13255 : : (void *)&cmd_show_tx_metadata_keyword,
13256 : : NULL,
13257 : : },
13258 : : };
13259 : :
13260 : : /* *** show fec capability per port configuration *** */
13261 : : struct cmd_show_fec_capability_result {
13262 : : cmdline_fixed_string_t cmd_show;
13263 : : cmdline_fixed_string_t cmd_port;
13264 : : cmdline_fixed_string_t cmd_fec;
13265 : : cmdline_fixed_string_t cmd_keyword;
13266 : : portid_t cmd_pid;
13267 : : };
13268 : :
13269 : : static void
13270 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
13271 : : __rte_unused struct cmdline *cl,
13272 : : __rte_unused void *data)
13273 : : {
13274 : : struct cmd_show_fec_capability_result *res = parsed_result;
13275 : : struct rte_eth_fec_capa *speed_fec_capa;
13276 : : unsigned int num;
13277 : : int ret;
13278 : :
13279 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13280 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13281 : 0 : return;
13282 : : }
13283 : :
13284 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
13285 : 0 : if (ret == -ENOTSUP) {
13286 : 0 : fprintf(stderr, "Function not implemented\n");
13287 : 0 : return;
13288 : 0 : } else if (ret < 0) {
13289 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
13290 : 0 : return;
13291 : : }
13292 : :
13293 : 0 : num = (unsigned int)ret;
13294 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
13295 : 0 : if (speed_fec_capa == NULL) {
13296 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
13297 : 0 : return;
13298 : : }
13299 : :
13300 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
13301 : 0 : if (ret < 0) {
13302 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
13303 : 0 : goto out;
13304 : : }
13305 : :
13306 : 0 : show_fec_capability(num, speed_fec_capa);
13307 : 0 : out:
13308 : 0 : free(speed_fec_capa);
13309 : : }
13310 : :
13311 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
13312 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13313 : : cmd_show, "show");
13314 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
13315 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13316 : : cmd_port, "port");
13317 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
13318 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
13319 : : cmd_pid, RTE_UINT16);
13320 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
13321 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13322 : : cmd_fec, "fec");
13323 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
13324 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13325 : : cmd_keyword, "capabilities");
13326 : :
13327 : : static cmdline_parse_inst_t cmd_show_capability = {
13328 : : .f = cmd_show_fec_capability_parsed,
13329 : : .data = NULL,
13330 : : .help_str = "show port <port_id> fec capabilities",
13331 : : .tokens = {
13332 : : (void *)&cmd_show_fec_capability_show,
13333 : : (void *)&cmd_show_fec_capability_port,
13334 : : (void *)&cmd_show_fec_capability_pid,
13335 : : (void *)&cmd_show_fec_capability_fec,
13336 : : (void *)&cmd_show_fec_capability_keyword,
13337 : : NULL,
13338 : : },
13339 : : };
13340 : :
13341 : : /* *** show fec mode per port configuration *** */
13342 : : struct cmd_show_fec_metadata_result {
13343 : : cmdline_fixed_string_t cmd_show;
13344 : : cmdline_fixed_string_t cmd_port;
13345 : : cmdline_fixed_string_t cmd_keyword;
13346 : : portid_t cmd_pid;
13347 : : };
13348 : :
13349 : : static void
13350 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
13351 : : __rte_unused struct cmdline *cl,
13352 : : __rte_unused void *data)
13353 : : {
13354 : : #define FEC_NAME_SIZE 16
13355 : : struct cmd_show_fec_metadata_result *res = parsed_result;
13356 : : uint32_t mode;
13357 : : char buf[FEC_NAME_SIZE];
13358 : : int ret;
13359 : :
13360 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13361 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13362 : 0 : return;
13363 : : }
13364 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
13365 : 0 : if (ret == -ENOTSUP) {
13366 : 0 : fprintf(stderr, "Function not implemented\n");
13367 : 0 : return;
13368 : 0 : } else if (ret < 0) {
13369 : 0 : fprintf(stderr, "Get FEC mode failed\n");
13370 : 0 : return;
13371 : : }
13372 : :
13373 : 0 : switch (mode) {
13374 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
13375 : : strlcpy(buf, "off", sizeof(buf));
13376 : : break;
13377 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
13378 : : strlcpy(buf, "auto", sizeof(buf));
13379 : : break;
13380 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
13381 : : strlcpy(buf, "baser", sizeof(buf));
13382 : : break;
13383 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
13384 : : strlcpy(buf, "rs", sizeof(buf));
13385 : : break;
13386 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
13387 : : strlcpy(buf, "llrs", sizeof(buf));
13388 : : break;
13389 : : default:
13390 : : return;
13391 : : }
13392 : :
13393 : : printf("%s\n", buf);
13394 : : }
13395 : :
13396 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
13397 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13398 : : cmd_show, "show");
13399 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
13400 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13401 : : cmd_port, "port");
13402 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
13403 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
13404 : : cmd_pid, RTE_UINT16);
13405 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
13406 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13407 : : cmd_keyword, "fec_mode");
13408 : :
13409 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
13410 : : .f = cmd_show_fec_mode_parsed,
13411 : : .data = NULL,
13412 : : .help_str = "show port <port_id> fec_mode",
13413 : : .tokens = {
13414 : : (void *)&cmd_show_fec_mode_show,
13415 : : (void *)&cmd_show_fec_mode_port,
13416 : : (void *)&cmd_show_fec_mode_pid,
13417 : : (void *)&cmd_show_fec_mode_keyword,
13418 : : NULL,
13419 : : },
13420 : : };
13421 : :
13422 : : /* *** set fec mode per port configuration *** */
13423 : : struct cmd_set_port_fec_mode {
13424 : : cmdline_fixed_string_t set;
13425 : : cmdline_fixed_string_t port;
13426 : : portid_t port_id;
13427 : : cmdline_fixed_string_t fec_mode;
13428 : : cmdline_fixed_string_t fec_value;
13429 : : };
13430 : :
13431 : : /* Common CLI fields for set fec mode */
13432 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
13433 : : TOKEN_STRING_INITIALIZER
13434 : : (struct cmd_set_port_fec_mode,
13435 : : set, "set");
13436 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
13437 : : TOKEN_STRING_INITIALIZER
13438 : : (struct cmd_set_port_fec_mode,
13439 : : port, "port");
13440 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
13441 : : TOKEN_NUM_INITIALIZER
13442 : : (struct cmd_set_port_fec_mode,
13443 : : port_id, RTE_UINT16);
13444 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
13445 : : TOKEN_STRING_INITIALIZER
13446 : : (struct cmd_set_port_fec_mode,
13447 : : fec_mode, "fec_mode");
13448 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
13449 : : TOKEN_STRING_INITIALIZER
13450 : : (struct cmd_set_port_fec_mode,
13451 : : fec_value, NULL);
13452 : :
13453 : : static void
13454 : 0 : cmd_set_port_fec_mode_parsed(
13455 : : void *parsed_result,
13456 : : __rte_unused struct cmdline *cl,
13457 : : __rte_unused void *data)
13458 : : {
13459 : : struct cmd_set_port_fec_mode *res = parsed_result;
13460 : 0 : uint16_t port_id = res->port_id;
13461 : : uint32_t fec_capa;
13462 : : int ret;
13463 : :
13464 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
13465 : 0 : if (ret < 0) {
13466 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
13467 : : res->fec_value, port_id);
13468 : 0 : return;
13469 : : }
13470 : :
13471 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
13472 : 0 : if (ret == -ENOTSUP) {
13473 : 0 : fprintf(stderr, "Function not implemented\n");
13474 : 0 : return;
13475 : 0 : } else if (ret < 0) {
13476 : 0 : fprintf(stderr, "Set FEC mode failed\n");
13477 : 0 : return;
13478 : : }
13479 : : }
13480 : :
13481 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
13482 : : .f = cmd_set_port_fec_mode_parsed,
13483 : : .data = NULL,
13484 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
13485 : : .tokens = {
13486 : : (void *)&cmd_set_port_fec_mode_set,
13487 : : (void *)&cmd_set_port_fec_mode_port,
13488 : : (void *)&cmd_set_port_fec_mode_port_id,
13489 : : (void *)&cmd_set_port_fec_mode_str,
13490 : : (void *)&cmd_set_port_fec_mode_value,
13491 : : NULL,
13492 : : },
13493 : : };
13494 : :
13495 : : /* *** set available descriptors threshold for an RxQ of a port *** */
13496 : : struct cmd_set_rxq_avail_thresh_result {
13497 : : cmdline_fixed_string_t set;
13498 : : cmdline_fixed_string_t port;
13499 : : uint16_t port_num;
13500 : : cmdline_fixed_string_t rxq;
13501 : : uint16_t rxq_num;
13502 : : cmdline_fixed_string_t avail_thresh;
13503 : : uint8_t avail_thresh_num;
13504 : : };
13505 : :
13506 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
13507 : : __rte_unused struct cmdline *cl,
13508 : : __rte_unused void *data)
13509 : : {
13510 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
13511 : : int ret = 0;
13512 : :
13513 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
13514 : 0 : && (strcmp(res->rxq, "rxq") == 0)
13515 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
13516 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
13517 : 0 : res->avail_thresh_num);
13518 : 0 : if (ret < 0)
13519 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
13520 : :
13521 : 0 : }
13522 : :
13523 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
13524 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13525 : : set, "set");
13526 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
13527 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13528 : : port, "port");
13529 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
13530 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13531 : : port_num, RTE_UINT16);
13532 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
13533 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13534 : : rxq, "rxq");
13535 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
13536 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13537 : : rxq_num, RTE_UINT16);
13538 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
13539 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13540 : : avail_thresh, "avail_thresh");
13541 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
13542 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13543 : : avail_thresh_num, RTE_UINT8);
13544 : :
13545 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
13546 : : .f = cmd_set_rxq_avail_thresh_parsed,
13547 : : .data = (void *)0,
13548 : : .help_str =
13549 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
13550 : : "Set available descriptors threshold for Rx queue",
13551 : : .tokens = {
13552 : : (void *)&cmd_set_rxq_avail_thresh_set,
13553 : : (void *)&cmd_set_rxq_avail_thresh_port,
13554 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
13555 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
13556 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
13557 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
13558 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
13559 : : NULL,
13560 : : },
13561 : : };
13562 : :
13563 : : /* show port supported ptypes */
13564 : :
13565 : : /* Common result structure for show port ptypes */
13566 : : struct cmd_show_port_supported_ptypes_result {
13567 : : cmdline_fixed_string_t show;
13568 : : cmdline_fixed_string_t port;
13569 : : portid_t port_id;
13570 : : cmdline_fixed_string_t ptypes;
13571 : : };
13572 : :
13573 : : /* Common CLI fields for show port ptypes */
13574 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
13575 : : TOKEN_STRING_INITIALIZER
13576 : : (struct cmd_show_port_supported_ptypes_result,
13577 : : show, "show");
13578 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
13579 : : TOKEN_STRING_INITIALIZER
13580 : : (struct cmd_show_port_supported_ptypes_result,
13581 : : port, "port");
13582 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
13583 : : TOKEN_NUM_INITIALIZER
13584 : : (struct cmd_show_port_supported_ptypes_result,
13585 : : port_id, RTE_UINT16);
13586 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
13587 : : TOKEN_STRING_INITIALIZER
13588 : : (struct cmd_show_port_supported_ptypes_result,
13589 : : ptypes, "ptypes");
13590 : :
13591 : : static void
13592 : 0 : cmd_show_port_supported_ptypes_parsed(
13593 : : void *parsed_result,
13594 : : __rte_unused struct cmdline *cl,
13595 : : __rte_unused void *data)
13596 : : {
13597 : : #define RSVD_PTYPE_MASK 0xf0000000
13598 : : #define MAX_PTYPES_PER_LAYER 16
13599 : : #define LTYPE_NAMESIZE 32
13600 : : #define PTYPE_NAMESIZE 256
13601 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
13602 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
13603 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
13604 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
13605 : 0 : uint16_t port_id = res->port_id;
13606 : : int ret, i;
13607 : :
13608 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
13609 : 0 : if (ret < 0)
13610 : 0 : return;
13611 : :
13612 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
13613 : :
13614 : 0 : switch (ptype_mask) {
13615 : : case RTE_PTYPE_L2_MASK:
13616 : : strlcpy(ltype, "L2", sizeof(ltype));
13617 : : break;
13618 : : case RTE_PTYPE_L3_MASK:
13619 : : strlcpy(ltype, "L3", sizeof(ltype));
13620 : : break;
13621 : : case RTE_PTYPE_L4_MASK:
13622 : : strlcpy(ltype, "L4", sizeof(ltype));
13623 : : break;
13624 : : case RTE_PTYPE_TUNNEL_MASK:
13625 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
13626 : : break;
13627 : : case RTE_PTYPE_INNER_L2_MASK:
13628 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
13629 : : break;
13630 : : case RTE_PTYPE_INNER_L3_MASK:
13631 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
13632 : : break;
13633 : : case RTE_PTYPE_INNER_L4_MASK:
13634 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
13635 : : break;
13636 : : default:
13637 : : return;
13638 : : }
13639 : :
13640 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
13641 : : ptype_mask, ptypes,
13642 : : MAX_PTYPES_PER_LAYER);
13643 : :
13644 : 0 : if (ret > 0)
13645 : : printf("Supported %s ptypes:\n", ltype);
13646 : : else
13647 : : printf("%s ptypes unsupported\n", ltype);
13648 : :
13649 : 0 : for (i = 0; i < ret; ++i) {
13650 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
13651 : : printf("%s\n", buf);
13652 : : }
13653 : :
13654 : 0 : ptype_mask <<= 4;
13655 : : }
13656 : : }
13657 : :
13658 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
13659 : : .f = cmd_show_port_supported_ptypes_parsed,
13660 : : .data = NULL,
13661 : : .help_str = "show port <port_id> ptypes",
13662 : : .tokens = {
13663 : : (void *)&cmd_show_port_supported_ptypes_show,
13664 : : (void *)&cmd_show_port_supported_ptypes_port,
13665 : : (void *)&cmd_show_port_supported_ptypes_port_id,
13666 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
13667 : : NULL,
13668 : : },
13669 : : };
13670 : :
13671 : : /* *** display rx/tx descriptor status *** */
13672 : : struct cmd_show_rx_tx_desc_status_result {
13673 : : cmdline_fixed_string_t cmd_show;
13674 : : cmdline_fixed_string_t cmd_port;
13675 : : cmdline_fixed_string_t cmd_keyword;
13676 : : cmdline_fixed_string_t cmd_desc;
13677 : : cmdline_fixed_string_t cmd_status;
13678 : : portid_t cmd_pid;
13679 : : portid_t cmd_qid;
13680 : : portid_t cmd_did;
13681 : : };
13682 : :
13683 : : static void
13684 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
13685 : : __rte_unused struct cmdline *cl,
13686 : : __rte_unused void *data)
13687 : : {
13688 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
13689 : : int rc;
13690 : :
13691 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
13692 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13693 : 0 : fprintf(stderr,
13694 : : "Invalid input: port id = %d, queue id = %d\n",
13695 : 0 : res->cmd_pid, res->cmd_qid);
13696 : 0 : return;
13697 : : }
13698 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
13699 : 0 : res->cmd_did);
13700 : 0 : if (rc < 0) {
13701 : 0 : fprintf(stderr,
13702 : : "Invalid input: queue id = %d, desc id = %d\n",
13703 : 0 : res->cmd_qid, res->cmd_did);
13704 : 0 : return;
13705 : : }
13706 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
13707 : : printf("Desc status = AVAILABLE\n");
13708 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
13709 : : printf("Desc status = DONE\n");
13710 : : else
13711 : : printf("Desc status = UNAVAILABLE\n");
13712 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
13713 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13714 : 0 : fprintf(stderr,
13715 : : "Invalid input: port id = %d, queue id = %d\n",
13716 : 0 : res->cmd_pid, res->cmd_qid);
13717 : 0 : return;
13718 : : }
13719 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
13720 : 0 : res->cmd_did);
13721 : 0 : if (rc < 0) {
13722 : 0 : fprintf(stderr,
13723 : : "Invalid input: queue id = %d, desc id = %d\n",
13724 : 0 : res->cmd_qid, res->cmd_did);
13725 : 0 : return;
13726 : : }
13727 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
13728 : : printf("Desc status = FULL\n");
13729 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
13730 : : printf("Desc status = DONE\n");
13731 : : else
13732 : : printf("Desc status = UNAVAILABLE\n");
13733 : : }
13734 : : }
13735 : :
13736 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
13737 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13738 : : cmd_show, "show");
13739 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
13740 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13741 : : cmd_port, "port");
13742 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
13743 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13744 : : cmd_pid, RTE_UINT16);
13745 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
13746 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13747 : : cmd_keyword, "rxq#txq");
13748 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
13749 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13750 : : cmd_qid, RTE_UINT16);
13751 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
13752 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13753 : : cmd_desc, "desc");
13754 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
13755 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13756 : : cmd_did, RTE_UINT16);
13757 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
13758 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13759 : : cmd_status, "status");
13760 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
13761 : : .f = cmd_show_rx_tx_desc_status_parsed,
13762 : : .data = NULL,
13763 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
13764 : : "status",
13765 : : .tokens = {
13766 : : (void *)&cmd_show_rx_tx_desc_status_show,
13767 : : (void *)&cmd_show_rx_tx_desc_status_port,
13768 : : (void *)&cmd_show_rx_tx_desc_status_pid,
13769 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
13770 : : (void *)&cmd_show_rx_tx_desc_status_qid,
13771 : : (void *)&cmd_show_rx_tx_desc_status_desc,
13772 : : (void *)&cmd_show_rx_tx_desc_status_did,
13773 : : (void *)&cmd_show_rx_tx_desc_status_status,
13774 : : NULL,
13775 : : },
13776 : : };
13777 : :
13778 : : /* *** display rx/tx queue descriptor used count *** */
13779 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
13780 : : cmdline_fixed_string_t cmd_show;
13781 : : cmdline_fixed_string_t cmd_port;
13782 : : cmdline_fixed_string_t cmd_dir;
13783 : : cmdline_fixed_string_t cmd_desc;
13784 : : cmdline_fixed_string_t cmd_used;
13785 : : cmdline_fixed_string_t cmd_count;
13786 : : portid_t cmd_pid;
13787 : : portid_t cmd_qid;
13788 : : };
13789 : :
13790 : : static void
13791 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
13792 : : __rte_unused void *data)
13793 : : {
13794 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
13795 : : int rc;
13796 : :
13797 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
13798 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13799 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13800 : 0 : res->cmd_pid, res->cmd_qid);
13801 : 0 : return;
13802 : : }
13803 : :
13804 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
13805 : 0 : if (rc < 0) {
13806 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
13807 : 0 : res->cmd_qid);
13808 : 0 : return;
13809 : : }
13810 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
13811 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
13812 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13813 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13814 : 0 : res->cmd_pid, res->cmd_qid);
13815 : 0 : return;
13816 : : }
13817 : :
13818 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
13819 : 0 : if (rc < 0) {
13820 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
13821 : 0 : res->cmd_qid);
13822 : 0 : return;
13823 : : }
13824 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
13825 : : }
13826 : : }
13827 : :
13828 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
13829 : : TOKEN_STRING_INITIALIZER
13830 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13831 : : cmd_show, "show");
13832 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
13833 : : TOKEN_STRING_INITIALIZER
13834 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13835 : : cmd_port, "port");
13836 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
13837 : : TOKEN_NUM_INITIALIZER
13838 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13839 : : cmd_pid, RTE_UINT16);
13840 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
13841 : : TOKEN_STRING_INITIALIZER
13842 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13843 : : cmd_dir, "rxq#txq");
13844 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
13845 : : TOKEN_NUM_INITIALIZER
13846 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13847 : : cmd_qid, RTE_UINT16);
13848 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
13849 : : TOKEN_STRING_INITIALIZER
13850 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13851 : : cmd_desc, "desc");
13852 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
13853 : : TOKEN_STRING_INITIALIZER
13854 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13855 : : cmd_count, "used");
13856 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
13857 : : TOKEN_STRING_INITIALIZER
13858 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13859 : : cmd_count, "count");
13860 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
13861 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
13862 : : .data = NULL,
13863 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
13864 : : .tokens = {
13865 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
13866 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
13867 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
13868 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
13869 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
13870 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
13871 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
13872 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
13873 : : NULL,
13874 : : },
13875 : : };
13876 : :
13877 : : /* Common result structure for set port ptypes */
13878 : : struct cmd_set_port_ptypes_result {
13879 : : cmdline_fixed_string_t set;
13880 : : cmdline_fixed_string_t port;
13881 : : portid_t port_id;
13882 : : cmdline_fixed_string_t ptype_mask;
13883 : : uint32_t mask;
13884 : : };
13885 : :
13886 : : /* Common CLI fields for set port ptypes */
13887 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
13888 : : TOKEN_STRING_INITIALIZER
13889 : : (struct cmd_set_port_ptypes_result,
13890 : : set, "set");
13891 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
13892 : : TOKEN_STRING_INITIALIZER
13893 : : (struct cmd_set_port_ptypes_result,
13894 : : port, "port");
13895 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
13896 : : TOKEN_NUM_INITIALIZER
13897 : : (struct cmd_set_port_ptypes_result,
13898 : : port_id, RTE_UINT16);
13899 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
13900 : : TOKEN_STRING_INITIALIZER
13901 : : (struct cmd_set_port_ptypes_result,
13902 : : ptype_mask, "ptype_mask");
13903 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
13904 : : TOKEN_NUM_INITIALIZER
13905 : : (struct cmd_set_port_ptypes_result,
13906 : : mask, RTE_UINT32);
13907 : :
13908 : : static void
13909 : 0 : cmd_set_port_ptypes_parsed(
13910 : : void *parsed_result,
13911 : : __rte_unused struct cmdline *cl,
13912 : : __rte_unused void *data)
13913 : : {
13914 : : struct cmd_set_port_ptypes_result *res = parsed_result;
13915 : : #define PTYPE_NAMESIZE 256
13916 : : char ptype_name[PTYPE_NAMESIZE];
13917 : 0 : uint16_t port_id = res->port_id;
13918 : 0 : uint32_t ptype_mask = res->mask;
13919 : : int ret, i;
13920 : :
13921 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
13922 : : NULL, 0);
13923 : 0 : if (ret <= 0) {
13924 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
13925 : : port_id);
13926 : 0 : return;
13927 : : }
13928 : :
13929 : 0 : uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
13930 : :
13931 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
13932 : 0 : if (ret < 0) {
13933 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
13934 : : port_id);
13935 : 0 : return;
13936 : : }
13937 : :
13938 : : printf("Successfully set following ptypes for Port %d\n", port_id);
13939 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
13940 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
13941 : : printf("%s\n", ptype_name);
13942 : : }
13943 : :
13944 : 0 : clear_ptypes = false;
13945 : : }
13946 : :
13947 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
13948 : : .f = cmd_set_port_ptypes_parsed,
13949 : : .data = NULL,
13950 : : .help_str = "set port <port_id> ptype_mask <mask>",
13951 : : .tokens = {
13952 : : (void *)&cmd_set_port_ptypes_set,
13953 : : (void *)&cmd_set_port_ptypes_port,
13954 : : (void *)&cmd_set_port_ptypes_port_id,
13955 : : (void *)&cmd_set_port_ptypes_mask_str,
13956 : : (void *)&cmd_set_port_ptypes_mask_u32,
13957 : : NULL,
13958 : : },
13959 : : };
13960 : :
13961 : : /* *** display mac addresses added to a port *** */
13962 : : struct cmd_showport_macs_result {
13963 : : cmdline_fixed_string_t cmd_show;
13964 : : cmdline_fixed_string_t cmd_port;
13965 : : cmdline_fixed_string_t cmd_keyword;
13966 : : portid_t cmd_pid;
13967 : : };
13968 : :
13969 : : static void
13970 : 0 : cmd_showport_macs_parsed(void *parsed_result,
13971 : : __rte_unused struct cmdline *cl,
13972 : : __rte_unused void *data)
13973 : : {
13974 : : struct cmd_showport_macs_result *res = parsed_result;
13975 : :
13976 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
13977 : : return;
13978 : :
13979 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
13980 : 0 : show_macs(res->cmd_pid);
13981 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
13982 : 0 : show_mcast_macs(res->cmd_pid);
13983 : : }
13984 : :
13985 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
13986 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13987 : : cmd_show, "show");
13988 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
13989 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13990 : : cmd_port, "port");
13991 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
13992 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
13993 : : cmd_pid, RTE_UINT16);
13994 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
13995 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13996 : : cmd_keyword, "macs#mcast_macs");
13997 : :
13998 : : static cmdline_parse_inst_t cmd_showport_macs = {
13999 : : .f = cmd_showport_macs_parsed,
14000 : : .data = NULL,
14001 : : .help_str = "show port <port_id> macs|mcast_macs",
14002 : : .tokens = {
14003 : : (void *)&cmd_showport_macs_show,
14004 : : (void *)&cmd_showport_macs_port,
14005 : : (void *)&cmd_showport_macs_pid,
14006 : : (void *)&cmd_showport_macs_keyword,
14007 : : NULL,
14008 : : },
14009 : : };
14010 : :
14011 : : /* *** show flow transfer proxy port ID for the given port *** */
14012 : : struct cmd_show_port_flow_transfer_proxy_result {
14013 : : cmdline_fixed_string_t show;
14014 : : cmdline_fixed_string_t port;
14015 : : portid_t port_id;
14016 : : cmdline_fixed_string_t flow;
14017 : : cmdline_fixed_string_t transfer;
14018 : : cmdline_fixed_string_t proxy;
14019 : : };
14020 : :
14021 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
14022 : : TOKEN_STRING_INITIALIZER
14023 : : (struct cmd_show_port_flow_transfer_proxy_result,
14024 : : show, "show");
14025 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
14026 : : TOKEN_STRING_INITIALIZER
14027 : : (struct cmd_show_port_flow_transfer_proxy_result,
14028 : : port, "port");
14029 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
14030 : : TOKEN_NUM_INITIALIZER
14031 : : (struct cmd_show_port_flow_transfer_proxy_result,
14032 : : port_id, RTE_UINT16);
14033 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
14034 : : TOKEN_STRING_INITIALIZER
14035 : : (struct cmd_show_port_flow_transfer_proxy_result,
14036 : : flow, "flow");
14037 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
14038 : : TOKEN_STRING_INITIALIZER
14039 : : (struct cmd_show_port_flow_transfer_proxy_result,
14040 : : transfer, "transfer");
14041 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
14042 : : TOKEN_STRING_INITIALIZER
14043 : : (struct cmd_show_port_flow_transfer_proxy_result,
14044 : : proxy, "proxy");
14045 : :
14046 : : static void
14047 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
14048 : : __rte_unused struct cmdline *cl,
14049 : : __rte_unused void *data)
14050 : : {
14051 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
14052 : : portid_t proxy_port_id;
14053 : : int ret;
14054 : :
14055 : : printf("\n");
14056 : :
14057 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
14058 : 0 : if (ret != 0) {
14059 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
14060 : : rte_strerror(-ret));
14061 : 0 : return;
14062 : : }
14063 : :
14064 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
14065 : : }
14066 : :
14067 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
14068 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
14069 : : .data = NULL,
14070 : : .help_str = "show port <port_id> flow transfer proxy",
14071 : : .tokens = {
14072 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
14073 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
14074 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
14075 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
14076 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
14077 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
14078 : : NULL,
14079 : : }
14080 : : };
14081 : :
14082 : : /* *** configure port txq affinity value *** */
14083 : : struct cmd_config_tx_affinity_map {
14084 : : cmdline_fixed_string_t port;
14085 : : cmdline_fixed_string_t config;
14086 : : portid_t portid;
14087 : : cmdline_fixed_string_t txq;
14088 : : uint16_t qid;
14089 : : cmdline_fixed_string_t affinity;
14090 : : uint8_t value;
14091 : : };
14092 : :
14093 : : static void
14094 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
14095 : : __rte_unused struct cmdline *cl,
14096 : : __rte_unused void *data)
14097 : : {
14098 : : struct cmd_config_tx_affinity_map *res = parsed_result;
14099 : : int ret;
14100 : :
14101 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
14102 : : return;
14103 : :
14104 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
14105 : : printf("Invalid port id\n");
14106 : 0 : return;
14107 : : }
14108 : :
14109 : 0 : if (strcmp(res->txq, "txq")) {
14110 : : printf("Unknown parameter\n");
14111 : 0 : return;
14112 : : }
14113 : 0 : if (tx_queue_id_is_invalid(res->qid))
14114 : : return;
14115 : :
14116 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
14117 : 0 : if (ret < 0) {
14118 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
14119 : : strerror(-ret));
14120 : 0 : return;
14121 : : }
14122 : :
14123 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
14124 : 0 : if (ret != 0) {
14125 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
14126 : : rte_strerror(-ret));
14127 : 0 : return;
14128 : : }
14129 : : }
14130 : :
14131 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
14132 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14133 : : port, "port");
14134 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
14135 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14136 : : config, "config");
14137 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
14138 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14139 : : portid, RTE_UINT16);
14140 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
14141 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14142 : : txq, "txq");
14143 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
14144 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14145 : : qid, RTE_UINT16);
14146 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
14147 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14148 : : affinity, "affinity");
14149 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
14150 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14151 : : value, RTE_UINT8);
14152 : :
14153 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
14154 : : .f = cmd_config_tx_affinity_map_parsed,
14155 : : .data = (void *)0,
14156 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
14157 : : .tokens = {
14158 : : (void *)&cmd_config_tx_affinity_map_port,
14159 : : (void *)&cmd_config_tx_affinity_map_config,
14160 : : (void *)&cmd_config_tx_affinity_map_portid,
14161 : : (void *)&cmd_config_tx_affinity_map_txq,
14162 : : (void *)&cmd_config_tx_affinity_map_qid,
14163 : : (void *)&cmd_config_tx_affinity_map_affinity,
14164 : : (void *)&cmd_config_tx_affinity_map_value,
14165 : : NULL,
14166 : : },
14167 : : };
14168 : :
14169 : : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
14170 : : struct cmd_dev_led_result {
14171 : : cmdline_fixed_string_t set;
14172 : : cmdline_fixed_string_t port;
14173 : : portid_t port_id;
14174 : : cmdline_fixed_string_t led;
14175 : : cmdline_fixed_string_t state;
14176 : : };
14177 : :
14178 : : static void
14179 : 0 : cmd_set_dev_led_parsed(void *parsed_result,
14180 : : __rte_unused struct cmdline *cl,
14181 : : __rte_unused void *data)
14182 : : {
14183 : : struct cmd_dev_led_result *res = parsed_result;
14184 : :
14185 : 0 : if (strcmp(res->state, "on") == 0)
14186 : 0 : set_dev_led(res->port_id, true);
14187 : : else
14188 : 0 : set_dev_led(res->port_id, false);
14189 : 0 : }
14190 : :
14191 : : static cmdline_parse_token_string_t cmd_dev_led_set =
14192 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
14193 : : static cmdline_parse_token_string_t cmd_dev_led_port =
14194 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
14195 : : static cmdline_parse_token_num_t cmd_dev_led_port_id =
14196 : : TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
14197 : : static cmdline_parse_token_string_t cmd_dev_led =
14198 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
14199 : : static cmdline_parse_token_string_t cmd_dev_state =
14200 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
14201 : :
14202 : : static cmdline_parse_inst_t cmd_set_dev_led = {
14203 : : .f = cmd_set_dev_led_parsed,
14204 : : .data = NULL,
14205 : : .help_str = "set port <port_id> led <on/off>",
14206 : : .tokens = {
14207 : : (void *)&cmd_dev_led_set,
14208 : : (void *)&cmd_dev_led_port,
14209 : : (void *)&cmd_dev_led_port_id,
14210 : : (void *)&cmd_dev_led,
14211 : : (void *)&cmd_dev_state,
14212 : : NULL,
14213 : : },
14214 : : };
14215 : :
14216 : : /* ******************************************************************************** */
14217 : :
14218 : : /* list of instructions */
14219 : : static cmdline_parse_ctx_t builtin_ctx[] = {
14220 : : &cmd_help_brief,
14221 : : &cmd_help_long,
14222 : : &cmd_quit,
14223 : : &cmd_load_from_file,
14224 : : &cmd_load_echo_file,
14225 : : &cmd_showport,
14226 : : &cmd_showqueue,
14227 : : &cmd_showeeprom,
14228 : : &cmd_seteeprom,
14229 : : &cmd_showportall,
14230 : : &cmd_representor_info,
14231 : : &cmd_showdevice,
14232 : : &cmd_showcfg,
14233 : : &cmd_showfwdall,
14234 : : &cmd_start,
14235 : : &cmd_start_tx_first,
14236 : : &cmd_start_tx_first_n,
14237 : : &cmd_set_link_up,
14238 : : &cmd_set_link_down,
14239 : : &cmd_reset,
14240 : : &cmd_set_numbers,
14241 : : &cmd_set_log,
14242 : : &cmd_set_rxoffs,
14243 : : &cmd_set_rxpkts,
14244 : : &cmd_set_rxhdrs,
14245 : : &cmd_set_txflows,
14246 : : &cmd_set_txpkts,
14247 : : &cmd_set_txsplit,
14248 : : &cmd_set_txtimes,
14249 : : &cmd_set_fwd_list,
14250 : : &cmd_set_fwd_mask,
14251 : : &cmd_set_fwd_mode,
14252 : : &cmd_set_fwd_retry_mode,
14253 : : &cmd_set_dcb_fwd_tc,
14254 : : &cmd_set_dcb_fwd_tc_cores,
14255 : : &cmd_set_burst_tx_retry,
14256 : : &cmd_set_promisc_mode_one,
14257 : : &cmd_set_promisc_mode_all,
14258 : : &cmd_set_allmulti_mode_one,
14259 : : &cmd_set_allmulti_mode_all,
14260 : : &cmd_set_flush_rx,
14261 : : &cmd_set_link_check,
14262 : : &cmd_vlan_offload,
14263 : : &cmd_vlan_tpid,
14264 : : &cmd_rx_vlan_filter_all,
14265 : : &cmd_rx_vlan_filter,
14266 : : &cmd_tx_vlan_set,
14267 : : &cmd_tx_vlan_set_qinq,
14268 : : &cmd_tx_vlan_reset,
14269 : : &cmd_tx_vlan_set_pvid,
14270 : : &cmd_csum_set,
14271 : : &cmd_csum_show,
14272 : : &cmd_csum_tunnel,
14273 : : &cmd_csum_mac_swap,
14274 : : &cmd_tso_set,
14275 : : &cmd_tso_show,
14276 : : &cmd_tunnel_tso_set,
14277 : : &cmd_tunnel_tso_show,
14278 : : #ifdef RTE_LIB_GRO
14279 : : &cmd_gro_enable,
14280 : : &cmd_gro_flush,
14281 : : &cmd_gro_show,
14282 : : #endif
14283 : : #ifdef RTE_LIB_GSO
14284 : : &cmd_gso_enable,
14285 : : &cmd_gso_size,
14286 : : &cmd_gso_show,
14287 : : #endif
14288 : : &cmd_link_flow_control_set,
14289 : : &cmd_link_flow_control_set_rx,
14290 : : &cmd_link_flow_control_set_tx,
14291 : : &cmd_link_flow_control_set_hw,
14292 : : &cmd_link_flow_control_set_lw,
14293 : : &cmd_link_flow_control_set_pt,
14294 : : &cmd_link_flow_control_set_xon,
14295 : : &cmd_link_flow_control_set_macfwd,
14296 : : &cmd_link_flow_control_set_autoneg,
14297 : : &cmd_link_flow_control_show,
14298 : : &cmd_priority_flow_control_set,
14299 : : &cmd_queue_priority_flow_control_set,
14300 : : &cmd_config_dcb,
14301 : : &cmd_read_rxd_txd,
14302 : : &cmd_stop,
14303 : : &cmd_mac_addr,
14304 : : &cmd_set_fwd_eth_peer,
14305 : : &cmd_set_xstats_hide_zero,
14306 : : &cmd_set_xstats_show_state,
14307 : : &cmd_set_xstats_hide_disabled,
14308 : : &cmd_operate_set_counter,
14309 : : &cmd_set_record_core_cycles,
14310 : : &cmd_set_record_burst_stats,
14311 : : &cmd_operate_port,
14312 : : &cmd_operate_specific_port,
14313 : : &cmd_operate_attach_port,
14314 : : &cmd_operate_detach_port,
14315 : : &cmd_operate_detach_device,
14316 : : &cmd_set_port_setup_on,
14317 : : &cmd_config_speed_all,
14318 : : &cmd_config_speed_specific,
14319 : : &cmd_config_speed_lanes_all,
14320 : : &cmd_config_speed_lanes_specific,
14321 : : &cmd_show_speed_lanes,
14322 : : &cmd_config_loopback_all,
14323 : : &cmd_config_loopback_specific,
14324 : : &cmd_config_rx_tx,
14325 : : &cmd_config_mtu,
14326 : : &cmd_config_max_pkt_len,
14327 : : &cmd_config_max_lro_pkt_size,
14328 : : &cmd_config_rx_mode_flag,
14329 : : &cmd_config_rss,
14330 : : &cmd_config_rxtx_ring_size,
14331 : : &cmd_config_rxtx_queue,
14332 : : &cmd_config_deferred_start_rxtx_queue,
14333 : : &cmd_setup_rxtx_queue,
14334 : : &cmd_config_rss_reta,
14335 : : &cmd_showport_reta,
14336 : : &cmd_showport_macs,
14337 : : &cmd_show_port_flow_transfer_proxy,
14338 : : &cmd_config_burst,
14339 : : &cmd_config_thresh,
14340 : : &cmd_config_threshold,
14341 : : &cmd_set_uc_hash_filter,
14342 : : &cmd_set_uc_all_hash_filter,
14343 : : &cmd_vf_mac_addr_filter,
14344 : : &cmd_queue_rate_limit,
14345 : : &cmd_show_queue_rate_limit,
14346 : : &cmd_tunnel_udp_config,
14347 : : &cmd_showport_rss_hash,
14348 : : &cmd_showport_rss_hash_key,
14349 : : &cmd_showport_rss_hash_algo,
14350 : : &cmd_config_rss_hash_key,
14351 : : &cmd_config_rss_hash_algo,
14352 : : &cmd_cleanup_txq_mbufs,
14353 : : &cmd_dump_simple,
14354 : : &cmd_dump_named,
14355 : : &cmd_dump_mbuf_history_stdout,
14356 : : &cmd_dump_mbuf_history_to_file,
14357 : : &cmd_dump_mbuf_pool_history_stdout,
14358 : : &cmd_dump_mbuf_pool_history_to_file,
14359 : : &cmd_flow,
14360 : : &cmd_show_port_meter_cap,
14361 : : &cmd_add_port_meter_profile_srtcm,
14362 : : &cmd_add_port_meter_profile_trtcm,
14363 : : &cmd_add_port_meter_profile_trtcm_rfc4115,
14364 : : &cmd_del_port_meter_profile,
14365 : : &cmd_create_port_meter,
14366 : : &cmd_enable_port_meter,
14367 : : &cmd_disable_port_meter,
14368 : : &cmd_del_port_meter,
14369 : : &cmd_del_port_meter_policy,
14370 : : &cmd_set_port_meter_profile,
14371 : : &cmd_set_port_meter_dscp_table,
14372 : : &cmd_set_port_meter_vlan_table,
14373 : : &cmd_set_port_meter_in_proto,
14374 : : &cmd_get_port_meter_in_proto,
14375 : : &cmd_get_port_meter_in_proto_prio,
14376 : : &cmd_set_port_meter_stats_mask,
14377 : : &cmd_show_port_meter_stats,
14378 : : &cmd_mcast_addr,
14379 : : &cmd_mcast_addr_flush,
14380 : : &cmd_set_vf_vlan_anti_spoof,
14381 : : &cmd_set_vf_mac_anti_spoof,
14382 : : &cmd_set_vf_vlan_stripq,
14383 : : &cmd_set_vf_vlan_insert,
14384 : : &cmd_set_tx_loopback,
14385 : : &cmd_set_all_queues_drop_en,
14386 : : &cmd_set_vf_traffic,
14387 : : &cmd_set_vf_rxmode,
14388 : : &cmd_vf_rate_limit,
14389 : : &cmd_vf_rxvlan_filter,
14390 : : &cmd_set_vf_mac_addr,
14391 : : &cmd_set_vxlan,
14392 : : &cmd_set_vxlan_tos_ttl,
14393 : : &cmd_set_vxlan_with_vlan,
14394 : : &cmd_set_nvgre,
14395 : : &cmd_set_nvgre_with_vlan,
14396 : : &cmd_set_l2_encap,
14397 : : &cmd_set_l2_encap_with_vlan,
14398 : : &cmd_set_l2_decap,
14399 : : &cmd_set_l2_decap_with_vlan,
14400 : : &cmd_set_mplsogre_encap,
14401 : : &cmd_set_mplsogre_encap_with_vlan,
14402 : : &cmd_set_mplsogre_decap,
14403 : : &cmd_set_mplsogre_decap_with_vlan,
14404 : : &cmd_set_mplsoudp_encap,
14405 : : &cmd_set_mplsoudp_encap_with_vlan,
14406 : : &cmd_set_mplsoudp_decap,
14407 : : &cmd_set_mplsoudp_decap_with_vlan,
14408 : : &cmd_set_conntrack_common,
14409 : : &cmd_set_conntrack_dir,
14410 : : &cmd_show_vf_stats,
14411 : : &cmd_clear_vf_stats,
14412 : : &cmd_show_port_supported_ptypes,
14413 : : &cmd_set_port_ptypes,
14414 : : &cmd_show_port_tm_cap,
14415 : : &cmd_show_port_tm_level_cap,
14416 : : &cmd_show_port_tm_node,
14417 : : &cmd_show_port_tm_node_cap,
14418 : : &cmd_show_port_tm_node_type,
14419 : : &cmd_show_port_tm_node_stats,
14420 : : &cmd_add_port_tm_node_shaper_profile,
14421 : : &cmd_del_port_tm_node_shaper_profile,
14422 : : &cmd_add_port_tm_node_shared_shaper,
14423 : : &cmd_del_port_tm_node_shared_shaper,
14424 : : &cmd_add_port_tm_node_wred_profile,
14425 : : &cmd_del_port_tm_node_wred_profile,
14426 : : &cmd_set_port_tm_node_shaper_profile,
14427 : : &cmd_add_port_tm_nonleaf_node,
14428 : : &cmd_add_port_tm_nonleaf_node_pmode,
14429 : : &cmd_add_port_tm_leaf_node,
14430 : : &cmd_del_port_tm_node,
14431 : : &cmd_set_port_tm_node_parent,
14432 : : &cmd_suspend_port_tm_node,
14433 : : &cmd_resume_port_tm_node,
14434 : : &cmd_port_tm_hierarchy_commit,
14435 : : &cmd_port_tm_mark_ip_ecn,
14436 : : &cmd_port_tm_mark_ip_dscp,
14437 : : &cmd_port_tm_mark_vlan_dei,
14438 : : &cmd_cfg_tunnel_udp_port,
14439 : : &cmd_rx_offload_get_capa,
14440 : : &cmd_rx_offload_get_configuration,
14441 : : &cmd_config_per_port_rx_offload,
14442 : : &cmd_config_all_port_rx_offload,
14443 : : &cmd_config_per_queue_rx_offload,
14444 : : &cmd_tx_offload_get_capa,
14445 : : &cmd_tx_offload_get_configuration,
14446 : : &cmd_config_per_port_tx_offload,
14447 : : &cmd_config_all_port_tx_offload,
14448 : : &cmd_config_per_queue_tx_offload,
14449 : : #ifdef RTE_LIB_BPF
14450 : : &cmd_operate_bpf_ld_parse,
14451 : : &cmd_operate_bpf_unld_parse,
14452 : : #endif
14453 : : &cmd_config_tx_metadata_specific,
14454 : : &cmd_show_tx_metadata,
14455 : : &cmd_show_rx_tx_desc_status,
14456 : : &cmd_show_rx_tx_queue_desc_used_count,
14457 : : &cmd_set_raw,
14458 : : &cmd_show_set_raw,
14459 : : &cmd_show_set_raw_all,
14460 : : &cmd_config_tx_dynf_specific,
14461 : : &cmd_show_fec_mode,
14462 : : &cmd_set_fec_mode,
14463 : : &cmd_set_rxq_avail_thresh,
14464 : : &cmd_show_capability,
14465 : : &cmd_set_flex_is_pattern,
14466 : : &cmd_set_flex_spec_pattern,
14467 : : &cmd_show_port_cman_capa,
14468 : : &cmd_show_port_cman_config,
14469 : : &cmd_set_port_cman_config,
14470 : : &cmd_config_tx_affinity_map,
14471 : : &cmd_set_dev_led,
14472 : : NULL,
14473 : : };
14474 : :
14475 : : void
14476 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
14477 : : {
14478 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
14479 : 0 : }
14480 : :
14481 : : int
14482 : 0 : init_cmdline(void)
14483 : : {
14484 : : struct testpmd_driver_commands *c;
14485 : : unsigned int count;
14486 : : unsigned int i;
14487 : :
14488 : : /* initialize non-constant commands */
14489 : 0 : cmd_set_fwd_mode_init();
14490 : 0 : cmd_set_fwd_retry_mode_init();
14491 : :
14492 : : count = 0;
14493 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
14494 : 0 : count++;
14495 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14496 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
14497 : 0 : count++;
14498 : : }
14499 : :
14500 : : /* cmdline expects a NULL terminated array */
14501 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
14502 : 0 : if (main_ctx == NULL)
14503 : : return -1;
14504 : :
14505 : : count = 0;
14506 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
14507 : 0 : main_ctx[count] = builtin_ctx[i];
14508 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14509 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
14510 : 0 : main_ctx[count] = c->commands[i].ctx;
14511 : : }
14512 : :
14513 : : return 0;
14514 : : }
14515 : :
14516 : : /* read cmdline commands from file */
14517 : : int
14518 : 0 : cmdline_read_from_file(const char *filename, bool echo)
14519 : : {
14520 : : struct cmdline *cl;
14521 : : int fd = -1;
14522 : : int ret = 0;
14523 : :
14524 : : /* cmdline_file_new does not produce any output
14525 : : * so when echoing is requested we open filename directly
14526 : : * and then pass that to cmdline_new with stdout as the output path.
14527 : : */
14528 : 0 : if (!echo) {
14529 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14530 : : } else {
14531 : : /* use basename(filename) as prompt */
14532 : 0 : char prompt[32] = "[] ";
14533 : :
14534 : 0 : rte_basename(filename, &prompt[1], sizeof(prompt) - strlen(prompt));
14535 : 0 : strlcat(prompt, "] ", sizeof(prompt));
14536 : :
14537 : : fd = open(filename, O_RDONLY);
14538 : 0 : if (fd < 0) {
14539 : 0 : fprintf(stderr, "Failed to open file %s: %s\n",
14540 : 0 : filename, strerror(errno));
14541 : 0 : return -1;
14542 : : }
14543 : :
14544 : 0 : cl = cmdline_new(main_ctx, prompt, fd, STDOUT_FILENO);
14545 : : }
14546 : 0 : if (cl == NULL) {
14547 : 0 : fprintf(stderr,
14548 : : "Failed to create file based cmdline context: %s\n",
14549 : : filename);
14550 : : ret = -1;
14551 : 0 : goto end;
14552 : : }
14553 : :
14554 : 0 : cmdline_interact(cl);
14555 : : /* when done, if we have echo, we only need to print end of file,
14556 : : * but if no echo, we need to use printf and include the filename.
14557 : : */
14558 : 0 : if (echo)
14559 : 0 : cmdline_printf(cl, "<End-Of-File>\n");
14560 : : else
14561 : : printf("Finished reading CLI commands from %s\n", filename);
14562 : :
14563 : 0 : cmdline_quit(cl);
14564 : 0 : cmdline_free(cl);
14565 : :
14566 : :
14567 : 0 : end:
14568 : 0 : if (fd >= 0)
14569 : 0 : close(fd);
14570 : : return ret;
14571 : : }
14572 : :
14573 : : void
14574 : 0 : prompt_exit(void)
14575 : : {
14576 : 0 : cmdline_quit(testpmd_cl);
14577 : 0 : }
14578 : :
14579 : : /* prompt function, called from main on MAIN lcore */
14580 : : void
14581 : 0 : prompt(void)
14582 : : {
14583 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14584 : 0 : if (testpmd_cl == NULL) {
14585 : 0 : fprintf(stderr,
14586 : : "Failed to create stdin based cmdline context\n");
14587 : 0 : return;
14588 : : }
14589 : :
14590 : 0 : cmdline_interact(testpmd_cl);
14591 : 0 : cmdline_stdin_exit(testpmd_cl);
14592 : : }
14593 : :
14594 : : void
14595 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14596 : : {
14597 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
14598 : : portid_t pid;
14599 : :
14600 : 0 : RTE_ETH_FOREACH_DEV(pid) {
14601 : : /* check if need_reconfig has been set to 1 */
14602 : 0 : if (ports[pid].need_reconfig == 0)
14603 : 0 : ports[pid].need_reconfig = dev;
14604 : : /* check if need_reconfig_queues has been set to 1 */
14605 : 0 : if (ports[pid].need_reconfig_queues == 0)
14606 : 0 : ports[pid].need_reconfig_queues = queue;
14607 : : }
14608 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14609 : : /* check if need_reconfig has been set to 1 */
14610 : 0 : if (ports[id].need_reconfig == 0)
14611 : 0 : ports[id].need_reconfig = dev;
14612 : : /* check if need_reconfig_queues has been set to 1 */
14613 : 0 : if (ports[id].need_reconfig_queues == 0)
14614 : 0 : ports[id].need_reconfig_queues = queue;
14615 : : }
14616 : 0 : }
|