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 : : "show port (port_id) module_eeprom decode\n"
176 : : " Display the decoded module EEPROM of port_id.\n\n"
177 : :
178 : : "set port (port_id) eeprom (accept_risk) magic (magic_num)"
179 : : " value (value) offset (offset)\n"
180 : : " Set the device eeprom for certain port.\nNote:\n"
181 : : " This is a high-risk command and its misuse may"
182 : : " result in unexpected behaviour from the NIC.\n"
183 : : " By inserting \"accept_risk\" into the command, the"
184 : : " user is acknowledging and taking responsibility for"
185 : : " this risk.\n\n"
186 : :
187 : : "show port X rss reta (size) (mask0,mask1,...)\n"
188 : : " Display the rss redirection table entry indicated"
189 : : " by masks on port X. size is used to indicate the"
190 : : " hardware supported reta size\n\n"
191 : :
192 : : "show port (port_id) rss-hash [key | algorithm]\n"
193 : : " Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
194 : :
195 : : "clear port (info|stats|xstats|fdir) (port_id|all)\n"
196 : : " Clear information for port_id, or all.\n\n"
197 : :
198 : : "show (rxq|txq) info (port_id) (queue_id)\n"
199 : : " Display information for configured RX/TX queue.\n\n"
200 : :
201 : : "show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes|dcbfwdtc)\n"
202 : : " Display the given configuration.\n\n"
203 : :
204 : : "read rxd (port_id) (queue_id) (rxd_id)\n"
205 : : " Display an RX descriptor of a port RX queue.\n\n"
206 : :
207 : : "read txd (port_id) (queue_id) (txd_id)\n"
208 : : " Display a TX descriptor of a port TX queue.\n\n"
209 : :
210 : : "show vf stats (port_id) (vf_id)\n"
211 : : " Display a VF's statistics.\n\n"
212 : :
213 : : "clear vf stats (port_id) (vf_id)\n"
214 : : " Reset a VF's statistics.\n\n"
215 : :
216 : : "show port meter stats (port_id) (meter_id) (clear)\n"
217 : : " Get meter stats on a port\n\n"
218 : :
219 : : "show fwd stats all\n"
220 : : " Display statistics for all fwd engines.\n\n"
221 : :
222 : : "clear fwd stats all\n"
223 : : " Clear statistics for all fwd engines.\n\n"
224 : :
225 : : "show port (port_id) rx_offload capabilities\n"
226 : : " List all per queue and per port Rx offloading"
227 : : " capabilities of a port\n\n"
228 : :
229 : : "show port (port_id) rx_offload configuration\n"
230 : : " List port level and all queue level"
231 : : " Rx offloading configuration\n\n"
232 : :
233 : : "show port (port_id) tx_offload capabilities\n"
234 : : " List all per queue and per port"
235 : : " Tx offloading capabilities of a port\n\n"
236 : :
237 : : "show port (port_id) tx_offload configuration\n"
238 : : " List port level and all queue level"
239 : : " Tx offloading configuration\n\n"
240 : :
241 : : "show port (port_id) tx_metadata\n"
242 : : " Show Tx metadata value set"
243 : : " for a specific port\n\n"
244 : :
245 : : "show port (port_id) ptypes\n"
246 : : " Show port supported ptypes"
247 : : " for a specific port\n\n"
248 : :
249 : : "show device info (<identifier>|all)"
250 : : " Show general information about devices probed.\n\n"
251 : :
252 : : "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
253 : : " Show status of rx|tx descriptor.\n\n"
254 : :
255 : : "show port (port_id) rxq|txq (queue_id) desc used count\n"
256 : : " Show current number of used descriptor count for rx|tx.\n\n"
257 : :
258 : : "show port (port_id) macs|mcast_macs"
259 : : " Display list of mac addresses added to port.\n\n"
260 : :
261 : : "show port (port_id) flow transfer proxy\n"
262 : : " Display proxy port to manage transfer flows\n\n"
263 : :
264 : : "show port (port_id) fec capabilities"
265 : : " Show fec capabilities of a port.\n\n"
266 : :
267 : : "show port (port_id) fec_mode"
268 : : " Show fec mode of a port.\n\n"
269 : :
270 : : "show port (port_id) flow_ctrl"
271 : : " Show flow control info of a port.\n\n"
272 : :
273 : : "dump physmem\n"
274 : : " Dumps all physical memory segment layouts\n\n"
275 : :
276 : : "dump socket_mem\n"
277 : : " Dumps the memory usage of all sockets\n\n"
278 : :
279 : : "dump memzone\n"
280 : : " Dumps the layout of all memory zones\n\n"
281 : :
282 : : "dump struct_sizes\n"
283 : : " Dumps the size of all memory structures\n\n"
284 : :
285 : : "dump ring [name]\n"
286 : : " Dumps the status of all or specific element in DPDK rings\n\n"
287 : :
288 : : "dump mempool [name]\n"
289 : : " Dumps the statistics of all or specific memory pool\n\n"
290 : :
291 : : "dump devargs\n"
292 : : " Dumps the user device list\n\n"
293 : :
294 : : "dump lcores\n"
295 : : " Dumps the logical cores list\n\n"
296 : :
297 : : "dump trace\n"
298 : : " Dumps the tracing data to the folder according to the current EAL settings\n\n"
299 : :
300 : : "dump log_types\n"
301 : : " Dumps the log level for all the dpdk modules\n\n"
302 : :
303 : : "dump mbuf history all [file_name]\n"
304 : : " Dumps the mbuf history for all mempools\n\n"
305 : :
306 : : "dump mbuf history <mbuf_addr> [file_name]\n"
307 : : " Dumps the history for a specific mbuf (use 0x<address> format)\n\n"
308 : :
309 : : "dump mbuf pool history <mempool_name> [file_name]\n"
310 : : " Dumps the history for a specific mempool\n\n"
311 : :
312 : : "show port (port_id) speed_lanes capabilities"
313 : : " Show speed lanes capabilities of a port.\n\n"
314 : : );
315 : : }
316 : :
317 : 0 : if (show_all || !strcmp(res->section, "config")) {
318 : 0 : cmdline_printf(
319 : : cl,
320 : : "\n"
321 : : "Configuration:\n"
322 : : "--------------\n"
323 : : "Configuration changes only become active when"
324 : : " forwarding is started/restarted.\n\n"
325 : :
326 : : "set default\n"
327 : : " Reset forwarding to the default configuration.\n\n"
328 : :
329 : : "set verbose (level)\n"
330 : : " Set the debug verbosity level X.\n\n"
331 : :
332 : : "set log global|(type) (level)\n"
333 : : " Set the log level.\n\n"
334 : :
335 : : "set nbport (num)\n"
336 : : " Set number of ports.\n\n"
337 : :
338 : : "set nbcore (num)\n"
339 : : " Set number of cores.\n\n"
340 : :
341 : : "set coremask (mask)\n"
342 : : " Set the forwarding cores hexadecimal mask.\n\n"
343 : :
344 : : "set portmask (mask)\n"
345 : : " Set the forwarding ports hexadecimal mask.\n\n"
346 : :
347 : : "set burst (num)\n"
348 : : " Set number of packets per burst.\n\n"
349 : :
350 : : "set burst tx delay (microseconds) retry (num)\n"
351 : : " Set the transmit delay time and number of retries,"
352 : : " effective when retry is enabled.\n\n"
353 : :
354 : : "set rxoffs (x[,y]*)\n"
355 : : " Set the offset of each packet segment on"
356 : : " receiving if split feature is engaged."
357 : : " Affects only the queues configured with split"
358 : : " offloads.\n\n"
359 : :
360 : : "set rxpkts (x[,y]*)\n"
361 : : " Set the length of each segment to scatter"
362 : : " packets on receiving if split feature is engaged."
363 : : " Affects only the queues configured with split"
364 : : " offloads.\n\n"
365 : :
366 : : "set rxhdrs (eth[,ipv4])*\n"
367 : : " Set the protocol hdr of each segment to scatter"
368 : : " packets on receiving if split feature is engaged."
369 : : " Affects only the queues configured with split"
370 : : " offloads.\n"
371 : : " Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
372 : : "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
373 : : "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
374 : : "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
375 : : "inner-ipv4-sctp|inner-ipv6-sctp\n\n"
376 : :
377 : : "set txpkts (x[,y]*)\n"
378 : : " Set the length of each segment of TXONLY"
379 : : " and optionally CSUM packets.\n\n"
380 : :
381 : : "set txsplit (off|on|rand)\n"
382 : : " Set the split policy for the TX packets."
383 : : " Right now only applicable for CSUM and TXONLY"
384 : : " modes\n\n"
385 : :
386 : : "set txtimes (x, y)\n"
387 : : " Set the scheduling on timestamps"
388 : : " timings for the TXONLY mode\n\n"
389 : :
390 : : "set txflows (N)\n"
391 : : " Set the number of flows per lcore in"
392 : : " txonly multi-flow mode (1-64)\n\n"
393 : :
394 : : "set corelist (x[,y]*)\n"
395 : : " Set the list of forwarding cores.\n\n"
396 : :
397 : : "set portlist (x[,y]*)\n"
398 : : " Set the list of forwarding ports.\n\n"
399 : :
400 : : "set port setup on (iterator|event)\n"
401 : : " Select how attached port is retrieved for setup.\n\n"
402 : :
403 : : "set tx loopback (port_id) (on|off)\n"
404 : : " Enable or disable tx loopback.\n\n"
405 : :
406 : : "set all queues drop (port_id) (on|off)\n"
407 : : " Set drop enable bit for all queues.\n\n"
408 : :
409 : : "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
410 : : " Set MAC antispoof for a VF from the PF.\n\n"
411 : :
412 : : "vlan set stripq (on|off) (port_id,queue_id)\n"
413 : : " Set the VLAN strip for a queue on a port.\n\n"
414 : :
415 : : "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
416 : : " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
417 : :
418 : : "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
419 : : " Set VLAN insert for a VF from the PF.\n\n"
420 : :
421 : : "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
422 : : " Set VLAN antispoof for a VF from the PF.\n\n"
423 : :
424 : : "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
425 : : " Set the VLAN strip or filter or qinq strip or extend\n\n"
426 : :
427 : : "vlan set (inner|outer) tpid (value) (port_id)\n"
428 : : " Set the VLAN TPID for Packet Filtering on"
429 : : " a port\n\n"
430 : :
431 : : "rx_vlan add (vlan_id|all) (port_id)\n"
432 : : " Add a vlan_id, or all identifiers, to the set"
433 : : " of VLAN identifiers filtered by port_id.\n\n"
434 : :
435 : : "rx_vlan rm (vlan_id|all) (port_id)\n"
436 : : " Remove a vlan_id, or all identifiers, from the set"
437 : : " of VLAN identifiers filtered by port_id.\n\n"
438 : :
439 : : "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
440 : : " Add a vlan_id, to the set of VLAN identifiers"
441 : : "filtered for VF(s) from port_id.\n\n"
442 : :
443 : : "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
444 : : " Remove a vlan_id, to the set of VLAN identifiers"
445 : : "filtered for VF(s) from port_id.\n\n"
446 : :
447 : : "rx_vxlan_port add (udp_port) (port_id)\n"
448 : : " Add an UDP port for VXLAN packet filter on a port\n\n"
449 : :
450 : : "rx_vxlan_port rm (udp_port) (port_id)\n"
451 : : " Remove an UDP port for VXLAN packet filter on a port\n\n"
452 : :
453 : : "tx_vlan set (port_id) vlan_tci[, vlan_tci_outer]\n"
454 : : " Set hardware insertion of VLAN TCI (single or double VLAN "
455 : : "depends on the number of VLAN TCIs) in packets sent on a port.\n\n"
456 : :
457 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
458 : : " Set port based TX VLAN insertion.\n\n"
459 : :
460 : : "tx_vlan reset (port_id)\n"
461 : : " Disable hardware insertion of a VLAN header in"
462 : : " packets sent on a port.\n\n"
463 : :
464 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
465 : : " Select hardware or software calculation of the"
466 : : " checksum when transmitting a packet using the"
467 : : " csum forward engine.\n"
468 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
469 : : " outer-ip concerns the outer IP layer in"
470 : : " outer-udp concerns the outer UDP layer in"
471 : : " case the packet is recognized as a tunnel packet by"
472 : : " the forward engine (vxlan, gre and ipip are supported)\n"
473 : : " Please check the NIC datasheet for HW limits.\n\n"
474 : :
475 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
476 : : " If disabled, treat tunnel packets as non-tunneled"
477 : : " packets (treat inner headers as payload). The port\n"
478 : : " argument is the port used for TX in csum forward"
479 : : " engine.\n\n"
480 : :
481 : : "csum show (port_id)\n"
482 : : " Display tx checksum offload configuration\n\n"
483 : :
484 : : "tso set (segsize) (portid)\n"
485 : : " Enable TCP Segmentation Offload in csum forward"
486 : : " engine.\n"
487 : : " Please check the NIC datasheet for HW limits.\n\n"
488 : :
489 : : "tso show (portid)"
490 : : " Display the status of TCP Segmentation Offload.\n\n"
491 : :
492 : : #ifdef RTE_LIB_GRO
493 : : "set port (port_id) gro on|off\n"
494 : : " Enable or disable Generic Receive Offload in"
495 : : " csum forwarding engine.\n\n"
496 : :
497 : : "show port (port_id) gro\n"
498 : : " Display GRO configuration.\n\n"
499 : :
500 : : "set gro flush (cycles)\n"
501 : : " Set the cycle to flush GROed packets from"
502 : : " reassembly tables.\n\n"
503 : : #endif
504 : :
505 : : #ifdef RTE_LIB_GSO
506 : : "set port (port_id) gso (on|off)"
507 : : " Enable or disable Generic Segmentation Offload in"
508 : : " csum forwarding engine.\n\n"
509 : :
510 : : "set gso segsz (length)\n"
511 : : " Set max packet length for output GSO segments,"
512 : : " including packet header and payload.\n\n"
513 : :
514 : : "show port (port_id) gso\n"
515 : : " Show GSO configuration.\n\n"
516 : : #endif
517 : :
518 : : "set fwd (%s)\n"
519 : : " Set packet forwarding mode.\n\n"
520 : :
521 : : "set dcb fwd_tc (tc_mask)\n"
522 : : " Set DCB forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled\n\n"
523 : :
524 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
525 : : " Add a MAC address on port_id.\n\n"
526 : :
527 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
528 : : " Remove a MAC address from port_id.\n\n"
529 : :
530 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
531 : : " Set the default MAC address for port_id.\n\n"
532 : :
533 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
534 : : " Add a MAC address for a VF on the port.\n\n"
535 : :
536 : : "mcast_addr add (port_id) (mcast_addr)\n"
537 : : " Add a multicast MAC addresses on port_id.\n\n"
538 : :
539 : : "mcast_addr remove (port_id) (mcast_addr)\n"
540 : : " Remove a multicast MAC address from port_id.\n\n"
541 : :
542 : : "mcast_addr flush (port_id)\n"
543 : : " Flush all multicast MAC addresses on port_id.\n\n"
544 : :
545 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
546 : : " Set the MAC address for a VF from the PF.\n\n"
547 : :
548 : : "set eth-peer (port_id) (peer_addr)\n"
549 : : " set the peer address for certain port.\n\n"
550 : :
551 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
552 : : " Add/Remove a or all unicast hash filter(s)"
553 : : "from port X.\n\n"
554 : :
555 : : "set promisc (port_id|all) (on|off)\n"
556 : : " Set the promiscuous mode on port_id, or all.\n\n"
557 : :
558 : : "set allmulti (port_id|all) (on|off)\n"
559 : : " Set the allmulti mode on port_id, or all.\n\n"
560 : :
561 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
562 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
563 : : " (on|off) autoneg (on|off) (port_id)\n"
564 : : "set flow_ctrl rx (on|off) (portid)\n"
565 : : "set flow_ctrl tx (on|off) (portid)\n"
566 : : "set flow_ctrl high_water (high_water) (portid)\n"
567 : : "set flow_ctrl low_water (low_water) (portid)\n"
568 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
569 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
570 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
571 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
572 : : " Set the link flow control parameter on a port.\n\n"
573 : :
574 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
575 : : " (low_water) (pause_time) (priority) (port_id)\n"
576 : : " Set the priority flow control parameter on a"
577 : : " port.\n\n"
578 : :
579 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
580 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
581 : : " Set the queue priority flow control parameter on a"
582 : : " given Rx and Tx queues of a port.\n\n"
583 : :
584 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
585 : : " set available descriptors threshold for Rx queue\n\n"
586 : :
587 : : "set xstats-hide-zero on|off\n"
588 : : " Set the option to hide the zero values"
589 : : " for xstats display.\n"
590 : :
591 : : "set record-core-cycles on|off\n"
592 : : " Set the option to enable measurement of CPU cycles.\n"
593 : :
594 : : "set record-burst-stats on|off\n"
595 : : " Set the option to enable display of RX and TX bursts.\n"
596 : :
597 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
598 : : " Enable/Disable a VF receive/transmit from a port\n\n"
599 : :
600 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
601 : : "|MPE) (on|off)\n"
602 : : " AUPE:accepts untagged VLAN;"
603 : : "ROPE:accept unicast hash\n\n"
604 : : " BAM:accepts broadcast packets;"
605 : : "MPE:accepts all multicast packets\n\n"
606 : : " Enable/Disable a VF receive mode of a port\n\n"
607 : :
608 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
609 : : " Set rate limit for a queue of a port\n\n"
610 : :
611 : : "set port (port_id) vf (vf_id) rate (rate_num) "
612 : : "queue_mask (queue_mask_value)\n"
613 : : " Set rate limit for queues in VF of a port\n\n"
614 : :
615 : : "set flush_rx (on|off)\n"
616 : : " Flush (default) or don't flush RX streams before"
617 : : " forwarding. Mainly used with PCAP drivers.\n\n"
618 : :
619 : : "set link-up port (port_id)\n"
620 : : " Set link up for a port.\n\n"
621 : :
622 : : "set link-down port (port_id)\n"
623 : : " Set link down for a port.\n\n"
624 : :
625 : : "set port (port_id) ptype_mask (ptype_mask)\n"
626 : : " set packet types classification for a specific port\n\n"
627 : :
628 : : "show port meter cap (port_id)\n"
629 : : " Show port meter capability information\n\n"
630 : :
631 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
632 : : " meter profile add - srtcm rfc 2697\n\n"
633 : :
634 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
635 : : " meter profile add - trtcm rfc 2698\n\n"
636 : :
637 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
638 : : " meter profile add - trtcm rfc 4115\n\n"
639 : :
640 : : "del port meter profile (port_id) (profile_id)\n"
641 : : " meter profile delete\n\n"
642 : :
643 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
644 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
645 : : "(dscp_tbl_entry63)]\n"
646 : : " meter create\n\n"
647 : :
648 : : "enable port meter (port_id) (mtr_id)\n"
649 : : " meter enable\n\n"
650 : :
651 : : "disable port meter (port_id) (mtr_id)\n"
652 : : " meter disable\n\n"
653 : :
654 : : "del port meter (port_id) (mtr_id)\n"
655 : : " meter delete\n\n"
656 : :
657 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
658 : : "y_actions (actions) r_actions (actions)\n"
659 : : " meter policy add\n\n"
660 : :
661 : : "del port meter policy (port_id) (policy_id)\n"
662 : : " meter policy delete\n\n"
663 : :
664 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
665 : : " meter update meter profile\n\n"
666 : :
667 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
668 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
669 : : " update meter dscp table entries\n\n"
670 : :
671 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
672 : : "(action0) [(action1) (action2)]\n"
673 : : " meter update policer action\n\n"
674 : :
675 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
676 : : " meter update stats\n\n"
677 : :
678 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
679 : : " set fec mode for a specific port\n\n"
680 : :
681 : : "show port cman capa (port_id)\n"
682 : : " Show congestion management capabilities\n\n"
683 : :
684 : : "show port cman config (port_id)\n"
685 : : " Show congestion management configuration\n\n"
686 : :
687 : : "set port cman config (port_id) (queue_id) default | "
688 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
689 : : "(max_thresh) (prob_inv)]\n"
690 : : " Set congestion management configuration\n\n"
691 : :
692 : : "set port (port_id) led (on|off)\n"
693 : : " Set a controllable LED associated with a certain"
694 : : " port on or off.\n\n"
695 : :
696 : : , list_pkt_forwarding_modes()
697 : : );
698 : : }
699 : :
700 : 0 : if (show_all || !strcmp(res->section, "ports")) {
701 : :
702 : 0 : cmdline_printf(
703 : : cl,
704 : : "\n"
705 : : "Port Operations:\n"
706 : : "----------------\n\n"
707 : :
708 : : "port start (port_id|all)\n"
709 : : " Start all ports or port_id.\n\n"
710 : :
711 : : "port stop (port_id|all)\n"
712 : : " Stop all ports or port_id.\n\n"
713 : :
714 : : "port close (port_id|all)\n"
715 : : " Close all ports or port_id.\n\n"
716 : :
717 : : "port reset (port_id|all)\n"
718 : : " Reset all ports or port_id.\n\n"
719 : :
720 : : "port attach (ident)\n"
721 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
722 : :
723 : : "port detach (port_id)\n"
724 : : " Detach physical or virtual dev by port_id\n\n"
725 : :
726 : : "port config (port_id|all)"
727 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|"
728 : : "100000|200000|400000|800000|1600000|auto)"
729 : : " duplex (half|full|auto) [autoneg (on|off)]\n"
730 : : " Set speed and duplex; optionally enable or disable link autonegotiation\n\n"
731 : :
732 : : "port config (port_id|all) loopback (mode)\n"
733 : : " Set loopback mode for all ports or port_id\n\n"
734 : :
735 : : "port config all (rxq|txq|rxd|txd) (value)\n"
736 : : " Set number for rxq/txq/rxd/txd.\n\n"
737 : :
738 : : "port config all max-pkt-len (value)\n"
739 : : " Set the max packet length.\n\n"
740 : :
741 : : "port config all max-lro-pkt-size (value)\n"
742 : : " Set the max LRO aggregated packet size.\n\n"
743 : :
744 : : "port config all drop-en (on|off)\n"
745 : : " Enable or disable packet drop on all RX queues of all ports when no "
746 : : "receive buffers available.\n\n"
747 : :
748 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
749 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
750 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
751 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
752 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
753 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
754 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
755 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
756 : : " Set the RSS mode.\n\n"
757 : :
758 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
759 : : " Set the RSS redirection table.\n\n"
760 : :
761 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
762 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
763 : : " Set the RSS hash algorithm.\n\n"
764 : :
765 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
766 : : " pfc (on|off)\n"
767 : : " Set the DCB mode.\n\n"
768 : :
769 : : "port config all burst (value)\n"
770 : : " Set the number of packets per burst.\n\n"
771 : :
772 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
773 : : " (value)\n"
774 : : " Set the ring prefetch/host/writeback threshold"
775 : : " for tx/rx queue.\n\n"
776 : :
777 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
778 : : " Set free threshold for rx/tx, or set"
779 : : " tx rs bit threshold.\n\n"
780 : : "port config mtu X value\n"
781 : : " Set the MTU of port X to a given value\n\n"
782 : :
783 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
784 : : " Set a rx/tx queue's ring size configuration, the new"
785 : : " value will take effect after command that (re-)start the port"
786 : : " or command that setup the specific queue\n\n"
787 : :
788 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
789 : : " Start/stop a rx/tx queue of port X. Only take effect"
790 : : " when port X is started\n\n"
791 : :
792 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
793 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
794 : : " take effect when port X is stopped.\n\n"
795 : :
796 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
797 : : " Setup a rx/tx queue of port X.\n\n"
798 : :
799 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
800 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
801 : :
802 : : "port config (port_id|all) rx_offload all|vlan_strip|"
803 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
804 : : "outer_ipv4_cksum|macsec_strip|"
805 : : "vlan_filter|vlan_extend|scatter|"
806 : : "buffer_split|timestamp|security|keep_crc on|off\n"
807 : : " Enable or disable a per port Rx offloading"
808 : : " on all Rx queues of a port\n\n"
809 : :
810 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
811 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
812 : : "outer_ipv4_cksum|macsec_strip|"
813 : : "vlan_filter|vlan_extend|scatter|"
814 : : "buffer_split|timestamp|security|keep_crc on|off\n"
815 : : " Enable or disable a per queue Rx offloading"
816 : : " only on a specific Rx queue\n\n"
817 : :
818 : : "port config (port_id|all) tx_offload all|vlan_insert|"
819 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
820 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
821 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
822 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
823 : : "security on|off\n"
824 : : " Enable or disable a per port Tx offloading"
825 : : " on all Tx queues of a port\n\n"
826 : :
827 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
828 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
829 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
830 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
831 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
832 : : " on|off\n"
833 : : " Enable or disable a per queue Tx offloading"
834 : : " only on a specific Tx queue\n\n"
835 : :
836 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
837 : : " Load an eBPF program as a callback"
838 : : " for particular RX/TX queue\n\n"
839 : :
840 : : "bpf-unload rx|tx (port) (queue)\n"
841 : : " Unload previously loaded eBPF program"
842 : : " for particular RX/TX queue\n\n"
843 : :
844 : : "port config (port_id) tx_metadata (value)\n"
845 : : " Set Tx metadata value per port. Testpmd will add this value"
846 : : " to any Tx packet sent from this port\n\n"
847 : :
848 : : "port config (port_id) dynf (name) set|clear\n"
849 : : " Register a dynf and Set/clear this flag on Tx. "
850 : : "Testpmd will set this value to any Tx packet "
851 : : "sent from this port\n\n"
852 : :
853 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
854 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
855 : :
856 : : "port config (port_id) txq (queue_id) affinity (value)\n"
857 : : " Map a Tx queue with an aggregated port "
858 : : "of the DPDK port\n\n"
859 : :
860 : : "port config (port_id|all) speed_lanes (value)\n"
861 : : " Set number of lanes for all ports or port_id for a forced speed\n\n"
862 : : );
863 : : }
864 : :
865 : 0 : if (show_all || !strcmp(res->section, "filters")) {
866 : :
867 : 0 : cmdline_printf(
868 : : cl,
869 : : "\n"
870 : : "filters:\n"
871 : : "--------\n\n"
872 : :
873 : : "flow validate {port_id}"
874 : : " [group {group_id}] [priority {level}]"
875 : : " [ingress] [egress]"
876 : : " pattern {item} [/ {item} [...]] / end"
877 : : " actions {action} [/ {action} [...]] / end\n"
878 : : " Check whether a flow rule can be created.\n\n"
879 : :
880 : : "flow create {port_id}"
881 : : " [group {group_id}] [priority {level}]"
882 : : " [ingress] [egress]"
883 : : " pattern {item} [/ {item} [...]] / end"
884 : : " actions {action} [/ {action} [...]] / end\n"
885 : : " Create a flow rule.\n\n"
886 : :
887 : : "flow destroy {port_id} rule {rule_id} [...]\n"
888 : : " Destroy specific flow rules.\n\n"
889 : :
890 : : "flow update {port_id} {rule_id}"
891 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
892 : : " Update a flow rule with new actions.\n\n"
893 : :
894 : : "flow flush {port_id}\n"
895 : : " Destroy all flow rules.\n\n"
896 : :
897 : : "flow query {port_id} {rule_id} {action}\n"
898 : : " Query an existing flow rule.\n\n"
899 : :
900 : : "flow list {port_id} [group {group_id}] [...]\n"
901 : : " List existing flow rules sorted by priority,"
902 : : " filtered by group identifiers.\n\n"
903 : :
904 : : "flow isolate {port_id} {boolean}\n"
905 : : " Restrict ingress traffic to the defined"
906 : : " flow rules\n\n"
907 : :
908 : : "flow aged {port_id} [destroy]\n"
909 : : " List and destroy aged flows"
910 : : " flow rules\n\n"
911 : :
912 : : "flow indirect_action {port_id} create"
913 : : " [action_id {indirect_action_id}]"
914 : : " [ingress] [egress]"
915 : : " action {action} / end\n"
916 : : " Create indirect action.\n\n"
917 : :
918 : : "flow indirect_action {port_id} update"
919 : : " {indirect_action_id} action {action} / end\n"
920 : : " Update indirect action.\n\n"
921 : :
922 : : "flow indirect_action {port_id} destroy"
923 : : " action_id {indirect_action_id} [...]\n"
924 : : " Destroy specific indirect actions.\n\n"
925 : :
926 : : "flow indirect_action {port_id} query"
927 : : " {indirect_action_id}\n"
928 : : " Query an existing indirect action.\n\n"
929 : :
930 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
931 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
932 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
933 : : " Configure the VXLAN encapsulation for flows.\n\n"
934 : :
935 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
936 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
937 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
938 : : " eth-dst (eth-dst)\n"
939 : : " Configure the VXLAN encapsulation for flows.\n\n"
940 : :
941 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
942 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
943 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
944 : : " eth-dst (eth-dst)\n"
945 : : " Configure the VXLAN encapsulation for flows.\n\n"
946 : :
947 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
948 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
949 : : " (eth-dst)\n"
950 : : " Configure the NVGRE encapsulation for flows.\n\n"
951 : :
952 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
953 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
954 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
955 : : " Configure the NVGRE encapsulation for flows.\n\n"
956 : :
957 : : "set raw_encap {flow items}\n"
958 : : " Configure the encapsulation with raw data.\n\n"
959 : :
960 : : "set raw_decap {flow items}\n"
961 : : " Configure the decapsulation with raw data.\n\n"
962 : :
963 : : );
964 : : }
965 : :
966 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
967 : 0 : cmdline_printf(
968 : : cl,
969 : : "\n"
970 : : "Traffic Management:\n"
971 : : "--------------\n"
972 : : "show port tm cap (port_id)\n"
973 : : " Display the port TM capability.\n\n"
974 : :
975 : : "show port tm level cap (port_id) (level_id)\n"
976 : : " Display the port TM hierarchical level capability.\n\n"
977 : :
978 : : "show port tm node cap (port_id) (node_id)\n"
979 : : " Display the port TM node capability.\n\n"
980 : :
981 : : "show port tm node type (port_id) (node_id)\n"
982 : : " Display the port TM node type.\n\n"
983 : :
984 : : "show port tm node stats (port_id) (node_id) (clear)\n"
985 : : " Display the port TM node stats.\n\n"
986 : :
987 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
988 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
989 : : " (packet_length_adjust) (packet_mode)\n"
990 : : " Add port tm node private shaper profile.\n\n"
991 : :
992 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
993 : : " Delete port tm node private shaper profile.\n\n"
994 : :
995 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
996 : : " (shaper_profile_id)\n"
997 : : " Add/update port tm node shared shaper.\n\n"
998 : :
999 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1000 : : " Delete port tm node shared shaper.\n\n"
1001 : :
1002 : : "set port tm node shaper profile (port_id) (node_id)"
1003 : : " (shaper_profile_id)\n"
1004 : : " Set port tm node shaper profile.\n\n"
1005 : :
1006 : : "add port tm node wred profile (port_id) (wred_profile_id)"
1007 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1008 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1009 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1010 : : " Add port tm node wred profile.\n\n"
1011 : :
1012 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
1013 : : " Delete port tm node wred profile.\n\n"
1014 : :
1015 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1016 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1017 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1018 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1019 : : " Add port tm nonleaf node.\n\n"
1020 : :
1021 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1022 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1023 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1024 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1025 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
1026 : :
1027 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1028 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1029 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1030 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1031 : : " Add port tm leaf node.\n\n"
1032 : :
1033 : : "del port tm node (port_id) (node_id)\n"
1034 : : " Delete port tm node.\n\n"
1035 : :
1036 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1037 : : " (priority) (weight)\n"
1038 : : " Set port tm node parent.\n\n"
1039 : :
1040 : : "suspend port tm node (port_id) (node_id)"
1041 : : " Suspend tm node.\n\n"
1042 : :
1043 : : "resume port tm node (port_id) (node_id)"
1044 : : " Resume tm node.\n\n"
1045 : :
1046 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1047 : : " Commit tm hierarchy.\n\n"
1048 : :
1049 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1050 : : " (red)\n"
1051 : : " Enables/Disables the traffic management marking"
1052 : : " for IP ECN (Explicit Congestion Notification)"
1053 : : " packets on a given port\n\n"
1054 : :
1055 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1056 : : " (red)\n"
1057 : : " Enables/Disables the traffic management marking"
1058 : : " on the port for IP dscp packets\n\n"
1059 : :
1060 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1061 : : " (red)\n"
1062 : : " Enables/Disables the traffic management marking"
1063 : : " on the port for VLAN packets with DEI enabled\n\n"
1064 : : );
1065 : : }
1066 : :
1067 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1068 : 0 : cmdline_printf(
1069 : : cl,
1070 : : "\n"
1071 : : "Device Operations:\n"
1072 : : "--------------\n"
1073 : : "device detach (identifier)\n"
1074 : : " Detach device by identifier.\n\n"
1075 : : );
1076 : : }
1077 : :
1078 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1079 : : struct testpmd_driver_commands *c;
1080 : : unsigned int i;
1081 : :
1082 : 0 : cmdline_printf(
1083 : : cl,
1084 : : "\n"
1085 : : "Driver specific:\n"
1086 : : "----------------\n"
1087 : : );
1088 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1089 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1090 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1091 : : }
1092 : : }
1093 : 0 : }
1094 : :
1095 : : static cmdline_parse_token_string_t cmd_help_long_help =
1096 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1097 : :
1098 : : static cmdline_parse_token_string_t cmd_help_long_section =
1099 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1100 : : "all#control#display#config#ports#"
1101 : : "filters#traffic_management#devices#drivers");
1102 : :
1103 : : static cmdline_parse_inst_t cmd_help_long = {
1104 : : .f = cmd_help_long_parsed,
1105 : : .data = NULL,
1106 : : .help_str = "help all|control|display|config|ports|"
1107 : : "filters|traffic_management|devices|drivers: "
1108 : : "Show help",
1109 : : .tokens = {
1110 : : (void *)&cmd_help_long_help,
1111 : : (void *)&cmd_help_long_section,
1112 : : NULL,
1113 : : },
1114 : : };
1115 : :
1116 : :
1117 : : /* *** start/stop/close all ports *** */
1118 : : struct cmd_operate_port_result {
1119 : : cmdline_fixed_string_t keyword;
1120 : : cmdline_fixed_string_t name;
1121 : : cmdline_fixed_string_t value;
1122 : : };
1123 : :
1124 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1125 : : __rte_unused struct cmdline *cl,
1126 : : __rte_unused void *data)
1127 : : {
1128 : : struct cmd_operate_port_result *res = parsed_result;
1129 : :
1130 : 0 : if (!strcmp(res->name, "start"))
1131 : 0 : start_port(RTE_PORT_ALL);
1132 : 0 : else if (!strcmp(res->name, "stop"))
1133 : 0 : stop_port(RTE_PORT_ALL);
1134 : 0 : else if (!strcmp(res->name, "close"))
1135 : 0 : close_port(RTE_PORT_ALL);
1136 : 0 : else if (!strcmp(res->name, "reset"))
1137 : 0 : reset_port(RTE_PORT_ALL);
1138 : : else
1139 : 0 : fprintf(stderr, "Unknown parameter\n");
1140 : 0 : }
1141 : :
1142 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1143 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1144 : : "port");
1145 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1146 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1147 : : "start#stop#close#reset");
1148 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1149 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1150 : :
1151 : : static cmdline_parse_inst_t cmd_operate_port = {
1152 : : .f = cmd_operate_port_parsed,
1153 : : .data = NULL,
1154 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1155 : : .tokens = {
1156 : : (void *)&cmd_operate_port_all_cmd,
1157 : : (void *)&cmd_operate_port_all_port,
1158 : : (void *)&cmd_operate_port_all_all,
1159 : : NULL,
1160 : : },
1161 : : };
1162 : :
1163 : : /* *** start/stop/close specific port *** */
1164 : : struct cmd_operate_specific_port_result {
1165 : : cmdline_fixed_string_t keyword;
1166 : : cmdline_fixed_string_t name;
1167 : : uint8_t value;
1168 : : };
1169 : :
1170 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1171 : : __rte_unused struct cmdline *cl,
1172 : : __rte_unused void *data)
1173 : : {
1174 : : struct cmd_operate_specific_port_result *res = parsed_result;
1175 : :
1176 : 0 : if (!strcmp(res->name, "start"))
1177 : 0 : start_port(res->value);
1178 : 0 : else if (!strcmp(res->name, "stop"))
1179 : 0 : stop_port(res->value);
1180 : 0 : else if (!strcmp(res->name, "close"))
1181 : 0 : close_port(res->value);
1182 : 0 : else if (!strcmp(res->name, "reset"))
1183 : 0 : reset_port(res->value);
1184 : : else
1185 : 0 : fprintf(stderr, "Unknown parameter\n");
1186 : 0 : }
1187 : :
1188 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1189 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1190 : : keyword, "port");
1191 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1192 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1193 : : name, "start#stop#close#reset");
1194 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1195 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1196 : : value, RTE_UINT8);
1197 : :
1198 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1199 : : .f = cmd_operate_specific_port_parsed,
1200 : : .data = NULL,
1201 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1202 : : .tokens = {
1203 : : (void *)&cmd_operate_specific_port_cmd,
1204 : : (void *)&cmd_operate_specific_port_port,
1205 : : (void *)&cmd_operate_specific_port_id,
1206 : : NULL,
1207 : : },
1208 : : };
1209 : :
1210 : : /* *** enable port setup (after attach) via iterator or event *** */
1211 : : struct cmd_set_port_setup_on_result {
1212 : : cmdline_fixed_string_t set;
1213 : : cmdline_fixed_string_t port;
1214 : : cmdline_fixed_string_t setup;
1215 : : cmdline_fixed_string_t on;
1216 : : cmdline_fixed_string_t mode;
1217 : : };
1218 : :
1219 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1220 : : __rte_unused struct cmdline *cl,
1221 : : __rte_unused void *data)
1222 : : {
1223 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1224 : :
1225 : 0 : if (strcmp(res->mode, "event") == 0)
1226 : 0 : setup_on_probe_event = true;
1227 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1228 : 0 : setup_on_probe_event = false;
1229 : : else
1230 : 0 : fprintf(stderr, "Unknown mode\n");
1231 : 0 : }
1232 : :
1233 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1234 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1235 : : set, "set");
1236 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1237 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1238 : : port, "port");
1239 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1240 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1241 : : setup, "setup");
1242 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1243 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1244 : : on, "on");
1245 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1246 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1247 : : mode, "iterator#event");
1248 : :
1249 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1250 : : .f = cmd_set_port_setup_on_parsed,
1251 : : .data = NULL,
1252 : : .help_str = "set port setup on iterator|event",
1253 : : .tokens = {
1254 : : (void *)&cmd_set_port_setup_on_set,
1255 : : (void *)&cmd_set_port_setup_on_port,
1256 : : (void *)&cmd_set_port_setup_on_setup,
1257 : : (void *)&cmd_set_port_setup_on_on,
1258 : : (void *)&cmd_set_port_setup_on_mode,
1259 : : NULL,
1260 : : },
1261 : : };
1262 : :
1263 : : /* *** attach a specified port *** */
1264 : : struct cmd_operate_attach_port_result {
1265 : : cmdline_fixed_string_t port;
1266 : : cmdline_fixed_string_t keyword;
1267 : : cmdline_multi_string_t identifier;
1268 : : };
1269 : :
1270 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1271 : : __rte_unused struct cmdline *cl,
1272 : : __rte_unused void *data)
1273 : : {
1274 : : struct cmd_operate_attach_port_result *res = parsed_result;
1275 : :
1276 : 0 : if (!strcmp(res->keyword, "attach"))
1277 : 0 : attach_port(res->identifier);
1278 : : else
1279 : 0 : fprintf(stderr, "Unknown parameter\n");
1280 : 0 : }
1281 : :
1282 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1283 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1284 : : port, "port");
1285 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1286 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1287 : : keyword, "attach");
1288 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1289 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1290 : : identifier, TOKEN_STRING_MULTI);
1291 : :
1292 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1293 : : .f = cmd_operate_attach_port_parsed,
1294 : : .data = NULL,
1295 : : .help_str = "port attach <identifier>: "
1296 : : "(identifier: pci address or virtual dev name)",
1297 : : .tokens = {
1298 : : (void *)&cmd_operate_attach_port_port,
1299 : : (void *)&cmd_operate_attach_port_keyword,
1300 : : (void *)&cmd_operate_attach_port_identifier,
1301 : : NULL,
1302 : : },
1303 : : };
1304 : :
1305 : : /* *** detach a specified port *** */
1306 : : struct cmd_operate_detach_port_result {
1307 : : cmdline_fixed_string_t port;
1308 : : cmdline_fixed_string_t keyword;
1309 : : portid_t port_id;
1310 : : };
1311 : :
1312 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1313 : : __rte_unused struct cmdline *cl,
1314 : : __rte_unused void *data)
1315 : : {
1316 : : struct cmd_operate_detach_port_result *res = parsed_result;
1317 : :
1318 : 0 : if (!strcmp(res->keyword, "detach")) {
1319 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1320 : 0 : detach_port_device(res->port_id);
1321 : : } else {
1322 : 0 : fprintf(stderr, "Unknown parameter\n");
1323 : : }
1324 : : }
1325 : :
1326 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1327 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1328 : : port, "port");
1329 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1330 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1331 : : keyword, "detach");
1332 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1333 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1334 : : port_id, RTE_UINT16);
1335 : :
1336 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1337 : : .f = cmd_operate_detach_port_parsed,
1338 : : .data = NULL,
1339 : : .help_str = "port detach <port_id>",
1340 : : .tokens = {
1341 : : (void *)&cmd_operate_detach_port_port,
1342 : : (void *)&cmd_operate_detach_port_keyword,
1343 : : (void *)&cmd_operate_detach_port_port_id,
1344 : : NULL,
1345 : : },
1346 : : };
1347 : :
1348 : : /* *** detach device by identifier *** */
1349 : : struct cmd_operate_detach_device_result {
1350 : : cmdline_fixed_string_t device;
1351 : : cmdline_fixed_string_t keyword;
1352 : : cmdline_fixed_string_t identifier;
1353 : : };
1354 : :
1355 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1356 : : __rte_unused struct cmdline *cl,
1357 : : __rte_unused void *data)
1358 : : {
1359 : : struct cmd_operate_detach_device_result *res = parsed_result;
1360 : :
1361 : 0 : if (!strcmp(res->keyword, "detach"))
1362 : 0 : detach_devargs(res->identifier);
1363 : : else
1364 : 0 : fprintf(stderr, "Unknown parameter\n");
1365 : 0 : }
1366 : :
1367 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1368 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1369 : : device, "device");
1370 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1371 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1372 : : keyword, "detach");
1373 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1374 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1375 : : identifier, NULL);
1376 : :
1377 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1378 : : .f = cmd_operate_detach_device_parsed,
1379 : : .data = NULL,
1380 : : .help_str = "device detach <identifier>:"
1381 : : "(identifier: pci address or virtual dev name)",
1382 : : .tokens = {
1383 : : (void *)&cmd_operate_detach_device_device,
1384 : : (void *)&cmd_operate_detach_device_keyword,
1385 : : (void *)&cmd_operate_detach_device_identifier,
1386 : : NULL,
1387 : : },
1388 : : };
1389 : : /* *** configure speed for all ports *** */
1390 : : struct cmd_config_speed_all {
1391 : : cmdline_fixed_string_t port;
1392 : : cmdline_fixed_string_t keyword;
1393 : : cmdline_fixed_string_t all;
1394 : : cmdline_fixed_string_t item1;
1395 : : cmdline_fixed_string_t item2;
1396 : : cmdline_fixed_string_t value1;
1397 : : cmdline_fixed_string_t value2;
1398 : : cmdline_fixed_string_t autoneg;
1399 : : cmdline_fixed_string_t autoneg_value;
1400 : : };
1401 : :
1402 : : static bool
1403 : 0 : link_speed_is_fixed(const char *speed, const char *autoneg)
1404 : : {
1405 : 0 : if (autoneg == NULL)
1406 : : /* if no flag specified, set fixed speed if speed is not "auto" */
1407 : 0 : return strcmp(speed, "auto") != 0;
1408 : :
1409 : 0 : return strcmp(autoneg, "off") == 0;
1410 : : }
1411 : :
1412 : : static int
1413 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, bool fixed, uint32_t *speed)
1414 : : {
1415 : :
1416 : : int duplex;
1417 : :
1418 : 0 : if (!strcmp(duplexstr, "half")) {
1419 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1420 : 0 : } else if (!strcmp(duplexstr, "full")) {
1421 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1422 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1423 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1424 : : } else {
1425 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1426 : 0 : return -1;
1427 : : }
1428 : :
1429 : 0 : if (!strcmp(speedstr, "10")) {
1430 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1431 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1432 : 0 : } else if (!strcmp(speedstr, "100")) {
1433 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1434 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1435 : : } else {
1436 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1437 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1438 : 0 : return -1;
1439 : : }
1440 : 0 : if (!strcmp(speedstr, "1000")) {
1441 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1442 : 0 : } else if (!strcmp(speedstr, "2500")) {
1443 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1444 : 0 : } else if (!strcmp(speedstr, "5000")) {
1445 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1446 : 0 : } else if (!strcmp(speedstr, "10000")) {
1447 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1448 : 0 : } else if (!strcmp(speedstr, "25000")) {
1449 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1450 : 0 : } else if (!strcmp(speedstr, "40000")) {
1451 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1452 : 0 : } else if (!strcmp(speedstr, "50000")) {
1453 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1454 : 0 : } else if (!strcmp(speedstr, "100000")) {
1455 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1456 : 0 : } else if (!strcmp(speedstr, "200000")) {
1457 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1458 : 0 : } else if (!strcmp(speedstr, "400000")) {
1459 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1460 : 0 : } else if (!strcmp(speedstr, "800000")) {
1461 : 0 : *speed = RTE_ETH_LINK_SPEED_800G;
1462 : 0 : } else if (!strcmp(speedstr, "1600000")) {
1463 : 0 : *speed = RTE_ETH_LINK_SPEED_1600G;
1464 : 0 : } else if (!strcmp(speedstr, "auto")) {
1465 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1466 : : } else {
1467 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1468 : 0 : return -1;
1469 : : }
1470 : : }
1471 : :
1472 : 0 : if (fixed) {
1473 : 0 : if (*speed == RTE_ETH_LINK_SPEED_AUTONEG) {
1474 : 0 : fprintf(stderr, "A fixed link requires a specific speed\n");
1475 : 0 : return -1;
1476 : : }
1477 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1478 : : }
1479 : :
1480 : : return 0;
1481 : : }
1482 : :
1483 : : static void
1484 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1485 : : __rte_unused struct cmdline *cl,
1486 : : void *data)
1487 : : {
1488 : : struct cmd_config_speed_all *res = parsed_result;
1489 : : /* data is used to identify command variant with/without explicit autoneg setting */
1490 : 0 : const char *autoneg = data != NULL ? res->autoneg_value : NULL;
1491 : : uint32_t link_speed;
1492 : : portid_t pid;
1493 : :
1494 : 0 : if (!all_ports_stopped()) {
1495 : 0 : fprintf(stderr, "Please stop all ports first\n");
1496 : 0 : return;
1497 : : }
1498 : :
1499 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1500 : 0 : link_speed_is_fixed(res->value1, autoneg), &link_speed) < 0)
1501 : : return;
1502 : :
1503 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1504 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1505 : : }
1506 : :
1507 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1508 : : }
1509 : :
1510 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1511 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1512 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1513 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1514 : : "config");
1515 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1516 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1517 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1518 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1519 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1520 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1521 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1522 : : "100000#200000#400000#800000#1600000#auto");
1523 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1524 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1525 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1526 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1527 : : "half#full#auto");
1528 : : static cmdline_parse_token_string_t cmd_config_speed_all_autoneg_token =
1529 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, autoneg, "autoneg");
1530 : : static cmdline_parse_token_string_t cmd_config_speed_all_autoneg_value =
1531 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, autoneg_value, "on#off");
1532 : :
1533 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1534 : : .f = cmd_config_speed_all_parsed,
1535 : : .data = NULL,
1536 : : .help_str = "port config all speed "
1537 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1538 : : "100000|200000|400000|800000|1600000|auto "
1539 : : "duplex half|full|auto",
1540 : : .tokens = {
1541 : : (void *)&cmd_config_speed_all_port,
1542 : : (void *)&cmd_config_speed_all_keyword,
1543 : : (void *)&cmd_config_speed_all_all,
1544 : : (void *)&cmd_config_speed_all_item1,
1545 : : (void *)&cmd_config_speed_all_value1,
1546 : : (void *)&cmd_config_speed_all_item2,
1547 : : (void *)&cmd_config_speed_all_value2,
1548 : : NULL,
1549 : : },
1550 : : };
1551 : :
1552 : : static cmdline_parse_inst_t cmd_config_speed_all_autoneg = {
1553 : : .f = cmd_config_speed_all_parsed,
1554 : : .data = &cmd_config_speed_all_autoneg,
1555 : : .help_str = "port config all speed "
1556 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1557 : : "100000|200000|400000|800000|auto "
1558 : : "duplex half|full|auto autoneg on|off",
1559 : : .tokens = {
1560 : : (void *)&cmd_config_speed_all_port,
1561 : : (void *)&cmd_config_speed_all_keyword,
1562 : : (void *)&cmd_config_speed_all_all,
1563 : : (void *)&cmd_config_speed_all_item1,
1564 : : (void *)&cmd_config_speed_all_value1,
1565 : : (void *)&cmd_config_speed_all_item2,
1566 : : (void *)&cmd_config_speed_all_value2,
1567 : : (void *)&cmd_config_speed_all_autoneg_token,
1568 : : (void *)&cmd_config_speed_all_autoneg_value,
1569 : : NULL,
1570 : : },
1571 : : };
1572 : :
1573 : : /* *** configure speed for specific port *** */
1574 : : struct cmd_config_speed_specific {
1575 : : cmdline_fixed_string_t port;
1576 : : cmdline_fixed_string_t keyword;
1577 : : portid_t id;
1578 : : cmdline_fixed_string_t item1;
1579 : : cmdline_fixed_string_t item2;
1580 : : cmdline_fixed_string_t value1;
1581 : : cmdline_fixed_string_t value2;
1582 : : cmdline_fixed_string_t autoneg;
1583 : : cmdline_fixed_string_t autoneg_value;
1584 : : };
1585 : :
1586 : : static void
1587 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1588 : : __rte_unused struct cmdline *cl,
1589 : : void *data)
1590 : : {
1591 : : struct cmd_config_speed_specific *res = parsed_result;
1592 : : /* data is used to identify command variant with/without explicit autoneg setting */
1593 : 0 : const char *autoneg = data != NULL ? res->autoneg_value : NULL;
1594 : : uint32_t link_speed;
1595 : :
1596 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1597 : 0 : return;
1598 : :
1599 : 0 : if (!port_is_stopped(res->id)) {
1600 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1601 : 0 : return;
1602 : : }
1603 : :
1604 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1605 : 0 : link_speed_is_fixed(res->value1, autoneg), &link_speed) < 0)
1606 : : return;
1607 : :
1608 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1609 : :
1610 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1611 : : }
1612 : :
1613 : :
1614 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1615 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1616 : : "port");
1617 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1618 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1619 : : "config");
1620 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1621 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1622 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1623 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1624 : : "speed");
1625 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1626 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1627 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1628 : : "100000#200000#400000#800000#1600000#auto");
1629 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1630 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1631 : : "duplex");
1632 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1633 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1634 : : "half#full#auto");
1635 : : static cmdline_parse_token_string_t cmd_config_speed_specific_autoneg_token =
1636 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, autoneg, "autoneg");
1637 : : static cmdline_parse_token_string_t cmd_config_speed_specific_autoneg_value =
1638 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, autoneg_value, "on#off");
1639 : :
1640 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1641 : : .f = cmd_config_speed_specific_parsed,
1642 : : .data = NULL,
1643 : : .help_str = "port config <port_id> speed "
1644 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1645 : : "100000|200000|400000|800000|1600000|auto "
1646 : : "duplex half|full|auto",
1647 : : .tokens = {
1648 : : (void *)&cmd_config_speed_specific_port,
1649 : : (void *)&cmd_config_speed_specific_keyword,
1650 : : (void *)&cmd_config_speed_specific_id,
1651 : : (void *)&cmd_config_speed_specific_item1,
1652 : : (void *)&cmd_config_speed_specific_value1,
1653 : : (void *)&cmd_config_speed_specific_item2,
1654 : : (void *)&cmd_config_speed_specific_value2,
1655 : : NULL,
1656 : : },
1657 : : };
1658 : :
1659 : : static cmdline_parse_inst_t cmd_config_speed_specific_autoneg = {
1660 : : .f = cmd_config_speed_specific_parsed,
1661 : : .data = &cmd_config_speed_specific_autoneg,
1662 : : .help_str = "port config <port_id> speed "
1663 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1664 : : "100000|200000|400000|800000|auto "
1665 : : "duplex half|full|auto autoneg on|off",
1666 : : .tokens = {
1667 : : (void *)&cmd_config_speed_specific_port,
1668 : : (void *)&cmd_config_speed_specific_keyword,
1669 : : (void *)&cmd_config_speed_specific_id,
1670 : : (void *)&cmd_config_speed_specific_item1,
1671 : : (void *)&cmd_config_speed_specific_value1,
1672 : : (void *)&cmd_config_speed_specific_item2,
1673 : : (void *)&cmd_config_speed_specific_value2,
1674 : : (void *)&cmd_config_speed_specific_autoneg_token,
1675 : : (void *)&cmd_config_speed_specific_autoneg_value,
1676 : : NULL,
1677 : : },
1678 : : };
1679 : :
1680 : : static int
1681 : 0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
1682 : : {
1683 : : int ret;
1684 : :
1685 : 0 : ret = rte_eth_speed_lanes_set(pid, lanes);
1686 : 0 : if (ret == -ENOTSUP) {
1687 : 0 : fprintf(stderr, "Function not implemented\n");
1688 : 0 : return -1;
1689 : 0 : } else if (ret < 0) {
1690 : 0 : fprintf(stderr, "Set speed lanes failed\n");
1691 : 0 : return -1;
1692 : : }
1693 : :
1694 : : return 0;
1695 : : }
1696 : :
1697 : : static void
1698 : 0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
1699 : : {
1700 : : unsigned int i;
1701 : : uint32_t capa;
1702 : :
1703 : : printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
1704 : : printf("\n-----------------------------------\n");
1705 : 0 : for (i = 0; i < num; i++) {
1706 : 0 : printf("%-17s ",
1707 : 0 : rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
1708 : 0 : capa = speed_lanes_capa[i].capa;
1709 : : int s = 0;
1710 : :
1711 : 0 : while (capa) {
1712 : 0 : if (capa & 0x1)
1713 : : printf("%-2d ", s);
1714 : 0 : s++;
1715 : 0 : capa = capa >> 1;
1716 : : }
1717 : : printf("\n");
1718 : : }
1719 : 0 : }
1720 : :
1721 : : /* *** display speed lanes per port capabilities *** */
1722 : : struct cmd_show_speed_lanes_result {
1723 : : cmdline_fixed_string_t cmd_show;
1724 : : cmdline_fixed_string_t cmd_port;
1725 : : cmdline_fixed_string_t cmd_keyword;
1726 : : portid_t cmd_pid;
1727 : : };
1728 : :
1729 : : static void
1730 : 0 : cmd_show_speed_lanes_parsed(void *parsed_result,
1731 : : __rte_unused struct cmdline *cl,
1732 : : __rte_unused void *data)
1733 : : {
1734 : : struct cmd_show_speed_lanes_result *res = parsed_result;
1735 : : struct rte_eth_speed_lanes_capa *speed_lanes_capa;
1736 : : unsigned int num;
1737 : : int ret;
1738 : :
1739 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
1740 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
1741 : 0 : return;
1742 : : }
1743 : :
1744 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
1745 : 0 : if (ret == -ENOTSUP) {
1746 : 0 : fprintf(stderr, "Function not implemented\n");
1747 : 0 : return;
1748 : 0 : } else if (ret < 0) {
1749 : 0 : fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
1750 : 0 : return;
1751 : : }
1752 : :
1753 : 0 : num = (unsigned int)ret;
1754 : 0 : speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
1755 : 0 : if (speed_lanes_capa == NULL) {
1756 : 0 : fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
1757 : 0 : return;
1758 : : }
1759 : :
1760 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
1761 : 0 : if (ret < 0) {
1762 : 0 : fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
1763 : 0 : goto out;
1764 : : }
1765 : :
1766 : 0 : show_speed_lanes_capability(num, speed_lanes_capa);
1767 : 0 : out:
1768 : 0 : free(speed_lanes_capa);
1769 : : }
1770 : :
1771 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
1772 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1773 : : cmd_show, "show");
1774 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
1775 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1776 : : cmd_port, "port");
1777 : : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
1778 : : TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
1779 : : cmd_pid, RTE_UINT16);
1780 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
1781 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1782 : : cmd_keyword, "speed_lanes");
1783 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
1784 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1785 : : cmd_keyword, "capabilities");
1786 : :
1787 : : static cmdline_parse_inst_t cmd_show_speed_lanes = {
1788 : : .f = cmd_show_speed_lanes_parsed,
1789 : : .data = NULL,
1790 : : .help_str = "show port <port_id> speed_lanes capabilities",
1791 : : .tokens = {
1792 : : (void *)&cmd_show_speed_lanes_show,
1793 : : (void *)&cmd_show_speed_lanes_port,
1794 : : (void *)&cmd_show_speed_lanes_pid,
1795 : : (void *)&cmd_show_speed_lanes_keyword,
1796 : : (void *)&cmd_show_speed_lanes_cap_keyword,
1797 : : NULL,
1798 : : },
1799 : : };
1800 : :
1801 : : /* *** configure speed_lanes for all ports *** */
1802 : : struct cmd_config_speed_lanes_all {
1803 : : cmdline_fixed_string_t port;
1804 : : cmdline_fixed_string_t keyword;
1805 : : cmdline_fixed_string_t all;
1806 : : cmdline_fixed_string_t item;
1807 : : uint32_t lanes;
1808 : : };
1809 : :
1810 : : static void
1811 : 0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
1812 : : __rte_unused struct cmdline *cl,
1813 : : __rte_unused void *data)
1814 : : {
1815 : : struct cmd_config_speed_lanes_all *res = parsed_result;
1816 : : portid_t pid;
1817 : :
1818 : 0 : if (!all_ports_stopped()) {
1819 : 0 : fprintf(stderr, "Please stop all ports first\n");
1820 : 0 : return;
1821 : : }
1822 : :
1823 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1824 : 0 : if (parse_speed_lanes_cfg(pid, res->lanes))
1825 : : return;
1826 : : }
1827 : :
1828 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1829 : : }
1830 : :
1831 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
1832 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
1833 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
1834 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
1835 : : "config");
1836 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
1837 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
1838 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
1839 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
1840 : : "speed_lanes");
1841 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
1842 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
1843 : :
1844 : : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
1845 : : .f = cmd_config_speed_lanes_all_parsed,
1846 : : .data = NULL,
1847 : : .help_str = "port config all speed_lanes <value>",
1848 : : .tokens = {
1849 : : (void *)&cmd_config_speed_lanes_all_port,
1850 : : (void *)&cmd_config_speed_lanes_all_keyword,
1851 : : (void *)&cmd_config_speed_lanes_all_all,
1852 : : (void *)&cmd_config_speed_lanes_all_item,
1853 : : (void *)&cmd_config_speed_lanes_all_lanes,
1854 : : NULL,
1855 : : },
1856 : : };
1857 : :
1858 : : /* *** configure speed_lanes for specific port *** */
1859 : : struct cmd_config_speed_lanes_specific {
1860 : : cmdline_fixed_string_t port;
1861 : : cmdline_fixed_string_t keyword;
1862 : : uint16_t port_id;
1863 : : cmdline_fixed_string_t item;
1864 : : uint32_t lanes;
1865 : : };
1866 : :
1867 : : static void
1868 : 0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
1869 : : __rte_unused struct cmdline *cl,
1870 : : __rte_unused void *data)
1871 : : {
1872 : : struct cmd_config_speed_lanes_specific *res = parsed_result;
1873 : :
1874 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1875 : : return;
1876 : :
1877 : 0 : if (!port_is_stopped(res->port_id)) {
1878 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1879 : 0 : return;
1880 : : }
1881 : :
1882 : 0 : if (parse_speed_lanes_cfg(res->port_id, res->lanes))
1883 : : return;
1884 : :
1885 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1886 : : }
1887 : :
1888 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
1889 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
1890 : : "port");
1891 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
1892 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
1893 : : "config");
1894 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
1895 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
1896 : : RTE_UINT16);
1897 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
1898 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
1899 : : "speed_lanes");
1900 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
1901 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
1902 : : RTE_UINT32);
1903 : :
1904 : : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
1905 : : .f = cmd_config_speed_lanes_specific_parsed,
1906 : : .data = NULL,
1907 : : .help_str = "port config <port_id> speed_lanes <value>",
1908 : : .tokens = {
1909 : : (void *)&cmd_config_speed_lanes_specific_port,
1910 : : (void *)&cmd_config_speed_lanes_specific_keyword,
1911 : : (void *)&cmd_config_speed_lanes_specific_id,
1912 : : (void *)&cmd_config_speed_lanes_specific_item,
1913 : : (void *)&cmd_config_speed_lanes_specific_lanes,
1914 : : NULL,
1915 : : },
1916 : : };
1917 : :
1918 : : /* *** configure loopback for all ports *** */
1919 : : struct cmd_config_loopback_all {
1920 : : cmdline_fixed_string_t port;
1921 : : cmdline_fixed_string_t keyword;
1922 : : cmdline_fixed_string_t all;
1923 : : cmdline_fixed_string_t item;
1924 : : uint32_t mode;
1925 : : };
1926 : :
1927 : : static void
1928 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1929 : : __rte_unused struct cmdline *cl,
1930 : : __rte_unused void *data)
1931 : : {
1932 : : struct cmd_config_loopback_all *res = parsed_result;
1933 : : portid_t pid;
1934 : :
1935 : 0 : if (!all_ports_stopped()) {
1936 : 0 : fprintf(stderr, "Please stop all ports first\n");
1937 : 0 : return;
1938 : : }
1939 : :
1940 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1941 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1942 : : }
1943 : :
1944 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1945 : : }
1946 : :
1947 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1948 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1949 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1950 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1951 : : "config");
1952 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1953 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1954 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1955 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1956 : : "loopback");
1957 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1958 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1959 : :
1960 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1961 : : .f = cmd_config_loopback_all_parsed,
1962 : : .data = NULL,
1963 : : .help_str = "port config all loopback <mode>",
1964 : : .tokens = {
1965 : : (void *)&cmd_config_loopback_all_port,
1966 : : (void *)&cmd_config_loopback_all_keyword,
1967 : : (void *)&cmd_config_loopback_all_all,
1968 : : (void *)&cmd_config_loopback_all_item,
1969 : : (void *)&cmd_config_loopback_all_mode,
1970 : : NULL,
1971 : : },
1972 : : };
1973 : :
1974 : : /* *** configure loopback for specific port *** */
1975 : : struct cmd_config_loopback_specific {
1976 : : cmdline_fixed_string_t port;
1977 : : cmdline_fixed_string_t keyword;
1978 : : uint16_t port_id;
1979 : : cmdline_fixed_string_t item;
1980 : : uint32_t mode;
1981 : : };
1982 : :
1983 : : static void
1984 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1985 : : __rte_unused struct cmdline *cl,
1986 : : __rte_unused void *data)
1987 : : {
1988 : : struct cmd_config_loopback_specific *res = parsed_result;
1989 : :
1990 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1991 : : return;
1992 : :
1993 : 0 : if (!port_is_stopped(res->port_id)) {
1994 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1995 : 0 : return;
1996 : : }
1997 : :
1998 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1999 : :
2000 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
2001 : : }
2002 : :
2003 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
2004 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
2005 : : "port");
2006 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
2007 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
2008 : : "config");
2009 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
2010 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
2011 : : RTE_UINT16);
2012 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
2013 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
2014 : : "loopback");
2015 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
2016 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
2017 : : RTE_UINT32);
2018 : :
2019 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
2020 : : .f = cmd_config_loopback_specific_parsed,
2021 : : .data = NULL,
2022 : : .help_str = "port config <port_id> loopback <mode>",
2023 : : .tokens = {
2024 : : (void *)&cmd_config_loopback_specific_port,
2025 : : (void *)&cmd_config_loopback_specific_keyword,
2026 : : (void *)&cmd_config_loopback_specific_id,
2027 : : (void *)&cmd_config_loopback_specific_item,
2028 : : (void *)&cmd_config_loopback_specific_mode,
2029 : : NULL,
2030 : : },
2031 : : };
2032 : :
2033 : : /* *** configure txq/rxq, txd/rxd *** */
2034 : : struct cmd_config_rx_tx {
2035 : : cmdline_fixed_string_t port;
2036 : : cmdline_fixed_string_t keyword;
2037 : : cmdline_fixed_string_t all;
2038 : : cmdline_fixed_string_t name;
2039 : : uint16_t value;
2040 : : };
2041 : :
2042 : : static void
2043 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
2044 : : __rte_unused struct cmdline *cl,
2045 : : __rte_unused void *data)
2046 : : {
2047 : : struct cmd_config_rx_tx *res = parsed_result;
2048 : :
2049 : 0 : if (!all_ports_stopped()) {
2050 : 0 : fprintf(stderr, "Please stop all ports first\n");
2051 : 0 : return;
2052 : : }
2053 : 0 : if (!strcmp(res->name, "rxq")) {
2054 : 0 : if (!res->value && !nb_txq) {
2055 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
2056 : 0 : return;
2057 : : }
2058 : 0 : if (check_nb_rxq(res->value) != 0)
2059 : : return;
2060 : 0 : nb_rxq = res->value;
2061 : : }
2062 : 0 : else if (!strcmp(res->name, "txq")) {
2063 : 0 : if (!res->value && !nb_rxq) {
2064 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
2065 : 0 : return;
2066 : : }
2067 : 0 : if (check_nb_txq(res->value) != 0)
2068 : : return;
2069 : 0 : nb_txq = res->value;
2070 : : }
2071 : 0 : else if (!strcmp(res->name, "rxd")) {
2072 : 0 : if (check_nb_rxd(res->value) != 0)
2073 : : return;
2074 : 0 : nb_rxd = res->value;
2075 : 0 : } else if (!strcmp(res->name, "txd")) {
2076 : 0 : if (check_nb_txd(res->value) != 0)
2077 : : return;
2078 : :
2079 : 0 : nb_txd = res->value;
2080 : : } else {
2081 : 0 : fprintf(stderr, "Unknown parameter\n");
2082 : 0 : return;
2083 : : }
2084 : :
2085 : 0 : init_port_config();
2086 : :
2087 : 0 : fwd_config_setup();
2088 : :
2089 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2090 : : }
2091 : :
2092 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
2093 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2094 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2095 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2096 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
2097 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2098 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
2099 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2100 : : "rxq#txq#rxd#txd");
2101 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
2102 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
2103 : :
2104 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
2105 : : .f = cmd_config_rx_tx_parsed,
2106 : : .data = NULL,
2107 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
2108 : : .tokens = {
2109 : : (void *)&cmd_config_rx_tx_port,
2110 : : (void *)&cmd_config_rx_tx_keyword,
2111 : : (void *)&cmd_config_rx_tx_all,
2112 : : (void *)&cmd_config_rx_tx_name,
2113 : : (void *)&cmd_config_rx_tx_value,
2114 : : NULL,
2115 : : },
2116 : : };
2117 : :
2118 : : /* *** config max packet length *** */
2119 : : struct cmd_config_max_pkt_len_result {
2120 : : cmdline_fixed_string_t port;
2121 : : cmdline_fixed_string_t keyword;
2122 : : cmdline_fixed_string_t all;
2123 : : cmdline_fixed_string_t name;
2124 : : uint32_t value;
2125 : : };
2126 : :
2127 : : static void
2128 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
2129 : : __rte_unused struct cmdline *cl,
2130 : : __rte_unused void *data)
2131 : : {
2132 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
2133 : : portid_t port_id;
2134 : : int ret;
2135 : :
2136 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
2137 : : printf("Unknown parameter\n");
2138 : 0 : return;
2139 : : }
2140 : :
2141 : 0 : if (!all_ports_stopped()) {
2142 : 0 : fprintf(stderr, "Please stop all ports first\n");
2143 : 0 : return;
2144 : : }
2145 : :
2146 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
2147 : 0 : struct rte_port *port = &ports[port_id];
2148 : :
2149 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
2150 : 0 : fprintf(stderr,
2151 : : "max-pkt-len can not be less than %d\n",
2152 : : RTE_ETHER_MIN_LEN);
2153 : 0 : return;
2154 : : }
2155 : :
2156 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
2157 : 0 : if (ret != 0) {
2158 : 0 : fprintf(stderr,
2159 : : "rte_eth_dev_info_get() failed for port %u\n",
2160 : : port_id);
2161 : 0 : return;
2162 : : }
2163 : :
2164 : 0 : update_mtu_from_frame_size(port_id, res->value);
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_pkt_len_port =
2173 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2174 : : "port");
2175 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2176 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2177 : : "config");
2178 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2179 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2180 : : "all");
2181 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2182 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2183 : : "max-pkt-len");
2184 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2185 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2186 : : RTE_UINT32);
2187 : :
2188 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
2189 : : .f = cmd_config_max_pkt_len_parsed,
2190 : : .data = NULL,
2191 : : .help_str = "port config all max-pkt-len <value>",
2192 : : .tokens = {
2193 : : (void *)&cmd_config_max_pkt_len_port,
2194 : : (void *)&cmd_config_max_pkt_len_keyword,
2195 : : (void *)&cmd_config_max_pkt_len_all,
2196 : : (void *)&cmd_config_max_pkt_len_name,
2197 : : (void *)&cmd_config_max_pkt_len_value,
2198 : : NULL,
2199 : : },
2200 : : };
2201 : :
2202 : : /* *** config max LRO aggregated packet size *** */
2203 : : struct cmd_config_max_lro_pkt_size_result {
2204 : : cmdline_fixed_string_t port;
2205 : : cmdline_fixed_string_t keyword;
2206 : : cmdline_fixed_string_t all;
2207 : : cmdline_fixed_string_t name;
2208 : : uint32_t value;
2209 : : };
2210 : :
2211 : : static void
2212 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2213 : : __rte_unused struct cmdline *cl,
2214 : : __rte_unused void *data)
2215 : : {
2216 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2217 : : portid_t pid;
2218 : :
2219 : 0 : if (!all_ports_stopped()) {
2220 : 0 : fprintf(stderr, "Please stop all ports first\n");
2221 : 0 : return;
2222 : : }
2223 : :
2224 : 0 : RTE_ETH_FOREACH_DEV(pid) {
2225 : 0 : struct rte_port *port = &ports[pid];
2226 : :
2227 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
2228 : 0 : if (res->value ==
2229 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
2230 : : return;
2231 : :
2232 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2233 : : } else {
2234 : 0 : fprintf(stderr, "Unknown parameter\n");
2235 : 0 : return;
2236 : : }
2237 : : }
2238 : :
2239 : 0 : init_port_config();
2240 : :
2241 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2242 : : }
2243 : :
2244 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2245 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2246 : : port, "port");
2247 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2248 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2249 : : keyword, "config");
2250 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2251 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2252 : : all, "all");
2253 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2254 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2255 : : name, "max-lro-pkt-size");
2256 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2257 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2258 : : value, RTE_UINT32);
2259 : :
2260 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2261 : : .f = cmd_config_max_lro_pkt_size_parsed,
2262 : : .data = NULL,
2263 : : .help_str = "port config all max-lro-pkt-size <value>",
2264 : : .tokens = {
2265 : : (void *)&cmd_config_max_lro_pkt_size_port,
2266 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
2267 : : (void *)&cmd_config_max_lro_pkt_size_all,
2268 : : (void *)&cmd_config_max_lro_pkt_size_name,
2269 : : (void *)&cmd_config_max_lro_pkt_size_value,
2270 : : NULL,
2271 : : },
2272 : : };
2273 : :
2274 : : /* *** configure port MTU *** */
2275 : : struct cmd_config_mtu_result {
2276 : : cmdline_fixed_string_t port;
2277 : : cmdline_fixed_string_t keyword;
2278 : : cmdline_fixed_string_t mtu;
2279 : : portid_t port_id;
2280 : : uint16_t value;
2281 : : };
2282 : :
2283 : : static void
2284 : 0 : cmd_config_mtu_parsed(void *parsed_result,
2285 : : __rte_unused struct cmdline *cl,
2286 : : __rte_unused void *data)
2287 : : {
2288 : : struct cmd_config_mtu_result *res = parsed_result;
2289 : :
2290 : 0 : port_mtu_set(res->port_id, res->value);
2291 : 0 : }
2292 : :
2293 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
2294 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2295 : : "port");
2296 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2297 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2298 : : "config");
2299 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2300 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2301 : : "mtu");
2302 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2303 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2304 : : RTE_UINT16);
2305 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
2306 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2307 : : RTE_UINT16);
2308 : :
2309 : : static cmdline_parse_inst_t cmd_config_mtu = {
2310 : : .f = cmd_config_mtu_parsed,
2311 : : .data = NULL,
2312 : : .help_str = "port config mtu <port_id> <value>",
2313 : : .tokens = {
2314 : : (void *)&cmd_config_mtu_port,
2315 : : (void *)&cmd_config_mtu_keyword,
2316 : : (void *)&cmd_config_mtu_mtu,
2317 : : (void *)&cmd_config_mtu_port_id,
2318 : : (void *)&cmd_config_mtu_value,
2319 : : NULL,
2320 : : },
2321 : : };
2322 : :
2323 : : /* *** configure rx mode *** */
2324 : : struct cmd_config_rx_mode_flag {
2325 : : cmdline_fixed_string_t port;
2326 : : cmdline_fixed_string_t keyword;
2327 : : cmdline_fixed_string_t all;
2328 : : cmdline_fixed_string_t name;
2329 : : cmdline_fixed_string_t value;
2330 : : };
2331 : :
2332 : : static void
2333 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
2334 : : __rte_unused struct cmdline *cl,
2335 : : __rte_unused void *data)
2336 : : {
2337 : : struct cmd_config_rx_mode_flag *res = parsed_result;
2338 : :
2339 : 0 : if (!all_ports_stopped()) {
2340 : 0 : fprintf(stderr, "Please stop all ports first\n");
2341 : 0 : return;
2342 : : }
2343 : :
2344 : 0 : if (!strcmp(res->name, "drop-en")) {
2345 : 0 : if (!strcmp(res->value, "on"))
2346 : 0 : rx_drop_en = 1;
2347 : 0 : else if (!strcmp(res->value, "off"))
2348 : 0 : rx_drop_en = 0;
2349 : : else {
2350 : 0 : fprintf(stderr, "Unknown parameter\n");
2351 : 0 : return;
2352 : : }
2353 : : } else {
2354 : 0 : fprintf(stderr, "Unknown parameter\n");
2355 : 0 : return;
2356 : : }
2357 : :
2358 : 0 : init_port_config();
2359 : :
2360 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2361 : : }
2362 : :
2363 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2364 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2365 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2366 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2367 : : "config");
2368 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2369 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2370 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2371 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2372 : : "drop-en");
2373 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2374 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2375 : : "on#off");
2376 : :
2377 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2378 : : .f = cmd_config_rx_mode_flag_parsed,
2379 : : .data = NULL,
2380 : : .help_str = "port config all drop-en on|off",
2381 : : .tokens = {
2382 : : (void *)&cmd_config_rx_mode_flag_port,
2383 : : (void *)&cmd_config_rx_mode_flag_keyword,
2384 : : (void *)&cmd_config_rx_mode_flag_all,
2385 : : (void *)&cmd_config_rx_mode_flag_name,
2386 : : (void *)&cmd_config_rx_mode_flag_value,
2387 : : NULL,
2388 : : },
2389 : : };
2390 : :
2391 : : /* *** configure rss *** */
2392 : : struct cmd_config_rss {
2393 : : cmdline_fixed_string_t port;
2394 : : cmdline_fixed_string_t keyword;
2395 : : cmdline_fixed_string_t all;
2396 : : cmdline_fixed_string_t name;
2397 : : cmdline_fixed_string_t value;
2398 : : };
2399 : :
2400 : : static void
2401 : 0 : cmd_config_rss_parsed(void *parsed_result,
2402 : : __rte_unused struct cmdline *cl,
2403 : : __rte_unused void *data)
2404 : : {
2405 : : struct cmd_config_rss *res = parsed_result;
2406 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2407 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2408 : : int use_default = 0;
2409 : : int all_updated = 1;
2410 : : int diag;
2411 : : uint16_t i;
2412 : : int ret;
2413 : :
2414 : 0 : if (!strcmp(res->value, "level-default")) {
2415 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2416 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2417 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2418 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2419 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2420 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2421 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2422 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2423 : 0 : } else if (!strcmp(res->value, "default")) {
2424 : : use_default = 1;
2425 : 0 : } else if (isdigit(res->value[0])) {
2426 : : int value = atoi(res->value);
2427 : 0 : if (value > 0 && value < 64)
2428 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2429 : : else {
2430 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2431 : 0 : return;
2432 : : }
2433 : 0 : } else if (!strcmp(res->value, "none")) {
2434 : : rss_conf.rss_hf = 0;
2435 : : } else {
2436 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2437 : 0 : if (rss_conf.rss_hf == 0) {
2438 : 0 : fprintf(stderr, "Unknown parameter\n");
2439 : 0 : return;
2440 : : }
2441 : : }
2442 : : rss_conf.rss_key = NULL;
2443 : : /* Update global configuration for RSS types. */
2444 : 0 : RTE_ETH_FOREACH_DEV(i) {
2445 : : struct rte_eth_rss_conf local_rss_conf;
2446 : :
2447 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2448 : 0 : if (ret != 0)
2449 : 0 : return;
2450 : :
2451 : 0 : if (use_default)
2452 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2453 : :
2454 : 0 : local_rss_conf = rss_conf;
2455 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2456 : 0 : dev_info.flow_type_rss_offloads;
2457 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2458 : : printf("Port %u modified RSS hash function based on hardware support,"
2459 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2460 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2461 : : }
2462 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2463 : 0 : if (diag < 0) {
2464 : : all_updated = 0;
2465 : 0 : fprintf(stderr,
2466 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2467 : : i, -diag, strerror(-diag));
2468 : : }
2469 : : }
2470 : 0 : if (all_updated && !use_default) {
2471 : 0 : rss_hf = rss_conf.rss_hf;
2472 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2473 : : }
2474 : : }
2475 : :
2476 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2477 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2478 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2479 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2480 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2481 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2482 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2483 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2484 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2485 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2486 : :
2487 : : static cmdline_parse_inst_t cmd_config_rss = {
2488 : : .f = cmd_config_rss_parsed,
2489 : : .data = NULL,
2490 : : .help_str = "port config all rss "
2491 : : "all|default|level-default|level-outer|level-inner|"
2492 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2493 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2494 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2495 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2496 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2497 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2498 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2499 : : .tokens = {
2500 : : (void *)&cmd_config_rss_port,
2501 : : (void *)&cmd_config_rss_keyword,
2502 : : (void *)&cmd_config_rss_all,
2503 : : (void *)&cmd_config_rss_name,
2504 : : (void *)&cmd_config_rss_value,
2505 : : NULL,
2506 : : },
2507 : : };
2508 : :
2509 : : /* *** configure rss hash key *** */
2510 : : struct cmd_config_rss_hash_key {
2511 : : cmdline_fixed_string_t port;
2512 : : cmdline_fixed_string_t config;
2513 : : portid_t port_id;
2514 : : cmdline_fixed_string_t rss_hash_key;
2515 : : cmdline_fixed_string_t rss_type;
2516 : : cmdline_fixed_string_t key;
2517 : : };
2518 : :
2519 : : static uint8_t
2520 : : hexa_digit_to_value(char hexa_digit)
2521 : : {
2522 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2523 : : return (uint8_t) (hexa_digit - '0');
2524 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2525 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2526 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2527 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2528 : : /* Invalid hexa digit */
2529 : : return 0xFF;
2530 : : }
2531 : :
2532 : : static uint8_t
2533 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2534 : : {
2535 : : uint8_t hexa_v;
2536 : :
2537 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2538 : : if (hexa_v == 0xFF)
2539 : 0 : fprintf(stderr,
2540 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2541 : : key[idx], idx);
2542 : 0 : return hexa_v;
2543 : : }
2544 : :
2545 : : static void
2546 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2547 : : __rte_unused struct cmdline *cl,
2548 : : __rte_unused void *data)
2549 : : {
2550 : : struct cmd_config_rss_hash_key *res = parsed_result;
2551 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2552 : : uint8_t xdgt0;
2553 : : uint8_t xdgt1;
2554 : : int i;
2555 : : struct rte_eth_dev_info dev_info;
2556 : : uint8_t hash_key_size;
2557 : : uint32_t key_len;
2558 : : int ret;
2559 : :
2560 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2561 : 0 : if (ret != 0)
2562 : 0 : return;
2563 : :
2564 : 0 : if (dev_info.hash_key_size > 0 &&
2565 : : dev_info.hash_key_size <= sizeof(hash_key))
2566 : : hash_key_size = dev_info.hash_key_size;
2567 : : else {
2568 : 0 : fprintf(stderr,
2569 : : "dev_info did not provide a valid hash key size\n");
2570 : 0 : return;
2571 : : }
2572 : : /* Check the length of the RSS hash key */
2573 : 0 : key_len = strlen(res->key);
2574 : 0 : if (key_len != (hash_key_size * 2)) {
2575 : 0 : fprintf(stderr,
2576 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2577 : : (int)key_len, hash_key_size * 2);
2578 : 0 : return;
2579 : : }
2580 : : /* Translate RSS hash key into binary representation */
2581 : 0 : for (i = 0; i < hash_key_size; i++) {
2582 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2583 : 0 : if (xdgt0 == 0xFF)
2584 : : return;
2585 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2586 : 0 : if (xdgt1 == 0xFF)
2587 : : return;
2588 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2589 : : }
2590 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2591 : : hash_key_size);
2592 : : }
2593 : :
2594 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2595 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2596 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2597 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2598 : : "config");
2599 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2600 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2601 : : RTE_UINT16);
2602 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2603 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2604 : : rss_hash_key, "rss-hash-key");
2605 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2606 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2607 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2608 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2609 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2610 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2611 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2612 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2613 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2614 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2615 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2616 : :
2617 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2618 : : .f = cmd_config_rss_hash_key_parsed,
2619 : : .data = NULL,
2620 : : .help_str = "port config <port_id> rss-hash-key "
2621 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2622 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2623 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2624 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2625 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2626 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2627 : : "<string of hex digits (variable length, NIC dependent)>",
2628 : : .tokens = {
2629 : : (void *)&cmd_config_rss_hash_key_port,
2630 : : (void *)&cmd_config_rss_hash_key_config,
2631 : : (void *)&cmd_config_rss_hash_key_port_id,
2632 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2633 : : (void *)&cmd_config_rss_hash_key_rss_type,
2634 : : (void *)&cmd_config_rss_hash_key_value,
2635 : : NULL,
2636 : : },
2637 : : };
2638 : :
2639 : : /* *** configure rss hash algorithm *** */
2640 : : struct cmd_config_rss_hash_algo {
2641 : : cmdline_fixed_string_t port;
2642 : : cmdline_fixed_string_t config;
2643 : : portid_t port_id;
2644 : : cmdline_fixed_string_t rss_hash_algo;
2645 : : cmdline_fixed_string_t algo;
2646 : : };
2647 : :
2648 : : static void
2649 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2650 : : __rte_unused struct cmdline *cl,
2651 : : __rte_unused void *data)
2652 : : {
2653 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2654 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2655 : : struct rte_eth_rss_conf rss_conf;
2656 : : uint32_t algorithm;
2657 : : int ret;
2658 : :
2659 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2660 : 0 : rss_conf.rss_key = rss_key;
2661 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2662 : 0 : if (ret != 0) {
2663 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2664 : 0 : res->port_id);
2665 : 0 : return;
2666 : : }
2667 : :
2668 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2669 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2670 : 0 : if (ret != 0) {
2671 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2672 : 0 : res->port_id, res->algo);
2673 : 0 : return;
2674 : : }
2675 : :
2676 : 0 : rss_conf.algorithm = algorithm;
2677 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2678 : 0 : if (ret != 0) {
2679 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2680 : 0 : res->port_id);
2681 : 0 : return;
2682 : : }
2683 : : }
2684 : :
2685 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2686 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2687 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2688 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2689 : : "config");
2690 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2691 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2692 : : RTE_UINT16);
2693 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2694 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2695 : : rss_hash_algo, "rss-hash-algo");
2696 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2697 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2698 : : "default#simple_xor#toeplitz#"
2699 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2700 : :
2701 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2702 : : .f = cmd_config_rss_hash_algo_parsed,
2703 : : .data = NULL,
2704 : : .help_str = "port config <port_id> rss-hash-algo "
2705 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2706 : : .tokens = {
2707 : : (void *)&cmd_config_rss_hash_algo_port,
2708 : : (void *)&cmd_config_rss_hash_algo_config,
2709 : : (void *)&cmd_config_rss_hash_algo_port_id,
2710 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2711 : : (void *)&cmd_config_rss_hash_algo_algo,
2712 : : NULL,
2713 : : },
2714 : : };
2715 : :
2716 : : /* *** cleanup txq mbufs *** */
2717 : : struct cmd_cleanup_txq_mbufs_result {
2718 : : cmdline_fixed_string_t port;
2719 : : cmdline_fixed_string_t keyword;
2720 : : cmdline_fixed_string_t name;
2721 : : uint16_t port_id;
2722 : : uint16_t queue_id;
2723 : : uint32_t free_cnt;
2724 : : };
2725 : :
2726 : : static void
2727 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2728 : : __rte_unused struct cmdline *cl,
2729 : : __rte_unused void *data)
2730 : : {
2731 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2732 : 0 : uint16_t port_id = res->port_id;
2733 : 0 : uint16_t queue_id = res->queue_id;
2734 : 0 : uint32_t free_cnt = res->free_cnt;
2735 : : struct rte_eth_txq_info qinfo;
2736 : : int ret;
2737 : :
2738 : 0 : if (test_done == 0) {
2739 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2740 : 0 : return;
2741 : : }
2742 : :
2743 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2744 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2745 : : port_id, queue_id);
2746 : 0 : return;
2747 : : }
2748 : :
2749 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2750 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2751 : 0 : return;
2752 : : }
2753 : :
2754 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2755 : 0 : if (ret < 0) {
2756 : 0 : fprintf(stderr,
2757 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2758 : : port_id, queue_id, strerror(-ret), ret);
2759 : 0 : return;
2760 : : }
2761 : :
2762 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2763 : : port_id, queue_id, ret);
2764 : : }
2765 : :
2766 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2767 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2768 : : "port");
2769 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2770 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2771 : : "cleanup");
2772 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2773 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2774 : : RTE_UINT16);
2775 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2776 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2777 : : "txq");
2778 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2779 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2780 : : RTE_UINT16);
2781 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2782 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2783 : : RTE_UINT32);
2784 : :
2785 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2786 : : .f = cmd_cleanup_txq_mbufs_parsed,
2787 : : .data = NULL,
2788 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2789 : : .tokens = {
2790 : : (void *)&cmd_cleanup_txq_mbufs_port,
2791 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2792 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2793 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2794 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2795 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2796 : : NULL,
2797 : : },
2798 : : };
2799 : :
2800 : : /* *** configure port rxq/txq ring size *** */
2801 : : struct cmd_config_rxtx_ring_size {
2802 : : cmdline_fixed_string_t port;
2803 : : cmdline_fixed_string_t config;
2804 : : portid_t portid;
2805 : : cmdline_fixed_string_t rxtxq;
2806 : : uint16_t qid;
2807 : : cmdline_fixed_string_t rsize;
2808 : : uint16_t size;
2809 : : };
2810 : :
2811 : : static void
2812 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2813 : : __rte_unused struct cmdline *cl,
2814 : : __rte_unused void *data)
2815 : : {
2816 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2817 : : struct rte_port *port;
2818 : : uint8_t isrx;
2819 : :
2820 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2821 : : return;
2822 : :
2823 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2824 : 0 : fprintf(stderr, "Invalid port id\n");
2825 : 0 : return;
2826 : : }
2827 : :
2828 : 0 : port = &ports[res->portid];
2829 : :
2830 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2831 : : isrx = 1;
2832 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2833 : : isrx = 0;
2834 : : else {
2835 : 0 : fprintf(stderr, "Unknown parameter\n");
2836 : 0 : return;
2837 : : }
2838 : :
2839 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2840 : : return;
2841 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2842 : : return;
2843 : :
2844 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2845 : 0 : fprintf(stderr,
2846 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2847 : : rx_free_thresh);
2848 : 0 : return;
2849 : : }
2850 : :
2851 : 0 : if (isrx)
2852 : 0 : port->nb_rx_desc[res->qid] = res->size;
2853 : : else
2854 : 0 : port->nb_tx_desc[res->qid] = res->size;
2855 : :
2856 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2857 : : }
2858 : :
2859 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2860 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2861 : : port, "port");
2862 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2863 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2864 : : config, "config");
2865 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2866 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2867 : : portid, RTE_UINT16);
2868 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2869 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2870 : : rxtxq, "rxq#txq");
2871 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2872 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2873 : : qid, RTE_UINT16);
2874 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2875 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2876 : : rsize, "ring_size");
2877 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2878 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2879 : : size, RTE_UINT16);
2880 : :
2881 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2882 : : .f = cmd_config_rxtx_ring_size_parsed,
2883 : : .data = NULL,
2884 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2885 : : .tokens = {
2886 : : (void *)&cmd_config_rxtx_ring_size_port,
2887 : : (void *)&cmd_config_rxtx_ring_size_config,
2888 : : (void *)&cmd_config_rxtx_ring_size_portid,
2889 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2890 : : (void *)&cmd_config_rxtx_ring_size_qid,
2891 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2892 : : (void *)&cmd_config_rxtx_ring_size_size,
2893 : : NULL,
2894 : : },
2895 : : };
2896 : :
2897 : : /* *** configure port rxq/txq start/stop *** */
2898 : : struct cmd_config_rxtx_queue {
2899 : : cmdline_fixed_string_t port;
2900 : : portid_t portid;
2901 : : cmdline_fixed_string_t rxtxq;
2902 : : uint16_t qid;
2903 : : cmdline_fixed_string_t opname;
2904 : : };
2905 : :
2906 : : static void
2907 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2908 : : __rte_unused struct cmdline *cl,
2909 : : __rte_unused void *data)
2910 : : {
2911 : : struct cmd_config_rxtx_queue *res = parsed_result;
2912 : : struct rte_port *port;
2913 : : uint8_t isrx;
2914 : : uint8_t isstart;
2915 : : uint8_t *state;
2916 : : int ret = 0;
2917 : :
2918 : 0 : if (test_done == 0) {
2919 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2920 : 0 : return;
2921 : : }
2922 : :
2923 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2924 : : return;
2925 : :
2926 : 0 : if (port_is_started(res->portid) != 1) {
2927 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2928 : 0 : return;
2929 : : }
2930 : :
2931 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2932 : : isrx = 1;
2933 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2934 : : isrx = 0;
2935 : : else {
2936 : 0 : fprintf(stderr, "Unknown parameter\n");
2937 : 0 : return;
2938 : : }
2939 : :
2940 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2941 : : return;
2942 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2943 : : return;
2944 : :
2945 : 0 : if (!strcmp(res->opname, "start"))
2946 : : isstart = 1;
2947 : 0 : else if (!strcmp(res->opname, "stop"))
2948 : : isstart = 0;
2949 : : else {
2950 : 0 : fprintf(stderr, "Unknown parameter\n");
2951 : 0 : return;
2952 : : }
2953 : :
2954 : 0 : if (isstart && isrx)
2955 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2956 : 0 : else if (!isstart && isrx)
2957 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2958 : 0 : else if (isstart && !isrx)
2959 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2960 : : else
2961 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2962 : :
2963 : 0 : if (ret == -ENOTSUP) {
2964 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2965 : 0 : return;
2966 : : }
2967 : :
2968 : 0 : port = &ports[res->portid];
2969 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2970 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2971 : : RTE_ETH_QUEUE_STATE_STOPPED;
2972 : : }
2973 : :
2974 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2975 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2976 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2977 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2978 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2979 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2980 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2981 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2982 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2983 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2984 : : "start#stop");
2985 : :
2986 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2987 : : .f = cmd_config_rxtx_queue_parsed,
2988 : : .data = NULL,
2989 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2990 : : .tokens = {
2991 : : (void *)&cmd_config_rxtx_queue_port,
2992 : : (void *)&cmd_config_rxtx_queue_portid,
2993 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2994 : : (void *)&cmd_config_rxtx_queue_qid,
2995 : : (void *)&cmd_config_rxtx_queue_opname,
2996 : : NULL,
2997 : : },
2998 : : };
2999 : :
3000 : : /* *** configure port rxq/txq deferred start on/off *** */
3001 : : struct cmd_config_deferred_start_rxtx_queue {
3002 : : cmdline_fixed_string_t port;
3003 : : portid_t port_id;
3004 : : cmdline_fixed_string_t rxtxq;
3005 : : uint16_t qid;
3006 : : cmdline_fixed_string_t opname;
3007 : : cmdline_fixed_string_t state;
3008 : : };
3009 : :
3010 : : static void
3011 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
3012 : : __rte_unused struct cmdline *cl,
3013 : : __rte_unused void *data)
3014 : : {
3015 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
3016 : : struct rte_port *port;
3017 : : uint8_t isrx;
3018 : : uint8_t ison;
3019 : : uint8_t needreconfig = 0;
3020 : :
3021 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
3022 : : return;
3023 : :
3024 : 0 : if (port_is_started(res->port_id) != 0) {
3025 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
3026 : 0 : return;
3027 : : }
3028 : :
3029 : 0 : port = &ports[res->port_id];
3030 : :
3031 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
3032 : :
3033 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
3034 : : return;
3035 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
3036 : : return;
3037 : :
3038 : 0 : ison = !strcmp(res->state, "on");
3039 : :
3040 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
3041 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
3042 : : needreconfig = 1;
3043 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
3044 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
3045 : : needreconfig = 1;
3046 : : }
3047 : :
3048 : : if (needreconfig)
3049 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
3050 : : }
3051 : :
3052 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
3053 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
3054 : : port, "port");
3055 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
3056 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
3057 : : port_id, RTE_UINT16);
3058 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
3059 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
3060 : : rxtxq, "rxq#txq");
3061 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
3062 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
3063 : : qid, RTE_UINT16);
3064 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
3065 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
3066 : : opname, "deferred_start");
3067 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
3068 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
3069 : : state, "on#off");
3070 : :
3071 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
3072 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
3073 : : .data = NULL,
3074 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
3075 : : .tokens = {
3076 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
3077 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
3078 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
3079 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
3080 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
3081 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
3082 : : NULL,
3083 : : },
3084 : : };
3085 : :
3086 : : /* *** configure port rxq/txq setup *** */
3087 : : struct cmd_setup_rxtx_queue {
3088 : : cmdline_fixed_string_t port;
3089 : : portid_t portid;
3090 : : cmdline_fixed_string_t rxtxq;
3091 : : uint16_t qid;
3092 : : cmdline_fixed_string_t setup;
3093 : : };
3094 : :
3095 : : /* Common CLI fields for queue setup */
3096 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
3097 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
3098 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
3099 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
3100 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
3101 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
3102 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
3103 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
3104 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
3105 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
3106 : :
3107 : : static void
3108 : 0 : cmd_setup_rxtx_queue_parsed(
3109 : : void *parsed_result,
3110 : : __rte_unused struct cmdline *cl,
3111 : : __rte_unused void *data)
3112 : : {
3113 : : struct cmd_setup_rxtx_queue *res = parsed_result;
3114 : : struct rte_port *port;
3115 : : struct rte_mempool *mp;
3116 : : unsigned int socket_id;
3117 : : uint8_t isrx = 0;
3118 : : int ret;
3119 : :
3120 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
3121 : : return;
3122 : :
3123 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
3124 : 0 : fprintf(stderr, "Invalid port id\n");
3125 : 0 : return;
3126 : : }
3127 : :
3128 : 0 : if (!strcmp(res->rxtxq, "rxq"))
3129 : : isrx = 1;
3130 : 0 : else if (!strcmp(res->rxtxq, "txq"))
3131 : : isrx = 0;
3132 : : else {
3133 : 0 : fprintf(stderr, "Unknown parameter\n");
3134 : 0 : return;
3135 : : }
3136 : :
3137 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
3138 : 0 : fprintf(stderr, "Invalid rx queue\n");
3139 : 0 : return;
3140 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
3141 : 0 : fprintf(stderr, "Invalid tx queue\n");
3142 : 0 : return;
3143 : : }
3144 : :
3145 : 0 : port = &ports[res->portid];
3146 : 0 : if (isrx) {
3147 : 0 : socket_id = rxring_numa[res->portid];
3148 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3149 : 0 : socket_id = port->socket_id;
3150 : :
3151 : 0 : mp = mbuf_pool_find_first(socket_id);
3152 : 0 : if (mp == NULL) {
3153 : : char buf[16];
3154 : :
3155 : 0 : fprintf(stderr,
3156 : : "Failed to setup RX queue: No mempool allocation on the socket %s\n",
3157 : : socket_id_str(socket_id, buf, sizeof(buf)));
3158 : : return;
3159 : : }
3160 : 0 : ret = rx_queue_setup(res->portid,
3161 : : res->qid,
3162 : 0 : port->nb_rx_desc[res->qid],
3163 : : socket_id,
3164 : 0 : &port->rxq[res->qid].conf,
3165 : : mp);
3166 : 0 : if (ret)
3167 : 0 : fprintf(stderr, "Failed to setup RX queue: %s\n",
3168 : : rte_strerror(-ret));
3169 : : } else {
3170 : 0 : socket_id = txring_numa[res->portid];
3171 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3172 : 0 : socket_id = port->socket_id;
3173 : :
3174 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
3175 : 0 : fprintf(stderr,
3176 : : "Failed to setup TX queue: not enough descriptors\n");
3177 : 0 : return;
3178 : : }
3179 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
3180 : : res->qid,
3181 : : port->nb_tx_desc[res->qid],
3182 : : socket_id,
3183 : 0 : &port->txq[res->qid].conf);
3184 : 0 : if (ret)
3185 : 0 : fprintf(stderr, "Failed to setup TX queue: %s\n",
3186 : : rte_strerror(-ret));
3187 : : }
3188 : : }
3189 : :
3190 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
3191 : : .f = cmd_setup_rxtx_queue_parsed,
3192 : : .data = NULL,
3193 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
3194 : : .tokens = {
3195 : : (void *)&cmd_setup_rxtx_queue_port,
3196 : : (void *)&cmd_setup_rxtx_queue_portid,
3197 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
3198 : : (void *)&cmd_setup_rxtx_queue_qid,
3199 : : (void *)&cmd_setup_rxtx_queue_setup,
3200 : : NULL,
3201 : : },
3202 : : };
3203 : :
3204 : :
3205 : : /* *** Configure RSS RETA *** */
3206 : : struct cmd_config_rss_reta {
3207 : : cmdline_fixed_string_t port;
3208 : : cmdline_fixed_string_t keyword;
3209 : : portid_t port_id;
3210 : : cmdline_fixed_string_t name;
3211 : : cmdline_fixed_string_t list_name;
3212 : : cmdline_fixed_string_t list_of_items;
3213 : : };
3214 : :
3215 : : static int
3216 : 0 : parse_reta_config(const char *str,
3217 : : struct rte_eth_rss_reta_entry64 *reta_conf,
3218 : : uint16_t nb_entries)
3219 : : {
3220 : : int i;
3221 : : unsigned size;
3222 : : uint16_t hash_index, idx, shift;
3223 : : uint16_t nb_queue;
3224 : : char s[256];
3225 : : const char *p, *p0 = str;
3226 : : char *end;
3227 : : enum fieldnames {
3228 : : FLD_HASH_INDEX = 0,
3229 : : FLD_QUEUE,
3230 : : _NUM_FLD
3231 : : };
3232 : : unsigned long int_fld[_NUM_FLD];
3233 : : char *str_fld[_NUM_FLD];
3234 : :
3235 : 0 : while ((p = strchr(p0,'(')) != NULL) {
3236 : 0 : ++p;
3237 : 0 : if((p0 = strchr(p,')')) == NULL)
3238 : : return -1;
3239 : :
3240 : 0 : size = p0 - p;
3241 : 0 : if(size >= sizeof(s))
3242 : : return -1;
3243 : :
3244 : : snprintf(s, sizeof(s), "%.*s", size, p);
3245 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3246 : : return -1;
3247 : 0 : for (i = 0; i < _NUM_FLD; i++) {
3248 : 0 : errno = 0;
3249 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
3250 : 0 : if (errno != 0 || end == str_fld[i] ||
3251 : : int_fld[i] > 65535)
3252 : : return -1;
3253 : : }
3254 : :
3255 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3256 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3257 : :
3258 : 0 : if (hash_index >= nb_entries) {
3259 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
3260 : : hash_index);
3261 : 0 : return -1;
3262 : : }
3263 : :
3264 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3265 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3266 : 0 : reta_conf[idx].mask |= (1ULL << shift);
3267 : 0 : reta_conf[idx].reta[shift] = nb_queue;
3268 : : }
3269 : :
3270 : : return 0;
3271 : : }
3272 : :
3273 : : static void
3274 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
3275 : : __rte_unused struct cmdline *cl,
3276 : : __rte_unused void *data)
3277 : : {
3278 : : int ret;
3279 : : struct rte_eth_dev_info dev_info;
3280 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3281 : : struct cmd_config_rss_reta *res = parsed_result;
3282 : :
3283 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3284 : 0 : if (ret != 0)
3285 : 0 : return;
3286 : :
3287 : 0 : if (dev_info.reta_size == 0) {
3288 : 0 : fprintf(stderr,
3289 : : "Redirection table size is 0 which is invalid for RSS\n");
3290 : 0 : return;
3291 : : } else
3292 : 0 : printf("The reta size of port %d is %u\n",
3293 : 0 : res->port_id, dev_info.reta_size);
3294 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3295 : 0 : fprintf(stderr,
3296 : : "Currently do not support more than %u entries of redirection table\n",
3297 : : RTE_ETH_RSS_RETA_SIZE_512);
3298 : 0 : return;
3299 : : }
3300 : :
3301 : : memset(reta_conf, 0, sizeof(reta_conf));
3302 : 0 : if (!strcmp(res->list_name, "reta")) {
3303 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
3304 : : dev_info.reta_size)) {
3305 : 0 : fprintf(stderr,
3306 : : "Invalid RSS Redirection Table config entered\n");
3307 : 0 : return;
3308 : : }
3309 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
3310 : 0 : reta_conf, dev_info.reta_size);
3311 : 0 : if (ret != 0)
3312 : 0 : fprintf(stderr,
3313 : : "Bad redirection table parameter, return code = %d\n",
3314 : : ret);
3315 : : }
3316 : : }
3317 : :
3318 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3319 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3320 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3321 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3322 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3323 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3324 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3325 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3326 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3327 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3328 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3329 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3330 : : NULL);
3331 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
3332 : : .f = cmd_set_rss_reta_parsed,
3333 : : .data = NULL,
3334 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3335 : : .tokens = {
3336 : : (void *)&cmd_config_rss_reta_port,
3337 : : (void *)&cmd_config_rss_reta_keyword,
3338 : : (void *)&cmd_config_rss_reta_port_id,
3339 : : (void *)&cmd_config_rss_reta_name,
3340 : : (void *)&cmd_config_rss_reta_list_name,
3341 : : (void *)&cmd_config_rss_reta_list_of_items,
3342 : : NULL,
3343 : : },
3344 : : };
3345 : :
3346 : : /* *** SHOW PORT RETA INFO *** */
3347 : : struct cmd_showport_reta {
3348 : : cmdline_fixed_string_t show;
3349 : : cmdline_fixed_string_t port;
3350 : : portid_t port_id;
3351 : : cmdline_fixed_string_t rss;
3352 : : cmdline_fixed_string_t reta;
3353 : : uint16_t size;
3354 : : cmdline_fixed_string_t list_of_items;
3355 : : };
3356 : :
3357 : : static int
3358 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3359 : : uint16_t nb_entries,
3360 : : char *str)
3361 : : {
3362 : : uint32_t size;
3363 : : const char *p, *p0 = str;
3364 : : char s[256];
3365 : : char *end;
3366 : : char *str_fld[8];
3367 : : uint16_t i;
3368 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3369 : : RTE_ETH_RETA_GROUP_SIZE;
3370 : : int ret;
3371 : :
3372 : 0 : p = strchr(p0, '(');
3373 : 0 : if (p == NULL)
3374 : : return -1;
3375 : 0 : p++;
3376 : 0 : p0 = strchr(p, ')');
3377 : 0 : if (p0 == NULL)
3378 : : return -1;
3379 : 0 : size = p0 - p;
3380 : 0 : if (size >= sizeof(s)) {
3381 : 0 : fprintf(stderr,
3382 : : "The string size exceeds the internal buffer size\n");
3383 : 0 : return -1;
3384 : : }
3385 : : snprintf(s, sizeof(s), "%.*s", size, p);
3386 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3387 : 0 : if (ret <= 0 || ret != num) {
3388 : 0 : fprintf(stderr,
3389 : : "The bits of masks do not match the number of reta entries: %u\n",
3390 : : num);
3391 : 0 : return -1;
3392 : : }
3393 : 0 : for (i = 0; i < ret; i++)
3394 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3395 : :
3396 : : return 0;
3397 : : }
3398 : :
3399 : : static void
3400 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3401 : : __rte_unused struct cmdline *cl,
3402 : : __rte_unused void *data)
3403 : : {
3404 : : struct cmd_showport_reta *res = parsed_result;
3405 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3406 : : struct rte_eth_dev_info dev_info;
3407 : : uint16_t max_reta_size;
3408 : : int ret;
3409 : :
3410 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3411 : 0 : if (ret != 0)
3412 : 0 : return;
3413 : :
3414 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3415 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3416 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3417 : : res->size, max_reta_size);
3418 : 0 : return;
3419 : : }
3420 : :
3421 : : memset(reta_conf, 0, sizeof(reta_conf));
3422 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3423 : 0 : res->list_of_items) < 0) {
3424 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3425 : : res->list_of_items);
3426 : 0 : return;
3427 : : }
3428 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3429 : : }
3430 : :
3431 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3432 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3433 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3434 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3435 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3436 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3437 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3438 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3439 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3440 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3441 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3442 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3443 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3444 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3445 : : list_of_items, NULL);
3446 : :
3447 : : static cmdline_parse_inst_t cmd_showport_reta = {
3448 : : .f = cmd_showport_reta_parsed,
3449 : : .data = NULL,
3450 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3451 : : .tokens = {
3452 : : (void *)&cmd_showport_reta_show,
3453 : : (void *)&cmd_showport_reta_port,
3454 : : (void *)&cmd_showport_reta_port_id,
3455 : : (void *)&cmd_showport_reta_rss,
3456 : : (void *)&cmd_showport_reta_reta,
3457 : : (void *)&cmd_showport_reta_size,
3458 : : (void *)&cmd_showport_reta_list_of_items,
3459 : : NULL,
3460 : : },
3461 : : };
3462 : :
3463 : : /* *** Show RSS hash configuration *** */
3464 : : struct cmd_showport_rss_hash {
3465 : : cmdline_fixed_string_t show;
3466 : : cmdline_fixed_string_t port;
3467 : : portid_t port_id;
3468 : : cmdline_fixed_string_t rss_hash;
3469 : : cmdline_fixed_string_t rss_type;
3470 : : cmdline_fixed_string_t key; /* optional argument */
3471 : : cmdline_fixed_string_t algorithm; /* optional argument */
3472 : : };
3473 : :
3474 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3475 : : __rte_unused struct cmdline *cl,
3476 : : __rte_unused void *data)
3477 : : {
3478 : : struct cmd_showport_rss_hash *res = parsed_result;
3479 : :
3480 : 0 : port_rss_hash_conf_show(res->port_id,
3481 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3482 : 0 : }
3483 : :
3484 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3485 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3486 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3487 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3488 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3489 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3490 : : RTE_UINT16);
3491 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3492 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3493 : : "rss-hash");
3494 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3495 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3496 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3497 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3498 : :
3499 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3500 : : .f = cmd_showport_rss_hash_parsed,
3501 : : .data = NULL,
3502 : : .help_str = "show port <port_id> rss-hash",
3503 : : .tokens = {
3504 : : (void *)&cmd_showport_rss_hash_show,
3505 : : (void *)&cmd_showport_rss_hash_port,
3506 : : (void *)&cmd_showport_rss_hash_port_id,
3507 : : (void *)&cmd_showport_rss_hash_rss_hash,
3508 : : NULL,
3509 : : },
3510 : : };
3511 : :
3512 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3513 : : .f = cmd_showport_rss_hash_parsed,
3514 : : .data = NULL,
3515 : : .help_str = "show port <port_id> rss-hash key",
3516 : : .tokens = {
3517 : : (void *)&cmd_showport_rss_hash_show,
3518 : : (void *)&cmd_showport_rss_hash_port,
3519 : : (void *)&cmd_showport_rss_hash_port_id,
3520 : : (void *)&cmd_showport_rss_hash_rss_hash,
3521 : : (void *)&cmd_showport_rss_hash_rss_key,
3522 : : NULL,
3523 : : },
3524 : : };
3525 : :
3526 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3527 : : .f = cmd_showport_rss_hash_parsed,
3528 : : .data = NULL,
3529 : : .help_str = "show port <port_id> rss-hash algorithm",
3530 : : .tokens = {
3531 : : (void *)&cmd_showport_rss_hash_show,
3532 : : (void *)&cmd_showport_rss_hash_port,
3533 : : (void *)&cmd_showport_rss_hash_port_id,
3534 : : (void *)&cmd_showport_rss_hash_rss_hash,
3535 : : (void *)&cmd_showport_rss_hash_rss_algo,
3536 : : NULL,
3537 : : },
3538 : : };
3539 : :
3540 : : /* *** Configure DCB *** */
3541 : : struct cmd_config_dcb {
3542 : : cmdline_fixed_string_t port;
3543 : : cmdline_fixed_string_t config;
3544 : : portid_t port_id;
3545 : : cmdline_fixed_string_t dcb;
3546 : : cmdline_fixed_string_t vt;
3547 : : cmdline_fixed_string_t vt_en;
3548 : : uint8_t num_tcs;
3549 : : cmdline_fixed_string_t pfc;
3550 : : cmdline_multi_string_t token_str;
3551 : : };
3552 : :
3553 : : static int
3554 : 0 : parse_dcb_token_prio_tc(char *param_str[], int param_num,
3555 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3556 : : uint8_t *prio_tc_en)
3557 : : {
3558 : : unsigned long prio, tc;
3559 : : int prio_tc_maps = 0;
3560 : : char *param, *end;
3561 : : int i;
3562 : :
3563 : 0 : for (i = 0; i < param_num; i++) {
3564 : 0 : param = param_str[i];
3565 : 0 : prio = strtoul(param, &end, 10);
3566 : 0 : if (prio >= RTE_ETH_DCB_NUM_USER_PRIORITIES) {
3567 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO %lu\n", prio);
3568 : 0 : return -1;
3569 : : }
3570 : 0 : if ((*end != ':') || (strlen(end + 1) == 0)) {
3571 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3572 : 0 : return -1;
3573 : : }
3574 : 0 : tc = strtoul(end + 1, &end, 10);
3575 : 0 : if (tc >= RTE_ETH_8_TCS) {
3576 : 0 : fprintf(stderr, "Bad Argument: invalid TC %lu\n", tc);
3577 : 0 : return -1;
3578 : : }
3579 : 0 : if (*end != '\0') {
3580 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3581 : 0 : return -1;
3582 : : }
3583 : 0 : prio_tc[prio] = tc;
3584 : 0 : prio_tc_maps++;
3585 : : } while (0);
3586 : :
3587 : 0 : if (prio_tc_maps == 0) {
3588 : 0 : fprintf(stderr, "Bad Argument: no PRIO:TC provided\n");
3589 : 0 : return -1;
3590 : : }
3591 : 0 : *prio_tc_en = 1;
3592 : :
3593 : 0 : return 0;
3594 : : }
3595 : :
3596 : : #define DCB_TOKEN_PRIO_TC "prio-tc"
3597 : : #define DCB_TOKEN_KEEP_QNUM "keep-qnum"
3598 : :
3599 : : static int
3600 : 0 : parse_dcb_token_find(char *split_str[], int split_num, int *param_num)
3601 : : {
3602 : : int i;
3603 : :
3604 : 0 : if (strcmp(split_str[0], DCB_TOKEN_KEEP_QNUM) == 0) {
3605 : 0 : *param_num = 0;
3606 : 0 : return 0;
3607 : : }
3608 : :
3609 : 0 : if (strcmp(split_str[0], DCB_TOKEN_PRIO_TC) != 0) {
3610 : 0 : fprintf(stderr, "Bad Argument: unknown token %s\n", split_str[0]);
3611 : 0 : return -EINVAL;
3612 : : }
3613 : :
3614 : 0 : for (i = 1; i < split_num; i++) {
3615 : 0 : if ((strcmp(split_str[i], DCB_TOKEN_PRIO_TC) != 0) &&
3616 : 0 : (strcmp(split_str[i], DCB_TOKEN_KEEP_QNUM) != 0))
3617 : : continue;
3618 : : /* find another optional parameter, then exit. */
3619 : : break;
3620 : : }
3621 : :
3622 : 0 : *param_num = i - 1;
3623 : :
3624 : 0 : return 0;
3625 : : }
3626 : :
3627 : : static int
3628 : 0 : parse_dcb_token_value(char *token_str,
3629 : : uint8_t *pfc_en,
3630 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3631 : : uint8_t *prio_tc_en,
3632 : : uint8_t *keep_qnum)
3633 : : {
3634 : : #define MAX_TOKEN_NUM 128
3635 : : char *split_str[MAX_TOKEN_NUM];
3636 : : int param_num, start, ret;
3637 : : int split_num = 0;
3638 : : char *token;
3639 : :
3640 : : /* split multiple token to split str. */
3641 : : do {
3642 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
3643 : 0 : if (token == NULL)
3644 : : break;
3645 : 0 : if (split_num >= MAX_TOKEN_NUM) {
3646 : 0 : fprintf(stderr, "Bad Argument: too much argument\n");
3647 : 0 : return -1;
3648 : : }
3649 : 0 : split_str[split_num++] = token;
3650 : : } while (1);
3651 : :
3652 : : /* parse fixed parameter "pfc-en" first. */
3653 : 0 : token = split_str[0];
3654 : 0 : if (strcmp(token, "on") == 0)
3655 : 0 : *pfc_en = 1;
3656 : 0 : else if (strcmp(token, "off") == 0)
3657 : 0 : *pfc_en = 0;
3658 : : else {
3659 : 0 : fprintf(stderr, "Bad Argument: pfc-en must be on or off\n");
3660 : 0 : return -EINVAL;
3661 : : }
3662 : :
3663 : 0 : if (split_num == 1)
3664 : : return 0;
3665 : :
3666 : : /* start parse optional parameter. */
3667 : : start = 1;
3668 : : do {
3669 : 0 : param_num = 0;
3670 : 0 : ret = parse_dcb_token_find(&split_str[start], split_num - start, ¶m_num);
3671 : 0 : if (ret != 0)
3672 : 0 : return ret;
3673 : :
3674 : 0 : token = split_str[start];
3675 : 0 : if (strcmp(token, DCB_TOKEN_PRIO_TC) == 0) {
3676 : 0 : if (*prio_tc_en == 1) {
3677 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3678 : : DCB_TOKEN_PRIO_TC);
3679 : 0 : return -1;
3680 : : }
3681 : 0 : ret = parse_dcb_token_prio_tc(&split_str[start + 1], param_num, prio_tc,
3682 : : prio_tc_en);
3683 : 0 : if (ret != 0)
3684 : 0 : return ret;
3685 : : } else {
3686 : : /* this must be keep-qnum. */
3687 : 0 : if (*keep_qnum == 1) {
3688 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3689 : : DCB_TOKEN_KEEP_QNUM);
3690 : 0 : return -1;
3691 : : }
3692 : 0 : *keep_qnum = 1;
3693 : : }
3694 : :
3695 : 0 : start += param_num + 1;
3696 : 0 : if (start >= split_num)
3697 : : break;
3698 : : } while (1);
3699 : :
3700 : : return 0;
3701 : : }
3702 : :
3703 : : static void
3704 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3705 : : __rte_unused struct cmdline *cl,
3706 : : __rte_unused void *data)
3707 : : {
3708 : 0 : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES] = {0};
3709 : : struct cmd_config_dcb *res = parsed_result;
3710 : : struct rte_eth_dcb_info dcb_info;
3711 : 0 : portid_t port_id = res->port_id;
3712 : 0 : uint8_t prio_tc_en = 0;
3713 : 0 : uint8_t keep_qnum = 0;
3714 : : struct rte_port *port;
3715 : 0 : uint8_t pfc_en = 0;
3716 : : int ret;
3717 : :
3718 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
3719 : 0 : return;
3720 : :
3721 : 0 : port = &ports[port_id];
3722 : : /** Check if the port is not started **/
3723 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3724 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3725 : 0 : return;
3726 : : }
3727 : :
3728 : 0 : if (res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS) {
3729 : 0 : fprintf(stderr,
3730 : : "The invalid number of traffic class, only 1~8 allowed.\n");
3731 : 0 : return;
3732 : : }
3733 : :
3734 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3735 : 0 : fprintf(stderr,
3736 : : "nb_cores shouldn't be less than number of TCs.\n");
3737 : 0 : return;
3738 : : }
3739 : :
3740 : : /* Check whether the port supports the report of DCB info. */
3741 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3742 : 0 : if (ret == -ENOTSUP) {
3743 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3744 : 0 : return;
3745 : : }
3746 : :
3747 : 0 : ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en, &keep_qnum);
3748 : 0 : if (ret != 0)
3749 : : return;
3750 : :
3751 : : /* DCB in VT mode */
3752 : 0 : if (!strncmp(res->vt_en, "on", 2))
3753 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3754 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3755 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3756 : : else
3757 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3758 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3759 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3760 : 0 : if (ret != 0) {
3761 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3762 : 0 : return;
3763 : : }
3764 : :
3765 : 0 : fwd_config_setup();
3766 : :
3767 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3768 : : }
3769 : :
3770 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3771 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3772 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3773 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3774 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3775 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3776 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3777 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3778 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3779 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3780 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3781 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3782 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3783 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3784 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3785 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3786 : : static cmdline_parse_token_string_t cmd_config_dcb_token_str =
3787 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, token_str, TOKEN_STRING_MULTI);
3788 : :
3789 : : static cmdline_parse_inst_t cmd_config_dcb = {
3790 : : .f = cmd_config_dcb_parsed,
3791 : : .data = NULL,
3792 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP keep-qnum\n"
3793 : : "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
3794 : : " PRIO-MAPPING := PRIO:TC\n"
3795 : : " PRIO: { 0 .. 7 }\n"
3796 : : " TC: { 0 .. 7 }",
3797 : : .tokens = {
3798 : : (void *)&cmd_config_dcb_port,
3799 : : (void *)&cmd_config_dcb_config,
3800 : : (void *)&cmd_config_dcb_port_id,
3801 : : (void *)&cmd_config_dcb_dcb,
3802 : : (void *)&cmd_config_dcb_vt,
3803 : : (void *)&cmd_config_dcb_vt_en,
3804 : : (void *)&cmd_config_dcb_num_tcs,
3805 : : (void *)&cmd_config_dcb_pfc,
3806 : : (void *)&cmd_config_dcb_token_str,
3807 : : NULL,
3808 : : },
3809 : : };
3810 : :
3811 : : /* *** configure number of packets per burst *** */
3812 : : struct cmd_config_burst {
3813 : : cmdline_fixed_string_t port;
3814 : : cmdline_fixed_string_t keyword;
3815 : : cmdline_fixed_string_t all;
3816 : : cmdline_fixed_string_t name;
3817 : : uint16_t value;
3818 : : };
3819 : :
3820 : : static void
3821 : 0 : cmd_config_burst_parsed(void *parsed_result,
3822 : : __rte_unused struct cmdline *cl,
3823 : : __rte_unused void *data)
3824 : : {
3825 : : struct cmd_config_burst *res = parsed_result;
3826 : : struct rte_eth_dev_info dev_info;
3827 : : uint16_t rec_nb_pkts;
3828 : : int ret;
3829 : :
3830 : 0 : if (!all_ports_stopped()) {
3831 : 0 : fprintf(stderr, "Please stop all ports first\n");
3832 : 0 : return;
3833 : : }
3834 : :
3835 : 0 : if (!strcmp(res->name, "burst")) {
3836 : 0 : if (res->value == 0) {
3837 : : /* If user gives a value of zero, query the PMD for
3838 : : * its recommended Rx burst size. Testpmd uses a single
3839 : : * size for all ports, so assume all ports are the same
3840 : : * NIC model and use the values from Port 0.
3841 : : */
3842 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3843 : 0 : if (ret != 0)
3844 : : return;
3845 : :
3846 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3847 : :
3848 : 0 : if (rec_nb_pkts == 0) {
3849 : : printf("PMD does not recommend a burst size.\n"
3850 : : "User provided value must be between"
3851 : : " 1 and %d\n", MAX_PKT_BURST);
3852 : 0 : return;
3853 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3854 : 0 : printf("PMD recommended burst size of %d"
3855 : : " exceeds maximum value of %d\n",
3856 : : rec_nb_pkts, MAX_PKT_BURST);
3857 : 0 : return;
3858 : : }
3859 : 0 : printf("Using PMD-provided burst value of %d\n",
3860 : : rec_nb_pkts);
3861 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3862 : 0 : } else if (res->value > MAX_PKT_BURST) {
3863 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3864 : : MAX_PKT_BURST);
3865 : 0 : return;
3866 : : } else
3867 : 0 : nb_pkt_per_burst = res->value;
3868 : : } else {
3869 : 0 : fprintf(stderr, "Unknown parameter\n");
3870 : 0 : return;
3871 : : }
3872 : :
3873 : 0 : init_port_config();
3874 : :
3875 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3876 : : }
3877 : :
3878 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3879 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3880 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3881 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3882 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3883 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3884 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3885 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3886 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3887 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3888 : :
3889 : : static cmdline_parse_inst_t cmd_config_burst = {
3890 : : .f = cmd_config_burst_parsed,
3891 : : .data = NULL,
3892 : : .help_str = "port config all burst <value>",
3893 : : .tokens = {
3894 : : (void *)&cmd_config_burst_port,
3895 : : (void *)&cmd_config_burst_keyword,
3896 : : (void *)&cmd_config_burst_all,
3897 : : (void *)&cmd_config_burst_name,
3898 : : (void *)&cmd_config_burst_value,
3899 : : NULL,
3900 : : },
3901 : : };
3902 : :
3903 : : /* *** configure rx/tx queues *** */
3904 : : struct cmd_config_thresh {
3905 : : cmdline_fixed_string_t port;
3906 : : cmdline_fixed_string_t keyword;
3907 : : cmdline_fixed_string_t all;
3908 : : cmdline_fixed_string_t name;
3909 : : uint8_t value;
3910 : : };
3911 : :
3912 : : static void
3913 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3914 : : __rte_unused struct cmdline *cl,
3915 : : __rte_unused void *data)
3916 : : {
3917 : : struct cmd_config_thresh *res = parsed_result;
3918 : :
3919 : 0 : if (!all_ports_stopped()) {
3920 : 0 : fprintf(stderr, "Please stop all ports first\n");
3921 : 0 : return;
3922 : : }
3923 : :
3924 : 0 : if (!strcmp(res->name, "txpt"))
3925 : 0 : tx_pthresh = res->value;
3926 : 0 : else if(!strcmp(res->name, "txht"))
3927 : 0 : tx_hthresh = res->value;
3928 : 0 : else if(!strcmp(res->name, "txwt"))
3929 : 0 : tx_wthresh = res->value;
3930 : 0 : else if(!strcmp(res->name, "rxpt"))
3931 : 0 : rx_pthresh = res->value;
3932 : 0 : else if(!strcmp(res->name, "rxht"))
3933 : 0 : rx_hthresh = res->value;
3934 : 0 : else if(!strcmp(res->name, "rxwt"))
3935 : 0 : rx_wthresh = res->value;
3936 : : else {
3937 : 0 : fprintf(stderr, "Unknown parameter\n");
3938 : 0 : return;
3939 : : }
3940 : :
3941 : 0 : init_port_config();
3942 : :
3943 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3944 : : }
3945 : :
3946 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3947 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3948 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3949 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3950 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3951 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3952 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3953 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3954 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3955 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3956 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3957 : :
3958 : : static cmdline_parse_inst_t cmd_config_thresh = {
3959 : : .f = cmd_config_thresh_parsed,
3960 : : .data = NULL,
3961 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3962 : : .tokens = {
3963 : : (void *)&cmd_config_thresh_port,
3964 : : (void *)&cmd_config_thresh_keyword,
3965 : : (void *)&cmd_config_thresh_all,
3966 : : (void *)&cmd_config_thresh_name,
3967 : : (void *)&cmd_config_thresh_value,
3968 : : NULL,
3969 : : },
3970 : : };
3971 : :
3972 : : /* *** configure free/rs threshold *** */
3973 : : struct cmd_config_threshold {
3974 : : cmdline_fixed_string_t port;
3975 : : cmdline_fixed_string_t keyword;
3976 : : cmdline_fixed_string_t all;
3977 : : cmdline_fixed_string_t name;
3978 : : uint16_t value;
3979 : : };
3980 : :
3981 : : static void
3982 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3983 : : __rte_unused struct cmdline *cl,
3984 : : __rte_unused void *data)
3985 : : {
3986 : : struct cmd_config_threshold *res = parsed_result;
3987 : :
3988 : 0 : if (!all_ports_stopped()) {
3989 : 0 : fprintf(stderr, "Please stop all ports first\n");
3990 : 0 : return;
3991 : : }
3992 : :
3993 : 0 : if (!strcmp(res->name, "txfreet"))
3994 : 0 : tx_free_thresh = res->value;
3995 : 0 : else if (!strcmp(res->name, "txrst"))
3996 : 0 : tx_rs_thresh = res->value;
3997 : 0 : else if (!strcmp(res->name, "rxfreet"))
3998 : 0 : rx_free_thresh = res->value;
3999 : : else {
4000 : 0 : fprintf(stderr, "Unknown parameter\n");
4001 : 0 : return;
4002 : : }
4003 : :
4004 : 0 : init_port_config();
4005 : :
4006 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
4007 : : }
4008 : :
4009 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
4010 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
4011 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
4012 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
4013 : : "config");
4014 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
4015 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
4016 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
4017 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
4018 : : "txfreet#txrst#rxfreet");
4019 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
4020 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
4021 : :
4022 : : static cmdline_parse_inst_t cmd_config_threshold = {
4023 : : .f = cmd_config_threshold_parsed,
4024 : : .data = NULL,
4025 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
4026 : : .tokens = {
4027 : : (void *)&cmd_config_threshold_port,
4028 : : (void *)&cmd_config_threshold_keyword,
4029 : : (void *)&cmd_config_threshold_all,
4030 : : (void *)&cmd_config_threshold_name,
4031 : : (void *)&cmd_config_threshold_value,
4032 : : NULL,
4033 : : },
4034 : : };
4035 : :
4036 : : /* *** stop *** */
4037 : : struct cmd_stop_result {
4038 : : cmdline_fixed_string_t stop;
4039 : : };
4040 : :
4041 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
4042 : : __rte_unused struct cmdline *cl,
4043 : : __rte_unused void *data)
4044 : : {
4045 : 0 : stop_packet_forwarding();
4046 : 0 : }
4047 : :
4048 : : static cmdline_parse_token_string_t cmd_stop_stop =
4049 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
4050 : :
4051 : : static cmdline_parse_inst_t cmd_stop = {
4052 : : .f = cmd_stop_parsed,
4053 : : .data = NULL,
4054 : : .help_str = "stop: Stop packet forwarding",
4055 : : .tokens = {
4056 : : (void *)&cmd_stop_stop,
4057 : : NULL,
4058 : : },
4059 : : };
4060 : :
4061 : : static unsigned int
4062 : 0 : get_ptype(char *value)
4063 : : {
4064 : : uint32_t protocol;
4065 : :
4066 : 0 : if (!strcmp(value, "eth"))
4067 : : protocol = RTE_PTYPE_L2_ETHER;
4068 : 0 : else if (!strcmp(value, "ipv4"))
4069 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
4070 : 0 : else if (!strcmp(value, "ipv6"))
4071 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
4072 : 0 : else if (!strcmp(value, "ipv4-tcp"))
4073 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
4074 : 0 : else if (!strcmp(value, "ipv4-udp"))
4075 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
4076 : 0 : else if (!strcmp(value, "ipv4-sctp"))
4077 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4078 : 0 : else if (!strcmp(value, "ipv6-tcp"))
4079 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
4080 : 0 : else if (!strcmp(value, "ipv6-udp"))
4081 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
4082 : 0 : else if (!strcmp(value, "ipv6-sctp"))
4083 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4084 : 0 : else if (!strcmp(value, "grenat"))
4085 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
4086 : 0 : else if (!strcmp(value, "inner-eth"))
4087 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
4088 : 0 : else if (!strcmp(value, "inner-ipv4"))
4089 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4090 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
4091 : 0 : else if (!strcmp(value, "inner-ipv6"))
4092 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4093 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
4094 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
4095 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4096 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4097 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
4098 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4099 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4100 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
4101 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4102 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4103 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
4104 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4105 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4106 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
4107 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4108 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4109 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
4110 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4111 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4112 : : else {
4113 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
4114 : : protocol = RTE_PTYPE_UNKNOWN;
4115 : : }
4116 : :
4117 : 0 : return protocol;
4118 : : }
4119 : :
4120 : : /* *** SET RXHDRSLIST *** */
4121 : :
4122 : : unsigned int
4123 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
4124 : : unsigned int *parsed_items)
4125 : : {
4126 : : unsigned int nb_item;
4127 : : char *cur;
4128 : : char *tmp;
4129 : :
4130 : : nb_item = 0;
4131 : 0 : char *str2 = strdup(str);
4132 : 0 : if (str2 == NULL)
4133 : : return nb_item;
4134 : 0 : cur = strtok_r(str2, ",", &tmp);
4135 : 0 : while (cur != NULL) {
4136 : 0 : parsed_items[nb_item] = get_ptype(cur);
4137 : 0 : cur = strtok_r(NULL, ",", &tmp);
4138 : 0 : nb_item++;
4139 : : }
4140 : 0 : if (nb_item > max_items)
4141 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4142 : : item_name, nb_item + 1, max_items);
4143 : 0 : free(str2);
4144 : 0 : return nb_item;
4145 : : }
4146 : :
4147 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
4148 : :
4149 : : unsigned int
4150 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
4151 : : unsigned int *parsed_items, int check_unique_values)
4152 : : {
4153 : : unsigned int nb_item;
4154 : : unsigned int value;
4155 : : unsigned int i;
4156 : : unsigned int j;
4157 : : int value_ok;
4158 : : char c;
4159 : :
4160 : : /*
4161 : : * First parse all items in the list and store their value.
4162 : : */
4163 : : value = 0;
4164 : : nb_item = 0;
4165 : : value_ok = 0;
4166 : 0 : for (i = 0; i < strnlen(str, STR_MULTI_TOKEN_SIZE); i++) {
4167 : 0 : c = str[i];
4168 : 0 : if ((c >= '0') && (c <= '9')) {
4169 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
4170 : : value_ok = 1;
4171 : 0 : continue;
4172 : : }
4173 : 0 : if (c != ',') {
4174 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
4175 : 0 : return 0;
4176 : : }
4177 : 0 : if (! value_ok) {
4178 : 0 : fprintf(stderr, "No valid value before comma\n");
4179 : 0 : return 0;
4180 : : }
4181 : 0 : if (nb_item < max_items) {
4182 : 0 : parsed_items[nb_item] = value;
4183 : : value_ok = 0;
4184 : : value = 0;
4185 : : }
4186 : 0 : nb_item++;
4187 : : }
4188 : 0 : if (nb_item >= max_items) {
4189 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4190 : : item_name, nb_item + 1, max_items);
4191 : 0 : return 0;
4192 : : }
4193 : 0 : parsed_items[nb_item++] = value;
4194 : 0 : if (! check_unique_values)
4195 : : return nb_item;
4196 : :
4197 : : /*
4198 : : * Then, check that all values in the list are different.
4199 : : * No optimization here...
4200 : : */
4201 : 0 : for (i = 0; i < nb_item; i++) {
4202 : 0 : for (j = i + 1; j < nb_item; j++) {
4203 : 0 : if (parsed_items[j] == parsed_items[i]) {
4204 : 0 : fprintf(stderr,
4205 : : "duplicated %s %u at index %u and %u\n",
4206 : : item_name, parsed_items[i], i, j);
4207 : 0 : return 0;
4208 : : }
4209 : : }
4210 : : }
4211 : : return nb_item;
4212 : : }
4213 : :
4214 : : struct cmd_set_list_result {
4215 : : cmdline_fixed_string_t cmd_keyword;
4216 : : cmdline_fixed_string_t list_name;
4217 : : cmdline_multi_string_t list_of_items;
4218 : : };
4219 : :
4220 : 0 : static void cmd_set_list_parsed(void *parsed_result,
4221 : : __rte_unused struct cmdline *cl,
4222 : : __rte_unused void *data)
4223 : : {
4224 : : struct cmd_set_list_result *res;
4225 : : union {
4226 : : unsigned int lcorelist[RTE_MAX_LCORE];
4227 : : unsigned int portlist[RTE_MAX_ETHPORTS];
4228 : : } parsed_items;
4229 : : unsigned int nb_item;
4230 : :
4231 : 0 : if (test_done == 0) {
4232 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4233 : 0 : return;
4234 : : }
4235 : :
4236 : : res = parsed_result;
4237 : 0 : if (!strcmp(res->list_name, "corelist")) {
4238 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
4239 : : RTE_MAX_LCORE,
4240 : : parsed_items.lcorelist, 1);
4241 : 0 : if (nb_item > 0) {
4242 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
4243 : 0 : fwd_config_setup();
4244 : : }
4245 : 0 : return;
4246 : : }
4247 : 0 : if (!strcmp(res->list_name, "portlist")) {
4248 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
4249 : : RTE_MAX_ETHPORTS,
4250 : : parsed_items.portlist, 1);
4251 : 0 : if (nb_item > 0) {
4252 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
4253 : 0 : fwd_config_setup();
4254 : : }
4255 : : }
4256 : : }
4257 : :
4258 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
4259 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
4260 : : "set");
4261 : : static cmdline_parse_token_string_t cmd_set_list_name =
4262 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
4263 : : "corelist#portlist");
4264 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
4265 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
4266 : : TOKEN_STRING_MULTI);
4267 : :
4268 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
4269 : : .f = cmd_set_list_parsed,
4270 : : .data = NULL,
4271 : : .help_str = "set corelist|portlist <list0[,list1]*>",
4272 : : .tokens = {
4273 : : (void *)&cmd_set_list_keyword,
4274 : : (void *)&cmd_set_list_name,
4275 : : (void *)&cmd_set_list_of_items,
4276 : : NULL,
4277 : : },
4278 : : };
4279 : :
4280 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
4281 : :
4282 : : struct cmd_setmask_result {
4283 : : cmdline_fixed_string_t set;
4284 : : cmdline_fixed_string_t mask;
4285 : : uint64_t hexavalue;
4286 : : };
4287 : :
4288 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
4289 : : __rte_unused struct cmdline *cl,
4290 : : __rte_unused void *data)
4291 : : {
4292 : : struct cmd_setmask_result *res = parsed_result;
4293 : :
4294 : 0 : if (test_done == 0) {
4295 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4296 : 0 : return;
4297 : : }
4298 : 0 : if (!strcmp(res->mask, "coremask")) {
4299 : 0 : set_fwd_lcores_mask(res->hexavalue);
4300 : 0 : fwd_config_setup();
4301 : 0 : } else if (!strcmp(res->mask, "portmask")) {
4302 : 0 : set_fwd_ports_mask(res->hexavalue);
4303 : 0 : fwd_config_setup();
4304 : : }
4305 : : }
4306 : :
4307 : : static cmdline_parse_token_string_t cmd_setmask_set =
4308 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
4309 : : static cmdline_parse_token_string_t cmd_setmask_mask =
4310 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
4311 : : "coremask#portmask");
4312 : : static cmdline_parse_token_num_t cmd_setmask_value =
4313 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
4314 : :
4315 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
4316 : : .f = cmd_set_mask_parsed,
4317 : : .data = NULL,
4318 : : .help_str = "set coremask|portmask <hexadecimal value>",
4319 : : .tokens = {
4320 : : (void *)&cmd_setmask_set,
4321 : : (void *)&cmd_setmask_mask,
4322 : : (void *)&cmd_setmask_value,
4323 : : NULL,
4324 : : },
4325 : : };
4326 : :
4327 : : /*
4328 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
4329 : : */
4330 : : struct cmd_set_result {
4331 : : cmdline_fixed_string_t set;
4332 : : cmdline_fixed_string_t what;
4333 : : uint16_t value;
4334 : : };
4335 : :
4336 : 0 : static void cmd_set_parsed(void *parsed_result,
4337 : : __rte_unused struct cmdline *cl,
4338 : : __rte_unused void *data)
4339 : : {
4340 : : struct cmd_set_result *res = parsed_result;
4341 : 0 : if (!strcmp(res->what, "nbport")) {
4342 : 0 : set_fwd_ports_number(res->value);
4343 : 0 : fwd_config_setup();
4344 : 0 : } else if (!strcmp(res->what, "nbcore")) {
4345 : 0 : set_fwd_lcores_number(res->value);
4346 : 0 : fwd_config_setup();
4347 : 0 : } else if (!strcmp(res->what, "burst"))
4348 : 0 : set_nb_pkt_per_burst(res->value);
4349 : 0 : else if (!strcmp(res->what, "verbose"))
4350 : 0 : set_verbose_level(res->value);
4351 : 0 : }
4352 : :
4353 : : static cmdline_parse_token_string_t cmd_set_set =
4354 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
4355 : : static cmdline_parse_token_string_t cmd_set_what =
4356 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
4357 : : "nbport#nbcore#burst#verbose");
4358 : : static cmdline_parse_token_num_t cmd_set_value =
4359 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
4360 : :
4361 : : static cmdline_parse_inst_t cmd_set_numbers = {
4362 : : .f = cmd_set_parsed,
4363 : : .data = NULL,
4364 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
4365 : : .tokens = {
4366 : : (void *)&cmd_set_set,
4367 : : (void *)&cmd_set_what,
4368 : : (void *)&cmd_set_value,
4369 : : NULL,
4370 : : },
4371 : : };
4372 : :
4373 : : /* *** SET LOG LEVEL CONFIGURATION *** */
4374 : :
4375 : : struct cmd_set_log_result {
4376 : : cmdline_fixed_string_t set;
4377 : : cmdline_fixed_string_t log;
4378 : : cmdline_fixed_string_t type;
4379 : : uint32_t level;
4380 : : };
4381 : :
4382 : : static void
4383 : 0 : cmd_set_log_parsed(void *parsed_result,
4384 : : __rte_unused struct cmdline *cl,
4385 : : __rte_unused void *data)
4386 : : {
4387 : : struct cmd_set_log_result *res;
4388 : : int ret;
4389 : :
4390 : : res = parsed_result;
4391 : 0 : if (!strcmp(res->type, "global"))
4392 : 0 : rte_log_set_global_level(res->level);
4393 : : else {
4394 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
4395 : 0 : if (ret < 0)
4396 : 0 : fprintf(stderr, "Unable to set log level\n");
4397 : : }
4398 : 0 : }
4399 : :
4400 : : static cmdline_parse_token_string_t cmd_set_log_set =
4401 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
4402 : : static cmdline_parse_token_string_t cmd_set_log_log =
4403 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
4404 : : static cmdline_parse_token_string_t cmd_set_log_type =
4405 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
4406 : : static cmdline_parse_token_num_t cmd_set_log_level =
4407 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
4408 : :
4409 : : static cmdline_parse_inst_t cmd_set_log = {
4410 : : .f = cmd_set_log_parsed,
4411 : : .data = NULL,
4412 : : .help_str = "set log global|<type> <level>",
4413 : : .tokens = {
4414 : : (void *)&cmd_set_log_set,
4415 : : (void *)&cmd_set_log_log,
4416 : : (void *)&cmd_set_log_type,
4417 : : (void *)&cmd_set_log_level,
4418 : : NULL,
4419 : : },
4420 : : };
4421 : :
4422 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
4423 : :
4424 : : struct cmd_set_rxoffs_result {
4425 : : cmdline_fixed_string_t cmd_keyword;
4426 : : cmdline_fixed_string_t rxoffs;
4427 : : cmdline_fixed_string_t seg_offsets;
4428 : : };
4429 : :
4430 : : static void
4431 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
4432 : : __rte_unused struct cmdline *cl,
4433 : : __rte_unused void *data)
4434 : : {
4435 : : struct cmd_set_rxoffs_result *res;
4436 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
4437 : : unsigned int nb_segs;
4438 : :
4439 : : res = parsed_result;
4440 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
4441 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
4442 : 0 : if (nb_segs > 0)
4443 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
4444 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4445 : 0 : }
4446 : :
4447 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
4448 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4449 : : cmd_keyword, "set");
4450 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
4451 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4452 : : rxoffs, "rxoffs");
4453 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
4454 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4455 : : seg_offsets, NULL);
4456 : :
4457 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
4458 : : .f = cmd_set_rxoffs_parsed,
4459 : : .data = NULL,
4460 : : .help_str = "set rxoffs <len0[,len1]*>",
4461 : : .tokens = {
4462 : : (void *)&cmd_set_rxoffs_keyword,
4463 : : (void *)&cmd_set_rxoffs_name,
4464 : : (void *)&cmd_set_rxoffs_offsets,
4465 : : NULL,
4466 : : },
4467 : : };
4468 : :
4469 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
4470 : :
4471 : : struct cmd_set_rxpkts_result {
4472 : : cmdline_fixed_string_t cmd_keyword;
4473 : : cmdline_fixed_string_t rxpkts;
4474 : : cmdline_fixed_string_t seg_lengths;
4475 : : };
4476 : :
4477 : : static void
4478 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
4479 : : __rte_unused struct cmdline *cl,
4480 : : __rte_unused void *data)
4481 : : {
4482 : : struct cmd_set_rxpkts_result *res;
4483 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
4484 : : unsigned int nb_segs;
4485 : :
4486 : : res = parsed_result;
4487 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4488 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
4489 : 0 : if (nb_segs > 0)
4490 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
4491 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4492 : 0 : }
4493 : :
4494 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
4495 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4496 : : cmd_keyword, "set");
4497 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
4498 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4499 : : rxpkts, "rxpkts");
4500 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4501 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4502 : : seg_lengths, NULL);
4503 : :
4504 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
4505 : : .f = cmd_set_rxpkts_parsed,
4506 : : .data = NULL,
4507 : : .help_str = "set rxpkts <len0[,len1]*>",
4508 : : .tokens = {
4509 : : (void *)&cmd_set_rxpkts_keyword,
4510 : : (void *)&cmd_set_rxpkts_name,
4511 : : (void *)&cmd_set_rxpkts_lengths,
4512 : : NULL,
4513 : : },
4514 : : };
4515 : :
4516 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4517 : : struct cmd_set_rxhdrs_result {
4518 : : cmdline_fixed_string_t set;
4519 : : cmdline_fixed_string_t rxhdrs;
4520 : : cmdline_fixed_string_t values;
4521 : : };
4522 : :
4523 : : static void
4524 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4525 : : __rte_unused struct cmdline *cl,
4526 : : __rte_unused void *data)
4527 : : {
4528 : : struct cmd_set_rxhdrs_result *res;
4529 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4530 : : unsigned int nb_segs;
4531 : :
4532 : : res = parsed_result;
4533 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4534 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4535 : 0 : if (nb_segs > 0)
4536 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4537 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4538 : 0 : }
4539 : :
4540 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4541 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4542 : : set, "set");
4543 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4544 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4545 : : rxhdrs, "rxhdrs");
4546 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4547 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4548 : : values, NULL);
4549 : :
4550 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4551 : : .f = cmd_set_rxhdrs_parsed,
4552 : : .data = NULL,
4553 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4554 : : .tokens = {
4555 : : (void *)&cmd_set_rxhdrs_set,
4556 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4557 : : (void *)&cmd_set_rxhdrs_values,
4558 : : NULL,
4559 : : },
4560 : : };
4561 : :
4562 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4563 : :
4564 : : struct cmd_set_txpkts_result {
4565 : : cmdline_fixed_string_t cmd_keyword;
4566 : : cmdline_fixed_string_t txpkts;
4567 : : cmdline_fixed_string_t seg_lengths;
4568 : : };
4569 : :
4570 : : static void
4571 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4572 : : __rte_unused struct cmdline *cl,
4573 : : __rte_unused void *data)
4574 : : {
4575 : : struct cmd_set_txpkts_result *res;
4576 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4577 : : unsigned int nb_segs;
4578 : :
4579 : : res = parsed_result;
4580 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4581 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4582 : 0 : if (nb_segs > 0)
4583 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4584 : 0 : }
4585 : :
4586 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4587 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4588 : : cmd_keyword, "set");
4589 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4590 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4591 : : txpkts, "txpkts");
4592 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4593 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4594 : : seg_lengths, NULL);
4595 : :
4596 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4597 : : .f = cmd_set_txpkts_parsed,
4598 : : .data = NULL,
4599 : : .help_str = "set txpkts <len0[,len1]*>",
4600 : : .tokens = {
4601 : : (void *)&cmd_set_txpkts_keyword,
4602 : : (void *)&cmd_set_txpkts_name,
4603 : : (void *)&cmd_set_txpkts_lengths,
4604 : : NULL,
4605 : : },
4606 : : };
4607 : :
4608 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4609 : :
4610 : : struct cmd_set_txsplit_result {
4611 : : cmdline_fixed_string_t cmd_keyword;
4612 : : cmdline_fixed_string_t txsplit;
4613 : : cmdline_fixed_string_t mode;
4614 : : };
4615 : :
4616 : : static void
4617 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4618 : : __rte_unused struct cmdline *cl,
4619 : : __rte_unused void *data)
4620 : : {
4621 : : struct cmd_set_txsplit_result *res;
4622 : :
4623 : : res = parsed_result;
4624 : 0 : set_tx_pkt_split(res->mode);
4625 : 0 : }
4626 : :
4627 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4628 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4629 : : cmd_keyword, "set");
4630 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4631 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4632 : : txsplit, "txsplit");
4633 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4634 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4635 : : mode, NULL);
4636 : :
4637 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4638 : : .f = cmd_set_txsplit_parsed,
4639 : : .data = NULL,
4640 : : .help_str = "set txsplit on|off|rand",
4641 : : .tokens = {
4642 : : (void *)&cmd_set_txsplit_keyword,
4643 : : (void *)&cmd_set_txsplit_name,
4644 : : (void *)&cmd_set_txsplit_mode,
4645 : : NULL,
4646 : : },
4647 : : };
4648 : :
4649 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4650 : :
4651 : : struct cmd_set_txtimes_result {
4652 : : cmdline_fixed_string_t cmd_keyword;
4653 : : cmdline_fixed_string_t txtimes;
4654 : : cmdline_fixed_string_t tx_times;
4655 : : };
4656 : :
4657 : : static void
4658 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4659 : : __rte_unused struct cmdline *cl,
4660 : : __rte_unused void *data)
4661 : : {
4662 : : struct cmd_set_txtimes_result *res;
4663 : 0 : unsigned int tx_times[2] = {0, 0};
4664 : : unsigned int n_times;
4665 : :
4666 : : res = parsed_result;
4667 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4668 : : 2, tx_times, 0);
4669 : 0 : if (n_times == 2)
4670 : 0 : set_tx_pkt_times(tx_times);
4671 : 0 : }
4672 : :
4673 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4674 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4675 : : cmd_keyword, "set");
4676 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4677 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4678 : : txtimes, "txtimes");
4679 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4680 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4681 : : tx_times, NULL);
4682 : :
4683 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4684 : : .f = cmd_set_txtimes_parsed,
4685 : : .data = NULL,
4686 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4687 : : .tokens = {
4688 : : (void *)&cmd_set_txtimes_keyword,
4689 : : (void *)&cmd_set_txtimes_name,
4690 : : (void *)&cmd_set_txtimes_value,
4691 : : NULL,
4692 : : },
4693 : : };
4694 : :
4695 : : /* *** SET NUMBER OF FLOWS IN TXONLY MULTI-FLOW MODE *** */
4696 : :
4697 : : struct cmd_set_txflows_result {
4698 : : cmdline_fixed_string_t cmd_keyword;
4699 : : cmdline_fixed_string_t name;
4700 : : uint16_t value;
4701 : : };
4702 : :
4703 : : static void
4704 : 0 : cmd_set_txflows_parsed(void *parsed_result,
4705 : : __rte_unused struct cmdline *cl,
4706 : : __rte_unused void *data)
4707 : : {
4708 : : struct cmd_set_txflows_result *res = parsed_result;
4709 : :
4710 : 0 : if (res->value < 1 || res->value > 64) {
4711 : 0 : fprintf(stderr, "txonly-flows must be >= 1 and <= 64\n");
4712 : 0 : return;
4713 : : }
4714 : 0 : txonly_flows = res->value;
4715 : : }
4716 : :
4717 : : static cmdline_parse_token_string_t cmd_set_txflows_keyword =
4718 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txflows_result,
4719 : : cmd_keyword, "set");
4720 : : static cmdline_parse_token_string_t cmd_set_txflows_name =
4721 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txflows_result,
4722 : : name, "txonly-flows");
4723 : : static cmdline_parse_token_num_t cmd_set_txflows_value =
4724 : : TOKEN_NUM_INITIALIZER(struct cmd_set_txflows_result,
4725 : : value, RTE_UINT16);
4726 : :
4727 : : static cmdline_parse_inst_t cmd_set_txflows = {
4728 : : .f = cmd_set_txflows_parsed,
4729 : : .data = NULL,
4730 : : .help_str = "set txonly-flows <N>",
4731 : : .tokens = {
4732 : : (void *)&cmd_set_txflows_keyword,
4733 : : (void *)&cmd_set_txflows_name,
4734 : : (void *)&cmd_set_txflows_value,
4735 : : NULL,
4736 : : },
4737 : : };
4738 : :
4739 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4740 : : struct cmd_rx_vlan_filter_all_result {
4741 : : cmdline_fixed_string_t rx_vlan;
4742 : : cmdline_fixed_string_t what;
4743 : : cmdline_fixed_string_t all;
4744 : : portid_t port_id;
4745 : : };
4746 : :
4747 : : static void
4748 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4749 : : __rte_unused struct cmdline *cl,
4750 : : __rte_unused void *data)
4751 : : {
4752 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4753 : :
4754 : 0 : if (!strcmp(res->what, "add"))
4755 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4756 : : else
4757 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4758 : 0 : }
4759 : :
4760 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4761 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4762 : : rx_vlan, "rx_vlan");
4763 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4764 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4765 : : what, "add#rm");
4766 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4767 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4768 : : all, "all");
4769 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4770 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4771 : : port_id, RTE_UINT16);
4772 : :
4773 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4774 : : .f = cmd_rx_vlan_filter_all_parsed,
4775 : : .data = NULL,
4776 : : .help_str = "rx_vlan add|rm all <port_id>: "
4777 : : "Add/Remove all identifiers to/from the set of VLAN "
4778 : : "identifiers filtered by a port",
4779 : : .tokens = {
4780 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4781 : : (void *)&cmd_rx_vlan_filter_all_what,
4782 : : (void *)&cmd_rx_vlan_filter_all_all,
4783 : : (void *)&cmd_rx_vlan_filter_all_portid,
4784 : : NULL,
4785 : : },
4786 : : };
4787 : :
4788 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4789 : : struct cmd_vlan_offload_result {
4790 : : cmdline_fixed_string_t vlan;
4791 : : cmdline_fixed_string_t set;
4792 : : cmdline_fixed_string_t vlan_type;
4793 : : cmdline_fixed_string_t what;
4794 : : cmdline_fixed_string_t on;
4795 : : cmdline_fixed_string_t port_id;
4796 : : };
4797 : :
4798 : : static void
4799 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4800 : : __rte_unused struct cmdline *cl,
4801 : : __rte_unused void *data)
4802 : : {
4803 : : int on;
4804 : : struct cmd_vlan_offload_result *res = parsed_result;
4805 : : char *str;
4806 : : int i, len = 0;
4807 : : portid_t port_id = 0;
4808 : : unsigned int tmp;
4809 : :
4810 : 0 : str = res->port_id;
4811 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4812 : : i = 0;
4813 : : /* Get port_id first */
4814 : 0 : while(i < len){
4815 : 0 : if(str[i] == ',')
4816 : : break;
4817 : :
4818 : 0 : i++;
4819 : : }
4820 : 0 : str[i]='\0';
4821 : 0 : tmp = strtoul(str, NULL, 0);
4822 : : /* If port_id greater that what portid_t can represent, return */
4823 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4824 : : return;
4825 : 0 : port_id = (portid_t)tmp;
4826 : :
4827 : 0 : if (!strcmp(res->on, "on"))
4828 : : on = 1;
4829 : : else
4830 : : on = 0;
4831 : :
4832 : 0 : if (!strcmp(res->what, "strip"))
4833 : 0 : rx_vlan_strip_set(port_id, on);
4834 : 0 : else if(!strcmp(res->what, "stripq")){
4835 : : uint16_t queue_id = 0;
4836 : :
4837 : : /* No queue_id, return */
4838 : 0 : if(i + 1 >= len) {
4839 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4840 : 0 : return;
4841 : : }
4842 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4843 : : /* If queue_id greater that what 16-bits can represent, return */
4844 : 0 : if(tmp > 0xffff)
4845 : : return;
4846 : :
4847 : 0 : queue_id = (uint16_t)tmp;
4848 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4849 : : }
4850 : 0 : else if (!strcmp(res->what, "filter"))
4851 : 0 : rx_vlan_filter_set(port_id, on);
4852 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4853 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4854 : : else
4855 : 0 : vlan_extend_set(port_id, on);
4856 : :
4857 : : return;
4858 : : }
4859 : :
4860 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4861 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4862 : : vlan, "vlan");
4863 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4864 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4865 : : set, "set");
4866 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4867 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4868 : : what, "strip#filter#qinq_strip#extend#stripq");
4869 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4870 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4871 : : on, "on#off");
4872 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4873 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4874 : : port_id, NULL);
4875 : :
4876 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4877 : : .f = cmd_vlan_offload_parsed,
4878 : : .data = NULL,
4879 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4880 : : "<port_id[,queue_id]>: "
4881 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4882 : : .tokens = {
4883 : : (void *)&cmd_vlan_offload_vlan,
4884 : : (void *)&cmd_vlan_offload_set,
4885 : : (void *)&cmd_vlan_offload_what,
4886 : : (void *)&cmd_vlan_offload_on,
4887 : : (void *)&cmd_vlan_offload_portid,
4888 : : NULL,
4889 : : },
4890 : : };
4891 : :
4892 : : /* *** VLAN TPID SET ON A PORT *** */
4893 : : struct cmd_vlan_tpid_result {
4894 : : cmdline_fixed_string_t vlan;
4895 : : cmdline_fixed_string_t set;
4896 : : cmdline_fixed_string_t vlan_type;
4897 : : cmdline_fixed_string_t what;
4898 : : uint16_t tp_id;
4899 : : portid_t port_id;
4900 : : };
4901 : :
4902 : : static void
4903 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4904 : : __rte_unused struct cmdline *cl,
4905 : : __rte_unused void *data)
4906 : : {
4907 : : struct cmd_vlan_tpid_result *res = parsed_result;
4908 : : enum rte_vlan_type vlan_type;
4909 : :
4910 : 0 : if (!strcmp(res->vlan_type, "inner"))
4911 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4912 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4913 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4914 : : else {
4915 : 0 : fprintf(stderr, "Unknown vlan type\n");
4916 : 0 : return;
4917 : : }
4918 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4919 : : }
4920 : :
4921 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4922 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4923 : : vlan, "vlan");
4924 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4925 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4926 : : set, "set");
4927 : : static cmdline_parse_token_string_t cmd_vlan_type =
4928 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4929 : : vlan_type, "inner#outer");
4930 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4931 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4932 : : what, "tpid");
4933 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4934 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4935 : : tp_id, RTE_UINT16);
4936 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4937 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4938 : : port_id, RTE_UINT16);
4939 : :
4940 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4941 : : .f = cmd_vlan_tpid_parsed,
4942 : : .data = NULL,
4943 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4944 : : "Set the VLAN Ether type",
4945 : : .tokens = {
4946 : : (void *)&cmd_vlan_tpid_vlan,
4947 : : (void *)&cmd_vlan_tpid_set,
4948 : : (void *)&cmd_vlan_type,
4949 : : (void *)&cmd_vlan_tpid_what,
4950 : : (void *)&cmd_vlan_tpid_tpid,
4951 : : (void *)&cmd_vlan_tpid_portid,
4952 : : NULL,
4953 : : },
4954 : : };
4955 : :
4956 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4957 : : struct cmd_rx_vlan_filter_result {
4958 : : cmdline_fixed_string_t rx_vlan;
4959 : : cmdline_fixed_string_t what;
4960 : : uint16_t vlan_id;
4961 : : portid_t port_id;
4962 : : };
4963 : :
4964 : : static void
4965 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4966 : : __rte_unused struct cmdline *cl,
4967 : : __rte_unused void *data)
4968 : : {
4969 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4970 : :
4971 : 0 : if (!strcmp(res->what, "add"))
4972 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4973 : : else
4974 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4975 : 0 : }
4976 : :
4977 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4978 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4979 : : rx_vlan, "rx_vlan");
4980 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4981 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4982 : : what, "add#rm");
4983 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4984 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4985 : : vlan_id, RTE_UINT16);
4986 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4987 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4988 : : port_id, RTE_UINT16);
4989 : :
4990 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4991 : : .f = cmd_rx_vlan_filter_parsed,
4992 : : .data = NULL,
4993 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4994 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4995 : : "identifiers filtered by a port",
4996 : : .tokens = {
4997 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4998 : : (void *)&cmd_rx_vlan_filter_what,
4999 : : (void *)&cmd_rx_vlan_filter_vlanid,
5000 : : (void *)&cmd_rx_vlan_filter_portid,
5001 : : NULL,
5002 : : },
5003 : : };
5004 : :
5005 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
5006 : : struct cmd_tx_vlan_set_result {
5007 : : cmdline_fixed_string_t tx_vlan;
5008 : : cmdline_fixed_string_t set;
5009 : : portid_t port_id;
5010 : : uint16_t vlan_tci;
5011 : : };
5012 : :
5013 : : static void
5014 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
5015 : : __rte_unused struct cmdline *cl,
5016 : : __rte_unused void *data)
5017 : : {
5018 : : struct cmd_tx_vlan_set_result *res = parsed_result;
5019 : :
5020 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5021 : : return;
5022 : :
5023 : 0 : if (!port_is_stopped(res->port_id)) {
5024 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5025 : 0 : return;
5026 : : }
5027 : :
5028 : 0 : tx_vlan_set(res->port_id, res->vlan_tci);
5029 : :
5030 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5031 : : }
5032 : :
5033 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
5034 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
5035 : : tx_vlan, "tx_vlan");
5036 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
5037 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
5038 : : set, "set");
5039 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
5040 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
5041 : : port_id, RTE_UINT16);
5042 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlantci =
5043 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
5044 : : vlan_tci, RTE_UINT16);
5045 : :
5046 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
5047 : : .f = cmd_tx_vlan_set_parsed,
5048 : : .data = NULL,
5049 : : .help_str = "tx_vlan set <port_id> <vlan_tci>: "
5050 : : "Enable hardware insertion of a single VLAN header "
5051 : : "with a given TCI in packets sent on a port",
5052 : : .tokens = {
5053 : : (void *)&cmd_tx_vlan_set_tx_vlan,
5054 : : (void *)&cmd_tx_vlan_set_set,
5055 : : (void *)&cmd_tx_vlan_set_portid,
5056 : : (void *)&cmd_tx_vlan_set_vlantci,
5057 : : NULL,
5058 : : },
5059 : : };
5060 : :
5061 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
5062 : : struct cmd_tx_vlan_set_qinq_result {
5063 : : cmdline_fixed_string_t tx_vlan;
5064 : : cmdline_fixed_string_t set;
5065 : : portid_t port_id;
5066 : : uint16_t vlan_tci;
5067 : : uint16_t vlan_tci_outer;
5068 : : };
5069 : :
5070 : : static void
5071 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
5072 : : __rte_unused struct cmdline *cl,
5073 : : __rte_unused void *data)
5074 : : {
5075 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
5076 : :
5077 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5078 : : return;
5079 : :
5080 : 0 : if (!port_is_stopped(res->port_id)) {
5081 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5082 : 0 : return;
5083 : : }
5084 : :
5085 : 0 : tx_qinq_set(res->port_id, res->vlan_tci, res->vlan_tci_outer);
5086 : :
5087 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5088 : : }
5089 : :
5090 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
5091 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5092 : : tx_vlan, "tx_vlan");
5093 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
5094 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5095 : : set, "set");
5096 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
5097 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5098 : : port_id, RTE_UINT16);
5099 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlantci =
5100 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5101 : : vlan_tci, RTE_UINT16);
5102 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlantci_outer =
5103 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5104 : : vlan_tci_outer, RTE_UINT16);
5105 : :
5106 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
5107 : : .f = cmd_tx_vlan_set_qinq_parsed,
5108 : : .data = NULL,
5109 : : .help_str = "tx_vlan set <port_id> <vlan_tci> <vlan_tci_outer>: "
5110 : : "Enable hardware insertion of double VLAN header "
5111 : : "with given TCIs in packets sent on a port",
5112 : : .tokens = {
5113 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
5114 : : (void *)&cmd_tx_vlan_set_qinq_set,
5115 : : (void *)&cmd_tx_vlan_set_qinq_portid,
5116 : : (void *)&cmd_tx_vlan_set_qinq_vlantci,
5117 : : (void *)&cmd_tx_vlan_set_qinq_vlantci_outer,
5118 : : NULL,
5119 : : },
5120 : : };
5121 : :
5122 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
5123 : : struct cmd_tx_vlan_set_pvid_result {
5124 : : cmdline_fixed_string_t tx_vlan;
5125 : : cmdline_fixed_string_t set;
5126 : : cmdline_fixed_string_t pvid;
5127 : : portid_t port_id;
5128 : : uint16_t vlan_id;
5129 : : cmdline_fixed_string_t mode;
5130 : : };
5131 : :
5132 : : static void
5133 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
5134 : : __rte_unused struct cmdline *cl,
5135 : : __rte_unused void *data)
5136 : : {
5137 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
5138 : :
5139 : 0 : if (strcmp(res->mode, "on") == 0)
5140 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
5141 : : else
5142 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
5143 : 0 : }
5144 : :
5145 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
5146 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5147 : : tx_vlan, "tx_vlan");
5148 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
5149 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5150 : : set, "set");
5151 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
5152 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5153 : : pvid, "pvid");
5154 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
5155 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5156 : : port_id, RTE_UINT16);
5157 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
5158 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5159 : : vlan_id, RTE_UINT16);
5160 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
5161 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5162 : : mode, "on#off");
5163 : :
5164 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
5165 : : .f = cmd_tx_vlan_set_pvid_parsed,
5166 : : .data = NULL,
5167 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
5168 : : .tokens = {
5169 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
5170 : : (void *)&cmd_tx_vlan_set_pvid_set,
5171 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
5172 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
5173 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
5174 : : (void *)&cmd_tx_vlan_set_pvid_mode,
5175 : : NULL,
5176 : : },
5177 : : };
5178 : :
5179 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
5180 : : struct cmd_tx_vlan_reset_result {
5181 : : cmdline_fixed_string_t tx_vlan;
5182 : : cmdline_fixed_string_t reset;
5183 : : portid_t port_id;
5184 : : };
5185 : :
5186 : : static void
5187 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
5188 : : __rte_unused struct cmdline *cl,
5189 : : __rte_unused void *data)
5190 : : {
5191 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
5192 : :
5193 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5194 : : return;
5195 : :
5196 : 0 : if (!port_is_stopped(res->port_id)) {
5197 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5198 : 0 : return;
5199 : : }
5200 : :
5201 : 0 : tx_vlan_reset(res->port_id);
5202 : :
5203 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5204 : : }
5205 : :
5206 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
5207 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5208 : : tx_vlan, "tx_vlan");
5209 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
5210 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5211 : : reset, "reset");
5212 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
5213 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
5214 : : port_id, RTE_UINT16);
5215 : :
5216 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
5217 : : .f = cmd_tx_vlan_reset_parsed,
5218 : : .data = NULL,
5219 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
5220 : : "VLAN header in packets sent on a port",
5221 : : .tokens = {
5222 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
5223 : : (void *)&cmd_tx_vlan_reset_reset,
5224 : : (void *)&cmd_tx_vlan_reset_portid,
5225 : : NULL,
5226 : : },
5227 : : };
5228 : :
5229 : :
5230 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
5231 : : struct cmd_csum_result {
5232 : : cmdline_fixed_string_t csum;
5233 : : cmdline_fixed_string_t mode;
5234 : : cmdline_fixed_string_t proto;
5235 : : cmdline_fixed_string_t hwsw;
5236 : : portid_t port_id;
5237 : : };
5238 : :
5239 : : static void
5240 : 0 : csum_show(int port_id)
5241 : : {
5242 : : struct rte_eth_dev_info dev_info;
5243 : : uint64_t tx_offloads;
5244 : : int ret;
5245 : :
5246 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
5247 : 0 : printf("Parse tunnel is %s\n",
5248 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
5249 : 0 : printf("IP checksum offload is %s\n",
5250 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
5251 : 0 : printf("UDP checksum offload is %s\n",
5252 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
5253 : 0 : printf("TCP checksum offload is %s\n",
5254 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
5255 : 0 : printf("SCTP checksum offload is %s\n",
5256 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
5257 : 0 : printf("Outer-Ip checksum offload is %s\n",
5258 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
5259 : 0 : printf("Outer-Udp checksum offload is %s\n",
5260 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
5261 : :
5262 : : /* display warnings if configuration is not supported by the NIC */
5263 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
5264 : 0 : if (ret != 0)
5265 : 0 : return;
5266 : :
5267 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
5268 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
5269 : 0 : fprintf(stderr,
5270 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
5271 : : port_id);
5272 : : }
5273 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
5274 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
5275 : 0 : fprintf(stderr,
5276 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
5277 : : port_id);
5278 : : }
5279 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
5280 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
5281 : 0 : fprintf(stderr,
5282 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
5283 : : port_id);
5284 : : }
5285 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
5286 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
5287 : 0 : fprintf(stderr,
5288 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
5289 : : port_id);
5290 : : }
5291 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
5292 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
5293 : 0 : fprintf(stderr,
5294 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
5295 : : port_id);
5296 : : }
5297 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
5298 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
5299 : : == 0) {
5300 : 0 : fprintf(stderr,
5301 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
5302 : : port_id);
5303 : : }
5304 : : }
5305 : :
5306 : : static void
5307 : : cmd_config_queue_tx_offloads(struct rte_port *port)
5308 : : {
5309 : : int k;
5310 : :
5311 : : /* Apply queue tx offloads configuration */
5312 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
5313 : 0 : port->txq[k].conf.offloads =
5314 : 0 : port->dev_conf.txmode.offloads;
5315 : : }
5316 : :
5317 : : static void
5318 : 0 : cmd_csum_parsed(void *parsed_result,
5319 : : __rte_unused struct cmdline *cl,
5320 : : __rte_unused void *data)
5321 : : {
5322 : : struct cmd_csum_result *res = parsed_result;
5323 : : int hw = 0;
5324 : : uint64_t csum_offloads = 0;
5325 : : struct rte_eth_dev_info dev_info;
5326 : : int ret;
5327 : :
5328 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
5329 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
5330 : 0 : return;
5331 : : }
5332 : 0 : if (!port_is_stopped(res->port_id)) {
5333 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5334 : 0 : return;
5335 : : }
5336 : :
5337 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5338 : 0 : if (ret != 0)
5339 : : return;
5340 : :
5341 : 0 : if (!strcmp(res->mode, "set")) {
5342 : :
5343 : 0 : if (!strcmp(res->hwsw, "hw"))
5344 : : hw = 1;
5345 : :
5346 : 0 : if (!strcmp(res->proto, "ip")) {
5347 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5348 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
5349 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
5350 : : } else {
5351 : 0 : fprintf(stderr,
5352 : : "IP checksum offload is not supported by port %u\n",
5353 : 0 : res->port_id);
5354 : : }
5355 : 0 : } else if (!strcmp(res->proto, "udp")) {
5356 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5357 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
5358 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
5359 : : } else {
5360 : 0 : fprintf(stderr,
5361 : : "UDP checksum offload is not supported by port %u\n",
5362 : 0 : res->port_id);
5363 : : }
5364 : 0 : } else if (!strcmp(res->proto, "tcp")) {
5365 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5366 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
5367 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
5368 : : } else {
5369 : 0 : fprintf(stderr,
5370 : : "TCP checksum offload is not supported by port %u\n",
5371 : 0 : res->port_id);
5372 : : }
5373 : 0 : } else if (!strcmp(res->proto, "sctp")) {
5374 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5375 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
5376 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
5377 : : } else {
5378 : 0 : fprintf(stderr,
5379 : : "SCTP checksum offload is not supported by port %u\n",
5380 : 0 : res->port_id);
5381 : : }
5382 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
5383 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5384 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5385 : : csum_offloads |=
5386 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
5387 : : } else {
5388 : 0 : fprintf(stderr,
5389 : : "Outer IP checksum offload is not supported by port %u\n",
5390 : 0 : res->port_id);
5391 : : }
5392 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
5393 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5394 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
5395 : : csum_offloads |=
5396 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
5397 : : } else {
5398 : 0 : fprintf(stderr,
5399 : : "Outer UDP checksum offload is not supported by port %u\n",
5400 : 0 : res->port_id);
5401 : : }
5402 : : }
5403 : :
5404 : 0 : if (hw) {
5405 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5406 : : csum_offloads;
5407 : : } else {
5408 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5409 : 0 : (~csum_offloads);
5410 : : }
5411 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5412 : : }
5413 : 0 : csum_show(res->port_id);
5414 : :
5415 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5416 : : }
5417 : :
5418 : : static cmdline_parse_token_string_t cmd_csum_csum =
5419 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5420 : : csum, "csum");
5421 : : static cmdline_parse_token_string_t cmd_csum_mode =
5422 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5423 : : mode, "set");
5424 : : static cmdline_parse_token_string_t cmd_csum_proto =
5425 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5426 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
5427 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
5428 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5429 : : hwsw, "hw#sw");
5430 : : static cmdline_parse_token_num_t cmd_csum_portid =
5431 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
5432 : : port_id, RTE_UINT16);
5433 : :
5434 : : static cmdline_parse_inst_t cmd_csum_set = {
5435 : : .f = cmd_csum_parsed,
5436 : : .data = NULL,
5437 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
5438 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
5439 : : "using csum forward engine",
5440 : : .tokens = {
5441 : : (void *)&cmd_csum_csum,
5442 : : (void *)&cmd_csum_mode,
5443 : : (void *)&cmd_csum_proto,
5444 : : (void *)&cmd_csum_hwsw,
5445 : : (void *)&cmd_csum_portid,
5446 : : NULL,
5447 : : },
5448 : : };
5449 : :
5450 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
5451 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5452 : : mode, "show");
5453 : :
5454 : : static cmdline_parse_inst_t cmd_csum_show = {
5455 : : .f = cmd_csum_parsed,
5456 : : .data = NULL,
5457 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
5458 : : .tokens = {
5459 : : (void *)&cmd_csum_csum,
5460 : : (void *)&cmd_csum_mode_show,
5461 : : (void *)&cmd_csum_portid,
5462 : : NULL,
5463 : : },
5464 : : };
5465 : :
5466 : : /* Enable/disable tunnel parsing */
5467 : : struct cmd_csum_tunnel_result {
5468 : : cmdline_fixed_string_t csum;
5469 : : cmdline_fixed_string_t parse;
5470 : : cmdline_fixed_string_t onoff;
5471 : : portid_t port_id;
5472 : : };
5473 : :
5474 : : static void
5475 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
5476 : : __rte_unused struct cmdline *cl,
5477 : : __rte_unused void *data)
5478 : : {
5479 : : struct cmd_csum_tunnel_result *res = parsed_result;
5480 : :
5481 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5482 : : return;
5483 : :
5484 : 0 : if (!strcmp(res->onoff, "on"))
5485 : 0 : ports[res->port_id].parse_tunnel = 1;
5486 : : else
5487 : 0 : ports[res->port_id].parse_tunnel = 0;
5488 : :
5489 : 0 : csum_show(res->port_id);
5490 : : }
5491 : :
5492 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
5493 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5494 : : csum, "csum");
5495 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
5496 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5497 : : parse, "parse-tunnel");
5498 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
5499 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5500 : : onoff, "on#off");
5501 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
5502 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
5503 : : port_id, RTE_UINT16);
5504 : :
5505 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
5506 : : .f = cmd_csum_tunnel_parsed,
5507 : : .data = NULL,
5508 : : .help_str = "csum parse-tunnel on|off <port_id>: "
5509 : : "Enable/Disable parsing of tunnels for csum engine",
5510 : : .tokens = {
5511 : : (void *)&cmd_csum_tunnel_csum,
5512 : : (void *)&cmd_csum_tunnel_parse,
5513 : : (void *)&cmd_csum_tunnel_onoff,
5514 : : (void *)&cmd_csum_tunnel_portid,
5515 : : NULL,
5516 : : },
5517 : : };
5518 : :
5519 : : struct cmd_csum_mac_swap_result {
5520 : : cmdline_fixed_string_t csum;
5521 : : cmdline_fixed_string_t parse;
5522 : : cmdline_fixed_string_t onoff;
5523 : : portid_t port_id;
5524 : : };
5525 : :
5526 : : static void
5527 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
5528 : : __rte_unused struct cmdline *cl,
5529 : : __rte_unused void *data)
5530 : : {
5531 : : struct cmd_csum_mac_swap_result *res = parsed_result;
5532 : :
5533 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5534 : : return;
5535 : 0 : if (strcmp(res->onoff, "on") == 0)
5536 : 0 : ports[res->port_id].fwd_mac_swap = 1;
5537 : : else
5538 : 0 : ports[res->port_id].fwd_mac_swap = 0;
5539 : : }
5540 : :
5541 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
5542 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5543 : : csum, "csum");
5544 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
5545 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5546 : : parse, "mac-swap");
5547 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
5548 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5549 : : onoff, "on#off");
5550 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
5551 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
5552 : : port_id, RTE_UINT16);
5553 : :
5554 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
5555 : : .f = cmd_csum_mac_swap_parsed,
5556 : : .data = NULL,
5557 : : .help_str = "csum mac-swap on|off <port_id>: "
5558 : : "Enable/Disable forward mac address swap",
5559 : : .tokens = {
5560 : : (void *)&cmd_csum_mac_swap_csum,
5561 : : (void *)&cmd_csum_mac_swap_parse,
5562 : : (void *)&cmd_csum_mac_swap_onoff,
5563 : : (void *)&cmd_csum_mac_swap_portid,
5564 : : NULL,
5565 : : },
5566 : : };
5567 : :
5568 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5569 : : struct cmd_tso_set_result {
5570 : : cmdline_fixed_string_t tso;
5571 : : cmdline_fixed_string_t mode;
5572 : : uint16_t tso_segsz;
5573 : : portid_t port_id;
5574 : : };
5575 : :
5576 : : static void
5577 : 0 : cmd_tso_set_parsed(void *parsed_result,
5578 : : __rte_unused struct cmdline *cl,
5579 : : __rte_unused void *data)
5580 : : {
5581 : : struct cmd_tso_set_result *res = parsed_result;
5582 : : struct rte_eth_dev_info dev_info;
5583 : : uint64_t offloads;
5584 : : int ret;
5585 : :
5586 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5587 : 0 : return;
5588 : 0 : if (!port_is_stopped(res->port_id)) {
5589 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5590 : 0 : return;
5591 : : }
5592 : :
5593 : 0 : if (!strcmp(res->mode, "set"))
5594 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5595 : :
5596 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5597 : 0 : if (ret != 0)
5598 : : return;
5599 : :
5600 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5601 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5602 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5603 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5604 : : res->port_id);
5605 : 0 : return;
5606 : : }
5607 : : /* display warnings if configuration is not supported by the NIC */
5608 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5609 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5610 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5611 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5612 : : }
5613 : :
5614 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5615 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5616 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5617 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5618 : : } else {
5619 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5620 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5621 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5622 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5623 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5624 : 0 : printf("segment size for non-tunneled packets is %d\n",
5625 : : ports[res->port_id].tso_segsz);
5626 : : }
5627 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5628 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5629 : : }
5630 : :
5631 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5632 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5633 : : tso, "tso");
5634 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5635 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5636 : : mode, "set");
5637 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5638 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5639 : : tso_segsz, RTE_UINT16);
5640 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5641 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5642 : : port_id, RTE_UINT16);
5643 : :
5644 : : static cmdline_parse_inst_t cmd_tso_set = {
5645 : : .f = cmd_tso_set_parsed,
5646 : : .data = NULL,
5647 : : .help_str = "tso set <tso_segsz> <port_id>: "
5648 : : "Set TSO segment size of non-tunneled packets for csum engine "
5649 : : "(0 to disable)",
5650 : : .tokens = {
5651 : : (void *)&cmd_tso_set_tso,
5652 : : (void *)&cmd_tso_set_mode,
5653 : : (void *)&cmd_tso_set_tso_segsz,
5654 : : (void *)&cmd_tso_set_portid,
5655 : : NULL,
5656 : : },
5657 : : };
5658 : :
5659 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5660 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5661 : : mode, "show");
5662 : :
5663 : :
5664 : : static cmdline_parse_inst_t cmd_tso_show = {
5665 : : .f = cmd_tso_set_parsed,
5666 : : .data = NULL,
5667 : : .help_str = "tso show <port_id>: "
5668 : : "Show TSO segment size of non-tunneled packets for csum engine",
5669 : : .tokens = {
5670 : : (void *)&cmd_tso_set_tso,
5671 : : (void *)&cmd_tso_show_mode,
5672 : : (void *)&cmd_tso_set_portid,
5673 : : NULL,
5674 : : },
5675 : : };
5676 : :
5677 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5678 : : struct cmd_tunnel_tso_set_result {
5679 : : cmdline_fixed_string_t tso;
5680 : : cmdline_fixed_string_t mode;
5681 : : uint16_t tso_segsz;
5682 : : portid_t port_id;
5683 : : };
5684 : :
5685 : : static void
5686 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5687 : : {
5688 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5689 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5690 : : port_id);
5691 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5692 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5693 : : port_id);
5694 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5695 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5696 : : port_id);
5697 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5698 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5699 : : port_id);
5700 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5701 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5702 : : port_id);
5703 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5704 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5705 : : port_id);
5706 : 0 : }
5707 : :
5708 : : static void
5709 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5710 : : __rte_unused struct cmdline *cl,
5711 : : __rte_unused void *data)
5712 : : {
5713 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5714 : : struct rte_eth_dev_info dev_info;
5715 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5716 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5717 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5718 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5719 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5720 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5721 : : int ret;
5722 : :
5723 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5724 : 0 : return;
5725 : 0 : if (!port_is_stopped(res->port_id)) {
5726 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5727 : 0 : return;
5728 : : }
5729 : :
5730 : 0 : if (!strcmp(res->mode, "set"))
5731 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5732 : :
5733 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5734 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5735 : : printf("TSO for tunneled packets is disabled\n");
5736 : : } else {
5737 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5738 : 0 : if (ret != 0)
5739 : : return;
5740 : :
5741 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5742 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5743 : 0 : res->port_id);
5744 : 0 : return;
5745 : : }
5746 : :
5747 : : /* Below conditions are needed to make it work:
5748 : : * (1) tunnel TSO is supported by the NIC;
5749 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5750 : : * are recognized;
5751 : : * (3) for tunneled pkts with outer L3 of IPv4,
5752 : : * "csum set outer-ip" must be set to hw, because after tso,
5753 : : * total_len of outer IP header is changed, and the checksum
5754 : : * of outer IP header calculated by sw should be wrong; that
5755 : : * is not necessary for IPv6 tunneled pkts because there's no
5756 : : * checksum in IP header anymore.
5757 : : */
5758 : 0 : if (!ports[res->port_id].parse_tunnel) {
5759 : 0 : fprintf(stderr,
5760 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5761 : 0 : return;
5762 : : }
5763 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5764 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5765 : 0 : fprintf(stderr,
5766 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5767 : 0 : return;
5768 : : }
5769 : :
5770 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5771 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5772 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5773 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5774 : 0 : ports[res->port_id].tunnel_tso_segsz);
5775 : : }
5776 : :
5777 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5778 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5779 : : }
5780 : :
5781 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5782 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5783 : : tso, "tunnel_tso");
5784 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5785 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5786 : : mode, "set");
5787 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5788 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5789 : : tso_segsz, RTE_UINT16);
5790 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5791 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5792 : : port_id, RTE_UINT16);
5793 : :
5794 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5795 : : .f = cmd_tunnel_tso_set_parsed,
5796 : : .data = NULL,
5797 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5798 : : "Set TSO segment size of tunneled packets for csum engine "
5799 : : "(0 to disable)",
5800 : : .tokens = {
5801 : : (void *)&cmd_tunnel_tso_set_tso,
5802 : : (void *)&cmd_tunnel_tso_set_mode,
5803 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5804 : : (void *)&cmd_tunnel_tso_set_portid,
5805 : : NULL,
5806 : : },
5807 : : };
5808 : :
5809 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5810 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5811 : : mode, "show");
5812 : :
5813 : :
5814 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5815 : : .f = cmd_tunnel_tso_set_parsed,
5816 : : .data = NULL,
5817 : : .help_str = "tunnel_tso show <port_id> "
5818 : : "Show TSO segment size of tunneled packets for csum engine",
5819 : : .tokens = {
5820 : : (void *)&cmd_tunnel_tso_set_tso,
5821 : : (void *)&cmd_tunnel_tso_show_mode,
5822 : : (void *)&cmd_tunnel_tso_set_portid,
5823 : : NULL,
5824 : : },
5825 : : };
5826 : :
5827 : : #ifdef RTE_LIB_GRO
5828 : : /* *** SET GRO FOR A PORT *** */
5829 : : struct cmd_gro_enable_result {
5830 : : cmdline_fixed_string_t cmd_set;
5831 : : cmdline_fixed_string_t cmd_port;
5832 : : cmdline_fixed_string_t cmd_keyword;
5833 : : cmdline_fixed_string_t cmd_onoff;
5834 : : portid_t cmd_pid;
5835 : : };
5836 : :
5837 : : static void
5838 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5839 : : __rte_unused struct cmdline *cl,
5840 : : __rte_unused void *data)
5841 : : {
5842 : : struct cmd_gro_enable_result *res;
5843 : :
5844 : : res = parsed_result;
5845 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5846 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5847 : 0 : }
5848 : :
5849 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5850 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5851 : : cmd_set, "set");
5852 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5853 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5854 : : cmd_keyword, "port");
5855 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5856 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5857 : : cmd_pid, RTE_UINT16);
5858 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5859 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5860 : : cmd_keyword, "gro");
5861 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5862 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5863 : : cmd_onoff, "on#off");
5864 : :
5865 : : static cmdline_parse_inst_t cmd_gro_enable = {
5866 : : .f = cmd_gro_enable_parsed,
5867 : : .data = NULL,
5868 : : .help_str = "set port <port_id> gro on|off",
5869 : : .tokens = {
5870 : : (void *)&cmd_gro_enable_set,
5871 : : (void *)&cmd_gro_enable_port,
5872 : : (void *)&cmd_gro_enable_pid,
5873 : : (void *)&cmd_gro_enable_keyword,
5874 : : (void *)&cmd_gro_enable_onoff,
5875 : : NULL,
5876 : : },
5877 : : };
5878 : :
5879 : : /* *** DISPLAY GRO CONFIGURATION *** */
5880 : : struct cmd_gro_show_result {
5881 : : cmdline_fixed_string_t cmd_show;
5882 : : cmdline_fixed_string_t cmd_port;
5883 : : cmdline_fixed_string_t cmd_keyword;
5884 : : portid_t cmd_pid;
5885 : : };
5886 : :
5887 : : static void
5888 : 0 : cmd_gro_show_parsed(void *parsed_result,
5889 : : __rte_unused struct cmdline *cl,
5890 : : __rte_unused void *data)
5891 : : {
5892 : : struct cmd_gro_show_result *res;
5893 : :
5894 : : res = parsed_result;
5895 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5896 : 0 : show_gro(res->cmd_pid);
5897 : 0 : }
5898 : :
5899 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5900 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5901 : : cmd_show, "show");
5902 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5903 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5904 : : cmd_port, "port");
5905 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5906 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5907 : : cmd_pid, RTE_UINT16);
5908 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5909 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5910 : : cmd_keyword, "gro");
5911 : :
5912 : : static cmdline_parse_inst_t cmd_gro_show = {
5913 : : .f = cmd_gro_show_parsed,
5914 : : .data = NULL,
5915 : : .help_str = "show port <port_id> gro",
5916 : : .tokens = {
5917 : : (void *)&cmd_gro_show_show,
5918 : : (void *)&cmd_gro_show_port,
5919 : : (void *)&cmd_gro_show_pid,
5920 : : (void *)&cmd_gro_show_keyword,
5921 : : NULL,
5922 : : },
5923 : : };
5924 : :
5925 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5926 : : struct cmd_gro_flush_result {
5927 : : cmdline_fixed_string_t cmd_set;
5928 : : cmdline_fixed_string_t cmd_keyword;
5929 : : cmdline_fixed_string_t cmd_flush;
5930 : : uint8_t cmd_cycles;
5931 : : };
5932 : :
5933 : : static void
5934 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5935 : : __rte_unused struct cmdline *cl,
5936 : : __rte_unused void *data)
5937 : : {
5938 : : struct cmd_gro_flush_result *res;
5939 : :
5940 : : res = parsed_result;
5941 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5942 : 0 : (!strcmp(res->cmd_flush, "flush")))
5943 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5944 : 0 : }
5945 : :
5946 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5947 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5948 : : cmd_set, "set");
5949 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5950 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5951 : : cmd_keyword, "gro");
5952 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5953 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5954 : : cmd_flush, "flush");
5955 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5956 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5957 : : cmd_cycles, RTE_UINT8);
5958 : :
5959 : : static cmdline_parse_inst_t cmd_gro_flush = {
5960 : : .f = cmd_gro_flush_parsed,
5961 : : .data = NULL,
5962 : : .help_str = "set gro flush <cycles>",
5963 : : .tokens = {
5964 : : (void *)&cmd_gro_flush_set,
5965 : : (void *)&cmd_gro_flush_keyword,
5966 : : (void *)&cmd_gro_flush_flush,
5967 : : (void *)&cmd_gro_flush_cycles,
5968 : : NULL,
5969 : : },
5970 : : };
5971 : : #endif /* RTE_LIB_GRO */
5972 : :
5973 : : #ifdef RTE_LIB_GSO
5974 : : /* *** ENABLE/DISABLE GSO *** */
5975 : : struct cmd_gso_enable_result {
5976 : : cmdline_fixed_string_t cmd_set;
5977 : : cmdline_fixed_string_t cmd_port;
5978 : : cmdline_fixed_string_t cmd_keyword;
5979 : : cmdline_fixed_string_t cmd_mode;
5980 : : portid_t cmd_pid;
5981 : : };
5982 : :
5983 : : static void
5984 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5985 : : __rte_unused struct cmdline *cl,
5986 : : __rte_unused void *data)
5987 : : {
5988 : : struct cmd_gso_enable_result *res;
5989 : :
5990 : : res = parsed_result;
5991 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5992 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5993 : 0 : }
5994 : :
5995 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5996 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5997 : : cmd_set, "set");
5998 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5999 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
6000 : : cmd_port, "port");
6001 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
6002 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
6003 : : cmd_keyword, "gso");
6004 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
6005 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
6006 : : cmd_mode, "on#off");
6007 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
6008 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
6009 : : cmd_pid, RTE_UINT16);
6010 : :
6011 : : static cmdline_parse_inst_t cmd_gso_enable = {
6012 : : .f = cmd_gso_enable_parsed,
6013 : : .data = NULL,
6014 : : .help_str = "set port <port_id> gso on|off",
6015 : : .tokens = {
6016 : : (void *)&cmd_gso_enable_set,
6017 : : (void *)&cmd_gso_enable_port,
6018 : : (void *)&cmd_gso_enable_pid,
6019 : : (void *)&cmd_gso_enable_keyword,
6020 : : (void *)&cmd_gso_enable_mode,
6021 : : NULL,
6022 : : },
6023 : : };
6024 : :
6025 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
6026 : : struct cmd_gso_size_result {
6027 : : cmdline_fixed_string_t cmd_set;
6028 : : cmdline_fixed_string_t cmd_keyword;
6029 : : cmdline_fixed_string_t cmd_segsz;
6030 : : uint16_t cmd_size;
6031 : : };
6032 : :
6033 : : static void
6034 : 0 : cmd_gso_size_parsed(void *parsed_result,
6035 : : __rte_unused struct cmdline *cl,
6036 : : __rte_unused void *data)
6037 : : {
6038 : : struct cmd_gso_size_result *res = parsed_result;
6039 : :
6040 : 0 : if (test_done == 0) {
6041 : 0 : fprintf(stderr,
6042 : : "Before setting GSO segsz, please first stop forwarding\n");
6043 : 0 : return;
6044 : : }
6045 : :
6046 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
6047 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
6048 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
6049 : 0 : fprintf(stderr,
6050 : : "gso_size should be larger than %zu. Please input a legal value\n",
6051 : : RTE_GSO_SEG_SIZE_MIN);
6052 : : else
6053 : 0 : gso_max_segment_size = res->cmd_size;
6054 : : }
6055 : : }
6056 : :
6057 : : static cmdline_parse_token_string_t cmd_gso_size_set =
6058 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
6059 : : cmd_set, "set");
6060 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
6061 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
6062 : : cmd_keyword, "gso");
6063 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
6064 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
6065 : : cmd_segsz, "segsz");
6066 : : static cmdline_parse_token_num_t cmd_gso_size_size =
6067 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
6068 : : cmd_size, RTE_UINT16);
6069 : :
6070 : : static cmdline_parse_inst_t cmd_gso_size = {
6071 : : .f = cmd_gso_size_parsed,
6072 : : .data = NULL,
6073 : : .help_str = "set gso segsz <length>",
6074 : : .tokens = {
6075 : : (void *)&cmd_gso_size_set,
6076 : : (void *)&cmd_gso_size_keyword,
6077 : : (void *)&cmd_gso_size_segsz,
6078 : : (void *)&cmd_gso_size_size,
6079 : : NULL,
6080 : : },
6081 : : };
6082 : :
6083 : : /* *** SHOW GSO CONFIGURATION *** */
6084 : : struct cmd_gso_show_result {
6085 : : cmdline_fixed_string_t cmd_show;
6086 : : cmdline_fixed_string_t cmd_port;
6087 : : cmdline_fixed_string_t cmd_keyword;
6088 : : portid_t cmd_pid;
6089 : : };
6090 : :
6091 : : static void
6092 : 0 : cmd_gso_show_parsed(void *parsed_result,
6093 : : __rte_unused struct cmdline *cl,
6094 : : __rte_unused void *data)
6095 : : {
6096 : : struct cmd_gso_show_result *res = parsed_result;
6097 : :
6098 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
6099 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
6100 : 0 : return;
6101 : : }
6102 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
6103 : 0 : if (gso_ports[res->cmd_pid].enable) {
6104 : 0 : printf("Max GSO'd packet size: %uB\n"
6105 : : "Supported GSO types: TCP/IPv4, "
6106 : : "UDP/IPv4, VxLAN with inner "
6107 : : "TCP/IPv4 packet, GRE with inner "
6108 : : "TCP/IPv4 packet\n",
6109 : : gso_max_segment_size);
6110 : : } else
6111 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
6112 : : }
6113 : : }
6114 : :
6115 : : static cmdline_parse_token_string_t cmd_gso_show_show =
6116 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6117 : : cmd_show, "show");
6118 : : static cmdline_parse_token_string_t cmd_gso_show_port =
6119 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6120 : : cmd_port, "port");
6121 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
6122 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6123 : : cmd_keyword, "gso");
6124 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
6125 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
6126 : : cmd_pid, RTE_UINT16);
6127 : :
6128 : : static cmdline_parse_inst_t cmd_gso_show = {
6129 : : .f = cmd_gso_show_parsed,
6130 : : .data = NULL,
6131 : : .help_str = "show port <port_id> gso",
6132 : : .tokens = {
6133 : : (void *)&cmd_gso_show_show,
6134 : : (void *)&cmd_gso_show_port,
6135 : : (void *)&cmd_gso_show_pid,
6136 : : (void *)&cmd_gso_show_keyword,
6137 : : NULL,
6138 : : },
6139 : : };
6140 : : #endif /* RTE_LIB_GSO */
6141 : :
6142 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
6143 : : struct cmd_set_flush_rx {
6144 : : cmdline_fixed_string_t set;
6145 : : cmdline_fixed_string_t flush_rx;
6146 : : cmdline_fixed_string_t mode;
6147 : : };
6148 : :
6149 : : static void
6150 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
6151 : : __rte_unused struct cmdline *cl,
6152 : : __rte_unused void *data)
6153 : : {
6154 : : struct cmd_set_flush_rx *res = parsed_result;
6155 : :
6156 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
6157 : : printf("multi-process doesn't support to flush Rx queues.\n");
6158 : 0 : return;
6159 : : }
6160 : :
6161 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6162 : : }
6163 : :
6164 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
6165 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6166 : : set, "set");
6167 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
6168 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6169 : : flush_rx, "flush_rx");
6170 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
6171 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6172 : : mode, "on#off");
6173 : :
6174 : :
6175 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
6176 : : .f = cmd_set_flush_rx_parsed,
6177 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
6178 : : .data = NULL,
6179 : : .tokens = {
6180 : : (void *)&cmd_setflushrx_set,
6181 : : (void *)&cmd_setflushrx_flush_rx,
6182 : : (void *)&cmd_setflushrx_mode,
6183 : : NULL,
6184 : : },
6185 : : };
6186 : :
6187 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
6188 : : struct cmd_set_link_check {
6189 : : cmdline_fixed_string_t set;
6190 : : cmdline_fixed_string_t link_check;
6191 : : cmdline_fixed_string_t mode;
6192 : : };
6193 : :
6194 : : static void
6195 : 0 : cmd_set_link_check_parsed(void *parsed_result,
6196 : : __rte_unused struct cmdline *cl,
6197 : : __rte_unused void *data)
6198 : : {
6199 : : struct cmd_set_link_check *res = parsed_result;
6200 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6201 : 0 : }
6202 : :
6203 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
6204 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6205 : : set, "set");
6206 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
6207 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6208 : : link_check, "link_check");
6209 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
6210 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6211 : : mode, "on#off");
6212 : :
6213 : :
6214 : : static cmdline_parse_inst_t cmd_set_link_check = {
6215 : : .f = cmd_set_link_check_parsed,
6216 : : .help_str = "set link_check on|off: Enable/Disable link status check "
6217 : : "when starting/stopping a port",
6218 : : .data = NULL,
6219 : : .tokens = {
6220 : : (void *)&cmd_setlinkcheck_set,
6221 : : (void *)&cmd_setlinkcheck_link_check,
6222 : : (void *)&cmd_setlinkcheck_mode,
6223 : : NULL,
6224 : : },
6225 : : };
6226 : :
6227 : : /* *** SET FORWARDING MODE *** */
6228 : : struct cmd_set_fwd_mode_result {
6229 : : cmdline_fixed_string_t set;
6230 : : cmdline_fixed_string_t fwd;
6231 : : cmdline_fixed_string_t mode;
6232 : : };
6233 : :
6234 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
6235 : : __rte_unused struct cmdline *cl,
6236 : : __rte_unused void *data)
6237 : : {
6238 : : struct cmd_set_fwd_mode_result *res = parsed_result;
6239 : :
6240 : 0 : retry_enabled = 0;
6241 : 0 : set_pkt_forwarding_mode(res->mode);
6242 : 0 : }
6243 : :
6244 : : static cmdline_parse_token_string_t cmd_setfwd_set =
6245 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6246 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
6247 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6248 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
6249 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6250 : : "" /* defined at init */);
6251 : :
6252 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
6253 : : .f = cmd_set_fwd_mode_parsed,
6254 : : .data = NULL,
6255 : : .help_str = NULL, /* defined at init */
6256 : : .tokens = {
6257 : : (void *)&cmd_setfwd_set,
6258 : : (void *)&cmd_setfwd_fwd,
6259 : : (void *)&cmd_setfwd_mode,
6260 : : NULL,
6261 : : },
6262 : : };
6263 : :
6264 : 0 : static void cmd_set_fwd_mode_init(void)
6265 : : {
6266 : : char *modes, *c;
6267 : : static char token[128];
6268 : : static char help[256];
6269 : : cmdline_parse_token_string_t *token_struct;
6270 : :
6271 : 0 : modes = list_pkt_forwarding_modes();
6272 : : snprintf(help, sizeof(help), "set fwd %s: "
6273 : : "Set packet forwarding mode", modes);
6274 : 0 : cmd_set_fwd_mode.help_str = help;
6275 : :
6276 : : /* string token separator is # */
6277 : 0 : for (c = token; *modes != '\0'; modes++)
6278 : 0 : if (*modes == '|')
6279 : 0 : *c++ = '#';
6280 : : else
6281 : 0 : *c++ = *modes;
6282 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6283 : 0 : token_struct->string_data.str = token;
6284 : 0 : }
6285 : :
6286 : : /* *** SET RETRY FORWARDING MODE *** */
6287 : : struct cmd_set_fwd_retry_mode_result {
6288 : : cmdline_fixed_string_t set;
6289 : : cmdline_fixed_string_t fwd;
6290 : : cmdline_fixed_string_t mode;
6291 : : cmdline_fixed_string_t retry;
6292 : : };
6293 : :
6294 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6295 : : __rte_unused struct cmdline *cl,
6296 : : __rte_unused void *data)
6297 : : {
6298 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6299 : :
6300 : 0 : retry_enabled = 1;
6301 : 0 : set_pkt_forwarding_mode(res->mode);
6302 : 0 : }
6303 : :
6304 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6305 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6306 : : set, "set");
6307 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6308 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6309 : : fwd, "fwd");
6310 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6311 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6312 : : mode,
6313 : : "" /* defined at init */);
6314 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6315 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6316 : : retry, "retry");
6317 : :
6318 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6319 : : .f = cmd_set_fwd_retry_mode_parsed,
6320 : : .data = NULL,
6321 : : .help_str = NULL, /* defined at init */
6322 : : .tokens = {
6323 : : (void *)&cmd_setfwd_retry_set,
6324 : : (void *)&cmd_setfwd_retry_fwd,
6325 : : (void *)&cmd_setfwd_retry_mode,
6326 : : (void *)&cmd_setfwd_retry_retry,
6327 : : NULL,
6328 : : },
6329 : : };
6330 : :
6331 : 0 : static void cmd_set_fwd_retry_mode_init(void)
6332 : : {
6333 : : char *modes, *c;
6334 : : static char token[128];
6335 : : static char help[256];
6336 : : cmdline_parse_token_string_t *token_struct;
6337 : :
6338 : 0 : modes = list_pkt_forwarding_retry_modes();
6339 : : snprintf(help, sizeof(help), "set fwd %s retry: "
6340 : : "Set packet forwarding mode with retry", modes);
6341 : 0 : cmd_set_fwd_retry_mode.help_str = help;
6342 : :
6343 : : /* string token separator is # */
6344 : 0 : for (c = token; *modes != '\0'; modes++)
6345 : 0 : if (*modes == '|')
6346 : 0 : *c++ = '#';
6347 : : else
6348 : 0 : *c++ = *modes;
6349 : 0 : token_struct = (cmdline_parse_token_string_t *)
6350 : : cmd_set_fwd_retry_mode.tokens[2];
6351 : 0 : token_struct->string_data.str = token;
6352 : 0 : }
6353 : :
6354 : 0 : static void show_dcb_fwd_tc_config(void)
6355 : : {
6356 : : int i;
6357 : : printf("DCB forwarding TC list:");
6358 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6359 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6360 : : printf(" %d", i);
6361 : : }
6362 : : printf("\n");
6363 : 0 : printf("DCB forwarding cores per-TC: %u\n", dcb_fwd_tc_cores);
6364 : 0 : }
6365 : :
6366 : : /* *** set DCB forward TCs *** */
6367 : : struct cmd_set_dcb_fwd_tc_result {
6368 : : cmdline_fixed_string_t set;
6369 : : cmdline_fixed_string_t dcb;
6370 : : cmdline_fixed_string_t fwd_tc;
6371 : : uint8_t tc_mask;
6372 : : };
6373 : :
6374 : 0 : static void cmd_set_dcb_fwd_tc_parsed(void *parsed_result,
6375 : : __rte_unused struct cmdline *cl,
6376 : : __rte_unused void *data)
6377 : : {
6378 : : struct cmd_set_dcb_fwd_tc_result *res = parsed_result;
6379 : : int i;
6380 : 0 : if (test_done == 0) {
6381 : 0 : fprintf(stderr, "Please stop forwarding first\n");
6382 : 0 : return;
6383 : : }
6384 : 0 : if (res->tc_mask == 0) {
6385 : 0 : fprintf(stderr, "TC mask should not be zero!\n");
6386 : 0 : return;
6387 : : }
6388 : : printf("Enabled DCB forwarding TC list:");
6389 : 0 : dcb_fwd_tc_mask = res->tc_mask;
6390 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6391 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6392 : : printf(" %d", i);
6393 : : }
6394 : : printf("\n");
6395 : : }
6396 : :
6397 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_set =
6398 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6399 : : set, "set");
6400 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_dcb =
6401 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6402 : : dcb, "dcb");
6403 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_fwdtc =
6404 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6405 : : fwd_tc, "fwd_tc");
6406 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_tcmask =
6407 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6408 : : tc_mask, RTE_UINT8);
6409 : :
6410 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc = {
6411 : : .f = cmd_set_dcb_fwd_tc_parsed,
6412 : : .data = NULL,
6413 : : .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.",
6414 : : .tokens = {
6415 : : (void *)&cmd_set_dcb_fwd_tc_set,
6416 : : (void *)&cmd_set_dcb_fwd_tc_dcb,
6417 : : (void *)&cmd_set_dcb_fwd_tc_fwdtc,
6418 : : (void *)&cmd_set_dcb_fwd_tc_tcmask,
6419 : : NULL,
6420 : : },
6421 : : };
6422 : :
6423 : : /* *** set DCB forward cores per TC *** */
6424 : : struct cmd_set_dcb_fwd_tc_cores_result {
6425 : : cmdline_fixed_string_t set;
6426 : : cmdline_fixed_string_t dcb;
6427 : : cmdline_fixed_string_t fwd_tc_cores;
6428 : : uint8_t tc_cores;
6429 : : };
6430 : :
6431 : 0 : static void cmd_set_dcb_fwd_tc_cores_parsed(void *parsed_result,
6432 : : __rte_unused struct cmdline *cl,
6433 : : __rte_unused void *data)
6434 : : {
6435 : : struct cmd_set_dcb_fwd_tc_cores_result *res = parsed_result;
6436 : 0 : if (test_done == 0) {
6437 : 0 : fprintf(stderr, "Please stop forwarding first\n");
6438 : 0 : return;
6439 : : }
6440 : 0 : if (res->tc_cores == 0) {
6441 : 0 : fprintf(stderr, "Cores per-TC should not be zero!\n");
6442 : 0 : return;
6443 : : }
6444 : 0 : dcb_fwd_tc_cores = res->tc_cores;
6445 : 0 : printf("Set cores-per-TC: %u\n", dcb_fwd_tc_cores);
6446 : : }
6447 : :
6448 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_set =
6449 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6450 : : set, "set");
6451 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_dcb =
6452 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6453 : : dcb, "dcb");
6454 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_fwdtccores =
6455 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6456 : : fwd_tc_cores, "fwd_tc_cores");
6457 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_cores_tccores =
6458 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6459 : : tc_cores, RTE_UINT8);
6460 : :
6461 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc_cores = {
6462 : : .f = cmd_set_dcb_fwd_tc_cores_parsed,
6463 : : .data = NULL,
6464 : : .help_str = "config DCB forwarding cores per-TC, 1-means one core process all queues of a TC.",
6465 : : .tokens = {
6466 : : (void *)&cmd_set_dcb_fwd_tc_cores_set,
6467 : : (void *)&cmd_set_dcb_fwd_tc_cores_dcb,
6468 : : (void *)&cmd_set_dcb_fwd_tc_cores_fwdtccores,
6469 : : (void *)&cmd_set_dcb_fwd_tc_cores_tccores,
6470 : : NULL,
6471 : : },
6472 : : };
6473 : :
6474 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6475 : : struct cmd_set_burst_tx_retry_result {
6476 : : cmdline_fixed_string_t set;
6477 : : cmdline_fixed_string_t burst;
6478 : : cmdline_fixed_string_t tx;
6479 : : cmdline_fixed_string_t delay;
6480 : : uint32_t time;
6481 : : cmdline_fixed_string_t retry;
6482 : : uint32_t retry_num;
6483 : : };
6484 : :
6485 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6486 : : __rte_unused struct cmdline *cl,
6487 : : __rte_unused void *data)
6488 : : {
6489 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
6490 : :
6491 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6492 : 0 : && !strcmp(res->tx, "tx")) {
6493 : 0 : if (!strcmp(res->delay, "delay"))
6494 : 0 : burst_tx_delay_time = res->time;
6495 : 0 : if (!strcmp(res->retry, "retry"))
6496 : 0 : burst_tx_retry_num = res->retry_num;
6497 : : }
6498 : :
6499 : 0 : }
6500 : :
6501 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6502 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6503 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6504 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6505 : : "burst");
6506 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6507 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6508 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6509 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6510 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6511 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6512 : : RTE_UINT32);
6513 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6514 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6515 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6516 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6517 : : RTE_UINT32);
6518 : :
6519 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6520 : : .f = cmd_set_burst_tx_retry_parsed,
6521 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6522 : : .tokens = {
6523 : : (void *)&cmd_set_burst_tx_retry_set,
6524 : : (void *)&cmd_set_burst_tx_retry_burst,
6525 : : (void *)&cmd_set_burst_tx_retry_tx,
6526 : : (void *)&cmd_set_burst_tx_retry_delay,
6527 : : (void *)&cmd_set_burst_tx_retry_time,
6528 : : (void *)&cmd_set_burst_tx_retry_retry,
6529 : : (void *)&cmd_set_burst_tx_retry_retry_num,
6530 : : NULL,
6531 : : },
6532 : : };
6533 : :
6534 : : /* *** SET PROMISC MODE *** */
6535 : : struct cmd_set_promisc_mode_result {
6536 : : cmdline_fixed_string_t set;
6537 : : cmdline_fixed_string_t promisc;
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_promisc_mode_parsed(void *parsed_result,
6544 : : __rte_unused struct cmdline *cl,
6545 : : void *allports)
6546 : : {
6547 : : struct cmd_set_promisc_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_promisc_mode(i, enable);
6560 : : } else {
6561 : 0 : eth_set_promisc_mode(res->port_num, enable);
6562 : : }
6563 : 0 : }
6564 : :
6565 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
6566 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6567 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
6568 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6569 : : "promisc");
6570 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
6571 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6572 : : "all");
6573 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
6574 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6575 : : RTE_UINT16);
6576 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
6577 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6578 : : "on#off");
6579 : :
6580 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6581 : : .f = cmd_set_promisc_mode_parsed,
6582 : : .data = (void *)1,
6583 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
6584 : : .tokens = {
6585 : : (void *)&cmd_setpromisc_set,
6586 : : (void *)&cmd_setpromisc_promisc,
6587 : : (void *)&cmd_setpromisc_portall,
6588 : : (void *)&cmd_setpromisc_mode,
6589 : : NULL,
6590 : : },
6591 : : };
6592 : :
6593 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6594 : : .f = cmd_set_promisc_mode_parsed,
6595 : : .data = (void *)0,
6596 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6597 : : .tokens = {
6598 : : (void *)&cmd_setpromisc_set,
6599 : : (void *)&cmd_setpromisc_promisc,
6600 : : (void *)&cmd_setpromisc_portnum,
6601 : : (void *)&cmd_setpromisc_mode,
6602 : : NULL,
6603 : : },
6604 : : };
6605 : :
6606 : : /* *** SET ALLMULTI MODE *** */
6607 : : struct cmd_set_allmulti_mode_result {
6608 : : cmdline_fixed_string_t set;
6609 : : cmdline_fixed_string_t allmulti;
6610 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6611 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6612 : : cmdline_fixed_string_t mode;
6613 : : };
6614 : :
6615 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6616 : : __rte_unused struct cmdline *cl,
6617 : : void *allports)
6618 : : {
6619 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
6620 : : int enable;
6621 : : portid_t i;
6622 : :
6623 : 0 : if (!strcmp(res->mode, "on"))
6624 : : enable = 1;
6625 : : else
6626 : : enable = 0;
6627 : :
6628 : : /* all ports */
6629 : 0 : if (allports) {
6630 : 0 : RTE_ETH_FOREACH_DEV(i) {
6631 : 0 : eth_set_allmulticast_mode(i, enable);
6632 : : }
6633 : : }
6634 : : else {
6635 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
6636 : : }
6637 : 0 : }
6638 : :
6639 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
6640 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6641 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6642 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6643 : : "allmulti");
6644 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
6645 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6646 : : "all");
6647 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
6648 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6649 : : RTE_UINT16);
6650 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
6651 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6652 : : "on#off");
6653 : :
6654 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6655 : : .f = cmd_set_allmulti_mode_parsed,
6656 : : .data = (void *)1,
6657 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6658 : : .tokens = {
6659 : : (void *)&cmd_setallmulti_set,
6660 : : (void *)&cmd_setallmulti_allmulti,
6661 : : (void *)&cmd_setallmulti_portall,
6662 : : (void *)&cmd_setallmulti_mode,
6663 : : NULL,
6664 : : },
6665 : : };
6666 : :
6667 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6668 : : .f = cmd_set_allmulti_mode_parsed,
6669 : : .data = (void *)0,
6670 : : .help_str = "set allmulti <port_id> on|off: "
6671 : : "Set allmulti mode on port_id",
6672 : : .tokens = {
6673 : : (void *)&cmd_setallmulti_set,
6674 : : (void *)&cmd_setallmulti_allmulti,
6675 : : (void *)&cmd_setallmulti_portnum,
6676 : : (void *)&cmd_setallmulti_mode,
6677 : : NULL,
6678 : : },
6679 : : };
6680 : :
6681 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6682 : : struct cmd_link_flow_ctrl_show {
6683 : : cmdline_fixed_string_t show;
6684 : : cmdline_fixed_string_t port;
6685 : : portid_t port_id;
6686 : : cmdline_fixed_string_t flow_ctrl;
6687 : : };
6688 : :
6689 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6690 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6691 : : show, "show");
6692 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6693 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6694 : : port, "port");
6695 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6696 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6697 : : port_id, RTE_UINT16);
6698 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6699 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6700 : : flow_ctrl, "flow_ctrl");
6701 : :
6702 : : static void
6703 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6704 : : __rte_unused struct cmdline *cl,
6705 : : __rte_unused void *data)
6706 : : {
6707 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6708 : : static const char *info_border = "*********************";
6709 : : struct rte_eth_fc_conf fc_conf;
6710 : : bool rx_fc_en = false;
6711 : : bool tx_fc_en = false;
6712 : : int ret;
6713 : :
6714 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6715 : 0 : if (ret != 0) {
6716 : 0 : fprintf(stderr,
6717 : : "Failed to get current flow ctrl information: err = %d\n",
6718 : : ret);
6719 : 0 : return;
6720 : : }
6721 : :
6722 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6723 : : rx_fc_en = true;
6724 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6725 : : tx_fc_en = true;
6726 : :
6727 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6728 : 0 : info_border, res->port_id, info_border);
6729 : : printf("FC mode:\n");
6730 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6731 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6732 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6733 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6734 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6735 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6736 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6737 : 0 : printf("Forward MAC control frames: %s\n",
6738 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6739 : 0 : printf("\n%s************** End ***********%s\n",
6740 : : info_border, info_border);
6741 : : }
6742 : :
6743 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6744 : : .f = cmd_link_flow_ctrl_show_parsed,
6745 : : .data = NULL,
6746 : : .help_str = "show port <port_id> flow_ctrl",
6747 : : .tokens = {
6748 : : (void *)&cmd_lfc_show_show,
6749 : : (void *)&cmd_lfc_show_port,
6750 : : (void *)&cmd_lfc_show_portid,
6751 : : (void *)&cmd_lfc_show_flow_ctrl,
6752 : : NULL,
6753 : : },
6754 : : };
6755 : :
6756 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6757 : : struct cmd_link_flow_ctrl_set_result {
6758 : : cmdline_fixed_string_t set;
6759 : : cmdline_fixed_string_t flow_ctrl;
6760 : : cmdline_fixed_string_t rx;
6761 : : cmdline_fixed_string_t rx_lfc_mode;
6762 : : cmdline_fixed_string_t tx;
6763 : : cmdline_fixed_string_t tx_lfc_mode;
6764 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6765 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6766 : : cmdline_fixed_string_t autoneg_str;
6767 : : cmdline_fixed_string_t autoneg;
6768 : : cmdline_fixed_string_t hw_str;
6769 : : uint32_t high_water;
6770 : : cmdline_fixed_string_t lw_str;
6771 : : uint32_t low_water;
6772 : : cmdline_fixed_string_t pt_str;
6773 : : uint16_t pause_time;
6774 : : cmdline_fixed_string_t xon_str;
6775 : : uint16_t send_xon;
6776 : : portid_t port_id;
6777 : : };
6778 : :
6779 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6780 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6781 : : set, "set");
6782 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6783 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6784 : : flow_ctrl, "flow_ctrl");
6785 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6786 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6787 : : rx, "rx");
6788 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6789 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6790 : : rx_lfc_mode, "on#off");
6791 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6792 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6793 : : tx, "tx");
6794 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6795 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6796 : : tx_lfc_mode, "on#off");
6797 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6798 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6799 : : hw_str, "high_water");
6800 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6801 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6802 : : high_water, RTE_UINT32);
6803 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6804 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6805 : : lw_str, "low_water");
6806 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6807 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6808 : : low_water, RTE_UINT32);
6809 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6810 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6811 : : pt_str, "pause_time");
6812 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6813 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6814 : : pause_time, RTE_UINT16);
6815 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6816 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6817 : : xon_str, "send_xon");
6818 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6819 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6820 : : send_xon, RTE_UINT16);
6821 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6822 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6823 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6824 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6825 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6826 : : mac_ctrl_frame_fwd_mode, "on#off");
6827 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6828 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6829 : : autoneg_str, "autoneg");
6830 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6831 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6832 : : autoneg, "on#off");
6833 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6834 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6835 : : port_id, RTE_UINT16);
6836 : :
6837 : : /* forward declaration */
6838 : : static void
6839 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6840 : : void *data);
6841 : :
6842 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6843 : : .f = cmd_link_flow_ctrl_set_parsed,
6844 : : .data = NULL,
6845 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6846 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6847 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6848 : : .tokens = {
6849 : : (void *)&cmd_lfc_set_set,
6850 : : (void *)&cmd_lfc_set_flow_ctrl,
6851 : : (void *)&cmd_lfc_set_rx,
6852 : : (void *)&cmd_lfc_set_rx_mode,
6853 : : (void *)&cmd_lfc_set_tx,
6854 : : (void *)&cmd_lfc_set_tx_mode,
6855 : : (void *)&cmd_lfc_set_high_water,
6856 : : (void *)&cmd_lfc_set_low_water,
6857 : : (void *)&cmd_lfc_set_pause_time,
6858 : : (void *)&cmd_lfc_set_send_xon,
6859 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6860 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6861 : : (void *)&cmd_lfc_set_autoneg_str,
6862 : : (void *)&cmd_lfc_set_autoneg,
6863 : : (void *)&cmd_lfc_set_portid,
6864 : : NULL,
6865 : : },
6866 : : };
6867 : :
6868 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6869 : : .f = cmd_link_flow_ctrl_set_parsed,
6870 : : .data = (void *)&cmd_link_flow_control_set_rx,
6871 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6872 : : "Change rx flow control parameter",
6873 : : .tokens = {
6874 : : (void *)&cmd_lfc_set_set,
6875 : : (void *)&cmd_lfc_set_flow_ctrl,
6876 : : (void *)&cmd_lfc_set_rx,
6877 : : (void *)&cmd_lfc_set_rx_mode,
6878 : : (void *)&cmd_lfc_set_portid,
6879 : : NULL,
6880 : : },
6881 : : };
6882 : :
6883 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6884 : : .f = cmd_link_flow_ctrl_set_parsed,
6885 : : .data = (void *)&cmd_link_flow_control_set_tx,
6886 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6887 : : "Change tx flow control parameter",
6888 : : .tokens = {
6889 : : (void *)&cmd_lfc_set_set,
6890 : : (void *)&cmd_lfc_set_flow_ctrl,
6891 : : (void *)&cmd_lfc_set_tx,
6892 : : (void *)&cmd_lfc_set_tx_mode,
6893 : : (void *)&cmd_lfc_set_portid,
6894 : : NULL,
6895 : : },
6896 : : };
6897 : :
6898 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6899 : : .f = cmd_link_flow_ctrl_set_parsed,
6900 : : .data = (void *)&cmd_link_flow_control_set_hw,
6901 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6902 : : "Change high water flow control parameter",
6903 : : .tokens = {
6904 : : (void *)&cmd_lfc_set_set,
6905 : : (void *)&cmd_lfc_set_flow_ctrl,
6906 : : (void *)&cmd_lfc_set_high_water_str,
6907 : : (void *)&cmd_lfc_set_high_water,
6908 : : (void *)&cmd_lfc_set_portid,
6909 : : NULL,
6910 : : },
6911 : : };
6912 : :
6913 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6914 : : .f = cmd_link_flow_ctrl_set_parsed,
6915 : : .data = (void *)&cmd_link_flow_control_set_lw,
6916 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6917 : : "Change low water flow control parameter",
6918 : : .tokens = {
6919 : : (void *)&cmd_lfc_set_set,
6920 : : (void *)&cmd_lfc_set_flow_ctrl,
6921 : : (void *)&cmd_lfc_set_low_water_str,
6922 : : (void *)&cmd_lfc_set_low_water,
6923 : : (void *)&cmd_lfc_set_portid,
6924 : : NULL,
6925 : : },
6926 : : };
6927 : :
6928 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6929 : : .f = cmd_link_flow_ctrl_set_parsed,
6930 : : .data = (void *)&cmd_link_flow_control_set_pt,
6931 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6932 : : "Change pause time flow control parameter",
6933 : : .tokens = {
6934 : : (void *)&cmd_lfc_set_set,
6935 : : (void *)&cmd_lfc_set_flow_ctrl,
6936 : : (void *)&cmd_lfc_set_pause_time_str,
6937 : : (void *)&cmd_lfc_set_pause_time,
6938 : : (void *)&cmd_lfc_set_portid,
6939 : : NULL,
6940 : : },
6941 : : };
6942 : :
6943 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6944 : : .f = cmd_link_flow_ctrl_set_parsed,
6945 : : .data = (void *)&cmd_link_flow_control_set_xon,
6946 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6947 : : "Change send_xon flow control parameter",
6948 : : .tokens = {
6949 : : (void *)&cmd_lfc_set_set,
6950 : : (void *)&cmd_lfc_set_flow_ctrl,
6951 : : (void *)&cmd_lfc_set_send_xon_str,
6952 : : (void *)&cmd_lfc_set_send_xon,
6953 : : (void *)&cmd_lfc_set_portid,
6954 : : NULL,
6955 : : },
6956 : : };
6957 : :
6958 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6959 : : .f = cmd_link_flow_ctrl_set_parsed,
6960 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6961 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6962 : : "Change mac ctrl fwd flow control parameter",
6963 : : .tokens = {
6964 : : (void *)&cmd_lfc_set_set,
6965 : : (void *)&cmd_lfc_set_flow_ctrl,
6966 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6967 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6968 : : (void *)&cmd_lfc_set_portid,
6969 : : NULL,
6970 : : },
6971 : : };
6972 : :
6973 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6974 : : .f = cmd_link_flow_ctrl_set_parsed,
6975 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6976 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6977 : : "Change autoneg flow control parameter",
6978 : : .tokens = {
6979 : : (void *)&cmd_lfc_set_set,
6980 : : (void *)&cmd_lfc_set_flow_ctrl,
6981 : : (void *)&cmd_lfc_set_autoneg_str,
6982 : : (void *)&cmd_lfc_set_autoneg,
6983 : : (void *)&cmd_lfc_set_portid,
6984 : : NULL,
6985 : : },
6986 : : };
6987 : :
6988 : : static void
6989 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6990 : : __rte_unused struct cmdline *cl,
6991 : : void *data)
6992 : : {
6993 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6994 : : cmdline_parse_inst_t *cmd = data;
6995 : : struct rte_eth_fc_conf fc_conf;
6996 : : int rx_fc_en = 0;
6997 : : int tx_fc_en = 0;
6998 : : int ret;
6999 : :
7000 : : /*
7001 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7002 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7003 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7004 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7005 : : */
7006 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
7007 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7008 : : };
7009 : :
7010 : : /* Partial command line, retrieve current configuration */
7011 : 0 : if (cmd) {
7012 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
7013 : 0 : if (ret != 0) {
7014 : 0 : fprintf(stderr,
7015 : : "cannot get current flow ctrl parameters, return code = %d\n",
7016 : : ret);
7017 : 0 : return;
7018 : : }
7019 : :
7020 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
7021 : : (fc_conf.mode == RTE_ETH_FC_FULL))
7022 : : rx_fc_en = 1;
7023 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
7024 : : (fc_conf.mode == RTE_ETH_FC_FULL))
7025 : : tx_fc_en = 1;
7026 : : }
7027 : :
7028 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
7029 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
7030 : :
7031 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
7032 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
7033 : :
7034 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
7035 : :
7036 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
7037 : 0 : fc_conf.high_water = res->high_water;
7038 : :
7039 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
7040 : 0 : fc_conf.low_water = res->low_water;
7041 : :
7042 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
7043 : 0 : fc_conf.pause_time = res->pause_time;
7044 : :
7045 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
7046 : 0 : fc_conf.send_xon = res->send_xon;
7047 : :
7048 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
7049 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
7050 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
7051 : : else
7052 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
7053 : : }
7054 : :
7055 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
7056 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
7057 : :
7058 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
7059 : 0 : if (ret != 0)
7060 : 0 : fprintf(stderr,
7061 : : "bad flow control parameter, return code = %d\n",
7062 : : ret);
7063 : : }
7064 : :
7065 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
7066 : : struct cmd_priority_flow_ctrl_set_result {
7067 : : cmdline_fixed_string_t set;
7068 : : cmdline_fixed_string_t pfc_ctrl;
7069 : : cmdline_fixed_string_t rx;
7070 : : cmdline_fixed_string_t rx_pfc_mode;
7071 : : cmdline_fixed_string_t tx;
7072 : : cmdline_fixed_string_t tx_pfc_mode;
7073 : : uint32_t high_water;
7074 : : uint32_t low_water;
7075 : : uint16_t pause_time;
7076 : : uint8_t priority;
7077 : : portid_t port_id;
7078 : : };
7079 : :
7080 : : static void
7081 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7082 : : __rte_unused struct cmdline *cl,
7083 : : __rte_unused void *data)
7084 : : {
7085 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7086 : : struct rte_eth_pfc_conf pfc_conf;
7087 : : int rx_fc_enable, tx_fc_enable;
7088 : : int ret;
7089 : :
7090 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
7091 : 0 : return;
7092 : :
7093 : : /*
7094 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7095 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7096 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7097 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7098 : : */
7099 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7100 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7101 : : };
7102 : :
7103 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7104 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7105 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7106 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7107 : 0 : pfc_conf.fc.high_water = res->high_water;
7108 : 0 : pfc_conf.fc.low_water = res->low_water;
7109 : 0 : pfc_conf.fc.pause_time = res->pause_time;
7110 : 0 : pfc_conf.priority = res->priority;
7111 : :
7112 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7113 : 0 : if (ret != 0)
7114 : 0 : fprintf(stderr,
7115 : : "bad priority flow control parameter, return code = %d\n",
7116 : : ret);
7117 : : }
7118 : :
7119 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
7120 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7121 : : set, "set");
7122 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7123 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7124 : : pfc_ctrl, "pfc_ctrl");
7125 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
7126 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7127 : : rx, "rx");
7128 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7129 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7130 : : rx_pfc_mode, "on#off");
7131 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
7132 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7133 : : tx, "tx");
7134 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7135 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7136 : : tx_pfc_mode, "on#off");
7137 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
7138 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7139 : : high_water, RTE_UINT32);
7140 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
7141 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7142 : : low_water, RTE_UINT32);
7143 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7144 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7145 : : pause_time, RTE_UINT16);
7146 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
7147 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7148 : : priority, RTE_UINT8);
7149 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
7150 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7151 : : port_id, RTE_UINT16);
7152 : :
7153 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
7154 : : .f = cmd_priority_flow_ctrl_set_parsed,
7155 : : .data = NULL,
7156 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7157 : : "<pause_time> <priority> <port_id>: "
7158 : : "Configure the Ethernet priority flow control",
7159 : : .tokens = {
7160 : : (void *)&cmd_pfc_set_set,
7161 : : (void *)&cmd_pfc_set_flow_ctrl,
7162 : : (void *)&cmd_pfc_set_rx,
7163 : : (void *)&cmd_pfc_set_rx_mode,
7164 : : (void *)&cmd_pfc_set_tx,
7165 : : (void *)&cmd_pfc_set_tx_mode,
7166 : : (void *)&cmd_pfc_set_high_water,
7167 : : (void *)&cmd_pfc_set_low_water,
7168 : : (void *)&cmd_pfc_set_pause_time,
7169 : : (void *)&cmd_pfc_set_priority,
7170 : : (void *)&cmd_pfc_set_portid,
7171 : : NULL,
7172 : : },
7173 : : };
7174 : :
7175 : : struct cmd_queue_priority_flow_ctrl_set_result {
7176 : : cmdline_fixed_string_t set;
7177 : : cmdline_fixed_string_t pfc_queue_ctrl;
7178 : : portid_t port_id;
7179 : : cmdline_fixed_string_t rx;
7180 : : cmdline_fixed_string_t rx_pfc_mode;
7181 : : uint16_t tx_qid;
7182 : : uint8_t tx_tc;
7183 : : cmdline_fixed_string_t tx;
7184 : : cmdline_fixed_string_t tx_pfc_mode;
7185 : : uint16_t rx_qid;
7186 : : uint8_t rx_tc;
7187 : : uint16_t pause_time;
7188 : : };
7189 : :
7190 : : static void
7191 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7192 : : __rte_unused struct cmdline *cl,
7193 : : __rte_unused void *data)
7194 : : {
7195 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7196 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
7197 : : int rx_fc_enable, tx_fc_enable;
7198 : : int ret;
7199 : :
7200 : : /*
7201 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
7202 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7203 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
7204 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7205 : : * the Tx side.
7206 : : */
7207 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7208 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7209 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7210 : : };
7211 : :
7212 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7213 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7214 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7215 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7216 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
7217 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7218 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
7219 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7220 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7221 : :
7222 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7223 : : &pfc_queue_conf);
7224 : 0 : if (ret != 0) {
7225 : 0 : fprintf(stderr,
7226 : : "bad queue priority flow control parameter, rc = %d\n",
7227 : : ret);
7228 : : }
7229 : 0 : }
7230 : :
7231 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
7232 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7233 : : set, "set");
7234 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7235 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7236 : : pfc_queue_ctrl, "pfc_queue_ctrl");
7237 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7238 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7239 : : port_id, RTE_UINT16);
7240 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7241 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7242 : : rx, "rx");
7243 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7244 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7245 : : rx_pfc_mode, "on#off");
7246 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7247 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7248 : : tx_qid, RTE_UINT16);
7249 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7250 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7251 : : tx_tc, RTE_UINT8);
7252 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7253 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7254 : : tx, "tx");
7255 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7256 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7257 : : tx_pfc_mode, "on#off");
7258 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7259 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7260 : : rx_qid, RTE_UINT16);
7261 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7262 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7263 : : rx_tc, RTE_UINT8);
7264 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7265 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7266 : : pause_time, RTE_UINT16);
7267 : :
7268 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7269 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
7270 : : .data = NULL,
7271 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7272 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7273 : : "Configure the Ethernet queue priority flow control",
7274 : : .tokens = {
7275 : : (void *)&cmd_q_pfc_set_set,
7276 : : (void *)&cmd_q_pfc_set_flow_ctrl,
7277 : : (void *)&cmd_q_pfc_set_portid,
7278 : : (void *)&cmd_q_pfc_set_rx,
7279 : : (void *)&cmd_q_pfc_set_rx_mode,
7280 : : (void *)&cmd_q_pfc_set_tx_qid,
7281 : : (void *)&cmd_q_pfc_set_tx_tc,
7282 : : (void *)&cmd_q_pfc_set_tx,
7283 : : (void *)&cmd_q_pfc_set_tx_mode,
7284 : : (void *)&cmd_q_pfc_set_rx_qid,
7285 : : (void *)&cmd_q_pfc_set_rx_tc,
7286 : : (void *)&cmd_q_pfc_set_pause_time,
7287 : : NULL,
7288 : : },
7289 : : };
7290 : :
7291 : : /* *** RESET CONFIGURATION *** */
7292 : : struct cmd_reset_result {
7293 : : cmdline_fixed_string_t reset;
7294 : : cmdline_fixed_string_t def;
7295 : : };
7296 : :
7297 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
7298 : : struct cmdline *cl,
7299 : : __rte_unused void *data)
7300 : : {
7301 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7302 : 0 : set_def_fwd_config();
7303 : 0 : }
7304 : :
7305 : : static cmdline_parse_token_string_t cmd_reset_set =
7306 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7307 : : static cmdline_parse_token_string_t cmd_reset_def =
7308 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7309 : : "default");
7310 : :
7311 : : static cmdline_parse_inst_t cmd_reset = {
7312 : : .f = cmd_reset_parsed,
7313 : : .data = NULL,
7314 : : .help_str = "set default: Reset default forwarding configuration",
7315 : : .tokens = {
7316 : : (void *)&cmd_reset_set,
7317 : : (void *)&cmd_reset_def,
7318 : : NULL,
7319 : : },
7320 : : };
7321 : :
7322 : : /* *** START FORWARDING *** */
7323 : : struct cmd_start_result {
7324 : : cmdline_fixed_string_t start;
7325 : : };
7326 : :
7327 : : static cmdline_parse_token_string_t cmd_start_start =
7328 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7329 : :
7330 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
7331 : : __rte_unused struct cmdline *cl,
7332 : : __rte_unused void *data)
7333 : : {
7334 : 0 : start_packet_forwarding(0);
7335 : 0 : }
7336 : :
7337 : : static cmdline_parse_inst_t cmd_start = {
7338 : : .f = cmd_start_parsed,
7339 : : .data = NULL,
7340 : : .help_str = "start: Start packet forwarding",
7341 : : .tokens = {
7342 : : (void *)&cmd_start_start,
7343 : : NULL,
7344 : : },
7345 : : };
7346 : :
7347 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7348 : : struct cmd_start_tx_first_result {
7349 : : cmdline_fixed_string_t start;
7350 : : cmdline_fixed_string_t tx_first;
7351 : : };
7352 : :
7353 : : static void
7354 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7355 : : __rte_unused struct cmdline *cl,
7356 : : __rte_unused void *data)
7357 : : {
7358 : 0 : start_packet_forwarding(1);
7359 : 0 : }
7360 : :
7361 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
7362 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7363 : : "start");
7364 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7365 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7366 : : tx_first, "tx_first");
7367 : :
7368 : : static cmdline_parse_inst_t cmd_start_tx_first = {
7369 : : .f = cmd_start_tx_first_parsed,
7370 : : .data = NULL,
7371 : : .help_str = "start tx_first: Start packet forwarding, "
7372 : : "after sending 1 burst of packets",
7373 : : .tokens = {
7374 : : (void *)&cmd_start_tx_first_start,
7375 : : (void *)&cmd_start_tx_first_tx_first,
7376 : : NULL,
7377 : : },
7378 : : };
7379 : :
7380 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
7381 : : struct cmd_start_tx_first_n_result {
7382 : : cmdline_fixed_string_t start;
7383 : : cmdline_fixed_string_t tx_first;
7384 : : uint32_t tx_num;
7385 : : };
7386 : :
7387 : : static void
7388 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
7389 : : __rte_unused struct cmdline *cl,
7390 : : __rte_unused void *data)
7391 : : {
7392 : : struct cmd_start_tx_first_n_result *res = parsed_result;
7393 : :
7394 : 0 : start_packet_forwarding(res->tx_num);
7395 : 0 : }
7396 : :
7397 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7398 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7399 : : start, "start");
7400 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7401 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7402 : : tx_first, "tx_first");
7403 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7404 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7405 : : tx_num, RTE_UINT32);
7406 : :
7407 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
7408 : : .f = cmd_start_tx_first_n_parsed,
7409 : : .data = NULL,
7410 : : .help_str = "start tx_first <num>: "
7411 : : "packet forwarding, after sending <num> bursts of packets",
7412 : : .tokens = {
7413 : : (void *)&cmd_start_tx_first_n_start,
7414 : : (void *)&cmd_start_tx_first_n_tx_first,
7415 : : (void *)&cmd_start_tx_first_n_tx_num,
7416 : : NULL,
7417 : : },
7418 : : };
7419 : :
7420 : : /* *** SET LINK UP *** */
7421 : : struct cmd_set_link_up_result {
7422 : : cmdline_fixed_string_t set;
7423 : : cmdline_fixed_string_t link_up;
7424 : : cmdline_fixed_string_t port;
7425 : : portid_t port_id;
7426 : : };
7427 : :
7428 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
7429 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7430 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7431 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7432 : : "link-up");
7433 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
7434 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7435 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7436 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7437 : : RTE_UINT16);
7438 : :
7439 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7440 : : __rte_unused struct cmdline *cl,
7441 : : __rte_unused void *data)
7442 : : {
7443 : : struct cmd_set_link_up_result *res = parsed_result;
7444 : 0 : dev_set_link_up(res->port_id);
7445 : 0 : }
7446 : :
7447 : : static cmdline_parse_inst_t cmd_set_link_up = {
7448 : : .f = cmd_set_link_up_parsed,
7449 : : .data = NULL,
7450 : : .help_str = "set link-up port <port id>",
7451 : : .tokens = {
7452 : : (void *)&cmd_set_link_up_set,
7453 : : (void *)&cmd_set_link_up_link_up,
7454 : : (void *)&cmd_set_link_up_port,
7455 : : (void *)&cmd_set_link_up_port_id,
7456 : : NULL,
7457 : : },
7458 : : };
7459 : :
7460 : : /* *** SET LINK DOWN *** */
7461 : : struct cmd_set_link_down_result {
7462 : : cmdline_fixed_string_t set;
7463 : : cmdline_fixed_string_t link_down;
7464 : : cmdline_fixed_string_t port;
7465 : : portid_t port_id;
7466 : : };
7467 : :
7468 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
7469 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7470 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
7471 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7472 : : "link-down");
7473 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
7474 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7475 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
7476 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7477 : : RTE_UINT16);
7478 : :
7479 : 0 : static void cmd_set_link_down_parsed(
7480 : : __rte_unused void *parsed_result,
7481 : : __rte_unused struct cmdline *cl,
7482 : : __rte_unused void *data)
7483 : : {
7484 : : struct cmd_set_link_down_result *res = parsed_result;
7485 : 0 : dev_set_link_down(res->port_id);
7486 : 0 : }
7487 : :
7488 : : static cmdline_parse_inst_t cmd_set_link_down = {
7489 : : .f = cmd_set_link_down_parsed,
7490 : : .data = NULL,
7491 : : .help_str = "set link-down port <port id>",
7492 : : .tokens = {
7493 : : (void *)&cmd_set_link_down_set,
7494 : : (void *)&cmd_set_link_down_link_down,
7495 : : (void *)&cmd_set_link_down_port,
7496 : : (void *)&cmd_set_link_down_port_id,
7497 : : NULL,
7498 : : },
7499 : : };
7500 : :
7501 : : /* *** SHOW CFG *** */
7502 : : struct cmd_showcfg_result {
7503 : : cmdline_fixed_string_t show;
7504 : : cmdline_fixed_string_t cfg;
7505 : : cmdline_fixed_string_t what;
7506 : : };
7507 : :
7508 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
7509 : : __rte_unused struct cmdline *cl,
7510 : : __rte_unused void *data)
7511 : : {
7512 : : struct cmd_showcfg_result *res = parsed_result;
7513 : 0 : if (!strcmp(res->what, "rxtx"))
7514 : 0 : rxtx_config_display();
7515 : 0 : else if (!strcmp(res->what, "cores"))
7516 : 0 : fwd_lcores_config_display();
7517 : 0 : else if (!strcmp(res->what, "fwd"))
7518 : 0 : pkt_fwd_config_display(&cur_fwd_config);
7519 : 0 : else if (!strcmp(res->what, "rxoffs"))
7520 : 0 : show_rx_pkt_offsets();
7521 : 0 : else if (!strcmp(res->what, "rxpkts"))
7522 : 0 : show_rx_pkt_segments();
7523 : 0 : else if (!strcmp(res->what, "rxhdrs"))
7524 : 0 : show_rx_pkt_hdrs();
7525 : 0 : else if (!strcmp(res->what, "txpkts"))
7526 : 0 : show_tx_pkt_segments();
7527 : 0 : else if (!strcmp(res->what, "txtimes"))
7528 : 0 : show_tx_pkt_times();
7529 : 0 : else if (!strcmp(res->what, "dcbfwdtc"))
7530 : 0 : show_dcb_fwd_tc_config();
7531 : 0 : }
7532 : :
7533 : : static cmdline_parse_token_string_t cmd_showcfg_show =
7534 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7535 : : static cmdline_parse_token_string_t cmd_showcfg_port =
7536 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7537 : : static cmdline_parse_token_string_t cmd_showcfg_what =
7538 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7539 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes#dcbfwdtc");
7540 : :
7541 : : static cmdline_parse_inst_t cmd_showcfg = {
7542 : : .f = cmd_showcfg_parsed,
7543 : : .data = NULL,
7544 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes|dcbfwdtc",
7545 : : .tokens = {
7546 : : (void *)&cmd_showcfg_show,
7547 : : (void *)&cmd_showcfg_port,
7548 : : (void *)&cmd_showcfg_what,
7549 : : NULL,
7550 : : },
7551 : : };
7552 : :
7553 : : /* *** SHOW ALL PORT INFO *** */
7554 : : struct cmd_showportall_result {
7555 : : cmdline_fixed_string_t show;
7556 : : cmdline_fixed_string_t port;
7557 : : cmdline_fixed_string_t what;
7558 : : cmdline_fixed_string_t all;
7559 : : };
7560 : :
7561 : 0 : static void cmd_showportall_parsed(void *parsed_result,
7562 : : __rte_unused struct cmdline *cl,
7563 : : __rte_unused void *data)
7564 : : {
7565 : : portid_t i;
7566 : :
7567 : : struct cmd_showportall_result *res = parsed_result;
7568 : 0 : if (!strcmp(res->show, "clear")) {
7569 : 0 : if (!strcmp(res->what, "stats"))
7570 : 0 : RTE_ETH_FOREACH_DEV(i)
7571 : 0 : nic_stats_clear(i);
7572 : 0 : else if (!strcmp(res->what, "xstats"))
7573 : 0 : RTE_ETH_FOREACH_DEV(i)
7574 : 0 : nic_xstats_clear(i);
7575 : 0 : } else if (!strcmp(res->what, "info"))
7576 : 0 : RTE_ETH_FOREACH_DEV(i)
7577 : 0 : port_infos_display(i);
7578 : 0 : else if (!strcmp(res->what, "summary")) {
7579 : 0 : port_summary_header_display();
7580 : 0 : RTE_ETH_FOREACH_DEV(i)
7581 : 0 : port_summary_display(i);
7582 : : }
7583 : 0 : else if (!strcmp(res->what, "stats"))
7584 : 0 : RTE_ETH_FOREACH_DEV(i)
7585 : 0 : nic_stats_display(i);
7586 : 0 : else if (!strcmp(res->what, "xstats"))
7587 : 0 : RTE_ETH_FOREACH_DEV(i)
7588 : 0 : nic_xstats_display(i);
7589 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7590 : 0 : else if (!strcmp(res->what, "fdir"))
7591 : 0 : RTE_ETH_FOREACH_DEV(i)
7592 : 0 : fdir_get_infos(i);
7593 : : #endif
7594 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7595 : 0 : RTE_ETH_FOREACH_DEV(i)
7596 : 0 : port_dcb_info_display(i);
7597 : 0 : }
7598 : :
7599 : : static cmdline_parse_token_string_t cmd_showportall_show =
7600 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7601 : : "show#clear");
7602 : : static cmdline_parse_token_string_t cmd_showportall_port =
7603 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7604 : : static cmdline_parse_token_string_t cmd_showportall_what =
7605 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7606 : : "info#summary#stats#xstats#fdir#dcb_tc");
7607 : : static cmdline_parse_token_string_t cmd_showportall_all =
7608 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7609 : : static cmdline_parse_inst_t cmd_showportall = {
7610 : : .f = cmd_showportall_parsed,
7611 : : .data = NULL,
7612 : : .help_str = "show|clear port "
7613 : : "info|summary|stats|xstats|fdir|dcb_tc all",
7614 : : .tokens = {
7615 : : (void *)&cmd_showportall_show,
7616 : : (void *)&cmd_showportall_port,
7617 : : (void *)&cmd_showportall_what,
7618 : : (void *)&cmd_showportall_all,
7619 : : NULL,
7620 : : },
7621 : : };
7622 : :
7623 : : /* *** SHOW PORT INFO *** */
7624 : : struct cmd_showport_result {
7625 : : cmdline_fixed_string_t show;
7626 : : cmdline_fixed_string_t port;
7627 : : cmdline_fixed_string_t what;
7628 : : uint16_t portnum;
7629 : : };
7630 : :
7631 : 0 : static void cmd_showport_parsed(void *parsed_result,
7632 : : __rte_unused struct cmdline *cl,
7633 : : __rte_unused void *data)
7634 : : {
7635 : : struct cmd_showport_result *res = parsed_result;
7636 : 0 : if (!strcmp(res->show, "clear")) {
7637 : 0 : if (!strcmp(res->what, "stats"))
7638 : 0 : nic_stats_clear(res->portnum);
7639 : 0 : else if (!strcmp(res->what, "xstats"))
7640 : 0 : nic_xstats_clear(res->portnum);
7641 : 0 : } else if (!strcmp(res->what, "info"))
7642 : 0 : port_infos_display(res->portnum);
7643 : 0 : else if (!strcmp(res->what, "summary")) {
7644 : 0 : port_summary_header_display();
7645 : 0 : port_summary_display(res->portnum);
7646 : : }
7647 : 0 : else if (!strcmp(res->what, "stats"))
7648 : 0 : nic_stats_display(res->portnum);
7649 : 0 : else if (!strcmp(res->what, "xstats"))
7650 : 0 : nic_xstats_display(res->portnum);
7651 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7652 : 0 : else if (!strcmp(res->what, "fdir"))
7653 : 0 : fdir_get_infos(res->portnum);
7654 : : #endif
7655 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7656 : 0 : port_dcb_info_display(res->portnum);
7657 : 0 : }
7658 : :
7659 : : static cmdline_parse_token_string_t cmd_showport_show =
7660 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7661 : : "show#clear");
7662 : : static cmdline_parse_token_string_t cmd_showport_port =
7663 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7664 : : static cmdline_parse_token_string_t cmd_showport_what =
7665 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7666 : : "info#summary#stats#xstats#fdir#dcb_tc");
7667 : : static cmdline_parse_token_num_t cmd_showport_portnum =
7668 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7669 : :
7670 : : static cmdline_parse_inst_t cmd_showport = {
7671 : : .f = cmd_showport_parsed,
7672 : : .data = NULL,
7673 : : .help_str = "show|clear port "
7674 : : "info|summary|stats|xstats|fdir|dcb_tc "
7675 : : "<port_id>",
7676 : : .tokens = {
7677 : : (void *)&cmd_showport_show,
7678 : : (void *)&cmd_showport_port,
7679 : : (void *)&cmd_showport_what,
7680 : : (void *)&cmd_showport_portnum,
7681 : : NULL,
7682 : : },
7683 : : };
7684 : :
7685 : : /* *** show port representors information *** */
7686 : : struct cmd_representor_info_result {
7687 : : cmdline_fixed_string_t cmd_show;
7688 : : cmdline_fixed_string_t cmd_port;
7689 : : cmdline_fixed_string_t cmd_info;
7690 : : cmdline_fixed_string_t cmd_keyword;
7691 : : portid_t cmd_pid;
7692 : : };
7693 : :
7694 : : static void
7695 : 0 : cmd_representor_info_parsed(void *parsed_result,
7696 : : __rte_unused struct cmdline *cl,
7697 : : __rte_unused void *data)
7698 : : {
7699 : : struct cmd_representor_info_result *res = parsed_result;
7700 : : struct rte_eth_representor_info *info;
7701 : : struct rte_eth_representor_range *range;
7702 : : uint32_t range_diff;
7703 : : uint32_t i;
7704 : : int ret;
7705 : : int num;
7706 : :
7707 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7708 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7709 : 0 : return;
7710 : : }
7711 : :
7712 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7713 : 0 : if (ret < 0) {
7714 : 0 : fprintf(stderr,
7715 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7716 : 0 : res->cmd_pid, rte_strerror(-ret));
7717 : 0 : return;
7718 : : }
7719 : : num = ret;
7720 : :
7721 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7722 : 0 : if (info == NULL) {
7723 : 0 : fprintf(stderr,
7724 : : "Failed to allocate memory for representor info for port %hu\n",
7725 : 0 : res->cmd_pid);
7726 : 0 : return;
7727 : : }
7728 : 0 : info->nb_ranges_alloc = num;
7729 : :
7730 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7731 : 0 : if (ret < 0) {
7732 : 0 : fprintf(stderr,
7733 : : "Failed to get the representor info for port %hu: %s\n",
7734 : 0 : res->cmd_pid, rte_strerror(-ret));
7735 : 0 : free(info);
7736 : 0 : return;
7737 : : }
7738 : :
7739 : 0 : printf("Port controller: %hu\n", info->controller);
7740 : 0 : printf("Port PF: %hu\n", info->pf);
7741 : :
7742 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7743 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7744 : : range = &info->ranges[i];
7745 : 0 : range_diff = range->id_end - range->id_base;
7746 : :
7747 : 0 : printf("%u. ", i + 1);
7748 : 0 : printf("'%s' ", range->name);
7749 : 0 : if (range_diff > 0)
7750 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7751 : : else
7752 : 0 : printf("[%u]: ", range->id_base);
7753 : :
7754 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7755 : :
7756 : 0 : switch (range->type) {
7757 : : case RTE_ETH_REPRESENTOR_NONE:
7758 : : printf(", NONE\n");
7759 : : break;
7760 : 0 : case RTE_ETH_REPRESENTOR_VF:
7761 : 0 : if (range_diff > 0)
7762 : 0 : printf(", VF %d..%d\n", range->vf,
7763 : 0 : range->vf + range_diff);
7764 : : else
7765 : 0 : printf(", VF %d\n", range->vf);
7766 : : break;
7767 : 0 : case RTE_ETH_REPRESENTOR_SF:
7768 : 0 : printf(", SF %d\n", range->sf);
7769 : : break;
7770 : 0 : case RTE_ETH_REPRESENTOR_PF:
7771 : 0 : if (range_diff > 0)
7772 : 0 : printf("..%d\n", range->pf + range_diff);
7773 : : else
7774 : : printf("\n");
7775 : : break;
7776 : 0 : default:
7777 : : printf(", UNKNOWN TYPE %d\n", range->type);
7778 : : break;
7779 : : }
7780 : : }
7781 : :
7782 : 0 : free(info);
7783 : : }
7784 : :
7785 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7786 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7787 : : cmd_show, "show");
7788 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7789 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7790 : : cmd_port, "port");
7791 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7792 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7793 : : cmd_info, "info");
7794 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7795 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7796 : : cmd_pid, RTE_UINT16);
7797 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7798 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7799 : : cmd_keyword, "representor");
7800 : :
7801 : : static cmdline_parse_inst_t cmd_representor_info = {
7802 : : .f = cmd_representor_info_parsed,
7803 : : .data = NULL,
7804 : : .help_str = "show port info <port_id> representor",
7805 : : .tokens = {
7806 : : (void *)&cmd_representor_info_show,
7807 : : (void *)&cmd_representor_info_port,
7808 : : (void *)&cmd_representor_info_info,
7809 : : (void *)&cmd_representor_info_pid,
7810 : : (void *)&cmd_representor_info_keyword,
7811 : : NULL,
7812 : : },
7813 : : };
7814 : :
7815 : :
7816 : : /* *** SHOW DEVICE INFO *** */
7817 : : struct cmd_showdevice_result {
7818 : : cmdline_fixed_string_t show;
7819 : : cmdline_fixed_string_t device;
7820 : : cmdline_fixed_string_t what;
7821 : : cmdline_fixed_string_t identifier;
7822 : : };
7823 : :
7824 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7825 : : __rte_unused struct cmdline *cl,
7826 : : __rte_unused void *data)
7827 : : {
7828 : : struct cmd_showdevice_result *res = parsed_result;
7829 : 0 : if (!strcmp(res->what, "info")) {
7830 : 0 : if (!strcmp(res->identifier, "all"))
7831 : 0 : device_infos_display(NULL);
7832 : : else
7833 : 0 : device_infos_display(res->identifier);
7834 : : }
7835 : 0 : }
7836 : :
7837 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7838 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7839 : : "show");
7840 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7841 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7842 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7843 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7844 : : "info");
7845 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7846 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7847 : : identifier, NULL);
7848 : :
7849 : : static cmdline_parse_inst_t cmd_showdevice = {
7850 : : .f = cmd_showdevice_parsed,
7851 : : .data = NULL,
7852 : : .help_str = "show device info <identifier>|all",
7853 : : .tokens = {
7854 : : (void *)&cmd_showdevice_show,
7855 : : (void *)&cmd_showdevice_device,
7856 : : (void *)&cmd_showdevice_what,
7857 : : (void *)&cmd_showdevice_identifier,
7858 : : NULL,
7859 : : },
7860 : : };
7861 : :
7862 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7863 : : struct cmd_showeeprom_result {
7864 : : cmdline_fixed_string_t show;
7865 : : cmdline_fixed_string_t port;
7866 : : uint16_t portnum;
7867 : : cmdline_fixed_string_t type;
7868 : : };
7869 : :
7870 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7871 : : __rte_unused struct cmdline *cl,
7872 : : __rte_unused void *data)
7873 : : {
7874 : : struct cmd_showeeprom_result *res = parsed_result;
7875 : :
7876 : 0 : if (!strcmp(res->type, "eeprom"))
7877 : 0 : port_eeprom_display(res->portnum);
7878 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7879 : 0 : port_module_eeprom_display(res->portnum);
7880 : : else
7881 : 0 : fprintf(stderr, "Unknown argument\n");
7882 : 0 : }
7883 : :
7884 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7885 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7886 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7887 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7888 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7889 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7890 : : RTE_UINT16);
7891 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7892 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7893 : :
7894 : : static cmdline_parse_inst_t cmd_showeeprom = {
7895 : : .f = cmd_showeeprom_parsed,
7896 : : .data = NULL,
7897 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7898 : : .tokens = {
7899 : : (void *)&cmd_showeeprom_show,
7900 : : (void *)&cmd_showeeprom_port,
7901 : : (void *)&cmd_showeeprom_portnum,
7902 : : (void *)&cmd_showeeprom_type,
7903 : : NULL,
7904 : : },
7905 : : };
7906 : :
7907 : : struct cmd_showeeprom_decode_result {
7908 : : cmdline_fixed_string_t show;
7909 : : cmdline_fixed_string_t port;
7910 : : uint16_t portnum;
7911 : : cmdline_fixed_string_t module_eeprom;
7912 : : cmdline_fixed_string_t decode;
7913 : : };
7914 : :
7915 : 0 : static void cmd_showeeprom_decode_parsed(void *parsed_result,
7916 : : __rte_unused struct cmdline *cl,
7917 : : __rte_unused void *data)
7918 : : {
7919 : : struct cmd_showeeprom_decode_result *res = parsed_result;
7920 : :
7921 : 0 : port_module_eeprom_decode_display(res->portnum);
7922 : 0 : }
7923 : :
7924 : : static cmdline_parse_token_string_t cmd_showeeprom_decode_show =
7925 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_decode_result, show, "show");
7926 : : static cmdline_parse_token_string_t cmd_showeeprom_decode_port =
7927 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_decode_result, port, "port");
7928 : : static cmdline_parse_token_num_t cmd_showeeprom_decode_portnum =
7929 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_decode_result, portnum,
7930 : : RTE_UINT16);
7931 : : static cmdline_parse_token_string_t cmd_showeeprom_decode_module_eeprom =
7932 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_decode_result, module_eeprom,
7933 : : "module_eeprom");
7934 : : static cmdline_parse_token_string_t cmd_showeeprom_decode_decode =
7935 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_decode_result, decode, "decode");
7936 : :
7937 : : static cmdline_parse_inst_t cmd_showeeprom_decode = {
7938 : : .f = cmd_showeeprom_decode_parsed,
7939 : : .data = NULL,
7940 : : .help_str = "show port <port_id> module_eeprom decode",
7941 : : .tokens = {
7942 : : (void *)&cmd_showeeprom_decode_show,
7943 : : (void *)&cmd_showeeprom_decode_port,
7944 : : (void *)&cmd_showeeprom_decode_portnum,
7945 : : (void *)&cmd_showeeprom_decode_module_eeprom,
7946 : : (void *)&cmd_showeeprom_decode_decode,
7947 : : NULL,
7948 : : },
7949 : : };
7950 : :
7951 : : /* *** SET PORT EEPROM *** */
7952 : : struct cmd_seteeprom_result {
7953 : : cmdline_fixed_string_t set;
7954 : : cmdline_fixed_string_t port;
7955 : : uint16_t portnum;
7956 : : cmdline_fixed_string_t eeprom;
7957 : : cmdline_fixed_string_t confirm_str;
7958 : : cmdline_fixed_string_t magic_str;
7959 : : uint32_t magic;
7960 : : cmdline_fixed_string_t value;
7961 : : cmdline_multi_string_t token_str;
7962 : : };
7963 : :
7964 : 0 : static void cmd_seteeprom_parsed(void *parsed_result,
7965 : : __rte_unused struct cmdline *cl,
7966 : : __rte_unused void *data)
7967 : : {
7968 : : struct cmd_seteeprom_result *res = parsed_result;
7969 : : uint32_t offset = 0;
7970 : : uint32_t length;
7971 : : uint8_t *value;
7972 : : char *token_str;
7973 : : char *token;
7974 : :
7975 : 0 : token_str = res->token_str;
7976 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7977 : :
7978 : : /* Parse Hex string to Byte data */
7979 : 0 : if (strlen(token) % 2 != 0) {
7980 : 0 : fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
7981 : : token);
7982 : 0 : return;
7983 : : }
7984 : :
7985 : 0 : length = strlen(token) / 2;
7986 : 0 : value = calloc(length, sizeof(uint8_t));
7987 : 0 : for (int count = 0; count < (int)(length); count++) {
7988 : 0 : if (sscanf(token, "%2hhx", &value[count]) != 1) {
7989 : 0 : fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
7990 : 0 : token - (count + 1));
7991 : 0 : goto out;
7992 : : }
7993 : 0 : token += 2;
7994 : : }
7995 : :
7996 : : /* Second token: offset string */
7997 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7998 : 0 : if (token != NULL) {
7999 : 0 : if (strcmp(token, "offset") == 0) {
8000 : : /* Third token: offset */
8001 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
8002 : 0 : if (token == NULL) {
8003 : 0 : fprintf(stderr, "No offset specified\n");
8004 : 0 : goto out;
8005 : : }
8006 : :
8007 : : char *end;
8008 : 0 : offset = strtoul(token, &end, 10);
8009 : 0 : if (offset == 0 && strcmp(end, "") != 0) {
8010 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
8011 : 0 : goto out;
8012 : : }
8013 : : } else {
8014 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
8015 : 0 : goto out;
8016 : : }
8017 : : }
8018 : :
8019 : 0 : port_eeprom_set(res->portnum, res->magic, offset, length, value);
8020 : :
8021 : 0 : out:
8022 : 0 : free(value);
8023 : : }
8024 : :
8025 : : static cmdline_parse_token_string_t cmd_seteeprom_set =
8026 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
8027 : : static cmdline_parse_token_string_t cmd_seteeprom_port =
8028 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
8029 : : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
8030 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
8031 : : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
8032 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
8033 : : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
8034 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
8035 : : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
8036 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
8037 : : static cmdline_parse_token_num_t cmd_seteeprom_magic =
8038 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
8039 : : static cmdline_parse_token_string_t cmd_seteeprom_value =
8040 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
8041 : : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
8042 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
8043 : :
8044 : : static cmdline_parse_inst_t cmd_seteeprom = {
8045 : : .f = cmd_seteeprom_parsed,
8046 : : .data = NULL,
8047 : : .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
8048 : : "value <value> offset <offset>: Set eeprom value for port_id.\n"
8049 : : "Note:\n"
8050 : : "This is a high-risk command and its misuse may result in "
8051 : : "unexpected behaviour from the NIC.\n"
8052 : : "By inserting \"accept_risk\" into the command, the user is "
8053 : : "acknowledging and taking responsibility for this risk.",
8054 : : .tokens = {
8055 : : (void *)&cmd_seteeprom_set,
8056 : : (void *)&cmd_seteeprom_port,
8057 : : (void *)&cmd_seteeprom_portnum,
8058 : : (void *)&cmd_seteeprom_eeprom,
8059 : : (void *)&cmd_seteeprom_confirm_str,
8060 : : (void *)&cmd_seteeprom_magic_str,
8061 : : (void *)&cmd_seteeprom_magic,
8062 : : (void *)&cmd_seteeprom_value,
8063 : : (void *)&cmd_seteeprom_token_str,
8064 : : NULL,
8065 : : },
8066 : : };
8067 : :
8068 : : /* *** SHOW QUEUE INFO *** */
8069 : : struct cmd_showqueue_result {
8070 : : cmdline_fixed_string_t show;
8071 : : cmdline_fixed_string_t type;
8072 : : cmdline_fixed_string_t what;
8073 : : uint16_t portnum;
8074 : : uint16_t queuenum;
8075 : : };
8076 : :
8077 : : static void
8078 : 0 : cmd_showqueue_parsed(void *parsed_result,
8079 : : __rte_unused struct cmdline *cl,
8080 : : __rte_unused void *data)
8081 : : {
8082 : : struct cmd_showqueue_result *res = parsed_result;
8083 : :
8084 : 0 : if (!strcmp(res->type, "rxq"))
8085 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
8086 : 0 : else if (!strcmp(res->type, "txq"))
8087 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
8088 : 0 : }
8089 : :
8090 : : static cmdline_parse_token_string_t cmd_showqueue_show =
8091 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8092 : : static cmdline_parse_token_string_t cmd_showqueue_type =
8093 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8094 : : static cmdline_parse_token_string_t cmd_showqueue_what =
8095 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8096 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
8097 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8098 : : RTE_UINT16);
8099 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
8100 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8101 : : RTE_UINT16);
8102 : :
8103 : : static cmdline_parse_inst_t cmd_showqueue = {
8104 : : .f = cmd_showqueue_parsed,
8105 : : .data = NULL,
8106 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
8107 : : .tokens = {
8108 : : (void *)&cmd_showqueue_show,
8109 : : (void *)&cmd_showqueue_type,
8110 : : (void *)&cmd_showqueue_what,
8111 : : (void *)&cmd_showqueue_portnum,
8112 : : (void *)&cmd_showqueue_queuenum,
8113 : : NULL,
8114 : : },
8115 : : };
8116 : :
8117 : : /* show/clear fwd engine statistics */
8118 : : struct fwd_result {
8119 : : cmdline_fixed_string_t action;
8120 : : cmdline_fixed_string_t fwd;
8121 : : cmdline_fixed_string_t stats;
8122 : : cmdline_fixed_string_t all;
8123 : : };
8124 : :
8125 : : static cmdline_parse_token_string_t cmd_fwd_action =
8126 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8127 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
8128 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8129 : : static cmdline_parse_token_string_t cmd_fwd_stats =
8130 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8131 : : static cmdline_parse_token_string_t cmd_fwd_all =
8132 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8133 : :
8134 : : static void
8135 : 0 : cmd_showfwdall_parsed(void *parsed_result,
8136 : : __rte_unused struct cmdline *cl,
8137 : : __rte_unused void *data)
8138 : : {
8139 : : struct fwd_result *res = parsed_result;
8140 : :
8141 : 0 : if (!strcmp(res->action, "show"))
8142 : 0 : fwd_stats_display();
8143 : : else
8144 : 0 : fwd_stats_reset();
8145 : 0 : }
8146 : :
8147 : : static cmdline_parse_inst_t cmd_showfwdall = {
8148 : : .f = cmd_showfwdall_parsed,
8149 : : .data = NULL,
8150 : : .help_str = "show|clear fwd stats all",
8151 : : .tokens = {
8152 : : (void *)&cmd_fwd_action,
8153 : : (void *)&cmd_fwd_fwd,
8154 : : (void *)&cmd_fwd_stats,
8155 : : (void *)&cmd_fwd_all,
8156 : : NULL,
8157 : : },
8158 : : };
8159 : :
8160 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8161 : : struct cmd_read_rxd_txd_result {
8162 : : cmdline_fixed_string_t read;
8163 : : cmdline_fixed_string_t rxd_txd;
8164 : : portid_t port_id;
8165 : : uint16_t queue_id;
8166 : : uint16_t desc_id;
8167 : : };
8168 : :
8169 : : static void
8170 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
8171 : : __rte_unused struct cmdline *cl,
8172 : : __rte_unused void *data)
8173 : : {
8174 : : struct cmd_read_rxd_txd_result *res = parsed_result;
8175 : :
8176 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
8177 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8178 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
8179 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8180 : 0 : }
8181 : :
8182 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8183 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8184 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8185 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8186 : : "rxd#txd");
8187 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8188 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8189 : : RTE_UINT16);
8190 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8191 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8192 : : RTE_UINT16);
8193 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8194 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8195 : : RTE_UINT16);
8196 : :
8197 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
8198 : : .f = cmd_read_rxd_txd_parsed,
8199 : : .data = NULL,
8200 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8201 : : .tokens = {
8202 : : (void *)&cmd_read_rxd_txd_read,
8203 : : (void *)&cmd_read_rxd_txd_rxd_txd,
8204 : : (void *)&cmd_read_rxd_txd_port_id,
8205 : : (void *)&cmd_read_rxd_txd_queue_id,
8206 : : (void *)&cmd_read_rxd_txd_desc_id,
8207 : : NULL,
8208 : : },
8209 : : };
8210 : :
8211 : : /* *** QUIT *** */
8212 : : struct cmd_quit_result {
8213 : : cmdline_fixed_string_t quit;
8214 : : };
8215 : :
8216 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
8217 : : struct cmdline *cl,
8218 : : __rte_unused void *data)
8219 : : {
8220 : 0 : cmdline_quit(cl);
8221 : 0 : cl_quit = 1;
8222 : 0 : }
8223 : :
8224 : : static cmdline_parse_token_string_t cmd_quit_quit =
8225 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8226 : :
8227 : : static cmdline_parse_inst_t cmd_quit = {
8228 : : .f = cmd_quit_parsed,
8229 : : .data = NULL,
8230 : : .help_str = "quit: Exit application",
8231 : : .tokens = {
8232 : : (void *)&cmd_quit_quit,
8233 : : NULL,
8234 : : },
8235 : : };
8236 : :
8237 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8238 : : struct cmd_mac_addr_result {
8239 : : cmdline_fixed_string_t mac_addr_cmd;
8240 : : cmdline_fixed_string_t what;
8241 : : uint16_t port_num;
8242 : : struct rte_ether_addr address;
8243 : : };
8244 : :
8245 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
8246 : : __rte_unused struct cmdline *cl,
8247 : : __rte_unused void *data)
8248 : : {
8249 : : struct cmd_mac_addr_result *res = parsed_result;
8250 : : int ret;
8251 : :
8252 : 0 : if (strcmp(res->what, "add") == 0)
8253 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8254 : 0 : else if (strcmp(res->what, "set") == 0)
8255 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8256 : : &res->address);
8257 : : else
8258 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8259 : :
8260 : : /* check the return value and print it if is < 0 */
8261 : 0 : if(ret < 0)
8262 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8263 : :
8264 : 0 : }
8265 : :
8266 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
8267 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8268 : : "mac_addr");
8269 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
8270 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8271 : : "add#remove#set");
8272 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
8273 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8274 : : RTE_UINT16);
8275 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8276 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8277 : :
8278 : : static cmdline_parse_inst_t cmd_mac_addr = {
8279 : : .f = cmd_mac_addr_parsed,
8280 : : .data = (void *)0,
8281 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8282 : : "Add/Remove/Set MAC address on port_id",
8283 : : .tokens = {
8284 : : (void *)&cmd_mac_addr_cmd,
8285 : : (void *)&cmd_mac_addr_what,
8286 : : (void *)&cmd_mac_addr_portnum,
8287 : : (void *)&cmd_mac_addr_addr,
8288 : : NULL,
8289 : : },
8290 : : };
8291 : :
8292 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8293 : : struct cmd_eth_peer_result {
8294 : : cmdline_fixed_string_t set;
8295 : : cmdline_fixed_string_t eth_peer;
8296 : : portid_t port_id;
8297 : : cmdline_fixed_string_t peer_addr;
8298 : : };
8299 : :
8300 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
8301 : : __rte_unused struct cmdline *cl,
8302 : : __rte_unused void *data)
8303 : : {
8304 : : struct cmd_eth_peer_result *res = parsed_result;
8305 : :
8306 : 0 : if (test_done == 0) {
8307 : 0 : fprintf(stderr, "Please stop forwarding first\n");
8308 : 0 : return;
8309 : : }
8310 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
8311 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
8312 : 0 : fwd_config_setup();
8313 : : }
8314 : : }
8315 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
8316 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8317 : : static cmdline_parse_token_string_t cmd_eth_peer =
8318 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8319 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
8320 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8321 : : RTE_UINT16);
8322 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
8323 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8324 : :
8325 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8326 : : .f = cmd_set_eth_peer_parsed,
8327 : : .data = NULL,
8328 : : .help_str = "set eth-peer <port_id> <peer_mac>",
8329 : : .tokens = {
8330 : : (void *)&cmd_eth_peer_set,
8331 : : (void *)&cmd_eth_peer,
8332 : : (void *)&cmd_eth_peer_port_id,
8333 : : (void *)&cmd_eth_peer_addr,
8334 : : NULL,
8335 : : },
8336 : : };
8337 : :
8338 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8339 : : struct cmd_set_xstats_hide_zero_result {
8340 : : cmdline_fixed_string_t keyword;
8341 : : cmdline_fixed_string_t name;
8342 : : cmdline_fixed_string_t on_off;
8343 : : };
8344 : :
8345 : : static void
8346 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8347 : : __rte_unused struct cmdline *cl,
8348 : : __rte_unused void *data)
8349 : : {
8350 : : struct cmd_set_xstats_hide_zero_result *res;
8351 : : uint16_t on_off = 0;
8352 : :
8353 : : res = parsed_result;
8354 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8355 : 0 : set_xstats_hide_zero(on_off);
8356 : 0 : }
8357 : :
8358 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8359 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8360 : : keyword, "set");
8361 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8362 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8363 : : name, "xstats-hide-zero");
8364 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8365 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8366 : : on_off, "on#off");
8367 : :
8368 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8369 : : .f = cmd_set_xstats_hide_zero_parsed,
8370 : : .data = NULL,
8371 : : .help_str = "set xstats-hide-zero on|off",
8372 : : .tokens = {
8373 : : (void *)&cmd_set_xstats_hide_zero_keyword,
8374 : : (void *)&cmd_set_xstats_hide_zero_name,
8375 : : (void *)&cmd_set_xstats_hide_zero_on_off,
8376 : : NULL,
8377 : : },
8378 : : };
8379 : :
8380 : : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
8381 : : struct cmd_set_xstats_show_state_result {
8382 : : cmdline_fixed_string_t keyword;
8383 : : cmdline_fixed_string_t name;
8384 : : uint8_t on_off;
8385 : : };
8386 : : static void
8387 : 0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
8388 : : __rte_unused struct cmdline *cl,
8389 : : __rte_unused void *data)
8390 : : {
8391 : : struct cmd_set_xstats_show_state_result *res = parsed_result;
8392 : 0 : set_xstats_show_state(res->on_off);
8393 : 0 : }
8394 : :
8395 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
8396 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8397 : : keyword, "set");
8398 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
8399 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8400 : : name, "xstats-show-state");
8401 : : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
8402 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
8403 : : on_off);
8404 : :
8405 : : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
8406 : : .f = cmd_set_xstats_show_state_parsed,
8407 : : .data = NULL,
8408 : : .help_str = "set xstats-show-state on|off",
8409 : : .tokens = {
8410 : : (void *)&cmd_set_xstats_show_state_keyword,
8411 : : (void *)&cmd_set_xstats_show_state_name,
8412 : : (void *)&cmd_set_xstats_show_state_on_off,
8413 : : NULL,
8414 : : },
8415 : : };
8416 : :
8417 : : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
8418 : : struct cmd_set_xstats_hide_disabled_result {
8419 : : cmdline_fixed_string_t keyword;
8420 : : cmdline_fixed_string_t name;
8421 : : uint8_t on_off;
8422 : : };
8423 : :
8424 : : static void
8425 : 0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
8426 : : __rte_unused struct cmdline *cl,
8427 : : __rte_unused void *data)
8428 : : {
8429 : : struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
8430 : 0 : set_xstats_hide_disabled(res->on_off);
8431 : 0 : }
8432 : :
8433 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
8434 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8435 : : keyword, "set");
8436 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
8437 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8438 : : name, "xstats-hide-disabled");
8439 : : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
8440 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8441 : : on_off);
8442 : :
8443 : : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
8444 : : .f = cmd_set_xstats_hide_disabled_parsed,
8445 : : .data = NULL,
8446 : : .help_str = "set xstats-hide-disabled on|off",
8447 : : .tokens = {
8448 : : (void *)&cmd_set_xstats_hide_disabled_keyword,
8449 : : (void *)&cmd_set_xstats_hide_disabled_name,
8450 : : (void *)&cmd_set_xstats_hide_disabled_on_off,
8451 : : NULL,
8452 : : },
8453 : : };
8454 : :
8455 : : /* *** enable/disable counter by name *** */
8456 : : struct cmd_operate_set_counter_result {
8457 : : cmdline_fixed_string_t port;
8458 : : portid_t port_id;
8459 : : cmdline_fixed_string_t what;
8460 : : cmdline_multi_string_t counter_name;
8461 : : };
8462 : :
8463 : : static void
8464 : 0 : cmd_operate_set_counter_parsed(void *parsed_result,
8465 : : __rte_unused struct cmdline *cl,
8466 : : __rte_unused void *data)
8467 : : {
8468 : : struct cmd_operate_set_counter_result *res = parsed_result;
8469 : 0 : uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
8470 : :
8471 : 0 : if ((strcmp(res->port, "port") == 0))
8472 : 0 : nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
8473 : 0 : }
8474 : :
8475 : : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
8476 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8477 : : port, "port");
8478 : : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
8479 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
8480 : : port_id, RTE_UINT16);
8481 : : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
8482 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8483 : : what, "enable#disable");
8484 : : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
8485 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8486 : : counter_name, TOKEN_STRING_MULTI);
8487 : :
8488 : : static cmdline_parse_inst_t cmd_operate_set_counter = {
8489 : : .f = cmd_operate_set_counter_parsed,
8490 : : .data = NULL,
8491 : : .help_str = "port (port_id) enable|disable <counter_name>",
8492 : : .tokens = {
8493 : : (void *)&cmd_operate_set_counter_port,
8494 : : (void *)&cmd_operate_set_counter_port_id,
8495 : : (void *)&cmd_operate_set_counter_what,
8496 : : (void *)&cmd_operate_set_counter_name,
8497 : : NULL,
8498 : : },
8499 : : };
8500 : :
8501 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8502 : : struct cmd_set_record_core_cycles_result {
8503 : : cmdline_fixed_string_t keyword;
8504 : : cmdline_fixed_string_t name;
8505 : : cmdline_fixed_string_t on_off;
8506 : : };
8507 : :
8508 : : static void
8509 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
8510 : : __rte_unused struct cmdline *cl,
8511 : : __rte_unused void *data)
8512 : : {
8513 : : struct cmd_set_record_core_cycles_result *res;
8514 : : uint16_t on_off = 0;
8515 : :
8516 : : res = parsed_result;
8517 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8518 : 0 : set_record_core_cycles(on_off);
8519 : 0 : }
8520 : :
8521 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8522 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8523 : : keyword, "set");
8524 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8525 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8526 : : name, "record-core-cycles");
8527 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8528 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8529 : : on_off, "on#off");
8530 : :
8531 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
8532 : : .f = cmd_set_record_core_cycles_parsed,
8533 : : .data = NULL,
8534 : : .help_str = "set record-core-cycles on|off",
8535 : : .tokens = {
8536 : : (void *)&cmd_set_record_core_cycles_keyword,
8537 : : (void *)&cmd_set_record_core_cycles_name,
8538 : : (void *)&cmd_set_record_core_cycles_on_off,
8539 : : NULL,
8540 : : },
8541 : : };
8542 : :
8543 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8544 : : struct cmd_set_record_burst_stats_result {
8545 : : cmdline_fixed_string_t keyword;
8546 : : cmdline_fixed_string_t name;
8547 : : cmdline_fixed_string_t on_off;
8548 : : };
8549 : :
8550 : : static void
8551 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
8552 : : __rte_unused struct cmdline *cl,
8553 : : __rte_unused void *data)
8554 : : {
8555 : : struct cmd_set_record_burst_stats_result *res;
8556 : : uint16_t on_off = 0;
8557 : :
8558 : : res = parsed_result;
8559 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8560 : 0 : set_record_burst_stats(on_off);
8561 : 0 : }
8562 : :
8563 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8564 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8565 : : keyword, "set");
8566 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8567 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8568 : : name, "record-burst-stats");
8569 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8570 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8571 : : on_off, "on#off");
8572 : :
8573 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
8574 : : .f = cmd_set_record_burst_stats_parsed,
8575 : : .data = NULL,
8576 : : .help_str = "set record-burst-stats on|off",
8577 : : .tokens = {
8578 : : (void *)&cmd_set_record_burst_stats_keyword,
8579 : : (void *)&cmd_set_record_burst_stats_name,
8580 : : (void *)&cmd_set_record_burst_stats_on_off,
8581 : : NULL,
8582 : : },
8583 : : };
8584 : :
8585 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
8586 : : struct cmd_set_uc_hash_table {
8587 : : cmdline_fixed_string_t set;
8588 : : cmdline_fixed_string_t port;
8589 : : portid_t port_id;
8590 : : cmdline_fixed_string_t what;
8591 : : struct rte_ether_addr address;
8592 : : cmdline_fixed_string_t mode;
8593 : : };
8594 : :
8595 : : static void
8596 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
8597 : : __rte_unused struct cmdline *cl,
8598 : : __rte_unused void *data)
8599 : : {
8600 : : int ret=0;
8601 : : struct cmd_set_uc_hash_table *res = parsed_result;
8602 : :
8603 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8604 : :
8605 : 0 : if (strcmp(res->what, "uta") == 0)
8606 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8607 : : &res->address,(uint8_t)is_on);
8608 : 0 : if (ret < 0)
8609 : 0 : fprintf(stderr,
8610 : : "bad unicast hash table parameter, return code = %d\n",
8611 : : ret);
8612 : :
8613 : 0 : }
8614 : :
8615 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
8616 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8617 : : set, "set");
8618 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
8619 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8620 : : port, "port");
8621 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8622 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8623 : : port_id, RTE_UINT16);
8624 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
8625 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8626 : : what, "uta");
8627 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8628 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8629 : : address);
8630 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8631 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8632 : : mode, "on#off");
8633 : :
8634 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8635 : : .f = cmd_set_uc_hash_parsed,
8636 : : .data = NULL,
8637 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
8638 : : .tokens = {
8639 : : (void *)&cmd_set_uc_hash_set,
8640 : : (void *)&cmd_set_uc_hash_port,
8641 : : (void *)&cmd_set_uc_hash_portid,
8642 : : (void *)&cmd_set_uc_hash_what,
8643 : : (void *)&cmd_set_uc_hash_mac,
8644 : : (void *)&cmd_set_uc_hash_mode,
8645 : : NULL,
8646 : : },
8647 : : };
8648 : :
8649 : : struct cmd_set_uc_all_hash_table {
8650 : : cmdline_fixed_string_t set;
8651 : : cmdline_fixed_string_t port;
8652 : : portid_t port_id;
8653 : : cmdline_fixed_string_t what;
8654 : : cmdline_fixed_string_t value;
8655 : : cmdline_fixed_string_t mode;
8656 : : };
8657 : :
8658 : : static void
8659 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
8660 : : __rte_unused struct cmdline *cl,
8661 : : __rte_unused void *data)
8662 : : {
8663 : : int ret=0;
8664 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
8665 : :
8666 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8667 : :
8668 : 0 : if ((strcmp(res->what, "uta") == 0) &&
8669 : 0 : (strcmp(res->value, "all") == 0))
8670 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8671 : 0 : if (ret < 0)
8672 : 0 : fprintf(stderr,
8673 : : "bad unicast hash table parameter, return code = %d\n",
8674 : : ret);
8675 : 0 : }
8676 : :
8677 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8678 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8679 : : set, "set");
8680 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8681 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8682 : : port, "port");
8683 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8684 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8685 : : port_id, RTE_UINT16);
8686 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8687 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8688 : : what, "uta");
8689 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8690 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8691 : : value,"all");
8692 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8693 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8694 : : mode, "on#off");
8695 : :
8696 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8697 : : .f = cmd_set_uc_all_hash_parsed,
8698 : : .data = NULL,
8699 : : .help_str = "set port <port_id> uta all on|off",
8700 : : .tokens = {
8701 : : (void *)&cmd_set_uc_all_hash_set,
8702 : : (void *)&cmd_set_uc_all_hash_port,
8703 : : (void *)&cmd_set_uc_all_hash_portid,
8704 : : (void *)&cmd_set_uc_all_hash_what,
8705 : : (void *)&cmd_set_uc_all_hash_value,
8706 : : (void *)&cmd_set_uc_all_hash_mode,
8707 : : NULL,
8708 : : },
8709 : : };
8710 : :
8711 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8712 : : struct cmd_set_vf_traffic {
8713 : : cmdline_fixed_string_t set;
8714 : : cmdline_fixed_string_t port;
8715 : : portid_t port_id;
8716 : : cmdline_fixed_string_t vf;
8717 : : uint8_t vf_id;
8718 : : cmdline_fixed_string_t what;
8719 : : cmdline_fixed_string_t mode;
8720 : : };
8721 : :
8722 : : static void
8723 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
8724 : : __rte_unused struct cmdline *cl,
8725 : : __rte_unused void *data)
8726 : : {
8727 : : struct cmd_set_vf_traffic *res = parsed_result;
8728 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8729 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8730 : :
8731 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8732 : 0 : }
8733 : :
8734 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
8735 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8736 : : set, "set");
8737 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
8738 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8739 : : port, "port");
8740 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8741 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8742 : : port_id, RTE_UINT16);
8743 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8744 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8745 : : vf, "vf");
8746 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8747 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8748 : : vf_id, RTE_UINT8);
8749 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
8750 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8751 : : what, "tx#rx");
8752 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8753 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8754 : : mode, "on#off");
8755 : :
8756 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
8757 : : .f = cmd_set_vf_traffic_parsed,
8758 : : .data = NULL,
8759 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8760 : : .tokens = {
8761 : : (void *)&cmd_setvf_traffic_set,
8762 : : (void *)&cmd_setvf_traffic_port,
8763 : : (void *)&cmd_setvf_traffic_portid,
8764 : : (void *)&cmd_setvf_traffic_vf,
8765 : : (void *)&cmd_setvf_traffic_vfid,
8766 : : (void *)&cmd_setvf_traffic_what,
8767 : : (void *)&cmd_setvf_traffic_mode,
8768 : : NULL,
8769 : : },
8770 : : };
8771 : :
8772 : : /* *** CONFIGURE VF RECEIVE MODE *** */
8773 : : struct cmd_set_vf_rxmode {
8774 : : cmdline_fixed_string_t set;
8775 : : cmdline_fixed_string_t port;
8776 : : portid_t port_id;
8777 : : cmdline_fixed_string_t vf;
8778 : : uint8_t vf_id;
8779 : : cmdline_fixed_string_t what;
8780 : : cmdline_fixed_string_t mode;
8781 : : cmdline_fixed_string_t on;
8782 : : };
8783 : :
8784 : : static void
8785 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
8786 : : __rte_unused struct cmdline *cl,
8787 : : __rte_unused void *data)
8788 : : {
8789 : : int ret = -ENOTSUP;
8790 : : uint16_t vf_rxmode = 0;
8791 : : struct cmd_set_vf_rxmode *res = parsed_result;
8792 : :
8793 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8794 : 0 : if (!strcmp(res->what,"rxmode")) {
8795 : 0 : if (!strcmp(res->mode, "AUPE"))
8796 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
8797 : 0 : else if (!strcmp(res->mode, "ROPE"))
8798 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
8799 : 0 : else if (!strcmp(res->mode, "BAM"))
8800 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
8801 : 0 : else if (!strncmp(res->mode, "MPE",3))
8802 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
8803 : : }
8804 : :
8805 : : RTE_SET_USED(is_on);
8806 : : RTE_SET_USED(vf_rxmode);
8807 : :
8808 : : #ifdef RTE_NET_IXGBE
8809 : : if (ret == -ENOTSUP)
8810 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8811 : : vf_rxmode, (uint8_t)is_on);
8812 : : #endif
8813 : : #ifdef RTE_NET_BNXT
8814 : 0 : if (ret == -ENOTSUP)
8815 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8816 : : vf_rxmode, (uint8_t)is_on);
8817 : : #endif
8818 : 0 : if (ret < 0)
8819 : 0 : fprintf(stderr,
8820 : : "bad VF receive mode parameter, return code = %d\n",
8821 : : ret);
8822 : 0 : }
8823 : :
8824 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8825 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8826 : : set, "set");
8827 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8828 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8829 : : port, "port");
8830 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8831 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8832 : : port_id, RTE_UINT16);
8833 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8834 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8835 : : vf, "vf");
8836 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8837 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8838 : : vf_id, RTE_UINT8);
8839 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8840 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8841 : : what, "rxmode");
8842 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8843 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8844 : : mode, "AUPE#ROPE#BAM#MPE");
8845 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8846 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8847 : : on, "on#off");
8848 : :
8849 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
8850 : : .f = cmd_set_vf_rxmode_parsed,
8851 : : .data = NULL,
8852 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
8853 : : "AUPE|ROPE|BAM|MPE on|off",
8854 : : .tokens = {
8855 : : (void *)&cmd_set_vf_rxmode_set,
8856 : : (void *)&cmd_set_vf_rxmode_port,
8857 : : (void *)&cmd_set_vf_rxmode_portid,
8858 : : (void *)&cmd_set_vf_rxmode_vf,
8859 : : (void *)&cmd_set_vf_rxmode_vfid,
8860 : : (void *)&cmd_set_vf_rxmode_what,
8861 : : (void *)&cmd_set_vf_rxmode_mode,
8862 : : (void *)&cmd_set_vf_rxmode_on,
8863 : : NULL,
8864 : : },
8865 : : };
8866 : :
8867 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8868 : : struct cmd_vf_mac_addr_result {
8869 : : cmdline_fixed_string_t mac_addr_cmd;
8870 : : cmdline_fixed_string_t what;
8871 : : cmdline_fixed_string_t port;
8872 : : uint16_t port_num;
8873 : : cmdline_fixed_string_t vf;
8874 : : uint8_t vf_num;
8875 : : struct rte_ether_addr address;
8876 : : };
8877 : :
8878 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
8879 : : __rte_unused struct cmdline *cl,
8880 : : __rte_unused void *data)
8881 : : {
8882 : : struct cmd_vf_mac_addr_result *res = parsed_result;
8883 : : int ret = -ENOTSUP;
8884 : :
8885 : 0 : if (strcmp(res->what, "add") != 0)
8886 : : return;
8887 : :
8888 : : #ifdef RTE_NET_I40E
8889 : : if (ret == -ENOTSUP)
8890 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8891 : : &res->address);
8892 : : #endif
8893 : : #ifdef RTE_NET_BNXT
8894 : 0 : if (ret == -ENOTSUP)
8895 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8896 : 0 : res->vf_num);
8897 : : #endif
8898 : :
8899 : 0 : if(ret < 0)
8900 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8901 : :
8902 : : }
8903 : :
8904 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8905 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8906 : : mac_addr_cmd,"mac_addr");
8907 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8908 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8909 : : what,"add");
8910 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8911 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8912 : : port,"port");
8913 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8914 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8915 : : port_num, RTE_UINT16);
8916 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8917 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8918 : : vf,"vf");
8919 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8920 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8921 : : vf_num, RTE_UINT8);
8922 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8923 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8924 : : address);
8925 : :
8926 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8927 : : .f = cmd_vf_mac_addr_parsed,
8928 : : .data = (void *)0,
8929 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8930 : : "Add MAC address filtering for a VF on port_id",
8931 : : .tokens = {
8932 : : (void *)&cmd_vf_mac_addr_cmd,
8933 : : (void *)&cmd_vf_mac_addr_what,
8934 : : (void *)&cmd_vf_mac_addr_port,
8935 : : (void *)&cmd_vf_mac_addr_portnum,
8936 : : (void *)&cmd_vf_mac_addr_vf,
8937 : : (void *)&cmd_vf_mac_addr_vfnum,
8938 : : (void *)&cmd_vf_mac_addr_addr,
8939 : : NULL,
8940 : : },
8941 : : };
8942 : :
8943 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8944 : : struct cmd_vf_rx_vlan_filter {
8945 : : cmdline_fixed_string_t rx_vlan;
8946 : : cmdline_fixed_string_t what;
8947 : : uint16_t vlan_id;
8948 : : cmdline_fixed_string_t port;
8949 : : portid_t port_id;
8950 : : cmdline_fixed_string_t vf;
8951 : : uint64_t vf_mask;
8952 : : };
8953 : :
8954 : : static void
8955 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8956 : : __rte_unused struct cmdline *cl,
8957 : : __rte_unused void *data)
8958 : : {
8959 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8960 : : int ret = -ENOTSUP;
8961 : :
8962 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8963 : :
8964 : : #ifdef RTE_NET_IXGBE
8965 : : if (ret == -ENOTSUP)
8966 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8967 : 0 : res->vlan_id, res->vf_mask, is_add);
8968 : : #endif
8969 : : #ifdef RTE_NET_I40E
8970 : 0 : if (ret == -ENOTSUP)
8971 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8972 : 0 : res->vlan_id, res->vf_mask, is_add);
8973 : : #endif
8974 : : #ifdef RTE_NET_BNXT
8975 : 0 : if (ret == -ENOTSUP)
8976 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8977 : 0 : res->vlan_id, res->vf_mask, is_add);
8978 : : #endif
8979 : :
8980 : 0 : switch (ret) {
8981 : : case 0:
8982 : : break;
8983 : 0 : case -EINVAL:
8984 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8985 : 0 : res->vlan_id, res->vf_mask);
8986 : : break;
8987 : 0 : case -ENODEV:
8988 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8989 : : break;
8990 : 0 : case -ENOTSUP:
8991 : 0 : fprintf(stderr, "function not implemented or supported\n");
8992 : : break;
8993 : 0 : default:
8994 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8995 : : }
8996 : 0 : }
8997 : :
8998 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8999 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9000 : : rx_vlan, "rx_vlan");
9001 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
9002 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9003 : : what, "add#rm");
9004 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
9005 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9006 : : vlan_id, RTE_UINT16);
9007 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
9008 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9009 : : port, "port");
9010 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
9011 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9012 : : port_id, RTE_UINT16);
9013 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
9014 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9015 : : vf, "vf");
9016 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
9017 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
9018 : : vf_mask, RTE_UINT64);
9019 : :
9020 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
9021 : : .f = cmd_vf_rx_vlan_filter_parsed,
9022 : : .data = NULL,
9023 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
9024 : : "(vf_mask = hexadecimal VF mask)",
9025 : : .tokens = {
9026 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
9027 : : (void *)&cmd_vf_rx_vlan_filter_what,
9028 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
9029 : : (void *)&cmd_vf_rx_vlan_filter_port,
9030 : : (void *)&cmd_vf_rx_vlan_filter_portid,
9031 : : (void *)&cmd_vf_rx_vlan_filter_vf,
9032 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
9033 : : NULL,
9034 : : },
9035 : : };
9036 : :
9037 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
9038 : : struct cmd_queue_rate_limit_result {
9039 : : cmdline_fixed_string_t set;
9040 : : cmdline_fixed_string_t port;
9041 : : uint16_t port_num;
9042 : : cmdline_fixed_string_t queue;
9043 : : uint8_t queue_num;
9044 : : cmdline_fixed_string_t rate;
9045 : : uint32_t rate_num;
9046 : : };
9047 : :
9048 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
9049 : : __rte_unused struct cmdline *cl,
9050 : : __rte_unused void *data)
9051 : : {
9052 : : struct cmd_queue_rate_limit_result *res = parsed_result;
9053 : : int ret = 0;
9054 : :
9055 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9056 : 0 : && (strcmp(res->queue, "queue") == 0)
9057 : 0 : && (strcmp(res->rate, "rate") == 0))
9058 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
9059 : : res->rate_num);
9060 : 0 : if (ret < 0)
9061 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
9062 : : strerror(-ret));
9063 : :
9064 : 0 : }
9065 : :
9066 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
9067 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9068 : : set, "set");
9069 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
9070 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9071 : : port, "port");
9072 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
9073 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9074 : : port_num, RTE_UINT16);
9075 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9076 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9077 : : queue, "queue");
9078 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9079 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9080 : : queue_num, RTE_UINT8);
9081 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9082 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9083 : : rate, "rate");
9084 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9085 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9086 : : rate_num, RTE_UINT32);
9087 : :
9088 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
9089 : : .f = cmd_queue_rate_limit_parsed,
9090 : : .data = (void *)0,
9091 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9092 : : "Set rate limit for a queue on port_id",
9093 : : .tokens = {
9094 : : (void *)&cmd_queue_rate_limit_set,
9095 : : (void *)&cmd_queue_rate_limit_port,
9096 : : (void *)&cmd_queue_rate_limit_portnum,
9097 : : (void *)&cmd_queue_rate_limit_queue,
9098 : : (void *)&cmd_queue_rate_limit_queuenum,
9099 : : (void *)&cmd_queue_rate_limit_rate,
9100 : : (void *)&cmd_queue_rate_limit_ratenum,
9101 : : NULL,
9102 : : },
9103 : : };
9104 : :
9105 : : /* *** SHOW RATE LIMIT FOR A QUEUE OF A PORT *** */
9106 : : struct cmd_show_queue_rate_limit_result {
9107 : : cmdline_fixed_string_t show;
9108 : : cmdline_fixed_string_t port;
9109 : : uint16_t port_num;
9110 : : cmdline_fixed_string_t queue;
9111 : : uint16_t queue_num;
9112 : : cmdline_fixed_string_t rate;
9113 : : };
9114 : :
9115 : 0 : static void cmd_show_queue_rate_limit_parsed(void *parsed_result,
9116 : : __rte_unused struct cmdline *cl,
9117 : : __rte_unused void *data)
9118 : : {
9119 : : struct cmd_show_queue_rate_limit_result *res = parsed_result;
9120 : 0 : uint32_t tx_rate = 0;
9121 : : int ret;
9122 : :
9123 : 0 : ret = rte_eth_get_queue_rate_limit(res->port_num, res->queue_num,
9124 : : &tx_rate);
9125 : 0 : if (ret) {
9126 : 0 : fprintf(stderr, "Get queue rate limit failed: %s\n",
9127 : : rte_strerror(-ret));
9128 : 0 : return;
9129 : : }
9130 : 0 : if (tx_rate)
9131 : 0 : printf("Port %u Queue %u rate limit: %u Mbps\n",
9132 : 0 : res->port_num, res->queue_num, tx_rate);
9133 : : else
9134 : 0 : printf("Port %u Queue %u rate limit: disabled\n",
9135 : 0 : res->port_num, res->queue_num);
9136 : : }
9137 : :
9138 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_show =
9139 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9140 : : show, "show");
9141 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_port =
9142 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9143 : : port, "port");
9144 : : static cmdline_parse_token_num_t cmd_show_queue_rate_limit_portnum =
9145 : : TOKEN_NUM_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9146 : : port_num, RTE_UINT16);
9147 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_queue =
9148 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9149 : : queue, "queue");
9150 : : static cmdline_parse_token_num_t cmd_show_queue_rate_limit_queuenum =
9151 : : TOKEN_NUM_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9152 : : queue_num, RTE_UINT16);
9153 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_rate =
9154 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9155 : : rate, "rate");
9156 : :
9157 : : static cmdline_parse_inst_t cmd_show_queue_rate_limit = {
9158 : : .f = cmd_show_queue_rate_limit_parsed,
9159 : : .data = NULL,
9160 : : .help_str = "show port <port_id> queue <queue_id> rate: "
9161 : : "Show rate limit for a queue on port_id",
9162 : : .tokens = {
9163 : : (void *)&cmd_show_queue_rate_limit_show,
9164 : : (void *)&cmd_show_queue_rate_limit_port,
9165 : : (void *)&cmd_show_queue_rate_limit_portnum,
9166 : : (void *)&cmd_show_queue_rate_limit_queue,
9167 : : (void *)&cmd_show_queue_rate_limit_queuenum,
9168 : : (void *)&cmd_show_queue_rate_limit_rate,
9169 : : NULL,
9170 : : },
9171 : : };
9172 : :
9173 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9174 : : struct cmd_vf_rate_limit_result {
9175 : : cmdline_fixed_string_t set;
9176 : : cmdline_fixed_string_t port;
9177 : : uint16_t port_num;
9178 : : cmdline_fixed_string_t vf;
9179 : : uint8_t vf_num;
9180 : : cmdline_fixed_string_t rate;
9181 : : uint32_t rate_num;
9182 : : cmdline_fixed_string_t q_msk;
9183 : : uint64_t q_msk_val;
9184 : : };
9185 : :
9186 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
9187 : : __rte_unused struct cmdline *cl,
9188 : : __rte_unused void *data)
9189 : : {
9190 : : struct cmd_vf_rate_limit_result *res = parsed_result;
9191 : : int ret = 0;
9192 : :
9193 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9194 : 0 : && (strcmp(res->vf, "vf") == 0)
9195 : 0 : && (strcmp(res->rate, "rate") == 0)
9196 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
9197 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
9198 : : res->rate_num, res->q_msk_val);
9199 : 0 : if (ret < 0)
9200 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9201 : : strerror(-ret));
9202 : :
9203 : 0 : }
9204 : :
9205 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9206 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9207 : : set, "set");
9208 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9209 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9210 : : port, "port");
9211 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9212 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9213 : : port_num, RTE_UINT16);
9214 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9215 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9216 : : vf, "vf");
9217 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9218 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9219 : : vf_num, RTE_UINT8);
9220 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9221 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9222 : : rate, "rate");
9223 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9224 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9225 : : rate_num, RTE_UINT32);
9226 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9227 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9228 : : q_msk, "queue_mask");
9229 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9230 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9231 : : q_msk_val, RTE_UINT64);
9232 : :
9233 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
9234 : : .f = cmd_vf_rate_limit_parsed,
9235 : : .data = (void *)0,
9236 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9237 : : "queue_mask <queue_mask_value>: "
9238 : : "Set rate limit for queues of VF on port_id",
9239 : : .tokens = {
9240 : : (void *)&cmd_vf_rate_limit_set,
9241 : : (void *)&cmd_vf_rate_limit_port,
9242 : : (void *)&cmd_vf_rate_limit_portnum,
9243 : : (void *)&cmd_vf_rate_limit_vf,
9244 : : (void *)&cmd_vf_rate_limit_vfnum,
9245 : : (void *)&cmd_vf_rate_limit_rate,
9246 : : (void *)&cmd_vf_rate_limit_ratenum,
9247 : : (void *)&cmd_vf_rate_limit_q_msk,
9248 : : (void *)&cmd_vf_rate_limit_q_msk_val,
9249 : : NULL,
9250 : : },
9251 : : };
9252 : :
9253 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
9254 : : struct cmd_tunnel_udp_config {
9255 : : cmdline_fixed_string_t rx_vxlan_port;
9256 : : cmdline_fixed_string_t what;
9257 : : uint16_t udp_port;
9258 : : portid_t port_id;
9259 : : };
9260 : :
9261 : : static void
9262 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
9263 : : __rte_unused struct cmdline *cl,
9264 : : __rte_unused void *data)
9265 : : {
9266 : : struct cmd_tunnel_udp_config *res = parsed_result;
9267 : : struct rte_eth_udp_tunnel tunnel_udp;
9268 : : int ret;
9269 : :
9270 : 0 : tunnel_udp.udp_port = res->udp_port;
9271 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9272 : :
9273 : 0 : if (!strcmp(res->what, "add"))
9274 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9275 : : &tunnel_udp);
9276 : : else
9277 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9278 : : &tunnel_udp);
9279 : :
9280 : 0 : if (ret < 0)
9281 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
9282 : : strerror(-ret));
9283 : 0 : }
9284 : :
9285 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9286 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9287 : : rx_vxlan_port, "rx_vxlan_port");
9288 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9289 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9290 : : what, "add#rm");
9291 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9292 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9293 : : udp_port, RTE_UINT16);
9294 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9295 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9296 : : port_id, RTE_UINT16);
9297 : :
9298 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
9299 : : .f = cmd_tunnel_udp_config_parsed,
9300 : : .data = (void *)0,
9301 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9302 : : "Add/Remove a tunneling UDP port filter",
9303 : : .tokens = {
9304 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9305 : : (void *)&cmd_tunnel_udp_config_what,
9306 : : (void *)&cmd_tunnel_udp_config_udp_port,
9307 : : (void *)&cmd_tunnel_udp_config_port_id,
9308 : : NULL,
9309 : : },
9310 : : };
9311 : :
9312 : : struct cmd_config_tunnel_udp_port {
9313 : : cmdline_fixed_string_t port;
9314 : : cmdline_fixed_string_t config;
9315 : : portid_t port_id;
9316 : : cmdline_fixed_string_t udp_tunnel_port;
9317 : : cmdline_fixed_string_t action;
9318 : : cmdline_fixed_string_t tunnel_type;
9319 : : uint16_t udp_port;
9320 : : };
9321 : :
9322 : : static void
9323 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9324 : : __rte_unused struct cmdline *cl,
9325 : : __rte_unused void *data)
9326 : : {
9327 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
9328 : : struct rte_eth_udp_tunnel tunnel_udp;
9329 : : int ret = 0;
9330 : :
9331 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9332 : 0 : return;
9333 : :
9334 : 0 : tunnel_udp.udp_port = res->udp_port;
9335 : :
9336 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
9337 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9338 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
9339 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9340 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9341 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9342 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
9343 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9344 : : } else {
9345 : 0 : fprintf(stderr, "Invalid tunnel type\n");
9346 : 0 : return;
9347 : : }
9348 : :
9349 : 0 : if (!strcmp(res->action, "add"))
9350 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9351 : : &tunnel_udp);
9352 : : else
9353 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9354 : : &tunnel_udp);
9355 : :
9356 : 0 : if (ret < 0)
9357 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
9358 : : strerror(-ret));
9359 : : }
9360 : :
9361 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9362 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9363 : : "port");
9364 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9365 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9366 : : "config");
9367 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9368 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9369 : : RTE_UINT16);
9370 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9371 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9372 : : udp_tunnel_port,
9373 : : "udp_tunnel_port");
9374 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9375 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9376 : : "add#rm");
9377 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9378 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9379 : : "vxlan#geneve#vxlan-gpe#ecpri");
9380 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9381 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9382 : : RTE_UINT16);
9383 : :
9384 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9385 : : .f = cmd_cfg_tunnel_udp_port_parsed,
9386 : : .data = NULL,
9387 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9388 : : "geneve|vxlan-gpe|ecpri <udp_port>",
9389 : : .tokens = {
9390 : : (void *)&cmd_config_tunnel_udp_port_port,
9391 : : (void *)&cmd_config_tunnel_udp_port_config,
9392 : : (void *)&cmd_config_tunnel_udp_port_port_id,
9393 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9394 : : (void *)&cmd_config_tunnel_udp_port_action,
9395 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9396 : : (void *)&cmd_config_tunnel_udp_port_value,
9397 : : NULL,
9398 : : },
9399 : : };
9400 : :
9401 : : /* ******************************************************************************** */
9402 : :
9403 : : struct cmd_dump_simple_result {
9404 : : cmdline_fixed_string_t dump;
9405 : : cmdline_fixed_string_t obj;
9406 : : cmdline_fixed_string_t name;
9407 : : };
9408 : : static cmdline_parse_token_string_t cmd_dump_simple_dump =
9409 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, dump, "dump");
9410 : : static cmdline_parse_token_string_t cmd_dump_simple_obj =
9411 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9412 : : "physmem#"
9413 : : "socket_mem#"
9414 : : "memzone#"
9415 : : "struct_sizes#"
9416 : : "ring#"
9417 : : "mempool#"
9418 : : "devargs#"
9419 : : "lcores#"
9420 : : "trace#"
9421 : : "log_types"
9422 : : );
9423 : : static cmdline_parse_token_string_t cmd_dump_named_obj =
9424 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9425 : : "ring#"
9426 : : "mempool#"
9427 : : );
9428 : : static cmdline_parse_token_string_t cmd_dump_named_name =
9429 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, name, NULL);
9430 : :
9431 : : static void
9432 : 0 : dump_struct_sizes(void)
9433 : : {
9434 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9435 : : DUMP_SIZE(struct rte_mbuf);
9436 : : DUMP_SIZE(struct rte_mempool);
9437 : : DUMP_SIZE(struct rte_ring);
9438 : : #undef DUMP_SIZE
9439 : 0 : }
9440 : :
9441 : : /* Dump the socket memory statistics on console */
9442 : : static void
9443 : 0 : dump_socket_mem(FILE *f)
9444 : : {
9445 : : struct rte_malloc_socket_stats socket_stats;
9446 : : unsigned int i;
9447 : : size_t total = 0;
9448 : : size_t alloc = 0;
9449 : : size_t free = 0;
9450 : : unsigned int n_alloc = 0;
9451 : : unsigned int n_free = 0;
9452 : : static size_t last_allocs;
9453 : : static size_t last_total;
9454 : :
9455 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9456 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9457 : 0 : !socket_stats.heap_totalsz_bytes)
9458 : 0 : continue;
9459 : 0 : total += socket_stats.heap_totalsz_bytes;
9460 : 0 : alloc += socket_stats.heap_allocsz_bytes;
9461 : 0 : free += socket_stats.heap_freesz_bytes;
9462 : 0 : n_alloc += socket_stats.alloc_count;
9463 : 0 : n_free += socket_stats.free_count;
9464 : 0 : fprintf(f,
9465 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9466 : : i,
9467 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9468 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9469 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
9470 : 0 : (double)socket_stats.heap_totalsz_bytes,
9471 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9472 : : socket_stats.alloc_count,
9473 : : socket_stats.free_count);
9474 : : }
9475 : 0 : fprintf(f,
9476 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9477 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9478 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
9479 : 0 : (double)free / (1024 * 1024),
9480 : : n_alloc, n_free);
9481 : 0 : if (last_allocs)
9482 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9483 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
9484 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
9485 : 0 : last_allocs = alloc;
9486 : 0 : last_total = total;
9487 : 0 : }
9488 : :
9489 : 0 : static void cmd_dump_simple_parsed(void *parsed_result,
9490 : : struct cmdline *cl,
9491 : : __rte_unused void *data)
9492 : : {
9493 : : struct cmd_dump_simple_result *res = parsed_result;
9494 : :
9495 : 0 : if (strcmp(res->obj, "physmem") == 0)
9496 : 0 : rte_dump_physmem_layout(stdout);
9497 : 0 : else if (strcmp(res->obj, "socket_mem") == 0)
9498 : 0 : dump_socket_mem(stdout);
9499 : 0 : else if (strcmp(res->obj, "memzone") == 0)
9500 : 0 : rte_memzone_dump(stdout);
9501 : 0 : else if (strcmp(res->obj, "struct_sizes") == 0)
9502 : 0 : dump_struct_sizes();
9503 : 0 : else if (strcmp(res->obj, "ring") == 0) {
9504 : 0 : if (strcmp(res->name, "") == 0) {
9505 : 0 : rte_ring_list_dump(stdout);
9506 : : } else {
9507 : : struct rte_ring *r;
9508 : 0 : r = rte_ring_lookup(res->name);
9509 : 0 : if (r == NULL) {
9510 : 0 : cmdline_printf(cl, "Cannot find ring\n");
9511 : 0 : return;
9512 : : }
9513 : 0 : rte_ring_dump(stdout, r);
9514 : : }
9515 : 0 : } else if (strcmp(res->obj, "mempool") == 0) {
9516 : 0 : if (strcmp(res->name, "") == 0) {
9517 : 0 : rte_mempool_list_dump(stdout);
9518 : : } else {
9519 : : struct rte_mempool *mp;
9520 : 0 : mp = rte_mempool_lookup(res->name);
9521 : 0 : if (mp == NULL) {
9522 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
9523 : 0 : return;
9524 : : }
9525 : 0 : rte_mempool_dump(stdout, mp);
9526 : : }
9527 : 0 : } else if (strcmp(res->obj, "devargs") == 0)
9528 : 0 : rte_devargs_dump(stdout);
9529 : 0 : else if (strcmp(res->obj, "lcores") == 0)
9530 : 0 : rte_lcore_dump(stdout);
9531 : 0 : else if (strcmp(res->obj, "trace") == 0)
9532 : : #ifdef RTE_EXEC_ENV_WINDOWS
9533 : : cmdline_printf(cl, "trace is not supported on Windows\n");
9534 : : #else
9535 : 0 : rte_trace_save();
9536 : : #endif
9537 : 0 : else if (strcmp(res->obj, "log_types") == 0)
9538 : 0 : rte_log_dump(stdout);
9539 : : }
9540 : :
9541 : : static cmdline_parse_inst_t cmd_dump_simple = {
9542 : : .f = cmd_dump_simple_parsed,
9543 : : .help_str = "Dump objects",
9544 : : .tokens = {
9545 : : (void *)&cmd_dump_simple_dump,
9546 : : (void *)&cmd_dump_simple_obj,
9547 : : NULL,
9548 : : },
9549 : : };
9550 : : static cmdline_parse_inst_t cmd_dump_named = {
9551 : : .f = cmd_dump_simple_parsed,
9552 : : .help_str = "dump ring|mempool <name>: Dump one ring/mempool",
9553 : : .tokens = {
9554 : : (void *)&cmd_dump_simple_dump,
9555 : : (void *)&cmd_dump_named_obj,
9556 : : (void *)&cmd_dump_named_name,
9557 : : NULL,
9558 : : },
9559 : : };
9560 : :
9561 : : struct cmd_dump_mbuf_history_result {
9562 : : cmdline_fixed_string_t dump;
9563 : : cmdline_fixed_string_t mbuf;
9564 : : cmdline_fixed_string_t history;
9565 : : cmdline_fixed_string_t obj;
9566 : : cmdline_fixed_string_t name;
9567 : : cmdline_fixed_string_t addr;
9568 : : cmdline_fixed_string_t file;
9569 : : };
9570 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_dump =
9571 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, dump, "dump");
9572 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_mbuf =
9573 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, mbuf, "mbuf");
9574 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_history =
9575 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, history, "history");
9576 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_obj =
9577 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, NULL);
9578 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_pool =
9579 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, "pool");
9580 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_name =
9581 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, name, NULL);
9582 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_file =
9583 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, file, NULL);
9584 : :
9585 : 0 : static void cmd_dump_mbuf_history_parsed(void *parsed_result,
9586 : : struct cmdline *cl,
9587 : : __rte_unused void *data)
9588 : : {
9589 : : struct cmd_dump_mbuf_history_result *res = parsed_result;
9590 : 0 : FILE *out = stdout;
9591 : :
9592 : 0 : if (strcmp(res->file, "") != 0) {
9593 : 0 : out = fopen(res->file, "w");
9594 : 0 : if (out == NULL) {
9595 : 0 : cmdline_printf(cl,
9596 : : "Failed to open file '%s'\n",
9597 : : res->file);
9598 : 0 : return;
9599 : : }
9600 : : }
9601 : :
9602 : 0 : if (strcmp(res->obj, "all") == 0) {
9603 : 0 : rte_mbuf_history_dump_all(out);
9604 : 0 : if (out != stdout)
9605 : 0 : cmdline_printf(cl,
9606 : : "Dump written in '%s'\n",
9607 : 0 : res->file);
9608 : 0 : } else if (strcmp(res->obj, "pool") == 0) {
9609 : 0 : struct rte_mempool *mp = rte_mempool_lookup(res->name);
9610 : 0 : if (mp == NULL) {
9611 : 0 : cmdline_printf(cl,
9612 : : "Failed to find mempool '%s'\n",
9613 : : res->name);
9614 : 0 : goto out_close;
9615 : : }
9616 : 0 : rte_mbuf_history_dump_mempool(out, mp);
9617 : 0 : if (out != stdout)
9618 : 0 : cmdline_printf(cl,
9619 : : "Dump for mempool '%s' written in '%s'\n",
9620 : 0 : res->name, res->file);
9621 : : } else {
9622 : : struct rte_mbuf *mbuf;
9623 : : uintptr_t mbuf_addr;
9624 : 0 : if (sscanf(res->obj, "0x%" SCNxPTR, &mbuf_addr) != 1) {
9625 : 0 : cmdline_printf(cl,
9626 : : "Invalid mbuf pointer format. Use 0x<address>\n");
9627 : 0 : goto out_close;
9628 : : }
9629 : 0 : mbuf = (struct rte_mbuf *)mbuf_addr;
9630 : 0 : rte_mbuf_history_dump(out, mbuf);
9631 : 0 : if (out != stdout)
9632 : 0 : cmdline_printf(cl,
9633 : : "Dump for mbuf '%p' written in '%s'\n",
9634 : 0 : mbuf, res->file);
9635 : : }
9636 : :
9637 : 0 : out_close:
9638 : 0 : if (out != stdout)
9639 : 0 : fclose(out);
9640 : : }
9641 : :
9642 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_stdout = {
9643 : : .f = cmd_dump_mbuf_history_parsed,
9644 : : .help_str = "dump mbuf history all|<address>",
9645 : : .tokens = {
9646 : : (void *)&cmd_dump_mbuf_history_dump,
9647 : : (void *)&cmd_dump_mbuf_history_mbuf,
9648 : : (void *)&cmd_dump_mbuf_history_history,
9649 : : (void *)&cmd_dump_mbuf_history_obj,
9650 : : NULL,
9651 : : },
9652 : : };
9653 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_to_file = {
9654 : : .f = cmd_dump_mbuf_history_parsed,
9655 : : .help_str = "dump mbuf history all|<address> [file]",
9656 : : .tokens = {
9657 : : (void *)&cmd_dump_mbuf_history_dump,
9658 : : (void *)&cmd_dump_mbuf_history_mbuf,
9659 : : (void *)&cmd_dump_mbuf_history_history,
9660 : : (void *)&cmd_dump_mbuf_history_obj,
9661 : : (void *)&cmd_dump_mbuf_history_file,
9662 : : NULL,
9663 : : },
9664 : : };
9665 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_stdout = {
9666 : : .f = cmd_dump_mbuf_history_parsed,
9667 : : .help_str = "dump mbuf pool history <name>",
9668 : : .tokens = {
9669 : : (void *)&cmd_dump_mbuf_history_dump,
9670 : : (void *)&cmd_dump_mbuf_history_mbuf,
9671 : : (void *)&cmd_dump_mbuf_history_pool,
9672 : : (void *)&cmd_dump_mbuf_history_history,
9673 : : (void *)&cmd_dump_mbuf_history_name,
9674 : : NULL,
9675 : : },
9676 : : };
9677 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_to_file = {
9678 : : .f = cmd_dump_mbuf_history_parsed,
9679 : : .help_str = "dump mbuf pool history <name> [file]",
9680 : : .tokens = {
9681 : : (void *)&cmd_dump_mbuf_history_dump,
9682 : : (void *)&cmd_dump_mbuf_history_mbuf,
9683 : : (void *)&cmd_dump_mbuf_history_pool,
9684 : : (void *)&cmd_dump_mbuf_history_history,
9685 : : (void *)&cmd_dump_mbuf_history_name,
9686 : : (void *)&cmd_dump_mbuf_history_file,
9687 : : NULL,
9688 : : },
9689 : : };
9690 : :
9691 : : /* *** Filters Control *** */
9692 : :
9693 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9694 : : do { \
9695 : : if ((ip_addr).family == AF_INET) \
9696 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
9697 : : else { \
9698 : : fprintf(stderr, "invalid parameter.\n"); \
9699 : : return; \
9700 : : } \
9701 : : } while (0)
9702 : :
9703 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9704 : : do { \
9705 : : if ((ip_addr).family == AF_INET6) \
9706 : : ip = ip_addr.addr.ipv6; \
9707 : : else { \
9708 : : fprintf(stderr, "invalid parameter.\n"); \
9709 : : return; \
9710 : : } \
9711 : : } while (0)
9712 : :
9713 : : /* Generic flow interface command. */
9714 : : extern cmdline_parse_inst_t cmd_flow;
9715 : :
9716 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9717 : : struct cmd_mcast_addr_result {
9718 : : cmdline_fixed_string_t mcast_addr_cmd;
9719 : : cmdline_fixed_string_t what;
9720 : : uint16_t port_num;
9721 : : struct rte_ether_addr mc_addr;
9722 : : };
9723 : :
9724 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
9725 : : __rte_unused struct cmdline *cl,
9726 : : __rte_unused void *data)
9727 : : {
9728 : : struct cmd_mcast_addr_result *res = parsed_result;
9729 : :
9730 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
9731 : 0 : fprintf(stderr,
9732 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
9733 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
9734 : 0 : return;
9735 : : }
9736 : 0 : if (strcmp(res->what, "add") == 0)
9737 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
9738 : : else
9739 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
9740 : : }
9741 : :
9742 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9743 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9744 : : mcast_addr_cmd, "mcast_addr");
9745 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
9746 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9747 : : "add#remove");
9748 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9749 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9750 : : RTE_UINT16);
9751 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9752 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9753 : :
9754 : : static cmdline_parse_inst_t cmd_mcast_addr = {
9755 : : .f = cmd_mcast_addr_parsed,
9756 : : .data = (void *)0,
9757 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
9758 : : "Add/Remove multicast MAC address on port_id",
9759 : : .tokens = {
9760 : : (void *)&cmd_mcast_addr_cmd,
9761 : : (void *)&cmd_mcast_addr_what,
9762 : : (void *)&cmd_mcast_addr_portnum,
9763 : : (void *)&cmd_mcast_addr_addr,
9764 : : NULL,
9765 : : },
9766 : : };
9767 : :
9768 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
9769 : : struct cmd_mcast_addr_flush_result {
9770 : : cmdline_fixed_string_t mcast_addr_cmd;
9771 : : cmdline_fixed_string_t what;
9772 : : uint16_t port_num;
9773 : : };
9774 : :
9775 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
9776 : : __rte_unused struct cmdline *cl,
9777 : : __rte_unused void *data)
9778 : : {
9779 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
9780 : :
9781 : 0 : mcast_addr_flush(res->port_num);
9782 : 0 : }
9783 : :
9784 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
9785 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9786 : : mcast_addr_cmd, "mcast_addr");
9787 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
9788 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9789 : : "flush");
9790 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
9791 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9792 : : RTE_UINT16);
9793 : :
9794 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
9795 : : .f = cmd_mcast_addr_flush_parsed,
9796 : : .data = (void *)0,
9797 : : .help_str = "mcast_addr flush <port_id> : "
9798 : : "flush all multicast MAC addresses on port_id",
9799 : : .tokens = {
9800 : : (void *)&cmd_mcast_addr_flush_cmd,
9801 : : (void *)&cmd_mcast_addr_flush_what,
9802 : : (void *)&cmd_mcast_addr_flush_portnum,
9803 : : NULL,
9804 : : },
9805 : : };
9806 : :
9807 : : /* vf vlan anti spoof configuration */
9808 : :
9809 : : /* Common result structure for vf vlan anti spoof */
9810 : : struct cmd_vf_vlan_anti_spoof_result {
9811 : : cmdline_fixed_string_t set;
9812 : : cmdline_fixed_string_t vf;
9813 : : cmdline_fixed_string_t vlan;
9814 : : cmdline_fixed_string_t antispoof;
9815 : : portid_t port_id;
9816 : : uint32_t vf_id;
9817 : : cmdline_fixed_string_t on_off;
9818 : : };
9819 : :
9820 : : /* Common CLI fields for vf vlan anti spoof enable disable */
9821 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
9822 : : TOKEN_STRING_INITIALIZER
9823 : : (struct cmd_vf_vlan_anti_spoof_result,
9824 : : set, "set");
9825 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
9826 : : TOKEN_STRING_INITIALIZER
9827 : : (struct cmd_vf_vlan_anti_spoof_result,
9828 : : vf, "vf");
9829 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
9830 : : TOKEN_STRING_INITIALIZER
9831 : : (struct cmd_vf_vlan_anti_spoof_result,
9832 : : vlan, "vlan");
9833 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
9834 : : TOKEN_STRING_INITIALIZER
9835 : : (struct cmd_vf_vlan_anti_spoof_result,
9836 : : antispoof, "antispoof");
9837 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
9838 : : TOKEN_NUM_INITIALIZER
9839 : : (struct cmd_vf_vlan_anti_spoof_result,
9840 : : port_id, RTE_UINT16);
9841 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
9842 : : TOKEN_NUM_INITIALIZER
9843 : : (struct cmd_vf_vlan_anti_spoof_result,
9844 : : vf_id, RTE_UINT32);
9845 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
9846 : : TOKEN_STRING_INITIALIZER
9847 : : (struct cmd_vf_vlan_anti_spoof_result,
9848 : : on_off, "on#off");
9849 : :
9850 : : static void
9851 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
9852 : : void *parsed_result,
9853 : : __rte_unused struct cmdline *cl,
9854 : : __rte_unused void *data)
9855 : : {
9856 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
9857 : : int ret = -ENOTSUP;
9858 : :
9859 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9860 : :
9861 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9862 : : return;
9863 : :
9864 : : #ifdef RTE_NET_IXGBE
9865 : : if (ret == -ENOTSUP)
9866 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
9867 : 0 : res->vf_id, is_on);
9868 : : #endif
9869 : : #ifdef RTE_NET_I40E
9870 : 0 : if (ret == -ENOTSUP)
9871 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
9872 : 0 : res->vf_id, is_on);
9873 : : #endif
9874 : : #ifdef RTE_NET_BNXT
9875 : 0 : if (ret == -ENOTSUP)
9876 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
9877 : 0 : res->vf_id, is_on);
9878 : : #endif
9879 : :
9880 : 0 : switch (ret) {
9881 : : case 0:
9882 : : break;
9883 : 0 : case -EINVAL:
9884 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
9885 : : break;
9886 : 0 : case -ENODEV:
9887 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9888 : : break;
9889 : 0 : case -ENOTSUP:
9890 : 0 : fprintf(stderr, "function not implemented\n");
9891 : : break;
9892 : 0 : default:
9893 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9894 : : }
9895 : : }
9896 : :
9897 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
9898 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
9899 : : .data = NULL,
9900 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
9901 : : .tokens = {
9902 : : (void *)&cmd_vf_vlan_anti_spoof_set,
9903 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
9904 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
9905 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
9906 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
9907 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
9908 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
9909 : : NULL,
9910 : : },
9911 : : };
9912 : :
9913 : : /* vf mac anti spoof configuration */
9914 : :
9915 : : /* Common result structure for vf mac anti spoof */
9916 : : struct cmd_vf_mac_anti_spoof_result {
9917 : : cmdline_fixed_string_t set;
9918 : : cmdline_fixed_string_t vf;
9919 : : cmdline_fixed_string_t mac;
9920 : : cmdline_fixed_string_t antispoof;
9921 : : portid_t port_id;
9922 : : uint32_t vf_id;
9923 : : cmdline_fixed_string_t on_off;
9924 : : };
9925 : :
9926 : : /* Common CLI fields for vf mac anti spoof enable disable */
9927 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
9928 : : TOKEN_STRING_INITIALIZER
9929 : : (struct cmd_vf_mac_anti_spoof_result,
9930 : : set, "set");
9931 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
9932 : : TOKEN_STRING_INITIALIZER
9933 : : (struct cmd_vf_mac_anti_spoof_result,
9934 : : vf, "vf");
9935 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
9936 : : TOKEN_STRING_INITIALIZER
9937 : : (struct cmd_vf_mac_anti_spoof_result,
9938 : : mac, "mac");
9939 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
9940 : : TOKEN_STRING_INITIALIZER
9941 : : (struct cmd_vf_mac_anti_spoof_result,
9942 : : antispoof, "antispoof");
9943 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
9944 : : TOKEN_NUM_INITIALIZER
9945 : : (struct cmd_vf_mac_anti_spoof_result,
9946 : : port_id, RTE_UINT16);
9947 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
9948 : : TOKEN_NUM_INITIALIZER
9949 : : (struct cmd_vf_mac_anti_spoof_result,
9950 : : vf_id, RTE_UINT32);
9951 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
9952 : : TOKEN_STRING_INITIALIZER
9953 : : (struct cmd_vf_mac_anti_spoof_result,
9954 : : on_off, "on#off");
9955 : :
9956 : : static void
9957 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
9958 : : void *parsed_result,
9959 : : __rte_unused struct cmdline *cl,
9960 : : __rte_unused void *data)
9961 : : {
9962 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
9963 : : int ret = -ENOTSUP;
9964 : :
9965 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9966 : :
9967 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9968 : : return;
9969 : :
9970 : : #ifdef RTE_NET_IXGBE
9971 : : if (ret == -ENOTSUP)
9972 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
9973 : 0 : res->vf_id, is_on);
9974 : : #endif
9975 : : #ifdef RTE_NET_I40E
9976 : 0 : if (ret == -ENOTSUP)
9977 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
9978 : 0 : res->vf_id, is_on);
9979 : : #endif
9980 : : #ifdef RTE_NET_BNXT
9981 : 0 : if (ret == -ENOTSUP)
9982 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
9983 : 0 : res->vf_id, is_on);
9984 : : #endif
9985 : :
9986 : 0 : switch (ret) {
9987 : : case 0:
9988 : : break;
9989 : 0 : case -EINVAL:
9990 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9991 : : res->vf_id, is_on);
9992 : : break;
9993 : 0 : case -ENODEV:
9994 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9995 : : break;
9996 : 0 : case -ENOTSUP:
9997 : 0 : fprintf(stderr, "function not implemented\n");
9998 : : break;
9999 : 0 : default:
10000 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10001 : : }
10002 : : }
10003 : :
10004 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
10005 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
10006 : : .data = NULL,
10007 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
10008 : : .tokens = {
10009 : : (void *)&cmd_vf_mac_anti_spoof_set,
10010 : : (void *)&cmd_vf_mac_anti_spoof_vf,
10011 : : (void *)&cmd_vf_mac_anti_spoof_mac,
10012 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
10013 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
10014 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
10015 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
10016 : : NULL,
10017 : : },
10018 : : };
10019 : :
10020 : : /* vf vlan strip queue configuration */
10021 : :
10022 : : /* Common result structure for vf mac anti spoof */
10023 : : struct cmd_vf_vlan_stripq_result {
10024 : : cmdline_fixed_string_t set;
10025 : : cmdline_fixed_string_t vf;
10026 : : cmdline_fixed_string_t vlan;
10027 : : cmdline_fixed_string_t stripq;
10028 : : portid_t port_id;
10029 : : uint16_t vf_id;
10030 : : cmdline_fixed_string_t on_off;
10031 : : };
10032 : :
10033 : : /* Common CLI fields for vf vlan strip enable disable */
10034 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
10035 : : TOKEN_STRING_INITIALIZER
10036 : : (struct cmd_vf_vlan_stripq_result,
10037 : : set, "set");
10038 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
10039 : : TOKEN_STRING_INITIALIZER
10040 : : (struct cmd_vf_vlan_stripq_result,
10041 : : vf, "vf");
10042 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
10043 : : TOKEN_STRING_INITIALIZER
10044 : : (struct cmd_vf_vlan_stripq_result,
10045 : : vlan, "vlan");
10046 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
10047 : : TOKEN_STRING_INITIALIZER
10048 : : (struct cmd_vf_vlan_stripq_result,
10049 : : stripq, "stripq");
10050 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
10051 : : TOKEN_NUM_INITIALIZER
10052 : : (struct cmd_vf_vlan_stripq_result,
10053 : : port_id, RTE_UINT16);
10054 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
10055 : : TOKEN_NUM_INITIALIZER
10056 : : (struct cmd_vf_vlan_stripq_result,
10057 : : vf_id, RTE_UINT16);
10058 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
10059 : : TOKEN_STRING_INITIALIZER
10060 : : (struct cmd_vf_vlan_stripq_result,
10061 : : on_off, "on#off");
10062 : :
10063 : : static void
10064 : 0 : cmd_set_vf_vlan_stripq_parsed(
10065 : : void *parsed_result,
10066 : : __rte_unused struct cmdline *cl,
10067 : : __rte_unused void *data)
10068 : : {
10069 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
10070 : : int ret = -ENOTSUP;
10071 : :
10072 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10073 : :
10074 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10075 : : return;
10076 : :
10077 : : #ifdef RTE_NET_IXGBE
10078 : : if (ret == -ENOTSUP)
10079 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10080 : 0 : res->vf_id, is_on);
10081 : : #endif
10082 : : #ifdef RTE_NET_I40E
10083 : 0 : if (ret == -ENOTSUP)
10084 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10085 : 0 : res->vf_id, is_on);
10086 : : #endif
10087 : : #ifdef RTE_NET_BNXT
10088 : 0 : if (ret == -ENOTSUP)
10089 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10090 : 0 : res->vf_id, is_on);
10091 : : #endif
10092 : :
10093 : 0 : switch (ret) {
10094 : : case 0:
10095 : : break;
10096 : 0 : case -EINVAL:
10097 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
10098 : 0 : res->vf_id, is_on);
10099 : : break;
10100 : 0 : case -ENODEV:
10101 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10102 : : break;
10103 : 0 : case -ENOTSUP:
10104 : 0 : fprintf(stderr, "function not implemented\n");
10105 : : break;
10106 : 0 : default:
10107 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10108 : : }
10109 : : }
10110 : :
10111 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10112 : : .f = cmd_set_vf_vlan_stripq_parsed,
10113 : : .data = NULL,
10114 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10115 : : .tokens = {
10116 : : (void *)&cmd_vf_vlan_stripq_set,
10117 : : (void *)&cmd_vf_vlan_stripq_vf,
10118 : : (void *)&cmd_vf_vlan_stripq_vlan,
10119 : : (void *)&cmd_vf_vlan_stripq_stripq,
10120 : : (void *)&cmd_vf_vlan_stripq_port_id,
10121 : : (void *)&cmd_vf_vlan_stripq_vf_id,
10122 : : (void *)&cmd_vf_vlan_stripq_on_off,
10123 : : NULL,
10124 : : },
10125 : : };
10126 : :
10127 : : /* vf vlan insert configuration */
10128 : :
10129 : : /* Common result structure for vf vlan insert */
10130 : : struct cmd_vf_vlan_insert_result {
10131 : : cmdline_fixed_string_t set;
10132 : : cmdline_fixed_string_t vf;
10133 : : cmdline_fixed_string_t vlan;
10134 : : cmdline_fixed_string_t insert;
10135 : : portid_t port_id;
10136 : : uint16_t vf_id;
10137 : : uint16_t vlan_id;
10138 : : };
10139 : :
10140 : : /* Common CLI fields for vf vlan insert enable disable */
10141 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
10142 : : TOKEN_STRING_INITIALIZER
10143 : : (struct cmd_vf_vlan_insert_result,
10144 : : set, "set");
10145 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
10146 : : TOKEN_STRING_INITIALIZER
10147 : : (struct cmd_vf_vlan_insert_result,
10148 : : vf, "vf");
10149 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
10150 : : TOKEN_STRING_INITIALIZER
10151 : : (struct cmd_vf_vlan_insert_result,
10152 : : vlan, "vlan");
10153 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
10154 : : TOKEN_STRING_INITIALIZER
10155 : : (struct cmd_vf_vlan_insert_result,
10156 : : insert, "insert");
10157 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
10158 : : TOKEN_NUM_INITIALIZER
10159 : : (struct cmd_vf_vlan_insert_result,
10160 : : port_id, RTE_UINT16);
10161 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
10162 : : TOKEN_NUM_INITIALIZER
10163 : : (struct cmd_vf_vlan_insert_result,
10164 : : vf_id, RTE_UINT16);
10165 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
10166 : : TOKEN_NUM_INITIALIZER
10167 : : (struct cmd_vf_vlan_insert_result,
10168 : : vlan_id, RTE_UINT16);
10169 : :
10170 : : static void
10171 : 0 : cmd_set_vf_vlan_insert_parsed(
10172 : : void *parsed_result,
10173 : : __rte_unused struct cmdline *cl,
10174 : : __rte_unused void *data)
10175 : : {
10176 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
10177 : : int ret = -ENOTSUP;
10178 : :
10179 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10180 : : return;
10181 : :
10182 : : #ifdef RTE_NET_IXGBE
10183 : : if (ret == -ENOTSUP)
10184 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
10185 : 0 : res->vlan_id);
10186 : : #endif
10187 : : #ifdef RTE_NET_I40E
10188 : 0 : if (ret == -ENOTSUP)
10189 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
10190 : 0 : res->vlan_id);
10191 : : #endif
10192 : : #ifdef RTE_NET_BNXT
10193 : 0 : if (ret == -ENOTSUP)
10194 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
10195 : 0 : res->vlan_id);
10196 : : #endif
10197 : :
10198 : 0 : switch (ret) {
10199 : : case 0:
10200 : : break;
10201 : 0 : case -EINVAL:
10202 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
10203 : 0 : res->vf_id, res->vlan_id);
10204 : : break;
10205 : 0 : case -ENODEV:
10206 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10207 : : break;
10208 : 0 : case -ENOTSUP:
10209 : 0 : fprintf(stderr, "function not implemented\n");
10210 : : break;
10211 : 0 : default:
10212 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10213 : : }
10214 : : }
10215 : :
10216 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
10217 : : .f = cmd_set_vf_vlan_insert_parsed,
10218 : : .data = NULL,
10219 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
10220 : : .tokens = {
10221 : : (void *)&cmd_vf_vlan_insert_set,
10222 : : (void *)&cmd_vf_vlan_insert_vf,
10223 : : (void *)&cmd_vf_vlan_insert_vlan,
10224 : : (void *)&cmd_vf_vlan_insert_insert,
10225 : : (void *)&cmd_vf_vlan_insert_port_id,
10226 : : (void *)&cmd_vf_vlan_insert_vf_id,
10227 : : (void *)&cmd_vf_vlan_insert_vlan_id,
10228 : : NULL,
10229 : : },
10230 : : };
10231 : :
10232 : : /* tx loopback configuration */
10233 : :
10234 : : /* Common result structure for tx loopback */
10235 : : struct cmd_tx_loopback_result {
10236 : : cmdline_fixed_string_t set;
10237 : : cmdline_fixed_string_t tx;
10238 : : cmdline_fixed_string_t loopback;
10239 : : portid_t port_id;
10240 : : cmdline_fixed_string_t on_off;
10241 : : };
10242 : :
10243 : : /* Common CLI fields for tx loopback enable disable */
10244 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
10245 : : TOKEN_STRING_INITIALIZER
10246 : : (struct cmd_tx_loopback_result,
10247 : : set, "set");
10248 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
10249 : : TOKEN_STRING_INITIALIZER
10250 : : (struct cmd_tx_loopback_result,
10251 : : tx, "tx");
10252 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
10253 : : TOKEN_STRING_INITIALIZER
10254 : : (struct cmd_tx_loopback_result,
10255 : : loopback, "loopback");
10256 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
10257 : : TOKEN_NUM_INITIALIZER
10258 : : (struct cmd_tx_loopback_result,
10259 : : port_id, RTE_UINT16);
10260 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
10261 : : TOKEN_STRING_INITIALIZER
10262 : : (struct cmd_tx_loopback_result,
10263 : : on_off, "on#off");
10264 : :
10265 : : static void
10266 : 0 : cmd_set_tx_loopback_parsed(
10267 : : void *parsed_result,
10268 : : __rte_unused struct cmdline *cl,
10269 : : __rte_unused void *data)
10270 : : {
10271 : : struct cmd_tx_loopback_result *res = parsed_result;
10272 : : int ret = -ENOTSUP;
10273 : :
10274 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10275 : :
10276 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10277 : : return;
10278 : :
10279 : : #ifdef RTE_NET_IXGBE
10280 : : if (ret == -ENOTSUP)
10281 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
10282 : : #endif
10283 : : #ifdef RTE_NET_I40E
10284 : 0 : if (ret == -ENOTSUP)
10285 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
10286 : : #endif
10287 : : #ifdef RTE_NET_BNXT
10288 : 0 : if (ret == -ENOTSUP)
10289 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
10290 : : #endif
10291 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
10292 : 0 : if (ret == -ENOTSUP)
10293 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
10294 : : #endif
10295 : :
10296 : 0 : switch (ret) {
10297 : : case 0:
10298 : : break;
10299 : 0 : case -EINVAL:
10300 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10301 : : break;
10302 : 0 : case -ENODEV:
10303 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10304 : : break;
10305 : 0 : case -ENOTSUP:
10306 : 0 : fprintf(stderr, "function not implemented\n");
10307 : : break;
10308 : 0 : default:
10309 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10310 : : }
10311 : : }
10312 : :
10313 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
10314 : : .f = cmd_set_tx_loopback_parsed,
10315 : : .data = NULL,
10316 : : .help_str = "set tx loopback <port_id> on|off",
10317 : : .tokens = {
10318 : : (void *)&cmd_tx_loopback_set,
10319 : : (void *)&cmd_tx_loopback_tx,
10320 : : (void *)&cmd_tx_loopback_loopback,
10321 : : (void *)&cmd_tx_loopback_port_id,
10322 : : (void *)&cmd_tx_loopback_on_off,
10323 : : NULL,
10324 : : },
10325 : : };
10326 : :
10327 : : /* all queues drop enable configuration */
10328 : :
10329 : : /* Common result structure for all queues drop enable */
10330 : : struct cmd_all_queues_drop_en_result {
10331 : : cmdline_fixed_string_t set;
10332 : : cmdline_fixed_string_t all;
10333 : : cmdline_fixed_string_t queues;
10334 : : cmdline_fixed_string_t drop;
10335 : : portid_t port_id;
10336 : : cmdline_fixed_string_t on_off;
10337 : : };
10338 : :
10339 : : /* Common CLI fields for tx loopback enable disable */
10340 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
10341 : : TOKEN_STRING_INITIALIZER
10342 : : (struct cmd_all_queues_drop_en_result,
10343 : : set, "set");
10344 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
10345 : : TOKEN_STRING_INITIALIZER
10346 : : (struct cmd_all_queues_drop_en_result,
10347 : : all, "all");
10348 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
10349 : : TOKEN_STRING_INITIALIZER
10350 : : (struct cmd_all_queues_drop_en_result,
10351 : : queues, "queues");
10352 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
10353 : : TOKEN_STRING_INITIALIZER
10354 : : (struct cmd_all_queues_drop_en_result,
10355 : : drop, "drop");
10356 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
10357 : : TOKEN_NUM_INITIALIZER
10358 : : (struct cmd_all_queues_drop_en_result,
10359 : : port_id, RTE_UINT16);
10360 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
10361 : : TOKEN_STRING_INITIALIZER
10362 : : (struct cmd_all_queues_drop_en_result,
10363 : : on_off, "on#off");
10364 : :
10365 : : static void
10366 : 0 : cmd_set_all_queues_drop_en_parsed(
10367 : : void *parsed_result,
10368 : : __rte_unused struct cmdline *cl,
10369 : : __rte_unused void *data)
10370 : : {
10371 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
10372 : : int ret = -ENOTSUP;
10373 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10374 : :
10375 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10376 : : return;
10377 : :
10378 : : #ifdef RTE_NET_IXGBE
10379 : : if (ret == -ENOTSUP)
10380 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
10381 : : #endif
10382 : : #ifdef RTE_NET_BNXT
10383 : 0 : if (ret == -ENOTSUP)
10384 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
10385 : : #endif
10386 : 0 : switch (ret) {
10387 : : case 0:
10388 : : break;
10389 : 0 : case -EINVAL:
10390 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10391 : : break;
10392 : 0 : case -ENODEV:
10393 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10394 : : break;
10395 : 0 : case -ENOTSUP:
10396 : 0 : fprintf(stderr, "function not implemented\n");
10397 : : break;
10398 : 0 : default:
10399 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10400 : : }
10401 : : }
10402 : :
10403 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
10404 : : .f = cmd_set_all_queues_drop_en_parsed,
10405 : : .data = NULL,
10406 : : .help_str = "set all queues drop <port_id> on|off",
10407 : : .tokens = {
10408 : : (void *)&cmd_all_queues_drop_en_set,
10409 : : (void *)&cmd_all_queues_drop_en_all,
10410 : : (void *)&cmd_all_queues_drop_en_queues,
10411 : : (void *)&cmd_all_queues_drop_en_drop,
10412 : : (void *)&cmd_all_queues_drop_en_port_id,
10413 : : (void *)&cmd_all_queues_drop_en_on_off,
10414 : : NULL,
10415 : : },
10416 : : };
10417 : :
10418 : : /* vf mac address configuration */
10419 : :
10420 : : /* Common result structure for vf mac address */
10421 : : struct cmd_set_vf_mac_addr_result {
10422 : : cmdline_fixed_string_t set;
10423 : : cmdline_fixed_string_t vf;
10424 : : cmdline_fixed_string_t mac;
10425 : : cmdline_fixed_string_t addr;
10426 : : portid_t port_id;
10427 : : uint16_t vf_id;
10428 : : struct rte_ether_addr mac_addr;
10429 : :
10430 : : };
10431 : :
10432 : : /* Common CLI fields for vf split drop enable disable */
10433 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
10434 : : TOKEN_STRING_INITIALIZER
10435 : : (struct cmd_set_vf_mac_addr_result,
10436 : : set, "set");
10437 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
10438 : : TOKEN_STRING_INITIALIZER
10439 : : (struct cmd_set_vf_mac_addr_result,
10440 : : vf, "vf");
10441 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
10442 : : TOKEN_STRING_INITIALIZER
10443 : : (struct cmd_set_vf_mac_addr_result,
10444 : : mac, "mac");
10445 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
10446 : : TOKEN_STRING_INITIALIZER
10447 : : (struct cmd_set_vf_mac_addr_result,
10448 : : addr, "addr");
10449 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
10450 : : TOKEN_NUM_INITIALIZER
10451 : : (struct cmd_set_vf_mac_addr_result,
10452 : : port_id, RTE_UINT16);
10453 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
10454 : : TOKEN_NUM_INITIALIZER
10455 : : (struct cmd_set_vf_mac_addr_result,
10456 : : vf_id, RTE_UINT16);
10457 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
10458 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
10459 : : mac_addr);
10460 : :
10461 : : static void
10462 : 0 : cmd_set_vf_mac_addr_parsed(
10463 : : void *parsed_result,
10464 : : __rte_unused struct cmdline *cl,
10465 : : __rte_unused void *data)
10466 : : {
10467 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
10468 : : int ret = -ENOTSUP;
10469 : :
10470 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10471 : : return;
10472 : :
10473 : : #ifdef RTE_NET_IXGBE
10474 : : if (ret == -ENOTSUP)
10475 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
10476 : : &res->mac_addr);
10477 : : #endif
10478 : : #ifdef RTE_NET_I40E
10479 : 0 : if (ret == -ENOTSUP)
10480 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
10481 : : &res->mac_addr);
10482 : : #endif
10483 : : #ifdef RTE_NET_BNXT
10484 : 0 : if (ret == -ENOTSUP)
10485 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
10486 : : &res->mac_addr);
10487 : : #endif
10488 : :
10489 : 0 : switch (ret) {
10490 : : case 0:
10491 : : break;
10492 : 0 : case -EINVAL:
10493 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
10494 : : break;
10495 : 0 : case -ENODEV:
10496 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10497 : : break;
10498 : 0 : case -ENOTSUP:
10499 : 0 : fprintf(stderr, "function not implemented\n");
10500 : : break;
10501 : 0 : default:
10502 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10503 : : }
10504 : : }
10505 : :
10506 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
10507 : : .f = cmd_set_vf_mac_addr_parsed,
10508 : : .data = NULL,
10509 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
10510 : : .tokens = {
10511 : : (void *)&cmd_set_vf_mac_addr_set,
10512 : : (void *)&cmd_set_vf_mac_addr_vf,
10513 : : (void *)&cmd_set_vf_mac_addr_mac,
10514 : : (void *)&cmd_set_vf_mac_addr_addr,
10515 : : (void *)&cmd_set_vf_mac_addr_port_id,
10516 : : (void *)&cmd_set_vf_mac_addr_vf_id,
10517 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
10518 : : NULL,
10519 : : },
10520 : : };
10521 : :
10522 : : /** Set VXLAN encapsulation details */
10523 : : struct cmd_set_vxlan_result {
10524 : : cmdline_fixed_string_t set;
10525 : : cmdline_fixed_string_t vxlan;
10526 : : cmdline_fixed_string_t pos_token;
10527 : : cmdline_fixed_string_t ip_version;
10528 : : uint32_t vlan_present:1;
10529 : : uint32_t vni;
10530 : : uint16_t udp_src;
10531 : : uint16_t udp_dst;
10532 : : cmdline_ipaddr_t ip_src;
10533 : : cmdline_ipaddr_t ip_dst;
10534 : : uint16_t tci;
10535 : : uint8_t tos;
10536 : : uint8_t ttl;
10537 : : struct rte_ether_addr eth_src;
10538 : : struct rte_ether_addr eth_dst;
10539 : : };
10540 : :
10541 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
10542 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
10543 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
10544 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
10545 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
10546 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10547 : : "vxlan-tos-ttl");
10548 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
10549 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10550 : : "vxlan-with-vlan");
10551 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
10552 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10553 : : "ip-version");
10554 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
10555 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
10556 : : "ipv4#ipv6");
10557 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
10558 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10559 : : "vni");
10560 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
10561 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
10562 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
10563 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10564 : : "udp-src");
10565 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
10566 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
10567 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
10568 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10569 : : "udp-dst");
10570 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
10571 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
10572 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
10573 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10574 : : "ip-tos");
10575 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
10576 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
10577 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
10578 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10579 : : "ip-ttl");
10580 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
10581 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
10582 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
10583 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10584 : : "ip-src");
10585 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
10586 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
10587 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
10588 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10589 : : "ip-dst");
10590 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
10591 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
10592 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
10593 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10594 : : "vlan-tci");
10595 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
10596 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
10597 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
10598 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10599 : : "eth-src");
10600 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
10601 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
10602 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
10603 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10604 : : "eth-dst");
10605 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
10606 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
10607 : :
10608 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
10609 : : __rte_unused struct cmdline *cl,
10610 : : __rte_unused void *data)
10611 : : {
10612 : : struct cmd_set_vxlan_result *res = parsed_result;
10613 : : union {
10614 : : uint32_t vxlan_id;
10615 : : uint8_t vni[4];
10616 : : } id = {
10617 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
10618 : : };
10619 : :
10620 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
10621 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
10622 : 0 : vxlan_encap_conf.select_vlan = 0;
10623 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
10624 : 0 : vxlan_encap_conf.select_vlan = 1;
10625 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
10626 : 0 : vxlan_encap_conf.select_vlan = 0;
10627 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
10628 : : }
10629 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10630 : 0 : vxlan_encap_conf.select_ipv4 = 1;
10631 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10632 : 0 : vxlan_encap_conf.select_ipv4 = 0;
10633 : : else
10634 : : return;
10635 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
10636 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10637 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10638 : 0 : vxlan_encap_conf.ip_tos = res->tos;
10639 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
10640 : 0 : if (vxlan_encap_conf.select_ipv4) {
10641 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
10642 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
10643 : : } else {
10644 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
10645 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
10646 : : }
10647 : 0 : if (vxlan_encap_conf.select_vlan)
10648 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10649 : : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
10650 : : RTE_ETHER_ADDR_LEN);
10651 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10652 : : RTE_ETHER_ADDR_LEN);
10653 : : }
10654 : :
10655 : : static cmdline_parse_inst_t cmd_set_vxlan = {
10656 : : .f = cmd_set_vxlan_parsed,
10657 : : .data = NULL,
10658 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
10659 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
10660 : : " eth-src <eth-src> eth-dst <eth-dst>",
10661 : : .tokens = {
10662 : : (void *)&cmd_set_vxlan_set,
10663 : : (void *)&cmd_set_vxlan_vxlan,
10664 : : (void *)&cmd_set_vxlan_ip_version,
10665 : : (void *)&cmd_set_vxlan_ip_version_value,
10666 : : (void *)&cmd_set_vxlan_vni,
10667 : : (void *)&cmd_set_vxlan_vni_value,
10668 : : (void *)&cmd_set_vxlan_udp_src,
10669 : : (void *)&cmd_set_vxlan_udp_src_value,
10670 : : (void *)&cmd_set_vxlan_udp_dst,
10671 : : (void *)&cmd_set_vxlan_udp_dst_value,
10672 : : (void *)&cmd_set_vxlan_ip_src,
10673 : : (void *)&cmd_set_vxlan_ip_src_value,
10674 : : (void *)&cmd_set_vxlan_ip_dst,
10675 : : (void *)&cmd_set_vxlan_ip_dst_value,
10676 : : (void *)&cmd_set_vxlan_eth_src,
10677 : : (void *)&cmd_set_vxlan_eth_src_value,
10678 : : (void *)&cmd_set_vxlan_eth_dst,
10679 : : (void *)&cmd_set_vxlan_eth_dst_value,
10680 : : NULL,
10681 : : },
10682 : : };
10683 : :
10684 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
10685 : : .f = cmd_set_vxlan_parsed,
10686 : : .data = NULL,
10687 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
10688 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
10689 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10690 : : " eth-dst <eth-dst>",
10691 : : .tokens = {
10692 : : (void *)&cmd_set_vxlan_set,
10693 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
10694 : : (void *)&cmd_set_vxlan_ip_version,
10695 : : (void *)&cmd_set_vxlan_ip_version_value,
10696 : : (void *)&cmd_set_vxlan_vni,
10697 : : (void *)&cmd_set_vxlan_vni_value,
10698 : : (void *)&cmd_set_vxlan_udp_src,
10699 : : (void *)&cmd_set_vxlan_udp_src_value,
10700 : : (void *)&cmd_set_vxlan_udp_dst,
10701 : : (void *)&cmd_set_vxlan_udp_dst_value,
10702 : : (void *)&cmd_set_vxlan_ip_tos,
10703 : : (void *)&cmd_set_vxlan_ip_tos_value,
10704 : : (void *)&cmd_set_vxlan_ip_ttl,
10705 : : (void *)&cmd_set_vxlan_ip_ttl_value,
10706 : : (void *)&cmd_set_vxlan_ip_src,
10707 : : (void *)&cmd_set_vxlan_ip_src_value,
10708 : : (void *)&cmd_set_vxlan_ip_dst,
10709 : : (void *)&cmd_set_vxlan_ip_dst_value,
10710 : : (void *)&cmd_set_vxlan_eth_src,
10711 : : (void *)&cmd_set_vxlan_eth_src_value,
10712 : : (void *)&cmd_set_vxlan_eth_dst,
10713 : : (void *)&cmd_set_vxlan_eth_dst_value,
10714 : : NULL,
10715 : : },
10716 : : };
10717 : :
10718 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
10719 : : .f = cmd_set_vxlan_parsed,
10720 : : .data = NULL,
10721 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
10722 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
10723 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
10724 : : " <eth-dst>",
10725 : : .tokens = {
10726 : : (void *)&cmd_set_vxlan_set,
10727 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
10728 : : (void *)&cmd_set_vxlan_ip_version,
10729 : : (void *)&cmd_set_vxlan_ip_version_value,
10730 : : (void *)&cmd_set_vxlan_vni,
10731 : : (void *)&cmd_set_vxlan_vni_value,
10732 : : (void *)&cmd_set_vxlan_udp_src,
10733 : : (void *)&cmd_set_vxlan_udp_src_value,
10734 : : (void *)&cmd_set_vxlan_udp_dst,
10735 : : (void *)&cmd_set_vxlan_udp_dst_value,
10736 : : (void *)&cmd_set_vxlan_ip_src,
10737 : : (void *)&cmd_set_vxlan_ip_src_value,
10738 : : (void *)&cmd_set_vxlan_ip_dst,
10739 : : (void *)&cmd_set_vxlan_ip_dst_value,
10740 : : (void *)&cmd_set_vxlan_vlan,
10741 : : (void *)&cmd_set_vxlan_vlan_value,
10742 : : (void *)&cmd_set_vxlan_eth_src,
10743 : : (void *)&cmd_set_vxlan_eth_src_value,
10744 : : (void *)&cmd_set_vxlan_eth_dst,
10745 : : (void *)&cmd_set_vxlan_eth_dst_value,
10746 : : NULL,
10747 : : },
10748 : : };
10749 : :
10750 : : /** Set NVGRE encapsulation details */
10751 : : struct cmd_set_nvgre_result {
10752 : : cmdline_fixed_string_t set;
10753 : : cmdline_fixed_string_t nvgre;
10754 : : cmdline_fixed_string_t pos_token;
10755 : : cmdline_fixed_string_t ip_version;
10756 : : uint32_t tni;
10757 : : cmdline_ipaddr_t ip_src;
10758 : : cmdline_ipaddr_t ip_dst;
10759 : : uint16_t tci;
10760 : : struct rte_ether_addr eth_src;
10761 : : struct rte_ether_addr eth_dst;
10762 : : };
10763 : :
10764 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
10765 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
10766 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
10767 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
10768 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
10769 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
10770 : : "nvgre-with-vlan");
10771 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
10772 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10773 : : "ip-version");
10774 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
10775 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
10776 : : "ipv4#ipv6");
10777 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
10778 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10779 : : "tni");
10780 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
10781 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
10782 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
10783 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10784 : : "ip-src");
10785 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
10786 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
10787 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
10788 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10789 : : "ip-dst");
10790 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
10791 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
10792 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
10793 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10794 : : "vlan-tci");
10795 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
10796 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
10797 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
10798 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10799 : : "eth-src");
10800 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
10801 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
10802 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
10803 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10804 : : "eth-dst");
10805 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
10806 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
10807 : :
10808 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
10809 : : __rte_unused struct cmdline *cl,
10810 : : __rte_unused void *data)
10811 : : {
10812 : : struct cmd_set_nvgre_result *res = parsed_result;
10813 : : union {
10814 : : uint32_t nvgre_tni;
10815 : : uint8_t tni[4];
10816 : : } id = {
10817 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
10818 : : };
10819 : :
10820 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
10821 : 0 : nvgre_encap_conf.select_vlan = 0;
10822 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
10823 : 0 : nvgre_encap_conf.select_vlan = 1;
10824 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10825 : 0 : nvgre_encap_conf.select_ipv4 = 1;
10826 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10827 : 0 : nvgre_encap_conf.select_ipv4 = 0;
10828 : : else
10829 : : return;
10830 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
10831 : 0 : if (nvgre_encap_conf.select_ipv4) {
10832 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
10833 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
10834 : : } else {
10835 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
10836 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
10837 : : }
10838 : 0 : if (nvgre_encap_conf.select_vlan)
10839 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10840 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
10841 : : RTE_ETHER_ADDR_LEN);
10842 : : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10843 : : RTE_ETHER_ADDR_LEN);
10844 : : }
10845 : :
10846 : : static cmdline_parse_inst_t cmd_set_nvgre = {
10847 : : .f = cmd_set_nvgre_parsed,
10848 : : .data = NULL,
10849 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
10850 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10851 : : " eth-dst <eth-dst>",
10852 : : .tokens = {
10853 : : (void *)&cmd_set_nvgre_set,
10854 : : (void *)&cmd_set_nvgre_nvgre,
10855 : : (void *)&cmd_set_nvgre_ip_version,
10856 : : (void *)&cmd_set_nvgre_ip_version_value,
10857 : : (void *)&cmd_set_nvgre_tni,
10858 : : (void *)&cmd_set_nvgre_tni_value,
10859 : : (void *)&cmd_set_nvgre_ip_src,
10860 : : (void *)&cmd_set_nvgre_ip_src_value,
10861 : : (void *)&cmd_set_nvgre_ip_dst,
10862 : : (void *)&cmd_set_nvgre_ip_dst_value,
10863 : : (void *)&cmd_set_nvgre_eth_src,
10864 : : (void *)&cmd_set_nvgre_eth_src_value,
10865 : : (void *)&cmd_set_nvgre_eth_dst,
10866 : : (void *)&cmd_set_nvgre_eth_dst_value,
10867 : : NULL,
10868 : : },
10869 : : };
10870 : :
10871 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
10872 : : .f = cmd_set_nvgre_parsed,
10873 : : .data = NULL,
10874 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
10875 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10876 : : " eth-src <eth-src> eth-dst <eth-dst>",
10877 : : .tokens = {
10878 : : (void *)&cmd_set_nvgre_set,
10879 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
10880 : : (void *)&cmd_set_nvgre_ip_version,
10881 : : (void *)&cmd_set_nvgre_ip_version_value,
10882 : : (void *)&cmd_set_nvgre_tni,
10883 : : (void *)&cmd_set_nvgre_tni_value,
10884 : : (void *)&cmd_set_nvgre_ip_src,
10885 : : (void *)&cmd_set_nvgre_ip_src_value,
10886 : : (void *)&cmd_set_nvgre_ip_dst,
10887 : : (void *)&cmd_set_nvgre_ip_dst_value,
10888 : : (void *)&cmd_set_nvgre_vlan,
10889 : : (void *)&cmd_set_nvgre_vlan_value,
10890 : : (void *)&cmd_set_nvgre_eth_src,
10891 : : (void *)&cmd_set_nvgre_eth_src_value,
10892 : : (void *)&cmd_set_nvgre_eth_dst,
10893 : : (void *)&cmd_set_nvgre_eth_dst_value,
10894 : : NULL,
10895 : : },
10896 : : };
10897 : :
10898 : : /** Set L2 encapsulation details */
10899 : : struct cmd_set_l2_encap_result {
10900 : : cmdline_fixed_string_t set;
10901 : : cmdline_fixed_string_t l2_encap;
10902 : : cmdline_fixed_string_t pos_token;
10903 : : cmdline_fixed_string_t ip_version;
10904 : : uint32_t vlan_present:1;
10905 : : uint16_t tci;
10906 : : struct rte_ether_addr eth_src;
10907 : : struct rte_ether_addr eth_dst;
10908 : : };
10909 : :
10910 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
10911 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
10912 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
10913 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
10914 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
10915 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
10916 : : "l2_encap-with-vlan");
10917 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
10918 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10919 : : "ip-version");
10920 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
10921 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
10922 : : "ipv4#ipv6");
10923 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
10924 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10925 : : "vlan-tci");
10926 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
10927 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
10928 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
10929 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10930 : : "eth-src");
10931 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
10932 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
10933 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
10934 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10935 : : "eth-dst");
10936 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
10937 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
10938 : :
10939 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
10940 : : __rte_unused struct cmdline *cl,
10941 : : __rte_unused void *data)
10942 : : {
10943 : : struct cmd_set_l2_encap_result *res = parsed_result;
10944 : :
10945 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
10946 : 0 : l2_encap_conf.select_vlan = 0;
10947 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
10948 : 0 : l2_encap_conf.select_vlan = 1;
10949 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10950 : 0 : l2_encap_conf.select_ipv4 = 1;
10951 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10952 : 0 : l2_encap_conf.select_ipv4 = 0;
10953 : : else
10954 : : return;
10955 : 0 : if (l2_encap_conf.select_vlan)
10956 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10957 : : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
10958 : : RTE_ETHER_ADDR_LEN);
10959 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10960 : : RTE_ETHER_ADDR_LEN);
10961 : : }
10962 : :
10963 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
10964 : : .f = cmd_set_l2_encap_parsed,
10965 : : .data = NULL,
10966 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
10967 : : " eth-src <eth-src> eth-dst <eth-dst>",
10968 : : .tokens = {
10969 : : (void *)&cmd_set_l2_encap_set,
10970 : : (void *)&cmd_set_l2_encap_l2_encap,
10971 : : (void *)&cmd_set_l2_encap_ip_version,
10972 : : (void *)&cmd_set_l2_encap_ip_version_value,
10973 : : (void *)&cmd_set_l2_encap_eth_src,
10974 : : (void *)&cmd_set_l2_encap_eth_src_value,
10975 : : (void *)&cmd_set_l2_encap_eth_dst,
10976 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10977 : : NULL,
10978 : : },
10979 : : };
10980 : :
10981 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
10982 : : .f = cmd_set_l2_encap_parsed,
10983 : : .data = NULL,
10984 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
10985 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10986 : : .tokens = {
10987 : : (void *)&cmd_set_l2_encap_set,
10988 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
10989 : : (void *)&cmd_set_l2_encap_ip_version,
10990 : : (void *)&cmd_set_l2_encap_ip_version_value,
10991 : : (void *)&cmd_set_l2_encap_vlan,
10992 : : (void *)&cmd_set_l2_encap_vlan_value,
10993 : : (void *)&cmd_set_l2_encap_eth_src,
10994 : : (void *)&cmd_set_l2_encap_eth_src_value,
10995 : : (void *)&cmd_set_l2_encap_eth_dst,
10996 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10997 : : NULL,
10998 : : },
10999 : : };
11000 : :
11001 : : /** Set L2 decapsulation details */
11002 : : struct cmd_set_l2_decap_result {
11003 : : cmdline_fixed_string_t set;
11004 : : cmdline_fixed_string_t l2_decap;
11005 : : cmdline_fixed_string_t pos_token;
11006 : : uint32_t vlan_present:1;
11007 : : };
11008 : :
11009 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
11010 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
11011 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
11012 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
11013 : : "l2_decap");
11014 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
11015 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
11016 : : "l2_decap-with-vlan");
11017 : :
11018 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
11019 : : __rte_unused struct cmdline *cl,
11020 : : __rte_unused void *data)
11021 : : {
11022 : : struct cmd_set_l2_decap_result *res = parsed_result;
11023 : :
11024 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
11025 : 0 : l2_decap_conf.select_vlan = 0;
11026 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
11027 : 0 : l2_decap_conf.select_vlan = 1;
11028 : 0 : }
11029 : :
11030 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
11031 : : .f = cmd_set_l2_decap_parsed,
11032 : : .data = NULL,
11033 : : .help_str = "set l2_decap",
11034 : : .tokens = {
11035 : : (void *)&cmd_set_l2_decap_set,
11036 : : (void *)&cmd_set_l2_decap_l2_decap,
11037 : : NULL,
11038 : : },
11039 : : };
11040 : :
11041 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
11042 : : .f = cmd_set_l2_decap_parsed,
11043 : : .data = NULL,
11044 : : .help_str = "set l2_decap-with-vlan",
11045 : : .tokens = {
11046 : : (void *)&cmd_set_l2_decap_set,
11047 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
11048 : : NULL,
11049 : : },
11050 : : };
11051 : :
11052 : : /** Set MPLSoGRE encapsulation details */
11053 : : struct cmd_set_mplsogre_encap_result {
11054 : : cmdline_fixed_string_t set;
11055 : : cmdline_fixed_string_t mplsogre;
11056 : : cmdline_fixed_string_t pos_token;
11057 : : cmdline_fixed_string_t ip_version;
11058 : : uint32_t vlan_present:1;
11059 : : uint32_t label;
11060 : : cmdline_ipaddr_t ip_src;
11061 : : cmdline_ipaddr_t ip_dst;
11062 : : uint16_t tci;
11063 : : struct rte_ether_addr eth_src;
11064 : : struct rte_ether_addr eth_dst;
11065 : : };
11066 : :
11067 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
11068 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
11069 : : "set");
11070 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
11071 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
11072 : : "mplsogre_encap");
11073 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
11074 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11075 : : mplsogre, "mplsogre_encap-with-vlan");
11076 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
11077 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11078 : : pos_token, "ip-version");
11079 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
11080 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11081 : : ip_version, "ipv4#ipv6");
11082 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
11083 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11084 : : pos_token, "label");
11085 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
11086 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
11087 : : RTE_UINT32);
11088 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
11089 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11090 : : pos_token, "ip-src");
11091 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
11092 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
11093 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
11094 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11095 : : pos_token, "ip-dst");
11096 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
11097 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
11098 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
11099 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11100 : : pos_token, "vlan-tci");
11101 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
11102 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
11103 : : RTE_UINT16);
11104 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
11105 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11106 : : pos_token, "eth-src");
11107 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
11108 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11109 : : eth_src);
11110 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
11111 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11112 : : pos_token, "eth-dst");
11113 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
11114 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11115 : : eth_dst);
11116 : :
11117 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
11118 : : __rte_unused struct cmdline *cl,
11119 : : __rte_unused void *data)
11120 : : {
11121 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
11122 : : union {
11123 : : uint32_t mplsogre_label;
11124 : : uint8_t label[4];
11125 : : } id = {
11126 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
11127 : : };
11128 : :
11129 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
11130 : 0 : mplsogre_encap_conf.select_vlan = 0;
11131 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
11132 : 0 : mplsogre_encap_conf.select_vlan = 1;
11133 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11134 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
11135 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11136 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
11137 : : else
11138 : : return;
11139 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
11140 : 0 : if (mplsogre_encap_conf.select_ipv4) {
11141 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
11142 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
11143 : : } else {
11144 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
11145 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
11146 : : }
11147 : 0 : if (mplsogre_encap_conf.select_vlan)
11148 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11149 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
11150 : : RTE_ETHER_ADDR_LEN);
11151 : : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11152 : : RTE_ETHER_ADDR_LEN);
11153 : : }
11154 : :
11155 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
11156 : : .f = cmd_set_mplsogre_encap_parsed,
11157 : : .data = NULL,
11158 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
11159 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
11160 : : " eth-dst <eth-dst>",
11161 : : .tokens = {
11162 : : (void *)&cmd_set_mplsogre_encap_set,
11163 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
11164 : : (void *)&cmd_set_mplsogre_encap_ip_version,
11165 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
11166 : : (void *)&cmd_set_mplsogre_encap_label,
11167 : : (void *)&cmd_set_mplsogre_encap_label_value,
11168 : : (void *)&cmd_set_mplsogre_encap_ip_src,
11169 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
11170 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
11171 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
11172 : : (void *)&cmd_set_mplsogre_encap_eth_src,
11173 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
11174 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
11175 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
11176 : : NULL,
11177 : : },
11178 : : };
11179 : :
11180 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
11181 : : .f = cmd_set_mplsogre_encap_parsed,
11182 : : .data = NULL,
11183 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
11184 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
11185 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
11186 : : .tokens = {
11187 : : (void *)&cmd_set_mplsogre_encap_set,
11188 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
11189 : : (void *)&cmd_set_mplsogre_encap_ip_version,
11190 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
11191 : : (void *)&cmd_set_mplsogre_encap_label,
11192 : : (void *)&cmd_set_mplsogre_encap_label_value,
11193 : : (void *)&cmd_set_mplsogre_encap_ip_src,
11194 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
11195 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
11196 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
11197 : : (void *)&cmd_set_mplsogre_encap_vlan,
11198 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
11199 : : (void *)&cmd_set_mplsogre_encap_eth_src,
11200 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
11201 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
11202 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
11203 : : NULL,
11204 : : },
11205 : : };
11206 : :
11207 : : /** Set MPLSoGRE decapsulation details */
11208 : : struct cmd_set_mplsogre_decap_result {
11209 : : cmdline_fixed_string_t set;
11210 : : cmdline_fixed_string_t mplsogre;
11211 : : cmdline_fixed_string_t pos_token;
11212 : : cmdline_fixed_string_t ip_version;
11213 : : uint32_t vlan_present:1;
11214 : : };
11215 : :
11216 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
11217 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
11218 : : "set");
11219 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
11220 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
11221 : : "mplsogre_decap");
11222 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
11223 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11224 : : mplsogre, "mplsogre_decap-with-vlan");
11225 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
11226 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11227 : : pos_token, "ip-version");
11228 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
11229 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11230 : : ip_version, "ipv4#ipv6");
11231 : :
11232 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
11233 : : __rte_unused struct cmdline *cl,
11234 : : __rte_unused void *data)
11235 : : {
11236 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
11237 : :
11238 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
11239 : 0 : mplsogre_decap_conf.select_vlan = 0;
11240 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
11241 : 0 : mplsogre_decap_conf.select_vlan = 1;
11242 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11243 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
11244 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11245 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
11246 : 0 : }
11247 : :
11248 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
11249 : : .f = cmd_set_mplsogre_decap_parsed,
11250 : : .data = NULL,
11251 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
11252 : : .tokens = {
11253 : : (void *)&cmd_set_mplsogre_decap_set,
11254 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
11255 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11256 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11257 : : NULL,
11258 : : },
11259 : : };
11260 : :
11261 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
11262 : : .f = cmd_set_mplsogre_decap_parsed,
11263 : : .data = NULL,
11264 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
11265 : : .tokens = {
11266 : : (void *)&cmd_set_mplsogre_decap_set,
11267 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
11268 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11269 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11270 : : NULL,
11271 : : },
11272 : : };
11273 : :
11274 : : /** Set MPLSoUDP encapsulation details */
11275 : : struct cmd_set_mplsoudp_encap_result {
11276 : : cmdline_fixed_string_t set;
11277 : : cmdline_fixed_string_t mplsoudp;
11278 : : cmdline_fixed_string_t pos_token;
11279 : : cmdline_fixed_string_t ip_version;
11280 : : uint32_t vlan_present:1;
11281 : : uint32_t label;
11282 : : uint16_t udp_src;
11283 : : uint16_t udp_dst;
11284 : : cmdline_ipaddr_t ip_src;
11285 : : cmdline_ipaddr_t ip_dst;
11286 : : uint16_t tci;
11287 : : struct rte_ether_addr eth_src;
11288 : : struct rte_ether_addr eth_dst;
11289 : : };
11290 : :
11291 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
11292 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
11293 : : "set");
11294 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
11295 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
11296 : : "mplsoudp_encap");
11297 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
11298 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11299 : : mplsoudp, "mplsoudp_encap-with-vlan");
11300 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
11301 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11302 : : pos_token, "ip-version");
11303 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
11304 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11305 : : ip_version, "ipv4#ipv6");
11306 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
11307 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11308 : : pos_token, "label");
11309 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
11310 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
11311 : : RTE_UINT32);
11312 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
11313 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11314 : : pos_token, "udp-src");
11315 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
11316 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
11317 : : RTE_UINT16);
11318 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
11319 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11320 : : pos_token, "udp-dst");
11321 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
11322 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
11323 : : RTE_UINT16);
11324 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
11325 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11326 : : pos_token, "ip-src");
11327 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
11328 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
11329 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
11330 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11331 : : pos_token, "ip-dst");
11332 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
11333 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
11334 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
11335 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11336 : : pos_token, "vlan-tci");
11337 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
11338 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
11339 : : RTE_UINT16);
11340 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
11341 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11342 : : pos_token, "eth-src");
11343 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
11344 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11345 : : eth_src);
11346 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
11347 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11348 : : pos_token, "eth-dst");
11349 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
11350 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11351 : : eth_dst);
11352 : :
11353 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
11354 : : __rte_unused struct cmdline *cl,
11355 : : __rte_unused void *data)
11356 : : {
11357 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
11358 : : union {
11359 : : uint32_t mplsoudp_label;
11360 : : uint8_t label[4];
11361 : : } id = {
11362 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
11363 : : };
11364 : :
11365 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
11366 : 0 : mplsoudp_encap_conf.select_vlan = 0;
11367 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
11368 : 0 : mplsoudp_encap_conf.select_vlan = 1;
11369 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11370 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
11371 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11372 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
11373 : : else
11374 : : return;
11375 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
11376 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
11377 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
11378 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
11379 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
11380 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
11381 : : } else {
11382 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
11383 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
11384 : : }
11385 : 0 : if (mplsoudp_encap_conf.select_vlan)
11386 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11387 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
11388 : : RTE_ETHER_ADDR_LEN);
11389 : : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11390 : : RTE_ETHER_ADDR_LEN);
11391 : : }
11392 : :
11393 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
11394 : : .f = cmd_set_mplsoudp_encap_parsed,
11395 : : .data = NULL,
11396 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
11397 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
11398 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
11399 : : .tokens = {
11400 : : (void *)&cmd_set_mplsoudp_encap_set,
11401 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
11402 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11403 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11404 : : (void *)&cmd_set_mplsoudp_encap_label,
11405 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11406 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11407 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11408 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11409 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11410 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11411 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11412 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11413 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11414 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11415 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11416 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11417 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11418 : : NULL,
11419 : : },
11420 : : };
11421 : :
11422 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
11423 : : .f = cmd_set_mplsoudp_encap_parsed,
11424 : : .data = NULL,
11425 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
11426 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
11427 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
11428 : : " eth-src <eth-src> eth-dst <eth-dst>",
11429 : : .tokens = {
11430 : : (void *)&cmd_set_mplsoudp_encap_set,
11431 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
11432 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11433 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11434 : : (void *)&cmd_set_mplsoudp_encap_label,
11435 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11436 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11437 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11438 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11439 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11440 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11441 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11442 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11443 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11444 : : (void *)&cmd_set_mplsoudp_encap_vlan,
11445 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
11446 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11447 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11448 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11449 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11450 : : NULL,
11451 : : },
11452 : : };
11453 : :
11454 : : /** Set MPLSoUDP decapsulation details */
11455 : : struct cmd_set_mplsoudp_decap_result {
11456 : : cmdline_fixed_string_t set;
11457 : : cmdline_fixed_string_t mplsoudp;
11458 : : cmdline_fixed_string_t pos_token;
11459 : : cmdline_fixed_string_t ip_version;
11460 : : uint32_t vlan_present:1;
11461 : : };
11462 : :
11463 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
11464 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
11465 : : "set");
11466 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
11467 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
11468 : : "mplsoudp_decap");
11469 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
11470 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11471 : : mplsoudp, "mplsoudp_decap-with-vlan");
11472 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
11473 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11474 : : pos_token, "ip-version");
11475 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
11476 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11477 : : ip_version, "ipv4#ipv6");
11478 : :
11479 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
11480 : : __rte_unused struct cmdline *cl,
11481 : : __rte_unused void *data)
11482 : : {
11483 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
11484 : :
11485 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
11486 : 0 : mplsoudp_decap_conf.select_vlan = 0;
11487 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
11488 : 0 : mplsoudp_decap_conf.select_vlan = 1;
11489 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11490 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
11491 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11492 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
11493 : 0 : }
11494 : :
11495 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
11496 : : .f = cmd_set_mplsoudp_decap_parsed,
11497 : : .data = NULL,
11498 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
11499 : : .tokens = {
11500 : : (void *)&cmd_set_mplsoudp_decap_set,
11501 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
11502 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11503 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11504 : : NULL,
11505 : : },
11506 : : };
11507 : :
11508 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
11509 : : .f = cmd_set_mplsoudp_decap_parsed,
11510 : : .data = NULL,
11511 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
11512 : : .tokens = {
11513 : : (void *)&cmd_set_mplsoudp_decap_set,
11514 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
11515 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11516 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11517 : : NULL,
11518 : : },
11519 : : };
11520 : :
11521 : : /** Set connection tracking object common details */
11522 : : struct cmd_set_conntrack_common_result {
11523 : : cmdline_fixed_string_t set;
11524 : : cmdline_fixed_string_t conntrack;
11525 : : cmdline_fixed_string_t common;
11526 : : cmdline_fixed_string_t peer;
11527 : : cmdline_fixed_string_t is_orig;
11528 : : cmdline_fixed_string_t enable;
11529 : : cmdline_fixed_string_t live;
11530 : : cmdline_fixed_string_t sack;
11531 : : cmdline_fixed_string_t cack;
11532 : : cmdline_fixed_string_t last_dir;
11533 : : cmdline_fixed_string_t liberal;
11534 : : cmdline_fixed_string_t state;
11535 : : cmdline_fixed_string_t max_ack_win;
11536 : : cmdline_fixed_string_t retrans;
11537 : : cmdline_fixed_string_t last_win;
11538 : : cmdline_fixed_string_t last_seq;
11539 : : cmdline_fixed_string_t last_ack;
11540 : : cmdline_fixed_string_t last_end;
11541 : : cmdline_fixed_string_t last_index;
11542 : : uint8_t stat;
11543 : : uint8_t factor;
11544 : : uint16_t peer_port;
11545 : : uint32_t is_original;
11546 : : uint32_t en;
11547 : : uint32_t is_live;
11548 : : uint32_t s_ack;
11549 : : uint32_t c_ack;
11550 : : uint32_t ld;
11551 : : uint32_t lb;
11552 : : uint8_t re_num;
11553 : : uint8_t li;
11554 : : uint16_t lw;
11555 : : uint32_t ls;
11556 : : uint32_t la;
11557 : : uint32_t le;
11558 : : };
11559 : :
11560 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
11561 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11562 : : set, "set");
11563 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
11564 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11565 : : conntrack, "conntrack");
11566 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
11567 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11568 : : common, "com");
11569 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
11570 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11571 : : peer, "peer");
11572 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
11573 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11574 : : peer_port, RTE_UINT16);
11575 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
11576 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11577 : : is_orig, "is_orig");
11578 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
11579 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11580 : : is_original, RTE_UINT32);
11581 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
11582 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11583 : : enable, "enable");
11584 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
11585 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11586 : : en, RTE_UINT32);
11587 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
11588 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11589 : : live, "live");
11590 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
11591 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11592 : : is_live, RTE_UINT32);
11593 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
11594 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11595 : : sack, "sack");
11596 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
11597 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11598 : : s_ack, RTE_UINT32);
11599 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
11600 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11601 : : cack, "cack");
11602 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
11603 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11604 : : c_ack, RTE_UINT32);
11605 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
11606 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11607 : : last_dir, "last_dir");
11608 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
11609 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11610 : : ld, RTE_UINT32);
11611 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
11612 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11613 : : liberal, "liberal");
11614 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
11615 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11616 : : lb, RTE_UINT32);
11617 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
11618 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11619 : : state, "state");
11620 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
11621 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11622 : : stat, RTE_UINT8);
11623 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
11624 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11625 : : max_ack_win, "max_ack_win");
11626 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
11627 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11628 : : factor, RTE_UINT8);
11629 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
11630 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11631 : : retrans, "r_lim");
11632 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
11633 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11634 : : re_num, RTE_UINT8);
11635 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
11636 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11637 : : last_win, "last_win");
11638 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
11639 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11640 : : lw, RTE_UINT16);
11641 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
11642 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11643 : : last_seq, "last_seq");
11644 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
11645 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11646 : : ls, RTE_UINT32);
11647 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
11648 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11649 : : last_ack, "last_ack");
11650 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
11651 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11652 : : la, RTE_UINT32);
11653 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
11654 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11655 : : last_end, "last_end");
11656 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
11657 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11658 : : le, RTE_UINT32);
11659 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
11660 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11661 : : last_index, "last_index");
11662 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
11663 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11664 : : li, RTE_UINT8);
11665 : :
11666 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
11667 : : __rte_unused struct cmdline *cl,
11668 : : __rte_unused void *data)
11669 : : {
11670 : : struct cmd_set_conntrack_common_result *res = parsed_result;
11671 : :
11672 : : /* No need to swap to big endian. */
11673 : 0 : conntrack_context.peer_port = res->peer_port;
11674 : 0 : conntrack_context.is_original_dir = res->is_original;
11675 : 0 : conntrack_context.enable = res->en;
11676 : 0 : conntrack_context.live_connection = res->is_live;
11677 : 0 : conntrack_context.selective_ack = res->s_ack;
11678 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
11679 : 0 : conntrack_context.last_direction = res->ld;
11680 : 0 : conntrack_context.liberal_mode = res->lb;
11681 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
11682 : 0 : conntrack_context.max_ack_window = res->factor;
11683 : 0 : conntrack_context.retransmission_limit = res->re_num;
11684 : 0 : conntrack_context.last_window = res->lw;
11685 : 0 : conntrack_context.last_index =
11686 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
11687 : 0 : conntrack_context.last_seq = res->ls;
11688 : 0 : conntrack_context.last_ack = res->la;
11689 : 0 : conntrack_context.last_end = res->le;
11690 : 0 : }
11691 : :
11692 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
11693 : : .f = cmd_set_conntrack_common_parsed,
11694 : : .data = NULL,
11695 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
11696 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
11697 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
11698 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
11699 : : " last_index <flag>",
11700 : : .tokens = {
11701 : : (void *)&cmd_set_conntrack_set,
11702 : : (void *)&cmd_set_conntrack_conntrack,
11703 : : (void *)&cmd_set_conntrack_common_com,
11704 : : (void *)&cmd_set_conntrack_common_peer,
11705 : : (void *)&cmd_set_conntrack_common_peer_value,
11706 : : (void *)&cmd_set_conntrack_common_is_orig,
11707 : : (void *)&cmd_set_conntrack_common_is_orig_value,
11708 : : (void *)&cmd_set_conntrack_common_enable,
11709 : : (void *)&cmd_set_conntrack_common_enable_value,
11710 : : (void *)&cmd_set_conntrack_common_live,
11711 : : (void *)&cmd_set_conntrack_common_live_value,
11712 : : (void *)&cmd_set_conntrack_common_sack,
11713 : : (void *)&cmd_set_conntrack_common_sack_value,
11714 : : (void *)&cmd_set_conntrack_common_cack,
11715 : : (void *)&cmd_set_conntrack_common_cack_value,
11716 : : (void *)&cmd_set_conntrack_common_last_dir,
11717 : : (void *)&cmd_set_conntrack_common_last_dir_value,
11718 : : (void *)&cmd_set_conntrack_common_liberal,
11719 : : (void *)&cmd_set_conntrack_common_liberal_value,
11720 : : (void *)&cmd_set_conntrack_common_state,
11721 : : (void *)&cmd_set_conntrack_common_state_value,
11722 : : (void *)&cmd_set_conntrack_common_max_ackwin,
11723 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
11724 : : (void *)&cmd_set_conntrack_common_retrans,
11725 : : (void *)&cmd_set_conntrack_common_retrans_value,
11726 : : (void *)&cmd_set_conntrack_common_last_win,
11727 : : (void *)&cmd_set_conntrack_common_last_win_value,
11728 : : (void *)&cmd_set_conntrack_common_last_seq,
11729 : : (void *)&cmd_set_conntrack_common_last_seq_value,
11730 : : (void *)&cmd_set_conntrack_common_last_ack,
11731 : : (void *)&cmd_set_conntrack_common_last_ack_value,
11732 : : (void *)&cmd_set_conntrack_common_last_end,
11733 : : (void *)&cmd_set_conntrack_common_last_end_value,
11734 : : (void *)&cmd_set_conntrack_common_last_index,
11735 : : (void *)&cmd_set_conntrack_common_last_index_value,
11736 : : NULL,
11737 : : },
11738 : : };
11739 : :
11740 : : /** Set connection tracking object both directions' details */
11741 : : struct cmd_set_conntrack_dir_result {
11742 : : cmdline_fixed_string_t set;
11743 : : cmdline_fixed_string_t conntrack;
11744 : : cmdline_fixed_string_t dir;
11745 : : cmdline_fixed_string_t scale;
11746 : : cmdline_fixed_string_t fin;
11747 : : cmdline_fixed_string_t ack_seen;
11748 : : cmdline_fixed_string_t unack;
11749 : : cmdline_fixed_string_t sent_end;
11750 : : cmdline_fixed_string_t reply_end;
11751 : : cmdline_fixed_string_t max_win;
11752 : : cmdline_fixed_string_t max_ack;
11753 : : uint32_t factor;
11754 : : uint32_t f;
11755 : : uint32_t as;
11756 : : uint32_t un;
11757 : : uint32_t se;
11758 : : uint32_t re;
11759 : : uint32_t mw;
11760 : : uint32_t ma;
11761 : : };
11762 : :
11763 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
11764 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11765 : : dir, "orig#rply");
11766 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
11767 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11768 : : scale, "scale");
11769 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
11770 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11771 : : factor, RTE_UINT32);
11772 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
11773 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11774 : : fin, "fin");
11775 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
11776 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11777 : : f, RTE_UINT32);
11778 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
11779 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11780 : : ack_seen, "acked");
11781 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
11782 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11783 : : as, RTE_UINT32);
11784 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
11785 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11786 : : unack, "unack_data");
11787 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
11788 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11789 : : un, RTE_UINT32);
11790 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
11791 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11792 : : sent_end, "sent_end");
11793 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
11794 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11795 : : se, RTE_UINT32);
11796 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
11797 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11798 : : reply_end, "reply_end");
11799 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
11800 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11801 : : re, RTE_UINT32);
11802 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
11803 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11804 : : max_win, "max_win");
11805 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
11806 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11807 : : mw, RTE_UINT32);
11808 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
11809 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11810 : : max_ack, "max_ack");
11811 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
11812 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11813 : : ma, RTE_UINT32);
11814 : :
11815 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
11816 : : __rte_unused struct cmdline *cl,
11817 : : __rte_unused void *data)
11818 : : {
11819 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
11820 : : struct rte_flow_tcp_dir_param *dir = NULL;
11821 : :
11822 : 0 : if (strcmp(res->dir, "orig") == 0)
11823 : : dir = &conntrack_context.original_dir;
11824 : 0 : else if (strcmp(res->dir, "rply") == 0)
11825 : : dir = &conntrack_context.reply_dir;
11826 : : else
11827 : : return;
11828 : 0 : dir->scale = res->factor;
11829 : 0 : dir->close_initiated = res->f;
11830 : 0 : dir->last_ack_seen = res->as;
11831 : 0 : dir->data_unacked = res->un;
11832 : 0 : dir->sent_end = res->se;
11833 : 0 : dir->reply_end = res->re;
11834 : 0 : dir->max_ack = res->ma;
11835 : 0 : dir->max_win = res->mw;
11836 : : }
11837 : :
11838 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
11839 : : .f = cmd_set_conntrack_dir_parsed,
11840 : : .data = NULL,
11841 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
11842 : : " acked <seen> unack_data <unack> sent_end <sent>"
11843 : : " reply_end <reply> max_win <win> max_ack <ack>",
11844 : : .tokens = {
11845 : : (void *)&cmd_set_conntrack_set,
11846 : : (void *)&cmd_set_conntrack_conntrack,
11847 : : (void *)&cmd_set_conntrack_dir_dir,
11848 : : (void *)&cmd_set_conntrack_dir_scale,
11849 : : (void *)&cmd_set_conntrack_dir_scale_value,
11850 : : (void *)&cmd_set_conntrack_dir_fin,
11851 : : (void *)&cmd_set_conntrack_dir_fin_value,
11852 : : (void *)&cmd_set_conntrack_dir_ack,
11853 : : (void *)&cmd_set_conntrack_dir_ack_value,
11854 : : (void *)&cmd_set_conntrack_dir_unack_data,
11855 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
11856 : : (void *)&cmd_set_conntrack_dir_sent_end,
11857 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
11858 : : (void *)&cmd_set_conntrack_dir_reply_end,
11859 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
11860 : : (void *)&cmd_set_conntrack_dir_max_win,
11861 : : (void *)&cmd_set_conntrack_dir_max_win_value,
11862 : : (void *)&cmd_set_conntrack_dir_max_ack,
11863 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
11864 : : NULL,
11865 : : },
11866 : : };
11867 : :
11868 : : /* show vf stats */
11869 : :
11870 : : /* Common result structure for show vf stats */
11871 : : struct cmd_show_vf_stats_result {
11872 : : cmdline_fixed_string_t show;
11873 : : cmdline_fixed_string_t vf;
11874 : : cmdline_fixed_string_t stats;
11875 : : portid_t port_id;
11876 : : uint16_t vf_id;
11877 : : };
11878 : :
11879 : : /* Common CLI fields show vf stats*/
11880 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
11881 : : TOKEN_STRING_INITIALIZER
11882 : : (struct cmd_show_vf_stats_result,
11883 : : show, "show");
11884 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
11885 : : TOKEN_STRING_INITIALIZER
11886 : : (struct cmd_show_vf_stats_result,
11887 : : vf, "vf");
11888 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
11889 : : TOKEN_STRING_INITIALIZER
11890 : : (struct cmd_show_vf_stats_result,
11891 : : stats, "stats");
11892 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
11893 : : TOKEN_NUM_INITIALIZER
11894 : : (struct cmd_show_vf_stats_result,
11895 : : port_id, RTE_UINT16);
11896 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
11897 : : TOKEN_NUM_INITIALIZER
11898 : : (struct cmd_show_vf_stats_result,
11899 : : vf_id, RTE_UINT16);
11900 : :
11901 : : static void
11902 : 0 : cmd_show_vf_stats_parsed(
11903 : : void *parsed_result,
11904 : : __rte_unused struct cmdline *cl,
11905 : : __rte_unused void *data)
11906 : : {
11907 : : struct cmd_show_vf_stats_result *res = parsed_result;
11908 : : struct rte_eth_stats stats;
11909 : : int ret = -ENOTSUP;
11910 : : static const char *nic_stats_border = "########################";
11911 : :
11912 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11913 : 0 : return;
11914 : :
11915 : : memset(&stats, 0, sizeof(stats));
11916 : :
11917 : : #ifdef RTE_NET_I40E
11918 : : if (ret == -ENOTSUP)
11919 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
11920 : 0 : res->vf_id,
11921 : : &stats);
11922 : : #endif
11923 : : #ifdef RTE_NET_BNXT
11924 : 0 : if (ret == -ENOTSUP)
11925 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
11926 : 0 : res->vf_id,
11927 : : &stats);
11928 : : #endif
11929 : :
11930 : 0 : switch (ret) {
11931 : : case 0:
11932 : : break;
11933 : 0 : case -EINVAL:
11934 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11935 : : break;
11936 : 0 : case -ENODEV:
11937 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11938 : : break;
11939 : 0 : case -ENOTSUP:
11940 : 0 : fprintf(stderr, "function not implemented\n");
11941 : : break;
11942 : 0 : default:
11943 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11944 : : }
11945 : :
11946 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
11947 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
11948 : :
11949 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
11950 : : "%-"PRIu64"\n",
11951 : : stats.ipackets, stats.imissed, stats.ibytes);
11952 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
11953 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
11954 : : stats.rx_nombuf);
11955 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
11956 : : "%-"PRIu64"\n",
11957 : : stats.opackets, stats.oerrors, stats.obytes);
11958 : :
11959 : 0 : printf(" %s############################%s\n",
11960 : : nic_stats_border, nic_stats_border);
11961 : : }
11962 : :
11963 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
11964 : : .f = cmd_show_vf_stats_parsed,
11965 : : .data = NULL,
11966 : : .help_str = "show vf stats <port_id> <vf_id>",
11967 : : .tokens = {
11968 : : (void *)&cmd_show_vf_stats_show,
11969 : : (void *)&cmd_show_vf_stats_vf,
11970 : : (void *)&cmd_show_vf_stats_stats,
11971 : : (void *)&cmd_show_vf_stats_port_id,
11972 : : (void *)&cmd_show_vf_stats_vf_id,
11973 : : NULL,
11974 : : },
11975 : : };
11976 : :
11977 : : /* clear vf stats */
11978 : :
11979 : : /* Common result structure for clear vf stats */
11980 : : struct cmd_clear_vf_stats_result {
11981 : : cmdline_fixed_string_t clear;
11982 : : cmdline_fixed_string_t vf;
11983 : : cmdline_fixed_string_t stats;
11984 : : portid_t port_id;
11985 : : uint16_t vf_id;
11986 : : };
11987 : :
11988 : : /* Common CLI fields clear vf stats*/
11989 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
11990 : : TOKEN_STRING_INITIALIZER
11991 : : (struct cmd_clear_vf_stats_result,
11992 : : clear, "clear");
11993 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
11994 : : TOKEN_STRING_INITIALIZER
11995 : : (struct cmd_clear_vf_stats_result,
11996 : : vf, "vf");
11997 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
11998 : : TOKEN_STRING_INITIALIZER
11999 : : (struct cmd_clear_vf_stats_result,
12000 : : stats, "stats");
12001 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
12002 : : TOKEN_NUM_INITIALIZER
12003 : : (struct cmd_clear_vf_stats_result,
12004 : : port_id, RTE_UINT16);
12005 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
12006 : : TOKEN_NUM_INITIALIZER
12007 : : (struct cmd_clear_vf_stats_result,
12008 : : vf_id, RTE_UINT16);
12009 : :
12010 : : static void
12011 : 0 : cmd_clear_vf_stats_parsed(
12012 : : void *parsed_result,
12013 : : __rte_unused struct cmdline *cl,
12014 : : __rte_unused void *data)
12015 : : {
12016 : : struct cmd_clear_vf_stats_result *res = parsed_result;
12017 : : int ret = -ENOTSUP;
12018 : :
12019 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12020 : : return;
12021 : :
12022 : : #ifdef RTE_NET_I40E
12023 : : if (ret == -ENOTSUP)
12024 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
12025 : 0 : res->vf_id);
12026 : : #endif
12027 : : #ifdef RTE_NET_BNXT
12028 : 0 : if (ret == -ENOTSUP)
12029 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
12030 : 0 : res->vf_id);
12031 : : #endif
12032 : :
12033 : 0 : switch (ret) {
12034 : : case 0:
12035 : : break;
12036 : 0 : case -EINVAL:
12037 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
12038 : : break;
12039 : 0 : case -ENODEV:
12040 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
12041 : : break;
12042 : 0 : case -ENOTSUP:
12043 : 0 : fprintf(stderr, "function not implemented\n");
12044 : : break;
12045 : 0 : default:
12046 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
12047 : : }
12048 : : }
12049 : :
12050 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
12051 : : .f = cmd_clear_vf_stats_parsed,
12052 : : .data = NULL,
12053 : : .help_str = "clear vf stats <port_id> <vf_id>",
12054 : : .tokens = {
12055 : : (void *)&cmd_clear_vf_stats_clear,
12056 : : (void *)&cmd_clear_vf_stats_vf,
12057 : : (void *)&cmd_clear_vf_stats_stats,
12058 : : (void *)&cmd_clear_vf_stats_port_id,
12059 : : (void *)&cmd_clear_vf_stats_vf_id,
12060 : : NULL,
12061 : : },
12062 : : };
12063 : :
12064 : : /* Common result structure for file commands */
12065 : : struct cmd_cmdfile_result {
12066 : : cmdline_fixed_string_t load;
12067 : : cmdline_fixed_string_t filename;
12068 : : };
12069 : :
12070 : : /* Common CLI fields for file commands */
12071 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
12072 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
12073 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
12074 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
12075 : :
12076 : : static void
12077 : 0 : cmd_load_from_file_parsed(
12078 : : void *parsed_result,
12079 : : __rte_unused struct cmdline *cl,
12080 : : __rte_unused void *data)
12081 : : {
12082 : : struct cmd_cmdfile_result *res = parsed_result;
12083 : :
12084 : 0 : if (cmdline_read_from_file(res->filename, false) != 0) {
12085 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
12086 : : }
12087 : 0 : }
12088 : :
12089 : : static cmdline_parse_inst_t cmd_load_from_file = {
12090 : : .f = cmd_load_from_file_parsed,
12091 : : .data = NULL,
12092 : : .help_str = "load <filename>",
12093 : : .tokens = {
12094 : : (void *)&cmd_load_cmdfile,
12095 : : (void *)&cmd_load_cmdfile_filename,
12096 : : NULL,
12097 : : },
12098 : : };
12099 : :
12100 : : /* command to load a file with echoing commands */
12101 : : struct cmd_load_echo_result {
12102 : : cmdline_fixed_string_t load_echo;
12103 : : cmdline_fixed_string_t filename;
12104 : : };
12105 : :
12106 : : /* CLI fields for file load with echo command */
12107 : : static cmdline_parse_token_string_t cmd_load_echo =
12108 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, load_echo, "load_echo");
12109 : : static cmdline_parse_token_string_t cmd_load_echo_filename =
12110 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, filename, NULL);
12111 : :
12112 : : static void
12113 : 0 : cmd_load_echo_file_parsed(
12114 : : void *parsed_result,
12115 : : __rte_unused struct cmdline *cl,
12116 : : __rte_unused void *data)
12117 : : {
12118 : : struct cmd_load_echo_result *res = parsed_result;
12119 : :
12120 : 0 : if (cmdline_read_from_file(res->filename, true) != 0)
12121 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
12122 : 0 : }
12123 : :
12124 : : static cmdline_parse_inst_t cmd_load_echo_file = {
12125 : : .f = cmd_load_echo_file_parsed,
12126 : : .data = NULL,
12127 : : .help_str = "load_echo <filename>",
12128 : : .tokens = {
12129 : : (void *)&cmd_load_echo,
12130 : : (void *)&cmd_load_echo_filename,
12131 : : NULL,
12132 : : },
12133 : : };
12134 : :
12135 : : /* Get Rx offloads capabilities */
12136 : : struct cmd_rx_offload_get_capa_result {
12137 : : cmdline_fixed_string_t show;
12138 : : cmdline_fixed_string_t port;
12139 : : portid_t port_id;
12140 : : cmdline_fixed_string_t rx_offload;
12141 : : cmdline_fixed_string_t capabilities;
12142 : : };
12143 : :
12144 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
12145 : : TOKEN_STRING_INITIALIZER
12146 : : (struct cmd_rx_offload_get_capa_result,
12147 : : show, "show");
12148 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
12149 : : TOKEN_STRING_INITIALIZER
12150 : : (struct cmd_rx_offload_get_capa_result,
12151 : : port, "port");
12152 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
12153 : : TOKEN_NUM_INITIALIZER
12154 : : (struct cmd_rx_offload_get_capa_result,
12155 : : port_id, RTE_UINT16);
12156 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
12157 : : TOKEN_STRING_INITIALIZER
12158 : : (struct cmd_rx_offload_get_capa_result,
12159 : : rx_offload, "rx_offload");
12160 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
12161 : : TOKEN_STRING_INITIALIZER
12162 : : (struct cmd_rx_offload_get_capa_result,
12163 : : capabilities, "capabilities");
12164 : :
12165 : : static void
12166 : 0 : print_rx_offloads(uint64_t offloads)
12167 : : {
12168 : : uint64_t single_offload;
12169 : : int begin;
12170 : : int end;
12171 : : int bit;
12172 : :
12173 : 0 : if (offloads == 0)
12174 : : return;
12175 : :
12176 : : begin = rte_ctz64(offloads);
12177 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12178 : :
12179 : 0 : single_offload = 1ULL << begin;
12180 : 0 : for (bit = begin; bit < end; bit++) {
12181 : 0 : if (offloads & single_offload)
12182 : 0 : printf(" %s",
12183 : : rte_eth_dev_rx_offload_name(single_offload));
12184 : 0 : single_offload <<= 1;
12185 : : }
12186 : : }
12187 : :
12188 : : static void
12189 : 0 : cmd_rx_offload_get_capa_parsed(
12190 : : void *parsed_result,
12191 : : __rte_unused struct cmdline *cl,
12192 : : __rte_unused void *data)
12193 : : {
12194 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
12195 : : struct rte_eth_dev_info dev_info;
12196 : 0 : portid_t port_id = res->port_id;
12197 : : uint64_t queue_offloads;
12198 : : uint64_t port_offloads;
12199 : : int ret;
12200 : :
12201 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12202 : 0 : if (ret != 0)
12203 : 0 : return;
12204 : :
12205 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
12206 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
12207 : :
12208 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
12209 : : printf(" Per Queue :");
12210 : 0 : print_rx_offloads(queue_offloads);
12211 : :
12212 : : printf("\n");
12213 : : printf(" Per Port :");
12214 : 0 : print_rx_offloads(port_offloads);
12215 : : printf("\n\n");
12216 : : }
12217 : :
12218 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
12219 : : .f = cmd_rx_offload_get_capa_parsed,
12220 : : .data = NULL,
12221 : : .help_str = "show port <port_id> rx_offload capabilities",
12222 : : .tokens = {
12223 : : (void *)&cmd_rx_offload_get_capa_show,
12224 : : (void *)&cmd_rx_offload_get_capa_port,
12225 : : (void *)&cmd_rx_offload_get_capa_port_id,
12226 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
12227 : : (void *)&cmd_rx_offload_get_capa_capabilities,
12228 : : NULL,
12229 : : }
12230 : : };
12231 : :
12232 : : /* Get Rx offloads configuration */
12233 : : struct cmd_rx_offload_get_configuration_result {
12234 : : cmdline_fixed_string_t show;
12235 : : cmdline_fixed_string_t port;
12236 : : portid_t port_id;
12237 : : cmdline_fixed_string_t rx_offload;
12238 : : cmdline_fixed_string_t configuration;
12239 : : };
12240 : :
12241 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
12242 : : TOKEN_STRING_INITIALIZER
12243 : : (struct cmd_rx_offload_get_configuration_result,
12244 : : show, "show");
12245 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
12246 : : TOKEN_STRING_INITIALIZER
12247 : : (struct cmd_rx_offload_get_configuration_result,
12248 : : port, "port");
12249 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
12250 : : TOKEN_NUM_INITIALIZER
12251 : : (struct cmd_rx_offload_get_configuration_result,
12252 : : port_id, RTE_UINT16);
12253 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
12254 : : TOKEN_STRING_INITIALIZER
12255 : : (struct cmd_rx_offload_get_configuration_result,
12256 : : rx_offload, "rx_offload");
12257 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
12258 : : TOKEN_STRING_INITIALIZER
12259 : : (struct cmd_rx_offload_get_configuration_result,
12260 : : configuration, "configuration");
12261 : :
12262 : : static void
12263 : 0 : cmd_rx_offload_get_configuration_parsed(
12264 : : void *parsed_result,
12265 : : __rte_unused struct cmdline *cl,
12266 : : __rte_unused void *data)
12267 : : {
12268 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
12269 : : struct rte_eth_dev_info dev_info;
12270 : 0 : portid_t port_id = res->port_id;
12271 : : struct rte_port *port;
12272 : : struct rte_eth_conf dev_conf;
12273 : : uint64_t port_offloads;
12274 : : uint64_t queue_offloads;
12275 : : uint16_t nb_rx_queues;
12276 : : int q;
12277 : : int ret;
12278 : :
12279 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12280 : 0 : if (ret != 0)
12281 : 0 : return;
12282 : :
12283 : 0 : port = &ports[port_id];
12284 : : printf("Rx Offloading Configuration of port %d :\n", port_id);
12285 : :
12286 : 0 : port_offloads = dev_conf.rxmode.offloads;
12287 : : printf(" Port :");
12288 : 0 : print_rx_offloads(port_offloads);
12289 : : printf("\n");
12290 : :
12291 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12292 : 0 : if (ret != 0)
12293 : : return;
12294 : :
12295 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12296 : 0 : for (q = 0; q < nb_rx_queues; q++) {
12297 : 0 : queue_offloads = port->rxq[q].conf.offloads;
12298 : : printf(" Queue[%2d] :", q);
12299 : 0 : print_rx_offloads(queue_offloads);
12300 : : printf("\n");
12301 : : }
12302 : : printf("\n");
12303 : : }
12304 : :
12305 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
12306 : : .f = cmd_rx_offload_get_configuration_parsed,
12307 : : .data = NULL,
12308 : : .help_str = "show port <port_id> rx_offload configuration",
12309 : : .tokens = {
12310 : : (void *)&cmd_rx_offload_get_configuration_show,
12311 : : (void *)&cmd_rx_offload_get_configuration_port,
12312 : : (void *)&cmd_rx_offload_get_configuration_port_id,
12313 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
12314 : : (void *)&cmd_rx_offload_get_configuration_configuration,
12315 : : NULL,
12316 : : }
12317 : : };
12318 : :
12319 : : /* Enable/Disable a per port offloading */
12320 : : struct cmd_config_per_port_rx_offload_result {
12321 : : cmdline_fixed_string_t port;
12322 : : cmdline_fixed_string_t config;
12323 : : portid_t port_id;
12324 : : cmdline_fixed_string_t rx_offload;
12325 : : cmdline_fixed_string_t offload;
12326 : : cmdline_fixed_string_t on_off;
12327 : : };
12328 : :
12329 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
12330 : : TOKEN_STRING_INITIALIZER
12331 : : (struct cmd_config_per_port_rx_offload_result,
12332 : : port, "port");
12333 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
12334 : : TOKEN_STRING_INITIALIZER
12335 : : (struct cmd_config_per_port_rx_offload_result,
12336 : : config, "config");
12337 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
12338 : : TOKEN_NUM_INITIALIZER
12339 : : (struct cmd_config_per_port_rx_offload_result,
12340 : : port_id, RTE_UINT16);
12341 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
12342 : : TOKEN_STRING_INITIALIZER
12343 : : (struct cmd_config_per_port_rx_offload_result,
12344 : : rx_offload, "rx_offload");
12345 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
12346 : : TOKEN_STRING_INITIALIZER
12347 : : (struct cmd_config_per_port_rx_offload_result,
12348 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12349 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12350 : : "vlan_filter#vlan_extend#"
12351 : : "scatter#buffer_split#timestamp#security#"
12352 : : "keep_crc#rss_hash");
12353 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
12354 : : TOKEN_STRING_INITIALIZER
12355 : : (struct cmd_config_per_port_rx_offload_result,
12356 : : on_off, "on#off");
12357 : :
12358 : : static uint64_t
12359 : 0 : search_rx_offload(const char *name)
12360 : : {
12361 : : uint64_t single_offload;
12362 : : const char *single_name;
12363 : : int found = 0;
12364 : : unsigned int bit;
12365 : :
12366 : : single_offload = 1;
12367 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12368 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
12369 : 0 : if (!strcasecmp(single_name, name)) {
12370 : : found = 1;
12371 : : break;
12372 : : }
12373 : 0 : single_offload <<= 1;
12374 : : }
12375 : :
12376 : 0 : if (found)
12377 : 0 : return single_offload;
12378 : :
12379 : : return 0;
12380 : : }
12381 : :
12382 : : static void
12383 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
12384 : : {
12385 : : struct rte_eth_dev_info dev_info;
12386 : : struct rte_port *port;
12387 : : uint16_t nb_rx_queues;
12388 : : uint64_t offload;
12389 : : int q;
12390 : : int ret;
12391 : :
12392 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12393 : 0 : if (ret != 0)
12394 : 0 : return;
12395 : :
12396 : 0 : port = &ports[port_id];
12397 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12398 : 0 : fprintf(stderr,
12399 : : "Error: Can't config offload when Port %d is not stopped\n",
12400 : : port_id);
12401 : 0 : return;
12402 : : }
12403 : :
12404 : 0 : if (!strcmp(name, "all")) {
12405 : 0 : offload = dev_info.rx_offload_capa;
12406 : : } else {
12407 : 0 : offload = search_rx_offload(name);
12408 : 0 : if (offload == 0) {
12409 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12410 : 0 : return;
12411 : : }
12412 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
12413 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12414 : : port_id, name);
12415 : 0 : return;
12416 : : }
12417 : : }
12418 : :
12419 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12420 : 0 : if (on) {
12421 : 0 : port->dev_conf.rxmode.offloads |= offload;
12422 : 0 : for (q = 0; q < nb_rx_queues; q++)
12423 : 0 : port->rxq[q].conf.offloads |= offload;
12424 : : } else {
12425 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
12426 : 0 : for (q = 0; q < nb_rx_queues; q++)
12427 : 0 : port->rxq[q].conf.offloads &= ~offload;
12428 : : }
12429 : :
12430 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12431 : : }
12432 : :
12433 : : static void
12434 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
12435 : : __rte_unused struct cmdline *cl,
12436 : : __rte_unused void *data)
12437 : : {
12438 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
12439 : : bool on;
12440 : :
12441 : 0 : on = strcmp(res->on_off, "on") == 0;
12442 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
12443 : 0 : }
12444 : :
12445 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
12446 : : .f = cmd_config_per_port_rx_offload_parsed,
12447 : : .data = NULL,
12448 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
12449 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12450 : : "macsec_strip|vlan_filter|vlan_extend|"
12451 : : "scatter|buffer_split|timestamp|security|"
12452 : : "keep_crc|rss_hash on|off",
12453 : : .tokens = {
12454 : : (void *)&cmd_config_per_port_rx_offload_result_port,
12455 : : (void *)&cmd_config_per_port_rx_offload_result_config,
12456 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
12457 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
12458 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
12459 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
12460 : : NULL,
12461 : : }
12462 : : };
12463 : :
12464 : : /* Enable/Disable all port Rx offloading */
12465 : : struct cmd_config_all_port_rx_offload_result {
12466 : : cmdline_fixed_string_t port;
12467 : : cmdline_fixed_string_t config;
12468 : : cmdline_fixed_string_t port_all;
12469 : : cmdline_fixed_string_t rx_offload;
12470 : : cmdline_fixed_string_t offload;
12471 : : cmdline_fixed_string_t on_off;
12472 : : };
12473 : :
12474 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
12475 : : TOKEN_STRING_INITIALIZER
12476 : : (struct cmd_config_all_port_rx_offload_result,
12477 : : port, "port");
12478 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
12479 : : TOKEN_STRING_INITIALIZER
12480 : : (struct cmd_config_all_port_rx_offload_result,
12481 : : config, "config");
12482 : :
12483 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
12484 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
12485 : : port_all, "all");
12486 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
12487 : : TOKEN_STRING_INITIALIZER
12488 : : (struct cmd_config_all_port_rx_offload_result,
12489 : : rx_offload, "rx_offload");
12490 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
12491 : : TOKEN_STRING_INITIALIZER
12492 : : (struct cmd_config_all_port_rx_offload_result,
12493 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12494 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12495 : : "vlan_filter#vlan_extend#"
12496 : : "scatter#buffer_split#timestamp#security#"
12497 : : "keep_crc#rss_hash");
12498 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
12499 : : TOKEN_STRING_INITIALIZER
12500 : : (struct cmd_config_all_port_rx_offload_result,
12501 : : on_off, "on#off");
12502 : :
12503 : : static void
12504 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
12505 : : __rte_unused struct cmdline *cl,
12506 : : __rte_unused void *data)
12507 : : {
12508 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
12509 : : bool on_off;
12510 : : portid_t i;
12511 : :
12512 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12513 : 0 : RTE_ETH_FOREACH_DEV(i)
12514 : 0 : config_port_rx_offload(i, res->offload, on_off);
12515 : :
12516 : 0 : }
12517 : :
12518 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
12519 : : .f = cmd_config_all_port_rx_offload_parsed,
12520 : : .data = NULL,
12521 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
12522 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12523 : : "macsec_strip|vlan_filter|vlan_extend|"
12524 : : "scatter|buffer_split|timestamp|security|"
12525 : : "keep_crc|rss_hash on|off",
12526 : : .tokens = {
12527 : : (void *)&cmd_config_all_port_rx_offload_result_port,
12528 : : (void *)&cmd_config_all_port_rx_offload_result_config,
12529 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
12530 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
12531 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
12532 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
12533 : : NULL,
12534 : : }
12535 : : };
12536 : :
12537 : : /* Enable/Disable a per queue offloading */
12538 : : struct cmd_config_per_queue_rx_offload_result {
12539 : : cmdline_fixed_string_t port;
12540 : : portid_t port_id;
12541 : : cmdline_fixed_string_t rxq;
12542 : : uint16_t queue_id;
12543 : : cmdline_fixed_string_t rx_offload;
12544 : : cmdline_fixed_string_t offload;
12545 : : cmdline_fixed_string_t on_off;
12546 : : };
12547 : :
12548 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
12549 : : TOKEN_STRING_INITIALIZER
12550 : : (struct cmd_config_per_queue_rx_offload_result,
12551 : : port, "port");
12552 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
12553 : : TOKEN_NUM_INITIALIZER
12554 : : (struct cmd_config_per_queue_rx_offload_result,
12555 : : port_id, RTE_UINT16);
12556 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
12557 : : TOKEN_STRING_INITIALIZER
12558 : : (struct cmd_config_per_queue_rx_offload_result,
12559 : : rxq, "rxq");
12560 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
12561 : : TOKEN_NUM_INITIALIZER
12562 : : (struct cmd_config_per_queue_rx_offload_result,
12563 : : queue_id, RTE_UINT16);
12564 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
12565 : : TOKEN_STRING_INITIALIZER
12566 : : (struct cmd_config_per_queue_rx_offload_result,
12567 : : rx_offload, "rx_offload");
12568 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
12569 : : TOKEN_STRING_INITIALIZER
12570 : : (struct cmd_config_per_queue_rx_offload_result,
12571 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12572 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12573 : : "vlan_filter#vlan_extend#"
12574 : : "scatter#buffer_split#timestamp#security#keep_crc");
12575 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
12576 : : TOKEN_STRING_INITIALIZER
12577 : : (struct cmd_config_per_queue_rx_offload_result,
12578 : : on_off, "on#off");
12579 : :
12580 : : static void
12581 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
12582 : : __rte_unused struct cmdline *cl,
12583 : : __rte_unused void *data)
12584 : : {
12585 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
12586 : : struct rte_eth_dev_info dev_info;
12587 : 0 : portid_t port_id = res->port_id;
12588 : 0 : uint16_t queue_id = res->queue_id;
12589 : : struct rte_port *port;
12590 : : uint64_t offload;
12591 : : int ret;
12592 : :
12593 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12594 : 0 : if (ret != 0)
12595 : 0 : return;
12596 : :
12597 : 0 : port = &ports[port_id];
12598 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12599 : 0 : fprintf(stderr,
12600 : : "Error: Can't config offload when Port %d is not stopped\n",
12601 : : port_id);
12602 : 0 : return;
12603 : : }
12604 : :
12605 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
12606 : 0 : fprintf(stderr,
12607 : : "Error: input queue_id should be 0 ... %d\n",
12608 : 0 : dev_info.nb_rx_queues - 1);
12609 : 0 : return;
12610 : : }
12611 : :
12612 : 0 : if (!strcmp(res->offload, "all")) {
12613 : 0 : offload = dev_info.rx_queue_offload_capa;
12614 : : } else {
12615 : 0 : offload = search_rx_offload(res->offload);
12616 : 0 : if (offload == 0) {
12617 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12618 : 0 : return;
12619 : : }
12620 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
12621 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12622 : : port_id, res->offload);
12623 : 0 : return;
12624 : : }
12625 : : }
12626 : :
12627 : 0 : if (!strcmp(res->on_off, "on"))
12628 : 0 : port->rxq[queue_id].conf.offloads |= offload;
12629 : : else
12630 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
12631 : :
12632 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12633 : : }
12634 : :
12635 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
12636 : : .f = cmd_config_per_queue_rx_offload_parsed,
12637 : : .data = NULL,
12638 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
12639 : : "all|vlan_strip|ipv4_cksum|"
12640 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12641 : : "macsec_strip|vlan_filter|vlan_extend|"
12642 : : "scatter|buffer_split|timestamp|security|"
12643 : : "keep_crc on|off",
12644 : : .tokens = {
12645 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
12646 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
12647 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
12648 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
12649 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
12650 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
12651 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
12652 : : NULL,
12653 : : }
12654 : : };
12655 : :
12656 : : /* Get Tx offloads capabilities */
12657 : : struct cmd_tx_offload_get_capa_result {
12658 : : cmdline_fixed_string_t show;
12659 : : cmdline_fixed_string_t port;
12660 : : portid_t port_id;
12661 : : cmdline_fixed_string_t tx_offload;
12662 : : cmdline_fixed_string_t capabilities;
12663 : : };
12664 : :
12665 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
12666 : : TOKEN_STRING_INITIALIZER
12667 : : (struct cmd_tx_offload_get_capa_result,
12668 : : show, "show");
12669 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
12670 : : TOKEN_STRING_INITIALIZER
12671 : : (struct cmd_tx_offload_get_capa_result,
12672 : : port, "port");
12673 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
12674 : : TOKEN_NUM_INITIALIZER
12675 : : (struct cmd_tx_offload_get_capa_result,
12676 : : port_id, RTE_UINT16);
12677 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
12678 : : TOKEN_STRING_INITIALIZER
12679 : : (struct cmd_tx_offload_get_capa_result,
12680 : : tx_offload, "tx_offload");
12681 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
12682 : : TOKEN_STRING_INITIALIZER
12683 : : (struct cmd_tx_offload_get_capa_result,
12684 : : capabilities, "capabilities");
12685 : :
12686 : : static void
12687 : 0 : print_tx_offloads(uint64_t offloads)
12688 : : {
12689 : : uint64_t single_offload;
12690 : : int begin;
12691 : : int end;
12692 : : int bit;
12693 : :
12694 : 0 : if (offloads == 0)
12695 : : return;
12696 : :
12697 : : begin = rte_ctz64(offloads);
12698 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12699 : :
12700 : 0 : single_offload = 1ULL << begin;
12701 : 0 : for (bit = begin; bit < end; bit++) {
12702 : 0 : if (offloads & single_offload)
12703 : 0 : printf(" %s",
12704 : : rte_eth_dev_tx_offload_name(single_offload));
12705 : 0 : single_offload <<= 1;
12706 : : }
12707 : : }
12708 : :
12709 : : static void
12710 : 0 : cmd_tx_offload_get_capa_parsed(
12711 : : void *parsed_result,
12712 : : __rte_unused struct cmdline *cl,
12713 : : __rte_unused void *data)
12714 : : {
12715 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
12716 : : struct rte_eth_dev_info dev_info;
12717 : 0 : portid_t port_id = res->port_id;
12718 : : uint64_t queue_offloads;
12719 : : uint64_t port_offloads;
12720 : : int ret;
12721 : :
12722 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12723 : 0 : if (ret != 0)
12724 : 0 : return;
12725 : :
12726 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
12727 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
12728 : :
12729 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
12730 : : printf(" Per Queue :");
12731 : 0 : print_tx_offloads(queue_offloads);
12732 : :
12733 : : printf("\n");
12734 : : printf(" Per Port :");
12735 : 0 : print_tx_offloads(port_offloads);
12736 : : printf("\n\n");
12737 : : }
12738 : :
12739 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
12740 : : .f = cmd_tx_offload_get_capa_parsed,
12741 : : .data = NULL,
12742 : : .help_str = "show port <port_id> tx_offload capabilities",
12743 : : .tokens = {
12744 : : (void *)&cmd_tx_offload_get_capa_show,
12745 : : (void *)&cmd_tx_offload_get_capa_port,
12746 : : (void *)&cmd_tx_offload_get_capa_port_id,
12747 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
12748 : : (void *)&cmd_tx_offload_get_capa_capabilities,
12749 : : NULL,
12750 : : }
12751 : : };
12752 : :
12753 : : /* Get Tx offloads configuration */
12754 : : struct cmd_tx_offload_get_configuration_result {
12755 : : cmdline_fixed_string_t show;
12756 : : cmdline_fixed_string_t port;
12757 : : portid_t port_id;
12758 : : cmdline_fixed_string_t tx_offload;
12759 : : cmdline_fixed_string_t configuration;
12760 : : };
12761 : :
12762 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
12763 : : TOKEN_STRING_INITIALIZER
12764 : : (struct cmd_tx_offload_get_configuration_result,
12765 : : show, "show");
12766 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
12767 : : TOKEN_STRING_INITIALIZER
12768 : : (struct cmd_tx_offload_get_configuration_result,
12769 : : port, "port");
12770 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
12771 : : TOKEN_NUM_INITIALIZER
12772 : : (struct cmd_tx_offload_get_configuration_result,
12773 : : port_id, RTE_UINT16);
12774 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
12775 : : TOKEN_STRING_INITIALIZER
12776 : : (struct cmd_tx_offload_get_configuration_result,
12777 : : tx_offload, "tx_offload");
12778 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
12779 : : TOKEN_STRING_INITIALIZER
12780 : : (struct cmd_tx_offload_get_configuration_result,
12781 : : configuration, "configuration");
12782 : :
12783 : : static void
12784 : 0 : cmd_tx_offload_get_configuration_parsed(
12785 : : void *parsed_result,
12786 : : __rte_unused struct cmdline *cl,
12787 : : __rte_unused void *data)
12788 : : {
12789 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
12790 : : struct rte_eth_dev_info dev_info;
12791 : 0 : portid_t port_id = res->port_id;
12792 : : struct rte_port *port;
12793 : : struct rte_eth_conf dev_conf;
12794 : : uint64_t port_offloads;
12795 : : uint64_t queue_offloads;
12796 : : uint16_t nb_tx_queues;
12797 : : int q;
12798 : : int ret;
12799 : :
12800 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12801 : 0 : if (ret != 0)
12802 : 0 : return;
12803 : :
12804 : : printf("Tx Offloading Configuration of port %d :\n", port_id);
12805 : 0 : port = &ports[port_id];
12806 : 0 : port_offloads = dev_conf.txmode.offloads;
12807 : : printf(" Port :");
12808 : 0 : print_tx_offloads(port_offloads);
12809 : : printf("\n");
12810 : :
12811 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12812 : 0 : if (ret != 0)
12813 : : return;
12814 : :
12815 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12816 : 0 : for (q = 0; q < nb_tx_queues; q++) {
12817 : 0 : queue_offloads = port->txq[q].conf.offloads;
12818 : : printf(" Queue[%2d] :", q);
12819 : 0 : print_tx_offloads(queue_offloads);
12820 : : printf("\n");
12821 : : }
12822 : : printf("\n");
12823 : : }
12824 : :
12825 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
12826 : : .f = cmd_tx_offload_get_configuration_parsed,
12827 : : .data = NULL,
12828 : : .help_str = "show port <port_id> tx_offload configuration",
12829 : : .tokens = {
12830 : : (void *)&cmd_tx_offload_get_configuration_show,
12831 : : (void *)&cmd_tx_offload_get_configuration_port,
12832 : : (void *)&cmd_tx_offload_get_configuration_port_id,
12833 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
12834 : : (void *)&cmd_tx_offload_get_configuration_configuration,
12835 : : NULL,
12836 : : }
12837 : : };
12838 : :
12839 : : /* Enable/Disable a per port offloading */
12840 : : struct cmd_config_per_port_tx_offload_result {
12841 : : cmdline_fixed_string_t port;
12842 : : cmdline_fixed_string_t config;
12843 : : portid_t port_id;
12844 : : cmdline_fixed_string_t tx_offload;
12845 : : cmdline_fixed_string_t offload;
12846 : : cmdline_fixed_string_t on_off;
12847 : : };
12848 : :
12849 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
12850 : : TOKEN_STRING_INITIALIZER
12851 : : (struct cmd_config_per_port_tx_offload_result,
12852 : : port, "port");
12853 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
12854 : : TOKEN_STRING_INITIALIZER
12855 : : (struct cmd_config_per_port_tx_offload_result,
12856 : : config, "config");
12857 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
12858 : : TOKEN_NUM_INITIALIZER
12859 : : (struct cmd_config_per_port_tx_offload_result,
12860 : : port_id, RTE_UINT16);
12861 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
12862 : : TOKEN_STRING_INITIALIZER
12863 : : (struct cmd_config_per_port_tx_offload_result,
12864 : : tx_offload, "tx_offload");
12865 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
12866 : : TOKEN_STRING_INITIALIZER
12867 : : (struct cmd_config_per_port_tx_offload_result,
12868 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12869 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12870 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12871 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12872 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12873 : : "send_on_timestamp");
12874 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
12875 : : TOKEN_STRING_INITIALIZER
12876 : : (struct cmd_config_per_port_tx_offload_result,
12877 : : on_off, "on#off");
12878 : :
12879 : : static uint64_t
12880 : 0 : search_tx_offload(const char *name)
12881 : : {
12882 : : uint64_t single_offload;
12883 : : const char *single_name;
12884 : : int found = 0;
12885 : : unsigned int bit;
12886 : :
12887 : : single_offload = 1;
12888 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12889 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
12890 : 0 : if (single_name == NULL)
12891 : : break;
12892 : 0 : if (!strcasecmp(single_name, name)) {
12893 : : found = 1;
12894 : : break;
12895 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
12896 : : break;
12897 : 0 : single_offload <<= 1;
12898 : : }
12899 : :
12900 : 0 : if (found)
12901 : 0 : return single_offload;
12902 : :
12903 : : return 0;
12904 : : }
12905 : :
12906 : : static void
12907 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
12908 : : {
12909 : : struct rte_eth_dev_info dev_info;
12910 : : struct rte_port *port;
12911 : : uint16_t nb_tx_queues;
12912 : : uint64_t offload;
12913 : : int q;
12914 : : int ret;
12915 : :
12916 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12917 : 0 : if (ret != 0)
12918 : 0 : return;
12919 : :
12920 : 0 : port = &ports[port_id];
12921 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12922 : 0 : fprintf(stderr,
12923 : : "Error: Can't config offload when Port %d is not stopped\n",
12924 : : port_id);
12925 : 0 : return;
12926 : : }
12927 : :
12928 : 0 : if (!strcmp(name, "all")) {
12929 : 0 : offload = dev_info.tx_offload_capa;
12930 : : } else {
12931 : 0 : offload = search_tx_offload(name);
12932 : 0 : if (offload == 0) {
12933 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12934 : 0 : return;
12935 : : }
12936 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
12937 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12938 : : port_id, name);
12939 : 0 : return;
12940 : : }
12941 : : }
12942 : :
12943 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12944 : 0 : if (on) {
12945 : 0 : port->dev_conf.txmode.offloads |= offload;
12946 : 0 : for (q = 0; q < nb_tx_queues; q++)
12947 : 0 : port->txq[q].conf.offloads |= offload;
12948 : : } else {
12949 : 0 : port->dev_conf.txmode.offloads &= ~offload;
12950 : 0 : for (q = 0; q < nb_tx_queues; q++)
12951 : 0 : port->txq[q].conf.offloads &= ~offload;
12952 : : }
12953 : :
12954 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12955 : : }
12956 : :
12957 : : static void
12958 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
12959 : : __rte_unused struct cmdline *cl,
12960 : : __rte_unused void *data)
12961 : : {
12962 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
12963 : : bool on;
12964 : :
12965 : 0 : on = strcmp(res->on_off, "on") == 0;
12966 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
12967 : 0 : }
12968 : :
12969 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
12970 : : .f = cmd_config_per_port_tx_offload_parsed,
12971 : : .data = NULL,
12972 : : .help_str = "port config <port_id> tx_offload "
12973 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12974 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12975 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12976 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12977 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12978 : : "send_on_timestamp on|off",
12979 : : .tokens = {
12980 : : (void *)&cmd_config_per_port_tx_offload_result_port,
12981 : : (void *)&cmd_config_per_port_tx_offload_result_config,
12982 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
12983 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
12984 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
12985 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
12986 : : NULL,
12987 : : }
12988 : : };
12989 : :
12990 : : /* Enable/Disable all port Tx offloading */
12991 : : struct cmd_config_all_port_tx_offload_result {
12992 : : cmdline_fixed_string_t port;
12993 : : cmdline_fixed_string_t config;
12994 : : cmdline_fixed_string_t port_all;
12995 : : cmdline_fixed_string_t tx_offload;
12996 : : cmdline_fixed_string_t offload;
12997 : : cmdline_fixed_string_t on_off;
12998 : : };
12999 : :
13000 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
13001 : : TOKEN_STRING_INITIALIZER
13002 : : (struct cmd_config_all_port_tx_offload_result,
13003 : : port, "port");
13004 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
13005 : : TOKEN_STRING_INITIALIZER
13006 : : (struct cmd_config_all_port_tx_offload_result,
13007 : : config, "config");
13008 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
13009 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
13010 : : port_all, "all");
13011 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
13012 : : TOKEN_STRING_INITIALIZER
13013 : : (struct cmd_config_all_port_tx_offload_result,
13014 : : tx_offload, "tx_offload");
13015 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
13016 : : TOKEN_STRING_INITIALIZER
13017 : : (struct cmd_config_all_port_tx_offload_result,
13018 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
13019 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
13020 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
13021 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
13022 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
13023 : : "send_on_timestamp");
13024 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
13025 : : TOKEN_STRING_INITIALIZER
13026 : : (struct cmd_config_all_port_tx_offload_result,
13027 : : on_off, "on#off");
13028 : :
13029 : : static void
13030 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
13031 : : __rte_unused struct cmdline *cl,
13032 : : __rte_unused void *data)
13033 : : {
13034 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
13035 : : portid_t i;
13036 : : bool on_off;
13037 : :
13038 : 0 : on_off = strcmp(res->on_off, "on") == 0;
13039 : 0 : RTE_ETH_FOREACH_DEV(i)
13040 : 0 : config_port_tx_offload(i, res->offload, on_off);
13041 : 0 : }
13042 : :
13043 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
13044 : : .f = cmd_config_all_port_tx_offload_parsed,
13045 : : .data = NULL,
13046 : : .help_str = "port config all tx_offload "
13047 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
13048 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
13049 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
13050 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
13051 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
13052 : : "send_on_timestamp on|off",
13053 : : .tokens = {
13054 : : (void *)&cmd_config_all_port_tx_offload_result_port,
13055 : : (void *)&cmd_config_all_port_tx_offload_result_config,
13056 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
13057 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
13058 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
13059 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
13060 : : NULL,
13061 : : }
13062 : : };
13063 : :
13064 : : /* Enable/Disable a per queue offloading */
13065 : : struct cmd_config_per_queue_tx_offload_result {
13066 : : cmdline_fixed_string_t port;
13067 : : portid_t port_id;
13068 : : cmdline_fixed_string_t txq;
13069 : : uint16_t queue_id;
13070 : : cmdline_fixed_string_t tx_offload;
13071 : : cmdline_fixed_string_t offload;
13072 : : cmdline_fixed_string_t on_off;
13073 : : };
13074 : :
13075 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
13076 : : TOKEN_STRING_INITIALIZER
13077 : : (struct cmd_config_per_queue_tx_offload_result,
13078 : : port, "port");
13079 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
13080 : : TOKEN_NUM_INITIALIZER
13081 : : (struct cmd_config_per_queue_tx_offload_result,
13082 : : port_id, RTE_UINT16);
13083 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
13084 : : TOKEN_STRING_INITIALIZER
13085 : : (struct cmd_config_per_queue_tx_offload_result,
13086 : : txq, "txq");
13087 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
13088 : : TOKEN_NUM_INITIALIZER
13089 : : (struct cmd_config_per_queue_tx_offload_result,
13090 : : queue_id, RTE_UINT16);
13091 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
13092 : : TOKEN_STRING_INITIALIZER
13093 : : (struct cmd_config_per_queue_tx_offload_result,
13094 : : tx_offload, "tx_offload");
13095 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
13096 : : TOKEN_STRING_INITIALIZER
13097 : : (struct cmd_config_per_queue_tx_offload_result,
13098 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
13099 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
13100 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
13101 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
13102 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
13103 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
13104 : : TOKEN_STRING_INITIALIZER
13105 : : (struct cmd_config_per_queue_tx_offload_result,
13106 : : on_off, "on#off");
13107 : :
13108 : : static void
13109 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
13110 : : __rte_unused struct cmdline *cl,
13111 : : __rte_unused void *data)
13112 : : {
13113 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
13114 : : struct rte_eth_dev_info dev_info;
13115 : 0 : portid_t port_id = res->port_id;
13116 : 0 : uint16_t queue_id = res->queue_id;
13117 : : struct rte_port *port;
13118 : : uint64_t offload;
13119 : : int ret;
13120 : :
13121 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
13122 : 0 : if (ret != 0)
13123 : 0 : return;
13124 : :
13125 : 0 : port = &ports[port_id];
13126 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
13127 : 0 : fprintf(stderr,
13128 : : "Error: Can't config offload when Port %d is not stopped\n",
13129 : : port_id);
13130 : 0 : return;
13131 : : }
13132 : :
13133 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
13134 : 0 : fprintf(stderr,
13135 : : "Error: input queue_id should be 0 ... %d\n",
13136 : 0 : dev_info.nb_tx_queues - 1);
13137 : 0 : return;
13138 : : }
13139 : :
13140 : 0 : if (!strcmp(res->offload, "all")) {
13141 : 0 : offload = dev_info.tx_queue_offload_capa;
13142 : : } else {
13143 : 0 : offload = search_tx_offload(res->offload);
13144 : 0 : if (offload == 0) {
13145 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
13146 : 0 : return;
13147 : : }
13148 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
13149 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
13150 : : port_id, res->offload);
13151 : 0 : return;
13152 : : }
13153 : : }
13154 : :
13155 : 0 : if (!strcmp(res->on_off, "on"))
13156 : 0 : port->txq[queue_id].conf.offloads |= offload;
13157 : : else
13158 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
13159 : :
13160 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
13161 : : }
13162 : :
13163 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
13164 : : .f = cmd_config_per_queue_tx_offload_parsed,
13165 : : .data = NULL,
13166 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
13167 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
13168 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
13169 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
13170 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
13171 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
13172 : : "on|off",
13173 : : .tokens = {
13174 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
13175 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
13176 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
13177 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
13178 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
13179 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
13180 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
13181 : : NULL,
13182 : : }
13183 : : };
13184 : :
13185 : : /* *** configure tx_metadata for specific port *** */
13186 : : struct cmd_config_tx_metadata_specific_result {
13187 : : cmdline_fixed_string_t port;
13188 : : cmdline_fixed_string_t keyword;
13189 : : uint16_t port_id;
13190 : : cmdline_fixed_string_t item;
13191 : : uint32_t value;
13192 : : };
13193 : :
13194 : : static void
13195 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
13196 : : __rte_unused struct cmdline *cl,
13197 : : __rte_unused void *data)
13198 : : {
13199 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
13200 : :
13201 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13202 : : return;
13203 : 0 : ports[res->port_id].tx_metadata = res->value;
13204 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
13205 : 0 : if (ports[res->port_id].tx_metadata)
13206 : 0 : add_tx_md_callback(res->port_id);
13207 : : else
13208 : 0 : remove_tx_md_callback(res->port_id);
13209 : 0 : rte_flow_dynf_metadata_register();
13210 : : }
13211 : :
13212 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
13213 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13214 : : port, "port");
13215 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
13216 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13217 : : keyword, "config");
13218 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
13219 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13220 : : port_id, RTE_UINT16);
13221 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
13222 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13223 : : item, "tx_metadata");
13224 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
13225 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13226 : : value, RTE_UINT32);
13227 : :
13228 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
13229 : : .f = cmd_config_tx_metadata_specific_parsed,
13230 : : .data = NULL,
13231 : : .help_str = "port config <port_id> tx_metadata <value>",
13232 : : .tokens = {
13233 : : (void *)&cmd_config_tx_metadata_specific_port,
13234 : : (void *)&cmd_config_tx_metadata_specific_keyword,
13235 : : (void *)&cmd_config_tx_metadata_specific_id,
13236 : : (void *)&cmd_config_tx_metadata_specific_item,
13237 : : (void *)&cmd_config_tx_metadata_specific_value,
13238 : : NULL,
13239 : : },
13240 : : };
13241 : :
13242 : : /* *** set dynf *** */
13243 : : struct cmd_config_tx_dynf_specific_result {
13244 : : cmdline_fixed_string_t port;
13245 : : cmdline_fixed_string_t keyword;
13246 : : uint16_t port_id;
13247 : : cmdline_fixed_string_t item;
13248 : : cmdline_fixed_string_t name;
13249 : : cmdline_fixed_string_t value;
13250 : : };
13251 : :
13252 : : static void
13253 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
13254 : : __rte_unused struct cmdline *cl,
13255 : : __rte_unused void *data)
13256 : : {
13257 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
13258 : : struct rte_mbuf_dynflag desc_flag;
13259 : : int flag;
13260 : : uint64_t old_port_flags;
13261 : :
13262 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13263 : 0 : return;
13264 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
13265 : 0 : if (flag <= 0) {
13266 : 0 : if (strlcpy(desc_flag.name, res->name,
13267 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
13268 : 0 : fprintf(stderr, "Flag name too long\n");
13269 : 0 : return;
13270 : : }
13271 : 0 : desc_flag.flags = 0;
13272 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
13273 : 0 : if (flag < 0) {
13274 : 0 : fprintf(stderr, "Can't register flag\n");
13275 : 0 : return;
13276 : : }
13277 : 0 : strcpy(dynf_names[flag], desc_flag.name);
13278 : : }
13279 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
13280 : 0 : if (!strcmp(res->value, "set")) {
13281 : 0 : ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
13282 : 0 : if (old_port_flags == 0)
13283 : 0 : add_tx_dynf_callback(res->port_id);
13284 : : } else {
13285 : 0 : ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
13286 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
13287 : 0 : remove_tx_dynf_callback(res->port_id);
13288 : : }
13289 : : }
13290 : :
13291 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
13292 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13293 : : keyword, "port");
13294 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
13295 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13296 : : keyword, "config");
13297 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
13298 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13299 : : port_id, RTE_UINT16);
13300 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
13301 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13302 : : item, "dynf");
13303 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
13304 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13305 : : name, NULL);
13306 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
13307 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13308 : : value, "set#clear");
13309 : :
13310 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
13311 : : .f = cmd_config_dynf_specific_parsed,
13312 : : .data = NULL,
13313 : : .help_str = "port config <port id> dynf <name> set|clear",
13314 : : .tokens = {
13315 : : (void *)&cmd_config_tx_dynf_specific_port,
13316 : : (void *)&cmd_config_tx_dynf_specific_keyword,
13317 : : (void *)&cmd_config_tx_dynf_specific_port_id,
13318 : : (void *)&cmd_config_tx_dynf_specific_item,
13319 : : (void *)&cmd_config_tx_dynf_specific_name,
13320 : : (void *)&cmd_config_tx_dynf_specific_value,
13321 : : NULL,
13322 : : },
13323 : : };
13324 : :
13325 : : /* *** display tx_metadata per port configuration *** */
13326 : : struct cmd_show_tx_metadata_result {
13327 : : cmdline_fixed_string_t cmd_show;
13328 : : cmdline_fixed_string_t cmd_port;
13329 : : cmdline_fixed_string_t cmd_keyword;
13330 : : portid_t cmd_pid;
13331 : : };
13332 : :
13333 : : static void
13334 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
13335 : : __rte_unused struct cmdline *cl,
13336 : : __rte_unused void *data)
13337 : : {
13338 : : struct cmd_show_tx_metadata_result *res = parsed_result;
13339 : :
13340 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13341 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
13342 : 0 : return;
13343 : : }
13344 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
13345 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
13346 : 0 : ports[res->cmd_pid].tx_metadata);
13347 : : }
13348 : : }
13349 : :
13350 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
13351 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13352 : : cmd_show, "show");
13353 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
13354 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13355 : : cmd_port, "port");
13356 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
13357 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
13358 : : cmd_pid, RTE_UINT16);
13359 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
13360 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13361 : : cmd_keyword, "tx_metadata");
13362 : :
13363 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
13364 : : .f = cmd_show_tx_metadata_parsed,
13365 : : .data = NULL,
13366 : : .help_str = "show port <port_id> tx_metadata",
13367 : : .tokens = {
13368 : : (void *)&cmd_show_tx_metadata_show,
13369 : : (void *)&cmd_show_tx_metadata_port,
13370 : : (void *)&cmd_show_tx_metadata_pid,
13371 : : (void *)&cmd_show_tx_metadata_keyword,
13372 : : NULL,
13373 : : },
13374 : : };
13375 : :
13376 : : /* *** show fec capability per port configuration *** */
13377 : : struct cmd_show_fec_capability_result {
13378 : : cmdline_fixed_string_t cmd_show;
13379 : : cmdline_fixed_string_t cmd_port;
13380 : : cmdline_fixed_string_t cmd_fec;
13381 : : cmdline_fixed_string_t cmd_keyword;
13382 : : portid_t cmd_pid;
13383 : : };
13384 : :
13385 : : static void
13386 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
13387 : : __rte_unused struct cmdline *cl,
13388 : : __rte_unused void *data)
13389 : : {
13390 : : struct cmd_show_fec_capability_result *res = parsed_result;
13391 : : struct rte_eth_fec_capa *speed_fec_capa;
13392 : : unsigned int num;
13393 : : int ret;
13394 : :
13395 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13396 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13397 : 0 : return;
13398 : : }
13399 : :
13400 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
13401 : 0 : if (ret == -ENOTSUP) {
13402 : 0 : fprintf(stderr, "Function not implemented\n");
13403 : 0 : return;
13404 : 0 : } else if (ret < 0) {
13405 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
13406 : 0 : return;
13407 : : }
13408 : :
13409 : 0 : num = (unsigned int)ret;
13410 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
13411 : 0 : if (speed_fec_capa == NULL) {
13412 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
13413 : 0 : return;
13414 : : }
13415 : :
13416 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
13417 : 0 : if (ret < 0) {
13418 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
13419 : 0 : goto out;
13420 : : }
13421 : :
13422 : 0 : show_fec_capability(num, speed_fec_capa);
13423 : 0 : out:
13424 : 0 : free(speed_fec_capa);
13425 : : }
13426 : :
13427 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
13428 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13429 : : cmd_show, "show");
13430 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
13431 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13432 : : cmd_port, "port");
13433 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
13434 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
13435 : : cmd_pid, RTE_UINT16);
13436 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
13437 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13438 : : cmd_fec, "fec");
13439 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
13440 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13441 : : cmd_keyword, "capabilities");
13442 : :
13443 : : static cmdline_parse_inst_t cmd_show_capability = {
13444 : : .f = cmd_show_fec_capability_parsed,
13445 : : .data = NULL,
13446 : : .help_str = "show port <port_id> fec capabilities",
13447 : : .tokens = {
13448 : : (void *)&cmd_show_fec_capability_show,
13449 : : (void *)&cmd_show_fec_capability_port,
13450 : : (void *)&cmd_show_fec_capability_pid,
13451 : : (void *)&cmd_show_fec_capability_fec,
13452 : : (void *)&cmd_show_fec_capability_keyword,
13453 : : NULL,
13454 : : },
13455 : : };
13456 : :
13457 : : /* *** show fec mode per port configuration *** */
13458 : : struct cmd_show_fec_metadata_result {
13459 : : cmdline_fixed_string_t cmd_show;
13460 : : cmdline_fixed_string_t cmd_port;
13461 : : cmdline_fixed_string_t cmd_keyword;
13462 : : portid_t cmd_pid;
13463 : : };
13464 : :
13465 : : static void
13466 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
13467 : : __rte_unused struct cmdline *cl,
13468 : : __rte_unused void *data)
13469 : : {
13470 : : #define FEC_NAME_SIZE 16
13471 : : struct cmd_show_fec_metadata_result *res = parsed_result;
13472 : : uint32_t mode;
13473 : : char buf[FEC_NAME_SIZE];
13474 : : int ret;
13475 : :
13476 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13477 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13478 : 0 : return;
13479 : : }
13480 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
13481 : 0 : if (ret == -ENOTSUP) {
13482 : 0 : fprintf(stderr, "Function not implemented\n");
13483 : 0 : return;
13484 : 0 : } else if (ret < 0) {
13485 : 0 : fprintf(stderr, "Get FEC mode failed\n");
13486 : 0 : return;
13487 : : }
13488 : :
13489 : 0 : switch (mode) {
13490 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
13491 : : strlcpy(buf, "off", sizeof(buf));
13492 : : break;
13493 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
13494 : : strlcpy(buf, "auto", sizeof(buf));
13495 : : break;
13496 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
13497 : : strlcpy(buf, "baser", sizeof(buf));
13498 : : break;
13499 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
13500 : : strlcpy(buf, "rs", sizeof(buf));
13501 : : break;
13502 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
13503 : : strlcpy(buf, "llrs", sizeof(buf));
13504 : : break;
13505 : : default:
13506 : : return;
13507 : : }
13508 : :
13509 : : printf("%s\n", buf);
13510 : : }
13511 : :
13512 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
13513 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13514 : : cmd_show, "show");
13515 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
13516 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13517 : : cmd_port, "port");
13518 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
13519 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
13520 : : cmd_pid, RTE_UINT16);
13521 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
13522 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13523 : : cmd_keyword, "fec_mode");
13524 : :
13525 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
13526 : : .f = cmd_show_fec_mode_parsed,
13527 : : .data = NULL,
13528 : : .help_str = "show port <port_id> fec_mode",
13529 : : .tokens = {
13530 : : (void *)&cmd_show_fec_mode_show,
13531 : : (void *)&cmd_show_fec_mode_port,
13532 : : (void *)&cmd_show_fec_mode_pid,
13533 : : (void *)&cmd_show_fec_mode_keyword,
13534 : : NULL,
13535 : : },
13536 : : };
13537 : :
13538 : : /* *** set fec mode per port configuration *** */
13539 : : struct cmd_set_port_fec_mode {
13540 : : cmdline_fixed_string_t set;
13541 : : cmdline_fixed_string_t port;
13542 : : portid_t port_id;
13543 : : cmdline_fixed_string_t fec_mode;
13544 : : cmdline_fixed_string_t fec_value;
13545 : : };
13546 : :
13547 : : /* Common CLI fields for set fec mode */
13548 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
13549 : : TOKEN_STRING_INITIALIZER
13550 : : (struct cmd_set_port_fec_mode,
13551 : : set, "set");
13552 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
13553 : : TOKEN_STRING_INITIALIZER
13554 : : (struct cmd_set_port_fec_mode,
13555 : : port, "port");
13556 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
13557 : : TOKEN_NUM_INITIALIZER
13558 : : (struct cmd_set_port_fec_mode,
13559 : : port_id, RTE_UINT16);
13560 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
13561 : : TOKEN_STRING_INITIALIZER
13562 : : (struct cmd_set_port_fec_mode,
13563 : : fec_mode, "fec_mode");
13564 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
13565 : : TOKEN_STRING_INITIALIZER
13566 : : (struct cmd_set_port_fec_mode,
13567 : : fec_value, NULL);
13568 : :
13569 : : static void
13570 : 0 : cmd_set_port_fec_mode_parsed(
13571 : : void *parsed_result,
13572 : : __rte_unused struct cmdline *cl,
13573 : : __rte_unused void *data)
13574 : : {
13575 : : struct cmd_set_port_fec_mode *res = parsed_result;
13576 : 0 : uint16_t port_id = res->port_id;
13577 : : uint32_t fec_capa;
13578 : : int ret;
13579 : :
13580 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
13581 : 0 : if (ret < 0) {
13582 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
13583 : : res->fec_value, port_id);
13584 : 0 : return;
13585 : : }
13586 : :
13587 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
13588 : 0 : if (ret == -ENOTSUP) {
13589 : 0 : fprintf(stderr, "Function not implemented\n");
13590 : 0 : return;
13591 : 0 : } else if (ret < 0) {
13592 : 0 : fprintf(stderr, "Set FEC mode failed\n");
13593 : 0 : return;
13594 : : }
13595 : : }
13596 : :
13597 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
13598 : : .f = cmd_set_port_fec_mode_parsed,
13599 : : .data = NULL,
13600 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
13601 : : .tokens = {
13602 : : (void *)&cmd_set_port_fec_mode_set,
13603 : : (void *)&cmd_set_port_fec_mode_port,
13604 : : (void *)&cmd_set_port_fec_mode_port_id,
13605 : : (void *)&cmd_set_port_fec_mode_str,
13606 : : (void *)&cmd_set_port_fec_mode_value,
13607 : : NULL,
13608 : : },
13609 : : };
13610 : :
13611 : : /* *** set available descriptors threshold for an RxQ of a port *** */
13612 : : struct cmd_set_rxq_avail_thresh_result {
13613 : : cmdline_fixed_string_t set;
13614 : : cmdline_fixed_string_t port;
13615 : : uint16_t port_num;
13616 : : cmdline_fixed_string_t rxq;
13617 : : uint16_t rxq_num;
13618 : : cmdline_fixed_string_t avail_thresh;
13619 : : uint8_t avail_thresh_num;
13620 : : };
13621 : :
13622 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
13623 : : __rte_unused struct cmdline *cl,
13624 : : __rte_unused void *data)
13625 : : {
13626 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
13627 : : int ret = 0;
13628 : :
13629 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
13630 : 0 : && (strcmp(res->rxq, "rxq") == 0)
13631 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
13632 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
13633 : 0 : res->avail_thresh_num);
13634 : 0 : if (ret < 0)
13635 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
13636 : :
13637 : 0 : }
13638 : :
13639 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
13640 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13641 : : set, "set");
13642 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
13643 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13644 : : port, "port");
13645 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
13646 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13647 : : port_num, RTE_UINT16);
13648 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
13649 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13650 : : rxq, "rxq");
13651 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
13652 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13653 : : rxq_num, RTE_UINT16);
13654 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
13655 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13656 : : avail_thresh, "avail_thresh");
13657 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
13658 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13659 : : avail_thresh_num, RTE_UINT8);
13660 : :
13661 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
13662 : : .f = cmd_set_rxq_avail_thresh_parsed,
13663 : : .data = (void *)0,
13664 : : .help_str =
13665 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
13666 : : "Set available descriptors threshold for Rx queue",
13667 : : .tokens = {
13668 : : (void *)&cmd_set_rxq_avail_thresh_set,
13669 : : (void *)&cmd_set_rxq_avail_thresh_port,
13670 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
13671 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
13672 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
13673 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
13674 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
13675 : : NULL,
13676 : : },
13677 : : };
13678 : :
13679 : : /* show port supported ptypes */
13680 : :
13681 : : /* Common result structure for show port ptypes */
13682 : : struct cmd_show_port_supported_ptypes_result {
13683 : : cmdline_fixed_string_t show;
13684 : : cmdline_fixed_string_t port;
13685 : : portid_t port_id;
13686 : : cmdline_fixed_string_t ptypes;
13687 : : };
13688 : :
13689 : : /* Common CLI fields for show port ptypes */
13690 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
13691 : : TOKEN_STRING_INITIALIZER
13692 : : (struct cmd_show_port_supported_ptypes_result,
13693 : : show, "show");
13694 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
13695 : : TOKEN_STRING_INITIALIZER
13696 : : (struct cmd_show_port_supported_ptypes_result,
13697 : : port, "port");
13698 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
13699 : : TOKEN_NUM_INITIALIZER
13700 : : (struct cmd_show_port_supported_ptypes_result,
13701 : : port_id, RTE_UINT16);
13702 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
13703 : : TOKEN_STRING_INITIALIZER
13704 : : (struct cmd_show_port_supported_ptypes_result,
13705 : : ptypes, "ptypes");
13706 : :
13707 : : static void
13708 : 0 : cmd_show_port_supported_ptypes_parsed(
13709 : : void *parsed_result,
13710 : : __rte_unused struct cmdline *cl,
13711 : : __rte_unused void *data)
13712 : : {
13713 : : #define RSVD_PTYPE_MASK 0xf0000000
13714 : : #define MAX_PTYPES_PER_LAYER 16
13715 : : #define LTYPE_NAMESIZE 32
13716 : : #define PTYPE_NAMESIZE 256
13717 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
13718 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
13719 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
13720 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
13721 : 0 : uint16_t port_id = res->port_id;
13722 : : int ret, i;
13723 : :
13724 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
13725 : 0 : if (ret < 0)
13726 : 0 : return;
13727 : :
13728 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
13729 : :
13730 : 0 : switch (ptype_mask) {
13731 : : case RTE_PTYPE_L2_MASK:
13732 : : strlcpy(ltype, "L2", sizeof(ltype));
13733 : : break;
13734 : : case RTE_PTYPE_L3_MASK:
13735 : : strlcpy(ltype, "L3", sizeof(ltype));
13736 : : break;
13737 : : case RTE_PTYPE_L4_MASK:
13738 : : strlcpy(ltype, "L4", sizeof(ltype));
13739 : : break;
13740 : : case RTE_PTYPE_TUNNEL_MASK:
13741 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
13742 : : break;
13743 : : case RTE_PTYPE_INNER_L2_MASK:
13744 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
13745 : : break;
13746 : : case RTE_PTYPE_INNER_L3_MASK:
13747 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
13748 : : break;
13749 : : case RTE_PTYPE_INNER_L4_MASK:
13750 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
13751 : : break;
13752 : : default:
13753 : : return;
13754 : : }
13755 : :
13756 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
13757 : : ptype_mask, ptypes,
13758 : : MAX_PTYPES_PER_LAYER);
13759 : :
13760 : 0 : if (ret > 0)
13761 : : printf("Supported %s ptypes:\n", ltype);
13762 : : else
13763 : : printf("%s ptypes unsupported\n", ltype);
13764 : :
13765 : 0 : for (i = 0; i < ret; ++i) {
13766 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
13767 : : printf("%s\n", buf);
13768 : : }
13769 : :
13770 : 0 : ptype_mask <<= 4;
13771 : : }
13772 : : }
13773 : :
13774 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
13775 : : .f = cmd_show_port_supported_ptypes_parsed,
13776 : : .data = NULL,
13777 : : .help_str = "show port <port_id> ptypes",
13778 : : .tokens = {
13779 : : (void *)&cmd_show_port_supported_ptypes_show,
13780 : : (void *)&cmd_show_port_supported_ptypes_port,
13781 : : (void *)&cmd_show_port_supported_ptypes_port_id,
13782 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
13783 : : NULL,
13784 : : },
13785 : : };
13786 : :
13787 : : /* *** display rx/tx descriptor status *** */
13788 : : struct cmd_show_rx_tx_desc_status_result {
13789 : : cmdline_fixed_string_t cmd_show;
13790 : : cmdline_fixed_string_t cmd_port;
13791 : : cmdline_fixed_string_t cmd_keyword;
13792 : : cmdline_fixed_string_t cmd_desc;
13793 : : cmdline_fixed_string_t cmd_status;
13794 : : portid_t cmd_pid;
13795 : : portid_t cmd_qid;
13796 : : portid_t cmd_did;
13797 : : };
13798 : :
13799 : : static void
13800 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
13801 : : __rte_unused struct cmdline *cl,
13802 : : __rte_unused void *data)
13803 : : {
13804 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
13805 : : int rc;
13806 : :
13807 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
13808 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13809 : 0 : fprintf(stderr,
13810 : : "Invalid input: port id = %d, queue id = %d\n",
13811 : 0 : res->cmd_pid, res->cmd_qid);
13812 : 0 : return;
13813 : : }
13814 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
13815 : 0 : res->cmd_did);
13816 : 0 : if (rc < 0) {
13817 : 0 : fprintf(stderr,
13818 : : "Invalid input: queue id = %d, desc id = %d\n",
13819 : 0 : res->cmd_qid, res->cmd_did);
13820 : 0 : return;
13821 : : }
13822 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
13823 : : printf("Desc status = AVAILABLE\n");
13824 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
13825 : : printf("Desc status = DONE\n");
13826 : : else
13827 : : printf("Desc status = UNAVAILABLE\n");
13828 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
13829 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13830 : 0 : fprintf(stderr,
13831 : : "Invalid input: port id = %d, queue id = %d\n",
13832 : 0 : res->cmd_pid, res->cmd_qid);
13833 : 0 : return;
13834 : : }
13835 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
13836 : 0 : res->cmd_did);
13837 : 0 : if (rc < 0) {
13838 : 0 : fprintf(stderr,
13839 : : "Invalid input: queue id = %d, desc id = %d\n",
13840 : 0 : res->cmd_qid, res->cmd_did);
13841 : 0 : return;
13842 : : }
13843 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
13844 : : printf("Desc status = FULL\n");
13845 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
13846 : : printf("Desc status = DONE\n");
13847 : : else
13848 : : printf("Desc status = UNAVAILABLE\n");
13849 : : }
13850 : : }
13851 : :
13852 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
13853 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13854 : : cmd_show, "show");
13855 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
13856 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13857 : : cmd_port, "port");
13858 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
13859 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13860 : : cmd_pid, RTE_UINT16);
13861 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
13862 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13863 : : cmd_keyword, "rxq#txq");
13864 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
13865 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13866 : : cmd_qid, RTE_UINT16);
13867 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
13868 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13869 : : cmd_desc, "desc");
13870 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
13871 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13872 : : cmd_did, RTE_UINT16);
13873 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
13874 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13875 : : cmd_status, "status");
13876 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
13877 : : .f = cmd_show_rx_tx_desc_status_parsed,
13878 : : .data = NULL,
13879 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
13880 : : "status",
13881 : : .tokens = {
13882 : : (void *)&cmd_show_rx_tx_desc_status_show,
13883 : : (void *)&cmd_show_rx_tx_desc_status_port,
13884 : : (void *)&cmd_show_rx_tx_desc_status_pid,
13885 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
13886 : : (void *)&cmd_show_rx_tx_desc_status_qid,
13887 : : (void *)&cmd_show_rx_tx_desc_status_desc,
13888 : : (void *)&cmd_show_rx_tx_desc_status_did,
13889 : : (void *)&cmd_show_rx_tx_desc_status_status,
13890 : : NULL,
13891 : : },
13892 : : };
13893 : :
13894 : : /* *** display rx/tx queue descriptor used count *** */
13895 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
13896 : : cmdline_fixed_string_t cmd_show;
13897 : : cmdline_fixed_string_t cmd_port;
13898 : : cmdline_fixed_string_t cmd_dir;
13899 : : cmdline_fixed_string_t cmd_desc;
13900 : : cmdline_fixed_string_t cmd_used;
13901 : : cmdline_fixed_string_t cmd_count;
13902 : : portid_t cmd_pid;
13903 : : portid_t cmd_qid;
13904 : : };
13905 : :
13906 : : static void
13907 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
13908 : : __rte_unused void *data)
13909 : : {
13910 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
13911 : : int rc;
13912 : :
13913 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
13914 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13915 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13916 : 0 : res->cmd_pid, res->cmd_qid);
13917 : 0 : return;
13918 : : }
13919 : :
13920 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
13921 : 0 : if (rc < 0) {
13922 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
13923 : 0 : res->cmd_qid);
13924 : 0 : return;
13925 : : }
13926 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
13927 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
13928 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13929 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13930 : 0 : res->cmd_pid, res->cmd_qid);
13931 : 0 : return;
13932 : : }
13933 : :
13934 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
13935 : 0 : if (rc < 0) {
13936 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
13937 : 0 : res->cmd_qid);
13938 : 0 : return;
13939 : : }
13940 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
13941 : : }
13942 : : }
13943 : :
13944 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
13945 : : TOKEN_STRING_INITIALIZER
13946 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13947 : : cmd_show, "show");
13948 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
13949 : : TOKEN_STRING_INITIALIZER
13950 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13951 : : cmd_port, "port");
13952 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
13953 : : TOKEN_NUM_INITIALIZER
13954 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13955 : : cmd_pid, RTE_UINT16);
13956 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
13957 : : TOKEN_STRING_INITIALIZER
13958 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13959 : : cmd_dir, "rxq#txq");
13960 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
13961 : : TOKEN_NUM_INITIALIZER
13962 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13963 : : cmd_qid, RTE_UINT16);
13964 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
13965 : : TOKEN_STRING_INITIALIZER
13966 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13967 : : cmd_desc, "desc");
13968 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
13969 : : TOKEN_STRING_INITIALIZER
13970 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13971 : : cmd_count, "used");
13972 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
13973 : : TOKEN_STRING_INITIALIZER
13974 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13975 : : cmd_count, "count");
13976 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
13977 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
13978 : : .data = NULL,
13979 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
13980 : : .tokens = {
13981 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
13982 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
13983 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
13984 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
13985 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
13986 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
13987 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
13988 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
13989 : : NULL,
13990 : : },
13991 : : };
13992 : :
13993 : : /* Common result structure for set port ptypes */
13994 : : struct cmd_set_port_ptypes_result {
13995 : : cmdline_fixed_string_t set;
13996 : : cmdline_fixed_string_t port;
13997 : : portid_t port_id;
13998 : : cmdline_fixed_string_t ptype_mask;
13999 : : uint32_t mask;
14000 : : };
14001 : :
14002 : : /* Common CLI fields for set port ptypes */
14003 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
14004 : : TOKEN_STRING_INITIALIZER
14005 : : (struct cmd_set_port_ptypes_result,
14006 : : set, "set");
14007 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
14008 : : TOKEN_STRING_INITIALIZER
14009 : : (struct cmd_set_port_ptypes_result,
14010 : : port, "port");
14011 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
14012 : : TOKEN_NUM_INITIALIZER
14013 : : (struct cmd_set_port_ptypes_result,
14014 : : port_id, RTE_UINT16);
14015 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
14016 : : TOKEN_STRING_INITIALIZER
14017 : : (struct cmd_set_port_ptypes_result,
14018 : : ptype_mask, "ptype_mask");
14019 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
14020 : : TOKEN_NUM_INITIALIZER
14021 : : (struct cmd_set_port_ptypes_result,
14022 : : mask, RTE_UINT32);
14023 : :
14024 : : static void
14025 : 0 : cmd_set_port_ptypes_parsed(
14026 : : void *parsed_result,
14027 : : __rte_unused struct cmdline *cl,
14028 : : __rte_unused void *data)
14029 : : {
14030 : : struct cmd_set_port_ptypes_result *res = parsed_result;
14031 : : #define PTYPE_NAMESIZE 256
14032 : : char ptype_name[PTYPE_NAMESIZE];
14033 : 0 : uint16_t port_id = res->port_id;
14034 : 0 : uint32_t ptype_mask = res->mask;
14035 : : int ret, i;
14036 : :
14037 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
14038 : : NULL, 0);
14039 : 0 : if (ret <= 0) {
14040 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
14041 : : port_id);
14042 : 0 : return;
14043 : : }
14044 : :
14045 : 0 : uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
14046 : :
14047 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
14048 : 0 : if (ret < 0) {
14049 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
14050 : : port_id);
14051 : 0 : return;
14052 : : }
14053 : :
14054 : : printf("Successfully set following ptypes for Port %d\n", port_id);
14055 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
14056 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
14057 : : printf("%s\n", ptype_name);
14058 : : }
14059 : :
14060 : 0 : clear_ptypes = false;
14061 : : }
14062 : :
14063 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
14064 : : .f = cmd_set_port_ptypes_parsed,
14065 : : .data = NULL,
14066 : : .help_str = "set port <port_id> ptype_mask <mask>",
14067 : : .tokens = {
14068 : : (void *)&cmd_set_port_ptypes_set,
14069 : : (void *)&cmd_set_port_ptypes_port,
14070 : : (void *)&cmd_set_port_ptypes_port_id,
14071 : : (void *)&cmd_set_port_ptypes_mask_str,
14072 : : (void *)&cmd_set_port_ptypes_mask_u32,
14073 : : NULL,
14074 : : },
14075 : : };
14076 : :
14077 : : /* *** display mac addresses added to a port *** */
14078 : : struct cmd_showport_macs_result {
14079 : : cmdline_fixed_string_t cmd_show;
14080 : : cmdline_fixed_string_t cmd_port;
14081 : : cmdline_fixed_string_t cmd_keyword;
14082 : : portid_t cmd_pid;
14083 : : };
14084 : :
14085 : : static void
14086 : 0 : cmd_showport_macs_parsed(void *parsed_result,
14087 : : __rte_unused struct cmdline *cl,
14088 : : __rte_unused void *data)
14089 : : {
14090 : : struct cmd_showport_macs_result *res = parsed_result;
14091 : :
14092 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
14093 : : return;
14094 : :
14095 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
14096 : 0 : show_macs(res->cmd_pid);
14097 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
14098 : 0 : show_mcast_macs(res->cmd_pid);
14099 : : }
14100 : :
14101 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
14102 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
14103 : : cmd_show, "show");
14104 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
14105 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
14106 : : cmd_port, "port");
14107 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
14108 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
14109 : : cmd_pid, RTE_UINT16);
14110 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
14111 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
14112 : : cmd_keyword, "macs#mcast_macs");
14113 : :
14114 : : static cmdline_parse_inst_t cmd_showport_macs = {
14115 : : .f = cmd_showport_macs_parsed,
14116 : : .data = NULL,
14117 : : .help_str = "show port <port_id> macs|mcast_macs",
14118 : : .tokens = {
14119 : : (void *)&cmd_showport_macs_show,
14120 : : (void *)&cmd_showport_macs_port,
14121 : : (void *)&cmd_showport_macs_pid,
14122 : : (void *)&cmd_showport_macs_keyword,
14123 : : NULL,
14124 : : },
14125 : : };
14126 : :
14127 : : /* *** show flow transfer proxy port ID for the given port *** */
14128 : : struct cmd_show_port_flow_transfer_proxy_result {
14129 : : cmdline_fixed_string_t show;
14130 : : cmdline_fixed_string_t port;
14131 : : portid_t port_id;
14132 : : cmdline_fixed_string_t flow;
14133 : : cmdline_fixed_string_t transfer;
14134 : : cmdline_fixed_string_t proxy;
14135 : : };
14136 : :
14137 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
14138 : : TOKEN_STRING_INITIALIZER
14139 : : (struct cmd_show_port_flow_transfer_proxy_result,
14140 : : show, "show");
14141 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
14142 : : TOKEN_STRING_INITIALIZER
14143 : : (struct cmd_show_port_flow_transfer_proxy_result,
14144 : : port, "port");
14145 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
14146 : : TOKEN_NUM_INITIALIZER
14147 : : (struct cmd_show_port_flow_transfer_proxy_result,
14148 : : port_id, RTE_UINT16);
14149 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
14150 : : TOKEN_STRING_INITIALIZER
14151 : : (struct cmd_show_port_flow_transfer_proxy_result,
14152 : : flow, "flow");
14153 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
14154 : : TOKEN_STRING_INITIALIZER
14155 : : (struct cmd_show_port_flow_transfer_proxy_result,
14156 : : transfer, "transfer");
14157 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
14158 : : TOKEN_STRING_INITIALIZER
14159 : : (struct cmd_show_port_flow_transfer_proxy_result,
14160 : : proxy, "proxy");
14161 : :
14162 : : static void
14163 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
14164 : : __rte_unused struct cmdline *cl,
14165 : : __rte_unused void *data)
14166 : : {
14167 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
14168 : : portid_t proxy_port_id;
14169 : : int ret;
14170 : :
14171 : : printf("\n");
14172 : :
14173 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
14174 : 0 : if (ret != 0) {
14175 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
14176 : : rte_strerror(-ret));
14177 : 0 : return;
14178 : : }
14179 : :
14180 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
14181 : : }
14182 : :
14183 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
14184 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
14185 : : .data = NULL,
14186 : : .help_str = "show port <port_id> flow transfer proxy",
14187 : : .tokens = {
14188 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
14189 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
14190 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
14191 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
14192 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
14193 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
14194 : : NULL,
14195 : : }
14196 : : };
14197 : :
14198 : : /* *** configure port txq affinity value *** */
14199 : : struct cmd_config_tx_affinity_map {
14200 : : cmdline_fixed_string_t port;
14201 : : cmdline_fixed_string_t config;
14202 : : portid_t portid;
14203 : : cmdline_fixed_string_t txq;
14204 : : uint16_t qid;
14205 : : cmdline_fixed_string_t affinity;
14206 : : uint8_t value;
14207 : : };
14208 : :
14209 : : static void
14210 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
14211 : : __rte_unused struct cmdline *cl,
14212 : : __rte_unused void *data)
14213 : : {
14214 : : struct cmd_config_tx_affinity_map *res = parsed_result;
14215 : : int ret;
14216 : :
14217 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
14218 : : return;
14219 : :
14220 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
14221 : : printf("Invalid port id\n");
14222 : 0 : return;
14223 : : }
14224 : :
14225 : 0 : if (strcmp(res->txq, "txq")) {
14226 : : printf("Unknown parameter\n");
14227 : 0 : return;
14228 : : }
14229 : 0 : if (tx_queue_id_is_invalid(res->qid))
14230 : : return;
14231 : :
14232 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
14233 : 0 : if (ret < 0) {
14234 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
14235 : : strerror(-ret));
14236 : 0 : return;
14237 : : }
14238 : :
14239 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
14240 : 0 : if (ret != 0) {
14241 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
14242 : : rte_strerror(-ret));
14243 : 0 : return;
14244 : : }
14245 : : }
14246 : :
14247 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
14248 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14249 : : port, "port");
14250 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
14251 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14252 : : config, "config");
14253 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
14254 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14255 : : portid, RTE_UINT16);
14256 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
14257 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14258 : : txq, "txq");
14259 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
14260 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14261 : : qid, RTE_UINT16);
14262 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
14263 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14264 : : affinity, "affinity");
14265 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
14266 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14267 : : value, RTE_UINT8);
14268 : :
14269 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
14270 : : .f = cmd_config_tx_affinity_map_parsed,
14271 : : .data = (void *)0,
14272 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
14273 : : .tokens = {
14274 : : (void *)&cmd_config_tx_affinity_map_port,
14275 : : (void *)&cmd_config_tx_affinity_map_config,
14276 : : (void *)&cmd_config_tx_affinity_map_portid,
14277 : : (void *)&cmd_config_tx_affinity_map_txq,
14278 : : (void *)&cmd_config_tx_affinity_map_qid,
14279 : : (void *)&cmd_config_tx_affinity_map_affinity,
14280 : : (void *)&cmd_config_tx_affinity_map_value,
14281 : : NULL,
14282 : : },
14283 : : };
14284 : :
14285 : : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
14286 : : struct cmd_dev_led_result {
14287 : : cmdline_fixed_string_t set;
14288 : : cmdline_fixed_string_t port;
14289 : : portid_t port_id;
14290 : : cmdline_fixed_string_t led;
14291 : : cmdline_fixed_string_t state;
14292 : : };
14293 : :
14294 : : static void
14295 : 0 : cmd_set_dev_led_parsed(void *parsed_result,
14296 : : __rte_unused struct cmdline *cl,
14297 : : __rte_unused void *data)
14298 : : {
14299 : : struct cmd_dev_led_result *res = parsed_result;
14300 : :
14301 : 0 : if (strcmp(res->state, "on") == 0)
14302 : 0 : set_dev_led(res->port_id, true);
14303 : : else
14304 : 0 : set_dev_led(res->port_id, false);
14305 : 0 : }
14306 : :
14307 : : static cmdline_parse_token_string_t cmd_dev_led_set =
14308 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
14309 : : static cmdline_parse_token_string_t cmd_dev_led_port =
14310 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
14311 : : static cmdline_parse_token_num_t cmd_dev_led_port_id =
14312 : : TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
14313 : : static cmdline_parse_token_string_t cmd_dev_led =
14314 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
14315 : : static cmdline_parse_token_string_t cmd_dev_state =
14316 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
14317 : :
14318 : : static cmdline_parse_inst_t cmd_set_dev_led = {
14319 : : .f = cmd_set_dev_led_parsed,
14320 : : .data = NULL,
14321 : : .help_str = "set port <port_id> led <on/off>",
14322 : : .tokens = {
14323 : : (void *)&cmd_dev_led_set,
14324 : : (void *)&cmd_dev_led_port,
14325 : : (void *)&cmd_dev_led_port_id,
14326 : : (void *)&cmd_dev_led,
14327 : : (void *)&cmd_dev_state,
14328 : : NULL,
14329 : : },
14330 : : };
14331 : :
14332 : : /* ******************************************************************************** */
14333 : :
14334 : : /* list of instructions */
14335 : : static cmdline_parse_ctx_t builtin_ctx[] = {
14336 : : &cmd_help_brief,
14337 : : &cmd_help_long,
14338 : : &cmd_quit,
14339 : : &cmd_load_from_file,
14340 : : &cmd_load_echo_file,
14341 : : &cmd_showport,
14342 : : &cmd_showqueue,
14343 : : &cmd_showeeprom,
14344 : : &cmd_showeeprom_decode,
14345 : : &cmd_seteeprom,
14346 : : &cmd_showportall,
14347 : : &cmd_representor_info,
14348 : : &cmd_showdevice,
14349 : : &cmd_showcfg,
14350 : : &cmd_showfwdall,
14351 : : &cmd_start,
14352 : : &cmd_start_tx_first,
14353 : : &cmd_start_tx_first_n,
14354 : : &cmd_set_link_up,
14355 : : &cmd_set_link_down,
14356 : : &cmd_reset,
14357 : : &cmd_set_numbers,
14358 : : &cmd_set_log,
14359 : : &cmd_set_rxoffs,
14360 : : &cmd_set_rxpkts,
14361 : : &cmd_set_rxhdrs,
14362 : : &cmd_set_txflows,
14363 : : &cmd_set_txpkts,
14364 : : &cmd_set_txsplit,
14365 : : &cmd_set_txtimes,
14366 : : &cmd_set_fwd_list,
14367 : : &cmd_set_fwd_mask,
14368 : : &cmd_set_fwd_mode,
14369 : : &cmd_set_fwd_retry_mode,
14370 : : &cmd_set_dcb_fwd_tc,
14371 : : &cmd_set_dcb_fwd_tc_cores,
14372 : : &cmd_set_burst_tx_retry,
14373 : : &cmd_set_promisc_mode_one,
14374 : : &cmd_set_promisc_mode_all,
14375 : : &cmd_set_allmulti_mode_one,
14376 : : &cmd_set_allmulti_mode_all,
14377 : : &cmd_set_flush_rx,
14378 : : &cmd_set_link_check,
14379 : : &cmd_vlan_offload,
14380 : : &cmd_vlan_tpid,
14381 : : &cmd_rx_vlan_filter_all,
14382 : : &cmd_rx_vlan_filter,
14383 : : &cmd_tx_vlan_set,
14384 : : &cmd_tx_vlan_set_qinq,
14385 : : &cmd_tx_vlan_reset,
14386 : : &cmd_tx_vlan_set_pvid,
14387 : : &cmd_csum_set,
14388 : : &cmd_csum_show,
14389 : : &cmd_csum_tunnel,
14390 : : &cmd_csum_mac_swap,
14391 : : &cmd_tso_set,
14392 : : &cmd_tso_show,
14393 : : &cmd_tunnel_tso_set,
14394 : : &cmd_tunnel_tso_show,
14395 : : #ifdef RTE_LIB_GRO
14396 : : &cmd_gro_enable,
14397 : : &cmd_gro_flush,
14398 : : &cmd_gro_show,
14399 : : #endif
14400 : : #ifdef RTE_LIB_GSO
14401 : : &cmd_gso_enable,
14402 : : &cmd_gso_size,
14403 : : &cmd_gso_show,
14404 : : #endif
14405 : : &cmd_link_flow_control_set,
14406 : : &cmd_link_flow_control_set_rx,
14407 : : &cmd_link_flow_control_set_tx,
14408 : : &cmd_link_flow_control_set_hw,
14409 : : &cmd_link_flow_control_set_lw,
14410 : : &cmd_link_flow_control_set_pt,
14411 : : &cmd_link_flow_control_set_xon,
14412 : : &cmd_link_flow_control_set_macfwd,
14413 : : &cmd_link_flow_control_set_autoneg,
14414 : : &cmd_link_flow_control_show,
14415 : : &cmd_priority_flow_control_set,
14416 : : &cmd_queue_priority_flow_control_set,
14417 : : &cmd_config_dcb,
14418 : : &cmd_read_rxd_txd,
14419 : : &cmd_stop,
14420 : : &cmd_mac_addr,
14421 : : &cmd_set_fwd_eth_peer,
14422 : : &cmd_set_xstats_hide_zero,
14423 : : &cmd_set_xstats_show_state,
14424 : : &cmd_set_xstats_hide_disabled,
14425 : : &cmd_operate_set_counter,
14426 : : &cmd_set_record_core_cycles,
14427 : : &cmd_set_record_burst_stats,
14428 : : &cmd_operate_port,
14429 : : &cmd_operate_specific_port,
14430 : : &cmd_operate_attach_port,
14431 : : &cmd_operate_detach_port,
14432 : : &cmd_operate_detach_device,
14433 : : &cmd_set_port_setup_on,
14434 : : &cmd_config_speed_all,
14435 : : &cmd_config_speed_all_autoneg,
14436 : : &cmd_config_speed_specific,
14437 : : &cmd_config_speed_specific_autoneg,
14438 : : &cmd_config_speed_lanes_all,
14439 : : &cmd_config_speed_lanes_specific,
14440 : : &cmd_show_speed_lanes,
14441 : : &cmd_config_loopback_all,
14442 : : &cmd_config_loopback_specific,
14443 : : &cmd_config_rx_tx,
14444 : : &cmd_config_mtu,
14445 : : &cmd_config_max_pkt_len,
14446 : : &cmd_config_max_lro_pkt_size,
14447 : : &cmd_config_rx_mode_flag,
14448 : : &cmd_config_rss,
14449 : : &cmd_config_rxtx_ring_size,
14450 : : &cmd_config_rxtx_queue,
14451 : : &cmd_config_deferred_start_rxtx_queue,
14452 : : &cmd_setup_rxtx_queue,
14453 : : &cmd_config_rss_reta,
14454 : : &cmd_showport_reta,
14455 : : &cmd_showport_macs,
14456 : : &cmd_show_port_flow_transfer_proxy,
14457 : : &cmd_config_burst,
14458 : : &cmd_config_thresh,
14459 : : &cmd_config_threshold,
14460 : : &cmd_set_uc_hash_filter,
14461 : : &cmd_set_uc_all_hash_filter,
14462 : : &cmd_vf_mac_addr_filter,
14463 : : &cmd_queue_rate_limit,
14464 : : &cmd_show_queue_rate_limit,
14465 : : &cmd_tunnel_udp_config,
14466 : : &cmd_showport_rss_hash,
14467 : : &cmd_showport_rss_hash_key,
14468 : : &cmd_showport_rss_hash_algo,
14469 : : &cmd_config_rss_hash_key,
14470 : : &cmd_config_rss_hash_algo,
14471 : : &cmd_cleanup_txq_mbufs,
14472 : : &cmd_dump_simple,
14473 : : &cmd_dump_named,
14474 : : &cmd_dump_mbuf_history_stdout,
14475 : : &cmd_dump_mbuf_history_to_file,
14476 : : &cmd_dump_mbuf_pool_history_stdout,
14477 : : &cmd_dump_mbuf_pool_history_to_file,
14478 : : &cmd_flow,
14479 : : &cmd_show_port_meter_cap,
14480 : : &cmd_add_port_meter_profile_srtcm,
14481 : : &cmd_add_port_meter_profile_trtcm,
14482 : : &cmd_add_port_meter_profile_trtcm_rfc4115,
14483 : : &cmd_del_port_meter_profile,
14484 : : &cmd_create_port_meter,
14485 : : &cmd_enable_port_meter,
14486 : : &cmd_disable_port_meter,
14487 : : &cmd_del_port_meter,
14488 : : &cmd_del_port_meter_policy,
14489 : : &cmd_set_port_meter_profile,
14490 : : &cmd_set_port_meter_dscp_table,
14491 : : &cmd_set_port_meter_vlan_table,
14492 : : &cmd_set_port_meter_in_proto,
14493 : : &cmd_get_port_meter_in_proto,
14494 : : &cmd_get_port_meter_in_proto_prio,
14495 : : &cmd_set_port_meter_stats_mask,
14496 : : &cmd_show_port_meter_stats,
14497 : : &cmd_mcast_addr,
14498 : : &cmd_mcast_addr_flush,
14499 : : &cmd_set_vf_vlan_anti_spoof,
14500 : : &cmd_set_vf_mac_anti_spoof,
14501 : : &cmd_set_vf_vlan_stripq,
14502 : : &cmd_set_vf_vlan_insert,
14503 : : &cmd_set_tx_loopback,
14504 : : &cmd_set_all_queues_drop_en,
14505 : : &cmd_set_vf_traffic,
14506 : : &cmd_set_vf_rxmode,
14507 : : &cmd_vf_rate_limit,
14508 : : &cmd_vf_rxvlan_filter,
14509 : : &cmd_set_vf_mac_addr,
14510 : : &cmd_set_vxlan,
14511 : : &cmd_set_vxlan_tos_ttl,
14512 : : &cmd_set_vxlan_with_vlan,
14513 : : &cmd_set_nvgre,
14514 : : &cmd_set_nvgre_with_vlan,
14515 : : &cmd_set_l2_encap,
14516 : : &cmd_set_l2_encap_with_vlan,
14517 : : &cmd_set_l2_decap,
14518 : : &cmd_set_l2_decap_with_vlan,
14519 : : &cmd_set_mplsogre_encap,
14520 : : &cmd_set_mplsogre_encap_with_vlan,
14521 : : &cmd_set_mplsogre_decap,
14522 : : &cmd_set_mplsogre_decap_with_vlan,
14523 : : &cmd_set_mplsoudp_encap,
14524 : : &cmd_set_mplsoudp_encap_with_vlan,
14525 : : &cmd_set_mplsoudp_decap,
14526 : : &cmd_set_mplsoudp_decap_with_vlan,
14527 : : &cmd_set_conntrack_common,
14528 : : &cmd_set_conntrack_dir,
14529 : : &cmd_show_vf_stats,
14530 : : &cmd_clear_vf_stats,
14531 : : &cmd_show_port_supported_ptypes,
14532 : : &cmd_set_port_ptypes,
14533 : : &cmd_show_port_tm_cap,
14534 : : &cmd_show_port_tm_level_cap,
14535 : : &cmd_show_port_tm_node,
14536 : : &cmd_show_port_tm_node_cap,
14537 : : &cmd_show_port_tm_node_type,
14538 : : &cmd_show_port_tm_node_stats,
14539 : : &cmd_add_port_tm_node_shaper_profile,
14540 : : &cmd_del_port_tm_node_shaper_profile,
14541 : : &cmd_add_port_tm_node_shared_shaper,
14542 : : &cmd_del_port_tm_node_shared_shaper,
14543 : : &cmd_add_port_tm_node_wred_profile,
14544 : : &cmd_del_port_tm_node_wred_profile,
14545 : : &cmd_set_port_tm_node_shaper_profile,
14546 : : &cmd_add_port_tm_nonleaf_node,
14547 : : &cmd_add_port_tm_nonleaf_node_pmode,
14548 : : &cmd_add_port_tm_leaf_node,
14549 : : &cmd_del_port_tm_node,
14550 : : &cmd_set_port_tm_node_parent,
14551 : : &cmd_suspend_port_tm_node,
14552 : : &cmd_resume_port_tm_node,
14553 : : &cmd_port_tm_hierarchy_commit,
14554 : : &cmd_port_tm_mark_ip_ecn,
14555 : : &cmd_port_tm_mark_ip_dscp,
14556 : : &cmd_port_tm_mark_vlan_dei,
14557 : : &cmd_cfg_tunnel_udp_port,
14558 : : &cmd_rx_offload_get_capa,
14559 : : &cmd_rx_offload_get_configuration,
14560 : : &cmd_config_per_port_rx_offload,
14561 : : &cmd_config_all_port_rx_offload,
14562 : : &cmd_config_per_queue_rx_offload,
14563 : : &cmd_tx_offload_get_capa,
14564 : : &cmd_tx_offload_get_configuration,
14565 : : &cmd_config_per_port_tx_offload,
14566 : : &cmd_config_all_port_tx_offload,
14567 : : &cmd_config_per_queue_tx_offload,
14568 : : #ifdef RTE_LIB_BPF
14569 : : &cmd_operate_bpf_ld_parse,
14570 : : &cmd_operate_bpf_unld_parse,
14571 : : #endif
14572 : : &cmd_config_tx_metadata_specific,
14573 : : &cmd_show_tx_metadata,
14574 : : &cmd_show_rx_tx_desc_status,
14575 : : &cmd_show_rx_tx_queue_desc_used_count,
14576 : : &cmd_set_raw,
14577 : : &cmd_show_set_raw,
14578 : : &cmd_show_set_raw_all,
14579 : : &cmd_config_tx_dynf_specific,
14580 : : &cmd_show_fec_mode,
14581 : : &cmd_set_fec_mode,
14582 : : &cmd_set_rxq_avail_thresh,
14583 : : &cmd_show_capability,
14584 : : &cmd_set_flex_is_pattern,
14585 : : &cmd_set_flex_spec_pattern,
14586 : : &cmd_show_port_cman_capa,
14587 : : &cmd_show_port_cman_config,
14588 : : &cmd_set_port_cman_config,
14589 : : &cmd_config_tx_affinity_map,
14590 : : &cmd_set_dev_led,
14591 : : NULL,
14592 : : };
14593 : :
14594 : : void
14595 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
14596 : : {
14597 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
14598 : 0 : }
14599 : :
14600 : : int
14601 : 0 : init_cmdline(void)
14602 : : {
14603 : : struct testpmd_driver_commands *c;
14604 : : unsigned int count;
14605 : : unsigned int i;
14606 : :
14607 : : /* initialize non-constant commands */
14608 : 0 : cmd_set_fwd_mode_init();
14609 : 0 : cmd_set_fwd_retry_mode_init();
14610 : :
14611 : : count = 0;
14612 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
14613 : 0 : count++;
14614 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14615 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
14616 : 0 : count++;
14617 : : }
14618 : :
14619 : : /* cmdline expects a NULL terminated array */
14620 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
14621 : 0 : if (main_ctx == NULL)
14622 : : return -1;
14623 : :
14624 : : count = 0;
14625 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
14626 : 0 : main_ctx[count] = builtin_ctx[i];
14627 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14628 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
14629 : 0 : main_ctx[count] = c->commands[i].ctx;
14630 : : }
14631 : :
14632 : : return 0;
14633 : : }
14634 : :
14635 : : /* read cmdline commands from file */
14636 : : int
14637 : 0 : cmdline_read_from_file(const char *filename, bool echo)
14638 : : {
14639 : : struct cmdline *cl;
14640 : : int fd = -1;
14641 : : int ret = 0;
14642 : :
14643 : : /* cmdline_file_new does not produce any output
14644 : : * so when echoing is requested we open filename directly
14645 : : * and then pass that to cmdline_new with stdout as the output path.
14646 : : */
14647 : 0 : if (!echo) {
14648 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14649 : : } else {
14650 : : /* use basename(filename) as prompt */
14651 : 0 : char prompt[32] = "[] ";
14652 : :
14653 : 0 : rte_basename(filename, &prompt[1], sizeof(prompt) - strlen(prompt));
14654 : 0 : strlcat(prompt, "] ", sizeof(prompt));
14655 : :
14656 : : fd = open(filename, O_RDONLY);
14657 : 0 : if (fd < 0) {
14658 : 0 : fprintf(stderr, "Failed to open file %s: %s\n",
14659 : 0 : filename, strerror(errno));
14660 : 0 : return -1;
14661 : : }
14662 : :
14663 : 0 : cl = cmdline_new(main_ctx, prompt, fd, STDOUT_FILENO);
14664 : : }
14665 : 0 : if (cl == NULL) {
14666 : 0 : fprintf(stderr,
14667 : : "Failed to create file based cmdline context: %s\n",
14668 : : filename);
14669 : : ret = -1;
14670 : 0 : goto end;
14671 : : }
14672 : :
14673 : 0 : cmdline_interact(cl);
14674 : : /* when done, if we have echo, we only need to print end of file,
14675 : : * but if no echo, we need to use printf and include the filename.
14676 : : */
14677 : 0 : if (echo)
14678 : 0 : cmdline_printf(cl, "<End-Of-File>\n");
14679 : : else
14680 : : printf("Finished reading CLI commands from %s\n", filename);
14681 : :
14682 : 0 : cmdline_quit(cl);
14683 : 0 : cmdline_free(cl);
14684 : :
14685 : :
14686 : 0 : end:
14687 : 0 : if (fd >= 0)
14688 : 0 : close(fd);
14689 : : return ret;
14690 : : }
14691 : :
14692 : : void
14693 : 0 : prompt_exit(void)
14694 : : {
14695 : 0 : cmdline_quit(testpmd_cl);
14696 : 0 : }
14697 : :
14698 : : /* prompt function, called from main on MAIN lcore */
14699 : : void
14700 : 0 : prompt(void)
14701 : : {
14702 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14703 : 0 : if (testpmd_cl == NULL) {
14704 : 0 : fprintf(stderr,
14705 : : "Failed to create stdin based cmdline context\n");
14706 : 0 : return;
14707 : : }
14708 : :
14709 : 0 : cmdline_interact(testpmd_cl);
14710 : 0 : cmdline_stdin_exit(testpmd_cl);
14711 : : }
14712 : :
14713 : : void
14714 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14715 : : {
14716 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
14717 : : portid_t pid;
14718 : :
14719 : 0 : RTE_ETH_FOREACH_DEV(pid) {
14720 : : /* check if need_reconfig has been set to 1 */
14721 : 0 : if (ports[pid].need_reconfig == 0)
14722 : 0 : ports[pid].need_reconfig = dev;
14723 : : /* check if need_reconfig_queues has been set to 1 */
14724 : 0 : if (ports[pid].need_reconfig_queues == 0)
14725 : 0 : ports[pid].need_reconfig_queues = queue;
14726 : : }
14727 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14728 : : /* check if need_reconfig has been set to 1 */
14729 : 0 : if (ports[id].need_reconfig == 0)
14730 : 0 : ports[id].need_reconfig = dev;
14731 : : /* check if need_reconfig_queues has been set to 1 */
14732 : 0 : if (ports[id].need_reconfig_queues == 0)
14733 : 0 : ports[id].need_reconfig_queues = queue;
14734 : : }
14735 : 0 : }
|