Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2016 Intel Corporation.
3 : : * Copyright(c) 2014 6WIND S.A.
4 : : */
5 : :
6 : : #include <ctype.h>
7 : : #include <stdarg.h>
8 : : #include <errno.h>
9 : : #include <fcntl.h>
10 : : #include <stdio.h>
11 : : #include <stdint.h>
12 : : #include <stdlib.h>
13 : : #include <string.h>
14 : : #include <unistd.h>
15 : : #include <inttypes.h>
16 : : #include <sys/queue.h>
17 : :
18 : : #include <rte_common.h>
19 : : #include <rte_byteorder.h>
20 : : #include <rte_log.h>
21 : : #include <rte_debug.h>
22 : : #include <rte_cycles.h>
23 : : #include <rte_memory.h>
24 : : #include <rte_memzone.h>
25 : : #include <rte_malloc.h>
26 : : #include <rte_launch.h>
27 : : #include <rte_eal.h>
28 : : #include <rte_per_lcore.h>
29 : : #include <rte_lcore.h>
30 : : #include <rte_branch_prediction.h>
31 : : #include <rte_ring.h>
32 : : #include <rte_mempool.h>
33 : : #include <rte_interrupts.h>
34 : : #include <rte_ether.h>
35 : : #include <rte_ethdev.h>
36 : : #include <rte_string_fns.h>
37 : : #include <rte_devargs.h>
38 : : #include <rte_flow.h>
39 : : #ifdef RTE_LIB_GRO
40 : : #include <rte_gro.h>
41 : : #endif
42 : : #include <rte_mbuf_dyn.h>
43 : : #include <rte_mbuf_history.h>
44 : : #include <rte_trace.h>
45 : :
46 : : #include <cmdline_rdline.h>
47 : : #include <cmdline_parse.h>
48 : : #include <cmdline_parse_num.h>
49 : : #include <cmdline_parse_bool.h>
50 : : #include <cmdline_parse_string.h>
51 : : #include <cmdline_parse_ipaddr.h>
52 : : #include <cmdline_parse_etheraddr.h>
53 : : #include <cmdline_socket.h>
54 : : #include <cmdline.h>
55 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
56 : : #include <rte_pmd_dpaa.h>
57 : : #endif
58 : : #ifdef RTE_NET_IXGBE
59 : : #include <rte_pmd_ixgbe.h>
60 : : #endif
61 : : #ifdef RTE_NET_I40E
62 : : #include <rte_pmd_i40e.h>
63 : : #endif
64 : : #ifdef RTE_NET_BNXT
65 : : #include <rte_pmd_bnxt.h>
66 : : #endif
67 : : #include "testpmd.h"
68 : : #include "cmdline_cman.h"
69 : : #include "cmdline_mtr.h"
70 : : #include "cmdline_tm.h"
71 : : #include "bpf_cmd.h"
72 : :
73 : : static struct cmdline *testpmd_cl;
74 : : static cmdline_parse_ctx_t *main_ctx;
75 : : static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
76 : : TAILQ_HEAD_INITIALIZER(driver_commands_head);
77 : :
78 : : /* *** Help command with introduction. *** */
79 : : struct cmd_help_brief_result {
80 : : cmdline_fixed_string_t help;
81 : : };
82 : :
83 : 0 : static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
84 : : struct cmdline *cl,
85 : : __rte_unused void *data)
86 : : {
87 : 0 : cmdline_printf(
88 : : cl,
89 : : "\n"
90 : : "Help is available for the following sections:\n\n"
91 : : " help control : Start and stop forwarding.\n"
92 : : " help display : Displaying port, stats and config "
93 : : "information.\n"
94 : : " help config : Configuration information.\n"
95 : : " help ports : Configuring ports.\n"
96 : : " help filters : Filters configuration help.\n"
97 : : " help traffic_management : Traffic Management commands.\n"
98 : : " help devices : Device related commands.\n"
99 : : " help drivers : Driver specific commands.\n"
100 : : " help all : All of the above sections.\n\n"
101 : : );
102 : :
103 : 0 : }
104 : :
105 : : static cmdline_parse_token_string_t cmd_help_brief_help =
106 : : TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
107 : :
108 : : static cmdline_parse_inst_t cmd_help_brief = {
109 : : .f = cmd_help_brief_parsed,
110 : : .data = NULL,
111 : : .help_str = "help: Show help",
112 : : .tokens = {
113 : : (void *)&cmd_help_brief_help,
114 : : NULL,
115 : : },
116 : : };
117 : :
118 : : /* *** Help command with help sections. *** */
119 : : struct cmd_help_long_result {
120 : : cmdline_fixed_string_t help;
121 : : cmdline_fixed_string_t section;
122 : : };
123 : :
124 : 0 : static void cmd_help_long_parsed(void *parsed_result,
125 : : struct cmdline *cl,
126 : : __rte_unused void *data)
127 : : {
128 : : int show_all = 0;
129 : : struct cmd_help_long_result *res = parsed_result;
130 : :
131 : 0 : if (!strcmp(res->section, "all"))
132 : : show_all = 1;
133 : :
134 : 0 : if (show_all || !strcmp(res->section, "control")) {
135 : :
136 : 0 : cmdline_printf(
137 : : cl,
138 : : "\n"
139 : : "Control forwarding:\n"
140 : : "-------------------\n\n"
141 : :
142 : : "start\n"
143 : : " Start packet forwarding with current configuration.\n\n"
144 : :
145 : : "start tx_first\n"
146 : : " Start packet forwarding with current config"
147 : : " after sending one burst of packets.\n\n"
148 : :
149 : : "stop\n"
150 : : " Stop packet forwarding, and display accumulated"
151 : : " statistics.\n\n"
152 : :
153 : : "quit\n"
154 : : " Quit to prompt.\n\n"
155 : : );
156 : : }
157 : :
158 : 0 : if (show_all || !strcmp(res->section, "display")) {
159 : :
160 : 0 : cmdline_printf(
161 : : cl,
162 : : "\n"
163 : : "Display:\n"
164 : : "--------\n\n"
165 : :
166 : : "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
167 : : " Display information for port_id, or all.\n\n"
168 : :
169 : : "show port info (port_id) representor\n"
170 : : " Show supported representors for a specific port\n\n"
171 : :
172 : : "show port port_id (module_eeprom|eeprom)\n"
173 : : " Display the module EEPROM or EEPROM information for port_id.\n\n"
174 : :
175 : : "set port (port_id) eeprom (accept_risk) magic (magic_num)"
176 : : " value (value) offset (offset)\n"
177 : : " Set the device eeprom for certain port.\nNote:\n"
178 : : " This is a high-risk command and its misuse may"
179 : : " result in unexpected behaviour from the NIC.\n"
180 : : " By inserting \"accept_risk\" into the command, the"
181 : : " user is acknowledging and taking responsibility for"
182 : : " this risk.\n\n"
183 : :
184 : : "show port X rss reta (size) (mask0,mask1,...)\n"
185 : : " Display the rss redirection table entry indicated"
186 : : " by masks on port X. size is used to indicate the"
187 : : " hardware supported reta size\n\n"
188 : :
189 : : "show port (port_id) rss-hash [key | algorithm]\n"
190 : : " Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
191 : :
192 : : "clear port (info|stats|xstats|fdir) (port_id|all)\n"
193 : : " Clear information for port_id, or all.\n\n"
194 : :
195 : : "show (rxq|txq) info (port_id) (queue_id)\n"
196 : : " Display information for configured RX/TX queue.\n\n"
197 : :
198 : : "show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes|dcbfwdtc)\n"
199 : : " Display the given configuration.\n\n"
200 : :
201 : : "read rxd (port_id) (queue_id) (rxd_id)\n"
202 : : " Display an RX descriptor of a port RX queue.\n\n"
203 : :
204 : : "read txd (port_id) (queue_id) (txd_id)\n"
205 : : " Display a TX descriptor of a port TX queue.\n\n"
206 : :
207 : : "show vf stats (port_id) (vf_id)\n"
208 : : " Display a VF's statistics.\n\n"
209 : :
210 : : "clear vf stats (port_id) (vf_id)\n"
211 : : " Reset a VF's statistics.\n\n"
212 : :
213 : : "show port meter stats (port_id) (meter_id) (clear)\n"
214 : : " Get meter stats on a port\n\n"
215 : :
216 : : "show fwd stats all\n"
217 : : " Display statistics for all fwd engines.\n\n"
218 : :
219 : : "clear fwd stats all\n"
220 : : " Clear statistics for all fwd engines.\n\n"
221 : :
222 : : "show port (port_id) rx_offload capabilities\n"
223 : : " List all per queue and per port Rx offloading"
224 : : " capabilities of a port\n\n"
225 : :
226 : : "show port (port_id) rx_offload configuration\n"
227 : : " List port level and all queue level"
228 : : " Rx offloading configuration\n\n"
229 : :
230 : : "show port (port_id) tx_offload capabilities\n"
231 : : " List all per queue and per port"
232 : : " Tx offloading capabilities of a port\n\n"
233 : :
234 : : "show port (port_id) tx_offload configuration\n"
235 : : " List port level and all queue level"
236 : : " Tx offloading configuration\n\n"
237 : :
238 : : "show port (port_id) tx_metadata\n"
239 : : " Show Tx metadata value set"
240 : : " for a specific port\n\n"
241 : :
242 : : "show port (port_id) ptypes\n"
243 : : " Show port supported ptypes"
244 : : " for a specific port\n\n"
245 : :
246 : : "show device info (<identifier>|all)"
247 : : " Show general information about devices probed.\n\n"
248 : :
249 : : "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
250 : : " Show status of rx|tx descriptor.\n\n"
251 : :
252 : : "show port (port_id) rxq|txq (queue_id) desc used count\n"
253 : : " Show current number of used descriptor count for rx|tx.\n\n"
254 : :
255 : : "show port (port_id) macs|mcast_macs"
256 : : " Display list of mac addresses added to port.\n\n"
257 : :
258 : : "show port (port_id) flow transfer proxy\n"
259 : : " Display proxy port to manage transfer flows\n\n"
260 : :
261 : : "show port (port_id) fec capabilities"
262 : : " Show fec capabilities of a port.\n\n"
263 : :
264 : : "show port (port_id) fec_mode"
265 : : " Show fec mode of a port.\n\n"
266 : :
267 : : "show port (port_id) flow_ctrl"
268 : : " Show flow control info of a port.\n\n"
269 : :
270 : : "dump physmem\n"
271 : : " Dumps all physical memory segment layouts\n\n"
272 : :
273 : : "dump socket_mem\n"
274 : : " Dumps the memory usage of all sockets\n\n"
275 : :
276 : : "dump memzone\n"
277 : : " Dumps the layout of all memory zones\n\n"
278 : :
279 : : "dump struct_sizes\n"
280 : : " Dumps the size of all memory structures\n\n"
281 : :
282 : : "dump ring [name]\n"
283 : : " Dumps the status of all or specific element in DPDK rings\n\n"
284 : :
285 : : "dump mempool [name]\n"
286 : : " Dumps the statistics of all or specific memory pool\n\n"
287 : :
288 : : "dump devargs\n"
289 : : " Dumps the user device list\n\n"
290 : :
291 : : "dump lcores\n"
292 : : " Dumps the logical cores list\n\n"
293 : :
294 : : "dump trace\n"
295 : : " Dumps the tracing data to the folder according to the current EAL settings\n\n"
296 : :
297 : : "dump log_types\n"
298 : : " Dumps the log level for all the dpdk modules\n\n"
299 : :
300 : : "dump mbuf history all [file_name]\n"
301 : : " Dumps the mbuf history for all mempools\n\n"
302 : :
303 : : "dump mbuf history <mbuf_addr> [file_name]\n"
304 : : " Dumps the history for a specific mbuf (use 0x<address> format)\n\n"
305 : :
306 : : "dump mbuf pool history <mempool_name> [file_name]\n"
307 : : " Dumps the history for a specific mempool\n\n"
308 : :
309 : : "show port (port_id) speed_lanes capabilities"
310 : : " Show speed lanes capabilities of a port.\n\n"
311 : : );
312 : : }
313 : :
314 : 0 : if (show_all || !strcmp(res->section, "config")) {
315 : 0 : cmdline_printf(
316 : : cl,
317 : : "\n"
318 : : "Configuration:\n"
319 : : "--------------\n"
320 : : "Configuration changes only become active when"
321 : : " forwarding is started/restarted.\n\n"
322 : :
323 : : "set default\n"
324 : : " Reset forwarding to the default configuration.\n\n"
325 : :
326 : : "set verbose (level)\n"
327 : : " Set the debug verbosity level X.\n\n"
328 : :
329 : : "set log global|(type) (level)\n"
330 : : " Set the log level.\n\n"
331 : :
332 : : "set nbport (num)\n"
333 : : " Set number of ports.\n\n"
334 : :
335 : : "set nbcore (num)\n"
336 : : " Set number of cores.\n\n"
337 : :
338 : : "set coremask (mask)\n"
339 : : " Set the forwarding cores hexadecimal mask.\n\n"
340 : :
341 : : "set portmask (mask)\n"
342 : : " Set the forwarding ports hexadecimal mask.\n\n"
343 : :
344 : : "set burst (num)\n"
345 : : " Set number of packets per burst.\n\n"
346 : :
347 : : "set burst tx delay (microseconds) retry (num)\n"
348 : : " Set the transmit delay time and number of retries,"
349 : : " effective when retry is enabled.\n\n"
350 : :
351 : : "set rxoffs (x[,y]*)\n"
352 : : " Set the offset of each packet segment on"
353 : : " receiving if split feature is engaged."
354 : : " Affects only the queues configured with split"
355 : : " offloads.\n\n"
356 : :
357 : : "set rxpkts (x[,y]*)\n"
358 : : " Set the length of each segment to scatter"
359 : : " packets on receiving if split feature is engaged."
360 : : " Affects only the queues configured with split"
361 : : " offloads.\n\n"
362 : :
363 : : "set rxhdrs (eth[,ipv4])*\n"
364 : : " Set the protocol hdr of each segment to scatter"
365 : : " packets on receiving if split feature is engaged."
366 : : " Affects only the queues configured with split"
367 : : " offloads.\n"
368 : : " Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
369 : : "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
370 : : "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
371 : : "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
372 : : "inner-ipv4-sctp|inner-ipv6-sctp\n\n"
373 : :
374 : : "set txpkts (x[,y]*)\n"
375 : : " Set the length of each segment of TXONLY"
376 : : " and optionally CSUM packets.\n\n"
377 : :
378 : : "set txsplit (off|on|rand)\n"
379 : : " Set the split policy for the TX packets."
380 : : " Right now only applicable for CSUM and TXONLY"
381 : : " modes\n\n"
382 : :
383 : : "set txtimes (x, y)\n"
384 : : " Set the scheduling on timestamps"
385 : : " timings for the TXONLY mode\n\n"
386 : :
387 : : "set txflows (N)\n"
388 : : " Set the number of flows per lcore in"
389 : : " txonly multi-flow mode (1-64)\n\n"
390 : :
391 : : "set corelist (x[,y]*)\n"
392 : : " Set the list of forwarding cores.\n\n"
393 : :
394 : : "set portlist (x[,y]*)\n"
395 : : " Set the list of forwarding ports.\n\n"
396 : :
397 : : "set port setup on (iterator|event)\n"
398 : : " Select how attached port is retrieved for setup.\n\n"
399 : :
400 : : "set tx loopback (port_id) (on|off)\n"
401 : : " Enable or disable tx loopback.\n\n"
402 : :
403 : : "set all queues drop (port_id) (on|off)\n"
404 : : " Set drop enable bit for all queues.\n\n"
405 : :
406 : : "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
407 : : " Set MAC antispoof for a VF from the PF.\n\n"
408 : :
409 : : "vlan set stripq (on|off) (port_id,queue_id)\n"
410 : : " Set the VLAN strip for a queue on a port.\n\n"
411 : :
412 : : "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
413 : : " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
414 : :
415 : : "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
416 : : " Set VLAN insert for a VF from the PF.\n\n"
417 : :
418 : : "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
419 : : " Set VLAN antispoof for a VF from the PF.\n\n"
420 : :
421 : : "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
422 : : " Set the VLAN strip or filter or qinq strip or extend\n\n"
423 : :
424 : : "vlan set (inner|outer) tpid (value) (port_id)\n"
425 : : " Set the VLAN TPID for Packet Filtering on"
426 : : " a port\n\n"
427 : :
428 : : "rx_vlan add (vlan_id|all) (port_id)\n"
429 : : " Add a vlan_id, or all identifiers, to the set"
430 : : " of VLAN identifiers filtered by port_id.\n\n"
431 : :
432 : : "rx_vlan rm (vlan_id|all) (port_id)\n"
433 : : " Remove a vlan_id, or all identifiers, from the set"
434 : : " of VLAN identifiers filtered by port_id.\n\n"
435 : :
436 : : "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
437 : : " Add a vlan_id, to the set of VLAN identifiers"
438 : : "filtered for VF(s) from port_id.\n\n"
439 : :
440 : : "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
441 : : " Remove a vlan_id, to the set of VLAN identifiers"
442 : : "filtered for VF(s) from port_id.\n\n"
443 : :
444 : : "rx_vxlan_port add (udp_port) (port_id)\n"
445 : : " Add an UDP port for VXLAN packet filter on a port\n\n"
446 : :
447 : : "rx_vxlan_port rm (udp_port) (port_id)\n"
448 : : " Remove an UDP port for VXLAN packet filter on a port\n\n"
449 : :
450 : : "tx_vlan set (port_id) vlan_tci[, vlan_tci_outer]\n"
451 : : " Set hardware insertion of VLAN TCI (single or double VLAN "
452 : : "depends on the number of VLAN TCIs) in packets sent on a port.\n\n"
453 : :
454 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
455 : : " Set port based TX VLAN insertion.\n\n"
456 : :
457 : : "tx_vlan reset (port_id)\n"
458 : : " Disable hardware insertion of a VLAN header in"
459 : : " packets sent on a port.\n\n"
460 : :
461 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
462 : : " Select hardware or software calculation of the"
463 : : " checksum when transmitting a packet using the"
464 : : " csum forward engine.\n"
465 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
466 : : " outer-ip concerns the outer IP layer in"
467 : : " outer-udp concerns the outer UDP layer in"
468 : : " case the packet is recognized as a tunnel packet by"
469 : : " the forward engine (vxlan, gre and ipip are supported)\n"
470 : : " Please check the NIC datasheet for HW limits.\n\n"
471 : :
472 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
473 : : " If disabled, treat tunnel packets as non-tunneled"
474 : : " packets (treat inner headers as payload). The port\n"
475 : : " argument is the port used for TX in csum forward"
476 : : " engine.\n\n"
477 : :
478 : : "csum show (port_id)\n"
479 : : " Display tx checksum offload configuration\n\n"
480 : :
481 : : "tso set (segsize) (portid)\n"
482 : : " Enable TCP Segmentation Offload in csum forward"
483 : : " engine.\n"
484 : : " Please check the NIC datasheet for HW limits.\n\n"
485 : :
486 : : "tso show (portid)"
487 : : " Display the status of TCP Segmentation Offload.\n\n"
488 : :
489 : : #ifdef RTE_LIB_GRO
490 : : "set port (port_id) gro on|off\n"
491 : : " Enable or disable Generic Receive Offload in"
492 : : " csum forwarding engine.\n\n"
493 : :
494 : : "show port (port_id) gro\n"
495 : : " Display GRO configuration.\n\n"
496 : :
497 : : "set gro flush (cycles)\n"
498 : : " Set the cycle to flush GROed packets from"
499 : : " reassembly tables.\n\n"
500 : : #endif
501 : :
502 : : #ifdef RTE_LIB_GSO
503 : : "set port (port_id) gso (on|off)"
504 : : " Enable or disable Generic Segmentation Offload in"
505 : : " csum forwarding engine.\n\n"
506 : :
507 : : "set gso segsz (length)\n"
508 : : " Set max packet length for output GSO segments,"
509 : : " including packet header and payload.\n\n"
510 : :
511 : : "show port (port_id) gso\n"
512 : : " Show GSO configuration.\n\n"
513 : : #endif
514 : :
515 : : "set fwd (%s)\n"
516 : : " Set packet forwarding mode.\n\n"
517 : :
518 : : "set dcb fwd_tc (tc_mask)\n"
519 : : " Set DCB forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled\n\n"
520 : :
521 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
522 : : " Add a MAC address on port_id.\n\n"
523 : :
524 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
525 : : " Remove a MAC address from port_id.\n\n"
526 : :
527 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
528 : : " Set the default MAC address for port_id.\n\n"
529 : :
530 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
531 : : " Add a MAC address for a VF on the port.\n\n"
532 : :
533 : : "mcast_addr add (port_id) (mcast_addr)\n"
534 : : " Add a multicast MAC addresses on port_id.\n\n"
535 : :
536 : : "mcast_addr remove (port_id) (mcast_addr)\n"
537 : : " Remove a multicast MAC address from port_id.\n\n"
538 : :
539 : : "mcast_addr flush (port_id)\n"
540 : : " Flush all multicast MAC addresses on port_id.\n\n"
541 : :
542 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
543 : : " Set the MAC address for a VF from the PF.\n\n"
544 : :
545 : : "set eth-peer (port_id) (peer_addr)\n"
546 : : " set the peer address for certain port.\n\n"
547 : :
548 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
549 : : " Add/Remove a or all unicast hash filter(s)"
550 : : "from port X.\n\n"
551 : :
552 : : "set promisc (port_id|all) (on|off)\n"
553 : : " Set the promiscuous mode on port_id, or all.\n\n"
554 : :
555 : : "set allmulti (port_id|all) (on|off)\n"
556 : : " Set the allmulti mode on port_id, or all.\n\n"
557 : :
558 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
559 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
560 : : " (on|off) autoneg (on|off) (port_id)\n"
561 : : "set flow_ctrl rx (on|off) (portid)\n"
562 : : "set flow_ctrl tx (on|off) (portid)\n"
563 : : "set flow_ctrl high_water (high_water) (portid)\n"
564 : : "set flow_ctrl low_water (low_water) (portid)\n"
565 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
566 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
567 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
568 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
569 : : " Set the link flow control parameter on a port.\n\n"
570 : :
571 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
572 : : " (low_water) (pause_time) (priority) (port_id)\n"
573 : : " Set the priority flow control parameter on a"
574 : : " port.\n\n"
575 : :
576 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
577 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
578 : : " Set the queue priority flow control parameter on a"
579 : : " given Rx and Tx queues of a port.\n\n"
580 : :
581 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
582 : : " set available descriptors threshold for Rx queue\n\n"
583 : :
584 : : "set xstats-hide-zero on|off\n"
585 : : " Set the option to hide the zero values"
586 : : " for xstats display.\n"
587 : :
588 : : "set record-core-cycles on|off\n"
589 : : " Set the option to enable measurement of CPU cycles.\n"
590 : :
591 : : "set record-burst-stats on|off\n"
592 : : " Set the option to enable display of RX and TX bursts.\n"
593 : :
594 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
595 : : " Enable/Disable a VF receive/transmit from a port\n\n"
596 : :
597 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
598 : : "|MPE) (on|off)\n"
599 : : " AUPE:accepts untagged VLAN;"
600 : : "ROPE:accept unicast hash\n\n"
601 : : " BAM:accepts broadcast packets;"
602 : : "MPE:accepts all multicast packets\n\n"
603 : : " Enable/Disable a VF receive mode of a port\n\n"
604 : :
605 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
606 : : " Set rate limit for a queue of a port\n\n"
607 : :
608 : : "set port (port_id) vf (vf_id) rate (rate_num) "
609 : : "queue_mask (queue_mask_value)\n"
610 : : " Set rate limit for queues in VF of a port\n\n"
611 : :
612 : : "set flush_rx (on|off)\n"
613 : : " Flush (default) or don't flush RX streams before"
614 : : " forwarding. Mainly used with PCAP drivers.\n\n"
615 : :
616 : : "set link-up port (port_id)\n"
617 : : " Set link up for a port.\n\n"
618 : :
619 : : "set link-down port (port_id)\n"
620 : : " Set link down for a port.\n\n"
621 : :
622 : : "set port (port_id) ptype_mask (ptype_mask)\n"
623 : : " set packet types classification for a specific port\n\n"
624 : :
625 : : "show port meter cap (port_id)\n"
626 : : " Show port meter capability information\n\n"
627 : :
628 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
629 : : " meter profile add - srtcm rfc 2697\n\n"
630 : :
631 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
632 : : " meter profile add - trtcm rfc 2698\n\n"
633 : :
634 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
635 : : " meter profile add - trtcm rfc 4115\n\n"
636 : :
637 : : "del port meter profile (port_id) (profile_id)\n"
638 : : " meter profile delete\n\n"
639 : :
640 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
641 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
642 : : "(dscp_tbl_entry63)]\n"
643 : : " meter create\n\n"
644 : :
645 : : "enable port meter (port_id) (mtr_id)\n"
646 : : " meter enable\n\n"
647 : :
648 : : "disable port meter (port_id) (mtr_id)\n"
649 : : " meter disable\n\n"
650 : :
651 : : "del port meter (port_id) (mtr_id)\n"
652 : : " meter delete\n\n"
653 : :
654 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
655 : : "y_actions (actions) r_actions (actions)\n"
656 : : " meter policy add\n\n"
657 : :
658 : : "del port meter policy (port_id) (policy_id)\n"
659 : : " meter policy delete\n\n"
660 : :
661 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
662 : : " meter update meter profile\n\n"
663 : :
664 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
665 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
666 : : " update meter dscp table entries\n\n"
667 : :
668 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
669 : : "(action0) [(action1) (action2)]\n"
670 : : " meter update policer action\n\n"
671 : :
672 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
673 : : " meter update stats\n\n"
674 : :
675 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
676 : : " set fec mode for a specific port\n\n"
677 : :
678 : : "show port cman capa (port_id)\n"
679 : : " Show congestion management capabilities\n\n"
680 : :
681 : : "show port cman config (port_id)\n"
682 : : " Show congestion management configuration\n\n"
683 : :
684 : : "set port cman config (port_id) (queue_id) default | "
685 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
686 : : "(max_thresh) (prob_inv)]\n"
687 : : " Set congestion management configuration\n\n"
688 : :
689 : : "set port (port_id) led (on|off)\n"
690 : : " Set a controllable LED associated with a certain"
691 : : " port on or off.\n\n"
692 : :
693 : : , list_pkt_forwarding_modes()
694 : : );
695 : : }
696 : :
697 : 0 : if (show_all || !strcmp(res->section, "ports")) {
698 : :
699 : 0 : cmdline_printf(
700 : : cl,
701 : : "\n"
702 : : "Port Operations:\n"
703 : : "----------------\n\n"
704 : :
705 : : "port start (port_id|all)\n"
706 : : " Start all ports or port_id.\n\n"
707 : :
708 : : "port stop (port_id|all)\n"
709 : : " Stop all ports or port_id.\n\n"
710 : :
711 : : "port close (port_id|all)\n"
712 : : " Close all ports or port_id.\n\n"
713 : :
714 : : "port reset (port_id|all)\n"
715 : : " Reset all ports or port_id.\n\n"
716 : :
717 : : "port attach (ident)\n"
718 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
719 : :
720 : : "port detach (port_id)\n"
721 : : " Detach physical or virtual dev by port_id\n\n"
722 : :
723 : : "port config (port_id|all)"
724 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|"
725 : : "100000|200000|400000|800000|auto)"
726 : : " duplex (half|full|auto)\n"
727 : : " Set speed and duplex for all ports or port_id\n\n"
728 : :
729 : : "port config (port_id|all) loopback (mode)\n"
730 : : " Set loopback mode for all ports or port_id\n\n"
731 : :
732 : : "port config all (rxq|txq|rxd|txd) (value)\n"
733 : : " Set number for rxq/txq/rxd/txd.\n\n"
734 : :
735 : : "port config all max-pkt-len (value)\n"
736 : : " Set the max packet length.\n\n"
737 : :
738 : : "port config all max-lro-pkt-size (value)\n"
739 : : " Set the max LRO aggregated packet size.\n\n"
740 : :
741 : : "port config all drop-en (on|off)\n"
742 : : " Enable or disable packet drop on all RX queues of all ports when no "
743 : : "receive buffers available.\n\n"
744 : :
745 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
746 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
747 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
748 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
749 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
750 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
751 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
752 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
753 : : " Set the RSS mode.\n\n"
754 : :
755 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
756 : : " Set the RSS redirection table.\n\n"
757 : :
758 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
759 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
760 : : " Set the RSS hash algorithm.\n\n"
761 : :
762 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
763 : : " pfc (on|off)\n"
764 : : " Set the DCB mode.\n\n"
765 : :
766 : : "port config all burst (value)\n"
767 : : " Set the number of packets per burst.\n\n"
768 : :
769 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
770 : : " (value)\n"
771 : : " Set the ring prefetch/host/writeback threshold"
772 : : " for tx/rx queue.\n\n"
773 : :
774 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
775 : : " Set free threshold for rx/tx, or set"
776 : : " tx rs bit threshold.\n\n"
777 : : "port config mtu X value\n"
778 : : " Set the MTU of port X to a given value\n\n"
779 : :
780 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
781 : : " Set a rx/tx queue's ring size configuration, the new"
782 : : " value will take effect after command that (re-)start the port"
783 : : " or command that setup the specific queue\n\n"
784 : :
785 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
786 : : " Start/stop a rx/tx queue of port X. Only take effect"
787 : : " when port X is started\n\n"
788 : :
789 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
790 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
791 : : " take effect when port X is stopped.\n\n"
792 : :
793 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
794 : : " Setup a rx/tx queue of port X.\n\n"
795 : :
796 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
797 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
798 : :
799 : : "port config (port_id|all) rx_offload all|vlan_strip|"
800 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
801 : : "outer_ipv4_cksum|macsec_strip|"
802 : : "vlan_filter|vlan_extend|scatter|"
803 : : "buffer_split|timestamp|security|keep_crc on|off\n"
804 : : " Enable or disable a per port Rx offloading"
805 : : " on all Rx queues of a port\n\n"
806 : :
807 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
808 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
809 : : "outer_ipv4_cksum|macsec_strip|"
810 : : "vlan_filter|vlan_extend|scatter|"
811 : : "buffer_split|timestamp|security|keep_crc on|off\n"
812 : : " Enable or disable a per queue Rx offloading"
813 : : " only on a specific Rx queue\n\n"
814 : :
815 : : "port config (port_id|all) tx_offload all|vlan_insert|"
816 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
817 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
818 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
819 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
820 : : "security on|off\n"
821 : : " Enable or disable a per port Tx offloading"
822 : : " on all Tx queues of a port\n\n"
823 : :
824 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
825 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
826 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
827 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
828 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
829 : : " on|off\n"
830 : : " Enable or disable a per queue Tx offloading"
831 : : " only on a specific Tx queue\n\n"
832 : :
833 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
834 : : " Load an eBPF program as a callback"
835 : : " for particular RX/TX queue\n\n"
836 : :
837 : : "bpf-unload rx|tx (port) (queue)\n"
838 : : " Unload previously loaded eBPF program"
839 : : " for particular RX/TX queue\n\n"
840 : :
841 : : "port config (port_id) tx_metadata (value)\n"
842 : : " Set Tx metadata value per port. Testpmd will add this value"
843 : : " to any Tx packet sent from this port\n\n"
844 : :
845 : : "port config (port_id) dynf (name) set|clear\n"
846 : : " Register a dynf and Set/clear this flag on Tx. "
847 : : "Testpmd will set this value to any Tx packet "
848 : : "sent from this port\n\n"
849 : :
850 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
851 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
852 : :
853 : : "port config (port_id) txq (queue_id) affinity (value)\n"
854 : : " Map a Tx queue with an aggregated port "
855 : : "of the DPDK port\n\n"
856 : :
857 : : "port config (port_id|all) speed_lanes (value)\n"
858 : : " Set number of lanes for all ports or port_id for a forced speed\n\n"
859 : : );
860 : : }
861 : :
862 : 0 : if (show_all || !strcmp(res->section, "filters")) {
863 : :
864 : 0 : cmdline_printf(
865 : : cl,
866 : : "\n"
867 : : "filters:\n"
868 : : "--------\n\n"
869 : :
870 : : "flow validate {port_id}"
871 : : " [group {group_id}] [priority {level}]"
872 : : " [ingress] [egress]"
873 : : " pattern {item} [/ {item} [...]] / end"
874 : : " actions {action} [/ {action} [...]] / end\n"
875 : : " Check whether a flow rule can be created.\n\n"
876 : :
877 : : "flow create {port_id}"
878 : : " [group {group_id}] [priority {level}]"
879 : : " [ingress] [egress]"
880 : : " pattern {item} [/ {item} [...]] / end"
881 : : " actions {action} [/ {action} [...]] / end\n"
882 : : " Create a flow rule.\n\n"
883 : :
884 : : "flow destroy {port_id} rule {rule_id} [...]\n"
885 : : " Destroy specific flow rules.\n\n"
886 : :
887 : : "flow update {port_id} {rule_id}"
888 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
889 : : " Update a flow rule with new actions.\n\n"
890 : :
891 : : "flow flush {port_id}\n"
892 : : " Destroy all flow rules.\n\n"
893 : :
894 : : "flow query {port_id} {rule_id} {action}\n"
895 : : " Query an existing flow rule.\n\n"
896 : :
897 : : "flow list {port_id} [group {group_id}] [...]\n"
898 : : " List existing flow rules sorted by priority,"
899 : : " filtered by group identifiers.\n\n"
900 : :
901 : : "flow isolate {port_id} {boolean}\n"
902 : : " Restrict ingress traffic to the defined"
903 : : " flow rules\n\n"
904 : :
905 : : "flow aged {port_id} [destroy]\n"
906 : : " List and destroy aged flows"
907 : : " flow rules\n\n"
908 : :
909 : : "flow indirect_action {port_id} create"
910 : : " [action_id {indirect_action_id}]"
911 : : " [ingress] [egress]"
912 : : " action {action} / end\n"
913 : : " Create indirect action.\n\n"
914 : :
915 : : "flow indirect_action {port_id} update"
916 : : " {indirect_action_id} action {action} / end\n"
917 : : " Update indirect action.\n\n"
918 : :
919 : : "flow indirect_action {port_id} destroy"
920 : : " action_id {indirect_action_id} [...]\n"
921 : : " Destroy specific indirect actions.\n\n"
922 : :
923 : : "flow indirect_action {port_id} query"
924 : : " {indirect_action_id}\n"
925 : : " Query an existing indirect action.\n\n"
926 : :
927 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
928 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
929 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
930 : : " Configure the VXLAN encapsulation for flows.\n\n"
931 : :
932 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
933 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
934 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
935 : : " eth-dst (eth-dst)\n"
936 : : " Configure the VXLAN encapsulation for flows.\n\n"
937 : :
938 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
939 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
940 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
941 : : " eth-dst (eth-dst)\n"
942 : : " Configure the VXLAN encapsulation for flows.\n\n"
943 : :
944 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
945 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
946 : : " (eth-dst)\n"
947 : : " Configure the NVGRE encapsulation for flows.\n\n"
948 : :
949 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
950 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
951 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
952 : : " Configure the NVGRE encapsulation for flows.\n\n"
953 : :
954 : : "set raw_encap {flow items}\n"
955 : : " Configure the encapsulation with raw data.\n\n"
956 : :
957 : : "set raw_decap {flow items}\n"
958 : : " Configure the decapsulation with raw data.\n\n"
959 : :
960 : : );
961 : : }
962 : :
963 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
964 : 0 : cmdline_printf(
965 : : cl,
966 : : "\n"
967 : : "Traffic Management:\n"
968 : : "--------------\n"
969 : : "show port tm cap (port_id)\n"
970 : : " Display the port TM capability.\n\n"
971 : :
972 : : "show port tm level cap (port_id) (level_id)\n"
973 : : " Display the port TM hierarchical level capability.\n\n"
974 : :
975 : : "show port tm node cap (port_id) (node_id)\n"
976 : : " Display the port TM node capability.\n\n"
977 : :
978 : : "show port tm node type (port_id) (node_id)\n"
979 : : " Display the port TM node type.\n\n"
980 : :
981 : : "show port tm node stats (port_id) (node_id) (clear)\n"
982 : : " Display the port TM node stats.\n\n"
983 : :
984 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
985 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
986 : : " (packet_length_adjust) (packet_mode)\n"
987 : : " Add port tm node private shaper profile.\n\n"
988 : :
989 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
990 : : " Delete port tm node private shaper profile.\n\n"
991 : :
992 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
993 : : " (shaper_profile_id)\n"
994 : : " Add/update port tm node shared shaper.\n\n"
995 : :
996 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
997 : : " Delete port tm node shared shaper.\n\n"
998 : :
999 : : "set port tm node shaper profile (port_id) (node_id)"
1000 : : " (shaper_profile_id)\n"
1001 : : " Set port tm node shaper profile.\n\n"
1002 : :
1003 : : "add port tm node wred profile (port_id) (wred_profile_id)"
1004 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1005 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1006 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1007 : : " Add port tm node wred profile.\n\n"
1008 : :
1009 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
1010 : : " Delete port tm node wred profile.\n\n"
1011 : :
1012 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1013 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1014 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1015 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1016 : : " Add port tm nonleaf node.\n\n"
1017 : :
1018 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1019 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1020 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1021 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1022 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
1023 : :
1024 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1025 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1026 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1027 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1028 : : " Add port tm leaf node.\n\n"
1029 : :
1030 : : "del port tm node (port_id) (node_id)\n"
1031 : : " Delete port tm node.\n\n"
1032 : :
1033 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1034 : : " (priority) (weight)\n"
1035 : : " Set port tm node parent.\n\n"
1036 : :
1037 : : "suspend port tm node (port_id) (node_id)"
1038 : : " Suspend tm node.\n\n"
1039 : :
1040 : : "resume port tm node (port_id) (node_id)"
1041 : : " Resume tm node.\n\n"
1042 : :
1043 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1044 : : " Commit tm hierarchy.\n\n"
1045 : :
1046 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1047 : : " (red)\n"
1048 : : " Enables/Disables the traffic management marking"
1049 : : " for IP ECN (Explicit Congestion Notification)"
1050 : : " packets on a given port\n\n"
1051 : :
1052 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1053 : : " (red)\n"
1054 : : " Enables/Disables the traffic management marking"
1055 : : " on the port for IP dscp packets\n\n"
1056 : :
1057 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1058 : : " (red)\n"
1059 : : " Enables/Disables the traffic management marking"
1060 : : " on the port for VLAN packets with DEI enabled\n\n"
1061 : : );
1062 : : }
1063 : :
1064 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1065 : 0 : cmdline_printf(
1066 : : cl,
1067 : : "\n"
1068 : : "Device Operations:\n"
1069 : : "--------------\n"
1070 : : "device detach (identifier)\n"
1071 : : " Detach device by identifier.\n\n"
1072 : : );
1073 : : }
1074 : :
1075 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1076 : : struct testpmd_driver_commands *c;
1077 : : unsigned int i;
1078 : :
1079 : 0 : cmdline_printf(
1080 : : cl,
1081 : : "\n"
1082 : : "Driver specific:\n"
1083 : : "----------------\n"
1084 : : );
1085 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1086 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1087 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1088 : : }
1089 : : }
1090 : 0 : }
1091 : :
1092 : : static cmdline_parse_token_string_t cmd_help_long_help =
1093 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1094 : :
1095 : : static cmdline_parse_token_string_t cmd_help_long_section =
1096 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1097 : : "all#control#display#config#ports#"
1098 : : "filters#traffic_management#devices#drivers");
1099 : :
1100 : : static cmdline_parse_inst_t cmd_help_long = {
1101 : : .f = cmd_help_long_parsed,
1102 : : .data = NULL,
1103 : : .help_str = "help all|control|display|config|ports|"
1104 : : "filters|traffic_management|devices|drivers: "
1105 : : "Show help",
1106 : : .tokens = {
1107 : : (void *)&cmd_help_long_help,
1108 : : (void *)&cmd_help_long_section,
1109 : : NULL,
1110 : : },
1111 : : };
1112 : :
1113 : :
1114 : : /* *** start/stop/close all ports *** */
1115 : : struct cmd_operate_port_result {
1116 : : cmdline_fixed_string_t keyword;
1117 : : cmdline_fixed_string_t name;
1118 : : cmdline_fixed_string_t value;
1119 : : };
1120 : :
1121 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1122 : : __rte_unused struct cmdline *cl,
1123 : : __rte_unused void *data)
1124 : : {
1125 : : struct cmd_operate_port_result *res = parsed_result;
1126 : :
1127 : 0 : if (!strcmp(res->name, "start"))
1128 : 0 : start_port(RTE_PORT_ALL);
1129 : 0 : else if (!strcmp(res->name, "stop"))
1130 : 0 : stop_port(RTE_PORT_ALL);
1131 : 0 : else if (!strcmp(res->name, "close"))
1132 : 0 : close_port(RTE_PORT_ALL);
1133 : 0 : else if (!strcmp(res->name, "reset"))
1134 : 0 : reset_port(RTE_PORT_ALL);
1135 : : else
1136 : 0 : fprintf(stderr, "Unknown parameter\n");
1137 : 0 : }
1138 : :
1139 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1140 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1141 : : "port");
1142 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1143 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1144 : : "start#stop#close#reset");
1145 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1146 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1147 : :
1148 : : static cmdline_parse_inst_t cmd_operate_port = {
1149 : : .f = cmd_operate_port_parsed,
1150 : : .data = NULL,
1151 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1152 : : .tokens = {
1153 : : (void *)&cmd_operate_port_all_cmd,
1154 : : (void *)&cmd_operate_port_all_port,
1155 : : (void *)&cmd_operate_port_all_all,
1156 : : NULL,
1157 : : },
1158 : : };
1159 : :
1160 : : /* *** start/stop/close specific port *** */
1161 : : struct cmd_operate_specific_port_result {
1162 : : cmdline_fixed_string_t keyword;
1163 : : cmdline_fixed_string_t name;
1164 : : uint8_t value;
1165 : : };
1166 : :
1167 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1168 : : __rte_unused struct cmdline *cl,
1169 : : __rte_unused void *data)
1170 : : {
1171 : : struct cmd_operate_specific_port_result *res = parsed_result;
1172 : :
1173 : 0 : if (!strcmp(res->name, "start"))
1174 : 0 : start_port(res->value);
1175 : 0 : else if (!strcmp(res->name, "stop"))
1176 : 0 : stop_port(res->value);
1177 : 0 : else if (!strcmp(res->name, "close"))
1178 : 0 : close_port(res->value);
1179 : 0 : else if (!strcmp(res->name, "reset"))
1180 : 0 : reset_port(res->value);
1181 : : else
1182 : 0 : fprintf(stderr, "Unknown parameter\n");
1183 : 0 : }
1184 : :
1185 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1186 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1187 : : keyword, "port");
1188 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1189 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1190 : : name, "start#stop#close#reset");
1191 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1192 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1193 : : value, RTE_UINT8);
1194 : :
1195 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1196 : : .f = cmd_operate_specific_port_parsed,
1197 : : .data = NULL,
1198 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1199 : : .tokens = {
1200 : : (void *)&cmd_operate_specific_port_cmd,
1201 : : (void *)&cmd_operate_specific_port_port,
1202 : : (void *)&cmd_operate_specific_port_id,
1203 : : NULL,
1204 : : },
1205 : : };
1206 : :
1207 : : /* *** enable port setup (after attach) via iterator or event *** */
1208 : : struct cmd_set_port_setup_on_result {
1209 : : cmdline_fixed_string_t set;
1210 : : cmdline_fixed_string_t port;
1211 : : cmdline_fixed_string_t setup;
1212 : : cmdline_fixed_string_t on;
1213 : : cmdline_fixed_string_t mode;
1214 : : };
1215 : :
1216 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1217 : : __rte_unused struct cmdline *cl,
1218 : : __rte_unused void *data)
1219 : : {
1220 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1221 : :
1222 : 0 : if (strcmp(res->mode, "event") == 0)
1223 : 0 : setup_on_probe_event = true;
1224 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1225 : 0 : setup_on_probe_event = false;
1226 : : else
1227 : 0 : fprintf(stderr, "Unknown mode\n");
1228 : 0 : }
1229 : :
1230 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1231 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1232 : : set, "set");
1233 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1234 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1235 : : port, "port");
1236 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1237 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1238 : : setup, "setup");
1239 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1240 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1241 : : on, "on");
1242 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1243 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1244 : : mode, "iterator#event");
1245 : :
1246 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1247 : : .f = cmd_set_port_setup_on_parsed,
1248 : : .data = NULL,
1249 : : .help_str = "set port setup on iterator|event",
1250 : : .tokens = {
1251 : : (void *)&cmd_set_port_setup_on_set,
1252 : : (void *)&cmd_set_port_setup_on_port,
1253 : : (void *)&cmd_set_port_setup_on_setup,
1254 : : (void *)&cmd_set_port_setup_on_on,
1255 : : (void *)&cmd_set_port_setup_on_mode,
1256 : : NULL,
1257 : : },
1258 : : };
1259 : :
1260 : : /* *** attach a specified port *** */
1261 : : struct cmd_operate_attach_port_result {
1262 : : cmdline_fixed_string_t port;
1263 : : cmdline_fixed_string_t keyword;
1264 : : cmdline_multi_string_t identifier;
1265 : : };
1266 : :
1267 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1268 : : __rte_unused struct cmdline *cl,
1269 : : __rte_unused void *data)
1270 : : {
1271 : : struct cmd_operate_attach_port_result *res = parsed_result;
1272 : :
1273 : 0 : if (!strcmp(res->keyword, "attach"))
1274 : 0 : attach_port(res->identifier);
1275 : : else
1276 : 0 : fprintf(stderr, "Unknown parameter\n");
1277 : 0 : }
1278 : :
1279 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1280 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1281 : : port, "port");
1282 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1283 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1284 : : keyword, "attach");
1285 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1286 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1287 : : identifier, TOKEN_STRING_MULTI);
1288 : :
1289 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1290 : : .f = cmd_operate_attach_port_parsed,
1291 : : .data = NULL,
1292 : : .help_str = "port attach <identifier>: "
1293 : : "(identifier: pci address or virtual dev name)",
1294 : : .tokens = {
1295 : : (void *)&cmd_operate_attach_port_port,
1296 : : (void *)&cmd_operate_attach_port_keyword,
1297 : : (void *)&cmd_operate_attach_port_identifier,
1298 : : NULL,
1299 : : },
1300 : : };
1301 : :
1302 : : /* *** detach a specified port *** */
1303 : : struct cmd_operate_detach_port_result {
1304 : : cmdline_fixed_string_t port;
1305 : : cmdline_fixed_string_t keyword;
1306 : : portid_t port_id;
1307 : : };
1308 : :
1309 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1310 : : __rte_unused struct cmdline *cl,
1311 : : __rte_unused void *data)
1312 : : {
1313 : : struct cmd_operate_detach_port_result *res = parsed_result;
1314 : :
1315 : 0 : if (!strcmp(res->keyword, "detach")) {
1316 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1317 : 0 : detach_port_device(res->port_id);
1318 : : } else {
1319 : 0 : fprintf(stderr, "Unknown parameter\n");
1320 : : }
1321 : : }
1322 : :
1323 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1324 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1325 : : port, "port");
1326 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1327 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1328 : : keyword, "detach");
1329 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1330 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1331 : : port_id, RTE_UINT16);
1332 : :
1333 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1334 : : .f = cmd_operate_detach_port_parsed,
1335 : : .data = NULL,
1336 : : .help_str = "port detach <port_id>",
1337 : : .tokens = {
1338 : : (void *)&cmd_operate_detach_port_port,
1339 : : (void *)&cmd_operate_detach_port_keyword,
1340 : : (void *)&cmd_operate_detach_port_port_id,
1341 : : NULL,
1342 : : },
1343 : : };
1344 : :
1345 : : /* *** detach device by identifier *** */
1346 : : struct cmd_operate_detach_device_result {
1347 : : cmdline_fixed_string_t device;
1348 : : cmdline_fixed_string_t keyword;
1349 : : cmdline_fixed_string_t identifier;
1350 : : };
1351 : :
1352 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1353 : : __rte_unused struct cmdline *cl,
1354 : : __rte_unused void *data)
1355 : : {
1356 : : struct cmd_operate_detach_device_result *res = parsed_result;
1357 : :
1358 : 0 : if (!strcmp(res->keyword, "detach"))
1359 : 0 : detach_devargs(res->identifier);
1360 : : else
1361 : 0 : fprintf(stderr, "Unknown parameter\n");
1362 : 0 : }
1363 : :
1364 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1365 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1366 : : device, "device");
1367 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1368 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1369 : : keyword, "detach");
1370 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1371 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1372 : : identifier, NULL);
1373 : :
1374 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1375 : : .f = cmd_operate_detach_device_parsed,
1376 : : .data = NULL,
1377 : : .help_str = "device detach <identifier>:"
1378 : : "(identifier: pci address or virtual dev name)",
1379 : : .tokens = {
1380 : : (void *)&cmd_operate_detach_device_device,
1381 : : (void *)&cmd_operate_detach_device_keyword,
1382 : : (void *)&cmd_operate_detach_device_identifier,
1383 : : NULL,
1384 : : },
1385 : : };
1386 : : /* *** configure speed for all ports *** */
1387 : : struct cmd_config_speed_all {
1388 : : cmdline_fixed_string_t port;
1389 : : cmdline_fixed_string_t keyword;
1390 : : cmdline_fixed_string_t all;
1391 : : cmdline_fixed_string_t item1;
1392 : : cmdline_fixed_string_t item2;
1393 : : cmdline_fixed_string_t value1;
1394 : : cmdline_fixed_string_t value2;
1395 : : };
1396 : :
1397 : : static int
1398 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1399 : : {
1400 : :
1401 : : int duplex;
1402 : :
1403 : 0 : if (!strcmp(duplexstr, "half")) {
1404 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1405 : 0 : } else if (!strcmp(duplexstr, "full")) {
1406 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1407 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1408 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1409 : : } else {
1410 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1411 : 0 : return -1;
1412 : : }
1413 : :
1414 : 0 : if (!strcmp(speedstr, "10")) {
1415 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1416 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1417 : 0 : } else if (!strcmp(speedstr, "100")) {
1418 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1419 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1420 : : } else {
1421 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1422 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1423 : 0 : return -1;
1424 : : }
1425 : 0 : if (!strcmp(speedstr, "1000")) {
1426 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1427 : 0 : } else if (!strcmp(speedstr, "2500")) {
1428 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1429 : 0 : } else if (!strcmp(speedstr, "5000")) {
1430 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1431 : 0 : } else if (!strcmp(speedstr, "10000")) {
1432 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1433 : 0 : } else if (!strcmp(speedstr, "25000")) {
1434 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1435 : 0 : } else if (!strcmp(speedstr, "40000")) {
1436 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1437 : 0 : } else if (!strcmp(speedstr, "50000")) {
1438 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1439 : 0 : } else if (!strcmp(speedstr, "100000")) {
1440 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1441 : 0 : } else if (!strcmp(speedstr, "200000")) {
1442 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1443 : 0 : } else if (!strcmp(speedstr, "400000")) {
1444 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1445 : 0 : } else if (!strcmp(speedstr, "800000")) {
1446 : 0 : *speed = RTE_ETH_LINK_SPEED_800G;
1447 : 0 : } else if (!strcmp(speedstr, "auto")) {
1448 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1449 : : } else {
1450 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1451 : 0 : return -1;
1452 : : }
1453 : : }
1454 : :
1455 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1456 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1457 : :
1458 : : return 0;
1459 : : }
1460 : :
1461 : : static void
1462 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1463 : : __rte_unused struct cmdline *cl,
1464 : : __rte_unused void *data)
1465 : : {
1466 : : struct cmd_config_speed_all *res = parsed_result;
1467 : : uint32_t link_speed;
1468 : : portid_t pid;
1469 : :
1470 : 0 : if (!all_ports_stopped()) {
1471 : 0 : fprintf(stderr, "Please stop all ports first\n");
1472 : 0 : return;
1473 : : }
1474 : :
1475 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1476 : : &link_speed) < 0)
1477 : : return;
1478 : :
1479 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1480 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1481 : : }
1482 : :
1483 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1484 : : }
1485 : :
1486 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1487 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1488 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1489 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1490 : : "config");
1491 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1492 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1493 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1494 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1495 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1496 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1497 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1498 : : "100000#200000#400000#800000#auto");
1499 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1500 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1501 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1502 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1503 : : "half#full#auto");
1504 : :
1505 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1506 : : .f = cmd_config_speed_all_parsed,
1507 : : .data = NULL,
1508 : : .help_str = "port config all speed "
1509 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1510 : : "100000|200000|400000|800000|auto "
1511 : : "duplex half|full|auto",
1512 : : .tokens = {
1513 : : (void *)&cmd_config_speed_all_port,
1514 : : (void *)&cmd_config_speed_all_keyword,
1515 : : (void *)&cmd_config_speed_all_all,
1516 : : (void *)&cmd_config_speed_all_item1,
1517 : : (void *)&cmd_config_speed_all_value1,
1518 : : (void *)&cmd_config_speed_all_item2,
1519 : : (void *)&cmd_config_speed_all_value2,
1520 : : NULL,
1521 : : },
1522 : : };
1523 : :
1524 : : /* *** configure speed for specific port *** */
1525 : : struct cmd_config_speed_specific {
1526 : : cmdline_fixed_string_t port;
1527 : : cmdline_fixed_string_t keyword;
1528 : : portid_t id;
1529 : : cmdline_fixed_string_t item1;
1530 : : cmdline_fixed_string_t item2;
1531 : : cmdline_fixed_string_t value1;
1532 : : cmdline_fixed_string_t value2;
1533 : : };
1534 : :
1535 : : static void
1536 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1537 : : __rte_unused struct cmdline *cl,
1538 : : __rte_unused void *data)
1539 : : {
1540 : : struct cmd_config_speed_specific *res = parsed_result;
1541 : : uint32_t link_speed;
1542 : :
1543 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1544 : 0 : return;
1545 : :
1546 : 0 : if (!port_is_stopped(res->id)) {
1547 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1548 : 0 : return;
1549 : : }
1550 : :
1551 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1552 : : &link_speed) < 0)
1553 : : return;
1554 : :
1555 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1556 : :
1557 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1558 : : }
1559 : :
1560 : :
1561 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1562 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1563 : : "port");
1564 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1565 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1566 : : "config");
1567 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1568 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1569 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1570 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1571 : : "speed");
1572 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1573 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1574 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1575 : : "100000#200000#400000#800000#auto");
1576 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1577 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1578 : : "duplex");
1579 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1580 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1581 : : "half#full#auto");
1582 : :
1583 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1584 : : .f = cmd_config_speed_specific_parsed,
1585 : : .data = NULL,
1586 : : .help_str = "port config <port_id> speed "
1587 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1588 : : "100000|200000|400000|800000|auto "
1589 : : "duplex half|full|auto",
1590 : : .tokens = {
1591 : : (void *)&cmd_config_speed_specific_port,
1592 : : (void *)&cmd_config_speed_specific_keyword,
1593 : : (void *)&cmd_config_speed_specific_id,
1594 : : (void *)&cmd_config_speed_specific_item1,
1595 : : (void *)&cmd_config_speed_specific_value1,
1596 : : (void *)&cmd_config_speed_specific_item2,
1597 : : (void *)&cmd_config_speed_specific_value2,
1598 : : NULL,
1599 : : },
1600 : : };
1601 : :
1602 : : static int
1603 : 0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
1604 : : {
1605 : : int ret;
1606 : :
1607 : 0 : ret = rte_eth_speed_lanes_set(pid, lanes);
1608 : 0 : if (ret == -ENOTSUP) {
1609 : 0 : fprintf(stderr, "Function not implemented\n");
1610 : 0 : return -1;
1611 : 0 : } else if (ret < 0) {
1612 : 0 : fprintf(stderr, "Set speed lanes failed\n");
1613 : 0 : return -1;
1614 : : }
1615 : :
1616 : : return 0;
1617 : : }
1618 : :
1619 : : static void
1620 : 0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
1621 : : {
1622 : : unsigned int i;
1623 : : uint32_t capa;
1624 : :
1625 : : printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
1626 : : printf("\n-----------------------------------\n");
1627 : 0 : for (i = 0; i < num; i++) {
1628 : 0 : printf("%-17s ",
1629 : 0 : rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
1630 : 0 : capa = speed_lanes_capa[i].capa;
1631 : : int s = 0;
1632 : :
1633 : 0 : while (capa) {
1634 : 0 : if (capa & 0x1)
1635 : : printf("%-2d ", s);
1636 : 0 : s++;
1637 : 0 : capa = capa >> 1;
1638 : : }
1639 : : printf("\n");
1640 : : }
1641 : 0 : }
1642 : :
1643 : : /* *** display speed lanes per port capabilities *** */
1644 : : struct cmd_show_speed_lanes_result {
1645 : : cmdline_fixed_string_t cmd_show;
1646 : : cmdline_fixed_string_t cmd_port;
1647 : : cmdline_fixed_string_t cmd_keyword;
1648 : : portid_t cmd_pid;
1649 : : };
1650 : :
1651 : : static void
1652 : 0 : cmd_show_speed_lanes_parsed(void *parsed_result,
1653 : : __rte_unused struct cmdline *cl,
1654 : : __rte_unused void *data)
1655 : : {
1656 : : struct cmd_show_speed_lanes_result *res = parsed_result;
1657 : : struct rte_eth_speed_lanes_capa *speed_lanes_capa;
1658 : : unsigned int num;
1659 : : int ret;
1660 : :
1661 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
1662 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
1663 : 0 : return;
1664 : : }
1665 : :
1666 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
1667 : 0 : if (ret == -ENOTSUP) {
1668 : 0 : fprintf(stderr, "Function not implemented\n");
1669 : 0 : return;
1670 : 0 : } else if (ret < 0) {
1671 : 0 : fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
1672 : 0 : return;
1673 : : }
1674 : :
1675 : 0 : num = (unsigned int)ret;
1676 : 0 : speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
1677 : 0 : if (speed_lanes_capa == NULL) {
1678 : 0 : fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
1679 : 0 : return;
1680 : : }
1681 : :
1682 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
1683 : 0 : if (ret < 0) {
1684 : 0 : fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
1685 : 0 : goto out;
1686 : : }
1687 : :
1688 : 0 : show_speed_lanes_capability(num, speed_lanes_capa);
1689 : 0 : out:
1690 : 0 : free(speed_lanes_capa);
1691 : : }
1692 : :
1693 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
1694 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1695 : : cmd_show, "show");
1696 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
1697 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1698 : : cmd_port, "port");
1699 : : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
1700 : : TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
1701 : : cmd_pid, RTE_UINT16);
1702 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
1703 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1704 : : cmd_keyword, "speed_lanes");
1705 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
1706 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1707 : : cmd_keyword, "capabilities");
1708 : :
1709 : : static cmdline_parse_inst_t cmd_show_speed_lanes = {
1710 : : .f = cmd_show_speed_lanes_parsed,
1711 : : .data = NULL,
1712 : : .help_str = "show port <port_id> speed_lanes capabilities",
1713 : : .tokens = {
1714 : : (void *)&cmd_show_speed_lanes_show,
1715 : : (void *)&cmd_show_speed_lanes_port,
1716 : : (void *)&cmd_show_speed_lanes_pid,
1717 : : (void *)&cmd_show_speed_lanes_keyword,
1718 : : (void *)&cmd_show_speed_lanes_cap_keyword,
1719 : : NULL,
1720 : : },
1721 : : };
1722 : :
1723 : : /* *** configure speed_lanes for all ports *** */
1724 : : struct cmd_config_speed_lanes_all {
1725 : : cmdline_fixed_string_t port;
1726 : : cmdline_fixed_string_t keyword;
1727 : : cmdline_fixed_string_t all;
1728 : : cmdline_fixed_string_t item;
1729 : : uint32_t lanes;
1730 : : };
1731 : :
1732 : : static void
1733 : 0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
1734 : : __rte_unused struct cmdline *cl,
1735 : : __rte_unused void *data)
1736 : : {
1737 : : struct cmd_config_speed_lanes_all *res = parsed_result;
1738 : : portid_t pid;
1739 : :
1740 : 0 : if (!all_ports_stopped()) {
1741 : 0 : fprintf(stderr, "Please stop all ports first\n");
1742 : 0 : return;
1743 : : }
1744 : :
1745 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1746 : 0 : if (parse_speed_lanes_cfg(pid, res->lanes))
1747 : : return;
1748 : : }
1749 : :
1750 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1751 : : }
1752 : :
1753 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
1754 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
1755 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
1756 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
1757 : : "config");
1758 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
1759 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
1760 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
1761 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
1762 : : "speed_lanes");
1763 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
1764 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
1765 : :
1766 : : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
1767 : : .f = cmd_config_speed_lanes_all_parsed,
1768 : : .data = NULL,
1769 : : .help_str = "port config all speed_lanes <value>",
1770 : : .tokens = {
1771 : : (void *)&cmd_config_speed_lanes_all_port,
1772 : : (void *)&cmd_config_speed_lanes_all_keyword,
1773 : : (void *)&cmd_config_speed_lanes_all_all,
1774 : : (void *)&cmd_config_speed_lanes_all_item,
1775 : : (void *)&cmd_config_speed_lanes_all_lanes,
1776 : : NULL,
1777 : : },
1778 : : };
1779 : :
1780 : : /* *** configure speed_lanes for specific port *** */
1781 : : struct cmd_config_speed_lanes_specific {
1782 : : cmdline_fixed_string_t port;
1783 : : cmdline_fixed_string_t keyword;
1784 : : uint16_t port_id;
1785 : : cmdline_fixed_string_t item;
1786 : : uint32_t lanes;
1787 : : };
1788 : :
1789 : : static void
1790 : 0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
1791 : : __rte_unused struct cmdline *cl,
1792 : : __rte_unused void *data)
1793 : : {
1794 : : struct cmd_config_speed_lanes_specific *res = parsed_result;
1795 : :
1796 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1797 : : return;
1798 : :
1799 : 0 : if (!port_is_stopped(res->port_id)) {
1800 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1801 : 0 : return;
1802 : : }
1803 : :
1804 : 0 : if (parse_speed_lanes_cfg(res->port_id, res->lanes))
1805 : : return;
1806 : :
1807 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1808 : : }
1809 : :
1810 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
1811 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
1812 : : "port");
1813 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
1814 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
1815 : : "config");
1816 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
1817 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
1818 : : RTE_UINT16);
1819 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
1820 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
1821 : : "speed_lanes");
1822 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
1823 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
1824 : : RTE_UINT32);
1825 : :
1826 : : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
1827 : : .f = cmd_config_speed_lanes_specific_parsed,
1828 : : .data = NULL,
1829 : : .help_str = "port config <port_id> speed_lanes <value>",
1830 : : .tokens = {
1831 : : (void *)&cmd_config_speed_lanes_specific_port,
1832 : : (void *)&cmd_config_speed_lanes_specific_keyword,
1833 : : (void *)&cmd_config_speed_lanes_specific_id,
1834 : : (void *)&cmd_config_speed_lanes_specific_item,
1835 : : (void *)&cmd_config_speed_lanes_specific_lanes,
1836 : : NULL,
1837 : : },
1838 : : };
1839 : :
1840 : : /* *** configure loopback for all ports *** */
1841 : : struct cmd_config_loopback_all {
1842 : : cmdline_fixed_string_t port;
1843 : : cmdline_fixed_string_t keyword;
1844 : : cmdline_fixed_string_t all;
1845 : : cmdline_fixed_string_t item;
1846 : : uint32_t mode;
1847 : : };
1848 : :
1849 : : static void
1850 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1851 : : __rte_unused struct cmdline *cl,
1852 : : __rte_unused void *data)
1853 : : {
1854 : : struct cmd_config_loopback_all *res = parsed_result;
1855 : : portid_t pid;
1856 : :
1857 : 0 : if (!all_ports_stopped()) {
1858 : 0 : fprintf(stderr, "Please stop all ports first\n");
1859 : 0 : return;
1860 : : }
1861 : :
1862 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1863 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1864 : : }
1865 : :
1866 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1867 : : }
1868 : :
1869 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1870 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1871 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1872 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1873 : : "config");
1874 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1875 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1876 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1877 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1878 : : "loopback");
1879 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1880 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1881 : :
1882 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1883 : : .f = cmd_config_loopback_all_parsed,
1884 : : .data = NULL,
1885 : : .help_str = "port config all loopback <mode>",
1886 : : .tokens = {
1887 : : (void *)&cmd_config_loopback_all_port,
1888 : : (void *)&cmd_config_loopback_all_keyword,
1889 : : (void *)&cmd_config_loopback_all_all,
1890 : : (void *)&cmd_config_loopback_all_item,
1891 : : (void *)&cmd_config_loopback_all_mode,
1892 : : NULL,
1893 : : },
1894 : : };
1895 : :
1896 : : /* *** configure loopback for specific port *** */
1897 : : struct cmd_config_loopback_specific {
1898 : : cmdline_fixed_string_t port;
1899 : : cmdline_fixed_string_t keyword;
1900 : : uint16_t port_id;
1901 : : cmdline_fixed_string_t item;
1902 : : uint32_t mode;
1903 : : };
1904 : :
1905 : : static void
1906 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1907 : : __rte_unused struct cmdline *cl,
1908 : : __rte_unused void *data)
1909 : : {
1910 : : struct cmd_config_loopback_specific *res = parsed_result;
1911 : :
1912 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1913 : : return;
1914 : :
1915 : 0 : if (!port_is_stopped(res->port_id)) {
1916 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1917 : 0 : return;
1918 : : }
1919 : :
1920 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1921 : :
1922 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1923 : : }
1924 : :
1925 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1926 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1927 : : "port");
1928 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1929 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1930 : : "config");
1931 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1932 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1933 : : RTE_UINT16);
1934 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1935 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1936 : : "loopback");
1937 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1938 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1939 : : RTE_UINT32);
1940 : :
1941 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1942 : : .f = cmd_config_loopback_specific_parsed,
1943 : : .data = NULL,
1944 : : .help_str = "port config <port_id> loopback <mode>",
1945 : : .tokens = {
1946 : : (void *)&cmd_config_loopback_specific_port,
1947 : : (void *)&cmd_config_loopback_specific_keyword,
1948 : : (void *)&cmd_config_loopback_specific_id,
1949 : : (void *)&cmd_config_loopback_specific_item,
1950 : : (void *)&cmd_config_loopback_specific_mode,
1951 : : NULL,
1952 : : },
1953 : : };
1954 : :
1955 : : /* *** configure txq/rxq, txd/rxd *** */
1956 : : struct cmd_config_rx_tx {
1957 : : cmdline_fixed_string_t port;
1958 : : cmdline_fixed_string_t keyword;
1959 : : cmdline_fixed_string_t all;
1960 : : cmdline_fixed_string_t name;
1961 : : uint16_t value;
1962 : : };
1963 : :
1964 : : static void
1965 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1966 : : __rte_unused struct cmdline *cl,
1967 : : __rte_unused void *data)
1968 : : {
1969 : : struct cmd_config_rx_tx *res = parsed_result;
1970 : :
1971 : 0 : if (!all_ports_stopped()) {
1972 : 0 : fprintf(stderr, "Please stop all ports first\n");
1973 : 0 : return;
1974 : : }
1975 : 0 : if (!strcmp(res->name, "rxq")) {
1976 : 0 : if (!res->value && !nb_txq) {
1977 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1978 : 0 : return;
1979 : : }
1980 : 0 : if (check_nb_rxq(res->value) != 0)
1981 : : return;
1982 : 0 : nb_rxq = res->value;
1983 : : }
1984 : 0 : else if (!strcmp(res->name, "txq")) {
1985 : 0 : if (!res->value && !nb_rxq) {
1986 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1987 : 0 : return;
1988 : : }
1989 : 0 : if (check_nb_txq(res->value) != 0)
1990 : : return;
1991 : 0 : nb_txq = res->value;
1992 : : }
1993 : 0 : else if (!strcmp(res->name, "rxd")) {
1994 : 0 : if (check_nb_rxd(res->value) != 0)
1995 : : return;
1996 : 0 : nb_rxd = res->value;
1997 : 0 : } else if (!strcmp(res->name, "txd")) {
1998 : 0 : if (check_nb_txd(res->value) != 0)
1999 : : return;
2000 : :
2001 : 0 : nb_txd = res->value;
2002 : : } else {
2003 : 0 : fprintf(stderr, "Unknown parameter\n");
2004 : 0 : return;
2005 : : }
2006 : :
2007 : 0 : init_port_config();
2008 : :
2009 : 0 : fwd_config_setup();
2010 : :
2011 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2012 : : }
2013 : :
2014 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
2015 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2016 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2017 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2018 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
2019 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2020 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
2021 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2022 : : "rxq#txq#rxd#txd");
2023 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
2024 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
2025 : :
2026 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
2027 : : .f = cmd_config_rx_tx_parsed,
2028 : : .data = NULL,
2029 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
2030 : : .tokens = {
2031 : : (void *)&cmd_config_rx_tx_port,
2032 : : (void *)&cmd_config_rx_tx_keyword,
2033 : : (void *)&cmd_config_rx_tx_all,
2034 : : (void *)&cmd_config_rx_tx_name,
2035 : : (void *)&cmd_config_rx_tx_value,
2036 : : NULL,
2037 : : },
2038 : : };
2039 : :
2040 : : /* *** config max packet length *** */
2041 : : struct cmd_config_max_pkt_len_result {
2042 : : cmdline_fixed_string_t port;
2043 : : cmdline_fixed_string_t keyword;
2044 : : cmdline_fixed_string_t all;
2045 : : cmdline_fixed_string_t name;
2046 : : uint32_t value;
2047 : : };
2048 : :
2049 : : static void
2050 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
2051 : : __rte_unused struct cmdline *cl,
2052 : : __rte_unused void *data)
2053 : : {
2054 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
2055 : : portid_t port_id;
2056 : : int ret;
2057 : :
2058 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
2059 : : printf("Unknown parameter\n");
2060 : 0 : return;
2061 : : }
2062 : :
2063 : 0 : if (!all_ports_stopped()) {
2064 : 0 : fprintf(stderr, "Please stop all ports first\n");
2065 : 0 : return;
2066 : : }
2067 : :
2068 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
2069 : 0 : struct rte_port *port = &ports[port_id];
2070 : :
2071 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
2072 : 0 : fprintf(stderr,
2073 : : "max-pkt-len can not be less than %d\n",
2074 : : RTE_ETHER_MIN_LEN);
2075 : 0 : return;
2076 : : }
2077 : :
2078 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
2079 : 0 : if (ret != 0) {
2080 : 0 : fprintf(stderr,
2081 : : "rte_eth_dev_info_get() failed for port %u\n",
2082 : : port_id);
2083 : 0 : return;
2084 : : }
2085 : :
2086 : 0 : update_mtu_from_frame_size(port_id, res->value);
2087 : : }
2088 : :
2089 : 0 : init_port_config();
2090 : :
2091 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2092 : : }
2093 : :
2094 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2095 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2096 : : "port");
2097 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2098 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2099 : : "config");
2100 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2101 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2102 : : "all");
2103 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2104 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2105 : : "max-pkt-len");
2106 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2107 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2108 : : RTE_UINT32);
2109 : :
2110 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
2111 : : .f = cmd_config_max_pkt_len_parsed,
2112 : : .data = NULL,
2113 : : .help_str = "port config all max-pkt-len <value>",
2114 : : .tokens = {
2115 : : (void *)&cmd_config_max_pkt_len_port,
2116 : : (void *)&cmd_config_max_pkt_len_keyword,
2117 : : (void *)&cmd_config_max_pkt_len_all,
2118 : : (void *)&cmd_config_max_pkt_len_name,
2119 : : (void *)&cmd_config_max_pkt_len_value,
2120 : : NULL,
2121 : : },
2122 : : };
2123 : :
2124 : : /* *** config max LRO aggregated packet size *** */
2125 : : struct cmd_config_max_lro_pkt_size_result {
2126 : : cmdline_fixed_string_t port;
2127 : : cmdline_fixed_string_t keyword;
2128 : : cmdline_fixed_string_t all;
2129 : : cmdline_fixed_string_t name;
2130 : : uint32_t value;
2131 : : };
2132 : :
2133 : : static void
2134 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2135 : : __rte_unused struct cmdline *cl,
2136 : : __rte_unused void *data)
2137 : : {
2138 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2139 : : portid_t pid;
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(pid) {
2147 : 0 : struct rte_port *port = &ports[pid];
2148 : :
2149 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
2150 : 0 : if (res->value ==
2151 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
2152 : : return;
2153 : :
2154 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2155 : : } else {
2156 : 0 : fprintf(stderr, "Unknown parameter\n");
2157 : 0 : return;
2158 : : }
2159 : : }
2160 : :
2161 : 0 : init_port_config();
2162 : :
2163 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2164 : : }
2165 : :
2166 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2167 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2168 : : port, "port");
2169 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2170 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2171 : : keyword, "config");
2172 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2173 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2174 : : all, "all");
2175 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2176 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2177 : : name, "max-lro-pkt-size");
2178 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2179 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2180 : : value, RTE_UINT32);
2181 : :
2182 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2183 : : .f = cmd_config_max_lro_pkt_size_parsed,
2184 : : .data = NULL,
2185 : : .help_str = "port config all max-lro-pkt-size <value>",
2186 : : .tokens = {
2187 : : (void *)&cmd_config_max_lro_pkt_size_port,
2188 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
2189 : : (void *)&cmd_config_max_lro_pkt_size_all,
2190 : : (void *)&cmd_config_max_lro_pkt_size_name,
2191 : : (void *)&cmd_config_max_lro_pkt_size_value,
2192 : : NULL,
2193 : : },
2194 : : };
2195 : :
2196 : : /* *** configure port MTU *** */
2197 : : struct cmd_config_mtu_result {
2198 : : cmdline_fixed_string_t port;
2199 : : cmdline_fixed_string_t keyword;
2200 : : cmdline_fixed_string_t mtu;
2201 : : portid_t port_id;
2202 : : uint16_t value;
2203 : : };
2204 : :
2205 : : static void
2206 : 0 : cmd_config_mtu_parsed(void *parsed_result,
2207 : : __rte_unused struct cmdline *cl,
2208 : : __rte_unused void *data)
2209 : : {
2210 : : struct cmd_config_mtu_result *res = parsed_result;
2211 : :
2212 : 0 : port_mtu_set(res->port_id, res->value);
2213 : 0 : }
2214 : :
2215 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
2216 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2217 : : "port");
2218 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2219 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2220 : : "config");
2221 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2222 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2223 : : "mtu");
2224 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2225 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2226 : : RTE_UINT16);
2227 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
2228 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2229 : : RTE_UINT16);
2230 : :
2231 : : static cmdline_parse_inst_t cmd_config_mtu = {
2232 : : .f = cmd_config_mtu_parsed,
2233 : : .data = NULL,
2234 : : .help_str = "port config mtu <port_id> <value>",
2235 : : .tokens = {
2236 : : (void *)&cmd_config_mtu_port,
2237 : : (void *)&cmd_config_mtu_keyword,
2238 : : (void *)&cmd_config_mtu_mtu,
2239 : : (void *)&cmd_config_mtu_port_id,
2240 : : (void *)&cmd_config_mtu_value,
2241 : : NULL,
2242 : : },
2243 : : };
2244 : :
2245 : : /* *** configure rx mode *** */
2246 : : struct cmd_config_rx_mode_flag {
2247 : : cmdline_fixed_string_t port;
2248 : : cmdline_fixed_string_t keyword;
2249 : : cmdline_fixed_string_t all;
2250 : : cmdline_fixed_string_t name;
2251 : : cmdline_fixed_string_t value;
2252 : : };
2253 : :
2254 : : static void
2255 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
2256 : : __rte_unused struct cmdline *cl,
2257 : : __rte_unused void *data)
2258 : : {
2259 : : struct cmd_config_rx_mode_flag *res = parsed_result;
2260 : :
2261 : 0 : if (!all_ports_stopped()) {
2262 : 0 : fprintf(stderr, "Please stop all ports first\n");
2263 : 0 : return;
2264 : : }
2265 : :
2266 : 0 : if (!strcmp(res->name, "drop-en")) {
2267 : 0 : if (!strcmp(res->value, "on"))
2268 : 0 : rx_drop_en = 1;
2269 : 0 : else if (!strcmp(res->value, "off"))
2270 : 0 : rx_drop_en = 0;
2271 : : else {
2272 : 0 : fprintf(stderr, "Unknown parameter\n");
2273 : 0 : return;
2274 : : }
2275 : : } else {
2276 : 0 : fprintf(stderr, "Unknown parameter\n");
2277 : 0 : return;
2278 : : }
2279 : :
2280 : 0 : init_port_config();
2281 : :
2282 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2283 : : }
2284 : :
2285 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2286 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2287 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2288 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2289 : : "config");
2290 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2291 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2292 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2293 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2294 : : "drop-en");
2295 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2296 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2297 : : "on#off");
2298 : :
2299 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2300 : : .f = cmd_config_rx_mode_flag_parsed,
2301 : : .data = NULL,
2302 : : .help_str = "port config all drop-en on|off",
2303 : : .tokens = {
2304 : : (void *)&cmd_config_rx_mode_flag_port,
2305 : : (void *)&cmd_config_rx_mode_flag_keyword,
2306 : : (void *)&cmd_config_rx_mode_flag_all,
2307 : : (void *)&cmd_config_rx_mode_flag_name,
2308 : : (void *)&cmd_config_rx_mode_flag_value,
2309 : : NULL,
2310 : : },
2311 : : };
2312 : :
2313 : : /* *** configure rss *** */
2314 : : struct cmd_config_rss {
2315 : : cmdline_fixed_string_t port;
2316 : : cmdline_fixed_string_t keyword;
2317 : : cmdline_fixed_string_t all;
2318 : : cmdline_fixed_string_t name;
2319 : : cmdline_fixed_string_t value;
2320 : : };
2321 : :
2322 : : static void
2323 : 0 : cmd_config_rss_parsed(void *parsed_result,
2324 : : __rte_unused struct cmdline *cl,
2325 : : __rte_unused void *data)
2326 : : {
2327 : : struct cmd_config_rss *res = parsed_result;
2328 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2329 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2330 : : int use_default = 0;
2331 : : int all_updated = 1;
2332 : : int diag;
2333 : : uint16_t i;
2334 : : int ret;
2335 : :
2336 : 0 : if (!strcmp(res->value, "level-default")) {
2337 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2338 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2339 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2340 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2341 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2342 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2343 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2344 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2345 : 0 : } else if (!strcmp(res->value, "default")) {
2346 : : use_default = 1;
2347 : 0 : } else if (isdigit(res->value[0])) {
2348 : : int value = atoi(res->value);
2349 : 0 : if (value > 0 && value < 64)
2350 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2351 : : else {
2352 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2353 : 0 : return;
2354 : : }
2355 : 0 : } else if (!strcmp(res->value, "none")) {
2356 : : rss_conf.rss_hf = 0;
2357 : : } else {
2358 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2359 : 0 : if (rss_conf.rss_hf == 0) {
2360 : 0 : fprintf(stderr, "Unknown parameter\n");
2361 : 0 : return;
2362 : : }
2363 : : }
2364 : : rss_conf.rss_key = NULL;
2365 : : /* Update global configuration for RSS types. */
2366 : 0 : RTE_ETH_FOREACH_DEV(i) {
2367 : : struct rte_eth_rss_conf local_rss_conf;
2368 : :
2369 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2370 : 0 : if (ret != 0)
2371 : 0 : return;
2372 : :
2373 : 0 : if (use_default)
2374 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2375 : :
2376 : 0 : local_rss_conf = rss_conf;
2377 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2378 : 0 : dev_info.flow_type_rss_offloads;
2379 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2380 : : printf("Port %u modified RSS hash function based on hardware support,"
2381 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2382 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2383 : : }
2384 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2385 : 0 : if (diag < 0) {
2386 : : all_updated = 0;
2387 : 0 : fprintf(stderr,
2388 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2389 : : i, -diag, strerror(-diag));
2390 : : }
2391 : : }
2392 : 0 : if (all_updated && !use_default) {
2393 : 0 : rss_hf = rss_conf.rss_hf;
2394 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2395 : : }
2396 : : }
2397 : :
2398 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2399 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2400 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2401 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2402 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2403 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2404 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2405 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2406 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2407 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2408 : :
2409 : : static cmdline_parse_inst_t cmd_config_rss = {
2410 : : .f = cmd_config_rss_parsed,
2411 : : .data = NULL,
2412 : : .help_str = "port config all rss "
2413 : : "all|default|level-default|level-outer|level-inner|"
2414 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2415 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2416 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2417 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2418 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2419 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2420 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2421 : : .tokens = {
2422 : : (void *)&cmd_config_rss_port,
2423 : : (void *)&cmd_config_rss_keyword,
2424 : : (void *)&cmd_config_rss_all,
2425 : : (void *)&cmd_config_rss_name,
2426 : : (void *)&cmd_config_rss_value,
2427 : : NULL,
2428 : : },
2429 : : };
2430 : :
2431 : : /* *** configure rss hash key *** */
2432 : : struct cmd_config_rss_hash_key {
2433 : : cmdline_fixed_string_t port;
2434 : : cmdline_fixed_string_t config;
2435 : : portid_t port_id;
2436 : : cmdline_fixed_string_t rss_hash_key;
2437 : : cmdline_fixed_string_t rss_type;
2438 : : cmdline_fixed_string_t key;
2439 : : };
2440 : :
2441 : : static uint8_t
2442 : : hexa_digit_to_value(char hexa_digit)
2443 : : {
2444 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2445 : : return (uint8_t) (hexa_digit - '0');
2446 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2447 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2448 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2449 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2450 : : /* Invalid hexa digit */
2451 : : return 0xFF;
2452 : : }
2453 : :
2454 : : static uint8_t
2455 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2456 : : {
2457 : : uint8_t hexa_v;
2458 : :
2459 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2460 : : if (hexa_v == 0xFF)
2461 : 0 : fprintf(stderr,
2462 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2463 : : key[idx], idx);
2464 : 0 : return hexa_v;
2465 : : }
2466 : :
2467 : : static void
2468 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2469 : : __rte_unused struct cmdline *cl,
2470 : : __rte_unused void *data)
2471 : : {
2472 : : struct cmd_config_rss_hash_key *res = parsed_result;
2473 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2474 : : uint8_t xdgt0;
2475 : : uint8_t xdgt1;
2476 : : int i;
2477 : : struct rte_eth_dev_info dev_info;
2478 : : uint8_t hash_key_size;
2479 : : uint32_t key_len;
2480 : : int ret;
2481 : :
2482 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2483 : 0 : if (ret != 0)
2484 : 0 : return;
2485 : :
2486 : 0 : if (dev_info.hash_key_size > 0 &&
2487 : : dev_info.hash_key_size <= sizeof(hash_key))
2488 : : hash_key_size = dev_info.hash_key_size;
2489 : : else {
2490 : 0 : fprintf(stderr,
2491 : : "dev_info did not provide a valid hash key size\n");
2492 : 0 : return;
2493 : : }
2494 : : /* Check the length of the RSS hash key */
2495 : 0 : key_len = strlen(res->key);
2496 : 0 : if (key_len != (hash_key_size * 2)) {
2497 : 0 : fprintf(stderr,
2498 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2499 : : (int)key_len, hash_key_size * 2);
2500 : 0 : return;
2501 : : }
2502 : : /* Translate RSS hash key into binary representation */
2503 : 0 : for (i = 0; i < hash_key_size; i++) {
2504 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2505 : 0 : if (xdgt0 == 0xFF)
2506 : : return;
2507 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2508 : 0 : if (xdgt1 == 0xFF)
2509 : : return;
2510 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2511 : : }
2512 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2513 : : hash_key_size);
2514 : : }
2515 : :
2516 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2517 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2518 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2519 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2520 : : "config");
2521 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2522 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2523 : : RTE_UINT16);
2524 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2525 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2526 : : rss_hash_key, "rss-hash-key");
2527 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2528 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2529 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2530 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2531 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2532 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2533 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2534 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2535 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2536 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2537 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2538 : :
2539 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2540 : : .f = cmd_config_rss_hash_key_parsed,
2541 : : .data = NULL,
2542 : : .help_str = "port config <port_id> rss-hash-key "
2543 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2544 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2545 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2546 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2547 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2548 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2549 : : "<string of hex digits (variable length, NIC dependent)>",
2550 : : .tokens = {
2551 : : (void *)&cmd_config_rss_hash_key_port,
2552 : : (void *)&cmd_config_rss_hash_key_config,
2553 : : (void *)&cmd_config_rss_hash_key_port_id,
2554 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2555 : : (void *)&cmd_config_rss_hash_key_rss_type,
2556 : : (void *)&cmd_config_rss_hash_key_value,
2557 : : NULL,
2558 : : },
2559 : : };
2560 : :
2561 : : /* *** configure rss hash algorithm *** */
2562 : : struct cmd_config_rss_hash_algo {
2563 : : cmdline_fixed_string_t port;
2564 : : cmdline_fixed_string_t config;
2565 : : portid_t port_id;
2566 : : cmdline_fixed_string_t rss_hash_algo;
2567 : : cmdline_fixed_string_t algo;
2568 : : };
2569 : :
2570 : : static void
2571 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2572 : : __rte_unused struct cmdline *cl,
2573 : : __rte_unused void *data)
2574 : : {
2575 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2576 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2577 : : struct rte_eth_rss_conf rss_conf;
2578 : : uint32_t algorithm;
2579 : : int ret;
2580 : :
2581 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2582 : 0 : rss_conf.rss_key = rss_key;
2583 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2584 : 0 : if (ret != 0) {
2585 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2586 : 0 : res->port_id);
2587 : 0 : return;
2588 : : }
2589 : :
2590 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2591 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2592 : 0 : if (ret != 0) {
2593 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2594 : 0 : res->port_id, res->algo);
2595 : 0 : return;
2596 : : }
2597 : :
2598 : 0 : rss_conf.algorithm = algorithm;
2599 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2600 : 0 : if (ret != 0) {
2601 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2602 : 0 : res->port_id);
2603 : 0 : return;
2604 : : }
2605 : : }
2606 : :
2607 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2608 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2609 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2610 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2611 : : "config");
2612 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2613 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2614 : : RTE_UINT16);
2615 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2616 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2617 : : rss_hash_algo, "rss-hash-algo");
2618 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2619 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2620 : : "default#simple_xor#toeplitz#"
2621 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2622 : :
2623 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2624 : : .f = cmd_config_rss_hash_algo_parsed,
2625 : : .data = NULL,
2626 : : .help_str = "port config <port_id> rss-hash-algo "
2627 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2628 : : .tokens = {
2629 : : (void *)&cmd_config_rss_hash_algo_port,
2630 : : (void *)&cmd_config_rss_hash_algo_config,
2631 : : (void *)&cmd_config_rss_hash_algo_port_id,
2632 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2633 : : (void *)&cmd_config_rss_hash_algo_algo,
2634 : : NULL,
2635 : : },
2636 : : };
2637 : :
2638 : : /* *** cleanup txq mbufs *** */
2639 : : struct cmd_cleanup_txq_mbufs_result {
2640 : : cmdline_fixed_string_t port;
2641 : : cmdline_fixed_string_t keyword;
2642 : : cmdline_fixed_string_t name;
2643 : : uint16_t port_id;
2644 : : uint16_t queue_id;
2645 : : uint32_t free_cnt;
2646 : : };
2647 : :
2648 : : static void
2649 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2650 : : __rte_unused struct cmdline *cl,
2651 : : __rte_unused void *data)
2652 : : {
2653 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2654 : 0 : uint16_t port_id = res->port_id;
2655 : 0 : uint16_t queue_id = res->queue_id;
2656 : 0 : uint32_t free_cnt = res->free_cnt;
2657 : : struct rte_eth_txq_info qinfo;
2658 : : int ret;
2659 : :
2660 : 0 : if (test_done == 0) {
2661 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2662 : 0 : return;
2663 : : }
2664 : :
2665 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2666 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2667 : : port_id, queue_id);
2668 : 0 : return;
2669 : : }
2670 : :
2671 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2672 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2673 : 0 : return;
2674 : : }
2675 : :
2676 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2677 : 0 : if (ret < 0) {
2678 : 0 : fprintf(stderr,
2679 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2680 : : port_id, queue_id, strerror(-ret), ret);
2681 : 0 : return;
2682 : : }
2683 : :
2684 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2685 : : port_id, queue_id, ret);
2686 : : }
2687 : :
2688 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2689 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2690 : : "port");
2691 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2692 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2693 : : "cleanup");
2694 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2695 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2696 : : RTE_UINT16);
2697 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2698 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2699 : : "txq");
2700 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2701 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2702 : : RTE_UINT16);
2703 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2704 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2705 : : RTE_UINT32);
2706 : :
2707 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2708 : : .f = cmd_cleanup_txq_mbufs_parsed,
2709 : : .data = NULL,
2710 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2711 : : .tokens = {
2712 : : (void *)&cmd_cleanup_txq_mbufs_port,
2713 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2714 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2715 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2716 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2717 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2718 : : NULL,
2719 : : },
2720 : : };
2721 : :
2722 : : /* *** configure port rxq/txq ring size *** */
2723 : : struct cmd_config_rxtx_ring_size {
2724 : : cmdline_fixed_string_t port;
2725 : : cmdline_fixed_string_t config;
2726 : : portid_t portid;
2727 : : cmdline_fixed_string_t rxtxq;
2728 : : uint16_t qid;
2729 : : cmdline_fixed_string_t rsize;
2730 : : uint16_t size;
2731 : : };
2732 : :
2733 : : static void
2734 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2735 : : __rte_unused struct cmdline *cl,
2736 : : __rte_unused void *data)
2737 : : {
2738 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2739 : : struct rte_port *port;
2740 : : uint8_t isrx;
2741 : :
2742 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2743 : : return;
2744 : :
2745 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2746 : 0 : fprintf(stderr, "Invalid port id\n");
2747 : 0 : return;
2748 : : }
2749 : :
2750 : 0 : port = &ports[res->portid];
2751 : :
2752 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2753 : : isrx = 1;
2754 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2755 : : isrx = 0;
2756 : : else {
2757 : 0 : fprintf(stderr, "Unknown parameter\n");
2758 : 0 : return;
2759 : : }
2760 : :
2761 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2762 : : return;
2763 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2764 : : return;
2765 : :
2766 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2767 : 0 : fprintf(stderr,
2768 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2769 : : rx_free_thresh);
2770 : 0 : return;
2771 : : }
2772 : :
2773 : 0 : if (isrx)
2774 : 0 : port->nb_rx_desc[res->qid] = res->size;
2775 : : else
2776 : 0 : port->nb_tx_desc[res->qid] = res->size;
2777 : :
2778 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2779 : : }
2780 : :
2781 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2782 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2783 : : port, "port");
2784 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2785 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2786 : : config, "config");
2787 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2788 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2789 : : portid, RTE_UINT16);
2790 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2791 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2792 : : rxtxq, "rxq#txq");
2793 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2794 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2795 : : qid, RTE_UINT16);
2796 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2797 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2798 : : rsize, "ring_size");
2799 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2800 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2801 : : size, RTE_UINT16);
2802 : :
2803 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2804 : : .f = cmd_config_rxtx_ring_size_parsed,
2805 : : .data = NULL,
2806 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2807 : : .tokens = {
2808 : : (void *)&cmd_config_rxtx_ring_size_port,
2809 : : (void *)&cmd_config_rxtx_ring_size_config,
2810 : : (void *)&cmd_config_rxtx_ring_size_portid,
2811 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2812 : : (void *)&cmd_config_rxtx_ring_size_qid,
2813 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2814 : : (void *)&cmd_config_rxtx_ring_size_size,
2815 : : NULL,
2816 : : },
2817 : : };
2818 : :
2819 : : /* *** configure port rxq/txq start/stop *** */
2820 : : struct cmd_config_rxtx_queue {
2821 : : cmdline_fixed_string_t port;
2822 : : portid_t portid;
2823 : : cmdline_fixed_string_t rxtxq;
2824 : : uint16_t qid;
2825 : : cmdline_fixed_string_t opname;
2826 : : };
2827 : :
2828 : : static void
2829 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2830 : : __rte_unused struct cmdline *cl,
2831 : : __rte_unused void *data)
2832 : : {
2833 : : struct cmd_config_rxtx_queue *res = parsed_result;
2834 : : struct rte_port *port;
2835 : : uint8_t isrx;
2836 : : uint8_t isstart;
2837 : : uint8_t *state;
2838 : : int ret = 0;
2839 : :
2840 : 0 : if (test_done == 0) {
2841 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2842 : 0 : return;
2843 : : }
2844 : :
2845 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2846 : : return;
2847 : :
2848 : 0 : if (port_is_started(res->portid) != 1) {
2849 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2850 : 0 : return;
2851 : : }
2852 : :
2853 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2854 : : isrx = 1;
2855 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2856 : : isrx = 0;
2857 : : else {
2858 : 0 : fprintf(stderr, "Unknown parameter\n");
2859 : 0 : return;
2860 : : }
2861 : :
2862 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2863 : : return;
2864 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2865 : : return;
2866 : :
2867 : 0 : if (!strcmp(res->opname, "start"))
2868 : : isstart = 1;
2869 : 0 : else if (!strcmp(res->opname, "stop"))
2870 : : isstart = 0;
2871 : : else {
2872 : 0 : fprintf(stderr, "Unknown parameter\n");
2873 : 0 : return;
2874 : : }
2875 : :
2876 : 0 : if (isstart && isrx)
2877 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2878 : 0 : else if (!isstart && isrx)
2879 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2880 : 0 : else if (isstart && !isrx)
2881 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2882 : : else
2883 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2884 : :
2885 : 0 : if (ret == -ENOTSUP) {
2886 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2887 : 0 : return;
2888 : : }
2889 : :
2890 : 0 : port = &ports[res->portid];
2891 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2892 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2893 : : RTE_ETH_QUEUE_STATE_STOPPED;
2894 : : }
2895 : :
2896 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2897 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2898 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2899 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2900 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2901 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2902 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2903 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2904 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2905 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2906 : : "start#stop");
2907 : :
2908 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2909 : : .f = cmd_config_rxtx_queue_parsed,
2910 : : .data = NULL,
2911 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2912 : : .tokens = {
2913 : : (void *)&cmd_config_rxtx_queue_port,
2914 : : (void *)&cmd_config_rxtx_queue_portid,
2915 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2916 : : (void *)&cmd_config_rxtx_queue_qid,
2917 : : (void *)&cmd_config_rxtx_queue_opname,
2918 : : NULL,
2919 : : },
2920 : : };
2921 : :
2922 : : /* *** configure port rxq/txq deferred start on/off *** */
2923 : : struct cmd_config_deferred_start_rxtx_queue {
2924 : : cmdline_fixed_string_t port;
2925 : : portid_t port_id;
2926 : : cmdline_fixed_string_t rxtxq;
2927 : : uint16_t qid;
2928 : : cmdline_fixed_string_t opname;
2929 : : cmdline_fixed_string_t state;
2930 : : };
2931 : :
2932 : : static void
2933 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2934 : : __rte_unused struct cmdline *cl,
2935 : : __rte_unused void *data)
2936 : : {
2937 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2938 : : struct rte_port *port;
2939 : : uint8_t isrx;
2940 : : uint8_t ison;
2941 : : uint8_t needreconfig = 0;
2942 : :
2943 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2944 : : return;
2945 : :
2946 : 0 : if (port_is_started(res->port_id) != 0) {
2947 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2948 : 0 : return;
2949 : : }
2950 : :
2951 : 0 : port = &ports[res->port_id];
2952 : :
2953 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2954 : :
2955 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2956 : : return;
2957 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2958 : : return;
2959 : :
2960 : 0 : ison = !strcmp(res->state, "on");
2961 : :
2962 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2963 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2964 : : needreconfig = 1;
2965 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2966 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2967 : : needreconfig = 1;
2968 : : }
2969 : :
2970 : : if (needreconfig)
2971 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2972 : : }
2973 : :
2974 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2975 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2976 : : port, "port");
2977 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2978 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2979 : : port_id, RTE_UINT16);
2980 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2981 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2982 : : rxtxq, "rxq#txq");
2983 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2984 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2985 : : qid, RTE_UINT16);
2986 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2987 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2988 : : opname, "deferred_start");
2989 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2990 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2991 : : state, "on#off");
2992 : :
2993 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2994 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
2995 : : .data = NULL,
2996 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2997 : : .tokens = {
2998 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
2999 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
3000 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
3001 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
3002 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
3003 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
3004 : : NULL,
3005 : : },
3006 : : };
3007 : :
3008 : : /* *** configure port rxq/txq setup *** */
3009 : : struct cmd_setup_rxtx_queue {
3010 : : cmdline_fixed_string_t port;
3011 : : portid_t portid;
3012 : : cmdline_fixed_string_t rxtxq;
3013 : : uint16_t qid;
3014 : : cmdline_fixed_string_t setup;
3015 : : };
3016 : :
3017 : : /* Common CLI fields for queue setup */
3018 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
3019 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
3020 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
3021 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
3022 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
3023 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
3024 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
3025 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
3026 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
3027 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
3028 : :
3029 : : static void
3030 : 0 : cmd_setup_rxtx_queue_parsed(
3031 : : void *parsed_result,
3032 : : __rte_unused struct cmdline *cl,
3033 : : __rte_unused void *data)
3034 : : {
3035 : : struct cmd_setup_rxtx_queue *res = parsed_result;
3036 : : struct rte_port *port;
3037 : : struct rte_mempool *mp;
3038 : : unsigned int socket_id;
3039 : : uint8_t isrx = 0;
3040 : : int ret;
3041 : :
3042 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
3043 : : return;
3044 : :
3045 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
3046 : 0 : fprintf(stderr, "Invalid port id\n");
3047 : 0 : return;
3048 : : }
3049 : :
3050 : 0 : if (!strcmp(res->rxtxq, "rxq"))
3051 : : isrx = 1;
3052 : 0 : else if (!strcmp(res->rxtxq, "txq"))
3053 : : isrx = 0;
3054 : : else {
3055 : 0 : fprintf(stderr, "Unknown parameter\n");
3056 : 0 : return;
3057 : : }
3058 : :
3059 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
3060 : 0 : fprintf(stderr, "Invalid rx queue\n");
3061 : 0 : return;
3062 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
3063 : 0 : fprintf(stderr, "Invalid tx queue\n");
3064 : 0 : return;
3065 : : }
3066 : :
3067 : 0 : port = &ports[res->portid];
3068 : 0 : if (isrx) {
3069 : 0 : socket_id = rxring_numa[res->portid];
3070 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3071 : 0 : socket_id = port->socket_id;
3072 : :
3073 : 0 : mp = mbuf_pool_find_first(socket_id);
3074 : 0 : if (mp == NULL) {
3075 : : char buf[16];
3076 : :
3077 : 0 : fprintf(stderr,
3078 : : "Failed to setup RX queue: No mempool allocation on the socket %s\n",
3079 : : socket_id_str(socket_id, buf, sizeof(buf)));
3080 : : return;
3081 : : }
3082 : 0 : ret = rx_queue_setup(res->portid,
3083 : : res->qid,
3084 : 0 : port->nb_rx_desc[res->qid],
3085 : : socket_id,
3086 : 0 : &port->rxq[res->qid].conf,
3087 : : mp);
3088 : 0 : if (ret)
3089 : 0 : fprintf(stderr, "Failed to setup RX queue: %s\n",
3090 : : rte_strerror(-ret));
3091 : : } else {
3092 : 0 : socket_id = txring_numa[res->portid];
3093 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3094 : 0 : socket_id = port->socket_id;
3095 : :
3096 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
3097 : 0 : fprintf(stderr,
3098 : : "Failed to setup TX queue: not enough descriptors\n");
3099 : 0 : return;
3100 : : }
3101 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
3102 : : res->qid,
3103 : : port->nb_tx_desc[res->qid],
3104 : : socket_id,
3105 : 0 : &port->txq[res->qid].conf);
3106 : 0 : if (ret)
3107 : 0 : fprintf(stderr, "Failed to setup TX queue: %s\n",
3108 : : rte_strerror(-ret));
3109 : : }
3110 : : }
3111 : :
3112 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
3113 : : .f = cmd_setup_rxtx_queue_parsed,
3114 : : .data = NULL,
3115 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
3116 : : .tokens = {
3117 : : (void *)&cmd_setup_rxtx_queue_port,
3118 : : (void *)&cmd_setup_rxtx_queue_portid,
3119 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
3120 : : (void *)&cmd_setup_rxtx_queue_qid,
3121 : : (void *)&cmd_setup_rxtx_queue_setup,
3122 : : NULL,
3123 : : },
3124 : : };
3125 : :
3126 : :
3127 : : /* *** Configure RSS RETA *** */
3128 : : struct cmd_config_rss_reta {
3129 : : cmdline_fixed_string_t port;
3130 : : cmdline_fixed_string_t keyword;
3131 : : portid_t port_id;
3132 : : cmdline_fixed_string_t name;
3133 : : cmdline_fixed_string_t list_name;
3134 : : cmdline_fixed_string_t list_of_items;
3135 : : };
3136 : :
3137 : : static int
3138 : 0 : parse_reta_config(const char *str,
3139 : : struct rte_eth_rss_reta_entry64 *reta_conf,
3140 : : uint16_t nb_entries)
3141 : : {
3142 : : int i;
3143 : : unsigned size;
3144 : : uint16_t hash_index, idx, shift;
3145 : : uint16_t nb_queue;
3146 : : char s[256];
3147 : : const char *p, *p0 = str;
3148 : : char *end;
3149 : : enum fieldnames {
3150 : : FLD_HASH_INDEX = 0,
3151 : : FLD_QUEUE,
3152 : : _NUM_FLD
3153 : : };
3154 : : unsigned long int_fld[_NUM_FLD];
3155 : : char *str_fld[_NUM_FLD];
3156 : :
3157 : 0 : while ((p = strchr(p0,'(')) != NULL) {
3158 : 0 : ++p;
3159 : 0 : if((p0 = strchr(p,')')) == NULL)
3160 : : return -1;
3161 : :
3162 : 0 : size = p0 - p;
3163 : 0 : if(size >= sizeof(s))
3164 : : return -1;
3165 : :
3166 : : snprintf(s, sizeof(s), "%.*s", size, p);
3167 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3168 : : return -1;
3169 : 0 : for (i = 0; i < _NUM_FLD; i++) {
3170 : 0 : errno = 0;
3171 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
3172 : 0 : if (errno != 0 || end == str_fld[i] ||
3173 : : int_fld[i] > 65535)
3174 : : return -1;
3175 : : }
3176 : :
3177 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3178 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3179 : :
3180 : 0 : if (hash_index >= nb_entries) {
3181 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
3182 : : hash_index);
3183 : 0 : return -1;
3184 : : }
3185 : :
3186 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3187 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3188 : 0 : reta_conf[idx].mask |= (1ULL << shift);
3189 : 0 : reta_conf[idx].reta[shift] = nb_queue;
3190 : : }
3191 : :
3192 : : return 0;
3193 : : }
3194 : :
3195 : : static void
3196 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
3197 : : __rte_unused struct cmdline *cl,
3198 : : __rte_unused void *data)
3199 : : {
3200 : : int ret;
3201 : : struct rte_eth_dev_info dev_info;
3202 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3203 : : struct cmd_config_rss_reta *res = parsed_result;
3204 : :
3205 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3206 : 0 : if (ret != 0)
3207 : 0 : return;
3208 : :
3209 : 0 : if (dev_info.reta_size == 0) {
3210 : 0 : fprintf(stderr,
3211 : : "Redirection table size is 0 which is invalid for RSS\n");
3212 : 0 : return;
3213 : : } else
3214 : 0 : printf("The reta size of port %d is %u\n",
3215 : 0 : res->port_id, dev_info.reta_size);
3216 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3217 : 0 : fprintf(stderr,
3218 : : "Currently do not support more than %u entries of redirection table\n",
3219 : : RTE_ETH_RSS_RETA_SIZE_512);
3220 : 0 : return;
3221 : : }
3222 : :
3223 : : memset(reta_conf, 0, sizeof(reta_conf));
3224 : 0 : if (!strcmp(res->list_name, "reta")) {
3225 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
3226 : : dev_info.reta_size)) {
3227 : 0 : fprintf(stderr,
3228 : : "Invalid RSS Redirection Table config entered\n");
3229 : 0 : return;
3230 : : }
3231 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
3232 : 0 : reta_conf, dev_info.reta_size);
3233 : 0 : if (ret != 0)
3234 : 0 : fprintf(stderr,
3235 : : "Bad redirection table parameter, return code = %d\n",
3236 : : ret);
3237 : : }
3238 : : }
3239 : :
3240 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3241 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3242 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3243 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3244 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3245 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3246 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3247 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3248 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3249 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3250 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3251 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3252 : : NULL);
3253 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
3254 : : .f = cmd_set_rss_reta_parsed,
3255 : : .data = NULL,
3256 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3257 : : .tokens = {
3258 : : (void *)&cmd_config_rss_reta_port,
3259 : : (void *)&cmd_config_rss_reta_keyword,
3260 : : (void *)&cmd_config_rss_reta_port_id,
3261 : : (void *)&cmd_config_rss_reta_name,
3262 : : (void *)&cmd_config_rss_reta_list_name,
3263 : : (void *)&cmd_config_rss_reta_list_of_items,
3264 : : NULL,
3265 : : },
3266 : : };
3267 : :
3268 : : /* *** SHOW PORT RETA INFO *** */
3269 : : struct cmd_showport_reta {
3270 : : cmdline_fixed_string_t show;
3271 : : cmdline_fixed_string_t port;
3272 : : portid_t port_id;
3273 : : cmdline_fixed_string_t rss;
3274 : : cmdline_fixed_string_t reta;
3275 : : uint16_t size;
3276 : : cmdline_fixed_string_t list_of_items;
3277 : : };
3278 : :
3279 : : static int
3280 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3281 : : uint16_t nb_entries,
3282 : : char *str)
3283 : : {
3284 : : uint32_t size;
3285 : : const char *p, *p0 = str;
3286 : : char s[256];
3287 : : char *end;
3288 : : char *str_fld[8];
3289 : : uint16_t i;
3290 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3291 : : RTE_ETH_RETA_GROUP_SIZE;
3292 : : int ret;
3293 : :
3294 : 0 : p = strchr(p0, '(');
3295 : 0 : if (p == NULL)
3296 : : return -1;
3297 : 0 : p++;
3298 : 0 : p0 = strchr(p, ')');
3299 : 0 : if (p0 == NULL)
3300 : : return -1;
3301 : 0 : size = p0 - p;
3302 : 0 : if (size >= sizeof(s)) {
3303 : 0 : fprintf(stderr,
3304 : : "The string size exceeds the internal buffer size\n");
3305 : 0 : return -1;
3306 : : }
3307 : : snprintf(s, sizeof(s), "%.*s", size, p);
3308 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3309 : 0 : if (ret <= 0 || ret != num) {
3310 : 0 : fprintf(stderr,
3311 : : "The bits of masks do not match the number of reta entries: %u\n",
3312 : : num);
3313 : 0 : return -1;
3314 : : }
3315 : 0 : for (i = 0; i < ret; i++)
3316 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3317 : :
3318 : : return 0;
3319 : : }
3320 : :
3321 : : static void
3322 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3323 : : __rte_unused struct cmdline *cl,
3324 : : __rte_unused void *data)
3325 : : {
3326 : : struct cmd_showport_reta *res = parsed_result;
3327 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3328 : : struct rte_eth_dev_info dev_info;
3329 : : uint16_t max_reta_size;
3330 : : int ret;
3331 : :
3332 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3333 : 0 : if (ret != 0)
3334 : 0 : return;
3335 : :
3336 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3337 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3338 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3339 : : res->size, max_reta_size);
3340 : 0 : return;
3341 : : }
3342 : :
3343 : : memset(reta_conf, 0, sizeof(reta_conf));
3344 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3345 : 0 : res->list_of_items) < 0) {
3346 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3347 : : res->list_of_items);
3348 : 0 : return;
3349 : : }
3350 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3351 : : }
3352 : :
3353 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3354 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3355 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3356 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3357 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3358 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3359 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3360 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3361 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3362 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3363 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3364 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3365 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3366 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3367 : : list_of_items, NULL);
3368 : :
3369 : : static cmdline_parse_inst_t cmd_showport_reta = {
3370 : : .f = cmd_showport_reta_parsed,
3371 : : .data = NULL,
3372 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3373 : : .tokens = {
3374 : : (void *)&cmd_showport_reta_show,
3375 : : (void *)&cmd_showport_reta_port,
3376 : : (void *)&cmd_showport_reta_port_id,
3377 : : (void *)&cmd_showport_reta_rss,
3378 : : (void *)&cmd_showport_reta_reta,
3379 : : (void *)&cmd_showport_reta_size,
3380 : : (void *)&cmd_showport_reta_list_of_items,
3381 : : NULL,
3382 : : },
3383 : : };
3384 : :
3385 : : /* *** Show RSS hash configuration *** */
3386 : : struct cmd_showport_rss_hash {
3387 : : cmdline_fixed_string_t show;
3388 : : cmdline_fixed_string_t port;
3389 : : portid_t port_id;
3390 : : cmdline_fixed_string_t rss_hash;
3391 : : cmdline_fixed_string_t rss_type;
3392 : : cmdline_fixed_string_t key; /* optional argument */
3393 : : cmdline_fixed_string_t algorithm; /* optional argument */
3394 : : };
3395 : :
3396 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3397 : : __rte_unused struct cmdline *cl,
3398 : : __rte_unused void *data)
3399 : : {
3400 : : struct cmd_showport_rss_hash *res = parsed_result;
3401 : :
3402 : 0 : port_rss_hash_conf_show(res->port_id,
3403 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3404 : 0 : }
3405 : :
3406 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3407 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3408 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3409 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3410 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3411 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3412 : : RTE_UINT16);
3413 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3414 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3415 : : "rss-hash");
3416 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3417 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3418 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3419 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3420 : :
3421 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3422 : : .f = cmd_showport_rss_hash_parsed,
3423 : : .data = NULL,
3424 : : .help_str = "show port <port_id> rss-hash",
3425 : : .tokens = {
3426 : : (void *)&cmd_showport_rss_hash_show,
3427 : : (void *)&cmd_showport_rss_hash_port,
3428 : : (void *)&cmd_showport_rss_hash_port_id,
3429 : : (void *)&cmd_showport_rss_hash_rss_hash,
3430 : : NULL,
3431 : : },
3432 : : };
3433 : :
3434 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3435 : : .f = cmd_showport_rss_hash_parsed,
3436 : : .data = NULL,
3437 : : .help_str = "show port <port_id> rss-hash key",
3438 : : .tokens = {
3439 : : (void *)&cmd_showport_rss_hash_show,
3440 : : (void *)&cmd_showport_rss_hash_port,
3441 : : (void *)&cmd_showport_rss_hash_port_id,
3442 : : (void *)&cmd_showport_rss_hash_rss_hash,
3443 : : (void *)&cmd_showport_rss_hash_rss_key,
3444 : : NULL,
3445 : : },
3446 : : };
3447 : :
3448 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3449 : : .f = cmd_showport_rss_hash_parsed,
3450 : : .data = NULL,
3451 : : .help_str = "show port <port_id> rss-hash algorithm",
3452 : : .tokens = {
3453 : : (void *)&cmd_showport_rss_hash_show,
3454 : : (void *)&cmd_showport_rss_hash_port,
3455 : : (void *)&cmd_showport_rss_hash_port_id,
3456 : : (void *)&cmd_showport_rss_hash_rss_hash,
3457 : : (void *)&cmd_showport_rss_hash_rss_algo,
3458 : : NULL,
3459 : : },
3460 : : };
3461 : :
3462 : : /* *** Configure DCB *** */
3463 : : struct cmd_config_dcb {
3464 : : cmdline_fixed_string_t port;
3465 : : cmdline_fixed_string_t config;
3466 : : portid_t port_id;
3467 : : cmdline_fixed_string_t dcb;
3468 : : cmdline_fixed_string_t vt;
3469 : : cmdline_fixed_string_t vt_en;
3470 : : uint8_t num_tcs;
3471 : : cmdline_fixed_string_t pfc;
3472 : : cmdline_multi_string_t token_str;
3473 : : };
3474 : :
3475 : : static int
3476 : 0 : parse_dcb_token_prio_tc(char *param_str[], int param_num,
3477 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3478 : : uint8_t *prio_tc_en)
3479 : : {
3480 : : unsigned long prio, tc;
3481 : : int prio_tc_maps = 0;
3482 : : char *param, *end;
3483 : : int i;
3484 : :
3485 : 0 : for (i = 0; i < param_num; i++) {
3486 : 0 : param = param_str[i];
3487 : 0 : prio = strtoul(param, &end, 10);
3488 : 0 : if (prio >= RTE_ETH_DCB_NUM_USER_PRIORITIES) {
3489 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO %lu\n", prio);
3490 : 0 : return -1;
3491 : : }
3492 : 0 : if ((*end != ':') || (strlen(end + 1) == 0)) {
3493 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3494 : 0 : return -1;
3495 : : }
3496 : 0 : tc = strtoul(end + 1, &end, 10);
3497 : 0 : if (tc >= RTE_ETH_8_TCS) {
3498 : 0 : fprintf(stderr, "Bad Argument: invalid TC %lu\n", tc);
3499 : 0 : return -1;
3500 : : }
3501 : 0 : if (*end != '\0') {
3502 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3503 : 0 : return -1;
3504 : : }
3505 : 0 : prio_tc[prio] = tc;
3506 : 0 : prio_tc_maps++;
3507 : : } while (0);
3508 : :
3509 : 0 : if (prio_tc_maps == 0) {
3510 : 0 : fprintf(stderr, "Bad Argument: no PRIO:TC provided\n");
3511 : 0 : return -1;
3512 : : }
3513 : 0 : *prio_tc_en = 1;
3514 : :
3515 : 0 : return 0;
3516 : : }
3517 : :
3518 : : #define DCB_TOKEN_PRIO_TC "prio-tc"
3519 : : #define DCB_TOKEN_KEEP_QNUM "keep-qnum"
3520 : :
3521 : : static int
3522 : 0 : parse_dcb_token_find(char *split_str[], int split_num, int *param_num)
3523 : : {
3524 : : int i;
3525 : :
3526 : 0 : if (strcmp(split_str[0], DCB_TOKEN_KEEP_QNUM) == 0) {
3527 : 0 : *param_num = 0;
3528 : 0 : return 0;
3529 : : }
3530 : :
3531 : 0 : if (strcmp(split_str[0], DCB_TOKEN_PRIO_TC) != 0) {
3532 : 0 : fprintf(stderr, "Bad Argument: unknown token %s\n", split_str[0]);
3533 : 0 : return -EINVAL;
3534 : : }
3535 : :
3536 : 0 : for (i = 1; i < split_num; i++) {
3537 : 0 : if ((strcmp(split_str[i], DCB_TOKEN_PRIO_TC) != 0) &&
3538 : 0 : (strcmp(split_str[i], DCB_TOKEN_KEEP_QNUM) != 0))
3539 : : continue;
3540 : : /* find another optional parameter, then exit. */
3541 : : break;
3542 : : }
3543 : :
3544 : 0 : *param_num = i - 1;
3545 : :
3546 : 0 : return 0;
3547 : : }
3548 : :
3549 : : static int
3550 : 0 : parse_dcb_token_value(char *token_str,
3551 : : uint8_t *pfc_en,
3552 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3553 : : uint8_t *prio_tc_en,
3554 : : uint8_t *keep_qnum)
3555 : : {
3556 : : #define MAX_TOKEN_NUM 128
3557 : : char *split_str[MAX_TOKEN_NUM];
3558 : : int param_num, start, ret;
3559 : : int split_num = 0;
3560 : : char *token;
3561 : :
3562 : : /* split multiple token to split str. */
3563 : : do {
3564 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
3565 : 0 : if (token == NULL)
3566 : : break;
3567 : 0 : if (split_num >= MAX_TOKEN_NUM) {
3568 : 0 : fprintf(stderr, "Bad Argument: too much argument\n");
3569 : 0 : return -1;
3570 : : }
3571 : 0 : split_str[split_num++] = token;
3572 : : } while (1);
3573 : :
3574 : : /* parse fixed parameter "pfc-en" first. */
3575 : 0 : token = split_str[0];
3576 : 0 : if (strcmp(token, "on") == 0)
3577 : 0 : *pfc_en = 1;
3578 : 0 : else if (strcmp(token, "off") == 0)
3579 : 0 : *pfc_en = 0;
3580 : : else {
3581 : 0 : fprintf(stderr, "Bad Argument: pfc-en must be on or off\n");
3582 : 0 : return -EINVAL;
3583 : : }
3584 : :
3585 : 0 : if (split_num == 1)
3586 : : return 0;
3587 : :
3588 : : /* start parse optional parameter. */
3589 : : start = 1;
3590 : : do {
3591 : 0 : param_num = 0;
3592 : 0 : ret = parse_dcb_token_find(&split_str[start], split_num - start, ¶m_num);
3593 : 0 : if (ret != 0)
3594 : 0 : return ret;
3595 : :
3596 : 0 : token = split_str[start];
3597 : 0 : if (strcmp(token, DCB_TOKEN_PRIO_TC) == 0) {
3598 : 0 : if (*prio_tc_en == 1) {
3599 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3600 : : DCB_TOKEN_PRIO_TC);
3601 : 0 : return -1;
3602 : : }
3603 : 0 : ret = parse_dcb_token_prio_tc(&split_str[start + 1], param_num, prio_tc,
3604 : : prio_tc_en);
3605 : 0 : if (ret != 0)
3606 : 0 : return ret;
3607 : : } else {
3608 : : /* this must be keep-qnum. */
3609 : 0 : if (*keep_qnum == 1) {
3610 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3611 : : DCB_TOKEN_KEEP_QNUM);
3612 : 0 : return -1;
3613 : : }
3614 : 0 : *keep_qnum = 1;
3615 : : }
3616 : :
3617 : 0 : start += param_num + 1;
3618 : 0 : if (start >= split_num)
3619 : : break;
3620 : : } while (1);
3621 : :
3622 : : return 0;
3623 : : }
3624 : :
3625 : : static void
3626 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3627 : : __rte_unused struct cmdline *cl,
3628 : : __rte_unused void *data)
3629 : : {
3630 : 0 : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES] = {0};
3631 : : struct cmd_config_dcb *res = parsed_result;
3632 : : struct rte_eth_dcb_info dcb_info;
3633 : 0 : portid_t port_id = res->port_id;
3634 : 0 : uint8_t prio_tc_en = 0;
3635 : 0 : uint8_t keep_qnum = 0;
3636 : : struct rte_port *port;
3637 : 0 : uint8_t pfc_en = 0;
3638 : : int ret;
3639 : :
3640 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
3641 : 0 : return;
3642 : :
3643 : 0 : port = &ports[port_id];
3644 : : /** Check if the port is not started **/
3645 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3646 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3647 : 0 : return;
3648 : : }
3649 : :
3650 : 0 : if (res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS) {
3651 : 0 : fprintf(stderr,
3652 : : "The invalid number of traffic class, only 1~8 allowed.\n");
3653 : 0 : return;
3654 : : }
3655 : :
3656 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3657 : 0 : fprintf(stderr,
3658 : : "nb_cores shouldn't be less than number of TCs.\n");
3659 : 0 : return;
3660 : : }
3661 : :
3662 : : /* Check whether the port supports the report of DCB info. */
3663 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3664 : 0 : if (ret == -ENOTSUP) {
3665 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3666 : 0 : return;
3667 : : }
3668 : :
3669 : 0 : ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en, &keep_qnum);
3670 : 0 : if (ret != 0)
3671 : : return;
3672 : :
3673 : : /* DCB in VT mode */
3674 : 0 : if (!strncmp(res->vt_en, "on", 2))
3675 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3676 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3677 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3678 : : else
3679 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3680 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3681 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3682 : 0 : if (ret != 0) {
3683 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3684 : 0 : return;
3685 : : }
3686 : :
3687 : 0 : fwd_config_setup();
3688 : :
3689 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3690 : : }
3691 : :
3692 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3693 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3694 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3695 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3696 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3697 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3698 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3699 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3700 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3701 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3702 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3703 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3704 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3705 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3706 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3707 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3708 : : static cmdline_parse_token_string_t cmd_config_dcb_token_str =
3709 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, token_str, TOKEN_STRING_MULTI);
3710 : :
3711 : : static cmdline_parse_inst_t cmd_config_dcb = {
3712 : : .f = cmd_config_dcb_parsed,
3713 : : .data = NULL,
3714 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP keep-qnum\n"
3715 : : "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
3716 : : " PRIO-MAPPING := PRIO:TC\n"
3717 : : " PRIO: { 0 .. 7 }\n"
3718 : : " TC: { 0 .. 7 }",
3719 : : .tokens = {
3720 : : (void *)&cmd_config_dcb_port,
3721 : : (void *)&cmd_config_dcb_config,
3722 : : (void *)&cmd_config_dcb_port_id,
3723 : : (void *)&cmd_config_dcb_dcb,
3724 : : (void *)&cmd_config_dcb_vt,
3725 : : (void *)&cmd_config_dcb_vt_en,
3726 : : (void *)&cmd_config_dcb_num_tcs,
3727 : : (void *)&cmd_config_dcb_pfc,
3728 : : (void *)&cmd_config_dcb_token_str,
3729 : : NULL,
3730 : : },
3731 : : };
3732 : :
3733 : : /* *** configure number of packets per burst *** */
3734 : : struct cmd_config_burst {
3735 : : cmdline_fixed_string_t port;
3736 : : cmdline_fixed_string_t keyword;
3737 : : cmdline_fixed_string_t all;
3738 : : cmdline_fixed_string_t name;
3739 : : uint16_t value;
3740 : : };
3741 : :
3742 : : static void
3743 : 0 : cmd_config_burst_parsed(void *parsed_result,
3744 : : __rte_unused struct cmdline *cl,
3745 : : __rte_unused void *data)
3746 : : {
3747 : : struct cmd_config_burst *res = parsed_result;
3748 : : struct rte_eth_dev_info dev_info;
3749 : : uint16_t rec_nb_pkts;
3750 : : int ret;
3751 : :
3752 : 0 : if (!all_ports_stopped()) {
3753 : 0 : fprintf(stderr, "Please stop all ports first\n");
3754 : 0 : return;
3755 : : }
3756 : :
3757 : 0 : if (!strcmp(res->name, "burst")) {
3758 : 0 : if (res->value == 0) {
3759 : : /* If user gives a value of zero, query the PMD for
3760 : : * its recommended Rx burst size. Testpmd uses a single
3761 : : * size for all ports, so assume all ports are the same
3762 : : * NIC model and use the values from Port 0.
3763 : : */
3764 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3765 : 0 : if (ret != 0)
3766 : : return;
3767 : :
3768 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3769 : :
3770 : 0 : if (rec_nb_pkts == 0) {
3771 : : printf("PMD does not recommend a burst size.\n"
3772 : : "User provided value must be between"
3773 : : " 1 and %d\n", MAX_PKT_BURST);
3774 : 0 : return;
3775 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3776 : 0 : printf("PMD recommended burst size of %d"
3777 : : " exceeds maximum value of %d\n",
3778 : : rec_nb_pkts, MAX_PKT_BURST);
3779 : 0 : return;
3780 : : }
3781 : 0 : printf("Using PMD-provided burst value of %d\n",
3782 : : rec_nb_pkts);
3783 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3784 : 0 : } else if (res->value > MAX_PKT_BURST) {
3785 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3786 : : MAX_PKT_BURST);
3787 : 0 : return;
3788 : : } else
3789 : 0 : nb_pkt_per_burst = res->value;
3790 : : } else {
3791 : 0 : fprintf(stderr, "Unknown parameter\n");
3792 : 0 : return;
3793 : : }
3794 : :
3795 : 0 : init_port_config();
3796 : :
3797 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3798 : : }
3799 : :
3800 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3801 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3802 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3803 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3804 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3805 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3806 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3807 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3808 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3809 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3810 : :
3811 : : static cmdline_parse_inst_t cmd_config_burst = {
3812 : : .f = cmd_config_burst_parsed,
3813 : : .data = NULL,
3814 : : .help_str = "port config all burst <value>",
3815 : : .tokens = {
3816 : : (void *)&cmd_config_burst_port,
3817 : : (void *)&cmd_config_burst_keyword,
3818 : : (void *)&cmd_config_burst_all,
3819 : : (void *)&cmd_config_burst_name,
3820 : : (void *)&cmd_config_burst_value,
3821 : : NULL,
3822 : : },
3823 : : };
3824 : :
3825 : : /* *** configure rx/tx queues *** */
3826 : : struct cmd_config_thresh {
3827 : : cmdline_fixed_string_t port;
3828 : : cmdline_fixed_string_t keyword;
3829 : : cmdline_fixed_string_t all;
3830 : : cmdline_fixed_string_t name;
3831 : : uint8_t value;
3832 : : };
3833 : :
3834 : : static void
3835 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3836 : : __rte_unused struct cmdline *cl,
3837 : : __rte_unused void *data)
3838 : : {
3839 : : struct cmd_config_thresh *res = parsed_result;
3840 : :
3841 : 0 : if (!all_ports_stopped()) {
3842 : 0 : fprintf(stderr, "Please stop all ports first\n");
3843 : 0 : return;
3844 : : }
3845 : :
3846 : 0 : if (!strcmp(res->name, "txpt"))
3847 : 0 : tx_pthresh = res->value;
3848 : 0 : else if(!strcmp(res->name, "txht"))
3849 : 0 : tx_hthresh = res->value;
3850 : 0 : else if(!strcmp(res->name, "txwt"))
3851 : 0 : tx_wthresh = res->value;
3852 : 0 : else if(!strcmp(res->name, "rxpt"))
3853 : 0 : rx_pthresh = res->value;
3854 : 0 : else if(!strcmp(res->name, "rxht"))
3855 : 0 : rx_hthresh = res->value;
3856 : 0 : else if(!strcmp(res->name, "rxwt"))
3857 : 0 : rx_wthresh = res->value;
3858 : : else {
3859 : 0 : fprintf(stderr, "Unknown parameter\n");
3860 : 0 : return;
3861 : : }
3862 : :
3863 : 0 : init_port_config();
3864 : :
3865 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3866 : : }
3867 : :
3868 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3869 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3870 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3871 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3872 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3873 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3874 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3875 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3876 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3877 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3878 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3879 : :
3880 : : static cmdline_parse_inst_t cmd_config_thresh = {
3881 : : .f = cmd_config_thresh_parsed,
3882 : : .data = NULL,
3883 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3884 : : .tokens = {
3885 : : (void *)&cmd_config_thresh_port,
3886 : : (void *)&cmd_config_thresh_keyword,
3887 : : (void *)&cmd_config_thresh_all,
3888 : : (void *)&cmd_config_thresh_name,
3889 : : (void *)&cmd_config_thresh_value,
3890 : : NULL,
3891 : : },
3892 : : };
3893 : :
3894 : : /* *** configure free/rs threshold *** */
3895 : : struct cmd_config_threshold {
3896 : : cmdline_fixed_string_t port;
3897 : : cmdline_fixed_string_t keyword;
3898 : : cmdline_fixed_string_t all;
3899 : : cmdline_fixed_string_t name;
3900 : : uint16_t value;
3901 : : };
3902 : :
3903 : : static void
3904 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3905 : : __rte_unused struct cmdline *cl,
3906 : : __rte_unused void *data)
3907 : : {
3908 : : struct cmd_config_threshold *res = parsed_result;
3909 : :
3910 : 0 : if (!all_ports_stopped()) {
3911 : 0 : fprintf(stderr, "Please stop all ports first\n");
3912 : 0 : return;
3913 : : }
3914 : :
3915 : 0 : if (!strcmp(res->name, "txfreet"))
3916 : 0 : tx_free_thresh = res->value;
3917 : 0 : else if (!strcmp(res->name, "txrst"))
3918 : 0 : tx_rs_thresh = res->value;
3919 : 0 : else if (!strcmp(res->name, "rxfreet"))
3920 : 0 : rx_free_thresh = res->value;
3921 : : else {
3922 : 0 : fprintf(stderr, "Unknown parameter\n");
3923 : 0 : return;
3924 : : }
3925 : :
3926 : 0 : init_port_config();
3927 : :
3928 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3929 : : }
3930 : :
3931 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3932 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3933 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3934 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3935 : : "config");
3936 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3937 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3938 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3939 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3940 : : "txfreet#txrst#rxfreet");
3941 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3942 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3943 : :
3944 : : static cmdline_parse_inst_t cmd_config_threshold = {
3945 : : .f = cmd_config_threshold_parsed,
3946 : : .data = NULL,
3947 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3948 : : .tokens = {
3949 : : (void *)&cmd_config_threshold_port,
3950 : : (void *)&cmd_config_threshold_keyword,
3951 : : (void *)&cmd_config_threshold_all,
3952 : : (void *)&cmd_config_threshold_name,
3953 : : (void *)&cmd_config_threshold_value,
3954 : : NULL,
3955 : : },
3956 : : };
3957 : :
3958 : : /* *** stop *** */
3959 : : struct cmd_stop_result {
3960 : : cmdline_fixed_string_t stop;
3961 : : };
3962 : :
3963 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3964 : : __rte_unused struct cmdline *cl,
3965 : : __rte_unused void *data)
3966 : : {
3967 : 0 : stop_packet_forwarding();
3968 : 0 : }
3969 : :
3970 : : static cmdline_parse_token_string_t cmd_stop_stop =
3971 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3972 : :
3973 : : static cmdline_parse_inst_t cmd_stop = {
3974 : : .f = cmd_stop_parsed,
3975 : : .data = NULL,
3976 : : .help_str = "stop: Stop packet forwarding",
3977 : : .tokens = {
3978 : : (void *)&cmd_stop_stop,
3979 : : NULL,
3980 : : },
3981 : : };
3982 : :
3983 : : static unsigned int
3984 : 0 : get_ptype(char *value)
3985 : : {
3986 : : uint32_t protocol;
3987 : :
3988 : 0 : if (!strcmp(value, "eth"))
3989 : : protocol = RTE_PTYPE_L2_ETHER;
3990 : 0 : else if (!strcmp(value, "ipv4"))
3991 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3992 : 0 : else if (!strcmp(value, "ipv6"))
3993 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3994 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3995 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3996 : 0 : else if (!strcmp(value, "ipv4-udp"))
3997 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3998 : 0 : else if (!strcmp(value, "ipv4-sctp"))
3999 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4000 : 0 : else if (!strcmp(value, "ipv6-tcp"))
4001 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
4002 : 0 : else if (!strcmp(value, "ipv6-udp"))
4003 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
4004 : 0 : else if (!strcmp(value, "ipv6-sctp"))
4005 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4006 : 0 : else if (!strcmp(value, "grenat"))
4007 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
4008 : 0 : else if (!strcmp(value, "inner-eth"))
4009 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
4010 : 0 : else if (!strcmp(value, "inner-ipv4"))
4011 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4012 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
4013 : 0 : else if (!strcmp(value, "inner-ipv6"))
4014 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4015 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
4016 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
4017 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4018 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4019 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
4020 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4021 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4022 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
4023 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4024 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4025 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
4026 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4027 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4028 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
4029 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4030 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4031 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
4032 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4033 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4034 : : else {
4035 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
4036 : : protocol = RTE_PTYPE_UNKNOWN;
4037 : : }
4038 : :
4039 : 0 : return protocol;
4040 : : }
4041 : :
4042 : : /* *** SET RXHDRSLIST *** */
4043 : :
4044 : : unsigned int
4045 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
4046 : : unsigned int *parsed_items)
4047 : : {
4048 : : unsigned int nb_item;
4049 : : char *cur;
4050 : : char *tmp;
4051 : :
4052 : : nb_item = 0;
4053 : 0 : char *str2 = strdup(str);
4054 : 0 : if (str2 == NULL)
4055 : : return nb_item;
4056 : 0 : cur = strtok_r(str2, ",", &tmp);
4057 : 0 : while (cur != NULL) {
4058 : 0 : parsed_items[nb_item] = get_ptype(cur);
4059 : 0 : cur = strtok_r(NULL, ",", &tmp);
4060 : 0 : nb_item++;
4061 : : }
4062 : 0 : if (nb_item > max_items)
4063 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4064 : : item_name, nb_item + 1, max_items);
4065 : 0 : free(str2);
4066 : 0 : return nb_item;
4067 : : }
4068 : :
4069 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
4070 : :
4071 : : unsigned int
4072 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
4073 : : unsigned int *parsed_items, int check_unique_values)
4074 : : {
4075 : : unsigned int nb_item;
4076 : : unsigned int value;
4077 : : unsigned int i;
4078 : : unsigned int j;
4079 : : int value_ok;
4080 : : char c;
4081 : :
4082 : : /*
4083 : : * First parse all items in the list and store their value.
4084 : : */
4085 : : value = 0;
4086 : : nb_item = 0;
4087 : : value_ok = 0;
4088 : 0 : for (i = 0; i < strnlen(str, STR_MULTI_TOKEN_SIZE); i++) {
4089 : 0 : c = str[i];
4090 : 0 : if ((c >= '0') && (c <= '9')) {
4091 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
4092 : : value_ok = 1;
4093 : 0 : continue;
4094 : : }
4095 : 0 : if (c != ',') {
4096 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
4097 : 0 : return 0;
4098 : : }
4099 : 0 : if (! value_ok) {
4100 : 0 : fprintf(stderr, "No valid value before comma\n");
4101 : 0 : return 0;
4102 : : }
4103 : 0 : if (nb_item < max_items) {
4104 : 0 : parsed_items[nb_item] = value;
4105 : : value_ok = 0;
4106 : : value = 0;
4107 : : }
4108 : 0 : nb_item++;
4109 : : }
4110 : 0 : if (nb_item >= max_items) {
4111 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4112 : : item_name, nb_item + 1, max_items);
4113 : 0 : return 0;
4114 : : }
4115 : 0 : parsed_items[nb_item++] = value;
4116 : 0 : if (! check_unique_values)
4117 : : return nb_item;
4118 : :
4119 : : /*
4120 : : * Then, check that all values in the list are different.
4121 : : * No optimization here...
4122 : : */
4123 : 0 : for (i = 0; i < nb_item; i++) {
4124 : 0 : for (j = i + 1; j < nb_item; j++) {
4125 : 0 : if (parsed_items[j] == parsed_items[i]) {
4126 : 0 : fprintf(stderr,
4127 : : "duplicated %s %u at index %u and %u\n",
4128 : : item_name, parsed_items[i], i, j);
4129 : 0 : return 0;
4130 : : }
4131 : : }
4132 : : }
4133 : : return nb_item;
4134 : : }
4135 : :
4136 : : struct cmd_set_list_result {
4137 : : cmdline_fixed_string_t cmd_keyword;
4138 : : cmdline_fixed_string_t list_name;
4139 : : cmdline_multi_string_t list_of_items;
4140 : : };
4141 : :
4142 : 0 : static void cmd_set_list_parsed(void *parsed_result,
4143 : : __rte_unused struct cmdline *cl,
4144 : : __rte_unused void *data)
4145 : : {
4146 : : struct cmd_set_list_result *res;
4147 : : union {
4148 : : unsigned int lcorelist[RTE_MAX_LCORE];
4149 : : unsigned int portlist[RTE_MAX_ETHPORTS];
4150 : : } parsed_items;
4151 : : unsigned int nb_item;
4152 : :
4153 : 0 : if (test_done == 0) {
4154 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4155 : 0 : return;
4156 : : }
4157 : :
4158 : : res = parsed_result;
4159 : 0 : if (!strcmp(res->list_name, "corelist")) {
4160 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
4161 : : RTE_MAX_LCORE,
4162 : : parsed_items.lcorelist, 1);
4163 : 0 : if (nb_item > 0) {
4164 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
4165 : 0 : fwd_config_setup();
4166 : : }
4167 : 0 : return;
4168 : : }
4169 : 0 : if (!strcmp(res->list_name, "portlist")) {
4170 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
4171 : : RTE_MAX_ETHPORTS,
4172 : : parsed_items.portlist, 1);
4173 : 0 : if (nb_item > 0) {
4174 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
4175 : 0 : fwd_config_setup();
4176 : : }
4177 : : }
4178 : : }
4179 : :
4180 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
4181 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
4182 : : "set");
4183 : : static cmdline_parse_token_string_t cmd_set_list_name =
4184 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
4185 : : "corelist#portlist");
4186 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
4187 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
4188 : : TOKEN_STRING_MULTI);
4189 : :
4190 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
4191 : : .f = cmd_set_list_parsed,
4192 : : .data = NULL,
4193 : : .help_str = "set corelist|portlist <list0[,list1]*>",
4194 : : .tokens = {
4195 : : (void *)&cmd_set_list_keyword,
4196 : : (void *)&cmd_set_list_name,
4197 : : (void *)&cmd_set_list_of_items,
4198 : : NULL,
4199 : : },
4200 : : };
4201 : :
4202 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
4203 : :
4204 : : struct cmd_setmask_result {
4205 : : cmdline_fixed_string_t set;
4206 : : cmdline_fixed_string_t mask;
4207 : : uint64_t hexavalue;
4208 : : };
4209 : :
4210 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
4211 : : __rte_unused struct cmdline *cl,
4212 : : __rte_unused void *data)
4213 : : {
4214 : : struct cmd_setmask_result *res = parsed_result;
4215 : :
4216 : 0 : if (test_done == 0) {
4217 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4218 : 0 : return;
4219 : : }
4220 : 0 : if (!strcmp(res->mask, "coremask")) {
4221 : 0 : set_fwd_lcores_mask(res->hexavalue);
4222 : 0 : fwd_config_setup();
4223 : 0 : } else if (!strcmp(res->mask, "portmask")) {
4224 : 0 : set_fwd_ports_mask(res->hexavalue);
4225 : 0 : fwd_config_setup();
4226 : : }
4227 : : }
4228 : :
4229 : : static cmdline_parse_token_string_t cmd_setmask_set =
4230 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
4231 : : static cmdline_parse_token_string_t cmd_setmask_mask =
4232 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
4233 : : "coremask#portmask");
4234 : : static cmdline_parse_token_num_t cmd_setmask_value =
4235 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
4236 : :
4237 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
4238 : : .f = cmd_set_mask_parsed,
4239 : : .data = NULL,
4240 : : .help_str = "set coremask|portmask <hexadecimal value>",
4241 : : .tokens = {
4242 : : (void *)&cmd_setmask_set,
4243 : : (void *)&cmd_setmask_mask,
4244 : : (void *)&cmd_setmask_value,
4245 : : NULL,
4246 : : },
4247 : : };
4248 : :
4249 : : /*
4250 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
4251 : : */
4252 : : struct cmd_set_result {
4253 : : cmdline_fixed_string_t set;
4254 : : cmdline_fixed_string_t what;
4255 : : uint16_t value;
4256 : : };
4257 : :
4258 : 0 : static void cmd_set_parsed(void *parsed_result,
4259 : : __rte_unused struct cmdline *cl,
4260 : : __rte_unused void *data)
4261 : : {
4262 : : struct cmd_set_result *res = parsed_result;
4263 : 0 : if (!strcmp(res->what, "nbport")) {
4264 : 0 : set_fwd_ports_number(res->value);
4265 : 0 : fwd_config_setup();
4266 : 0 : } else if (!strcmp(res->what, "nbcore")) {
4267 : 0 : set_fwd_lcores_number(res->value);
4268 : 0 : fwd_config_setup();
4269 : 0 : } else if (!strcmp(res->what, "burst"))
4270 : 0 : set_nb_pkt_per_burst(res->value);
4271 : 0 : else if (!strcmp(res->what, "verbose"))
4272 : 0 : set_verbose_level(res->value);
4273 : 0 : }
4274 : :
4275 : : static cmdline_parse_token_string_t cmd_set_set =
4276 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
4277 : : static cmdline_parse_token_string_t cmd_set_what =
4278 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
4279 : : "nbport#nbcore#burst#verbose");
4280 : : static cmdline_parse_token_num_t cmd_set_value =
4281 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
4282 : :
4283 : : static cmdline_parse_inst_t cmd_set_numbers = {
4284 : : .f = cmd_set_parsed,
4285 : : .data = NULL,
4286 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
4287 : : .tokens = {
4288 : : (void *)&cmd_set_set,
4289 : : (void *)&cmd_set_what,
4290 : : (void *)&cmd_set_value,
4291 : : NULL,
4292 : : },
4293 : : };
4294 : :
4295 : : /* *** SET LOG LEVEL CONFIGURATION *** */
4296 : :
4297 : : struct cmd_set_log_result {
4298 : : cmdline_fixed_string_t set;
4299 : : cmdline_fixed_string_t log;
4300 : : cmdline_fixed_string_t type;
4301 : : uint32_t level;
4302 : : };
4303 : :
4304 : : static void
4305 : 0 : cmd_set_log_parsed(void *parsed_result,
4306 : : __rte_unused struct cmdline *cl,
4307 : : __rte_unused void *data)
4308 : : {
4309 : : struct cmd_set_log_result *res;
4310 : : int ret;
4311 : :
4312 : : res = parsed_result;
4313 : 0 : if (!strcmp(res->type, "global"))
4314 : 0 : rte_log_set_global_level(res->level);
4315 : : else {
4316 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
4317 : 0 : if (ret < 0)
4318 : 0 : fprintf(stderr, "Unable to set log level\n");
4319 : : }
4320 : 0 : }
4321 : :
4322 : : static cmdline_parse_token_string_t cmd_set_log_set =
4323 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
4324 : : static cmdline_parse_token_string_t cmd_set_log_log =
4325 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
4326 : : static cmdline_parse_token_string_t cmd_set_log_type =
4327 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
4328 : : static cmdline_parse_token_num_t cmd_set_log_level =
4329 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
4330 : :
4331 : : static cmdline_parse_inst_t cmd_set_log = {
4332 : : .f = cmd_set_log_parsed,
4333 : : .data = NULL,
4334 : : .help_str = "set log global|<type> <level>",
4335 : : .tokens = {
4336 : : (void *)&cmd_set_log_set,
4337 : : (void *)&cmd_set_log_log,
4338 : : (void *)&cmd_set_log_type,
4339 : : (void *)&cmd_set_log_level,
4340 : : NULL,
4341 : : },
4342 : : };
4343 : :
4344 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
4345 : :
4346 : : struct cmd_set_rxoffs_result {
4347 : : cmdline_fixed_string_t cmd_keyword;
4348 : : cmdline_fixed_string_t rxoffs;
4349 : : cmdline_fixed_string_t seg_offsets;
4350 : : };
4351 : :
4352 : : static void
4353 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
4354 : : __rte_unused struct cmdline *cl,
4355 : : __rte_unused void *data)
4356 : : {
4357 : : struct cmd_set_rxoffs_result *res;
4358 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
4359 : : unsigned int nb_segs;
4360 : :
4361 : : res = parsed_result;
4362 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
4363 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
4364 : 0 : if (nb_segs > 0)
4365 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
4366 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4367 : 0 : }
4368 : :
4369 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
4370 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4371 : : cmd_keyword, "set");
4372 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
4373 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4374 : : rxoffs, "rxoffs");
4375 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
4376 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4377 : : seg_offsets, NULL);
4378 : :
4379 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
4380 : : .f = cmd_set_rxoffs_parsed,
4381 : : .data = NULL,
4382 : : .help_str = "set rxoffs <len0[,len1]*>",
4383 : : .tokens = {
4384 : : (void *)&cmd_set_rxoffs_keyword,
4385 : : (void *)&cmd_set_rxoffs_name,
4386 : : (void *)&cmd_set_rxoffs_offsets,
4387 : : NULL,
4388 : : },
4389 : : };
4390 : :
4391 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
4392 : :
4393 : : struct cmd_set_rxpkts_result {
4394 : : cmdline_fixed_string_t cmd_keyword;
4395 : : cmdline_fixed_string_t rxpkts;
4396 : : cmdline_fixed_string_t seg_lengths;
4397 : : };
4398 : :
4399 : : static void
4400 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
4401 : : __rte_unused struct cmdline *cl,
4402 : : __rte_unused void *data)
4403 : : {
4404 : : struct cmd_set_rxpkts_result *res;
4405 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
4406 : : unsigned int nb_segs;
4407 : :
4408 : : res = parsed_result;
4409 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4410 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
4411 : 0 : if (nb_segs > 0)
4412 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
4413 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4414 : 0 : }
4415 : :
4416 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
4417 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4418 : : cmd_keyword, "set");
4419 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
4420 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4421 : : rxpkts, "rxpkts");
4422 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4423 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4424 : : seg_lengths, NULL);
4425 : :
4426 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
4427 : : .f = cmd_set_rxpkts_parsed,
4428 : : .data = NULL,
4429 : : .help_str = "set rxpkts <len0[,len1]*>",
4430 : : .tokens = {
4431 : : (void *)&cmd_set_rxpkts_keyword,
4432 : : (void *)&cmd_set_rxpkts_name,
4433 : : (void *)&cmd_set_rxpkts_lengths,
4434 : : NULL,
4435 : : },
4436 : : };
4437 : :
4438 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4439 : : struct cmd_set_rxhdrs_result {
4440 : : cmdline_fixed_string_t set;
4441 : : cmdline_fixed_string_t rxhdrs;
4442 : : cmdline_fixed_string_t values;
4443 : : };
4444 : :
4445 : : static void
4446 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4447 : : __rte_unused struct cmdline *cl,
4448 : : __rte_unused void *data)
4449 : : {
4450 : : struct cmd_set_rxhdrs_result *res;
4451 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4452 : : unsigned int nb_segs;
4453 : :
4454 : : res = parsed_result;
4455 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4456 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4457 : 0 : if (nb_segs > 0)
4458 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4459 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4460 : 0 : }
4461 : :
4462 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4463 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4464 : : set, "set");
4465 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4466 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4467 : : rxhdrs, "rxhdrs");
4468 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4469 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4470 : : values, NULL);
4471 : :
4472 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4473 : : .f = cmd_set_rxhdrs_parsed,
4474 : : .data = NULL,
4475 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4476 : : .tokens = {
4477 : : (void *)&cmd_set_rxhdrs_set,
4478 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4479 : : (void *)&cmd_set_rxhdrs_values,
4480 : : NULL,
4481 : : },
4482 : : };
4483 : :
4484 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4485 : :
4486 : : struct cmd_set_txpkts_result {
4487 : : cmdline_fixed_string_t cmd_keyword;
4488 : : cmdline_fixed_string_t txpkts;
4489 : : cmdline_fixed_string_t seg_lengths;
4490 : : };
4491 : :
4492 : : static void
4493 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4494 : : __rte_unused struct cmdline *cl,
4495 : : __rte_unused void *data)
4496 : : {
4497 : : struct cmd_set_txpkts_result *res;
4498 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4499 : : unsigned int nb_segs;
4500 : :
4501 : : res = parsed_result;
4502 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4503 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4504 : 0 : if (nb_segs > 0)
4505 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4506 : 0 : }
4507 : :
4508 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4509 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4510 : : cmd_keyword, "set");
4511 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4512 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4513 : : txpkts, "txpkts");
4514 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4515 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4516 : : seg_lengths, NULL);
4517 : :
4518 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4519 : : .f = cmd_set_txpkts_parsed,
4520 : : .data = NULL,
4521 : : .help_str = "set txpkts <len0[,len1]*>",
4522 : : .tokens = {
4523 : : (void *)&cmd_set_txpkts_keyword,
4524 : : (void *)&cmd_set_txpkts_name,
4525 : : (void *)&cmd_set_txpkts_lengths,
4526 : : NULL,
4527 : : },
4528 : : };
4529 : :
4530 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4531 : :
4532 : : struct cmd_set_txsplit_result {
4533 : : cmdline_fixed_string_t cmd_keyword;
4534 : : cmdline_fixed_string_t txsplit;
4535 : : cmdline_fixed_string_t mode;
4536 : : };
4537 : :
4538 : : static void
4539 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4540 : : __rte_unused struct cmdline *cl,
4541 : : __rte_unused void *data)
4542 : : {
4543 : : struct cmd_set_txsplit_result *res;
4544 : :
4545 : : res = parsed_result;
4546 : 0 : set_tx_pkt_split(res->mode);
4547 : 0 : }
4548 : :
4549 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4550 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4551 : : cmd_keyword, "set");
4552 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4553 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4554 : : txsplit, "txsplit");
4555 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4556 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4557 : : mode, NULL);
4558 : :
4559 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4560 : : .f = cmd_set_txsplit_parsed,
4561 : : .data = NULL,
4562 : : .help_str = "set txsplit on|off|rand",
4563 : : .tokens = {
4564 : : (void *)&cmd_set_txsplit_keyword,
4565 : : (void *)&cmd_set_txsplit_name,
4566 : : (void *)&cmd_set_txsplit_mode,
4567 : : NULL,
4568 : : },
4569 : : };
4570 : :
4571 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4572 : :
4573 : : struct cmd_set_txtimes_result {
4574 : : cmdline_fixed_string_t cmd_keyword;
4575 : : cmdline_fixed_string_t txtimes;
4576 : : cmdline_fixed_string_t tx_times;
4577 : : };
4578 : :
4579 : : static void
4580 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4581 : : __rte_unused struct cmdline *cl,
4582 : : __rte_unused void *data)
4583 : : {
4584 : : struct cmd_set_txtimes_result *res;
4585 : 0 : unsigned int tx_times[2] = {0, 0};
4586 : : unsigned int n_times;
4587 : :
4588 : : res = parsed_result;
4589 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4590 : : 2, tx_times, 0);
4591 : 0 : if (n_times == 2)
4592 : 0 : set_tx_pkt_times(tx_times);
4593 : 0 : }
4594 : :
4595 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4596 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4597 : : cmd_keyword, "set");
4598 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4599 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4600 : : txtimes, "txtimes");
4601 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4602 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4603 : : tx_times, NULL);
4604 : :
4605 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4606 : : .f = cmd_set_txtimes_parsed,
4607 : : .data = NULL,
4608 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4609 : : .tokens = {
4610 : : (void *)&cmd_set_txtimes_keyword,
4611 : : (void *)&cmd_set_txtimes_name,
4612 : : (void *)&cmd_set_txtimes_value,
4613 : : NULL,
4614 : : },
4615 : : };
4616 : :
4617 : : /* *** SET NUMBER OF FLOWS IN TXONLY MULTI-FLOW MODE *** */
4618 : :
4619 : : struct cmd_set_txflows_result {
4620 : : cmdline_fixed_string_t cmd_keyword;
4621 : : cmdline_fixed_string_t name;
4622 : : uint16_t value;
4623 : : };
4624 : :
4625 : : static void
4626 : 0 : cmd_set_txflows_parsed(void *parsed_result,
4627 : : __rte_unused struct cmdline *cl,
4628 : : __rte_unused void *data)
4629 : : {
4630 : : struct cmd_set_txflows_result *res = parsed_result;
4631 : :
4632 : 0 : if (res->value < 1 || res->value > 64) {
4633 : 0 : fprintf(stderr, "txonly-flows must be >= 1 and <= 64\n");
4634 : 0 : return;
4635 : : }
4636 : 0 : txonly_flows = res->value;
4637 : : }
4638 : :
4639 : : static cmdline_parse_token_string_t cmd_set_txflows_keyword =
4640 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txflows_result,
4641 : : cmd_keyword, "set");
4642 : : static cmdline_parse_token_string_t cmd_set_txflows_name =
4643 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txflows_result,
4644 : : name, "txonly-flows");
4645 : : static cmdline_parse_token_num_t cmd_set_txflows_value =
4646 : : TOKEN_NUM_INITIALIZER(struct cmd_set_txflows_result,
4647 : : value, RTE_UINT16);
4648 : :
4649 : : static cmdline_parse_inst_t cmd_set_txflows = {
4650 : : .f = cmd_set_txflows_parsed,
4651 : : .data = NULL,
4652 : : .help_str = "set txonly-flows <N>",
4653 : : .tokens = {
4654 : : (void *)&cmd_set_txflows_keyword,
4655 : : (void *)&cmd_set_txflows_name,
4656 : : (void *)&cmd_set_txflows_value,
4657 : : NULL,
4658 : : },
4659 : : };
4660 : :
4661 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4662 : : struct cmd_rx_vlan_filter_all_result {
4663 : : cmdline_fixed_string_t rx_vlan;
4664 : : cmdline_fixed_string_t what;
4665 : : cmdline_fixed_string_t all;
4666 : : portid_t port_id;
4667 : : };
4668 : :
4669 : : static void
4670 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4671 : : __rte_unused struct cmdline *cl,
4672 : : __rte_unused void *data)
4673 : : {
4674 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4675 : :
4676 : 0 : if (!strcmp(res->what, "add"))
4677 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4678 : : else
4679 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4680 : 0 : }
4681 : :
4682 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4683 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4684 : : rx_vlan, "rx_vlan");
4685 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4686 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4687 : : what, "add#rm");
4688 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4689 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4690 : : all, "all");
4691 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4692 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4693 : : port_id, RTE_UINT16);
4694 : :
4695 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4696 : : .f = cmd_rx_vlan_filter_all_parsed,
4697 : : .data = NULL,
4698 : : .help_str = "rx_vlan add|rm all <port_id>: "
4699 : : "Add/Remove all identifiers to/from the set of VLAN "
4700 : : "identifiers filtered by a port",
4701 : : .tokens = {
4702 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4703 : : (void *)&cmd_rx_vlan_filter_all_what,
4704 : : (void *)&cmd_rx_vlan_filter_all_all,
4705 : : (void *)&cmd_rx_vlan_filter_all_portid,
4706 : : NULL,
4707 : : },
4708 : : };
4709 : :
4710 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4711 : : struct cmd_vlan_offload_result {
4712 : : cmdline_fixed_string_t vlan;
4713 : : cmdline_fixed_string_t set;
4714 : : cmdline_fixed_string_t vlan_type;
4715 : : cmdline_fixed_string_t what;
4716 : : cmdline_fixed_string_t on;
4717 : : cmdline_fixed_string_t port_id;
4718 : : };
4719 : :
4720 : : static void
4721 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4722 : : __rte_unused struct cmdline *cl,
4723 : : __rte_unused void *data)
4724 : : {
4725 : : int on;
4726 : : struct cmd_vlan_offload_result *res = parsed_result;
4727 : : char *str;
4728 : : int i, len = 0;
4729 : : portid_t port_id = 0;
4730 : : unsigned int tmp;
4731 : :
4732 : 0 : str = res->port_id;
4733 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4734 : : i = 0;
4735 : : /* Get port_id first */
4736 : 0 : while(i < len){
4737 : 0 : if(str[i] == ',')
4738 : : break;
4739 : :
4740 : 0 : i++;
4741 : : }
4742 : 0 : str[i]='\0';
4743 : 0 : tmp = strtoul(str, NULL, 0);
4744 : : /* If port_id greater that what portid_t can represent, return */
4745 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4746 : : return;
4747 : 0 : port_id = (portid_t)tmp;
4748 : :
4749 : 0 : if (!strcmp(res->on, "on"))
4750 : : on = 1;
4751 : : else
4752 : : on = 0;
4753 : :
4754 : 0 : if (!strcmp(res->what, "strip"))
4755 : 0 : rx_vlan_strip_set(port_id, on);
4756 : 0 : else if(!strcmp(res->what, "stripq")){
4757 : : uint16_t queue_id = 0;
4758 : :
4759 : : /* No queue_id, return */
4760 : 0 : if(i + 1 >= len) {
4761 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4762 : 0 : return;
4763 : : }
4764 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4765 : : /* If queue_id greater that what 16-bits can represent, return */
4766 : 0 : if(tmp > 0xffff)
4767 : : return;
4768 : :
4769 : 0 : queue_id = (uint16_t)tmp;
4770 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4771 : : }
4772 : 0 : else if (!strcmp(res->what, "filter"))
4773 : 0 : rx_vlan_filter_set(port_id, on);
4774 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4775 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4776 : : else
4777 : 0 : vlan_extend_set(port_id, on);
4778 : :
4779 : : return;
4780 : : }
4781 : :
4782 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4783 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4784 : : vlan, "vlan");
4785 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4786 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4787 : : set, "set");
4788 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4789 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4790 : : what, "strip#filter#qinq_strip#extend#stripq");
4791 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4792 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4793 : : on, "on#off");
4794 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4795 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4796 : : port_id, NULL);
4797 : :
4798 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4799 : : .f = cmd_vlan_offload_parsed,
4800 : : .data = NULL,
4801 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4802 : : "<port_id[,queue_id]>: "
4803 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4804 : : .tokens = {
4805 : : (void *)&cmd_vlan_offload_vlan,
4806 : : (void *)&cmd_vlan_offload_set,
4807 : : (void *)&cmd_vlan_offload_what,
4808 : : (void *)&cmd_vlan_offload_on,
4809 : : (void *)&cmd_vlan_offload_portid,
4810 : : NULL,
4811 : : },
4812 : : };
4813 : :
4814 : : /* *** VLAN TPID SET ON A PORT *** */
4815 : : struct cmd_vlan_tpid_result {
4816 : : cmdline_fixed_string_t vlan;
4817 : : cmdline_fixed_string_t set;
4818 : : cmdline_fixed_string_t vlan_type;
4819 : : cmdline_fixed_string_t what;
4820 : : uint16_t tp_id;
4821 : : portid_t port_id;
4822 : : };
4823 : :
4824 : : static void
4825 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4826 : : __rte_unused struct cmdline *cl,
4827 : : __rte_unused void *data)
4828 : : {
4829 : : struct cmd_vlan_tpid_result *res = parsed_result;
4830 : : enum rte_vlan_type vlan_type;
4831 : :
4832 : 0 : if (!strcmp(res->vlan_type, "inner"))
4833 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4834 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4835 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4836 : : else {
4837 : 0 : fprintf(stderr, "Unknown vlan type\n");
4838 : 0 : return;
4839 : : }
4840 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4841 : : }
4842 : :
4843 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4844 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4845 : : vlan, "vlan");
4846 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4847 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4848 : : set, "set");
4849 : : static cmdline_parse_token_string_t cmd_vlan_type =
4850 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4851 : : vlan_type, "inner#outer");
4852 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4853 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4854 : : what, "tpid");
4855 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4856 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4857 : : tp_id, RTE_UINT16);
4858 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4859 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4860 : : port_id, RTE_UINT16);
4861 : :
4862 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4863 : : .f = cmd_vlan_tpid_parsed,
4864 : : .data = NULL,
4865 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4866 : : "Set the VLAN Ether type",
4867 : : .tokens = {
4868 : : (void *)&cmd_vlan_tpid_vlan,
4869 : : (void *)&cmd_vlan_tpid_set,
4870 : : (void *)&cmd_vlan_type,
4871 : : (void *)&cmd_vlan_tpid_what,
4872 : : (void *)&cmd_vlan_tpid_tpid,
4873 : : (void *)&cmd_vlan_tpid_portid,
4874 : : NULL,
4875 : : },
4876 : : };
4877 : :
4878 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4879 : : struct cmd_rx_vlan_filter_result {
4880 : : cmdline_fixed_string_t rx_vlan;
4881 : : cmdline_fixed_string_t what;
4882 : : uint16_t vlan_id;
4883 : : portid_t port_id;
4884 : : };
4885 : :
4886 : : static void
4887 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4888 : : __rte_unused struct cmdline *cl,
4889 : : __rte_unused void *data)
4890 : : {
4891 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4892 : :
4893 : 0 : if (!strcmp(res->what, "add"))
4894 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4895 : : else
4896 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4897 : 0 : }
4898 : :
4899 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4900 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4901 : : rx_vlan, "rx_vlan");
4902 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4903 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4904 : : what, "add#rm");
4905 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4906 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4907 : : vlan_id, RTE_UINT16);
4908 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4909 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4910 : : port_id, RTE_UINT16);
4911 : :
4912 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4913 : : .f = cmd_rx_vlan_filter_parsed,
4914 : : .data = NULL,
4915 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4916 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4917 : : "identifiers filtered by a port",
4918 : : .tokens = {
4919 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4920 : : (void *)&cmd_rx_vlan_filter_what,
4921 : : (void *)&cmd_rx_vlan_filter_vlanid,
4922 : : (void *)&cmd_rx_vlan_filter_portid,
4923 : : NULL,
4924 : : },
4925 : : };
4926 : :
4927 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4928 : : struct cmd_tx_vlan_set_result {
4929 : : cmdline_fixed_string_t tx_vlan;
4930 : : cmdline_fixed_string_t set;
4931 : : portid_t port_id;
4932 : : uint16_t vlan_tci;
4933 : : };
4934 : :
4935 : : static void
4936 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4937 : : __rte_unused struct cmdline *cl,
4938 : : __rte_unused void *data)
4939 : : {
4940 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4941 : :
4942 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4943 : : return;
4944 : :
4945 : 0 : if (!port_is_stopped(res->port_id)) {
4946 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4947 : 0 : return;
4948 : : }
4949 : :
4950 : 0 : tx_vlan_set(res->port_id, res->vlan_tci);
4951 : :
4952 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4953 : : }
4954 : :
4955 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4956 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4957 : : tx_vlan, "tx_vlan");
4958 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4959 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4960 : : set, "set");
4961 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4962 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4963 : : port_id, RTE_UINT16);
4964 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlantci =
4965 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4966 : : vlan_tci, RTE_UINT16);
4967 : :
4968 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4969 : : .f = cmd_tx_vlan_set_parsed,
4970 : : .data = NULL,
4971 : : .help_str = "tx_vlan set <port_id> <vlan_tci>: "
4972 : : "Enable hardware insertion of a single VLAN header "
4973 : : "with a given TCI in packets sent on a port",
4974 : : .tokens = {
4975 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4976 : : (void *)&cmd_tx_vlan_set_set,
4977 : : (void *)&cmd_tx_vlan_set_portid,
4978 : : (void *)&cmd_tx_vlan_set_vlantci,
4979 : : NULL,
4980 : : },
4981 : : };
4982 : :
4983 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4984 : : struct cmd_tx_vlan_set_qinq_result {
4985 : : cmdline_fixed_string_t tx_vlan;
4986 : : cmdline_fixed_string_t set;
4987 : : portid_t port_id;
4988 : : uint16_t vlan_tci;
4989 : : uint16_t vlan_tci_outer;
4990 : : };
4991 : :
4992 : : static void
4993 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4994 : : __rte_unused struct cmdline *cl,
4995 : : __rte_unused void *data)
4996 : : {
4997 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4998 : :
4999 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5000 : : return;
5001 : :
5002 : 0 : if (!port_is_stopped(res->port_id)) {
5003 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5004 : 0 : return;
5005 : : }
5006 : :
5007 : 0 : tx_qinq_set(res->port_id, res->vlan_tci, res->vlan_tci_outer);
5008 : :
5009 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5010 : : }
5011 : :
5012 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
5013 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5014 : : tx_vlan, "tx_vlan");
5015 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
5016 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5017 : : set, "set");
5018 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
5019 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5020 : : port_id, RTE_UINT16);
5021 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlantci =
5022 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5023 : : vlan_tci, RTE_UINT16);
5024 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlantci_outer =
5025 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5026 : : vlan_tci_outer, RTE_UINT16);
5027 : :
5028 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
5029 : : .f = cmd_tx_vlan_set_qinq_parsed,
5030 : : .data = NULL,
5031 : : .help_str = "tx_vlan set <port_id> <vlan_tci> <vlan_tci_outer>: "
5032 : : "Enable hardware insertion of double VLAN header "
5033 : : "with given TCIs in packets sent on a port",
5034 : : .tokens = {
5035 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
5036 : : (void *)&cmd_tx_vlan_set_qinq_set,
5037 : : (void *)&cmd_tx_vlan_set_qinq_portid,
5038 : : (void *)&cmd_tx_vlan_set_qinq_vlantci,
5039 : : (void *)&cmd_tx_vlan_set_qinq_vlantci_outer,
5040 : : NULL,
5041 : : },
5042 : : };
5043 : :
5044 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
5045 : : struct cmd_tx_vlan_set_pvid_result {
5046 : : cmdline_fixed_string_t tx_vlan;
5047 : : cmdline_fixed_string_t set;
5048 : : cmdline_fixed_string_t pvid;
5049 : : portid_t port_id;
5050 : : uint16_t vlan_id;
5051 : : cmdline_fixed_string_t mode;
5052 : : };
5053 : :
5054 : : static void
5055 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
5056 : : __rte_unused struct cmdline *cl,
5057 : : __rte_unused void *data)
5058 : : {
5059 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
5060 : :
5061 : 0 : if (strcmp(res->mode, "on") == 0)
5062 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
5063 : : else
5064 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
5065 : 0 : }
5066 : :
5067 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
5068 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5069 : : tx_vlan, "tx_vlan");
5070 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
5071 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5072 : : set, "set");
5073 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
5074 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5075 : : pvid, "pvid");
5076 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
5077 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5078 : : port_id, RTE_UINT16);
5079 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
5080 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5081 : : vlan_id, RTE_UINT16);
5082 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
5083 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5084 : : mode, "on#off");
5085 : :
5086 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
5087 : : .f = cmd_tx_vlan_set_pvid_parsed,
5088 : : .data = NULL,
5089 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
5090 : : .tokens = {
5091 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
5092 : : (void *)&cmd_tx_vlan_set_pvid_set,
5093 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
5094 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
5095 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
5096 : : (void *)&cmd_tx_vlan_set_pvid_mode,
5097 : : NULL,
5098 : : },
5099 : : };
5100 : :
5101 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
5102 : : struct cmd_tx_vlan_reset_result {
5103 : : cmdline_fixed_string_t tx_vlan;
5104 : : cmdline_fixed_string_t reset;
5105 : : portid_t port_id;
5106 : : };
5107 : :
5108 : : static void
5109 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
5110 : : __rte_unused struct cmdline *cl,
5111 : : __rte_unused void *data)
5112 : : {
5113 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
5114 : :
5115 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5116 : : return;
5117 : :
5118 : 0 : if (!port_is_stopped(res->port_id)) {
5119 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5120 : 0 : return;
5121 : : }
5122 : :
5123 : 0 : tx_vlan_reset(res->port_id);
5124 : :
5125 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5126 : : }
5127 : :
5128 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
5129 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5130 : : tx_vlan, "tx_vlan");
5131 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
5132 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5133 : : reset, "reset");
5134 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
5135 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
5136 : : port_id, RTE_UINT16);
5137 : :
5138 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
5139 : : .f = cmd_tx_vlan_reset_parsed,
5140 : : .data = NULL,
5141 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
5142 : : "VLAN header in packets sent on a port",
5143 : : .tokens = {
5144 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
5145 : : (void *)&cmd_tx_vlan_reset_reset,
5146 : : (void *)&cmd_tx_vlan_reset_portid,
5147 : : NULL,
5148 : : },
5149 : : };
5150 : :
5151 : :
5152 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
5153 : : struct cmd_csum_result {
5154 : : cmdline_fixed_string_t csum;
5155 : : cmdline_fixed_string_t mode;
5156 : : cmdline_fixed_string_t proto;
5157 : : cmdline_fixed_string_t hwsw;
5158 : : portid_t port_id;
5159 : : };
5160 : :
5161 : : static void
5162 : 0 : csum_show(int port_id)
5163 : : {
5164 : : struct rte_eth_dev_info dev_info;
5165 : : uint64_t tx_offloads;
5166 : : int ret;
5167 : :
5168 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
5169 : 0 : printf("Parse tunnel is %s\n",
5170 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
5171 : 0 : printf("IP checksum offload is %s\n",
5172 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
5173 : 0 : printf("UDP checksum offload is %s\n",
5174 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
5175 : 0 : printf("TCP checksum offload is %s\n",
5176 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
5177 : 0 : printf("SCTP checksum offload is %s\n",
5178 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
5179 : 0 : printf("Outer-Ip checksum offload is %s\n",
5180 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
5181 : 0 : printf("Outer-Udp checksum offload is %s\n",
5182 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
5183 : :
5184 : : /* display warnings if configuration is not supported by the NIC */
5185 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
5186 : 0 : if (ret != 0)
5187 : 0 : return;
5188 : :
5189 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
5190 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
5191 : 0 : fprintf(stderr,
5192 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
5193 : : port_id);
5194 : : }
5195 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
5196 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
5197 : 0 : fprintf(stderr,
5198 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
5199 : : port_id);
5200 : : }
5201 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
5202 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
5203 : 0 : fprintf(stderr,
5204 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
5205 : : port_id);
5206 : : }
5207 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
5208 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
5209 : 0 : fprintf(stderr,
5210 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
5211 : : port_id);
5212 : : }
5213 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
5214 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
5215 : 0 : fprintf(stderr,
5216 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
5217 : : port_id);
5218 : : }
5219 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
5220 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
5221 : : == 0) {
5222 : 0 : fprintf(stderr,
5223 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
5224 : : port_id);
5225 : : }
5226 : : }
5227 : :
5228 : : static void
5229 : : cmd_config_queue_tx_offloads(struct rte_port *port)
5230 : : {
5231 : : int k;
5232 : :
5233 : : /* Apply queue tx offloads configuration */
5234 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
5235 : 0 : port->txq[k].conf.offloads =
5236 : 0 : port->dev_conf.txmode.offloads;
5237 : : }
5238 : :
5239 : : static void
5240 : 0 : cmd_csum_parsed(void *parsed_result,
5241 : : __rte_unused struct cmdline *cl,
5242 : : __rte_unused void *data)
5243 : : {
5244 : : struct cmd_csum_result *res = parsed_result;
5245 : : int hw = 0;
5246 : : uint64_t csum_offloads = 0;
5247 : : struct rte_eth_dev_info dev_info;
5248 : : int ret;
5249 : :
5250 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
5251 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
5252 : 0 : return;
5253 : : }
5254 : 0 : if (!port_is_stopped(res->port_id)) {
5255 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5256 : 0 : return;
5257 : : }
5258 : :
5259 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5260 : 0 : if (ret != 0)
5261 : : return;
5262 : :
5263 : 0 : if (!strcmp(res->mode, "set")) {
5264 : :
5265 : 0 : if (!strcmp(res->hwsw, "hw"))
5266 : : hw = 1;
5267 : :
5268 : 0 : if (!strcmp(res->proto, "ip")) {
5269 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5270 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
5271 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
5272 : : } else {
5273 : 0 : fprintf(stderr,
5274 : : "IP checksum offload is not supported by port %u\n",
5275 : 0 : res->port_id);
5276 : : }
5277 : 0 : } else if (!strcmp(res->proto, "udp")) {
5278 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5279 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
5280 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
5281 : : } else {
5282 : 0 : fprintf(stderr,
5283 : : "UDP checksum offload is not supported by port %u\n",
5284 : 0 : res->port_id);
5285 : : }
5286 : 0 : } else if (!strcmp(res->proto, "tcp")) {
5287 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5288 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
5289 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
5290 : : } else {
5291 : 0 : fprintf(stderr,
5292 : : "TCP checksum offload is not supported by port %u\n",
5293 : 0 : res->port_id);
5294 : : }
5295 : 0 : } else if (!strcmp(res->proto, "sctp")) {
5296 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5297 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
5298 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
5299 : : } else {
5300 : 0 : fprintf(stderr,
5301 : : "SCTP checksum offload is not supported by port %u\n",
5302 : 0 : res->port_id);
5303 : : }
5304 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
5305 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5306 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5307 : : csum_offloads |=
5308 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
5309 : : } else {
5310 : 0 : fprintf(stderr,
5311 : : "Outer IP checksum offload is not supported by port %u\n",
5312 : 0 : res->port_id);
5313 : : }
5314 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
5315 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5316 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
5317 : : csum_offloads |=
5318 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
5319 : : } else {
5320 : 0 : fprintf(stderr,
5321 : : "Outer UDP checksum offload is not supported by port %u\n",
5322 : 0 : res->port_id);
5323 : : }
5324 : : }
5325 : :
5326 : 0 : if (hw) {
5327 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5328 : : csum_offloads;
5329 : : } else {
5330 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5331 : 0 : (~csum_offloads);
5332 : : }
5333 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5334 : : }
5335 : 0 : csum_show(res->port_id);
5336 : :
5337 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5338 : : }
5339 : :
5340 : : static cmdline_parse_token_string_t cmd_csum_csum =
5341 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5342 : : csum, "csum");
5343 : : static cmdline_parse_token_string_t cmd_csum_mode =
5344 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5345 : : mode, "set");
5346 : : static cmdline_parse_token_string_t cmd_csum_proto =
5347 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5348 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
5349 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
5350 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5351 : : hwsw, "hw#sw");
5352 : : static cmdline_parse_token_num_t cmd_csum_portid =
5353 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
5354 : : port_id, RTE_UINT16);
5355 : :
5356 : : static cmdline_parse_inst_t cmd_csum_set = {
5357 : : .f = cmd_csum_parsed,
5358 : : .data = NULL,
5359 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
5360 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
5361 : : "using csum forward engine",
5362 : : .tokens = {
5363 : : (void *)&cmd_csum_csum,
5364 : : (void *)&cmd_csum_mode,
5365 : : (void *)&cmd_csum_proto,
5366 : : (void *)&cmd_csum_hwsw,
5367 : : (void *)&cmd_csum_portid,
5368 : : NULL,
5369 : : },
5370 : : };
5371 : :
5372 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
5373 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5374 : : mode, "show");
5375 : :
5376 : : static cmdline_parse_inst_t cmd_csum_show = {
5377 : : .f = cmd_csum_parsed,
5378 : : .data = NULL,
5379 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
5380 : : .tokens = {
5381 : : (void *)&cmd_csum_csum,
5382 : : (void *)&cmd_csum_mode_show,
5383 : : (void *)&cmd_csum_portid,
5384 : : NULL,
5385 : : },
5386 : : };
5387 : :
5388 : : /* Enable/disable tunnel parsing */
5389 : : struct cmd_csum_tunnel_result {
5390 : : cmdline_fixed_string_t csum;
5391 : : cmdline_fixed_string_t parse;
5392 : : cmdline_fixed_string_t onoff;
5393 : : portid_t port_id;
5394 : : };
5395 : :
5396 : : static void
5397 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
5398 : : __rte_unused struct cmdline *cl,
5399 : : __rte_unused void *data)
5400 : : {
5401 : : struct cmd_csum_tunnel_result *res = parsed_result;
5402 : :
5403 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5404 : : return;
5405 : :
5406 : 0 : if (!strcmp(res->onoff, "on"))
5407 : 0 : ports[res->port_id].parse_tunnel = 1;
5408 : : else
5409 : 0 : ports[res->port_id].parse_tunnel = 0;
5410 : :
5411 : 0 : csum_show(res->port_id);
5412 : : }
5413 : :
5414 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
5415 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5416 : : csum, "csum");
5417 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
5418 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5419 : : parse, "parse-tunnel");
5420 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
5421 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5422 : : onoff, "on#off");
5423 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
5424 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
5425 : : port_id, RTE_UINT16);
5426 : :
5427 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
5428 : : .f = cmd_csum_tunnel_parsed,
5429 : : .data = NULL,
5430 : : .help_str = "csum parse-tunnel on|off <port_id>: "
5431 : : "Enable/Disable parsing of tunnels for csum engine",
5432 : : .tokens = {
5433 : : (void *)&cmd_csum_tunnel_csum,
5434 : : (void *)&cmd_csum_tunnel_parse,
5435 : : (void *)&cmd_csum_tunnel_onoff,
5436 : : (void *)&cmd_csum_tunnel_portid,
5437 : : NULL,
5438 : : },
5439 : : };
5440 : :
5441 : : struct cmd_csum_mac_swap_result {
5442 : : cmdline_fixed_string_t csum;
5443 : : cmdline_fixed_string_t parse;
5444 : : cmdline_fixed_string_t onoff;
5445 : : portid_t port_id;
5446 : : };
5447 : :
5448 : : static void
5449 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
5450 : : __rte_unused struct cmdline *cl,
5451 : : __rte_unused void *data)
5452 : : {
5453 : : struct cmd_csum_mac_swap_result *res = parsed_result;
5454 : :
5455 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5456 : : return;
5457 : 0 : if (strcmp(res->onoff, "on") == 0)
5458 : 0 : ports[res->port_id].fwd_mac_swap = 1;
5459 : : else
5460 : 0 : ports[res->port_id].fwd_mac_swap = 0;
5461 : : }
5462 : :
5463 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
5464 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5465 : : csum, "csum");
5466 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
5467 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5468 : : parse, "mac-swap");
5469 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
5470 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5471 : : onoff, "on#off");
5472 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
5473 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
5474 : : port_id, RTE_UINT16);
5475 : :
5476 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
5477 : : .f = cmd_csum_mac_swap_parsed,
5478 : : .data = NULL,
5479 : : .help_str = "csum mac-swap on|off <port_id>: "
5480 : : "Enable/Disable forward mac address swap",
5481 : : .tokens = {
5482 : : (void *)&cmd_csum_mac_swap_csum,
5483 : : (void *)&cmd_csum_mac_swap_parse,
5484 : : (void *)&cmd_csum_mac_swap_onoff,
5485 : : (void *)&cmd_csum_mac_swap_portid,
5486 : : NULL,
5487 : : },
5488 : : };
5489 : :
5490 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5491 : : struct cmd_tso_set_result {
5492 : : cmdline_fixed_string_t tso;
5493 : : cmdline_fixed_string_t mode;
5494 : : uint16_t tso_segsz;
5495 : : portid_t port_id;
5496 : : };
5497 : :
5498 : : static void
5499 : 0 : cmd_tso_set_parsed(void *parsed_result,
5500 : : __rte_unused struct cmdline *cl,
5501 : : __rte_unused void *data)
5502 : : {
5503 : : struct cmd_tso_set_result *res = parsed_result;
5504 : : struct rte_eth_dev_info dev_info;
5505 : : uint64_t offloads;
5506 : : int ret;
5507 : :
5508 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5509 : 0 : return;
5510 : 0 : if (!port_is_stopped(res->port_id)) {
5511 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5512 : 0 : return;
5513 : : }
5514 : :
5515 : 0 : if (!strcmp(res->mode, "set"))
5516 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5517 : :
5518 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5519 : 0 : if (ret != 0)
5520 : : return;
5521 : :
5522 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5523 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5524 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5525 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5526 : : res->port_id);
5527 : 0 : return;
5528 : : }
5529 : : /* display warnings if configuration is not supported by the NIC */
5530 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5531 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5532 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5533 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5534 : : }
5535 : :
5536 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5537 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5538 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5539 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5540 : : } else {
5541 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5542 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5543 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5544 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5545 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5546 : 0 : printf("segment size for non-tunneled packets is %d\n",
5547 : : ports[res->port_id].tso_segsz);
5548 : : }
5549 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5550 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5551 : : }
5552 : :
5553 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5554 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5555 : : tso, "tso");
5556 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5557 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5558 : : mode, "set");
5559 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5560 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5561 : : tso_segsz, RTE_UINT16);
5562 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5563 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5564 : : port_id, RTE_UINT16);
5565 : :
5566 : : static cmdline_parse_inst_t cmd_tso_set = {
5567 : : .f = cmd_tso_set_parsed,
5568 : : .data = NULL,
5569 : : .help_str = "tso set <tso_segsz> <port_id>: "
5570 : : "Set TSO segment size of non-tunneled packets for csum engine "
5571 : : "(0 to disable)",
5572 : : .tokens = {
5573 : : (void *)&cmd_tso_set_tso,
5574 : : (void *)&cmd_tso_set_mode,
5575 : : (void *)&cmd_tso_set_tso_segsz,
5576 : : (void *)&cmd_tso_set_portid,
5577 : : NULL,
5578 : : },
5579 : : };
5580 : :
5581 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5582 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5583 : : mode, "show");
5584 : :
5585 : :
5586 : : static cmdline_parse_inst_t cmd_tso_show = {
5587 : : .f = cmd_tso_set_parsed,
5588 : : .data = NULL,
5589 : : .help_str = "tso show <port_id>: "
5590 : : "Show TSO segment size of non-tunneled packets for csum engine",
5591 : : .tokens = {
5592 : : (void *)&cmd_tso_set_tso,
5593 : : (void *)&cmd_tso_show_mode,
5594 : : (void *)&cmd_tso_set_portid,
5595 : : NULL,
5596 : : },
5597 : : };
5598 : :
5599 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5600 : : struct cmd_tunnel_tso_set_result {
5601 : : cmdline_fixed_string_t tso;
5602 : : cmdline_fixed_string_t mode;
5603 : : uint16_t tso_segsz;
5604 : : portid_t port_id;
5605 : : };
5606 : :
5607 : : static void
5608 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5609 : : {
5610 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5611 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5612 : : port_id);
5613 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5614 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5615 : : port_id);
5616 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5617 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5618 : : port_id);
5619 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5620 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5621 : : port_id);
5622 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5623 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5624 : : port_id);
5625 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5626 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5627 : : port_id);
5628 : 0 : }
5629 : :
5630 : : static void
5631 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5632 : : __rte_unused struct cmdline *cl,
5633 : : __rte_unused void *data)
5634 : : {
5635 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5636 : : struct rte_eth_dev_info dev_info;
5637 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5638 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5639 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5640 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5641 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5642 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5643 : : int ret;
5644 : :
5645 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5646 : 0 : return;
5647 : 0 : if (!port_is_stopped(res->port_id)) {
5648 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5649 : 0 : return;
5650 : : }
5651 : :
5652 : 0 : if (!strcmp(res->mode, "set"))
5653 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5654 : :
5655 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5656 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5657 : : printf("TSO for tunneled packets is disabled\n");
5658 : : } else {
5659 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5660 : 0 : if (ret != 0)
5661 : : return;
5662 : :
5663 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5664 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5665 : 0 : res->port_id);
5666 : 0 : return;
5667 : : }
5668 : :
5669 : : /* Below conditions are needed to make it work:
5670 : : * (1) tunnel TSO is supported by the NIC;
5671 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5672 : : * are recognized;
5673 : : * (3) for tunneled pkts with outer L3 of IPv4,
5674 : : * "csum set outer-ip" must be set to hw, because after tso,
5675 : : * total_len of outer IP header is changed, and the checksum
5676 : : * of outer IP header calculated by sw should be wrong; that
5677 : : * is not necessary for IPv6 tunneled pkts because there's no
5678 : : * checksum in IP header anymore.
5679 : : */
5680 : 0 : if (!ports[res->port_id].parse_tunnel) {
5681 : 0 : fprintf(stderr,
5682 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5683 : 0 : return;
5684 : : }
5685 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5686 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5687 : 0 : fprintf(stderr,
5688 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5689 : 0 : return;
5690 : : }
5691 : :
5692 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5693 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5694 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5695 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5696 : 0 : ports[res->port_id].tunnel_tso_segsz);
5697 : : }
5698 : :
5699 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5700 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5701 : : }
5702 : :
5703 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5704 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5705 : : tso, "tunnel_tso");
5706 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5707 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5708 : : mode, "set");
5709 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5710 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5711 : : tso_segsz, RTE_UINT16);
5712 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5713 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5714 : : port_id, RTE_UINT16);
5715 : :
5716 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5717 : : .f = cmd_tunnel_tso_set_parsed,
5718 : : .data = NULL,
5719 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5720 : : "Set TSO segment size of tunneled packets for csum engine "
5721 : : "(0 to disable)",
5722 : : .tokens = {
5723 : : (void *)&cmd_tunnel_tso_set_tso,
5724 : : (void *)&cmd_tunnel_tso_set_mode,
5725 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5726 : : (void *)&cmd_tunnel_tso_set_portid,
5727 : : NULL,
5728 : : },
5729 : : };
5730 : :
5731 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5732 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5733 : : mode, "show");
5734 : :
5735 : :
5736 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5737 : : .f = cmd_tunnel_tso_set_parsed,
5738 : : .data = NULL,
5739 : : .help_str = "tunnel_tso show <port_id> "
5740 : : "Show TSO segment size of tunneled packets for csum engine",
5741 : : .tokens = {
5742 : : (void *)&cmd_tunnel_tso_set_tso,
5743 : : (void *)&cmd_tunnel_tso_show_mode,
5744 : : (void *)&cmd_tunnel_tso_set_portid,
5745 : : NULL,
5746 : : },
5747 : : };
5748 : :
5749 : : #ifdef RTE_LIB_GRO
5750 : : /* *** SET GRO FOR A PORT *** */
5751 : : struct cmd_gro_enable_result {
5752 : : cmdline_fixed_string_t cmd_set;
5753 : : cmdline_fixed_string_t cmd_port;
5754 : : cmdline_fixed_string_t cmd_keyword;
5755 : : cmdline_fixed_string_t cmd_onoff;
5756 : : portid_t cmd_pid;
5757 : : };
5758 : :
5759 : : static void
5760 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5761 : : __rte_unused struct cmdline *cl,
5762 : : __rte_unused void *data)
5763 : : {
5764 : : struct cmd_gro_enable_result *res;
5765 : :
5766 : : res = parsed_result;
5767 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5768 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5769 : 0 : }
5770 : :
5771 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5772 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5773 : : cmd_set, "set");
5774 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5775 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5776 : : cmd_keyword, "port");
5777 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5778 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5779 : : cmd_pid, RTE_UINT16);
5780 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5781 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5782 : : cmd_keyword, "gro");
5783 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5784 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5785 : : cmd_onoff, "on#off");
5786 : :
5787 : : static cmdline_parse_inst_t cmd_gro_enable = {
5788 : : .f = cmd_gro_enable_parsed,
5789 : : .data = NULL,
5790 : : .help_str = "set port <port_id> gro on|off",
5791 : : .tokens = {
5792 : : (void *)&cmd_gro_enable_set,
5793 : : (void *)&cmd_gro_enable_port,
5794 : : (void *)&cmd_gro_enable_pid,
5795 : : (void *)&cmd_gro_enable_keyword,
5796 : : (void *)&cmd_gro_enable_onoff,
5797 : : NULL,
5798 : : },
5799 : : };
5800 : :
5801 : : /* *** DISPLAY GRO CONFIGURATION *** */
5802 : : struct cmd_gro_show_result {
5803 : : cmdline_fixed_string_t cmd_show;
5804 : : cmdline_fixed_string_t cmd_port;
5805 : : cmdline_fixed_string_t cmd_keyword;
5806 : : portid_t cmd_pid;
5807 : : };
5808 : :
5809 : : static void
5810 : 0 : cmd_gro_show_parsed(void *parsed_result,
5811 : : __rte_unused struct cmdline *cl,
5812 : : __rte_unused void *data)
5813 : : {
5814 : : struct cmd_gro_show_result *res;
5815 : :
5816 : : res = parsed_result;
5817 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5818 : 0 : show_gro(res->cmd_pid);
5819 : 0 : }
5820 : :
5821 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5822 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5823 : : cmd_show, "show");
5824 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5825 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5826 : : cmd_port, "port");
5827 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5828 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5829 : : cmd_pid, RTE_UINT16);
5830 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5831 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5832 : : cmd_keyword, "gro");
5833 : :
5834 : : static cmdline_parse_inst_t cmd_gro_show = {
5835 : : .f = cmd_gro_show_parsed,
5836 : : .data = NULL,
5837 : : .help_str = "show port <port_id> gro",
5838 : : .tokens = {
5839 : : (void *)&cmd_gro_show_show,
5840 : : (void *)&cmd_gro_show_port,
5841 : : (void *)&cmd_gro_show_pid,
5842 : : (void *)&cmd_gro_show_keyword,
5843 : : NULL,
5844 : : },
5845 : : };
5846 : :
5847 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5848 : : struct cmd_gro_flush_result {
5849 : : cmdline_fixed_string_t cmd_set;
5850 : : cmdline_fixed_string_t cmd_keyword;
5851 : : cmdline_fixed_string_t cmd_flush;
5852 : : uint8_t cmd_cycles;
5853 : : };
5854 : :
5855 : : static void
5856 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5857 : : __rte_unused struct cmdline *cl,
5858 : : __rte_unused void *data)
5859 : : {
5860 : : struct cmd_gro_flush_result *res;
5861 : :
5862 : : res = parsed_result;
5863 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5864 : 0 : (!strcmp(res->cmd_flush, "flush")))
5865 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5866 : 0 : }
5867 : :
5868 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5869 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5870 : : cmd_set, "set");
5871 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5872 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5873 : : cmd_keyword, "gro");
5874 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5875 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5876 : : cmd_flush, "flush");
5877 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5878 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5879 : : cmd_cycles, RTE_UINT8);
5880 : :
5881 : : static cmdline_parse_inst_t cmd_gro_flush = {
5882 : : .f = cmd_gro_flush_parsed,
5883 : : .data = NULL,
5884 : : .help_str = "set gro flush <cycles>",
5885 : : .tokens = {
5886 : : (void *)&cmd_gro_flush_set,
5887 : : (void *)&cmd_gro_flush_keyword,
5888 : : (void *)&cmd_gro_flush_flush,
5889 : : (void *)&cmd_gro_flush_cycles,
5890 : : NULL,
5891 : : },
5892 : : };
5893 : : #endif /* RTE_LIB_GRO */
5894 : :
5895 : : #ifdef RTE_LIB_GSO
5896 : : /* *** ENABLE/DISABLE GSO *** */
5897 : : struct cmd_gso_enable_result {
5898 : : cmdline_fixed_string_t cmd_set;
5899 : : cmdline_fixed_string_t cmd_port;
5900 : : cmdline_fixed_string_t cmd_keyword;
5901 : : cmdline_fixed_string_t cmd_mode;
5902 : : portid_t cmd_pid;
5903 : : };
5904 : :
5905 : : static void
5906 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5907 : : __rte_unused struct cmdline *cl,
5908 : : __rte_unused void *data)
5909 : : {
5910 : : struct cmd_gso_enable_result *res;
5911 : :
5912 : : res = parsed_result;
5913 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5914 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5915 : 0 : }
5916 : :
5917 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5918 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5919 : : cmd_set, "set");
5920 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5921 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5922 : : cmd_port, "port");
5923 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5924 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5925 : : cmd_keyword, "gso");
5926 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5927 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5928 : : cmd_mode, "on#off");
5929 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5930 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5931 : : cmd_pid, RTE_UINT16);
5932 : :
5933 : : static cmdline_parse_inst_t cmd_gso_enable = {
5934 : : .f = cmd_gso_enable_parsed,
5935 : : .data = NULL,
5936 : : .help_str = "set port <port_id> gso on|off",
5937 : : .tokens = {
5938 : : (void *)&cmd_gso_enable_set,
5939 : : (void *)&cmd_gso_enable_port,
5940 : : (void *)&cmd_gso_enable_pid,
5941 : : (void *)&cmd_gso_enable_keyword,
5942 : : (void *)&cmd_gso_enable_mode,
5943 : : NULL,
5944 : : },
5945 : : };
5946 : :
5947 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5948 : : struct cmd_gso_size_result {
5949 : : cmdline_fixed_string_t cmd_set;
5950 : : cmdline_fixed_string_t cmd_keyword;
5951 : : cmdline_fixed_string_t cmd_segsz;
5952 : : uint16_t cmd_size;
5953 : : };
5954 : :
5955 : : static void
5956 : 0 : cmd_gso_size_parsed(void *parsed_result,
5957 : : __rte_unused struct cmdline *cl,
5958 : : __rte_unused void *data)
5959 : : {
5960 : : struct cmd_gso_size_result *res = parsed_result;
5961 : :
5962 : 0 : if (test_done == 0) {
5963 : 0 : fprintf(stderr,
5964 : : "Before setting GSO segsz, please first stop forwarding\n");
5965 : 0 : return;
5966 : : }
5967 : :
5968 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5969 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5970 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5971 : 0 : fprintf(stderr,
5972 : : "gso_size should be larger than %zu. Please input a legal value\n",
5973 : : RTE_GSO_SEG_SIZE_MIN);
5974 : : else
5975 : 0 : gso_max_segment_size = res->cmd_size;
5976 : : }
5977 : : }
5978 : :
5979 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5980 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5981 : : cmd_set, "set");
5982 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5983 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5984 : : cmd_keyword, "gso");
5985 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5986 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5987 : : cmd_segsz, "segsz");
5988 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5989 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5990 : : cmd_size, RTE_UINT16);
5991 : :
5992 : : static cmdline_parse_inst_t cmd_gso_size = {
5993 : : .f = cmd_gso_size_parsed,
5994 : : .data = NULL,
5995 : : .help_str = "set gso segsz <length>",
5996 : : .tokens = {
5997 : : (void *)&cmd_gso_size_set,
5998 : : (void *)&cmd_gso_size_keyword,
5999 : : (void *)&cmd_gso_size_segsz,
6000 : : (void *)&cmd_gso_size_size,
6001 : : NULL,
6002 : : },
6003 : : };
6004 : :
6005 : : /* *** SHOW GSO CONFIGURATION *** */
6006 : : struct cmd_gso_show_result {
6007 : : cmdline_fixed_string_t cmd_show;
6008 : : cmdline_fixed_string_t cmd_port;
6009 : : cmdline_fixed_string_t cmd_keyword;
6010 : : portid_t cmd_pid;
6011 : : };
6012 : :
6013 : : static void
6014 : 0 : cmd_gso_show_parsed(void *parsed_result,
6015 : : __rte_unused struct cmdline *cl,
6016 : : __rte_unused void *data)
6017 : : {
6018 : : struct cmd_gso_show_result *res = parsed_result;
6019 : :
6020 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
6021 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
6022 : 0 : return;
6023 : : }
6024 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
6025 : 0 : if (gso_ports[res->cmd_pid].enable) {
6026 : 0 : printf("Max GSO'd packet size: %uB\n"
6027 : : "Supported GSO types: TCP/IPv4, "
6028 : : "UDP/IPv4, VxLAN with inner "
6029 : : "TCP/IPv4 packet, GRE with inner "
6030 : : "TCP/IPv4 packet\n",
6031 : : gso_max_segment_size);
6032 : : } else
6033 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
6034 : : }
6035 : : }
6036 : :
6037 : : static cmdline_parse_token_string_t cmd_gso_show_show =
6038 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6039 : : cmd_show, "show");
6040 : : static cmdline_parse_token_string_t cmd_gso_show_port =
6041 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6042 : : cmd_port, "port");
6043 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
6044 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6045 : : cmd_keyword, "gso");
6046 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
6047 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
6048 : : cmd_pid, RTE_UINT16);
6049 : :
6050 : : static cmdline_parse_inst_t cmd_gso_show = {
6051 : : .f = cmd_gso_show_parsed,
6052 : : .data = NULL,
6053 : : .help_str = "show port <port_id> gso",
6054 : : .tokens = {
6055 : : (void *)&cmd_gso_show_show,
6056 : : (void *)&cmd_gso_show_port,
6057 : : (void *)&cmd_gso_show_pid,
6058 : : (void *)&cmd_gso_show_keyword,
6059 : : NULL,
6060 : : },
6061 : : };
6062 : : #endif /* RTE_LIB_GSO */
6063 : :
6064 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
6065 : : struct cmd_set_flush_rx {
6066 : : cmdline_fixed_string_t set;
6067 : : cmdline_fixed_string_t flush_rx;
6068 : : cmdline_fixed_string_t mode;
6069 : : };
6070 : :
6071 : : static void
6072 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
6073 : : __rte_unused struct cmdline *cl,
6074 : : __rte_unused void *data)
6075 : : {
6076 : : struct cmd_set_flush_rx *res = parsed_result;
6077 : :
6078 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
6079 : : printf("multi-process doesn't support to flush Rx queues.\n");
6080 : 0 : return;
6081 : : }
6082 : :
6083 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6084 : : }
6085 : :
6086 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
6087 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6088 : : set, "set");
6089 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
6090 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6091 : : flush_rx, "flush_rx");
6092 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
6093 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6094 : : mode, "on#off");
6095 : :
6096 : :
6097 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
6098 : : .f = cmd_set_flush_rx_parsed,
6099 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
6100 : : .data = NULL,
6101 : : .tokens = {
6102 : : (void *)&cmd_setflushrx_set,
6103 : : (void *)&cmd_setflushrx_flush_rx,
6104 : : (void *)&cmd_setflushrx_mode,
6105 : : NULL,
6106 : : },
6107 : : };
6108 : :
6109 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
6110 : : struct cmd_set_link_check {
6111 : : cmdline_fixed_string_t set;
6112 : : cmdline_fixed_string_t link_check;
6113 : : cmdline_fixed_string_t mode;
6114 : : };
6115 : :
6116 : : static void
6117 : 0 : cmd_set_link_check_parsed(void *parsed_result,
6118 : : __rte_unused struct cmdline *cl,
6119 : : __rte_unused void *data)
6120 : : {
6121 : : struct cmd_set_link_check *res = parsed_result;
6122 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6123 : 0 : }
6124 : :
6125 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
6126 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6127 : : set, "set");
6128 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
6129 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6130 : : link_check, "link_check");
6131 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
6132 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6133 : : mode, "on#off");
6134 : :
6135 : :
6136 : : static cmdline_parse_inst_t cmd_set_link_check = {
6137 : : .f = cmd_set_link_check_parsed,
6138 : : .help_str = "set link_check on|off: Enable/Disable link status check "
6139 : : "when starting/stopping a port",
6140 : : .data = NULL,
6141 : : .tokens = {
6142 : : (void *)&cmd_setlinkcheck_set,
6143 : : (void *)&cmd_setlinkcheck_link_check,
6144 : : (void *)&cmd_setlinkcheck_mode,
6145 : : NULL,
6146 : : },
6147 : : };
6148 : :
6149 : : /* *** SET FORWARDING MODE *** */
6150 : : struct cmd_set_fwd_mode_result {
6151 : : cmdline_fixed_string_t set;
6152 : : cmdline_fixed_string_t fwd;
6153 : : cmdline_fixed_string_t mode;
6154 : : };
6155 : :
6156 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
6157 : : __rte_unused struct cmdline *cl,
6158 : : __rte_unused void *data)
6159 : : {
6160 : : struct cmd_set_fwd_mode_result *res = parsed_result;
6161 : :
6162 : 0 : retry_enabled = 0;
6163 : 0 : set_pkt_forwarding_mode(res->mode);
6164 : 0 : }
6165 : :
6166 : : static cmdline_parse_token_string_t cmd_setfwd_set =
6167 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6168 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
6169 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6170 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
6171 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6172 : : "" /* defined at init */);
6173 : :
6174 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
6175 : : .f = cmd_set_fwd_mode_parsed,
6176 : : .data = NULL,
6177 : : .help_str = NULL, /* defined at init */
6178 : : .tokens = {
6179 : : (void *)&cmd_setfwd_set,
6180 : : (void *)&cmd_setfwd_fwd,
6181 : : (void *)&cmd_setfwd_mode,
6182 : : NULL,
6183 : : },
6184 : : };
6185 : :
6186 : 0 : static void cmd_set_fwd_mode_init(void)
6187 : : {
6188 : : char *modes, *c;
6189 : : static char token[128];
6190 : : static char help[256];
6191 : : cmdline_parse_token_string_t *token_struct;
6192 : :
6193 : 0 : modes = list_pkt_forwarding_modes();
6194 : : snprintf(help, sizeof(help), "set fwd %s: "
6195 : : "Set packet forwarding mode", modes);
6196 : 0 : cmd_set_fwd_mode.help_str = help;
6197 : :
6198 : : /* string token separator is # */
6199 : 0 : for (c = token; *modes != '\0'; modes++)
6200 : 0 : if (*modes == '|')
6201 : 0 : *c++ = '#';
6202 : : else
6203 : 0 : *c++ = *modes;
6204 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6205 : 0 : token_struct->string_data.str = token;
6206 : 0 : }
6207 : :
6208 : : /* *** SET RETRY FORWARDING MODE *** */
6209 : : struct cmd_set_fwd_retry_mode_result {
6210 : : cmdline_fixed_string_t set;
6211 : : cmdline_fixed_string_t fwd;
6212 : : cmdline_fixed_string_t mode;
6213 : : cmdline_fixed_string_t retry;
6214 : : };
6215 : :
6216 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6217 : : __rte_unused struct cmdline *cl,
6218 : : __rte_unused void *data)
6219 : : {
6220 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6221 : :
6222 : 0 : retry_enabled = 1;
6223 : 0 : set_pkt_forwarding_mode(res->mode);
6224 : 0 : }
6225 : :
6226 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6227 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6228 : : set, "set");
6229 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6230 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6231 : : fwd, "fwd");
6232 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6233 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6234 : : mode,
6235 : : "" /* defined at init */);
6236 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6237 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6238 : : retry, "retry");
6239 : :
6240 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6241 : : .f = cmd_set_fwd_retry_mode_parsed,
6242 : : .data = NULL,
6243 : : .help_str = NULL, /* defined at init */
6244 : : .tokens = {
6245 : : (void *)&cmd_setfwd_retry_set,
6246 : : (void *)&cmd_setfwd_retry_fwd,
6247 : : (void *)&cmd_setfwd_retry_mode,
6248 : : (void *)&cmd_setfwd_retry_retry,
6249 : : NULL,
6250 : : },
6251 : : };
6252 : :
6253 : 0 : static void cmd_set_fwd_retry_mode_init(void)
6254 : : {
6255 : : char *modes, *c;
6256 : : static char token[128];
6257 : : static char help[256];
6258 : : cmdline_parse_token_string_t *token_struct;
6259 : :
6260 : 0 : modes = list_pkt_forwarding_retry_modes();
6261 : : snprintf(help, sizeof(help), "set fwd %s retry: "
6262 : : "Set packet forwarding mode with retry", modes);
6263 : 0 : cmd_set_fwd_retry_mode.help_str = help;
6264 : :
6265 : : /* string token separator is # */
6266 : 0 : for (c = token; *modes != '\0'; modes++)
6267 : 0 : if (*modes == '|')
6268 : 0 : *c++ = '#';
6269 : : else
6270 : 0 : *c++ = *modes;
6271 : 0 : token_struct = (cmdline_parse_token_string_t *)
6272 : : cmd_set_fwd_retry_mode.tokens[2];
6273 : 0 : token_struct->string_data.str = token;
6274 : 0 : }
6275 : :
6276 : 0 : static void show_dcb_fwd_tc_config(void)
6277 : : {
6278 : : int i;
6279 : : printf("DCB forwarding TC list:");
6280 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6281 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6282 : : printf(" %d", i);
6283 : : }
6284 : : printf("\n");
6285 : 0 : printf("DCB forwarding cores per-TC: %u\n", dcb_fwd_tc_cores);
6286 : 0 : }
6287 : :
6288 : : /* *** set DCB forward TCs *** */
6289 : : struct cmd_set_dcb_fwd_tc_result {
6290 : : cmdline_fixed_string_t set;
6291 : : cmdline_fixed_string_t dcb;
6292 : : cmdline_fixed_string_t fwd_tc;
6293 : : uint8_t tc_mask;
6294 : : };
6295 : :
6296 : 0 : static void cmd_set_dcb_fwd_tc_parsed(void *parsed_result,
6297 : : __rte_unused struct cmdline *cl,
6298 : : __rte_unused void *data)
6299 : : {
6300 : : struct cmd_set_dcb_fwd_tc_result *res = parsed_result;
6301 : : int i;
6302 : 0 : if (test_done == 0) {
6303 : 0 : fprintf(stderr, "Please stop forwarding first\n");
6304 : 0 : return;
6305 : : }
6306 : 0 : if (res->tc_mask == 0) {
6307 : 0 : fprintf(stderr, "TC mask should not be zero!\n");
6308 : 0 : return;
6309 : : }
6310 : : printf("Enabled DCB forwarding TC list:");
6311 : 0 : dcb_fwd_tc_mask = res->tc_mask;
6312 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6313 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6314 : : printf(" %d", i);
6315 : : }
6316 : : printf("\n");
6317 : : }
6318 : :
6319 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_set =
6320 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6321 : : set, "set");
6322 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_dcb =
6323 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6324 : : dcb, "dcb");
6325 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_fwdtc =
6326 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6327 : : fwd_tc, "fwd_tc");
6328 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_tcmask =
6329 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6330 : : tc_mask, RTE_UINT8);
6331 : :
6332 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc = {
6333 : : .f = cmd_set_dcb_fwd_tc_parsed,
6334 : : .data = NULL,
6335 : : .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.",
6336 : : .tokens = {
6337 : : (void *)&cmd_set_dcb_fwd_tc_set,
6338 : : (void *)&cmd_set_dcb_fwd_tc_dcb,
6339 : : (void *)&cmd_set_dcb_fwd_tc_fwdtc,
6340 : : (void *)&cmd_set_dcb_fwd_tc_tcmask,
6341 : : NULL,
6342 : : },
6343 : : };
6344 : :
6345 : : /* *** set DCB forward cores per TC *** */
6346 : : struct cmd_set_dcb_fwd_tc_cores_result {
6347 : : cmdline_fixed_string_t set;
6348 : : cmdline_fixed_string_t dcb;
6349 : : cmdline_fixed_string_t fwd_tc_cores;
6350 : : uint8_t tc_cores;
6351 : : };
6352 : :
6353 : 0 : static void cmd_set_dcb_fwd_tc_cores_parsed(void *parsed_result,
6354 : : __rte_unused struct cmdline *cl,
6355 : : __rte_unused void *data)
6356 : : {
6357 : : struct cmd_set_dcb_fwd_tc_cores_result *res = parsed_result;
6358 : 0 : if (test_done == 0) {
6359 : 0 : fprintf(stderr, "Please stop forwarding first\n");
6360 : 0 : return;
6361 : : }
6362 : 0 : if (res->tc_cores == 0) {
6363 : 0 : fprintf(stderr, "Cores per-TC should not be zero!\n");
6364 : 0 : return;
6365 : : }
6366 : 0 : dcb_fwd_tc_cores = res->tc_cores;
6367 : 0 : printf("Set cores-per-TC: %u\n", dcb_fwd_tc_cores);
6368 : : }
6369 : :
6370 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_set =
6371 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6372 : : set, "set");
6373 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_dcb =
6374 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6375 : : dcb, "dcb");
6376 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_fwdtccores =
6377 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6378 : : fwd_tc_cores, "fwd_tc_cores");
6379 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_cores_tccores =
6380 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6381 : : tc_cores, RTE_UINT8);
6382 : :
6383 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc_cores = {
6384 : : .f = cmd_set_dcb_fwd_tc_cores_parsed,
6385 : : .data = NULL,
6386 : : .help_str = "config DCB forwarding cores per-TC, 1-means one core process all queues of a TC.",
6387 : : .tokens = {
6388 : : (void *)&cmd_set_dcb_fwd_tc_cores_set,
6389 : : (void *)&cmd_set_dcb_fwd_tc_cores_dcb,
6390 : : (void *)&cmd_set_dcb_fwd_tc_cores_fwdtccores,
6391 : : (void *)&cmd_set_dcb_fwd_tc_cores_tccores,
6392 : : NULL,
6393 : : },
6394 : : };
6395 : :
6396 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6397 : : struct cmd_set_burst_tx_retry_result {
6398 : : cmdline_fixed_string_t set;
6399 : : cmdline_fixed_string_t burst;
6400 : : cmdline_fixed_string_t tx;
6401 : : cmdline_fixed_string_t delay;
6402 : : uint32_t time;
6403 : : cmdline_fixed_string_t retry;
6404 : : uint32_t retry_num;
6405 : : };
6406 : :
6407 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6408 : : __rte_unused struct cmdline *cl,
6409 : : __rte_unused void *data)
6410 : : {
6411 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
6412 : :
6413 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6414 : 0 : && !strcmp(res->tx, "tx")) {
6415 : 0 : if (!strcmp(res->delay, "delay"))
6416 : 0 : burst_tx_delay_time = res->time;
6417 : 0 : if (!strcmp(res->retry, "retry"))
6418 : 0 : burst_tx_retry_num = res->retry_num;
6419 : : }
6420 : :
6421 : 0 : }
6422 : :
6423 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6424 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6425 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6426 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6427 : : "burst");
6428 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6429 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6430 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6431 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6432 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6433 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6434 : : RTE_UINT32);
6435 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6436 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6437 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6438 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6439 : : RTE_UINT32);
6440 : :
6441 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6442 : : .f = cmd_set_burst_tx_retry_parsed,
6443 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6444 : : .tokens = {
6445 : : (void *)&cmd_set_burst_tx_retry_set,
6446 : : (void *)&cmd_set_burst_tx_retry_burst,
6447 : : (void *)&cmd_set_burst_tx_retry_tx,
6448 : : (void *)&cmd_set_burst_tx_retry_delay,
6449 : : (void *)&cmd_set_burst_tx_retry_time,
6450 : : (void *)&cmd_set_burst_tx_retry_retry,
6451 : : (void *)&cmd_set_burst_tx_retry_retry_num,
6452 : : NULL,
6453 : : },
6454 : : };
6455 : :
6456 : : /* *** SET PROMISC MODE *** */
6457 : : struct cmd_set_promisc_mode_result {
6458 : : cmdline_fixed_string_t set;
6459 : : cmdline_fixed_string_t promisc;
6460 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6461 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6462 : : cmdline_fixed_string_t mode;
6463 : : };
6464 : :
6465 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
6466 : : __rte_unused struct cmdline *cl,
6467 : : void *allports)
6468 : : {
6469 : : struct cmd_set_promisc_mode_result *res = parsed_result;
6470 : : int enable;
6471 : : portid_t i;
6472 : :
6473 : 0 : if (!strcmp(res->mode, "on"))
6474 : : enable = 1;
6475 : : else
6476 : : enable = 0;
6477 : :
6478 : : /* all ports */
6479 : 0 : if (allports) {
6480 : 0 : RTE_ETH_FOREACH_DEV(i)
6481 : 0 : eth_set_promisc_mode(i, enable);
6482 : : } else {
6483 : 0 : eth_set_promisc_mode(res->port_num, enable);
6484 : : }
6485 : 0 : }
6486 : :
6487 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
6488 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6489 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
6490 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6491 : : "promisc");
6492 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
6493 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6494 : : "all");
6495 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
6496 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6497 : : RTE_UINT16);
6498 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
6499 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6500 : : "on#off");
6501 : :
6502 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6503 : : .f = cmd_set_promisc_mode_parsed,
6504 : : .data = (void *)1,
6505 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
6506 : : .tokens = {
6507 : : (void *)&cmd_setpromisc_set,
6508 : : (void *)&cmd_setpromisc_promisc,
6509 : : (void *)&cmd_setpromisc_portall,
6510 : : (void *)&cmd_setpromisc_mode,
6511 : : NULL,
6512 : : },
6513 : : };
6514 : :
6515 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6516 : : .f = cmd_set_promisc_mode_parsed,
6517 : : .data = (void *)0,
6518 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6519 : : .tokens = {
6520 : : (void *)&cmd_setpromisc_set,
6521 : : (void *)&cmd_setpromisc_promisc,
6522 : : (void *)&cmd_setpromisc_portnum,
6523 : : (void *)&cmd_setpromisc_mode,
6524 : : NULL,
6525 : : },
6526 : : };
6527 : :
6528 : : /* *** SET ALLMULTI MODE *** */
6529 : : struct cmd_set_allmulti_mode_result {
6530 : : cmdline_fixed_string_t set;
6531 : : cmdline_fixed_string_t allmulti;
6532 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6533 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6534 : : cmdline_fixed_string_t mode;
6535 : : };
6536 : :
6537 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6538 : : __rte_unused struct cmdline *cl,
6539 : : void *allports)
6540 : : {
6541 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
6542 : : int enable;
6543 : : portid_t i;
6544 : :
6545 : 0 : if (!strcmp(res->mode, "on"))
6546 : : enable = 1;
6547 : : else
6548 : : enable = 0;
6549 : :
6550 : : /* all ports */
6551 : 0 : if (allports) {
6552 : 0 : RTE_ETH_FOREACH_DEV(i) {
6553 : 0 : eth_set_allmulticast_mode(i, enable);
6554 : : }
6555 : : }
6556 : : else {
6557 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
6558 : : }
6559 : 0 : }
6560 : :
6561 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
6562 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6563 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6564 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6565 : : "allmulti");
6566 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
6567 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6568 : : "all");
6569 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
6570 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6571 : : RTE_UINT16);
6572 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
6573 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6574 : : "on#off");
6575 : :
6576 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6577 : : .f = cmd_set_allmulti_mode_parsed,
6578 : : .data = (void *)1,
6579 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6580 : : .tokens = {
6581 : : (void *)&cmd_setallmulti_set,
6582 : : (void *)&cmd_setallmulti_allmulti,
6583 : : (void *)&cmd_setallmulti_portall,
6584 : : (void *)&cmd_setallmulti_mode,
6585 : : NULL,
6586 : : },
6587 : : };
6588 : :
6589 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6590 : : .f = cmd_set_allmulti_mode_parsed,
6591 : : .data = (void *)0,
6592 : : .help_str = "set allmulti <port_id> on|off: "
6593 : : "Set allmulti mode on port_id",
6594 : : .tokens = {
6595 : : (void *)&cmd_setallmulti_set,
6596 : : (void *)&cmd_setallmulti_allmulti,
6597 : : (void *)&cmd_setallmulti_portnum,
6598 : : (void *)&cmd_setallmulti_mode,
6599 : : NULL,
6600 : : },
6601 : : };
6602 : :
6603 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6604 : : struct cmd_link_flow_ctrl_show {
6605 : : cmdline_fixed_string_t show;
6606 : : cmdline_fixed_string_t port;
6607 : : portid_t port_id;
6608 : : cmdline_fixed_string_t flow_ctrl;
6609 : : };
6610 : :
6611 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6612 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6613 : : show, "show");
6614 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6615 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6616 : : port, "port");
6617 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6618 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6619 : : port_id, RTE_UINT16);
6620 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6621 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6622 : : flow_ctrl, "flow_ctrl");
6623 : :
6624 : : static void
6625 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6626 : : __rte_unused struct cmdline *cl,
6627 : : __rte_unused void *data)
6628 : : {
6629 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6630 : : static const char *info_border = "*********************";
6631 : : struct rte_eth_fc_conf fc_conf;
6632 : : bool rx_fc_en = false;
6633 : : bool tx_fc_en = false;
6634 : : int ret;
6635 : :
6636 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6637 : 0 : if (ret != 0) {
6638 : 0 : fprintf(stderr,
6639 : : "Failed to get current flow ctrl information: err = %d\n",
6640 : : ret);
6641 : 0 : return;
6642 : : }
6643 : :
6644 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6645 : : rx_fc_en = true;
6646 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6647 : : tx_fc_en = true;
6648 : :
6649 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6650 : 0 : info_border, res->port_id, info_border);
6651 : : printf("FC mode:\n");
6652 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6653 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6654 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6655 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6656 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6657 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6658 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6659 : 0 : printf("Forward MAC control frames: %s\n",
6660 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6661 : 0 : printf("\n%s************** End ***********%s\n",
6662 : : info_border, info_border);
6663 : : }
6664 : :
6665 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6666 : : .f = cmd_link_flow_ctrl_show_parsed,
6667 : : .data = NULL,
6668 : : .help_str = "show port <port_id> flow_ctrl",
6669 : : .tokens = {
6670 : : (void *)&cmd_lfc_show_show,
6671 : : (void *)&cmd_lfc_show_port,
6672 : : (void *)&cmd_lfc_show_portid,
6673 : : (void *)&cmd_lfc_show_flow_ctrl,
6674 : : NULL,
6675 : : },
6676 : : };
6677 : :
6678 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6679 : : struct cmd_link_flow_ctrl_set_result {
6680 : : cmdline_fixed_string_t set;
6681 : : cmdline_fixed_string_t flow_ctrl;
6682 : : cmdline_fixed_string_t rx;
6683 : : cmdline_fixed_string_t rx_lfc_mode;
6684 : : cmdline_fixed_string_t tx;
6685 : : cmdline_fixed_string_t tx_lfc_mode;
6686 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6687 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6688 : : cmdline_fixed_string_t autoneg_str;
6689 : : cmdline_fixed_string_t autoneg;
6690 : : cmdline_fixed_string_t hw_str;
6691 : : uint32_t high_water;
6692 : : cmdline_fixed_string_t lw_str;
6693 : : uint32_t low_water;
6694 : : cmdline_fixed_string_t pt_str;
6695 : : uint16_t pause_time;
6696 : : cmdline_fixed_string_t xon_str;
6697 : : uint16_t send_xon;
6698 : : portid_t port_id;
6699 : : };
6700 : :
6701 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6702 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6703 : : set, "set");
6704 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6705 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6706 : : flow_ctrl, "flow_ctrl");
6707 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6708 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6709 : : rx, "rx");
6710 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6711 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6712 : : rx_lfc_mode, "on#off");
6713 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6714 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6715 : : tx, "tx");
6716 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6717 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6718 : : tx_lfc_mode, "on#off");
6719 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6720 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6721 : : hw_str, "high_water");
6722 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6723 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6724 : : high_water, RTE_UINT32);
6725 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6726 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6727 : : lw_str, "low_water");
6728 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6729 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6730 : : low_water, RTE_UINT32);
6731 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6732 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6733 : : pt_str, "pause_time");
6734 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6735 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6736 : : pause_time, RTE_UINT16);
6737 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6738 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6739 : : xon_str, "send_xon");
6740 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6741 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6742 : : send_xon, RTE_UINT16);
6743 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6744 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6745 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6746 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6747 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6748 : : mac_ctrl_frame_fwd_mode, "on#off");
6749 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6750 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6751 : : autoneg_str, "autoneg");
6752 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6753 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6754 : : autoneg, "on#off");
6755 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6756 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6757 : : port_id, RTE_UINT16);
6758 : :
6759 : : /* forward declaration */
6760 : : static void
6761 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6762 : : void *data);
6763 : :
6764 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6765 : : .f = cmd_link_flow_ctrl_set_parsed,
6766 : : .data = NULL,
6767 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6768 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6769 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6770 : : .tokens = {
6771 : : (void *)&cmd_lfc_set_set,
6772 : : (void *)&cmd_lfc_set_flow_ctrl,
6773 : : (void *)&cmd_lfc_set_rx,
6774 : : (void *)&cmd_lfc_set_rx_mode,
6775 : : (void *)&cmd_lfc_set_tx,
6776 : : (void *)&cmd_lfc_set_tx_mode,
6777 : : (void *)&cmd_lfc_set_high_water,
6778 : : (void *)&cmd_lfc_set_low_water,
6779 : : (void *)&cmd_lfc_set_pause_time,
6780 : : (void *)&cmd_lfc_set_send_xon,
6781 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6782 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6783 : : (void *)&cmd_lfc_set_autoneg_str,
6784 : : (void *)&cmd_lfc_set_autoneg,
6785 : : (void *)&cmd_lfc_set_portid,
6786 : : NULL,
6787 : : },
6788 : : };
6789 : :
6790 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6791 : : .f = cmd_link_flow_ctrl_set_parsed,
6792 : : .data = (void *)&cmd_link_flow_control_set_rx,
6793 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6794 : : "Change rx flow control parameter",
6795 : : .tokens = {
6796 : : (void *)&cmd_lfc_set_set,
6797 : : (void *)&cmd_lfc_set_flow_ctrl,
6798 : : (void *)&cmd_lfc_set_rx,
6799 : : (void *)&cmd_lfc_set_rx_mode,
6800 : : (void *)&cmd_lfc_set_portid,
6801 : : NULL,
6802 : : },
6803 : : };
6804 : :
6805 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6806 : : .f = cmd_link_flow_ctrl_set_parsed,
6807 : : .data = (void *)&cmd_link_flow_control_set_tx,
6808 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6809 : : "Change tx flow control parameter",
6810 : : .tokens = {
6811 : : (void *)&cmd_lfc_set_set,
6812 : : (void *)&cmd_lfc_set_flow_ctrl,
6813 : : (void *)&cmd_lfc_set_tx,
6814 : : (void *)&cmd_lfc_set_tx_mode,
6815 : : (void *)&cmd_lfc_set_portid,
6816 : : NULL,
6817 : : },
6818 : : };
6819 : :
6820 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6821 : : .f = cmd_link_flow_ctrl_set_parsed,
6822 : : .data = (void *)&cmd_link_flow_control_set_hw,
6823 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6824 : : "Change high water flow control parameter",
6825 : : .tokens = {
6826 : : (void *)&cmd_lfc_set_set,
6827 : : (void *)&cmd_lfc_set_flow_ctrl,
6828 : : (void *)&cmd_lfc_set_high_water_str,
6829 : : (void *)&cmd_lfc_set_high_water,
6830 : : (void *)&cmd_lfc_set_portid,
6831 : : NULL,
6832 : : },
6833 : : };
6834 : :
6835 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6836 : : .f = cmd_link_flow_ctrl_set_parsed,
6837 : : .data = (void *)&cmd_link_flow_control_set_lw,
6838 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6839 : : "Change low water flow control parameter",
6840 : : .tokens = {
6841 : : (void *)&cmd_lfc_set_set,
6842 : : (void *)&cmd_lfc_set_flow_ctrl,
6843 : : (void *)&cmd_lfc_set_low_water_str,
6844 : : (void *)&cmd_lfc_set_low_water,
6845 : : (void *)&cmd_lfc_set_portid,
6846 : : NULL,
6847 : : },
6848 : : };
6849 : :
6850 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6851 : : .f = cmd_link_flow_ctrl_set_parsed,
6852 : : .data = (void *)&cmd_link_flow_control_set_pt,
6853 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6854 : : "Change pause time flow control parameter",
6855 : : .tokens = {
6856 : : (void *)&cmd_lfc_set_set,
6857 : : (void *)&cmd_lfc_set_flow_ctrl,
6858 : : (void *)&cmd_lfc_set_pause_time_str,
6859 : : (void *)&cmd_lfc_set_pause_time,
6860 : : (void *)&cmd_lfc_set_portid,
6861 : : NULL,
6862 : : },
6863 : : };
6864 : :
6865 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6866 : : .f = cmd_link_flow_ctrl_set_parsed,
6867 : : .data = (void *)&cmd_link_flow_control_set_xon,
6868 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6869 : : "Change send_xon flow control parameter",
6870 : : .tokens = {
6871 : : (void *)&cmd_lfc_set_set,
6872 : : (void *)&cmd_lfc_set_flow_ctrl,
6873 : : (void *)&cmd_lfc_set_send_xon_str,
6874 : : (void *)&cmd_lfc_set_send_xon,
6875 : : (void *)&cmd_lfc_set_portid,
6876 : : NULL,
6877 : : },
6878 : : };
6879 : :
6880 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6881 : : .f = cmd_link_flow_ctrl_set_parsed,
6882 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6883 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6884 : : "Change mac ctrl fwd flow control parameter",
6885 : : .tokens = {
6886 : : (void *)&cmd_lfc_set_set,
6887 : : (void *)&cmd_lfc_set_flow_ctrl,
6888 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6889 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6890 : : (void *)&cmd_lfc_set_portid,
6891 : : NULL,
6892 : : },
6893 : : };
6894 : :
6895 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6896 : : .f = cmd_link_flow_ctrl_set_parsed,
6897 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6898 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6899 : : "Change autoneg flow control parameter",
6900 : : .tokens = {
6901 : : (void *)&cmd_lfc_set_set,
6902 : : (void *)&cmd_lfc_set_flow_ctrl,
6903 : : (void *)&cmd_lfc_set_autoneg_str,
6904 : : (void *)&cmd_lfc_set_autoneg,
6905 : : (void *)&cmd_lfc_set_portid,
6906 : : NULL,
6907 : : },
6908 : : };
6909 : :
6910 : : static void
6911 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6912 : : __rte_unused struct cmdline *cl,
6913 : : void *data)
6914 : : {
6915 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6916 : : cmdline_parse_inst_t *cmd = data;
6917 : : struct rte_eth_fc_conf fc_conf;
6918 : : int rx_fc_en = 0;
6919 : : int tx_fc_en = 0;
6920 : : int ret;
6921 : :
6922 : : /*
6923 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6924 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6925 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6926 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6927 : : */
6928 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6929 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6930 : : };
6931 : :
6932 : : /* Partial command line, retrieve current configuration */
6933 : 0 : if (cmd) {
6934 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6935 : 0 : if (ret != 0) {
6936 : 0 : fprintf(stderr,
6937 : : "cannot get current flow ctrl parameters, return code = %d\n",
6938 : : ret);
6939 : 0 : return;
6940 : : }
6941 : :
6942 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6943 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6944 : : rx_fc_en = 1;
6945 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6946 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6947 : : tx_fc_en = 1;
6948 : : }
6949 : :
6950 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6951 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6952 : :
6953 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6954 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6955 : :
6956 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6957 : :
6958 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6959 : 0 : fc_conf.high_water = res->high_water;
6960 : :
6961 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6962 : 0 : fc_conf.low_water = res->low_water;
6963 : :
6964 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6965 : 0 : fc_conf.pause_time = res->pause_time;
6966 : :
6967 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6968 : 0 : fc_conf.send_xon = res->send_xon;
6969 : :
6970 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6971 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6972 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6973 : : else
6974 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6975 : : }
6976 : :
6977 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6978 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6979 : :
6980 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6981 : 0 : if (ret != 0)
6982 : 0 : fprintf(stderr,
6983 : : "bad flow control parameter, return code = %d\n",
6984 : : ret);
6985 : : }
6986 : :
6987 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6988 : : struct cmd_priority_flow_ctrl_set_result {
6989 : : cmdline_fixed_string_t set;
6990 : : cmdline_fixed_string_t pfc_ctrl;
6991 : : cmdline_fixed_string_t rx;
6992 : : cmdline_fixed_string_t rx_pfc_mode;
6993 : : cmdline_fixed_string_t tx;
6994 : : cmdline_fixed_string_t tx_pfc_mode;
6995 : : uint32_t high_water;
6996 : : uint32_t low_water;
6997 : : uint16_t pause_time;
6998 : : uint8_t priority;
6999 : : portid_t port_id;
7000 : : };
7001 : :
7002 : : static void
7003 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7004 : : __rte_unused struct cmdline *cl,
7005 : : __rte_unused void *data)
7006 : : {
7007 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7008 : : struct rte_eth_pfc_conf pfc_conf;
7009 : : int rx_fc_enable, tx_fc_enable;
7010 : : int ret;
7011 : :
7012 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
7013 : 0 : return;
7014 : :
7015 : : /*
7016 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7017 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7018 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7019 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7020 : : */
7021 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7022 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7023 : : };
7024 : :
7025 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7026 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7027 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7028 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7029 : 0 : pfc_conf.fc.high_water = res->high_water;
7030 : 0 : pfc_conf.fc.low_water = res->low_water;
7031 : 0 : pfc_conf.fc.pause_time = res->pause_time;
7032 : 0 : pfc_conf.priority = res->priority;
7033 : :
7034 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7035 : 0 : if (ret != 0)
7036 : 0 : fprintf(stderr,
7037 : : "bad priority flow control parameter, return code = %d\n",
7038 : : ret);
7039 : : }
7040 : :
7041 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
7042 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7043 : : set, "set");
7044 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7045 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7046 : : pfc_ctrl, "pfc_ctrl");
7047 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
7048 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7049 : : rx, "rx");
7050 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7051 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7052 : : rx_pfc_mode, "on#off");
7053 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
7054 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7055 : : tx, "tx");
7056 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7057 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7058 : : tx_pfc_mode, "on#off");
7059 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
7060 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7061 : : high_water, RTE_UINT32);
7062 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
7063 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7064 : : low_water, RTE_UINT32);
7065 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7066 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7067 : : pause_time, RTE_UINT16);
7068 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
7069 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7070 : : priority, RTE_UINT8);
7071 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
7072 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7073 : : port_id, RTE_UINT16);
7074 : :
7075 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
7076 : : .f = cmd_priority_flow_ctrl_set_parsed,
7077 : : .data = NULL,
7078 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7079 : : "<pause_time> <priority> <port_id>: "
7080 : : "Configure the Ethernet priority flow control",
7081 : : .tokens = {
7082 : : (void *)&cmd_pfc_set_set,
7083 : : (void *)&cmd_pfc_set_flow_ctrl,
7084 : : (void *)&cmd_pfc_set_rx,
7085 : : (void *)&cmd_pfc_set_rx_mode,
7086 : : (void *)&cmd_pfc_set_tx,
7087 : : (void *)&cmd_pfc_set_tx_mode,
7088 : : (void *)&cmd_pfc_set_high_water,
7089 : : (void *)&cmd_pfc_set_low_water,
7090 : : (void *)&cmd_pfc_set_pause_time,
7091 : : (void *)&cmd_pfc_set_priority,
7092 : : (void *)&cmd_pfc_set_portid,
7093 : : NULL,
7094 : : },
7095 : : };
7096 : :
7097 : : struct cmd_queue_priority_flow_ctrl_set_result {
7098 : : cmdline_fixed_string_t set;
7099 : : cmdline_fixed_string_t pfc_queue_ctrl;
7100 : : portid_t port_id;
7101 : : cmdline_fixed_string_t rx;
7102 : : cmdline_fixed_string_t rx_pfc_mode;
7103 : : uint16_t tx_qid;
7104 : : uint8_t tx_tc;
7105 : : cmdline_fixed_string_t tx;
7106 : : cmdline_fixed_string_t tx_pfc_mode;
7107 : : uint16_t rx_qid;
7108 : : uint8_t rx_tc;
7109 : : uint16_t pause_time;
7110 : : };
7111 : :
7112 : : static void
7113 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7114 : : __rte_unused struct cmdline *cl,
7115 : : __rte_unused void *data)
7116 : : {
7117 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7118 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
7119 : : int rx_fc_enable, tx_fc_enable;
7120 : : int ret;
7121 : :
7122 : : /*
7123 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
7124 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7125 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
7126 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7127 : : * the Tx side.
7128 : : */
7129 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7130 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7131 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7132 : : };
7133 : :
7134 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7135 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7136 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7137 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7138 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
7139 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7140 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
7141 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7142 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7143 : :
7144 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7145 : : &pfc_queue_conf);
7146 : 0 : if (ret != 0) {
7147 : 0 : fprintf(stderr,
7148 : : "bad queue priority flow control parameter, rc = %d\n",
7149 : : ret);
7150 : : }
7151 : 0 : }
7152 : :
7153 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
7154 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7155 : : set, "set");
7156 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7157 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7158 : : pfc_queue_ctrl, "pfc_queue_ctrl");
7159 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7160 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7161 : : port_id, RTE_UINT16);
7162 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7163 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7164 : : rx, "rx");
7165 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7166 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7167 : : rx_pfc_mode, "on#off");
7168 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7169 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7170 : : tx_qid, RTE_UINT16);
7171 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7172 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7173 : : tx_tc, RTE_UINT8);
7174 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7175 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7176 : : tx, "tx");
7177 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7178 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7179 : : tx_pfc_mode, "on#off");
7180 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7181 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7182 : : rx_qid, RTE_UINT16);
7183 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7184 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7185 : : rx_tc, RTE_UINT8);
7186 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7187 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7188 : : pause_time, RTE_UINT16);
7189 : :
7190 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7191 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
7192 : : .data = NULL,
7193 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7194 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7195 : : "Configure the Ethernet queue priority flow control",
7196 : : .tokens = {
7197 : : (void *)&cmd_q_pfc_set_set,
7198 : : (void *)&cmd_q_pfc_set_flow_ctrl,
7199 : : (void *)&cmd_q_pfc_set_portid,
7200 : : (void *)&cmd_q_pfc_set_rx,
7201 : : (void *)&cmd_q_pfc_set_rx_mode,
7202 : : (void *)&cmd_q_pfc_set_tx_qid,
7203 : : (void *)&cmd_q_pfc_set_tx_tc,
7204 : : (void *)&cmd_q_pfc_set_tx,
7205 : : (void *)&cmd_q_pfc_set_tx_mode,
7206 : : (void *)&cmd_q_pfc_set_rx_qid,
7207 : : (void *)&cmd_q_pfc_set_rx_tc,
7208 : : (void *)&cmd_q_pfc_set_pause_time,
7209 : : NULL,
7210 : : },
7211 : : };
7212 : :
7213 : : /* *** RESET CONFIGURATION *** */
7214 : : struct cmd_reset_result {
7215 : : cmdline_fixed_string_t reset;
7216 : : cmdline_fixed_string_t def;
7217 : : };
7218 : :
7219 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
7220 : : struct cmdline *cl,
7221 : : __rte_unused void *data)
7222 : : {
7223 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7224 : 0 : set_def_fwd_config();
7225 : 0 : }
7226 : :
7227 : : static cmdline_parse_token_string_t cmd_reset_set =
7228 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7229 : : static cmdline_parse_token_string_t cmd_reset_def =
7230 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7231 : : "default");
7232 : :
7233 : : static cmdline_parse_inst_t cmd_reset = {
7234 : : .f = cmd_reset_parsed,
7235 : : .data = NULL,
7236 : : .help_str = "set default: Reset default forwarding configuration",
7237 : : .tokens = {
7238 : : (void *)&cmd_reset_set,
7239 : : (void *)&cmd_reset_def,
7240 : : NULL,
7241 : : },
7242 : : };
7243 : :
7244 : : /* *** START FORWARDING *** */
7245 : : struct cmd_start_result {
7246 : : cmdline_fixed_string_t start;
7247 : : };
7248 : :
7249 : : static cmdline_parse_token_string_t cmd_start_start =
7250 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7251 : :
7252 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
7253 : : __rte_unused struct cmdline *cl,
7254 : : __rte_unused void *data)
7255 : : {
7256 : 0 : start_packet_forwarding(0);
7257 : 0 : }
7258 : :
7259 : : static cmdline_parse_inst_t cmd_start = {
7260 : : .f = cmd_start_parsed,
7261 : : .data = NULL,
7262 : : .help_str = "start: Start packet forwarding",
7263 : : .tokens = {
7264 : : (void *)&cmd_start_start,
7265 : : NULL,
7266 : : },
7267 : : };
7268 : :
7269 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7270 : : struct cmd_start_tx_first_result {
7271 : : cmdline_fixed_string_t start;
7272 : : cmdline_fixed_string_t tx_first;
7273 : : };
7274 : :
7275 : : static void
7276 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7277 : : __rte_unused struct cmdline *cl,
7278 : : __rte_unused void *data)
7279 : : {
7280 : 0 : start_packet_forwarding(1);
7281 : 0 : }
7282 : :
7283 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
7284 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7285 : : "start");
7286 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7287 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7288 : : tx_first, "tx_first");
7289 : :
7290 : : static cmdline_parse_inst_t cmd_start_tx_first = {
7291 : : .f = cmd_start_tx_first_parsed,
7292 : : .data = NULL,
7293 : : .help_str = "start tx_first: Start packet forwarding, "
7294 : : "after sending 1 burst of packets",
7295 : : .tokens = {
7296 : : (void *)&cmd_start_tx_first_start,
7297 : : (void *)&cmd_start_tx_first_tx_first,
7298 : : NULL,
7299 : : },
7300 : : };
7301 : :
7302 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
7303 : : struct cmd_start_tx_first_n_result {
7304 : : cmdline_fixed_string_t start;
7305 : : cmdline_fixed_string_t tx_first;
7306 : : uint32_t tx_num;
7307 : : };
7308 : :
7309 : : static void
7310 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
7311 : : __rte_unused struct cmdline *cl,
7312 : : __rte_unused void *data)
7313 : : {
7314 : : struct cmd_start_tx_first_n_result *res = parsed_result;
7315 : :
7316 : 0 : start_packet_forwarding(res->tx_num);
7317 : 0 : }
7318 : :
7319 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7320 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7321 : : start, "start");
7322 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7323 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7324 : : tx_first, "tx_first");
7325 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7326 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7327 : : tx_num, RTE_UINT32);
7328 : :
7329 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
7330 : : .f = cmd_start_tx_first_n_parsed,
7331 : : .data = NULL,
7332 : : .help_str = "start tx_first <num>: "
7333 : : "packet forwarding, after sending <num> bursts of packets",
7334 : : .tokens = {
7335 : : (void *)&cmd_start_tx_first_n_start,
7336 : : (void *)&cmd_start_tx_first_n_tx_first,
7337 : : (void *)&cmd_start_tx_first_n_tx_num,
7338 : : NULL,
7339 : : },
7340 : : };
7341 : :
7342 : : /* *** SET LINK UP *** */
7343 : : struct cmd_set_link_up_result {
7344 : : cmdline_fixed_string_t set;
7345 : : cmdline_fixed_string_t link_up;
7346 : : cmdline_fixed_string_t port;
7347 : : portid_t port_id;
7348 : : };
7349 : :
7350 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
7351 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7352 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7353 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7354 : : "link-up");
7355 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
7356 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7357 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7358 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7359 : : RTE_UINT16);
7360 : :
7361 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7362 : : __rte_unused struct cmdline *cl,
7363 : : __rte_unused void *data)
7364 : : {
7365 : : struct cmd_set_link_up_result *res = parsed_result;
7366 : 0 : dev_set_link_up(res->port_id);
7367 : 0 : }
7368 : :
7369 : : static cmdline_parse_inst_t cmd_set_link_up = {
7370 : : .f = cmd_set_link_up_parsed,
7371 : : .data = NULL,
7372 : : .help_str = "set link-up port <port id>",
7373 : : .tokens = {
7374 : : (void *)&cmd_set_link_up_set,
7375 : : (void *)&cmd_set_link_up_link_up,
7376 : : (void *)&cmd_set_link_up_port,
7377 : : (void *)&cmd_set_link_up_port_id,
7378 : : NULL,
7379 : : },
7380 : : };
7381 : :
7382 : : /* *** SET LINK DOWN *** */
7383 : : struct cmd_set_link_down_result {
7384 : : cmdline_fixed_string_t set;
7385 : : cmdline_fixed_string_t link_down;
7386 : : cmdline_fixed_string_t port;
7387 : : portid_t port_id;
7388 : : };
7389 : :
7390 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
7391 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7392 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
7393 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7394 : : "link-down");
7395 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
7396 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7397 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
7398 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7399 : : RTE_UINT16);
7400 : :
7401 : 0 : static void cmd_set_link_down_parsed(
7402 : : __rte_unused void *parsed_result,
7403 : : __rte_unused struct cmdline *cl,
7404 : : __rte_unused void *data)
7405 : : {
7406 : : struct cmd_set_link_down_result *res = parsed_result;
7407 : 0 : dev_set_link_down(res->port_id);
7408 : 0 : }
7409 : :
7410 : : static cmdline_parse_inst_t cmd_set_link_down = {
7411 : : .f = cmd_set_link_down_parsed,
7412 : : .data = NULL,
7413 : : .help_str = "set link-down port <port id>",
7414 : : .tokens = {
7415 : : (void *)&cmd_set_link_down_set,
7416 : : (void *)&cmd_set_link_down_link_down,
7417 : : (void *)&cmd_set_link_down_port,
7418 : : (void *)&cmd_set_link_down_port_id,
7419 : : NULL,
7420 : : },
7421 : : };
7422 : :
7423 : : /* *** SHOW CFG *** */
7424 : : struct cmd_showcfg_result {
7425 : : cmdline_fixed_string_t show;
7426 : : cmdline_fixed_string_t cfg;
7427 : : cmdline_fixed_string_t what;
7428 : : };
7429 : :
7430 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
7431 : : __rte_unused struct cmdline *cl,
7432 : : __rte_unused void *data)
7433 : : {
7434 : : struct cmd_showcfg_result *res = parsed_result;
7435 : 0 : if (!strcmp(res->what, "rxtx"))
7436 : 0 : rxtx_config_display();
7437 : 0 : else if (!strcmp(res->what, "cores"))
7438 : 0 : fwd_lcores_config_display();
7439 : 0 : else if (!strcmp(res->what, "fwd"))
7440 : 0 : pkt_fwd_config_display(&cur_fwd_config);
7441 : 0 : else if (!strcmp(res->what, "rxoffs"))
7442 : 0 : show_rx_pkt_offsets();
7443 : 0 : else if (!strcmp(res->what, "rxpkts"))
7444 : 0 : show_rx_pkt_segments();
7445 : 0 : else if (!strcmp(res->what, "rxhdrs"))
7446 : 0 : show_rx_pkt_hdrs();
7447 : 0 : else if (!strcmp(res->what, "txpkts"))
7448 : 0 : show_tx_pkt_segments();
7449 : 0 : else if (!strcmp(res->what, "txtimes"))
7450 : 0 : show_tx_pkt_times();
7451 : 0 : else if (!strcmp(res->what, "dcbfwdtc"))
7452 : 0 : show_dcb_fwd_tc_config();
7453 : 0 : }
7454 : :
7455 : : static cmdline_parse_token_string_t cmd_showcfg_show =
7456 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7457 : : static cmdline_parse_token_string_t cmd_showcfg_port =
7458 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7459 : : static cmdline_parse_token_string_t cmd_showcfg_what =
7460 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7461 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes#dcbfwdtc");
7462 : :
7463 : : static cmdline_parse_inst_t cmd_showcfg = {
7464 : : .f = cmd_showcfg_parsed,
7465 : : .data = NULL,
7466 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes|dcbfwdtc",
7467 : : .tokens = {
7468 : : (void *)&cmd_showcfg_show,
7469 : : (void *)&cmd_showcfg_port,
7470 : : (void *)&cmd_showcfg_what,
7471 : : NULL,
7472 : : },
7473 : : };
7474 : :
7475 : : /* *** SHOW ALL PORT INFO *** */
7476 : : struct cmd_showportall_result {
7477 : : cmdline_fixed_string_t show;
7478 : : cmdline_fixed_string_t port;
7479 : : cmdline_fixed_string_t what;
7480 : : cmdline_fixed_string_t all;
7481 : : };
7482 : :
7483 : 0 : static void cmd_showportall_parsed(void *parsed_result,
7484 : : __rte_unused struct cmdline *cl,
7485 : : __rte_unused void *data)
7486 : : {
7487 : : portid_t i;
7488 : :
7489 : : struct cmd_showportall_result *res = parsed_result;
7490 : 0 : if (!strcmp(res->show, "clear")) {
7491 : 0 : if (!strcmp(res->what, "stats"))
7492 : 0 : RTE_ETH_FOREACH_DEV(i)
7493 : 0 : nic_stats_clear(i);
7494 : 0 : else if (!strcmp(res->what, "xstats"))
7495 : 0 : RTE_ETH_FOREACH_DEV(i)
7496 : 0 : nic_xstats_clear(i);
7497 : 0 : } else if (!strcmp(res->what, "info"))
7498 : 0 : RTE_ETH_FOREACH_DEV(i)
7499 : 0 : port_infos_display(i);
7500 : 0 : else if (!strcmp(res->what, "summary")) {
7501 : 0 : port_summary_header_display();
7502 : 0 : RTE_ETH_FOREACH_DEV(i)
7503 : 0 : port_summary_display(i);
7504 : : }
7505 : 0 : else if (!strcmp(res->what, "stats"))
7506 : 0 : RTE_ETH_FOREACH_DEV(i)
7507 : 0 : nic_stats_display(i);
7508 : 0 : else if (!strcmp(res->what, "xstats"))
7509 : 0 : RTE_ETH_FOREACH_DEV(i)
7510 : 0 : nic_xstats_display(i);
7511 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7512 : 0 : else if (!strcmp(res->what, "fdir"))
7513 : 0 : RTE_ETH_FOREACH_DEV(i)
7514 : 0 : fdir_get_infos(i);
7515 : : #endif
7516 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7517 : 0 : RTE_ETH_FOREACH_DEV(i)
7518 : 0 : port_dcb_info_display(i);
7519 : 0 : }
7520 : :
7521 : : static cmdline_parse_token_string_t cmd_showportall_show =
7522 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7523 : : "show#clear");
7524 : : static cmdline_parse_token_string_t cmd_showportall_port =
7525 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7526 : : static cmdline_parse_token_string_t cmd_showportall_what =
7527 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7528 : : "info#summary#stats#xstats#fdir#dcb_tc");
7529 : : static cmdline_parse_token_string_t cmd_showportall_all =
7530 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7531 : : static cmdline_parse_inst_t cmd_showportall = {
7532 : : .f = cmd_showportall_parsed,
7533 : : .data = NULL,
7534 : : .help_str = "show|clear port "
7535 : : "info|summary|stats|xstats|fdir|dcb_tc all",
7536 : : .tokens = {
7537 : : (void *)&cmd_showportall_show,
7538 : : (void *)&cmd_showportall_port,
7539 : : (void *)&cmd_showportall_what,
7540 : : (void *)&cmd_showportall_all,
7541 : : NULL,
7542 : : },
7543 : : };
7544 : :
7545 : : /* *** SHOW PORT INFO *** */
7546 : : struct cmd_showport_result {
7547 : : cmdline_fixed_string_t show;
7548 : : cmdline_fixed_string_t port;
7549 : : cmdline_fixed_string_t what;
7550 : : uint16_t portnum;
7551 : : };
7552 : :
7553 : 0 : static void cmd_showport_parsed(void *parsed_result,
7554 : : __rte_unused struct cmdline *cl,
7555 : : __rte_unused void *data)
7556 : : {
7557 : : struct cmd_showport_result *res = parsed_result;
7558 : 0 : if (!strcmp(res->show, "clear")) {
7559 : 0 : if (!strcmp(res->what, "stats"))
7560 : 0 : nic_stats_clear(res->portnum);
7561 : 0 : else if (!strcmp(res->what, "xstats"))
7562 : 0 : nic_xstats_clear(res->portnum);
7563 : 0 : } else if (!strcmp(res->what, "info"))
7564 : 0 : port_infos_display(res->portnum);
7565 : 0 : else if (!strcmp(res->what, "summary")) {
7566 : 0 : port_summary_header_display();
7567 : 0 : port_summary_display(res->portnum);
7568 : : }
7569 : 0 : else if (!strcmp(res->what, "stats"))
7570 : 0 : nic_stats_display(res->portnum);
7571 : 0 : else if (!strcmp(res->what, "xstats"))
7572 : 0 : nic_xstats_display(res->portnum);
7573 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7574 : 0 : else if (!strcmp(res->what, "fdir"))
7575 : 0 : fdir_get_infos(res->portnum);
7576 : : #endif
7577 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7578 : 0 : port_dcb_info_display(res->portnum);
7579 : 0 : }
7580 : :
7581 : : static cmdline_parse_token_string_t cmd_showport_show =
7582 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7583 : : "show#clear");
7584 : : static cmdline_parse_token_string_t cmd_showport_port =
7585 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7586 : : static cmdline_parse_token_string_t cmd_showport_what =
7587 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7588 : : "info#summary#stats#xstats#fdir#dcb_tc");
7589 : : static cmdline_parse_token_num_t cmd_showport_portnum =
7590 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7591 : :
7592 : : static cmdline_parse_inst_t cmd_showport = {
7593 : : .f = cmd_showport_parsed,
7594 : : .data = NULL,
7595 : : .help_str = "show|clear port "
7596 : : "info|summary|stats|xstats|fdir|dcb_tc "
7597 : : "<port_id>",
7598 : : .tokens = {
7599 : : (void *)&cmd_showport_show,
7600 : : (void *)&cmd_showport_port,
7601 : : (void *)&cmd_showport_what,
7602 : : (void *)&cmd_showport_portnum,
7603 : : NULL,
7604 : : },
7605 : : };
7606 : :
7607 : : /* *** show port representors information *** */
7608 : : struct cmd_representor_info_result {
7609 : : cmdline_fixed_string_t cmd_show;
7610 : : cmdline_fixed_string_t cmd_port;
7611 : : cmdline_fixed_string_t cmd_info;
7612 : : cmdline_fixed_string_t cmd_keyword;
7613 : : portid_t cmd_pid;
7614 : : };
7615 : :
7616 : : static void
7617 : 0 : cmd_representor_info_parsed(void *parsed_result,
7618 : : __rte_unused struct cmdline *cl,
7619 : : __rte_unused void *data)
7620 : : {
7621 : : struct cmd_representor_info_result *res = parsed_result;
7622 : : struct rte_eth_representor_info *info;
7623 : : struct rte_eth_representor_range *range;
7624 : : uint32_t range_diff;
7625 : : uint32_t i;
7626 : : int ret;
7627 : : int num;
7628 : :
7629 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7630 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7631 : 0 : return;
7632 : : }
7633 : :
7634 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7635 : 0 : if (ret < 0) {
7636 : 0 : fprintf(stderr,
7637 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7638 : 0 : res->cmd_pid, rte_strerror(-ret));
7639 : 0 : return;
7640 : : }
7641 : : num = ret;
7642 : :
7643 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7644 : 0 : if (info == NULL) {
7645 : 0 : fprintf(stderr,
7646 : : "Failed to allocate memory for representor info for port %hu\n",
7647 : 0 : res->cmd_pid);
7648 : 0 : return;
7649 : : }
7650 : 0 : info->nb_ranges_alloc = num;
7651 : :
7652 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7653 : 0 : if (ret < 0) {
7654 : 0 : fprintf(stderr,
7655 : : "Failed to get the representor info for port %hu: %s\n",
7656 : 0 : res->cmd_pid, rte_strerror(-ret));
7657 : 0 : free(info);
7658 : 0 : return;
7659 : : }
7660 : :
7661 : 0 : printf("Port controller: %hu\n", info->controller);
7662 : 0 : printf("Port PF: %hu\n", info->pf);
7663 : :
7664 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7665 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7666 : : range = &info->ranges[i];
7667 : 0 : range_diff = range->id_end - range->id_base;
7668 : :
7669 : 0 : printf("%u. ", i + 1);
7670 : 0 : printf("'%s' ", range->name);
7671 : 0 : if (range_diff > 0)
7672 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7673 : : else
7674 : 0 : printf("[%u]: ", range->id_base);
7675 : :
7676 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7677 : :
7678 : 0 : switch (range->type) {
7679 : : case RTE_ETH_REPRESENTOR_NONE:
7680 : : printf(", NONE\n");
7681 : : break;
7682 : 0 : case RTE_ETH_REPRESENTOR_VF:
7683 : 0 : if (range_diff > 0)
7684 : 0 : printf(", VF %d..%d\n", range->vf,
7685 : 0 : range->vf + range_diff);
7686 : : else
7687 : 0 : printf(", VF %d\n", range->vf);
7688 : : break;
7689 : 0 : case RTE_ETH_REPRESENTOR_SF:
7690 : 0 : printf(", SF %d\n", range->sf);
7691 : : break;
7692 : 0 : case RTE_ETH_REPRESENTOR_PF:
7693 : 0 : if (range_diff > 0)
7694 : 0 : printf("..%d\n", range->pf + range_diff);
7695 : : else
7696 : : printf("\n");
7697 : : break;
7698 : 0 : default:
7699 : : printf(", UNKNOWN TYPE %d\n", range->type);
7700 : : break;
7701 : : }
7702 : : }
7703 : :
7704 : 0 : free(info);
7705 : : }
7706 : :
7707 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7708 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7709 : : cmd_show, "show");
7710 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7711 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7712 : : cmd_port, "port");
7713 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7714 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7715 : : cmd_info, "info");
7716 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7717 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7718 : : cmd_pid, RTE_UINT16);
7719 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7720 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7721 : : cmd_keyword, "representor");
7722 : :
7723 : : static cmdline_parse_inst_t cmd_representor_info = {
7724 : : .f = cmd_representor_info_parsed,
7725 : : .data = NULL,
7726 : : .help_str = "show port info <port_id> representor",
7727 : : .tokens = {
7728 : : (void *)&cmd_representor_info_show,
7729 : : (void *)&cmd_representor_info_port,
7730 : : (void *)&cmd_representor_info_info,
7731 : : (void *)&cmd_representor_info_pid,
7732 : : (void *)&cmd_representor_info_keyword,
7733 : : NULL,
7734 : : },
7735 : : };
7736 : :
7737 : :
7738 : : /* *** SHOW DEVICE INFO *** */
7739 : : struct cmd_showdevice_result {
7740 : : cmdline_fixed_string_t show;
7741 : : cmdline_fixed_string_t device;
7742 : : cmdline_fixed_string_t what;
7743 : : cmdline_fixed_string_t identifier;
7744 : : };
7745 : :
7746 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7747 : : __rte_unused struct cmdline *cl,
7748 : : __rte_unused void *data)
7749 : : {
7750 : : struct cmd_showdevice_result *res = parsed_result;
7751 : 0 : if (!strcmp(res->what, "info")) {
7752 : 0 : if (!strcmp(res->identifier, "all"))
7753 : 0 : device_infos_display(NULL);
7754 : : else
7755 : 0 : device_infos_display(res->identifier);
7756 : : }
7757 : 0 : }
7758 : :
7759 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7760 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7761 : : "show");
7762 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7763 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7764 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7765 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7766 : : "info");
7767 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7768 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7769 : : identifier, NULL);
7770 : :
7771 : : static cmdline_parse_inst_t cmd_showdevice = {
7772 : : .f = cmd_showdevice_parsed,
7773 : : .data = NULL,
7774 : : .help_str = "show device info <identifier>|all",
7775 : : .tokens = {
7776 : : (void *)&cmd_showdevice_show,
7777 : : (void *)&cmd_showdevice_device,
7778 : : (void *)&cmd_showdevice_what,
7779 : : (void *)&cmd_showdevice_identifier,
7780 : : NULL,
7781 : : },
7782 : : };
7783 : :
7784 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7785 : : struct cmd_showeeprom_result {
7786 : : cmdline_fixed_string_t show;
7787 : : cmdline_fixed_string_t port;
7788 : : uint16_t portnum;
7789 : : cmdline_fixed_string_t type;
7790 : : };
7791 : :
7792 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7793 : : __rte_unused struct cmdline *cl,
7794 : : __rte_unused void *data)
7795 : : {
7796 : : struct cmd_showeeprom_result *res = parsed_result;
7797 : :
7798 : 0 : if (!strcmp(res->type, "eeprom"))
7799 : 0 : port_eeprom_display(res->portnum);
7800 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7801 : 0 : port_module_eeprom_display(res->portnum);
7802 : : else
7803 : 0 : fprintf(stderr, "Unknown argument\n");
7804 : 0 : }
7805 : :
7806 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7807 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7808 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7809 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7810 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7811 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7812 : : RTE_UINT16);
7813 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7814 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7815 : :
7816 : : static cmdline_parse_inst_t cmd_showeeprom = {
7817 : : .f = cmd_showeeprom_parsed,
7818 : : .data = NULL,
7819 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7820 : : .tokens = {
7821 : : (void *)&cmd_showeeprom_show,
7822 : : (void *)&cmd_showeeprom_port,
7823 : : (void *)&cmd_showeeprom_portnum,
7824 : : (void *)&cmd_showeeprom_type,
7825 : : NULL,
7826 : : },
7827 : : };
7828 : :
7829 : : /* *** SET PORT EEPROM *** */
7830 : : struct cmd_seteeprom_result {
7831 : : cmdline_fixed_string_t set;
7832 : : cmdline_fixed_string_t port;
7833 : : uint16_t portnum;
7834 : : cmdline_fixed_string_t eeprom;
7835 : : cmdline_fixed_string_t confirm_str;
7836 : : cmdline_fixed_string_t magic_str;
7837 : : uint32_t magic;
7838 : : cmdline_fixed_string_t value;
7839 : : cmdline_multi_string_t token_str;
7840 : : };
7841 : :
7842 : 0 : static void cmd_seteeprom_parsed(void *parsed_result,
7843 : : __rte_unused struct cmdline *cl,
7844 : : __rte_unused void *data)
7845 : : {
7846 : : struct cmd_seteeprom_result *res = parsed_result;
7847 : : uint32_t offset = 0;
7848 : : uint32_t length;
7849 : : uint8_t *value;
7850 : : char *token_str;
7851 : : char *token;
7852 : :
7853 : 0 : token_str = res->token_str;
7854 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7855 : :
7856 : : /* Parse Hex string to Byte data */
7857 : 0 : if (strlen(token) % 2 != 0) {
7858 : 0 : fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
7859 : : token);
7860 : 0 : return;
7861 : : }
7862 : :
7863 : 0 : length = strlen(token) / 2;
7864 : 0 : value = calloc(length, sizeof(uint8_t));
7865 : 0 : for (int count = 0; count < (int)(length); count++) {
7866 : 0 : if (sscanf(token, "%2hhx", &value[count]) != 1) {
7867 : 0 : fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
7868 : 0 : token - (count + 1));
7869 : 0 : goto out;
7870 : : }
7871 : 0 : token += 2;
7872 : : }
7873 : :
7874 : : /* Second token: offset string */
7875 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7876 : 0 : if (token != NULL) {
7877 : 0 : if (strcmp(token, "offset") == 0) {
7878 : : /* Third token: offset */
7879 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7880 : 0 : if (token == NULL) {
7881 : 0 : fprintf(stderr, "No offset specified\n");
7882 : 0 : goto out;
7883 : : }
7884 : :
7885 : : char *end;
7886 : 0 : offset = strtoul(token, &end, 10);
7887 : 0 : if (offset == 0 && strcmp(end, "") != 0) {
7888 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7889 : 0 : goto out;
7890 : : }
7891 : : } else {
7892 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7893 : 0 : goto out;
7894 : : }
7895 : : }
7896 : :
7897 : 0 : port_eeprom_set(res->portnum, res->magic, offset, length, value);
7898 : :
7899 : 0 : out:
7900 : 0 : free(value);
7901 : : }
7902 : :
7903 : : static cmdline_parse_token_string_t cmd_seteeprom_set =
7904 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
7905 : : static cmdline_parse_token_string_t cmd_seteeprom_port =
7906 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
7907 : : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
7908 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
7909 : : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
7910 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
7911 : : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
7912 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
7913 : : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
7914 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
7915 : : static cmdline_parse_token_num_t cmd_seteeprom_magic =
7916 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
7917 : : static cmdline_parse_token_string_t cmd_seteeprom_value =
7918 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
7919 : : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
7920 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
7921 : :
7922 : : static cmdline_parse_inst_t cmd_seteeprom = {
7923 : : .f = cmd_seteeprom_parsed,
7924 : : .data = NULL,
7925 : : .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
7926 : : "value <value> offset <offset>: Set eeprom value for port_id.\n"
7927 : : "Note:\n"
7928 : : "This is a high-risk command and its misuse may result in "
7929 : : "unexpected behaviour from the NIC.\n"
7930 : : "By inserting \"accept_risk\" into the command, the user is "
7931 : : "acknowledging and taking responsibility for this risk.",
7932 : : .tokens = {
7933 : : (void *)&cmd_seteeprom_set,
7934 : : (void *)&cmd_seteeprom_port,
7935 : : (void *)&cmd_seteeprom_portnum,
7936 : : (void *)&cmd_seteeprom_eeprom,
7937 : : (void *)&cmd_seteeprom_confirm_str,
7938 : : (void *)&cmd_seteeprom_magic_str,
7939 : : (void *)&cmd_seteeprom_magic,
7940 : : (void *)&cmd_seteeprom_value,
7941 : : (void *)&cmd_seteeprom_token_str,
7942 : : NULL,
7943 : : },
7944 : : };
7945 : :
7946 : : /* *** SHOW QUEUE INFO *** */
7947 : : struct cmd_showqueue_result {
7948 : : cmdline_fixed_string_t show;
7949 : : cmdline_fixed_string_t type;
7950 : : cmdline_fixed_string_t what;
7951 : : uint16_t portnum;
7952 : : uint16_t queuenum;
7953 : : };
7954 : :
7955 : : static void
7956 : 0 : cmd_showqueue_parsed(void *parsed_result,
7957 : : __rte_unused struct cmdline *cl,
7958 : : __rte_unused void *data)
7959 : : {
7960 : : struct cmd_showqueue_result *res = parsed_result;
7961 : :
7962 : 0 : if (!strcmp(res->type, "rxq"))
7963 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7964 : 0 : else if (!strcmp(res->type, "txq"))
7965 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7966 : 0 : }
7967 : :
7968 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7969 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7970 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7971 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7972 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7973 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7974 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7975 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7976 : : RTE_UINT16);
7977 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7978 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7979 : : RTE_UINT16);
7980 : :
7981 : : static cmdline_parse_inst_t cmd_showqueue = {
7982 : : .f = cmd_showqueue_parsed,
7983 : : .data = NULL,
7984 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7985 : : .tokens = {
7986 : : (void *)&cmd_showqueue_show,
7987 : : (void *)&cmd_showqueue_type,
7988 : : (void *)&cmd_showqueue_what,
7989 : : (void *)&cmd_showqueue_portnum,
7990 : : (void *)&cmd_showqueue_queuenum,
7991 : : NULL,
7992 : : },
7993 : : };
7994 : :
7995 : : /* show/clear fwd engine statistics */
7996 : : struct fwd_result {
7997 : : cmdline_fixed_string_t action;
7998 : : cmdline_fixed_string_t fwd;
7999 : : cmdline_fixed_string_t stats;
8000 : : cmdline_fixed_string_t all;
8001 : : };
8002 : :
8003 : : static cmdline_parse_token_string_t cmd_fwd_action =
8004 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8005 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
8006 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8007 : : static cmdline_parse_token_string_t cmd_fwd_stats =
8008 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8009 : : static cmdline_parse_token_string_t cmd_fwd_all =
8010 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8011 : :
8012 : : static void
8013 : 0 : cmd_showfwdall_parsed(void *parsed_result,
8014 : : __rte_unused struct cmdline *cl,
8015 : : __rte_unused void *data)
8016 : : {
8017 : : struct fwd_result *res = parsed_result;
8018 : :
8019 : 0 : if (!strcmp(res->action, "show"))
8020 : 0 : fwd_stats_display();
8021 : : else
8022 : 0 : fwd_stats_reset();
8023 : 0 : }
8024 : :
8025 : : static cmdline_parse_inst_t cmd_showfwdall = {
8026 : : .f = cmd_showfwdall_parsed,
8027 : : .data = NULL,
8028 : : .help_str = "show|clear fwd stats all",
8029 : : .tokens = {
8030 : : (void *)&cmd_fwd_action,
8031 : : (void *)&cmd_fwd_fwd,
8032 : : (void *)&cmd_fwd_stats,
8033 : : (void *)&cmd_fwd_all,
8034 : : NULL,
8035 : : },
8036 : : };
8037 : :
8038 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8039 : : struct cmd_read_rxd_txd_result {
8040 : : cmdline_fixed_string_t read;
8041 : : cmdline_fixed_string_t rxd_txd;
8042 : : portid_t port_id;
8043 : : uint16_t queue_id;
8044 : : uint16_t desc_id;
8045 : : };
8046 : :
8047 : : static void
8048 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
8049 : : __rte_unused struct cmdline *cl,
8050 : : __rte_unused void *data)
8051 : : {
8052 : : struct cmd_read_rxd_txd_result *res = parsed_result;
8053 : :
8054 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
8055 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8056 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
8057 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8058 : 0 : }
8059 : :
8060 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8061 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8062 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8063 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8064 : : "rxd#txd");
8065 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8066 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8067 : : RTE_UINT16);
8068 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8069 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8070 : : RTE_UINT16);
8071 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8072 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8073 : : RTE_UINT16);
8074 : :
8075 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
8076 : : .f = cmd_read_rxd_txd_parsed,
8077 : : .data = NULL,
8078 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8079 : : .tokens = {
8080 : : (void *)&cmd_read_rxd_txd_read,
8081 : : (void *)&cmd_read_rxd_txd_rxd_txd,
8082 : : (void *)&cmd_read_rxd_txd_port_id,
8083 : : (void *)&cmd_read_rxd_txd_queue_id,
8084 : : (void *)&cmd_read_rxd_txd_desc_id,
8085 : : NULL,
8086 : : },
8087 : : };
8088 : :
8089 : : /* *** QUIT *** */
8090 : : struct cmd_quit_result {
8091 : : cmdline_fixed_string_t quit;
8092 : : };
8093 : :
8094 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
8095 : : struct cmdline *cl,
8096 : : __rte_unused void *data)
8097 : : {
8098 : 0 : cmdline_quit(cl);
8099 : 0 : cl_quit = 1;
8100 : 0 : }
8101 : :
8102 : : static cmdline_parse_token_string_t cmd_quit_quit =
8103 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8104 : :
8105 : : static cmdline_parse_inst_t cmd_quit = {
8106 : : .f = cmd_quit_parsed,
8107 : : .data = NULL,
8108 : : .help_str = "quit: Exit application",
8109 : : .tokens = {
8110 : : (void *)&cmd_quit_quit,
8111 : : NULL,
8112 : : },
8113 : : };
8114 : :
8115 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8116 : : struct cmd_mac_addr_result {
8117 : : cmdline_fixed_string_t mac_addr_cmd;
8118 : : cmdline_fixed_string_t what;
8119 : : uint16_t port_num;
8120 : : struct rte_ether_addr address;
8121 : : };
8122 : :
8123 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
8124 : : __rte_unused struct cmdline *cl,
8125 : : __rte_unused void *data)
8126 : : {
8127 : : struct cmd_mac_addr_result *res = parsed_result;
8128 : : int ret;
8129 : :
8130 : 0 : if (strcmp(res->what, "add") == 0)
8131 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8132 : 0 : else if (strcmp(res->what, "set") == 0)
8133 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8134 : : &res->address);
8135 : : else
8136 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8137 : :
8138 : : /* check the return value and print it if is < 0 */
8139 : 0 : if(ret < 0)
8140 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8141 : :
8142 : 0 : }
8143 : :
8144 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
8145 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8146 : : "mac_addr");
8147 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
8148 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8149 : : "add#remove#set");
8150 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
8151 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8152 : : RTE_UINT16);
8153 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8154 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8155 : :
8156 : : static cmdline_parse_inst_t cmd_mac_addr = {
8157 : : .f = cmd_mac_addr_parsed,
8158 : : .data = (void *)0,
8159 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8160 : : "Add/Remove/Set MAC address on port_id",
8161 : : .tokens = {
8162 : : (void *)&cmd_mac_addr_cmd,
8163 : : (void *)&cmd_mac_addr_what,
8164 : : (void *)&cmd_mac_addr_portnum,
8165 : : (void *)&cmd_mac_addr_addr,
8166 : : NULL,
8167 : : },
8168 : : };
8169 : :
8170 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8171 : : struct cmd_eth_peer_result {
8172 : : cmdline_fixed_string_t set;
8173 : : cmdline_fixed_string_t eth_peer;
8174 : : portid_t port_id;
8175 : : cmdline_fixed_string_t peer_addr;
8176 : : };
8177 : :
8178 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
8179 : : __rte_unused struct cmdline *cl,
8180 : : __rte_unused void *data)
8181 : : {
8182 : : struct cmd_eth_peer_result *res = parsed_result;
8183 : :
8184 : 0 : if (test_done == 0) {
8185 : 0 : fprintf(stderr, "Please stop forwarding first\n");
8186 : 0 : return;
8187 : : }
8188 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
8189 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
8190 : 0 : fwd_config_setup();
8191 : : }
8192 : : }
8193 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
8194 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8195 : : static cmdline_parse_token_string_t cmd_eth_peer =
8196 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8197 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
8198 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8199 : : RTE_UINT16);
8200 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
8201 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8202 : :
8203 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8204 : : .f = cmd_set_eth_peer_parsed,
8205 : : .data = NULL,
8206 : : .help_str = "set eth-peer <port_id> <peer_mac>",
8207 : : .tokens = {
8208 : : (void *)&cmd_eth_peer_set,
8209 : : (void *)&cmd_eth_peer,
8210 : : (void *)&cmd_eth_peer_port_id,
8211 : : (void *)&cmd_eth_peer_addr,
8212 : : NULL,
8213 : : },
8214 : : };
8215 : :
8216 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8217 : : struct cmd_set_xstats_hide_zero_result {
8218 : : cmdline_fixed_string_t keyword;
8219 : : cmdline_fixed_string_t name;
8220 : : cmdline_fixed_string_t on_off;
8221 : : };
8222 : :
8223 : : static void
8224 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8225 : : __rte_unused struct cmdline *cl,
8226 : : __rte_unused void *data)
8227 : : {
8228 : : struct cmd_set_xstats_hide_zero_result *res;
8229 : : uint16_t on_off = 0;
8230 : :
8231 : : res = parsed_result;
8232 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8233 : 0 : set_xstats_hide_zero(on_off);
8234 : 0 : }
8235 : :
8236 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8237 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8238 : : keyword, "set");
8239 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8240 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8241 : : name, "xstats-hide-zero");
8242 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8243 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8244 : : on_off, "on#off");
8245 : :
8246 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8247 : : .f = cmd_set_xstats_hide_zero_parsed,
8248 : : .data = NULL,
8249 : : .help_str = "set xstats-hide-zero on|off",
8250 : : .tokens = {
8251 : : (void *)&cmd_set_xstats_hide_zero_keyword,
8252 : : (void *)&cmd_set_xstats_hide_zero_name,
8253 : : (void *)&cmd_set_xstats_hide_zero_on_off,
8254 : : NULL,
8255 : : },
8256 : : };
8257 : :
8258 : : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
8259 : : struct cmd_set_xstats_show_state_result {
8260 : : cmdline_fixed_string_t keyword;
8261 : : cmdline_fixed_string_t name;
8262 : : uint8_t on_off;
8263 : : };
8264 : : static void
8265 : 0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
8266 : : __rte_unused struct cmdline *cl,
8267 : : __rte_unused void *data)
8268 : : {
8269 : : struct cmd_set_xstats_show_state_result *res = parsed_result;
8270 : 0 : set_xstats_show_state(res->on_off);
8271 : 0 : }
8272 : :
8273 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
8274 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8275 : : keyword, "set");
8276 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
8277 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8278 : : name, "xstats-show-state");
8279 : : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
8280 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
8281 : : on_off);
8282 : :
8283 : : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
8284 : : .f = cmd_set_xstats_show_state_parsed,
8285 : : .data = NULL,
8286 : : .help_str = "set xstats-show-state on|off",
8287 : : .tokens = {
8288 : : (void *)&cmd_set_xstats_show_state_keyword,
8289 : : (void *)&cmd_set_xstats_show_state_name,
8290 : : (void *)&cmd_set_xstats_show_state_on_off,
8291 : : NULL,
8292 : : },
8293 : : };
8294 : :
8295 : : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
8296 : : struct cmd_set_xstats_hide_disabled_result {
8297 : : cmdline_fixed_string_t keyword;
8298 : : cmdline_fixed_string_t name;
8299 : : uint8_t on_off;
8300 : : };
8301 : :
8302 : : static void
8303 : 0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
8304 : : __rte_unused struct cmdline *cl,
8305 : : __rte_unused void *data)
8306 : : {
8307 : : struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
8308 : 0 : set_xstats_hide_disabled(res->on_off);
8309 : 0 : }
8310 : :
8311 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
8312 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8313 : : keyword, "set");
8314 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
8315 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8316 : : name, "xstats-hide-disabled");
8317 : : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
8318 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8319 : : on_off);
8320 : :
8321 : : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
8322 : : .f = cmd_set_xstats_hide_disabled_parsed,
8323 : : .data = NULL,
8324 : : .help_str = "set xstats-hide-disabled on|off",
8325 : : .tokens = {
8326 : : (void *)&cmd_set_xstats_hide_disabled_keyword,
8327 : : (void *)&cmd_set_xstats_hide_disabled_name,
8328 : : (void *)&cmd_set_xstats_hide_disabled_on_off,
8329 : : NULL,
8330 : : },
8331 : : };
8332 : :
8333 : : /* *** enable/disable counter by name *** */
8334 : : struct cmd_operate_set_counter_result {
8335 : : cmdline_fixed_string_t port;
8336 : : portid_t port_id;
8337 : : cmdline_fixed_string_t what;
8338 : : cmdline_multi_string_t counter_name;
8339 : : };
8340 : :
8341 : : static void
8342 : 0 : cmd_operate_set_counter_parsed(void *parsed_result,
8343 : : __rte_unused struct cmdline *cl,
8344 : : __rte_unused void *data)
8345 : : {
8346 : : struct cmd_operate_set_counter_result *res = parsed_result;
8347 : 0 : uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
8348 : :
8349 : 0 : if ((strcmp(res->port, "port") == 0))
8350 : 0 : nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
8351 : 0 : }
8352 : :
8353 : : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
8354 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8355 : : port, "port");
8356 : : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
8357 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
8358 : : port_id, RTE_UINT16);
8359 : : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
8360 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8361 : : what, "enable#disable");
8362 : : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
8363 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8364 : : counter_name, TOKEN_STRING_MULTI);
8365 : :
8366 : : static cmdline_parse_inst_t cmd_operate_set_counter = {
8367 : : .f = cmd_operate_set_counter_parsed,
8368 : : .data = NULL,
8369 : : .help_str = "port (port_id) enable|disable <counter_name>",
8370 : : .tokens = {
8371 : : (void *)&cmd_operate_set_counter_port,
8372 : : (void *)&cmd_operate_set_counter_port_id,
8373 : : (void *)&cmd_operate_set_counter_what,
8374 : : (void *)&cmd_operate_set_counter_name,
8375 : : NULL,
8376 : : },
8377 : : };
8378 : :
8379 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8380 : : struct cmd_set_record_core_cycles_result {
8381 : : cmdline_fixed_string_t keyword;
8382 : : cmdline_fixed_string_t name;
8383 : : cmdline_fixed_string_t on_off;
8384 : : };
8385 : :
8386 : : static void
8387 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
8388 : : __rte_unused struct cmdline *cl,
8389 : : __rte_unused void *data)
8390 : : {
8391 : : struct cmd_set_record_core_cycles_result *res;
8392 : : uint16_t on_off = 0;
8393 : :
8394 : : res = parsed_result;
8395 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8396 : 0 : set_record_core_cycles(on_off);
8397 : 0 : }
8398 : :
8399 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8400 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8401 : : keyword, "set");
8402 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8403 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8404 : : name, "record-core-cycles");
8405 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8406 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8407 : : on_off, "on#off");
8408 : :
8409 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
8410 : : .f = cmd_set_record_core_cycles_parsed,
8411 : : .data = NULL,
8412 : : .help_str = "set record-core-cycles on|off",
8413 : : .tokens = {
8414 : : (void *)&cmd_set_record_core_cycles_keyword,
8415 : : (void *)&cmd_set_record_core_cycles_name,
8416 : : (void *)&cmd_set_record_core_cycles_on_off,
8417 : : NULL,
8418 : : },
8419 : : };
8420 : :
8421 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8422 : : struct cmd_set_record_burst_stats_result {
8423 : : cmdline_fixed_string_t keyword;
8424 : : cmdline_fixed_string_t name;
8425 : : cmdline_fixed_string_t on_off;
8426 : : };
8427 : :
8428 : : static void
8429 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
8430 : : __rte_unused struct cmdline *cl,
8431 : : __rte_unused void *data)
8432 : : {
8433 : : struct cmd_set_record_burst_stats_result *res;
8434 : : uint16_t on_off = 0;
8435 : :
8436 : : res = parsed_result;
8437 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8438 : 0 : set_record_burst_stats(on_off);
8439 : 0 : }
8440 : :
8441 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8442 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8443 : : keyword, "set");
8444 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8445 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8446 : : name, "record-burst-stats");
8447 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8448 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8449 : : on_off, "on#off");
8450 : :
8451 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
8452 : : .f = cmd_set_record_burst_stats_parsed,
8453 : : .data = NULL,
8454 : : .help_str = "set record-burst-stats on|off",
8455 : : .tokens = {
8456 : : (void *)&cmd_set_record_burst_stats_keyword,
8457 : : (void *)&cmd_set_record_burst_stats_name,
8458 : : (void *)&cmd_set_record_burst_stats_on_off,
8459 : : NULL,
8460 : : },
8461 : : };
8462 : :
8463 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
8464 : : struct cmd_set_uc_hash_table {
8465 : : cmdline_fixed_string_t set;
8466 : : cmdline_fixed_string_t port;
8467 : : portid_t port_id;
8468 : : cmdline_fixed_string_t what;
8469 : : struct rte_ether_addr address;
8470 : : cmdline_fixed_string_t mode;
8471 : : };
8472 : :
8473 : : static void
8474 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
8475 : : __rte_unused struct cmdline *cl,
8476 : : __rte_unused void *data)
8477 : : {
8478 : : int ret=0;
8479 : : struct cmd_set_uc_hash_table *res = parsed_result;
8480 : :
8481 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8482 : :
8483 : 0 : if (strcmp(res->what, "uta") == 0)
8484 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8485 : : &res->address,(uint8_t)is_on);
8486 : 0 : if (ret < 0)
8487 : 0 : fprintf(stderr,
8488 : : "bad unicast hash table parameter, return code = %d\n",
8489 : : ret);
8490 : :
8491 : 0 : }
8492 : :
8493 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
8494 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8495 : : set, "set");
8496 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
8497 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8498 : : port, "port");
8499 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8500 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8501 : : port_id, RTE_UINT16);
8502 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
8503 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8504 : : what, "uta");
8505 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8506 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8507 : : address);
8508 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8509 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8510 : : mode, "on#off");
8511 : :
8512 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8513 : : .f = cmd_set_uc_hash_parsed,
8514 : : .data = NULL,
8515 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
8516 : : .tokens = {
8517 : : (void *)&cmd_set_uc_hash_set,
8518 : : (void *)&cmd_set_uc_hash_port,
8519 : : (void *)&cmd_set_uc_hash_portid,
8520 : : (void *)&cmd_set_uc_hash_what,
8521 : : (void *)&cmd_set_uc_hash_mac,
8522 : : (void *)&cmd_set_uc_hash_mode,
8523 : : NULL,
8524 : : },
8525 : : };
8526 : :
8527 : : struct cmd_set_uc_all_hash_table {
8528 : : cmdline_fixed_string_t set;
8529 : : cmdline_fixed_string_t port;
8530 : : portid_t port_id;
8531 : : cmdline_fixed_string_t what;
8532 : : cmdline_fixed_string_t value;
8533 : : cmdline_fixed_string_t mode;
8534 : : };
8535 : :
8536 : : static void
8537 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
8538 : : __rte_unused struct cmdline *cl,
8539 : : __rte_unused void *data)
8540 : : {
8541 : : int ret=0;
8542 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
8543 : :
8544 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8545 : :
8546 : 0 : if ((strcmp(res->what, "uta") == 0) &&
8547 : 0 : (strcmp(res->value, "all") == 0))
8548 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8549 : 0 : if (ret < 0)
8550 : 0 : fprintf(stderr,
8551 : : "bad unicast hash table parameter, return code = %d\n",
8552 : : ret);
8553 : 0 : }
8554 : :
8555 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8556 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8557 : : set, "set");
8558 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8559 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8560 : : port, "port");
8561 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8562 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8563 : : port_id, RTE_UINT16);
8564 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8565 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8566 : : what, "uta");
8567 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8568 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8569 : : value,"all");
8570 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8571 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8572 : : mode, "on#off");
8573 : :
8574 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8575 : : .f = cmd_set_uc_all_hash_parsed,
8576 : : .data = NULL,
8577 : : .help_str = "set port <port_id> uta all on|off",
8578 : : .tokens = {
8579 : : (void *)&cmd_set_uc_all_hash_set,
8580 : : (void *)&cmd_set_uc_all_hash_port,
8581 : : (void *)&cmd_set_uc_all_hash_portid,
8582 : : (void *)&cmd_set_uc_all_hash_what,
8583 : : (void *)&cmd_set_uc_all_hash_value,
8584 : : (void *)&cmd_set_uc_all_hash_mode,
8585 : : NULL,
8586 : : },
8587 : : };
8588 : :
8589 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8590 : : struct cmd_set_vf_traffic {
8591 : : cmdline_fixed_string_t set;
8592 : : cmdline_fixed_string_t port;
8593 : : portid_t port_id;
8594 : : cmdline_fixed_string_t vf;
8595 : : uint8_t vf_id;
8596 : : cmdline_fixed_string_t what;
8597 : : cmdline_fixed_string_t mode;
8598 : : };
8599 : :
8600 : : static void
8601 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
8602 : : __rte_unused struct cmdline *cl,
8603 : : __rte_unused void *data)
8604 : : {
8605 : : struct cmd_set_vf_traffic *res = parsed_result;
8606 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8607 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8608 : :
8609 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8610 : 0 : }
8611 : :
8612 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
8613 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8614 : : set, "set");
8615 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
8616 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8617 : : port, "port");
8618 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8619 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8620 : : port_id, RTE_UINT16);
8621 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8622 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8623 : : vf, "vf");
8624 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8625 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8626 : : vf_id, RTE_UINT8);
8627 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
8628 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8629 : : what, "tx#rx");
8630 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8631 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8632 : : mode, "on#off");
8633 : :
8634 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
8635 : : .f = cmd_set_vf_traffic_parsed,
8636 : : .data = NULL,
8637 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8638 : : .tokens = {
8639 : : (void *)&cmd_setvf_traffic_set,
8640 : : (void *)&cmd_setvf_traffic_port,
8641 : : (void *)&cmd_setvf_traffic_portid,
8642 : : (void *)&cmd_setvf_traffic_vf,
8643 : : (void *)&cmd_setvf_traffic_vfid,
8644 : : (void *)&cmd_setvf_traffic_what,
8645 : : (void *)&cmd_setvf_traffic_mode,
8646 : : NULL,
8647 : : },
8648 : : };
8649 : :
8650 : : /* *** CONFIGURE VF RECEIVE MODE *** */
8651 : : struct cmd_set_vf_rxmode {
8652 : : cmdline_fixed_string_t set;
8653 : : cmdline_fixed_string_t port;
8654 : : portid_t port_id;
8655 : : cmdline_fixed_string_t vf;
8656 : : uint8_t vf_id;
8657 : : cmdline_fixed_string_t what;
8658 : : cmdline_fixed_string_t mode;
8659 : : cmdline_fixed_string_t on;
8660 : : };
8661 : :
8662 : : static void
8663 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
8664 : : __rte_unused struct cmdline *cl,
8665 : : __rte_unused void *data)
8666 : : {
8667 : : int ret = -ENOTSUP;
8668 : : uint16_t vf_rxmode = 0;
8669 : : struct cmd_set_vf_rxmode *res = parsed_result;
8670 : :
8671 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8672 : 0 : if (!strcmp(res->what,"rxmode")) {
8673 : 0 : if (!strcmp(res->mode, "AUPE"))
8674 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
8675 : 0 : else if (!strcmp(res->mode, "ROPE"))
8676 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
8677 : 0 : else if (!strcmp(res->mode, "BAM"))
8678 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
8679 : 0 : else if (!strncmp(res->mode, "MPE",3))
8680 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
8681 : : }
8682 : :
8683 : : RTE_SET_USED(is_on);
8684 : : RTE_SET_USED(vf_rxmode);
8685 : :
8686 : : #ifdef RTE_NET_IXGBE
8687 : : if (ret == -ENOTSUP)
8688 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8689 : : vf_rxmode, (uint8_t)is_on);
8690 : : #endif
8691 : : #ifdef RTE_NET_BNXT
8692 : 0 : if (ret == -ENOTSUP)
8693 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8694 : : vf_rxmode, (uint8_t)is_on);
8695 : : #endif
8696 : 0 : if (ret < 0)
8697 : 0 : fprintf(stderr,
8698 : : "bad VF receive mode parameter, return code = %d\n",
8699 : : ret);
8700 : 0 : }
8701 : :
8702 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8703 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8704 : : set, "set");
8705 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8706 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8707 : : port, "port");
8708 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8709 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8710 : : port_id, RTE_UINT16);
8711 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8712 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8713 : : vf, "vf");
8714 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8715 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8716 : : vf_id, RTE_UINT8);
8717 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8718 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8719 : : what, "rxmode");
8720 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8721 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8722 : : mode, "AUPE#ROPE#BAM#MPE");
8723 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8724 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8725 : : on, "on#off");
8726 : :
8727 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
8728 : : .f = cmd_set_vf_rxmode_parsed,
8729 : : .data = NULL,
8730 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
8731 : : "AUPE|ROPE|BAM|MPE on|off",
8732 : : .tokens = {
8733 : : (void *)&cmd_set_vf_rxmode_set,
8734 : : (void *)&cmd_set_vf_rxmode_port,
8735 : : (void *)&cmd_set_vf_rxmode_portid,
8736 : : (void *)&cmd_set_vf_rxmode_vf,
8737 : : (void *)&cmd_set_vf_rxmode_vfid,
8738 : : (void *)&cmd_set_vf_rxmode_what,
8739 : : (void *)&cmd_set_vf_rxmode_mode,
8740 : : (void *)&cmd_set_vf_rxmode_on,
8741 : : NULL,
8742 : : },
8743 : : };
8744 : :
8745 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8746 : : struct cmd_vf_mac_addr_result {
8747 : : cmdline_fixed_string_t mac_addr_cmd;
8748 : : cmdline_fixed_string_t what;
8749 : : cmdline_fixed_string_t port;
8750 : : uint16_t port_num;
8751 : : cmdline_fixed_string_t vf;
8752 : : uint8_t vf_num;
8753 : : struct rte_ether_addr address;
8754 : : };
8755 : :
8756 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
8757 : : __rte_unused struct cmdline *cl,
8758 : : __rte_unused void *data)
8759 : : {
8760 : : struct cmd_vf_mac_addr_result *res = parsed_result;
8761 : : int ret = -ENOTSUP;
8762 : :
8763 : 0 : if (strcmp(res->what, "add") != 0)
8764 : : return;
8765 : :
8766 : : #ifdef RTE_NET_I40E
8767 : : if (ret == -ENOTSUP)
8768 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8769 : : &res->address);
8770 : : #endif
8771 : : #ifdef RTE_NET_BNXT
8772 : 0 : if (ret == -ENOTSUP)
8773 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8774 : 0 : res->vf_num);
8775 : : #endif
8776 : :
8777 : 0 : if(ret < 0)
8778 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8779 : :
8780 : : }
8781 : :
8782 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8783 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8784 : : mac_addr_cmd,"mac_addr");
8785 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8786 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8787 : : what,"add");
8788 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8789 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8790 : : port,"port");
8791 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8792 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8793 : : port_num, RTE_UINT16);
8794 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8795 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8796 : : vf,"vf");
8797 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8798 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8799 : : vf_num, RTE_UINT8);
8800 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8801 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8802 : : address);
8803 : :
8804 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8805 : : .f = cmd_vf_mac_addr_parsed,
8806 : : .data = (void *)0,
8807 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8808 : : "Add MAC address filtering for a VF on port_id",
8809 : : .tokens = {
8810 : : (void *)&cmd_vf_mac_addr_cmd,
8811 : : (void *)&cmd_vf_mac_addr_what,
8812 : : (void *)&cmd_vf_mac_addr_port,
8813 : : (void *)&cmd_vf_mac_addr_portnum,
8814 : : (void *)&cmd_vf_mac_addr_vf,
8815 : : (void *)&cmd_vf_mac_addr_vfnum,
8816 : : (void *)&cmd_vf_mac_addr_addr,
8817 : : NULL,
8818 : : },
8819 : : };
8820 : :
8821 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8822 : : struct cmd_vf_rx_vlan_filter {
8823 : : cmdline_fixed_string_t rx_vlan;
8824 : : cmdline_fixed_string_t what;
8825 : : uint16_t vlan_id;
8826 : : cmdline_fixed_string_t port;
8827 : : portid_t port_id;
8828 : : cmdline_fixed_string_t vf;
8829 : : uint64_t vf_mask;
8830 : : };
8831 : :
8832 : : static void
8833 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8834 : : __rte_unused struct cmdline *cl,
8835 : : __rte_unused void *data)
8836 : : {
8837 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8838 : : int ret = -ENOTSUP;
8839 : :
8840 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8841 : :
8842 : : #ifdef RTE_NET_IXGBE
8843 : : if (ret == -ENOTSUP)
8844 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8845 : 0 : res->vlan_id, res->vf_mask, is_add);
8846 : : #endif
8847 : : #ifdef RTE_NET_I40E
8848 : 0 : if (ret == -ENOTSUP)
8849 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8850 : 0 : res->vlan_id, res->vf_mask, is_add);
8851 : : #endif
8852 : : #ifdef RTE_NET_BNXT
8853 : 0 : if (ret == -ENOTSUP)
8854 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8855 : 0 : res->vlan_id, res->vf_mask, is_add);
8856 : : #endif
8857 : :
8858 : 0 : switch (ret) {
8859 : : case 0:
8860 : : break;
8861 : 0 : case -EINVAL:
8862 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8863 : 0 : res->vlan_id, res->vf_mask);
8864 : : break;
8865 : 0 : case -ENODEV:
8866 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8867 : : break;
8868 : 0 : case -ENOTSUP:
8869 : 0 : fprintf(stderr, "function not implemented or supported\n");
8870 : : break;
8871 : 0 : default:
8872 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8873 : : }
8874 : 0 : }
8875 : :
8876 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8877 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8878 : : rx_vlan, "rx_vlan");
8879 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8880 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8881 : : what, "add#rm");
8882 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8883 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8884 : : vlan_id, RTE_UINT16);
8885 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8886 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8887 : : port, "port");
8888 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8889 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8890 : : port_id, RTE_UINT16);
8891 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8892 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8893 : : vf, "vf");
8894 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8895 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8896 : : vf_mask, RTE_UINT64);
8897 : :
8898 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8899 : : .f = cmd_vf_rx_vlan_filter_parsed,
8900 : : .data = NULL,
8901 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8902 : : "(vf_mask = hexadecimal VF mask)",
8903 : : .tokens = {
8904 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8905 : : (void *)&cmd_vf_rx_vlan_filter_what,
8906 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8907 : : (void *)&cmd_vf_rx_vlan_filter_port,
8908 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8909 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8910 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8911 : : NULL,
8912 : : },
8913 : : };
8914 : :
8915 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8916 : : struct cmd_queue_rate_limit_result {
8917 : : cmdline_fixed_string_t set;
8918 : : cmdline_fixed_string_t port;
8919 : : uint16_t port_num;
8920 : : cmdline_fixed_string_t queue;
8921 : : uint8_t queue_num;
8922 : : cmdline_fixed_string_t rate;
8923 : : uint32_t rate_num;
8924 : : };
8925 : :
8926 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8927 : : __rte_unused struct cmdline *cl,
8928 : : __rte_unused void *data)
8929 : : {
8930 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8931 : : int ret = 0;
8932 : :
8933 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8934 : 0 : && (strcmp(res->queue, "queue") == 0)
8935 : 0 : && (strcmp(res->rate, "rate") == 0))
8936 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8937 : : res->rate_num);
8938 : 0 : if (ret < 0)
8939 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8940 : : strerror(-ret));
8941 : :
8942 : 0 : }
8943 : :
8944 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8945 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8946 : : set, "set");
8947 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8948 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8949 : : port, "port");
8950 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8951 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8952 : : port_num, RTE_UINT16);
8953 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8954 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8955 : : queue, "queue");
8956 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8957 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8958 : : queue_num, RTE_UINT8);
8959 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8960 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8961 : : rate, "rate");
8962 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8963 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8964 : : rate_num, RTE_UINT32);
8965 : :
8966 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8967 : : .f = cmd_queue_rate_limit_parsed,
8968 : : .data = (void *)0,
8969 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8970 : : "Set rate limit for a queue on port_id",
8971 : : .tokens = {
8972 : : (void *)&cmd_queue_rate_limit_set,
8973 : : (void *)&cmd_queue_rate_limit_port,
8974 : : (void *)&cmd_queue_rate_limit_portnum,
8975 : : (void *)&cmd_queue_rate_limit_queue,
8976 : : (void *)&cmd_queue_rate_limit_queuenum,
8977 : : (void *)&cmd_queue_rate_limit_rate,
8978 : : (void *)&cmd_queue_rate_limit_ratenum,
8979 : : NULL,
8980 : : },
8981 : : };
8982 : :
8983 : : /* *** SHOW RATE LIMIT FOR A QUEUE OF A PORT *** */
8984 : : struct cmd_show_queue_rate_limit_result {
8985 : : cmdline_fixed_string_t show;
8986 : : cmdline_fixed_string_t port;
8987 : : uint16_t port_num;
8988 : : cmdline_fixed_string_t queue;
8989 : : uint16_t queue_num;
8990 : : cmdline_fixed_string_t rate;
8991 : : };
8992 : :
8993 : 0 : static void cmd_show_queue_rate_limit_parsed(void *parsed_result,
8994 : : __rte_unused struct cmdline *cl,
8995 : : __rte_unused void *data)
8996 : : {
8997 : : struct cmd_show_queue_rate_limit_result *res = parsed_result;
8998 : 0 : uint32_t tx_rate = 0;
8999 : : int ret;
9000 : :
9001 : 0 : ret = rte_eth_get_queue_rate_limit(res->port_num, res->queue_num,
9002 : : &tx_rate);
9003 : 0 : if (ret) {
9004 : 0 : fprintf(stderr, "Get queue rate limit failed: %s\n",
9005 : : rte_strerror(-ret));
9006 : 0 : return;
9007 : : }
9008 : 0 : if (tx_rate)
9009 : 0 : printf("Port %u Queue %u rate limit: %u Mbps\n",
9010 : 0 : res->port_num, res->queue_num, tx_rate);
9011 : : else
9012 : 0 : printf("Port %u Queue %u rate limit: disabled\n",
9013 : 0 : res->port_num, res->queue_num);
9014 : : }
9015 : :
9016 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_show =
9017 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9018 : : show, "show");
9019 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_port =
9020 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9021 : : port, "port");
9022 : : static cmdline_parse_token_num_t cmd_show_queue_rate_limit_portnum =
9023 : : TOKEN_NUM_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9024 : : port_num, RTE_UINT16);
9025 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_queue =
9026 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9027 : : queue, "queue");
9028 : : static cmdline_parse_token_num_t cmd_show_queue_rate_limit_queuenum =
9029 : : TOKEN_NUM_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9030 : : queue_num, RTE_UINT16);
9031 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_rate =
9032 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9033 : : rate, "rate");
9034 : :
9035 : : static cmdline_parse_inst_t cmd_show_queue_rate_limit = {
9036 : : .f = cmd_show_queue_rate_limit_parsed,
9037 : : .data = NULL,
9038 : : .help_str = "show port <port_id> queue <queue_id> rate: "
9039 : : "Show rate limit for a queue on port_id",
9040 : : .tokens = {
9041 : : (void *)&cmd_show_queue_rate_limit_show,
9042 : : (void *)&cmd_show_queue_rate_limit_port,
9043 : : (void *)&cmd_show_queue_rate_limit_portnum,
9044 : : (void *)&cmd_show_queue_rate_limit_queue,
9045 : : (void *)&cmd_show_queue_rate_limit_queuenum,
9046 : : (void *)&cmd_show_queue_rate_limit_rate,
9047 : : NULL,
9048 : : },
9049 : : };
9050 : :
9051 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9052 : : struct cmd_vf_rate_limit_result {
9053 : : cmdline_fixed_string_t set;
9054 : : cmdline_fixed_string_t port;
9055 : : uint16_t port_num;
9056 : : cmdline_fixed_string_t vf;
9057 : : uint8_t vf_num;
9058 : : cmdline_fixed_string_t rate;
9059 : : uint32_t rate_num;
9060 : : cmdline_fixed_string_t q_msk;
9061 : : uint64_t q_msk_val;
9062 : : };
9063 : :
9064 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
9065 : : __rte_unused struct cmdline *cl,
9066 : : __rte_unused void *data)
9067 : : {
9068 : : struct cmd_vf_rate_limit_result *res = parsed_result;
9069 : : int ret = 0;
9070 : :
9071 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9072 : 0 : && (strcmp(res->vf, "vf") == 0)
9073 : 0 : && (strcmp(res->rate, "rate") == 0)
9074 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
9075 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
9076 : : res->rate_num, res->q_msk_val);
9077 : 0 : if (ret < 0)
9078 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9079 : : strerror(-ret));
9080 : :
9081 : 0 : }
9082 : :
9083 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9084 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9085 : : set, "set");
9086 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9087 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9088 : : port, "port");
9089 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9090 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9091 : : port_num, RTE_UINT16);
9092 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9093 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9094 : : vf, "vf");
9095 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9096 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9097 : : vf_num, RTE_UINT8);
9098 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9099 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9100 : : rate, "rate");
9101 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9102 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9103 : : rate_num, RTE_UINT32);
9104 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9105 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9106 : : q_msk, "queue_mask");
9107 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9108 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9109 : : q_msk_val, RTE_UINT64);
9110 : :
9111 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
9112 : : .f = cmd_vf_rate_limit_parsed,
9113 : : .data = (void *)0,
9114 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9115 : : "queue_mask <queue_mask_value>: "
9116 : : "Set rate limit for queues of VF on port_id",
9117 : : .tokens = {
9118 : : (void *)&cmd_vf_rate_limit_set,
9119 : : (void *)&cmd_vf_rate_limit_port,
9120 : : (void *)&cmd_vf_rate_limit_portnum,
9121 : : (void *)&cmd_vf_rate_limit_vf,
9122 : : (void *)&cmd_vf_rate_limit_vfnum,
9123 : : (void *)&cmd_vf_rate_limit_rate,
9124 : : (void *)&cmd_vf_rate_limit_ratenum,
9125 : : (void *)&cmd_vf_rate_limit_q_msk,
9126 : : (void *)&cmd_vf_rate_limit_q_msk_val,
9127 : : NULL,
9128 : : },
9129 : : };
9130 : :
9131 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
9132 : : struct cmd_tunnel_udp_config {
9133 : : cmdline_fixed_string_t rx_vxlan_port;
9134 : : cmdline_fixed_string_t what;
9135 : : uint16_t udp_port;
9136 : : portid_t port_id;
9137 : : };
9138 : :
9139 : : static void
9140 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
9141 : : __rte_unused struct cmdline *cl,
9142 : : __rte_unused void *data)
9143 : : {
9144 : : struct cmd_tunnel_udp_config *res = parsed_result;
9145 : : struct rte_eth_udp_tunnel tunnel_udp;
9146 : : int ret;
9147 : :
9148 : 0 : tunnel_udp.udp_port = res->udp_port;
9149 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9150 : :
9151 : 0 : if (!strcmp(res->what, "add"))
9152 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9153 : : &tunnel_udp);
9154 : : else
9155 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9156 : : &tunnel_udp);
9157 : :
9158 : 0 : if (ret < 0)
9159 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
9160 : : strerror(-ret));
9161 : 0 : }
9162 : :
9163 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9164 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9165 : : rx_vxlan_port, "rx_vxlan_port");
9166 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9167 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9168 : : what, "add#rm");
9169 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9170 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9171 : : udp_port, RTE_UINT16);
9172 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9173 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9174 : : port_id, RTE_UINT16);
9175 : :
9176 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
9177 : : .f = cmd_tunnel_udp_config_parsed,
9178 : : .data = (void *)0,
9179 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9180 : : "Add/Remove a tunneling UDP port filter",
9181 : : .tokens = {
9182 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9183 : : (void *)&cmd_tunnel_udp_config_what,
9184 : : (void *)&cmd_tunnel_udp_config_udp_port,
9185 : : (void *)&cmd_tunnel_udp_config_port_id,
9186 : : NULL,
9187 : : },
9188 : : };
9189 : :
9190 : : struct cmd_config_tunnel_udp_port {
9191 : : cmdline_fixed_string_t port;
9192 : : cmdline_fixed_string_t config;
9193 : : portid_t port_id;
9194 : : cmdline_fixed_string_t udp_tunnel_port;
9195 : : cmdline_fixed_string_t action;
9196 : : cmdline_fixed_string_t tunnel_type;
9197 : : uint16_t udp_port;
9198 : : };
9199 : :
9200 : : static void
9201 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9202 : : __rte_unused struct cmdline *cl,
9203 : : __rte_unused void *data)
9204 : : {
9205 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
9206 : : struct rte_eth_udp_tunnel tunnel_udp;
9207 : : int ret = 0;
9208 : :
9209 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9210 : 0 : return;
9211 : :
9212 : 0 : tunnel_udp.udp_port = res->udp_port;
9213 : :
9214 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
9215 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9216 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
9217 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9218 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9219 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9220 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
9221 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9222 : : } else {
9223 : 0 : fprintf(stderr, "Invalid tunnel type\n");
9224 : 0 : return;
9225 : : }
9226 : :
9227 : 0 : if (!strcmp(res->action, "add"))
9228 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9229 : : &tunnel_udp);
9230 : : else
9231 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9232 : : &tunnel_udp);
9233 : :
9234 : 0 : if (ret < 0)
9235 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
9236 : : strerror(-ret));
9237 : : }
9238 : :
9239 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9240 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9241 : : "port");
9242 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9243 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9244 : : "config");
9245 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9246 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9247 : : RTE_UINT16);
9248 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9249 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9250 : : udp_tunnel_port,
9251 : : "udp_tunnel_port");
9252 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9253 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9254 : : "add#rm");
9255 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9256 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9257 : : "vxlan#geneve#vxlan-gpe#ecpri");
9258 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9259 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9260 : : RTE_UINT16);
9261 : :
9262 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9263 : : .f = cmd_cfg_tunnel_udp_port_parsed,
9264 : : .data = NULL,
9265 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9266 : : "geneve|vxlan-gpe|ecpri <udp_port>",
9267 : : .tokens = {
9268 : : (void *)&cmd_config_tunnel_udp_port_port,
9269 : : (void *)&cmd_config_tunnel_udp_port_config,
9270 : : (void *)&cmd_config_tunnel_udp_port_port_id,
9271 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9272 : : (void *)&cmd_config_tunnel_udp_port_action,
9273 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9274 : : (void *)&cmd_config_tunnel_udp_port_value,
9275 : : NULL,
9276 : : },
9277 : : };
9278 : :
9279 : : /* ******************************************************************************** */
9280 : :
9281 : : struct cmd_dump_simple_result {
9282 : : cmdline_fixed_string_t dump;
9283 : : cmdline_fixed_string_t obj;
9284 : : cmdline_fixed_string_t name;
9285 : : };
9286 : : static cmdline_parse_token_string_t cmd_dump_simple_dump =
9287 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, dump, "dump");
9288 : : static cmdline_parse_token_string_t cmd_dump_simple_obj =
9289 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9290 : : "physmem#"
9291 : : "socket_mem#"
9292 : : "memzone#"
9293 : : "struct_sizes#"
9294 : : "ring#"
9295 : : "mempool#"
9296 : : "devargs#"
9297 : : "lcores#"
9298 : : "trace#"
9299 : : "log_types"
9300 : : );
9301 : : static cmdline_parse_token_string_t cmd_dump_named_obj =
9302 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9303 : : "ring#"
9304 : : "mempool#"
9305 : : );
9306 : : static cmdline_parse_token_string_t cmd_dump_named_name =
9307 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, name, NULL);
9308 : :
9309 : : static void
9310 : 0 : dump_struct_sizes(void)
9311 : : {
9312 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9313 : : DUMP_SIZE(struct rte_mbuf);
9314 : : DUMP_SIZE(struct rte_mempool);
9315 : : DUMP_SIZE(struct rte_ring);
9316 : : #undef DUMP_SIZE
9317 : 0 : }
9318 : :
9319 : : /* Dump the socket memory statistics on console */
9320 : : static void
9321 : 0 : dump_socket_mem(FILE *f)
9322 : : {
9323 : : struct rte_malloc_socket_stats socket_stats;
9324 : : unsigned int i;
9325 : : size_t total = 0;
9326 : : size_t alloc = 0;
9327 : : size_t free = 0;
9328 : : unsigned int n_alloc = 0;
9329 : : unsigned int n_free = 0;
9330 : : static size_t last_allocs;
9331 : : static size_t last_total;
9332 : :
9333 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9334 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9335 : 0 : !socket_stats.heap_totalsz_bytes)
9336 : 0 : continue;
9337 : 0 : total += socket_stats.heap_totalsz_bytes;
9338 : 0 : alloc += socket_stats.heap_allocsz_bytes;
9339 : 0 : free += socket_stats.heap_freesz_bytes;
9340 : 0 : n_alloc += socket_stats.alloc_count;
9341 : 0 : n_free += socket_stats.free_count;
9342 : 0 : fprintf(f,
9343 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9344 : : i,
9345 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9346 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9347 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
9348 : 0 : (double)socket_stats.heap_totalsz_bytes,
9349 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9350 : : socket_stats.alloc_count,
9351 : : socket_stats.free_count);
9352 : : }
9353 : 0 : fprintf(f,
9354 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9355 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9356 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
9357 : 0 : (double)free / (1024 * 1024),
9358 : : n_alloc, n_free);
9359 : 0 : if (last_allocs)
9360 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9361 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
9362 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
9363 : 0 : last_allocs = alloc;
9364 : 0 : last_total = total;
9365 : 0 : }
9366 : :
9367 : 0 : static void cmd_dump_simple_parsed(void *parsed_result,
9368 : : struct cmdline *cl,
9369 : : __rte_unused void *data)
9370 : : {
9371 : : struct cmd_dump_simple_result *res = parsed_result;
9372 : :
9373 : 0 : if (strcmp(res->obj, "physmem") == 0)
9374 : 0 : rte_dump_physmem_layout(stdout);
9375 : 0 : else if (strcmp(res->obj, "socket_mem") == 0)
9376 : 0 : dump_socket_mem(stdout);
9377 : 0 : else if (strcmp(res->obj, "memzone") == 0)
9378 : 0 : rte_memzone_dump(stdout);
9379 : 0 : else if (strcmp(res->obj, "struct_sizes") == 0)
9380 : 0 : dump_struct_sizes();
9381 : 0 : else if (strcmp(res->obj, "ring") == 0) {
9382 : 0 : if (strcmp(res->name, "") == 0) {
9383 : 0 : rte_ring_list_dump(stdout);
9384 : : } else {
9385 : : struct rte_ring *r;
9386 : 0 : r = rte_ring_lookup(res->name);
9387 : 0 : if (r == NULL) {
9388 : 0 : cmdline_printf(cl, "Cannot find ring\n");
9389 : 0 : return;
9390 : : }
9391 : 0 : rte_ring_dump(stdout, r);
9392 : : }
9393 : 0 : } else if (strcmp(res->obj, "mempool") == 0) {
9394 : 0 : if (strcmp(res->name, "") == 0) {
9395 : 0 : rte_mempool_list_dump(stdout);
9396 : : } else {
9397 : : struct rte_mempool *mp;
9398 : 0 : mp = rte_mempool_lookup(res->name);
9399 : 0 : if (mp == NULL) {
9400 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
9401 : 0 : return;
9402 : : }
9403 : 0 : rte_mempool_dump(stdout, mp);
9404 : : }
9405 : 0 : } else if (strcmp(res->obj, "devargs") == 0)
9406 : 0 : rte_devargs_dump(stdout);
9407 : 0 : else if (strcmp(res->obj, "lcores") == 0)
9408 : 0 : rte_lcore_dump(stdout);
9409 : 0 : else if (strcmp(res->obj, "trace") == 0)
9410 : : #ifdef RTE_EXEC_ENV_WINDOWS
9411 : : cmdline_printf(cl, "trace is not supported on Windows\n");
9412 : : #else
9413 : 0 : rte_trace_save();
9414 : : #endif
9415 : 0 : else if (strcmp(res->obj, "log_types") == 0)
9416 : 0 : rte_log_dump(stdout);
9417 : : }
9418 : :
9419 : : static cmdline_parse_inst_t cmd_dump_simple = {
9420 : : .f = cmd_dump_simple_parsed,
9421 : : .help_str = "Dump objects",
9422 : : .tokens = {
9423 : : (void *)&cmd_dump_simple_dump,
9424 : : (void *)&cmd_dump_simple_obj,
9425 : : NULL,
9426 : : },
9427 : : };
9428 : : static cmdline_parse_inst_t cmd_dump_named = {
9429 : : .f = cmd_dump_simple_parsed,
9430 : : .help_str = "dump ring|mempool <name>: Dump one ring/mempool",
9431 : : .tokens = {
9432 : : (void *)&cmd_dump_simple_dump,
9433 : : (void *)&cmd_dump_named_obj,
9434 : : (void *)&cmd_dump_named_name,
9435 : : NULL,
9436 : : },
9437 : : };
9438 : :
9439 : : struct cmd_dump_mbuf_history_result {
9440 : : cmdline_fixed_string_t dump;
9441 : : cmdline_fixed_string_t mbuf;
9442 : : cmdline_fixed_string_t history;
9443 : : cmdline_fixed_string_t obj;
9444 : : cmdline_fixed_string_t name;
9445 : : cmdline_fixed_string_t addr;
9446 : : cmdline_fixed_string_t file;
9447 : : };
9448 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_dump =
9449 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, dump, "dump");
9450 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_mbuf =
9451 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, mbuf, "mbuf");
9452 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_history =
9453 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, history, "history");
9454 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_obj =
9455 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, NULL);
9456 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_pool =
9457 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, "pool");
9458 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_name =
9459 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, name, NULL);
9460 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_file =
9461 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, file, NULL);
9462 : :
9463 : 0 : static void cmd_dump_mbuf_history_parsed(void *parsed_result,
9464 : : struct cmdline *cl,
9465 : : __rte_unused void *data)
9466 : : {
9467 : : struct cmd_dump_mbuf_history_result *res = parsed_result;
9468 : 0 : FILE *out = stdout;
9469 : :
9470 : 0 : if (strcmp(res->file, "") != 0) {
9471 : 0 : out = fopen(res->file, "w");
9472 : 0 : if (out == NULL) {
9473 : 0 : cmdline_printf(cl,
9474 : : "Failed to open file '%s'\n",
9475 : : res->file);
9476 : 0 : return;
9477 : : }
9478 : : }
9479 : :
9480 : 0 : if (strcmp(res->obj, "all") == 0) {
9481 : 0 : rte_mbuf_history_dump_all(out);
9482 : 0 : if (out != stdout)
9483 : 0 : cmdline_printf(cl,
9484 : : "Dump written in '%s'\n",
9485 : 0 : res->file);
9486 : 0 : } else if (strcmp(res->obj, "pool") == 0) {
9487 : 0 : struct rte_mempool *mp = rte_mempool_lookup(res->name);
9488 : 0 : if (mp == NULL) {
9489 : 0 : cmdline_printf(cl,
9490 : : "Failed to find mempool '%s'\n",
9491 : : res->name);
9492 : 0 : goto out_close;
9493 : : }
9494 : 0 : rte_mbuf_history_dump_mempool(out, mp);
9495 : 0 : if (out != stdout)
9496 : 0 : cmdline_printf(cl,
9497 : : "Dump for mempool '%s' written in '%s'\n",
9498 : 0 : res->name, res->file);
9499 : : } else {
9500 : : struct rte_mbuf *mbuf;
9501 : : uintptr_t mbuf_addr;
9502 : 0 : if (sscanf(res->obj, "0x%" SCNxPTR, &mbuf_addr) != 1) {
9503 : 0 : cmdline_printf(cl,
9504 : : "Invalid mbuf pointer format. Use 0x<address>\n");
9505 : 0 : goto out_close;
9506 : : }
9507 : 0 : mbuf = (struct rte_mbuf *)mbuf_addr;
9508 : 0 : rte_mbuf_history_dump(out, mbuf);
9509 : 0 : if (out != stdout)
9510 : 0 : cmdline_printf(cl,
9511 : : "Dump for mbuf '%p' written in '%s'\n",
9512 : 0 : mbuf, res->file);
9513 : : }
9514 : :
9515 : 0 : out_close:
9516 : 0 : if (out != stdout)
9517 : 0 : fclose(out);
9518 : : }
9519 : :
9520 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_stdout = {
9521 : : .f = cmd_dump_mbuf_history_parsed,
9522 : : .help_str = "dump mbuf history all|<address>",
9523 : : .tokens = {
9524 : : (void *)&cmd_dump_mbuf_history_dump,
9525 : : (void *)&cmd_dump_mbuf_history_mbuf,
9526 : : (void *)&cmd_dump_mbuf_history_history,
9527 : : (void *)&cmd_dump_mbuf_history_obj,
9528 : : NULL,
9529 : : },
9530 : : };
9531 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_to_file = {
9532 : : .f = cmd_dump_mbuf_history_parsed,
9533 : : .help_str = "dump mbuf history all|<address> [file]",
9534 : : .tokens = {
9535 : : (void *)&cmd_dump_mbuf_history_dump,
9536 : : (void *)&cmd_dump_mbuf_history_mbuf,
9537 : : (void *)&cmd_dump_mbuf_history_history,
9538 : : (void *)&cmd_dump_mbuf_history_obj,
9539 : : (void *)&cmd_dump_mbuf_history_file,
9540 : : NULL,
9541 : : },
9542 : : };
9543 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_stdout = {
9544 : : .f = cmd_dump_mbuf_history_parsed,
9545 : : .help_str = "dump mbuf pool history <name>",
9546 : : .tokens = {
9547 : : (void *)&cmd_dump_mbuf_history_dump,
9548 : : (void *)&cmd_dump_mbuf_history_mbuf,
9549 : : (void *)&cmd_dump_mbuf_history_pool,
9550 : : (void *)&cmd_dump_mbuf_history_history,
9551 : : (void *)&cmd_dump_mbuf_history_name,
9552 : : NULL,
9553 : : },
9554 : : };
9555 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_to_file = {
9556 : : .f = cmd_dump_mbuf_history_parsed,
9557 : : .help_str = "dump mbuf pool history <name> [file]",
9558 : : .tokens = {
9559 : : (void *)&cmd_dump_mbuf_history_dump,
9560 : : (void *)&cmd_dump_mbuf_history_mbuf,
9561 : : (void *)&cmd_dump_mbuf_history_pool,
9562 : : (void *)&cmd_dump_mbuf_history_history,
9563 : : (void *)&cmd_dump_mbuf_history_name,
9564 : : (void *)&cmd_dump_mbuf_history_file,
9565 : : NULL,
9566 : : },
9567 : : };
9568 : :
9569 : : /* *** Filters Control *** */
9570 : :
9571 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9572 : : do { \
9573 : : if ((ip_addr).family == AF_INET) \
9574 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
9575 : : else { \
9576 : : fprintf(stderr, "invalid parameter.\n"); \
9577 : : return; \
9578 : : } \
9579 : : } while (0)
9580 : :
9581 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9582 : : do { \
9583 : : if ((ip_addr).family == AF_INET6) \
9584 : : ip = ip_addr.addr.ipv6; \
9585 : : else { \
9586 : : fprintf(stderr, "invalid parameter.\n"); \
9587 : : return; \
9588 : : } \
9589 : : } while (0)
9590 : :
9591 : : /* Generic flow interface command. */
9592 : : extern cmdline_parse_inst_t cmd_flow;
9593 : :
9594 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9595 : : struct cmd_mcast_addr_result {
9596 : : cmdline_fixed_string_t mcast_addr_cmd;
9597 : : cmdline_fixed_string_t what;
9598 : : uint16_t port_num;
9599 : : struct rte_ether_addr mc_addr;
9600 : : };
9601 : :
9602 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
9603 : : __rte_unused struct cmdline *cl,
9604 : : __rte_unused void *data)
9605 : : {
9606 : : struct cmd_mcast_addr_result *res = parsed_result;
9607 : :
9608 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
9609 : 0 : fprintf(stderr,
9610 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
9611 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
9612 : 0 : return;
9613 : : }
9614 : 0 : if (strcmp(res->what, "add") == 0)
9615 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
9616 : : else
9617 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
9618 : : }
9619 : :
9620 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9621 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9622 : : mcast_addr_cmd, "mcast_addr");
9623 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
9624 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9625 : : "add#remove");
9626 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9627 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9628 : : RTE_UINT16);
9629 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9630 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9631 : :
9632 : : static cmdline_parse_inst_t cmd_mcast_addr = {
9633 : : .f = cmd_mcast_addr_parsed,
9634 : : .data = (void *)0,
9635 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
9636 : : "Add/Remove multicast MAC address on port_id",
9637 : : .tokens = {
9638 : : (void *)&cmd_mcast_addr_cmd,
9639 : : (void *)&cmd_mcast_addr_what,
9640 : : (void *)&cmd_mcast_addr_portnum,
9641 : : (void *)&cmd_mcast_addr_addr,
9642 : : NULL,
9643 : : },
9644 : : };
9645 : :
9646 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
9647 : : struct cmd_mcast_addr_flush_result {
9648 : : cmdline_fixed_string_t mcast_addr_cmd;
9649 : : cmdline_fixed_string_t what;
9650 : : uint16_t port_num;
9651 : : };
9652 : :
9653 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
9654 : : __rte_unused struct cmdline *cl,
9655 : : __rte_unused void *data)
9656 : : {
9657 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
9658 : :
9659 : 0 : mcast_addr_flush(res->port_num);
9660 : 0 : }
9661 : :
9662 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
9663 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9664 : : mcast_addr_cmd, "mcast_addr");
9665 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
9666 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9667 : : "flush");
9668 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
9669 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9670 : : RTE_UINT16);
9671 : :
9672 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
9673 : : .f = cmd_mcast_addr_flush_parsed,
9674 : : .data = (void *)0,
9675 : : .help_str = "mcast_addr flush <port_id> : "
9676 : : "flush all multicast MAC addresses on port_id",
9677 : : .tokens = {
9678 : : (void *)&cmd_mcast_addr_flush_cmd,
9679 : : (void *)&cmd_mcast_addr_flush_what,
9680 : : (void *)&cmd_mcast_addr_flush_portnum,
9681 : : NULL,
9682 : : },
9683 : : };
9684 : :
9685 : : /* vf vlan anti spoof configuration */
9686 : :
9687 : : /* Common result structure for vf vlan anti spoof */
9688 : : struct cmd_vf_vlan_anti_spoof_result {
9689 : : cmdline_fixed_string_t set;
9690 : : cmdline_fixed_string_t vf;
9691 : : cmdline_fixed_string_t vlan;
9692 : : cmdline_fixed_string_t antispoof;
9693 : : portid_t port_id;
9694 : : uint32_t vf_id;
9695 : : cmdline_fixed_string_t on_off;
9696 : : };
9697 : :
9698 : : /* Common CLI fields for vf vlan anti spoof enable disable */
9699 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
9700 : : TOKEN_STRING_INITIALIZER
9701 : : (struct cmd_vf_vlan_anti_spoof_result,
9702 : : set, "set");
9703 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
9704 : : TOKEN_STRING_INITIALIZER
9705 : : (struct cmd_vf_vlan_anti_spoof_result,
9706 : : vf, "vf");
9707 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
9708 : : TOKEN_STRING_INITIALIZER
9709 : : (struct cmd_vf_vlan_anti_spoof_result,
9710 : : vlan, "vlan");
9711 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
9712 : : TOKEN_STRING_INITIALIZER
9713 : : (struct cmd_vf_vlan_anti_spoof_result,
9714 : : antispoof, "antispoof");
9715 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
9716 : : TOKEN_NUM_INITIALIZER
9717 : : (struct cmd_vf_vlan_anti_spoof_result,
9718 : : port_id, RTE_UINT16);
9719 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
9720 : : TOKEN_NUM_INITIALIZER
9721 : : (struct cmd_vf_vlan_anti_spoof_result,
9722 : : vf_id, RTE_UINT32);
9723 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
9724 : : TOKEN_STRING_INITIALIZER
9725 : : (struct cmd_vf_vlan_anti_spoof_result,
9726 : : on_off, "on#off");
9727 : :
9728 : : static void
9729 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
9730 : : void *parsed_result,
9731 : : __rte_unused struct cmdline *cl,
9732 : : __rte_unused void *data)
9733 : : {
9734 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
9735 : : int ret = -ENOTSUP;
9736 : :
9737 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9738 : :
9739 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9740 : : return;
9741 : :
9742 : : #ifdef RTE_NET_IXGBE
9743 : : if (ret == -ENOTSUP)
9744 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
9745 : 0 : res->vf_id, is_on);
9746 : : #endif
9747 : : #ifdef RTE_NET_I40E
9748 : 0 : if (ret == -ENOTSUP)
9749 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
9750 : 0 : res->vf_id, is_on);
9751 : : #endif
9752 : : #ifdef RTE_NET_BNXT
9753 : 0 : if (ret == -ENOTSUP)
9754 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
9755 : 0 : res->vf_id, is_on);
9756 : : #endif
9757 : :
9758 : 0 : switch (ret) {
9759 : : case 0:
9760 : : break;
9761 : 0 : case -EINVAL:
9762 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
9763 : : break;
9764 : 0 : case -ENODEV:
9765 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9766 : : break;
9767 : 0 : case -ENOTSUP:
9768 : 0 : fprintf(stderr, "function not implemented\n");
9769 : : break;
9770 : 0 : default:
9771 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9772 : : }
9773 : : }
9774 : :
9775 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
9776 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
9777 : : .data = NULL,
9778 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
9779 : : .tokens = {
9780 : : (void *)&cmd_vf_vlan_anti_spoof_set,
9781 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
9782 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
9783 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
9784 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
9785 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
9786 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
9787 : : NULL,
9788 : : },
9789 : : };
9790 : :
9791 : : /* vf mac anti spoof configuration */
9792 : :
9793 : : /* Common result structure for vf mac anti spoof */
9794 : : struct cmd_vf_mac_anti_spoof_result {
9795 : : cmdline_fixed_string_t set;
9796 : : cmdline_fixed_string_t vf;
9797 : : cmdline_fixed_string_t mac;
9798 : : cmdline_fixed_string_t antispoof;
9799 : : portid_t port_id;
9800 : : uint32_t vf_id;
9801 : : cmdline_fixed_string_t on_off;
9802 : : };
9803 : :
9804 : : /* Common CLI fields for vf mac anti spoof enable disable */
9805 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
9806 : : TOKEN_STRING_INITIALIZER
9807 : : (struct cmd_vf_mac_anti_spoof_result,
9808 : : set, "set");
9809 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
9810 : : TOKEN_STRING_INITIALIZER
9811 : : (struct cmd_vf_mac_anti_spoof_result,
9812 : : vf, "vf");
9813 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
9814 : : TOKEN_STRING_INITIALIZER
9815 : : (struct cmd_vf_mac_anti_spoof_result,
9816 : : mac, "mac");
9817 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
9818 : : TOKEN_STRING_INITIALIZER
9819 : : (struct cmd_vf_mac_anti_spoof_result,
9820 : : antispoof, "antispoof");
9821 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
9822 : : TOKEN_NUM_INITIALIZER
9823 : : (struct cmd_vf_mac_anti_spoof_result,
9824 : : port_id, RTE_UINT16);
9825 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
9826 : : TOKEN_NUM_INITIALIZER
9827 : : (struct cmd_vf_mac_anti_spoof_result,
9828 : : vf_id, RTE_UINT32);
9829 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
9830 : : TOKEN_STRING_INITIALIZER
9831 : : (struct cmd_vf_mac_anti_spoof_result,
9832 : : on_off, "on#off");
9833 : :
9834 : : static void
9835 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
9836 : : void *parsed_result,
9837 : : __rte_unused struct cmdline *cl,
9838 : : __rte_unused void *data)
9839 : : {
9840 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
9841 : : int ret = -ENOTSUP;
9842 : :
9843 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9844 : :
9845 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9846 : : return;
9847 : :
9848 : : #ifdef RTE_NET_IXGBE
9849 : : if (ret == -ENOTSUP)
9850 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
9851 : 0 : res->vf_id, is_on);
9852 : : #endif
9853 : : #ifdef RTE_NET_I40E
9854 : 0 : if (ret == -ENOTSUP)
9855 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
9856 : 0 : res->vf_id, is_on);
9857 : : #endif
9858 : : #ifdef RTE_NET_BNXT
9859 : 0 : if (ret == -ENOTSUP)
9860 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
9861 : 0 : res->vf_id, is_on);
9862 : : #endif
9863 : :
9864 : 0 : switch (ret) {
9865 : : case 0:
9866 : : break;
9867 : 0 : case -EINVAL:
9868 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9869 : : res->vf_id, is_on);
9870 : : break;
9871 : 0 : case -ENODEV:
9872 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9873 : : break;
9874 : 0 : case -ENOTSUP:
9875 : 0 : fprintf(stderr, "function not implemented\n");
9876 : : break;
9877 : 0 : default:
9878 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9879 : : }
9880 : : }
9881 : :
9882 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
9883 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
9884 : : .data = NULL,
9885 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
9886 : : .tokens = {
9887 : : (void *)&cmd_vf_mac_anti_spoof_set,
9888 : : (void *)&cmd_vf_mac_anti_spoof_vf,
9889 : : (void *)&cmd_vf_mac_anti_spoof_mac,
9890 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
9891 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
9892 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
9893 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
9894 : : NULL,
9895 : : },
9896 : : };
9897 : :
9898 : : /* vf vlan strip queue configuration */
9899 : :
9900 : : /* Common result structure for vf mac anti spoof */
9901 : : struct cmd_vf_vlan_stripq_result {
9902 : : cmdline_fixed_string_t set;
9903 : : cmdline_fixed_string_t vf;
9904 : : cmdline_fixed_string_t vlan;
9905 : : cmdline_fixed_string_t stripq;
9906 : : portid_t port_id;
9907 : : uint16_t vf_id;
9908 : : cmdline_fixed_string_t on_off;
9909 : : };
9910 : :
9911 : : /* Common CLI fields for vf vlan strip enable disable */
9912 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
9913 : : TOKEN_STRING_INITIALIZER
9914 : : (struct cmd_vf_vlan_stripq_result,
9915 : : set, "set");
9916 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
9917 : : TOKEN_STRING_INITIALIZER
9918 : : (struct cmd_vf_vlan_stripq_result,
9919 : : vf, "vf");
9920 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
9921 : : TOKEN_STRING_INITIALIZER
9922 : : (struct cmd_vf_vlan_stripq_result,
9923 : : vlan, "vlan");
9924 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
9925 : : TOKEN_STRING_INITIALIZER
9926 : : (struct cmd_vf_vlan_stripq_result,
9927 : : stripq, "stripq");
9928 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
9929 : : TOKEN_NUM_INITIALIZER
9930 : : (struct cmd_vf_vlan_stripq_result,
9931 : : port_id, RTE_UINT16);
9932 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
9933 : : TOKEN_NUM_INITIALIZER
9934 : : (struct cmd_vf_vlan_stripq_result,
9935 : : vf_id, RTE_UINT16);
9936 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
9937 : : TOKEN_STRING_INITIALIZER
9938 : : (struct cmd_vf_vlan_stripq_result,
9939 : : on_off, "on#off");
9940 : :
9941 : : static void
9942 : 0 : cmd_set_vf_vlan_stripq_parsed(
9943 : : void *parsed_result,
9944 : : __rte_unused struct cmdline *cl,
9945 : : __rte_unused void *data)
9946 : : {
9947 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
9948 : : int ret = -ENOTSUP;
9949 : :
9950 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9951 : :
9952 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9953 : : return;
9954 : :
9955 : : #ifdef RTE_NET_IXGBE
9956 : : if (ret == -ENOTSUP)
9957 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
9958 : 0 : res->vf_id, is_on);
9959 : : #endif
9960 : : #ifdef RTE_NET_I40E
9961 : 0 : if (ret == -ENOTSUP)
9962 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
9963 : 0 : res->vf_id, is_on);
9964 : : #endif
9965 : : #ifdef RTE_NET_BNXT
9966 : 0 : if (ret == -ENOTSUP)
9967 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
9968 : 0 : res->vf_id, is_on);
9969 : : #endif
9970 : :
9971 : 0 : switch (ret) {
9972 : : case 0:
9973 : : break;
9974 : 0 : case -EINVAL:
9975 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9976 : 0 : res->vf_id, is_on);
9977 : : break;
9978 : 0 : case -ENODEV:
9979 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9980 : : break;
9981 : 0 : case -ENOTSUP:
9982 : 0 : fprintf(stderr, "function not implemented\n");
9983 : : break;
9984 : 0 : default:
9985 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9986 : : }
9987 : : }
9988 : :
9989 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
9990 : : .f = cmd_set_vf_vlan_stripq_parsed,
9991 : : .data = NULL,
9992 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
9993 : : .tokens = {
9994 : : (void *)&cmd_vf_vlan_stripq_set,
9995 : : (void *)&cmd_vf_vlan_stripq_vf,
9996 : : (void *)&cmd_vf_vlan_stripq_vlan,
9997 : : (void *)&cmd_vf_vlan_stripq_stripq,
9998 : : (void *)&cmd_vf_vlan_stripq_port_id,
9999 : : (void *)&cmd_vf_vlan_stripq_vf_id,
10000 : : (void *)&cmd_vf_vlan_stripq_on_off,
10001 : : NULL,
10002 : : },
10003 : : };
10004 : :
10005 : : /* vf vlan insert configuration */
10006 : :
10007 : : /* Common result structure for vf vlan insert */
10008 : : struct cmd_vf_vlan_insert_result {
10009 : : cmdline_fixed_string_t set;
10010 : : cmdline_fixed_string_t vf;
10011 : : cmdline_fixed_string_t vlan;
10012 : : cmdline_fixed_string_t insert;
10013 : : portid_t port_id;
10014 : : uint16_t vf_id;
10015 : : uint16_t vlan_id;
10016 : : };
10017 : :
10018 : : /* Common CLI fields for vf vlan insert enable disable */
10019 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
10020 : : TOKEN_STRING_INITIALIZER
10021 : : (struct cmd_vf_vlan_insert_result,
10022 : : set, "set");
10023 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
10024 : : TOKEN_STRING_INITIALIZER
10025 : : (struct cmd_vf_vlan_insert_result,
10026 : : vf, "vf");
10027 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
10028 : : TOKEN_STRING_INITIALIZER
10029 : : (struct cmd_vf_vlan_insert_result,
10030 : : vlan, "vlan");
10031 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
10032 : : TOKEN_STRING_INITIALIZER
10033 : : (struct cmd_vf_vlan_insert_result,
10034 : : insert, "insert");
10035 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
10036 : : TOKEN_NUM_INITIALIZER
10037 : : (struct cmd_vf_vlan_insert_result,
10038 : : port_id, RTE_UINT16);
10039 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
10040 : : TOKEN_NUM_INITIALIZER
10041 : : (struct cmd_vf_vlan_insert_result,
10042 : : vf_id, RTE_UINT16);
10043 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
10044 : : TOKEN_NUM_INITIALIZER
10045 : : (struct cmd_vf_vlan_insert_result,
10046 : : vlan_id, RTE_UINT16);
10047 : :
10048 : : static void
10049 : 0 : cmd_set_vf_vlan_insert_parsed(
10050 : : void *parsed_result,
10051 : : __rte_unused struct cmdline *cl,
10052 : : __rte_unused void *data)
10053 : : {
10054 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
10055 : : int ret = -ENOTSUP;
10056 : :
10057 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10058 : : return;
10059 : :
10060 : : #ifdef RTE_NET_IXGBE
10061 : : if (ret == -ENOTSUP)
10062 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
10063 : 0 : res->vlan_id);
10064 : : #endif
10065 : : #ifdef RTE_NET_I40E
10066 : 0 : if (ret == -ENOTSUP)
10067 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
10068 : 0 : res->vlan_id);
10069 : : #endif
10070 : : #ifdef RTE_NET_BNXT
10071 : 0 : if (ret == -ENOTSUP)
10072 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
10073 : 0 : res->vlan_id);
10074 : : #endif
10075 : :
10076 : 0 : switch (ret) {
10077 : : case 0:
10078 : : break;
10079 : 0 : case -EINVAL:
10080 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
10081 : 0 : res->vf_id, res->vlan_id);
10082 : : break;
10083 : 0 : case -ENODEV:
10084 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10085 : : break;
10086 : 0 : case -ENOTSUP:
10087 : 0 : fprintf(stderr, "function not implemented\n");
10088 : : break;
10089 : 0 : default:
10090 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10091 : : }
10092 : : }
10093 : :
10094 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
10095 : : .f = cmd_set_vf_vlan_insert_parsed,
10096 : : .data = NULL,
10097 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
10098 : : .tokens = {
10099 : : (void *)&cmd_vf_vlan_insert_set,
10100 : : (void *)&cmd_vf_vlan_insert_vf,
10101 : : (void *)&cmd_vf_vlan_insert_vlan,
10102 : : (void *)&cmd_vf_vlan_insert_insert,
10103 : : (void *)&cmd_vf_vlan_insert_port_id,
10104 : : (void *)&cmd_vf_vlan_insert_vf_id,
10105 : : (void *)&cmd_vf_vlan_insert_vlan_id,
10106 : : NULL,
10107 : : },
10108 : : };
10109 : :
10110 : : /* tx loopback configuration */
10111 : :
10112 : : /* Common result structure for tx loopback */
10113 : : struct cmd_tx_loopback_result {
10114 : : cmdline_fixed_string_t set;
10115 : : cmdline_fixed_string_t tx;
10116 : : cmdline_fixed_string_t loopback;
10117 : : portid_t port_id;
10118 : : cmdline_fixed_string_t on_off;
10119 : : };
10120 : :
10121 : : /* Common CLI fields for tx loopback enable disable */
10122 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
10123 : : TOKEN_STRING_INITIALIZER
10124 : : (struct cmd_tx_loopback_result,
10125 : : set, "set");
10126 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
10127 : : TOKEN_STRING_INITIALIZER
10128 : : (struct cmd_tx_loopback_result,
10129 : : tx, "tx");
10130 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
10131 : : TOKEN_STRING_INITIALIZER
10132 : : (struct cmd_tx_loopback_result,
10133 : : loopback, "loopback");
10134 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
10135 : : TOKEN_NUM_INITIALIZER
10136 : : (struct cmd_tx_loopback_result,
10137 : : port_id, RTE_UINT16);
10138 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
10139 : : TOKEN_STRING_INITIALIZER
10140 : : (struct cmd_tx_loopback_result,
10141 : : on_off, "on#off");
10142 : :
10143 : : static void
10144 : 0 : cmd_set_tx_loopback_parsed(
10145 : : void *parsed_result,
10146 : : __rte_unused struct cmdline *cl,
10147 : : __rte_unused void *data)
10148 : : {
10149 : : struct cmd_tx_loopback_result *res = parsed_result;
10150 : : int ret = -ENOTSUP;
10151 : :
10152 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10153 : :
10154 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10155 : : return;
10156 : :
10157 : : #ifdef RTE_NET_IXGBE
10158 : : if (ret == -ENOTSUP)
10159 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
10160 : : #endif
10161 : : #ifdef RTE_NET_I40E
10162 : 0 : if (ret == -ENOTSUP)
10163 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
10164 : : #endif
10165 : : #ifdef RTE_NET_BNXT
10166 : 0 : if (ret == -ENOTSUP)
10167 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
10168 : : #endif
10169 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
10170 : 0 : if (ret == -ENOTSUP)
10171 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
10172 : : #endif
10173 : :
10174 : 0 : switch (ret) {
10175 : : case 0:
10176 : : break;
10177 : 0 : case -EINVAL:
10178 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10179 : : break;
10180 : 0 : case -ENODEV:
10181 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10182 : : break;
10183 : 0 : case -ENOTSUP:
10184 : 0 : fprintf(stderr, "function not implemented\n");
10185 : : break;
10186 : 0 : default:
10187 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10188 : : }
10189 : : }
10190 : :
10191 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
10192 : : .f = cmd_set_tx_loopback_parsed,
10193 : : .data = NULL,
10194 : : .help_str = "set tx loopback <port_id> on|off",
10195 : : .tokens = {
10196 : : (void *)&cmd_tx_loopback_set,
10197 : : (void *)&cmd_tx_loopback_tx,
10198 : : (void *)&cmd_tx_loopback_loopback,
10199 : : (void *)&cmd_tx_loopback_port_id,
10200 : : (void *)&cmd_tx_loopback_on_off,
10201 : : NULL,
10202 : : },
10203 : : };
10204 : :
10205 : : /* all queues drop enable configuration */
10206 : :
10207 : : /* Common result structure for all queues drop enable */
10208 : : struct cmd_all_queues_drop_en_result {
10209 : : cmdline_fixed_string_t set;
10210 : : cmdline_fixed_string_t all;
10211 : : cmdline_fixed_string_t queues;
10212 : : cmdline_fixed_string_t drop;
10213 : : portid_t port_id;
10214 : : cmdline_fixed_string_t on_off;
10215 : : };
10216 : :
10217 : : /* Common CLI fields for tx loopback enable disable */
10218 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
10219 : : TOKEN_STRING_INITIALIZER
10220 : : (struct cmd_all_queues_drop_en_result,
10221 : : set, "set");
10222 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
10223 : : TOKEN_STRING_INITIALIZER
10224 : : (struct cmd_all_queues_drop_en_result,
10225 : : all, "all");
10226 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
10227 : : TOKEN_STRING_INITIALIZER
10228 : : (struct cmd_all_queues_drop_en_result,
10229 : : queues, "queues");
10230 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
10231 : : TOKEN_STRING_INITIALIZER
10232 : : (struct cmd_all_queues_drop_en_result,
10233 : : drop, "drop");
10234 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
10235 : : TOKEN_NUM_INITIALIZER
10236 : : (struct cmd_all_queues_drop_en_result,
10237 : : port_id, RTE_UINT16);
10238 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
10239 : : TOKEN_STRING_INITIALIZER
10240 : : (struct cmd_all_queues_drop_en_result,
10241 : : on_off, "on#off");
10242 : :
10243 : : static void
10244 : 0 : cmd_set_all_queues_drop_en_parsed(
10245 : : void *parsed_result,
10246 : : __rte_unused struct cmdline *cl,
10247 : : __rte_unused void *data)
10248 : : {
10249 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
10250 : : int ret = -ENOTSUP;
10251 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10252 : :
10253 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10254 : : return;
10255 : :
10256 : : #ifdef RTE_NET_IXGBE
10257 : : if (ret == -ENOTSUP)
10258 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
10259 : : #endif
10260 : : #ifdef RTE_NET_BNXT
10261 : 0 : if (ret == -ENOTSUP)
10262 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
10263 : : #endif
10264 : 0 : switch (ret) {
10265 : : case 0:
10266 : : break;
10267 : 0 : case -EINVAL:
10268 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10269 : : break;
10270 : 0 : case -ENODEV:
10271 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10272 : : break;
10273 : 0 : case -ENOTSUP:
10274 : 0 : fprintf(stderr, "function not implemented\n");
10275 : : break;
10276 : 0 : default:
10277 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10278 : : }
10279 : : }
10280 : :
10281 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
10282 : : .f = cmd_set_all_queues_drop_en_parsed,
10283 : : .data = NULL,
10284 : : .help_str = "set all queues drop <port_id> on|off",
10285 : : .tokens = {
10286 : : (void *)&cmd_all_queues_drop_en_set,
10287 : : (void *)&cmd_all_queues_drop_en_all,
10288 : : (void *)&cmd_all_queues_drop_en_queues,
10289 : : (void *)&cmd_all_queues_drop_en_drop,
10290 : : (void *)&cmd_all_queues_drop_en_port_id,
10291 : : (void *)&cmd_all_queues_drop_en_on_off,
10292 : : NULL,
10293 : : },
10294 : : };
10295 : :
10296 : : /* vf mac address configuration */
10297 : :
10298 : : /* Common result structure for vf mac address */
10299 : : struct cmd_set_vf_mac_addr_result {
10300 : : cmdline_fixed_string_t set;
10301 : : cmdline_fixed_string_t vf;
10302 : : cmdline_fixed_string_t mac;
10303 : : cmdline_fixed_string_t addr;
10304 : : portid_t port_id;
10305 : : uint16_t vf_id;
10306 : : struct rte_ether_addr mac_addr;
10307 : :
10308 : : };
10309 : :
10310 : : /* Common CLI fields for vf split drop enable disable */
10311 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
10312 : : TOKEN_STRING_INITIALIZER
10313 : : (struct cmd_set_vf_mac_addr_result,
10314 : : set, "set");
10315 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
10316 : : TOKEN_STRING_INITIALIZER
10317 : : (struct cmd_set_vf_mac_addr_result,
10318 : : vf, "vf");
10319 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
10320 : : TOKEN_STRING_INITIALIZER
10321 : : (struct cmd_set_vf_mac_addr_result,
10322 : : mac, "mac");
10323 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
10324 : : TOKEN_STRING_INITIALIZER
10325 : : (struct cmd_set_vf_mac_addr_result,
10326 : : addr, "addr");
10327 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
10328 : : TOKEN_NUM_INITIALIZER
10329 : : (struct cmd_set_vf_mac_addr_result,
10330 : : port_id, RTE_UINT16);
10331 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
10332 : : TOKEN_NUM_INITIALIZER
10333 : : (struct cmd_set_vf_mac_addr_result,
10334 : : vf_id, RTE_UINT16);
10335 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
10336 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
10337 : : mac_addr);
10338 : :
10339 : : static void
10340 : 0 : cmd_set_vf_mac_addr_parsed(
10341 : : void *parsed_result,
10342 : : __rte_unused struct cmdline *cl,
10343 : : __rte_unused void *data)
10344 : : {
10345 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
10346 : : int ret = -ENOTSUP;
10347 : :
10348 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10349 : : return;
10350 : :
10351 : : #ifdef RTE_NET_IXGBE
10352 : : if (ret == -ENOTSUP)
10353 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
10354 : : &res->mac_addr);
10355 : : #endif
10356 : : #ifdef RTE_NET_I40E
10357 : 0 : if (ret == -ENOTSUP)
10358 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
10359 : : &res->mac_addr);
10360 : : #endif
10361 : : #ifdef RTE_NET_BNXT
10362 : 0 : if (ret == -ENOTSUP)
10363 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
10364 : : &res->mac_addr);
10365 : : #endif
10366 : :
10367 : 0 : switch (ret) {
10368 : : case 0:
10369 : : break;
10370 : 0 : case -EINVAL:
10371 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
10372 : : break;
10373 : 0 : case -ENODEV:
10374 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10375 : : break;
10376 : 0 : case -ENOTSUP:
10377 : 0 : fprintf(stderr, "function not implemented\n");
10378 : : break;
10379 : 0 : default:
10380 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10381 : : }
10382 : : }
10383 : :
10384 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
10385 : : .f = cmd_set_vf_mac_addr_parsed,
10386 : : .data = NULL,
10387 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
10388 : : .tokens = {
10389 : : (void *)&cmd_set_vf_mac_addr_set,
10390 : : (void *)&cmd_set_vf_mac_addr_vf,
10391 : : (void *)&cmd_set_vf_mac_addr_mac,
10392 : : (void *)&cmd_set_vf_mac_addr_addr,
10393 : : (void *)&cmd_set_vf_mac_addr_port_id,
10394 : : (void *)&cmd_set_vf_mac_addr_vf_id,
10395 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
10396 : : NULL,
10397 : : },
10398 : : };
10399 : :
10400 : : /** Set VXLAN encapsulation details */
10401 : : struct cmd_set_vxlan_result {
10402 : : cmdline_fixed_string_t set;
10403 : : cmdline_fixed_string_t vxlan;
10404 : : cmdline_fixed_string_t pos_token;
10405 : : cmdline_fixed_string_t ip_version;
10406 : : uint32_t vlan_present:1;
10407 : : uint32_t vni;
10408 : : uint16_t udp_src;
10409 : : uint16_t udp_dst;
10410 : : cmdline_ipaddr_t ip_src;
10411 : : cmdline_ipaddr_t ip_dst;
10412 : : uint16_t tci;
10413 : : uint8_t tos;
10414 : : uint8_t ttl;
10415 : : struct rte_ether_addr eth_src;
10416 : : struct rte_ether_addr eth_dst;
10417 : : };
10418 : :
10419 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
10420 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
10421 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
10422 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
10423 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
10424 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10425 : : "vxlan-tos-ttl");
10426 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
10427 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10428 : : "vxlan-with-vlan");
10429 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
10430 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10431 : : "ip-version");
10432 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
10433 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
10434 : : "ipv4#ipv6");
10435 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
10436 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10437 : : "vni");
10438 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
10439 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
10440 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
10441 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10442 : : "udp-src");
10443 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
10444 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
10445 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
10446 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10447 : : "udp-dst");
10448 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
10449 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
10450 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
10451 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10452 : : "ip-tos");
10453 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
10454 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
10455 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
10456 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10457 : : "ip-ttl");
10458 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
10459 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
10460 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
10461 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10462 : : "ip-src");
10463 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
10464 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
10465 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
10466 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10467 : : "ip-dst");
10468 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
10469 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
10470 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
10471 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10472 : : "vlan-tci");
10473 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
10474 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
10475 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
10476 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10477 : : "eth-src");
10478 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
10479 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
10480 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
10481 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10482 : : "eth-dst");
10483 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
10484 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
10485 : :
10486 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
10487 : : __rte_unused struct cmdline *cl,
10488 : : __rte_unused void *data)
10489 : : {
10490 : : struct cmd_set_vxlan_result *res = parsed_result;
10491 : : union {
10492 : : uint32_t vxlan_id;
10493 : : uint8_t vni[4];
10494 : : } id = {
10495 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
10496 : : };
10497 : :
10498 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
10499 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
10500 : 0 : vxlan_encap_conf.select_vlan = 0;
10501 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
10502 : 0 : vxlan_encap_conf.select_vlan = 1;
10503 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
10504 : 0 : vxlan_encap_conf.select_vlan = 0;
10505 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
10506 : : }
10507 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10508 : 0 : vxlan_encap_conf.select_ipv4 = 1;
10509 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10510 : 0 : vxlan_encap_conf.select_ipv4 = 0;
10511 : : else
10512 : : return;
10513 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
10514 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10515 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10516 : 0 : vxlan_encap_conf.ip_tos = res->tos;
10517 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
10518 : 0 : if (vxlan_encap_conf.select_ipv4) {
10519 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
10520 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
10521 : : } else {
10522 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
10523 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
10524 : : }
10525 : 0 : if (vxlan_encap_conf.select_vlan)
10526 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10527 : : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
10528 : : RTE_ETHER_ADDR_LEN);
10529 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10530 : : RTE_ETHER_ADDR_LEN);
10531 : : }
10532 : :
10533 : : static cmdline_parse_inst_t cmd_set_vxlan = {
10534 : : .f = cmd_set_vxlan_parsed,
10535 : : .data = NULL,
10536 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
10537 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
10538 : : " eth-src <eth-src> eth-dst <eth-dst>",
10539 : : .tokens = {
10540 : : (void *)&cmd_set_vxlan_set,
10541 : : (void *)&cmd_set_vxlan_vxlan,
10542 : : (void *)&cmd_set_vxlan_ip_version,
10543 : : (void *)&cmd_set_vxlan_ip_version_value,
10544 : : (void *)&cmd_set_vxlan_vni,
10545 : : (void *)&cmd_set_vxlan_vni_value,
10546 : : (void *)&cmd_set_vxlan_udp_src,
10547 : : (void *)&cmd_set_vxlan_udp_src_value,
10548 : : (void *)&cmd_set_vxlan_udp_dst,
10549 : : (void *)&cmd_set_vxlan_udp_dst_value,
10550 : : (void *)&cmd_set_vxlan_ip_src,
10551 : : (void *)&cmd_set_vxlan_ip_src_value,
10552 : : (void *)&cmd_set_vxlan_ip_dst,
10553 : : (void *)&cmd_set_vxlan_ip_dst_value,
10554 : : (void *)&cmd_set_vxlan_eth_src,
10555 : : (void *)&cmd_set_vxlan_eth_src_value,
10556 : : (void *)&cmd_set_vxlan_eth_dst,
10557 : : (void *)&cmd_set_vxlan_eth_dst_value,
10558 : : NULL,
10559 : : },
10560 : : };
10561 : :
10562 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
10563 : : .f = cmd_set_vxlan_parsed,
10564 : : .data = NULL,
10565 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
10566 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
10567 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10568 : : " eth-dst <eth-dst>",
10569 : : .tokens = {
10570 : : (void *)&cmd_set_vxlan_set,
10571 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
10572 : : (void *)&cmd_set_vxlan_ip_version,
10573 : : (void *)&cmd_set_vxlan_ip_version_value,
10574 : : (void *)&cmd_set_vxlan_vni,
10575 : : (void *)&cmd_set_vxlan_vni_value,
10576 : : (void *)&cmd_set_vxlan_udp_src,
10577 : : (void *)&cmd_set_vxlan_udp_src_value,
10578 : : (void *)&cmd_set_vxlan_udp_dst,
10579 : : (void *)&cmd_set_vxlan_udp_dst_value,
10580 : : (void *)&cmd_set_vxlan_ip_tos,
10581 : : (void *)&cmd_set_vxlan_ip_tos_value,
10582 : : (void *)&cmd_set_vxlan_ip_ttl,
10583 : : (void *)&cmd_set_vxlan_ip_ttl_value,
10584 : : (void *)&cmd_set_vxlan_ip_src,
10585 : : (void *)&cmd_set_vxlan_ip_src_value,
10586 : : (void *)&cmd_set_vxlan_ip_dst,
10587 : : (void *)&cmd_set_vxlan_ip_dst_value,
10588 : : (void *)&cmd_set_vxlan_eth_src,
10589 : : (void *)&cmd_set_vxlan_eth_src_value,
10590 : : (void *)&cmd_set_vxlan_eth_dst,
10591 : : (void *)&cmd_set_vxlan_eth_dst_value,
10592 : : NULL,
10593 : : },
10594 : : };
10595 : :
10596 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
10597 : : .f = cmd_set_vxlan_parsed,
10598 : : .data = NULL,
10599 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
10600 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
10601 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
10602 : : " <eth-dst>",
10603 : : .tokens = {
10604 : : (void *)&cmd_set_vxlan_set,
10605 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
10606 : : (void *)&cmd_set_vxlan_ip_version,
10607 : : (void *)&cmd_set_vxlan_ip_version_value,
10608 : : (void *)&cmd_set_vxlan_vni,
10609 : : (void *)&cmd_set_vxlan_vni_value,
10610 : : (void *)&cmd_set_vxlan_udp_src,
10611 : : (void *)&cmd_set_vxlan_udp_src_value,
10612 : : (void *)&cmd_set_vxlan_udp_dst,
10613 : : (void *)&cmd_set_vxlan_udp_dst_value,
10614 : : (void *)&cmd_set_vxlan_ip_src,
10615 : : (void *)&cmd_set_vxlan_ip_src_value,
10616 : : (void *)&cmd_set_vxlan_ip_dst,
10617 : : (void *)&cmd_set_vxlan_ip_dst_value,
10618 : : (void *)&cmd_set_vxlan_vlan,
10619 : : (void *)&cmd_set_vxlan_vlan_value,
10620 : : (void *)&cmd_set_vxlan_eth_src,
10621 : : (void *)&cmd_set_vxlan_eth_src_value,
10622 : : (void *)&cmd_set_vxlan_eth_dst,
10623 : : (void *)&cmd_set_vxlan_eth_dst_value,
10624 : : NULL,
10625 : : },
10626 : : };
10627 : :
10628 : : /** Set NVGRE encapsulation details */
10629 : : struct cmd_set_nvgre_result {
10630 : : cmdline_fixed_string_t set;
10631 : : cmdline_fixed_string_t nvgre;
10632 : : cmdline_fixed_string_t pos_token;
10633 : : cmdline_fixed_string_t ip_version;
10634 : : uint32_t tni;
10635 : : cmdline_ipaddr_t ip_src;
10636 : : cmdline_ipaddr_t ip_dst;
10637 : : uint16_t tci;
10638 : : struct rte_ether_addr eth_src;
10639 : : struct rte_ether_addr eth_dst;
10640 : : };
10641 : :
10642 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
10643 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
10644 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
10645 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
10646 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
10647 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
10648 : : "nvgre-with-vlan");
10649 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
10650 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10651 : : "ip-version");
10652 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
10653 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
10654 : : "ipv4#ipv6");
10655 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
10656 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10657 : : "tni");
10658 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
10659 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
10660 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
10661 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10662 : : "ip-src");
10663 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
10664 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
10665 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
10666 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10667 : : "ip-dst");
10668 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
10669 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
10670 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
10671 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10672 : : "vlan-tci");
10673 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
10674 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
10675 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
10676 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10677 : : "eth-src");
10678 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
10679 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
10680 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
10681 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10682 : : "eth-dst");
10683 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
10684 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
10685 : :
10686 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
10687 : : __rte_unused struct cmdline *cl,
10688 : : __rte_unused void *data)
10689 : : {
10690 : : struct cmd_set_nvgre_result *res = parsed_result;
10691 : : union {
10692 : : uint32_t nvgre_tni;
10693 : : uint8_t tni[4];
10694 : : } id = {
10695 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
10696 : : };
10697 : :
10698 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
10699 : 0 : nvgre_encap_conf.select_vlan = 0;
10700 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
10701 : 0 : nvgre_encap_conf.select_vlan = 1;
10702 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10703 : 0 : nvgre_encap_conf.select_ipv4 = 1;
10704 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10705 : 0 : nvgre_encap_conf.select_ipv4 = 0;
10706 : : else
10707 : : return;
10708 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
10709 : 0 : if (nvgre_encap_conf.select_ipv4) {
10710 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
10711 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
10712 : : } else {
10713 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
10714 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
10715 : : }
10716 : 0 : if (nvgre_encap_conf.select_vlan)
10717 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10718 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
10719 : : RTE_ETHER_ADDR_LEN);
10720 : : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10721 : : RTE_ETHER_ADDR_LEN);
10722 : : }
10723 : :
10724 : : static cmdline_parse_inst_t cmd_set_nvgre = {
10725 : : .f = cmd_set_nvgre_parsed,
10726 : : .data = NULL,
10727 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
10728 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10729 : : " eth-dst <eth-dst>",
10730 : : .tokens = {
10731 : : (void *)&cmd_set_nvgre_set,
10732 : : (void *)&cmd_set_nvgre_nvgre,
10733 : : (void *)&cmd_set_nvgre_ip_version,
10734 : : (void *)&cmd_set_nvgre_ip_version_value,
10735 : : (void *)&cmd_set_nvgre_tni,
10736 : : (void *)&cmd_set_nvgre_tni_value,
10737 : : (void *)&cmd_set_nvgre_ip_src,
10738 : : (void *)&cmd_set_nvgre_ip_src_value,
10739 : : (void *)&cmd_set_nvgre_ip_dst,
10740 : : (void *)&cmd_set_nvgre_ip_dst_value,
10741 : : (void *)&cmd_set_nvgre_eth_src,
10742 : : (void *)&cmd_set_nvgre_eth_src_value,
10743 : : (void *)&cmd_set_nvgre_eth_dst,
10744 : : (void *)&cmd_set_nvgre_eth_dst_value,
10745 : : NULL,
10746 : : },
10747 : : };
10748 : :
10749 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
10750 : : .f = cmd_set_nvgre_parsed,
10751 : : .data = NULL,
10752 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
10753 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10754 : : " eth-src <eth-src> eth-dst <eth-dst>",
10755 : : .tokens = {
10756 : : (void *)&cmd_set_nvgre_set,
10757 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
10758 : : (void *)&cmd_set_nvgre_ip_version,
10759 : : (void *)&cmd_set_nvgre_ip_version_value,
10760 : : (void *)&cmd_set_nvgre_tni,
10761 : : (void *)&cmd_set_nvgre_tni_value,
10762 : : (void *)&cmd_set_nvgre_ip_src,
10763 : : (void *)&cmd_set_nvgre_ip_src_value,
10764 : : (void *)&cmd_set_nvgre_ip_dst,
10765 : : (void *)&cmd_set_nvgre_ip_dst_value,
10766 : : (void *)&cmd_set_nvgre_vlan,
10767 : : (void *)&cmd_set_nvgre_vlan_value,
10768 : : (void *)&cmd_set_nvgre_eth_src,
10769 : : (void *)&cmd_set_nvgre_eth_src_value,
10770 : : (void *)&cmd_set_nvgre_eth_dst,
10771 : : (void *)&cmd_set_nvgre_eth_dst_value,
10772 : : NULL,
10773 : : },
10774 : : };
10775 : :
10776 : : /** Set L2 encapsulation details */
10777 : : struct cmd_set_l2_encap_result {
10778 : : cmdline_fixed_string_t set;
10779 : : cmdline_fixed_string_t l2_encap;
10780 : : cmdline_fixed_string_t pos_token;
10781 : : cmdline_fixed_string_t ip_version;
10782 : : uint32_t vlan_present:1;
10783 : : uint16_t tci;
10784 : : struct rte_ether_addr eth_src;
10785 : : struct rte_ether_addr eth_dst;
10786 : : };
10787 : :
10788 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
10789 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
10790 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
10791 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
10792 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
10793 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
10794 : : "l2_encap-with-vlan");
10795 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
10796 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10797 : : "ip-version");
10798 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
10799 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
10800 : : "ipv4#ipv6");
10801 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
10802 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10803 : : "vlan-tci");
10804 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
10805 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
10806 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
10807 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10808 : : "eth-src");
10809 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
10810 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
10811 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
10812 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10813 : : "eth-dst");
10814 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
10815 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
10816 : :
10817 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
10818 : : __rte_unused struct cmdline *cl,
10819 : : __rte_unused void *data)
10820 : : {
10821 : : struct cmd_set_l2_encap_result *res = parsed_result;
10822 : :
10823 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
10824 : 0 : l2_encap_conf.select_vlan = 0;
10825 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
10826 : 0 : l2_encap_conf.select_vlan = 1;
10827 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10828 : 0 : l2_encap_conf.select_ipv4 = 1;
10829 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10830 : 0 : l2_encap_conf.select_ipv4 = 0;
10831 : : else
10832 : : return;
10833 : 0 : if (l2_encap_conf.select_vlan)
10834 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10835 : : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
10836 : : RTE_ETHER_ADDR_LEN);
10837 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10838 : : RTE_ETHER_ADDR_LEN);
10839 : : }
10840 : :
10841 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
10842 : : .f = cmd_set_l2_encap_parsed,
10843 : : .data = NULL,
10844 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
10845 : : " eth-src <eth-src> eth-dst <eth-dst>",
10846 : : .tokens = {
10847 : : (void *)&cmd_set_l2_encap_set,
10848 : : (void *)&cmd_set_l2_encap_l2_encap,
10849 : : (void *)&cmd_set_l2_encap_ip_version,
10850 : : (void *)&cmd_set_l2_encap_ip_version_value,
10851 : : (void *)&cmd_set_l2_encap_eth_src,
10852 : : (void *)&cmd_set_l2_encap_eth_src_value,
10853 : : (void *)&cmd_set_l2_encap_eth_dst,
10854 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10855 : : NULL,
10856 : : },
10857 : : };
10858 : :
10859 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
10860 : : .f = cmd_set_l2_encap_parsed,
10861 : : .data = NULL,
10862 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
10863 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10864 : : .tokens = {
10865 : : (void *)&cmd_set_l2_encap_set,
10866 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
10867 : : (void *)&cmd_set_l2_encap_ip_version,
10868 : : (void *)&cmd_set_l2_encap_ip_version_value,
10869 : : (void *)&cmd_set_l2_encap_vlan,
10870 : : (void *)&cmd_set_l2_encap_vlan_value,
10871 : : (void *)&cmd_set_l2_encap_eth_src,
10872 : : (void *)&cmd_set_l2_encap_eth_src_value,
10873 : : (void *)&cmd_set_l2_encap_eth_dst,
10874 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10875 : : NULL,
10876 : : },
10877 : : };
10878 : :
10879 : : /** Set L2 decapsulation details */
10880 : : struct cmd_set_l2_decap_result {
10881 : : cmdline_fixed_string_t set;
10882 : : cmdline_fixed_string_t l2_decap;
10883 : : cmdline_fixed_string_t pos_token;
10884 : : uint32_t vlan_present:1;
10885 : : };
10886 : :
10887 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
10888 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
10889 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
10890 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10891 : : "l2_decap");
10892 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
10893 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10894 : : "l2_decap-with-vlan");
10895 : :
10896 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
10897 : : __rte_unused struct cmdline *cl,
10898 : : __rte_unused void *data)
10899 : : {
10900 : : struct cmd_set_l2_decap_result *res = parsed_result;
10901 : :
10902 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
10903 : 0 : l2_decap_conf.select_vlan = 0;
10904 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
10905 : 0 : l2_decap_conf.select_vlan = 1;
10906 : 0 : }
10907 : :
10908 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
10909 : : .f = cmd_set_l2_decap_parsed,
10910 : : .data = NULL,
10911 : : .help_str = "set l2_decap",
10912 : : .tokens = {
10913 : : (void *)&cmd_set_l2_decap_set,
10914 : : (void *)&cmd_set_l2_decap_l2_decap,
10915 : : NULL,
10916 : : },
10917 : : };
10918 : :
10919 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
10920 : : .f = cmd_set_l2_decap_parsed,
10921 : : .data = NULL,
10922 : : .help_str = "set l2_decap-with-vlan",
10923 : : .tokens = {
10924 : : (void *)&cmd_set_l2_decap_set,
10925 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
10926 : : NULL,
10927 : : },
10928 : : };
10929 : :
10930 : : /** Set MPLSoGRE encapsulation details */
10931 : : struct cmd_set_mplsogre_encap_result {
10932 : : cmdline_fixed_string_t set;
10933 : : cmdline_fixed_string_t mplsogre;
10934 : : cmdline_fixed_string_t pos_token;
10935 : : cmdline_fixed_string_t ip_version;
10936 : : uint32_t vlan_present:1;
10937 : : uint32_t label;
10938 : : cmdline_ipaddr_t ip_src;
10939 : : cmdline_ipaddr_t ip_dst;
10940 : : uint16_t tci;
10941 : : struct rte_ether_addr eth_src;
10942 : : struct rte_ether_addr eth_dst;
10943 : : };
10944 : :
10945 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
10946 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
10947 : : "set");
10948 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
10949 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
10950 : : "mplsogre_encap");
10951 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
10952 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10953 : : mplsogre, "mplsogre_encap-with-vlan");
10954 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
10955 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10956 : : pos_token, "ip-version");
10957 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
10958 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10959 : : ip_version, "ipv4#ipv6");
10960 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
10961 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10962 : : pos_token, "label");
10963 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
10964 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
10965 : : RTE_UINT32);
10966 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
10967 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10968 : : pos_token, "ip-src");
10969 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
10970 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
10971 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
10972 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10973 : : pos_token, "ip-dst");
10974 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
10975 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
10976 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
10977 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10978 : : pos_token, "vlan-tci");
10979 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
10980 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
10981 : : RTE_UINT16);
10982 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
10983 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10984 : : pos_token, "eth-src");
10985 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
10986 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10987 : : eth_src);
10988 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
10989 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10990 : : pos_token, "eth-dst");
10991 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
10992 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10993 : : eth_dst);
10994 : :
10995 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
10996 : : __rte_unused struct cmdline *cl,
10997 : : __rte_unused void *data)
10998 : : {
10999 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
11000 : : union {
11001 : : uint32_t mplsogre_label;
11002 : : uint8_t label[4];
11003 : : } id = {
11004 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
11005 : : };
11006 : :
11007 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
11008 : 0 : mplsogre_encap_conf.select_vlan = 0;
11009 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
11010 : 0 : mplsogre_encap_conf.select_vlan = 1;
11011 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11012 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
11013 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11014 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
11015 : : else
11016 : : return;
11017 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
11018 : 0 : if (mplsogre_encap_conf.select_ipv4) {
11019 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
11020 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
11021 : : } else {
11022 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
11023 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
11024 : : }
11025 : 0 : if (mplsogre_encap_conf.select_vlan)
11026 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11027 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
11028 : : RTE_ETHER_ADDR_LEN);
11029 : : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11030 : : RTE_ETHER_ADDR_LEN);
11031 : : }
11032 : :
11033 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
11034 : : .f = cmd_set_mplsogre_encap_parsed,
11035 : : .data = NULL,
11036 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
11037 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
11038 : : " eth-dst <eth-dst>",
11039 : : .tokens = {
11040 : : (void *)&cmd_set_mplsogre_encap_set,
11041 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
11042 : : (void *)&cmd_set_mplsogre_encap_ip_version,
11043 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
11044 : : (void *)&cmd_set_mplsogre_encap_label,
11045 : : (void *)&cmd_set_mplsogre_encap_label_value,
11046 : : (void *)&cmd_set_mplsogre_encap_ip_src,
11047 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
11048 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
11049 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
11050 : : (void *)&cmd_set_mplsogre_encap_eth_src,
11051 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
11052 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
11053 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
11054 : : NULL,
11055 : : },
11056 : : };
11057 : :
11058 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
11059 : : .f = cmd_set_mplsogre_encap_parsed,
11060 : : .data = NULL,
11061 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
11062 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
11063 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
11064 : : .tokens = {
11065 : : (void *)&cmd_set_mplsogre_encap_set,
11066 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
11067 : : (void *)&cmd_set_mplsogre_encap_ip_version,
11068 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
11069 : : (void *)&cmd_set_mplsogre_encap_label,
11070 : : (void *)&cmd_set_mplsogre_encap_label_value,
11071 : : (void *)&cmd_set_mplsogre_encap_ip_src,
11072 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
11073 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
11074 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
11075 : : (void *)&cmd_set_mplsogre_encap_vlan,
11076 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
11077 : : (void *)&cmd_set_mplsogre_encap_eth_src,
11078 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
11079 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
11080 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
11081 : : NULL,
11082 : : },
11083 : : };
11084 : :
11085 : : /** Set MPLSoGRE decapsulation details */
11086 : : struct cmd_set_mplsogre_decap_result {
11087 : : cmdline_fixed_string_t set;
11088 : : cmdline_fixed_string_t mplsogre;
11089 : : cmdline_fixed_string_t pos_token;
11090 : : cmdline_fixed_string_t ip_version;
11091 : : uint32_t vlan_present:1;
11092 : : };
11093 : :
11094 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
11095 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
11096 : : "set");
11097 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
11098 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
11099 : : "mplsogre_decap");
11100 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
11101 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11102 : : mplsogre, "mplsogre_decap-with-vlan");
11103 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
11104 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11105 : : pos_token, "ip-version");
11106 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
11107 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11108 : : ip_version, "ipv4#ipv6");
11109 : :
11110 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
11111 : : __rte_unused struct cmdline *cl,
11112 : : __rte_unused void *data)
11113 : : {
11114 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
11115 : :
11116 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
11117 : 0 : mplsogre_decap_conf.select_vlan = 0;
11118 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
11119 : 0 : mplsogre_decap_conf.select_vlan = 1;
11120 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11121 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
11122 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11123 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
11124 : 0 : }
11125 : :
11126 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
11127 : : .f = cmd_set_mplsogre_decap_parsed,
11128 : : .data = NULL,
11129 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
11130 : : .tokens = {
11131 : : (void *)&cmd_set_mplsogre_decap_set,
11132 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
11133 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11134 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11135 : : NULL,
11136 : : },
11137 : : };
11138 : :
11139 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
11140 : : .f = cmd_set_mplsogre_decap_parsed,
11141 : : .data = NULL,
11142 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
11143 : : .tokens = {
11144 : : (void *)&cmd_set_mplsogre_decap_set,
11145 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
11146 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11147 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11148 : : NULL,
11149 : : },
11150 : : };
11151 : :
11152 : : /** Set MPLSoUDP encapsulation details */
11153 : : struct cmd_set_mplsoudp_encap_result {
11154 : : cmdline_fixed_string_t set;
11155 : : cmdline_fixed_string_t mplsoudp;
11156 : : cmdline_fixed_string_t pos_token;
11157 : : cmdline_fixed_string_t ip_version;
11158 : : uint32_t vlan_present:1;
11159 : : uint32_t label;
11160 : : uint16_t udp_src;
11161 : : uint16_t udp_dst;
11162 : : cmdline_ipaddr_t ip_src;
11163 : : cmdline_ipaddr_t ip_dst;
11164 : : uint16_t tci;
11165 : : struct rte_ether_addr eth_src;
11166 : : struct rte_ether_addr eth_dst;
11167 : : };
11168 : :
11169 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
11170 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
11171 : : "set");
11172 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
11173 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
11174 : : "mplsoudp_encap");
11175 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
11176 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11177 : : mplsoudp, "mplsoudp_encap-with-vlan");
11178 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
11179 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11180 : : pos_token, "ip-version");
11181 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
11182 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11183 : : ip_version, "ipv4#ipv6");
11184 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
11185 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11186 : : pos_token, "label");
11187 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
11188 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
11189 : : RTE_UINT32);
11190 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
11191 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11192 : : pos_token, "udp-src");
11193 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
11194 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
11195 : : RTE_UINT16);
11196 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
11197 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11198 : : pos_token, "udp-dst");
11199 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
11200 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
11201 : : RTE_UINT16);
11202 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
11203 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11204 : : pos_token, "ip-src");
11205 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
11206 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
11207 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
11208 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11209 : : pos_token, "ip-dst");
11210 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
11211 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
11212 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
11213 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11214 : : pos_token, "vlan-tci");
11215 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
11216 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
11217 : : RTE_UINT16);
11218 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
11219 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11220 : : pos_token, "eth-src");
11221 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
11222 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11223 : : eth_src);
11224 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
11225 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11226 : : pos_token, "eth-dst");
11227 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
11228 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11229 : : eth_dst);
11230 : :
11231 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
11232 : : __rte_unused struct cmdline *cl,
11233 : : __rte_unused void *data)
11234 : : {
11235 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
11236 : : union {
11237 : : uint32_t mplsoudp_label;
11238 : : uint8_t label[4];
11239 : : } id = {
11240 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
11241 : : };
11242 : :
11243 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
11244 : 0 : mplsoudp_encap_conf.select_vlan = 0;
11245 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
11246 : 0 : mplsoudp_encap_conf.select_vlan = 1;
11247 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11248 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
11249 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11250 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
11251 : : else
11252 : : return;
11253 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
11254 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
11255 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
11256 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
11257 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
11258 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
11259 : : } else {
11260 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
11261 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
11262 : : }
11263 : 0 : if (mplsoudp_encap_conf.select_vlan)
11264 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11265 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
11266 : : RTE_ETHER_ADDR_LEN);
11267 : : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11268 : : RTE_ETHER_ADDR_LEN);
11269 : : }
11270 : :
11271 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
11272 : : .f = cmd_set_mplsoudp_encap_parsed,
11273 : : .data = NULL,
11274 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
11275 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
11276 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
11277 : : .tokens = {
11278 : : (void *)&cmd_set_mplsoudp_encap_set,
11279 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
11280 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11281 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11282 : : (void *)&cmd_set_mplsoudp_encap_label,
11283 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11284 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11285 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11286 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11287 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11288 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11289 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11290 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11291 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11292 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11293 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11294 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11295 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11296 : : NULL,
11297 : : },
11298 : : };
11299 : :
11300 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
11301 : : .f = cmd_set_mplsoudp_encap_parsed,
11302 : : .data = NULL,
11303 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
11304 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
11305 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
11306 : : " eth-src <eth-src> eth-dst <eth-dst>",
11307 : : .tokens = {
11308 : : (void *)&cmd_set_mplsoudp_encap_set,
11309 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
11310 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11311 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11312 : : (void *)&cmd_set_mplsoudp_encap_label,
11313 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11314 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11315 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11316 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11317 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11318 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11319 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11320 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11321 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11322 : : (void *)&cmd_set_mplsoudp_encap_vlan,
11323 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
11324 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11325 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11326 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11327 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11328 : : NULL,
11329 : : },
11330 : : };
11331 : :
11332 : : /** Set MPLSoUDP decapsulation details */
11333 : : struct cmd_set_mplsoudp_decap_result {
11334 : : cmdline_fixed_string_t set;
11335 : : cmdline_fixed_string_t mplsoudp;
11336 : : cmdline_fixed_string_t pos_token;
11337 : : cmdline_fixed_string_t ip_version;
11338 : : uint32_t vlan_present:1;
11339 : : };
11340 : :
11341 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
11342 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
11343 : : "set");
11344 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
11345 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
11346 : : "mplsoudp_decap");
11347 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
11348 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11349 : : mplsoudp, "mplsoudp_decap-with-vlan");
11350 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
11351 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11352 : : pos_token, "ip-version");
11353 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
11354 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11355 : : ip_version, "ipv4#ipv6");
11356 : :
11357 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
11358 : : __rte_unused struct cmdline *cl,
11359 : : __rte_unused void *data)
11360 : : {
11361 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
11362 : :
11363 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
11364 : 0 : mplsoudp_decap_conf.select_vlan = 0;
11365 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
11366 : 0 : mplsoudp_decap_conf.select_vlan = 1;
11367 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11368 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
11369 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11370 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
11371 : 0 : }
11372 : :
11373 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
11374 : : .f = cmd_set_mplsoudp_decap_parsed,
11375 : : .data = NULL,
11376 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
11377 : : .tokens = {
11378 : : (void *)&cmd_set_mplsoudp_decap_set,
11379 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
11380 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11381 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11382 : : NULL,
11383 : : },
11384 : : };
11385 : :
11386 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
11387 : : .f = cmd_set_mplsoudp_decap_parsed,
11388 : : .data = NULL,
11389 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
11390 : : .tokens = {
11391 : : (void *)&cmd_set_mplsoudp_decap_set,
11392 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
11393 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11394 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11395 : : NULL,
11396 : : },
11397 : : };
11398 : :
11399 : : /** Set connection tracking object common details */
11400 : : struct cmd_set_conntrack_common_result {
11401 : : cmdline_fixed_string_t set;
11402 : : cmdline_fixed_string_t conntrack;
11403 : : cmdline_fixed_string_t common;
11404 : : cmdline_fixed_string_t peer;
11405 : : cmdline_fixed_string_t is_orig;
11406 : : cmdline_fixed_string_t enable;
11407 : : cmdline_fixed_string_t live;
11408 : : cmdline_fixed_string_t sack;
11409 : : cmdline_fixed_string_t cack;
11410 : : cmdline_fixed_string_t last_dir;
11411 : : cmdline_fixed_string_t liberal;
11412 : : cmdline_fixed_string_t state;
11413 : : cmdline_fixed_string_t max_ack_win;
11414 : : cmdline_fixed_string_t retrans;
11415 : : cmdline_fixed_string_t last_win;
11416 : : cmdline_fixed_string_t last_seq;
11417 : : cmdline_fixed_string_t last_ack;
11418 : : cmdline_fixed_string_t last_end;
11419 : : cmdline_fixed_string_t last_index;
11420 : : uint8_t stat;
11421 : : uint8_t factor;
11422 : : uint16_t peer_port;
11423 : : uint32_t is_original;
11424 : : uint32_t en;
11425 : : uint32_t is_live;
11426 : : uint32_t s_ack;
11427 : : uint32_t c_ack;
11428 : : uint32_t ld;
11429 : : uint32_t lb;
11430 : : uint8_t re_num;
11431 : : uint8_t li;
11432 : : uint16_t lw;
11433 : : uint32_t ls;
11434 : : uint32_t la;
11435 : : uint32_t le;
11436 : : };
11437 : :
11438 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
11439 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11440 : : set, "set");
11441 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
11442 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11443 : : conntrack, "conntrack");
11444 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
11445 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11446 : : common, "com");
11447 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
11448 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11449 : : peer, "peer");
11450 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
11451 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11452 : : peer_port, RTE_UINT16);
11453 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
11454 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11455 : : is_orig, "is_orig");
11456 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
11457 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11458 : : is_original, RTE_UINT32);
11459 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
11460 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11461 : : enable, "enable");
11462 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
11463 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11464 : : en, RTE_UINT32);
11465 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
11466 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11467 : : live, "live");
11468 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
11469 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11470 : : is_live, RTE_UINT32);
11471 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
11472 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11473 : : sack, "sack");
11474 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
11475 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11476 : : s_ack, RTE_UINT32);
11477 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
11478 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11479 : : cack, "cack");
11480 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
11481 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11482 : : c_ack, RTE_UINT32);
11483 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
11484 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11485 : : last_dir, "last_dir");
11486 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
11487 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11488 : : ld, RTE_UINT32);
11489 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
11490 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11491 : : liberal, "liberal");
11492 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
11493 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11494 : : lb, RTE_UINT32);
11495 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
11496 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11497 : : state, "state");
11498 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
11499 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11500 : : stat, RTE_UINT8);
11501 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
11502 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11503 : : max_ack_win, "max_ack_win");
11504 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
11505 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11506 : : factor, RTE_UINT8);
11507 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
11508 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11509 : : retrans, "r_lim");
11510 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
11511 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11512 : : re_num, RTE_UINT8);
11513 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
11514 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11515 : : last_win, "last_win");
11516 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
11517 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11518 : : lw, RTE_UINT16);
11519 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
11520 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11521 : : last_seq, "last_seq");
11522 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
11523 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11524 : : ls, RTE_UINT32);
11525 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
11526 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11527 : : last_ack, "last_ack");
11528 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
11529 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11530 : : la, RTE_UINT32);
11531 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
11532 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11533 : : last_end, "last_end");
11534 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
11535 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11536 : : le, RTE_UINT32);
11537 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
11538 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11539 : : last_index, "last_index");
11540 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
11541 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11542 : : li, RTE_UINT8);
11543 : :
11544 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
11545 : : __rte_unused struct cmdline *cl,
11546 : : __rte_unused void *data)
11547 : : {
11548 : : struct cmd_set_conntrack_common_result *res = parsed_result;
11549 : :
11550 : : /* No need to swap to big endian. */
11551 : 0 : conntrack_context.peer_port = res->peer_port;
11552 : 0 : conntrack_context.is_original_dir = res->is_original;
11553 : 0 : conntrack_context.enable = res->en;
11554 : 0 : conntrack_context.live_connection = res->is_live;
11555 : 0 : conntrack_context.selective_ack = res->s_ack;
11556 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
11557 : 0 : conntrack_context.last_direction = res->ld;
11558 : 0 : conntrack_context.liberal_mode = res->lb;
11559 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
11560 : 0 : conntrack_context.max_ack_window = res->factor;
11561 : 0 : conntrack_context.retransmission_limit = res->re_num;
11562 : 0 : conntrack_context.last_window = res->lw;
11563 : 0 : conntrack_context.last_index =
11564 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
11565 : 0 : conntrack_context.last_seq = res->ls;
11566 : 0 : conntrack_context.last_ack = res->la;
11567 : 0 : conntrack_context.last_end = res->le;
11568 : 0 : }
11569 : :
11570 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
11571 : : .f = cmd_set_conntrack_common_parsed,
11572 : : .data = NULL,
11573 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
11574 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
11575 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
11576 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
11577 : : " last_index <flag>",
11578 : : .tokens = {
11579 : : (void *)&cmd_set_conntrack_set,
11580 : : (void *)&cmd_set_conntrack_conntrack,
11581 : : (void *)&cmd_set_conntrack_common_com,
11582 : : (void *)&cmd_set_conntrack_common_peer,
11583 : : (void *)&cmd_set_conntrack_common_peer_value,
11584 : : (void *)&cmd_set_conntrack_common_is_orig,
11585 : : (void *)&cmd_set_conntrack_common_is_orig_value,
11586 : : (void *)&cmd_set_conntrack_common_enable,
11587 : : (void *)&cmd_set_conntrack_common_enable_value,
11588 : : (void *)&cmd_set_conntrack_common_live,
11589 : : (void *)&cmd_set_conntrack_common_live_value,
11590 : : (void *)&cmd_set_conntrack_common_sack,
11591 : : (void *)&cmd_set_conntrack_common_sack_value,
11592 : : (void *)&cmd_set_conntrack_common_cack,
11593 : : (void *)&cmd_set_conntrack_common_cack_value,
11594 : : (void *)&cmd_set_conntrack_common_last_dir,
11595 : : (void *)&cmd_set_conntrack_common_last_dir_value,
11596 : : (void *)&cmd_set_conntrack_common_liberal,
11597 : : (void *)&cmd_set_conntrack_common_liberal_value,
11598 : : (void *)&cmd_set_conntrack_common_state,
11599 : : (void *)&cmd_set_conntrack_common_state_value,
11600 : : (void *)&cmd_set_conntrack_common_max_ackwin,
11601 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
11602 : : (void *)&cmd_set_conntrack_common_retrans,
11603 : : (void *)&cmd_set_conntrack_common_retrans_value,
11604 : : (void *)&cmd_set_conntrack_common_last_win,
11605 : : (void *)&cmd_set_conntrack_common_last_win_value,
11606 : : (void *)&cmd_set_conntrack_common_last_seq,
11607 : : (void *)&cmd_set_conntrack_common_last_seq_value,
11608 : : (void *)&cmd_set_conntrack_common_last_ack,
11609 : : (void *)&cmd_set_conntrack_common_last_ack_value,
11610 : : (void *)&cmd_set_conntrack_common_last_end,
11611 : : (void *)&cmd_set_conntrack_common_last_end_value,
11612 : : (void *)&cmd_set_conntrack_common_last_index,
11613 : : (void *)&cmd_set_conntrack_common_last_index_value,
11614 : : NULL,
11615 : : },
11616 : : };
11617 : :
11618 : : /** Set connection tracking object both directions' details */
11619 : : struct cmd_set_conntrack_dir_result {
11620 : : cmdline_fixed_string_t set;
11621 : : cmdline_fixed_string_t conntrack;
11622 : : cmdline_fixed_string_t dir;
11623 : : cmdline_fixed_string_t scale;
11624 : : cmdline_fixed_string_t fin;
11625 : : cmdline_fixed_string_t ack_seen;
11626 : : cmdline_fixed_string_t unack;
11627 : : cmdline_fixed_string_t sent_end;
11628 : : cmdline_fixed_string_t reply_end;
11629 : : cmdline_fixed_string_t max_win;
11630 : : cmdline_fixed_string_t max_ack;
11631 : : uint32_t factor;
11632 : : uint32_t f;
11633 : : uint32_t as;
11634 : : uint32_t un;
11635 : : uint32_t se;
11636 : : uint32_t re;
11637 : : uint32_t mw;
11638 : : uint32_t ma;
11639 : : };
11640 : :
11641 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
11642 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11643 : : dir, "orig#rply");
11644 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
11645 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11646 : : scale, "scale");
11647 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
11648 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11649 : : factor, RTE_UINT32);
11650 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
11651 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11652 : : fin, "fin");
11653 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
11654 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11655 : : f, RTE_UINT32);
11656 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
11657 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11658 : : ack_seen, "acked");
11659 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
11660 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11661 : : as, RTE_UINT32);
11662 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
11663 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11664 : : unack, "unack_data");
11665 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
11666 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11667 : : un, RTE_UINT32);
11668 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
11669 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11670 : : sent_end, "sent_end");
11671 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
11672 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11673 : : se, RTE_UINT32);
11674 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
11675 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11676 : : reply_end, "reply_end");
11677 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
11678 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11679 : : re, RTE_UINT32);
11680 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
11681 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11682 : : max_win, "max_win");
11683 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
11684 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11685 : : mw, RTE_UINT32);
11686 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
11687 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11688 : : max_ack, "max_ack");
11689 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
11690 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11691 : : ma, RTE_UINT32);
11692 : :
11693 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
11694 : : __rte_unused struct cmdline *cl,
11695 : : __rte_unused void *data)
11696 : : {
11697 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
11698 : : struct rte_flow_tcp_dir_param *dir = NULL;
11699 : :
11700 : 0 : if (strcmp(res->dir, "orig") == 0)
11701 : : dir = &conntrack_context.original_dir;
11702 : 0 : else if (strcmp(res->dir, "rply") == 0)
11703 : : dir = &conntrack_context.reply_dir;
11704 : : else
11705 : : return;
11706 : 0 : dir->scale = res->factor;
11707 : 0 : dir->close_initiated = res->f;
11708 : 0 : dir->last_ack_seen = res->as;
11709 : 0 : dir->data_unacked = res->un;
11710 : 0 : dir->sent_end = res->se;
11711 : 0 : dir->reply_end = res->re;
11712 : 0 : dir->max_ack = res->ma;
11713 : 0 : dir->max_win = res->mw;
11714 : : }
11715 : :
11716 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
11717 : : .f = cmd_set_conntrack_dir_parsed,
11718 : : .data = NULL,
11719 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
11720 : : " acked <seen> unack_data <unack> sent_end <sent>"
11721 : : " reply_end <reply> max_win <win> max_ack <ack>",
11722 : : .tokens = {
11723 : : (void *)&cmd_set_conntrack_set,
11724 : : (void *)&cmd_set_conntrack_conntrack,
11725 : : (void *)&cmd_set_conntrack_dir_dir,
11726 : : (void *)&cmd_set_conntrack_dir_scale,
11727 : : (void *)&cmd_set_conntrack_dir_scale_value,
11728 : : (void *)&cmd_set_conntrack_dir_fin,
11729 : : (void *)&cmd_set_conntrack_dir_fin_value,
11730 : : (void *)&cmd_set_conntrack_dir_ack,
11731 : : (void *)&cmd_set_conntrack_dir_ack_value,
11732 : : (void *)&cmd_set_conntrack_dir_unack_data,
11733 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
11734 : : (void *)&cmd_set_conntrack_dir_sent_end,
11735 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
11736 : : (void *)&cmd_set_conntrack_dir_reply_end,
11737 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
11738 : : (void *)&cmd_set_conntrack_dir_max_win,
11739 : : (void *)&cmd_set_conntrack_dir_max_win_value,
11740 : : (void *)&cmd_set_conntrack_dir_max_ack,
11741 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
11742 : : NULL,
11743 : : },
11744 : : };
11745 : :
11746 : : /* show vf stats */
11747 : :
11748 : : /* Common result structure for show vf stats */
11749 : : struct cmd_show_vf_stats_result {
11750 : : cmdline_fixed_string_t show;
11751 : : cmdline_fixed_string_t vf;
11752 : : cmdline_fixed_string_t stats;
11753 : : portid_t port_id;
11754 : : uint16_t vf_id;
11755 : : };
11756 : :
11757 : : /* Common CLI fields show vf stats*/
11758 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
11759 : : TOKEN_STRING_INITIALIZER
11760 : : (struct cmd_show_vf_stats_result,
11761 : : show, "show");
11762 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
11763 : : TOKEN_STRING_INITIALIZER
11764 : : (struct cmd_show_vf_stats_result,
11765 : : vf, "vf");
11766 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
11767 : : TOKEN_STRING_INITIALIZER
11768 : : (struct cmd_show_vf_stats_result,
11769 : : stats, "stats");
11770 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
11771 : : TOKEN_NUM_INITIALIZER
11772 : : (struct cmd_show_vf_stats_result,
11773 : : port_id, RTE_UINT16);
11774 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
11775 : : TOKEN_NUM_INITIALIZER
11776 : : (struct cmd_show_vf_stats_result,
11777 : : vf_id, RTE_UINT16);
11778 : :
11779 : : static void
11780 : 0 : cmd_show_vf_stats_parsed(
11781 : : void *parsed_result,
11782 : : __rte_unused struct cmdline *cl,
11783 : : __rte_unused void *data)
11784 : : {
11785 : : struct cmd_show_vf_stats_result *res = parsed_result;
11786 : : struct rte_eth_stats stats;
11787 : : int ret = -ENOTSUP;
11788 : : static const char *nic_stats_border = "########################";
11789 : :
11790 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11791 : 0 : return;
11792 : :
11793 : : memset(&stats, 0, sizeof(stats));
11794 : :
11795 : : #ifdef RTE_NET_I40E
11796 : : if (ret == -ENOTSUP)
11797 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
11798 : 0 : res->vf_id,
11799 : : &stats);
11800 : : #endif
11801 : : #ifdef RTE_NET_BNXT
11802 : 0 : if (ret == -ENOTSUP)
11803 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
11804 : 0 : res->vf_id,
11805 : : &stats);
11806 : : #endif
11807 : :
11808 : 0 : switch (ret) {
11809 : : case 0:
11810 : : break;
11811 : 0 : case -EINVAL:
11812 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11813 : : break;
11814 : 0 : case -ENODEV:
11815 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11816 : : break;
11817 : 0 : case -ENOTSUP:
11818 : 0 : fprintf(stderr, "function not implemented\n");
11819 : : break;
11820 : 0 : default:
11821 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11822 : : }
11823 : :
11824 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
11825 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
11826 : :
11827 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
11828 : : "%-"PRIu64"\n",
11829 : : stats.ipackets, stats.imissed, stats.ibytes);
11830 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
11831 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
11832 : : stats.rx_nombuf);
11833 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
11834 : : "%-"PRIu64"\n",
11835 : : stats.opackets, stats.oerrors, stats.obytes);
11836 : :
11837 : 0 : printf(" %s############################%s\n",
11838 : : nic_stats_border, nic_stats_border);
11839 : : }
11840 : :
11841 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
11842 : : .f = cmd_show_vf_stats_parsed,
11843 : : .data = NULL,
11844 : : .help_str = "show vf stats <port_id> <vf_id>",
11845 : : .tokens = {
11846 : : (void *)&cmd_show_vf_stats_show,
11847 : : (void *)&cmd_show_vf_stats_vf,
11848 : : (void *)&cmd_show_vf_stats_stats,
11849 : : (void *)&cmd_show_vf_stats_port_id,
11850 : : (void *)&cmd_show_vf_stats_vf_id,
11851 : : NULL,
11852 : : },
11853 : : };
11854 : :
11855 : : /* clear vf stats */
11856 : :
11857 : : /* Common result structure for clear vf stats */
11858 : : struct cmd_clear_vf_stats_result {
11859 : : cmdline_fixed_string_t clear;
11860 : : cmdline_fixed_string_t vf;
11861 : : cmdline_fixed_string_t stats;
11862 : : portid_t port_id;
11863 : : uint16_t vf_id;
11864 : : };
11865 : :
11866 : : /* Common CLI fields clear vf stats*/
11867 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
11868 : : TOKEN_STRING_INITIALIZER
11869 : : (struct cmd_clear_vf_stats_result,
11870 : : clear, "clear");
11871 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
11872 : : TOKEN_STRING_INITIALIZER
11873 : : (struct cmd_clear_vf_stats_result,
11874 : : vf, "vf");
11875 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
11876 : : TOKEN_STRING_INITIALIZER
11877 : : (struct cmd_clear_vf_stats_result,
11878 : : stats, "stats");
11879 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
11880 : : TOKEN_NUM_INITIALIZER
11881 : : (struct cmd_clear_vf_stats_result,
11882 : : port_id, RTE_UINT16);
11883 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
11884 : : TOKEN_NUM_INITIALIZER
11885 : : (struct cmd_clear_vf_stats_result,
11886 : : vf_id, RTE_UINT16);
11887 : :
11888 : : static void
11889 : 0 : cmd_clear_vf_stats_parsed(
11890 : : void *parsed_result,
11891 : : __rte_unused struct cmdline *cl,
11892 : : __rte_unused void *data)
11893 : : {
11894 : : struct cmd_clear_vf_stats_result *res = parsed_result;
11895 : : int ret = -ENOTSUP;
11896 : :
11897 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11898 : : return;
11899 : :
11900 : : #ifdef RTE_NET_I40E
11901 : : if (ret == -ENOTSUP)
11902 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
11903 : 0 : res->vf_id);
11904 : : #endif
11905 : : #ifdef RTE_NET_BNXT
11906 : 0 : if (ret == -ENOTSUP)
11907 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
11908 : 0 : res->vf_id);
11909 : : #endif
11910 : :
11911 : 0 : switch (ret) {
11912 : : case 0:
11913 : : break;
11914 : 0 : case -EINVAL:
11915 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11916 : : break;
11917 : 0 : case -ENODEV:
11918 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11919 : : break;
11920 : 0 : case -ENOTSUP:
11921 : 0 : fprintf(stderr, "function not implemented\n");
11922 : : break;
11923 : 0 : default:
11924 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11925 : : }
11926 : : }
11927 : :
11928 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
11929 : : .f = cmd_clear_vf_stats_parsed,
11930 : : .data = NULL,
11931 : : .help_str = "clear vf stats <port_id> <vf_id>",
11932 : : .tokens = {
11933 : : (void *)&cmd_clear_vf_stats_clear,
11934 : : (void *)&cmd_clear_vf_stats_vf,
11935 : : (void *)&cmd_clear_vf_stats_stats,
11936 : : (void *)&cmd_clear_vf_stats_port_id,
11937 : : (void *)&cmd_clear_vf_stats_vf_id,
11938 : : NULL,
11939 : : },
11940 : : };
11941 : :
11942 : : /* Common result structure for file commands */
11943 : : struct cmd_cmdfile_result {
11944 : : cmdline_fixed_string_t load;
11945 : : cmdline_fixed_string_t filename;
11946 : : };
11947 : :
11948 : : /* Common CLI fields for file commands */
11949 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
11950 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
11951 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
11952 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
11953 : :
11954 : : static void
11955 : 0 : cmd_load_from_file_parsed(
11956 : : void *parsed_result,
11957 : : __rte_unused struct cmdline *cl,
11958 : : __rte_unused void *data)
11959 : : {
11960 : : struct cmd_cmdfile_result *res = parsed_result;
11961 : :
11962 : 0 : if (cmdline_read_from_file(res->filename, false) != 0) {
11963 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
11964 : : }
11965 : 0 : }
11966 : :
11967 : : static cmdline_parse_inst_t cmd_load_from_file = {
11968 : : .f = cmd_load_from_file_parsed,
11969 : : .data = NULL,
11970 : : .help_str = "load <filename>",
11971 : : .tokens = {
11972 : : (void *)&cmd_load_cmdfile,
11973 : : (void *)&cmd_load_cmdfile_filename,
11974 : : NULL,
11975 : : },
11976 : : };
11977 : :
11978 : : /* command to load a file with echoing commands */
11979 : : struct cmd_load_echo_result {
11980 : : cmdline_fixed_string_t load_echo;
11981 : : cmdline_fixed_string_t filename;
11982 : : };
11983 : :
11984 : : /* CLI fields for file load with echo command */
11985 : : static cmdline_parse_token_string_t cmd_load_echo =
11986 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, load_echo, "load_echo");
11987 : : static cmdline_parse_token_string_t cmd_load_echo_filename =
11988 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, filename, NULL);
11989 : :
11990 : : static void
11991 : 0 : cmd_load_echo_file_parsed(
11992 : : void *parsed_result,
11993 : : __rte_unused struct cmdline *cl,
11994 : : __rte_unused void *data)
11995 : : {
11996 : : struct cmd_load_echo_result *res = parsed_result;
11997 : :
11998 : 0 : if (cmdline_read_from_file(res->filename, true) != 0)
11999 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
12000 : 0 : }
12001 : :
12002 : : static cmdline_parse_inst_t cmd_load_echo_file = {
12003 : : .f = cmd_load_echo_file_parsed,
12004 : : .data = NULL,
12005 : : .help_str = "load_echo <filename>",
12006 : : .tokens = {
12007 : : (void *)&cmd_load_echo,
12008 : : (void *)&cmd_load_echo_filename,
12009 : : NULL,
12010 : : },
12011 : : };
12012 : :
12013 : : /* Get Rx offloads capabilities */
12014 : : struct cmd_rx_offload_get_capa_result {
12015 : : cmdline_fixed_string_t show;
12016 : : cmdline_fixed_string_t port;
12017 : : portid_t port_id;
12018 : : cmdline_fixed_string_t rx_offload;
12019 : : cmdline_fixed_string_t capabilities;
12020 : : };
12021 : :
12022 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
12023 : : TOKEN_STRING_INITIALIZER
12024 : : (struct cmd_rx_offload_get_capa_result,
12025 : : show, "show");
12026 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
12027 : : TOKEN_STRING_INITIALIZER
12028 : : (struct cmd_rx_offload_get_capa_result,
12029 : : port, "port");
12030 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
12031 : : TOKEN_NUM_INITIALIZER
12032 : : (struct cmd_rx_offload_get_capa_result,
12033 : : port_id, RTE_UINT16);
12034 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
12035 : : TOKEN_STRING_INITIALIZER
12036 : : (struct cmd_rx_offload_get_capa_result,
12037 : : rx_offload, "rx_offload");
12038 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
12039 : : TOKEN_STRING_INITIALIZER
12040 : : (struct cmd_rx_offload_get_capa_result,
12041 : : capabilities, "capabilities");
12042 : :
12043 : : static void
12044 : 0 : print_rx_offloads(uint64_t offloads)
12045 : : {
12046 : : uint64_t single_offload;
12047 : : int begin;
12048 : : int end;
12049 : : int bit;
12050 : :
12051 : 0 : if (offloads == 0)
12052 : : return;
12053 : :
12054 : : begin = rte_ctz64(offloads);
12055 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12056 : :
12057 : 0 : single_offload = 1ULL << begin;
12058 : 0 : for (bit = begin; bit < end; bit++) {
12059 : 0 : if (offloads & single_offload)
12060 : 0 : printf(" %s",
12061 : : rte_eth_dev_rx_offload_name(single_offload));
12062 : 0 : single_offload <<= 1;
12063 : : }
12064 : : }
12065 : :
12066 : : static void
12067 : 0 : cmd_rx_offload_get_capa_parsed(
12068 : : void *parsed_result,
12069 : : __rte_unused struct cmdline *cl,
12070 : : __rte_unused void *data)
12071 : : {
12072 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
12073 : : struct rte_eth_dev_info dev_info;
12074 : 0 : portid_t port_id = res->port_id;
12075 : : uint64_t queue_offloads;
12076 : : uint64_t port_offloads;
12077 : : int ret;
12078 : :
12079 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12080 : 0 : if (ret != 0)
12081 : 0 : return;
12082 : :
12083 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
12084 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
12085 : :
12086 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
12087 : : printf(" Per Queue :");
12088 : 0 : print_rx_offloads(queue_offloads);
12089 : :
12090 : : printf("\n");
12091 : : printf(" Per Port :");
12092 : 0 : print_rx_offloads(port_offloads);
12093 : : printf("\n\n");
12094 : : }
12095 : :
12096 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
12097 : : .f = cmd_rx_offload_get_capa_parsed,
12098 : : .data = NULL,
12099 : : .help_str = "show port <port_id> rx_offload capabilities",
12100 : : .tokens = {
12101 : : (void *)&cmd_rx_offload_get_capa_show,
12102 : : (void *)&cmd_rx_offload_get_capa_port,
12103 : : (void *)&cmd_rx_offload_get_capa_port_id,
12104 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
12105 : : (void *)&cmd_rx_offload_get_capa_capabilities,
12106 : : NULL,
12107 : : }
12108 : : };
12109 : :
12110 : : /* Get Rx offloads configuration */
12111 : : struct cmd_rx_offload_get_configuration_result {
12112 : : cmdline_fixed_string_t show;
12113 : : cmdline_fixed_string_t port;
12114 : : portid_t port_id;
12115 : : cmdline_fixed_string_t rx_offload;
12116 : : cmdline_fixed_string_t configuration;
12117 : : };
12118 : :
12119 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
12120 : : TOKEN_STRING_INITIALIZER
12121 : : (struct cmd_rx_offload_get_configuration_result,
12122 : : show, "show");
12123 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
12124 : : TOKEN_STRING_INITIALIZER
12125 : : (struct cmd_rx_offload_get_configuration_result,
12126 : : port, "port");
12127 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
12128 : : TOKEN_NUM_INITIALIZER
12129 : : (struct cmd_rx_offload_get_configuration_result,
12130 : : port_id, RTE_UINT16);
12131 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
12132 : : TOKEN_STRING_INITIALIZER
12133 : : (struct cmd_rx_offload_get_configuration_result,
12134 : : rx_offload, "rx_offload");
12135 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
12136 : : TOKEN_STRING_INITIALIZER
12137 : : (struct cmd_rx_offload_get_configuration_result,
12138 : : configuration, "configuration");
12139 : :
12140 : : static void
12141 : 0 : cmd_rx_offload_get_configuration_parsed(
12142 : : void *parsed_result,
12143 : : __rte_unused struct cmdline *cl,
12144 : : __rte_unused void *data)
12145 : : {
12146 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
12147 : : struct rte_eth_dev_info dev_info;
12148 : 0 : portid_t port_id = res->port_id;
12149 : : struct rte_port *port;
12150 : : struct rte_eth_conf dev_conf;
12151 : : uint64_t port_offloads;
12152 : : uint64_t queue_offloads;
12153 : : uint16_t nb_rx_queues;
12154 : : int q;
12155 : : int ret;
12156 : :
12157 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12158 : 0 : if (ret != 0)
12159 : 0 : return;
12160 : :
12161 : 0 : port = &ports[port_id];
12162 : : printf("Rx Offloading Configuration of port %d :\n", port_id);
12163 : :
12164 : 0 : port_offloads = dev_conf.rxmode.offloads;
12165 : : printf(" Port :");
12166 : 0 : print_rx_offloads(port_offloads);
12167 : : printf("\n");
12168 : :
12169 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12170 : 0 : if (ret != 0)
12171 : : return;
12172 : :
12173 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12174 : 0 : for (q = 0; q < nb_rx_queues; q++) {
12175 : 0 : queue_offloads = port->rxq[q].conf.offloads;
12176 : : printf(" Queue[%2d] :", q);
12177 : 0 : print_rx_offloads(queue_offloads);
12178 : : printf("\n");
12179 : : }
12180 : : printf("\n");
12181 : : }
12182 : :
12183 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
12184 : : .f = cmd_rx_offload_get_configuration_parsed,
12185 : : .data = NULL,
12186 : : .help_str = "show port <port_id> rx_offload configuration",
12187 : : .tokens = {
12188 : : (void *)&cmd_rx_offload_get_configuration_show,
12189 : : (void *)&cmd_rx_offload_get_configuration_port,
12190 : : (void *)&cmd_rx_offload_get_configuration_port_id,
12191 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
12192 : : (void *)&cmd_rx_offload_get_configuration_configuration,
12193 : : NULL,
12194 : : }
12195 : : };
12196 : :
12197 : : /* Enable/Disable a per port offloading */
12198 : : struct cmd_config_per_port_rx_offload_result {
12199 : : cmdline_fixed_string_t port;
12200 : : cmdline_fixed_string_t config;
12201 : : portid_t port_id;
12202 : : cmdline_fixed_string_t rx_offload;
12203 : : cmdline_fixed_string_t offload;
12204 : : cmdline_fixed_string_t on_off;
12205 : : };
12206 : :
12207 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
12208 : : TOKEN_STRING_INITIALIZER
12209 : : (struct cmd_config_per_port_rx_offload_result,
12210 : : port, "port");
12211 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
12212 : : TOKEN_STRING_INITIALIZER
12213 : : (struct cmd_config_per_port_rx_offload_result,
12214 : : config, "config");
12215 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
12216 : : TOKEN_NUM_INITIALIZER
12217 : : (struct cmd_config_per_port_rx_offload_result,
12218 : : port_id, RTE_UINT16);
12219 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
12220 : : TOKEN_STRING_INITIALIZER
12221 : : (struct cmd_config_per_port_rx_offload_result,
12222 : : rx_offload, "rx_offload");
12223 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
12224 : : TOKEN_STRING_INITIALIZER
12225 : : (struct cmd_config_per_port_rx_offload_result,
12226 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12227 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12228 : : "vlan_filter#vlan_extend#"
12229 : : "scatter#buffer_split#timestamp#security#"
12230 : : "keep_crc#rss_hash");
12231 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
12232 : : TOKEN_STRING_INITIALIZER
12233 : : (struct cmd_config_per_port_rx_offload_result,
12234 : : on_off, "on#off");
12235 : :
12236 : : static uint64_t
12237 : 0 : search_rx_offload(const char *name)
12238 : : {
12239 : : uint64_t single_offload;
12240 : : const char *single_name;
12241 : : int found = 0;
12242 : : unsigned int bit;
12243 : :
12244 : : single_offload = 1;
12245 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12246 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
12247 : 0 : if (!strcasecmp(single_name, name)) {
12248 : : found = 1;
12249 : : break;
12250 : : }
12251 : 0 : single_offload <<= 1;
12252 : : }
12253 : :
12254 : 0 : if (found)
12255 : 0 : return single_offload;
12256 : :
12257 : : return 0;
12258 : : }
12259 : :
12260 : : static void
12261 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
12262 : : {
12263 : : struct rte_eth_dev_info dev_info;
12264 : : struct rte_port *port;
12265 : : uint16_t nb_rx_queues;
12266 : : uint64_t offload;
12267 : : int q;
12268 : : int ret;
12269 : :
12270 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12271 : 0 : if (ret != 0)
12272 : 0 : return;
12273 : :
12274 : 0 : port = &ports[port_id];
12275 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12276 : 0 : fprintf(stderr,
12277 : : "Error: Can't config offload when Port %d is not stopped\n",
12278 : : port_id);
12279 : 0 : return;
12280 : : }
12281 : :
12282 : 0 : if (!strcmp(name, "all")) {
12283 : 0 : offload = dev_info.rx_offload_capa;
12284 : : } else {
12285 : 0 : offload = search_rx_offload(name);
12286 : 0 : if (offload == 0) {
12287 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12288 : 0 : return;
12289 : : }
12290 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
12291 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12292 : : port_id, name);
12293 : 0 : return;
12294 : : }
12295 : : }
12296 : :
12297 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12298 : 0 : if (on) {
12299 : 0 : port->dev_conf.rxmode.offloads |= offload;
12300 : 0 : for (q = 0; q < nb_rx_queues; q++)
12301 : 0 : port->rxq[q].conf.offloads |= offload;
12302 : : } else {
12303 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
12304 : 0 : for (q = 0; q < nb_rx_queues; q++)
12305 : 0 : port->rxq[q].conf.offloads &= ~offload;
12306 : : }
12307 : :
12308 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12309 : : }
12310 : :
12311 : : static void
12312 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
12313 : : __rte_unused struct cmdline *cl,
12314 : : __rte_unused void *data)
12315 : : {
12316 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
12317 : : bool on;
12318 : :
12319 : 0 : on = strcmp(res->on_off, "on") == 0;
12320 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
12321 : 0 : }
12322 : :
12323 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
12324 : : .f = cmd_config_per_port_rx_offload_parsed,
12325 : : .data = NULL,
12326 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
12327 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12328 : : "macsec_strip|vlan_filter|vlan_extend|"
12329 : : "scatter|buffer_split|timestamp|security|"
12330 : : "keep_crc|rss_hash on|off",
12331 : : .tokens = {
12332 : : (void *)&cmd_config_per_port_rx_offload_result_port,
12333 : : (void *)&cmd_config_per_port_rx_offload_result_config,
12334 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
12335 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
12336 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
12337 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
12338 : : NULL,
12339 : : }
12340 : : };
12341 : :
12342 : : /* Enable/Disable all port Rx offloading */
12343 : : struct cmd_config_all_port_rx_offload_result {
12344 : : cmdline_fixed_string_t port;
12345 : : cmdline_fixed_string_t config;
12346 : : cmdline_fixed_string_t port_all;
12347 : : cmdline_fixed_string_t rx_offload;
12348 : : cmdline_fixed_string_t offload;
12349 : : cmdline_fixed_string_t on_off;
12350 : : };
12351 : :
12352 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
12353 : : TOKEN_STRING_INITIALIZER
12354 : : (struct cmd_config_all_port_rx_offload_result,
12355 : : port, "port");
12356 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
12357 : : TOKEN_STRING_INITIALIZER
12358 : : (struct cmd_config_all_port_rx_offload_result,
12359 : : config, "config");
12360 : :
12361 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
12362 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
12363 : : port_all, "all");
12364 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
12365 : : TOKEN_STRING_INITIALIZER
12366 : : (struct cmd_config_all_port_rx_offload_result,
12367 : : rx_offload, "rx_offload");
12368 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
12369 : : TOKEN_STRING_INITIALIZER
12370 : : (struct cmd_config_all_port_rx_offload_result,
12371 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12372 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12373 : : "vlan_filter#vlan_extend#"
12374 : : "scatter#buffer_split#timestamp#security#"
12375 : : "keep_crc#rss_hash");
12376 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
12377 : : TOKEN_STRING_INITIALIZER
12378 : : (struct cmd_config_all_port_rx_offload_result,
12379 : : on_off, "on#off");
12380 : :
12381 : : static void
12382 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
12383 : : __rte_unused struct cmdline *cl,
12384 : : __rte_unused void *data)
12385 : : {
12386 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
12387 : : bool on_off;
12388 : : portid_t i;
12389 : :
12390 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12391 : 0 : RTE_ETH_FOREACH_DEV(i)
12392 : 0 : config_port_rx_offload(i, res->offload, on_off);
12393 : :
12394 : 0 : }
12395 : :
12396 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
12397 : : .f = cmd_config_all_port_rx_offload_parsed,
12398 : : .data = NULL,
12399 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
12400 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12401 : : "macsec_strip|vlan_filter|vlan_extend|"
12402 : : "scatter|buffer_split|timestamp|security|"
12403 : : "keep_crc|rss_hash on|off",
12404 : : .tokens = {
12405 : : (void *)&cmd_config_all_port_rx_offload_result_port,
12406 : : (void *)&cmd_config_all_port_rx_offload_result_config,
12407 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
12408 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
12409 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
12410 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
12411 : : NULL,
12412 : : }
12413 : : };
12414 : :
12415 : : /* Enable/Disable a per queue offloading */
12416 : : struct cmd_config_per_queue_rx_offload_result {
12417 : : cmdline_fixed_string_t port;
12418 : : portid_t port_id;
12419 : : cmdline_fixed_string_t rxq;
12420 : : uint16_t queue_id;
12421 : : cmdline_fixed_string_t rx_offload;
12422 : : cmdline_fixed_string_t offload;
12423 : : cmdline_fixed_string_t on_off;
12424 : : };
12425 : :
12426 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
12427 : : TOKEN_STRING_INITIALIZER
12428 : : (struct cmd_config_per_queue_rx_offload_result,
12429 : : port, "port");
12430 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
12431 : : TOKEN_NUM_INITIALIZER
12432 : : (struct cmd_config_per_queue_rx_offload_result,
12433 : : port_id, RTE_UINT16);
12434 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
12435 : : TOKEN_STRING_INITIALIZER
12436 : : (struct cmd_config_per_queue_rx_offload_result,
12437 : : rxq, "rxq");
12438 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
12439 : : TOKEN_NUM_INITIALIZER
12440 : : (struct cmd_config_per_queue_rx_offload_result,
12441 : : queue_id, RTE_UINT16);
12442 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
12443 : : TOKEN_STRING_INITIALIZER
12444 : : (struct cmd_config_per_queue_rx_offload_result,
12445 : : rx_offload, "rx_offload");
12446 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
12447 : : TOKEN_STRING_INITIALIZER
12448 : : (struct cmd_config_per_queue_rx_offload_result,
12449 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12450 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12451 : : "vlan_filter#vlan_extend#"
12452 : : "scatter#buffer_split#timestamp#security#keep_crc");
12453 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
12454 : : TOKEN_STRING_INITIALIZER
12455 : : (struct cmd_config_per_queue_rx_offload_result,
12456 : : on_off, "on#off");
12457 : :
12458 : : static void
12459 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
12460 : : __rte_unused struct cmdline *cl,
12461 : : __rte_unused void *data)
12462 : : {
12463 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
12464 : : struct rte_eth_dev_info dev_info;
12465 : 0 : portid_t port_id = res->port_id;
12466 : 0 : uint16_t queue_id = res->queue_id;
12467 : : struct rte_port *port;
12468 : : uint64_t offload;
12469 : : int ret;
12470 : :
12471 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12472 : 0 : if (ret != 0)
12473 : 0 : return;
12474 : :
12475 : 0 : port = &ports[port_id];
12476 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12477 : 0 : fprintf(stderr,
12478 : : "Error: Can't config offload when Port %d is not stopped\n",
12479 : : port_id);
12480 : 0 : return;
12481 : : }
12482 : :
12483 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
12484 : 0 : fprintf(stderr,
12485 : : "Error: input queue_id should be 0 ... %d\n",
12486 : 0 : dev_info.nb_rx_queues - 1);
12487 : 0 : return;
12488 : : }
12489 : :
12490 : 0 : if (!strcmp(res->offload, "all")) {
12491 : 0 : offload = dev_info.rx_queue_offload_capa;
12492 : : } else {
12493 : 0 : offload = search_rx_offload(res->offload);
12494 : 0 : if (offload == 0) {
12495 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12496 : 0 : return;
12497 : : }
12498 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
12499 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12500 : : port_id, res->offload);
12501 : 0 : return;
12502 : : }
12503 : : }
12504 : :
12505 : 0 : if (!strcmp(res->on_off, "on"))
12506 : 0 : port->rxq[queue_id].conf.offloads |= offload;
12507 : : else
12508 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
12509 : :
12510 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12511 : : }
12512 : :
12513 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
12514 : : .f = cmd_config_per_queue_rx_offload_parsed,
12515 : : .data = NULL,
12516 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
12517 : : "all|vlan_strip|ipv4_cksum|"
12518 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12519 : : "macsec_strip|vlan_filter|vlan_extend|"
12520 : : "scatter|buffer_split|timestamp|security|"
12521 : : "keep_crc on|off",
12522 : : .tokens = {
12523 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
12524 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
12525 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
12526 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
12527 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
12528 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
12529 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
12530 : : NULL,
12531 : : }
12532 : : };
12533 : :
12534 : : /* Get Tx offloads capabilities */
12535 : : struct cmd_tx_offload_get_capa_result {
12536 : : cmdline_fixed_string_t show;
12537 : : cmdline_fixed_string_t port;
12538 : : portid_t port_id;
12539 : : cmdline_fixed_string_t tx_offload;
12540 : : cmdline_fixed_string_t capabilities;
12541 : : };
12542 : :
12543 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
12544 : : TOKEN_STRING_INITIALIZER
12545 : : (struct cmd_tx_offload_get_capa_result,
12546 : : show, "show");
12547 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
12548 : : TOKEN_STRING_INITIALIZER
12549 : : (struct cmd_tx_offload_get_capa_result,
12550 : : port, "port");
12551 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
12552 : : TOKEN_NUM_INITIALIZER
12553 : : (struct cmd_tx_offload_get_capa_result,
12554 : : port_id, RTE_UINT16);
12555 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
12556 : : TOKEN_STRING_INITIALIZER
12557 : : (struct cmd_tx_offload_get_capa_result,
12558 : : tx_offload, "tx_offload");
12559 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
12560 : : TOKEN_STRING_INITIALIZER
12561 : : (struct cmd_tx_offload_get_capa_result,
12562 : : capabilities, "capabilities");
12563 : :
12564 : : static void
12565 : 0 : print_tx_offloads(uint64_t offloads)
12566 : : {
12567 : : uint64_t single_offload;
12568 : : int begin;
12569 : : int end;
12570 : : int bit;
12571 : :
12572 : 0 : if (offloads == 0)
12573 : : return;
12574 : :
12575 : : begin = rte_ctz64(offloads);
12576 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12577 : :
12578 : 0 : single_offload = 1ULL << begin;
12579 : 0 : for (bit = begin; bit < end; bit++) {
12580 : 0 : if (offloads & single_offload)
12581 : 0 : printf(" %s",
12582 : : rte_eth_dev_tx_offload_name(single_offload));
12583 : 0 : single_offload <<= 1;
12584 : : }
12585 : : }
12586 : :
12587 : : static void
12588 : 0 : cmd_tx_offload_get_capa_parsed(
12589 : : void *parsed_result,
12590 : : __rte_unused struct cmdline *cl,
12591 : : __rte_unused void *data)
12592 : : {
12593 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
12594 : : struct rte_eth_dev_info dev_info;
12595 : 0 : portid_t port_id = res->port_id;
12596 : : uint64_t queue_offloads;
12597 : : uint64_t port_offloads;
12598 : : int ret;
12599 : :
12600 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12601 : 0 : if (ret != 0)
12602 : 0 : return;
12603 : :
12604 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
12605 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
12606 : :
12607 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
12608 : : printf(" Per Queue :");
12609 : 0 : print_tx_offloads(queue_offloads);
12610 : :
12611 : : printf("\n");
12612 : : printf(" Per Port :");
12613 : 0 : print_tx_offloads(port_offloads);
12614 : : printf("\n\n");
12615 : : }
12616 : :
12617 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
12618 : : .f = cmd_tx_offload_get_capa_parsed,
12619 : : .data = NULL,
12620 : : .help_str = "show port <port_id> tx_offload capabilities",
12621 : : .tokens = {
12622 : : (void *)&cmd_tx_offload_get_capa_show,
12623 : : (void *)&cmd_tx_offload_get_capa_port,
12624 : : (void *)&cmd_tx_offload_get_capa_port_id,
12625 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
12626 : : (void *)&cmd_tx_offload_get_capa_capabilities,
12627 : : NULL,
12628 : : }
12629 : : };
12630 : :
12631 : : /* Get Tx offloads configuration */
12632 : : struct cmd_tx_offload_get_configuration_result {
12633 : : cmdline_fixed_string_t show;
12634 : : cmdline_fixed_string_t port;
12635 : : portid_t port_id;
12636 : : cmdline_fixed_string_t tx_offload;
12637 : : cmdline_fixed_string_t configuration;
12638 : : };
12639 : :
12640 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
12641 : : TOKEN_STRING_INITIALIZER
12642 : : (struct cmd_tx_offload_get_configuration_result,
12643 : : show, "show");
12644 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
12645 : : TOKEN_STRING_INITIALIZER
12646 : : (struct cmd_tx_offload_get_configuration_result,
12647 : : port, "port");
12648 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
12649 : : TOKEN_NUM_INITIALIZER
12650 : : (struct cmd_tx_offload_get_configuration_result,
12651 : : port_id, RTE_UINT16);
12652 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
12653 : : TOKEN_STRING_INITIALIZER
12654 : : (struct cmd_tx_offload_get_configuration_result,
12655 : : tx_offload, "tx_offload");
12656 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
12657 : : TOKEN_STRING_INITIALIZER
12658 : : (struct cmd_tx_offload_get_configuration_result,
12659 : : configuration, "configuration");
12660 : :
12661 : : static void
12662 : 0 : cmd_tx_offload_get_configuration_parsed(
12663 : : void *parsed_result,
12664 : : __rte_unused struct cmdline *cl,
12665 : : __rte_unused void *data)
12666 : : {
12667 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
12668 : : struct rte_eth_dev_info dev_info;
12669 : 0 : portid_t port_id = res->port_id;
12670 : : struct rte_port *port;
12671 : : struct rte_eth_conf dev_conf;
12672 : : uint64_t port_offloads;
12673 : : uint64_t queue_offloads;
12674 : : uint16_t nb_tx_queues;
12675 : : int q;
12676 : : int ret;
12677 : :
12678 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12679 : 0 : if (ret != 0)
12680 : 0 : return;
12681 : :
12682 : : printf("Tx Offloading Configuration of port %d :\n", port_id);
12683 : 0 : port = &ports[port_id];
12684 : 0 : port_offloads = dev_conf.txmode.offloads;
12685 : : printf(" Port :");
12686 : 0 : print_tx_offloads(port_offloads);
12687 : : printf("\n");
12688 : :
12689 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12690 : 0 : if (ret != 0)
12691 : : return;
12692 : :
12693 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12694 : 0 : for (q = 0; q < nb_tx_queues; q++) {
12695 : 0 : queue_offloads = port->txq[q].conf.offloads;
12696 : : printf(" Queue[%2d] :", q);
12697 : 0 : print_tx_offloads(queue_offloads);
12698 : : printf("\n");
12699 : : }
12700 : : printf("\n");
12701 : : }
12702 : :
12703 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
12704 : : .f = cmd_tx_offload_get_configuration_parsed,
12705 : : .data = NULL,
12706 : : .help_str = "show port <port_id> tx_offload configuration",
12707 : : .tokens = {
12708 : : (void *)&cmd_tx_offload_get_configuration_show,
12709 : : (void *)&cmd_tx_offload_get_configuration_port,
12710 : : (void *)&cmd_tx_offload_get_configuration_port_id,
12711 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
12712 : : (void *)&cmd_tx_offload_get_configuration_configuration,
12713 : : NULL,
12714 : : }
12715 : : };
12716 : :
12717 : : /* Enable/Disable a per port offloading */
12718 : : struct cmd_config_per_port_tx_offload_result {
12719 : : cmdline_fixed_string_t port;
12720 : : cmdline_fixed_string_t config;
12721 : : portid_t port_id;
12722 : : cmdline_fixed_string_t tx_offload;
12723 : : cmdline_fixed_string_t offload;
12724 : : cmdline_fixed_string_t on_off;
12725 : : };
12726 : :
12727 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
12728 : : TOKEN_STRING_INITIALIZER
12729 : : (struct cmd_config_per_port_tx_offload_result,
12730 : : port, "port");
12731 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
12732 : : TOKEN_STRING_INITIALIZER
12733 : : (struct cmd_config_per_port_tx_offload_result,
12734 : : config, "config");
12735 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
12736 : : TOKEN_NUM_INITIALIZER
12737 : : (struct cmd_config_per_port_tx_offload_result,
12738 : : port_id, RTE_UINT16);
12739 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
12740 : : TOKEN_STRING_INITIALIZER
12741 : : (struct cmd_config_per_port_tx_offload_result,
12742 : : tx_offload, "tx_offload");
12743 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
12744 : : TOKEN_STRING_INITIALIZER
12745 : : (struct cmd_config_per_port_tx_offload_result,
12746 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12747 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12748 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12749 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12750 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12751 : : "send_on_timestamp");
12752 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
12753 : : TOKEN_STRING_INITIALIZER
12754 : : (struct cmd_config_per_port_tx_offload_result,
12755 : : on_off, "on#off");
12756 : :
12757 : : static uint64_t
12758 : 0 : search_tx_offload(const char *name)
12759 : : {
12760 : : uint64_t single_offload;
12761 : : const char *single_name;
12762 : : int found = 0;
12763 : : unsigned int bit;
12764 : :
12765 : : single_offload = 1;
12766 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12767 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
12768 : 0 : if (single_name == NULL)
12769 : : break;
12770 : 0 : if (!strcasecmp(single_name, name)) {
12771 : : found = 1;
12772 : : break;
12773 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
12774 : : break;
12775 : 0 : single_offload <<= 1;
12776 : : }
12777 : :
12778 : 0 : if (found)
12779 : 0 : return single_offload;
12780 : :
12781 : : return 0;
12782 : : }
12783 : :
12784 : : static void
12785 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
12786 : : {
12787 : : struct rte_eth_dev_info dev_info;
12788 : : struct rte_port *port;
12789 : : uint16_t nb_tx_queues;
12790 : : uint64_t offload;
12791 : : int q;
12792 : : int ret;
12793 : :
12794 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12795 : 0 : if (ret != 0)
12796 : 0 : return;
12797 : :
12798 : 0 : port = &ports[port_id];
12799 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12800 : 0 : fprintf(stderr,
12801 : : "Error: Can't config offload when Port %d is not stopped\n",
12802 : : port_id);
12803 : 0 : return;
12804 : : }
12805 : :
12806 : 0 : if (!strcmp(name, "all")) {
12807 : 0 : offload = dev_info.tx_offload_capa;
12808 : : } else {
12809 : 0 : offload = search_tx_offload(name);
12810 : 0 : if (offload == 0) {
12811 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12812 : 0 : return;
12813 : : }
12814 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
12815 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12816 : : port_id, name);
12817 : 0 : return;
12818 : : }
12819 : : }
12820 : :
12821 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12822 : 0 : if (on) {
12823 : 0 : port->dev_conf.txmode.offloads |= offload;
12824 : 0 : for (q = 0; q < nb_tx_queues; q++)
12825 : 0 : port->txq[q].conf.offloads |= offload;
12826 : : } else {
12827 : 0 : port->dev_conf.txmode.offloads &= ~offload;
12828 : 0 : for (q = 0; q < nb_tx_queues; q++)
12829 : 0 : port->txq[q].conf.offloads &= ~offload;
12830 : : }
12831 : :
12832 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12833 : : }
12834 : :
12835 : : static void
12836 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
12837 : : __rte_unused struct cmdline *cl,
12838 : : __rte_unused void *data)
12839 : : {
12840 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
12841 : : bool on;
12842 : :
12843 : 0 : on = strcmp(res->on_off, "on") == 0;
12844 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
12845 : 0 : }
12846 : :
12847 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
12848 : : .f = cmd_config_per_port_tx_offload_parsed,
12849 : : .data = NULL,
12850 : : .help_str = "port config <port_id> tx_offload "
12851 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12852 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12853 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12854 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12855 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12856 : : "send_on_timestamp on|off",
12857 : : .tokens = {
12858 : : (void *)&cmd_config_per_port_tx_offload_result_port,
12859 : : (void *)&cmd_config_per_port_tx_offload_result_config,
12860 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
12861 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
12862 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
12863 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
12864 : : NULL,
12865 : : }
12866 : : };
12867 : :
12868 : : /* Enable/Disable all port Tx offloading */
12869 : : struct cmd_config_all_port_tx_offload_result {
12870 : : cmdline_fixed_string_t port;
12871 : : cmdline_fixed_string_t config;
12872 : : cmdline_fixed_string_t port_all;
12873 : : cmdline_fixed_string_t tx_offload;
12874 : : cmdline_fixed_string_t offload;
12875 : : cmdline_fixed_string_t on_off;
12876 : : };
12877 : :
12878 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
12879 : : TOKEN_STRING_INITIALIZER
12880 : : (struct cmd_config_all_port_tx_offload_result,
12881 : : port, "port");
12882 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
12883 : : TOKEN_STRING_INITIALIZER
12884 : : (struct cmd_config_all_port_tx_offload_result,
12885 : : config, "config");
12886 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
12887 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
12888 : : port_all, "all");
12889 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
12890 : : TOKEN_STRING_INITIALIZER
12891 : : (struct cmd_config_all_port_tx_offload_result,
12892 : : tx_offload, "tx_offload");
12893 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
12894 : : TOKEN_STRING_INITIALIZER
12895 : : (struct cmd_config_all_port_tx_offload_result,
12896 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12897 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12898 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12899 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12900 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12901 : : "send_on_timestamp");
12902 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
12903 : : TOKEN_STRING_INITIALIZER
12904 : : (struct cmd_config_all_port_tx_offload_result,
12905 : : on_off, "on#off");
12906 : :
12907 : : static void
12908 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
12909 : : __rte_unused struct cmdline *cl,
12910 : : __rte_unused void *data)
12911 : : {
12912 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
12913 : : portid_t i;
12914 : : bool on_off;
12915 : :
12916 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12917 : 0 : RTE_ETH_FOREACH_DEV(i)
12918 : 0 : config_port_tx_offload(i, res->offload, on_off);
12919 : 0 : }
12920 : :
12921 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
12922 : : .f = cmd_config_all_port_tx_offload_parsed,
12923 : : .data = NULL,
12924 : : .help_str = "port config all tx_offload "
12925 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12926 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12927 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12928 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12929 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12930 : : "send_on_timestamp on|off",
12931 : : .tokens = {
12932 : : (void *)&cmd_config_all_port_tx_offload_result_port,
12933 : : (void *)&cmd_config_all_port_tx_offload_result_config,
12934 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
12935 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
12936 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
12937 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
12938 : : NULL,
12939 : : }
12940 : : };
12941 : :
12942 : : /* Enable/Disable a per queue offloading */
12943 : : struct cmd_config_per_queue_tx_offload_result {
12944 : : cmdline_fixed_string_t port;
12945 : : portid_t port_id;
12946 : : cmdline_fixed_string_t txq;
12947 : : uint16_t queue_id;
12948 : : cmdline_fixed_string_t tx_offload;
12949 : : cmdline_fixed_string_t offload;
12950 : : cmdline_fixed_string_t on_off;
12951 : : };
12952 : :
12953 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
12954 : : TOKEN_STRING_INITIALIZER
12955 : : (struct cmd_config_per_queue_tx_offload_result,
12956 : : port, "port");
12957 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
12958 : : TOKEN_NUM_INITIALIZER
12959 : : (struct cmd_config_per_queue_tx_offload_result,
12960 : : port_id, RTE_UINT16);
12961 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
12962 : : TOKEN_STRING_INITIALIZER
12963 : : (struct cmd_config_per_queue_tx_offload_result,
12964 : : txq, "txq");
12965 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
12966 : : TOKEN_NUM_INITIALIZER
12967 : : (struct cmd_config_per_queue_tx_offload_result,
12968 : : queue_id, RTE_UINT16);
12969 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
12970 : : TOKEN_STRING_INITIALIZER
12971 : : (struct cmd_config_per_queue_tx_offload_result,
12972 : : tx_offload, "tx_offload");
12973 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
12974 : : TOKEN_STRING_INITIALIZER
12975 : : (struct cmd_config_per_queue_tx_offload_result,
12976 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12977 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12978 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12979 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12980 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
12981 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
12982 : : TOKEN_STRING_INITIALIZER
12983 : : (struct cmd_config_per_queue_tx_offload_result,
12984 : : on_off, "on#off");
12985 : :
12986 : : static void
12987 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
12988 : : __rte_unused struct cmdline *cl,
12989 : : __rte_unused void *data)
12990 : : {
12991 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
12992 : : struct rte_eth_dev_info dev_info;
12993 : 0 : portid_t port_id = res->port_id;
12994 : 0 : uint16_t queue_id = res->queue_id;
12995 : : struct rte_port *port;
12996 : : uint64_t offload;
12997 : : int ret;
12998 : :
12999 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
13000 : 0 : if (ret != 0)
13001 : 0 : return;
13002 : :
13003 : 0 : port = &ports[port_id];
13004 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
13005 : 0 : fprintf(stderr,
13006 : : "Error: Can't config offload when Port %d is not stopped\n",
13007 : : port_id);
13008 : 0 : return;
13009 : : }
13010 : :
13011 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
13012 : 0 : fprintf(stderr,
13013 : : "Error: input queue_id should be 0 ... %d\n",
13014 : 0 : dev_info.nb_tx_queues - 1);
13015 : 0 : return;
13016 : : }
13017 : :
13018 : 0 : if (!strcmp(res->offload, "all")) {
13019 : 0 : offload = dev_info.tx_queue_offload_capa;
13020 : : } else {
13021 : 0 : offload = search_tx_offload(res->offload);
13022 : 0 : if (offload == 0) {
13023 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
13024 : 0 : return;
13025 : : }
13026 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
13027 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
13028 : : port_id, res->offload);
13029 : 0 : return;
13030 : : }
13031 : : }
13032 : :
13033 : 0 : if (!strcmp(res->on_off, "on"))
13034 : 0 : port->txq[queue_id].conf.offloads |= offload;
13035 : : else
13036 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
13037 : :
13038 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
13039 : : }
13040 : :
13041 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
13042 : : .f = cmd_config_per_queue_tx_offload_parsed,
13043 : : .data = NULL,
13044 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
13045 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
13046 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
13047 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
13048 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
13049 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
13050 : : "on|off",
13051 : : .tokens = {
13052 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
13053 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
13054 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
13055 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
13056 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
13057 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
13058 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
13059 : : NULL,
13060 : : }
13061 : : };
13062 : :
13063 : : /* *** configure tx_metadata for specific port *** */
13064 : : struct cmd_config_tx_metadata_specific_result {
13065 : : cmdline_fixed_string_t port;
13066 : : cmdline_fixed_string_t keyword;
13067 : : uint16_t port_id;
13068 : : cmdline_fixed_string_t item;
13069 : : uint32_t value;
13070 : : };
13071 : :
13072 : : static void
13073 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
13074 : : __rte_unused struct cmdline *cl,
13075 : : __rte_unused void *data)
13076 : : {
13077 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
13078 : :
13079 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13080 : : return;
13081 : 0 : ports[res->port_id].tx_metadata = res->value;
13082 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
13083 : 0 : if (ports[res->port_id].tx_metadata)
13084 : 0 : add_tx_md_callback(res->port_id);
13085 : : else
13086 : 0 : remove_tx_md_callback(res->port_id);
13087 : 0 : rte_flow_dynf_metadata_register();
13088 : : }
13089 : :
13090 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
13091 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13092 : : port, "port");
13093 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
13094 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13095 : : keyword, "config");
13096 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
13097 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13098 : : port_id, RTE_UINT16);
13099 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
13100 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13101 : : item, "tx_metadata");
13102 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
13103 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13104 : : value, RTE_UINT32);
13105 : :
13106 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
13107 : : .f = cmd_config_tx_metadata_specific_parsed,
13108 : : .data = NULL,
13109 : : .help_str = "port config <port_id> tx_metadata <value>",
13110 : : .tokens = {
13111 : : (void *)&cmd_config_tx_metadata_specific_port,
13112 : : (void *)&cmd_config_tx_metadata_specific_keyword,
13113 : : (void *)&cmd_config_tx_metadata_specific_id,
13114 : : (void *)&cmd_config_tx_metadata_specific_item,
13115 : : (void *)&cmd_config_tx_metadata_specific_value,
13116 : : NULL,
13117 : : },
13118 : : };
13119 : :
13120 : : /* *** set dynf *** */
13121 : : struct cmd_config_tx_dynf_specific_result {
13122 : : cmdline_fixed_string_t port;
13123 : : cmdline_fixed_string_t keyword;
13124 : : uint16_t port_id;
13125 : : cmdline_fixed_string_t item;
13126 : : cmdline_fixed_string_t name;
13127 : : cmdline_fixed_string_t value;
13128 : : };
13129 : :
13130 : : static void
13131 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
13132 : : __rte_unused struct cmdline *cl,
13133 : : __rte_unused void *data)
13134 : : {
13135 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
13136 : : struct rte_mbuf_dynflag desc_flag;
13137 : : int flag;
13138 : : uint64_t old_port_flags;
13139 : :
13140 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13141 : 0 : return;
13142 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
13143 : 0 : if (flag <= 0) {
13144 : 0 : if (strlcpy(desc_flag.name, res->name,
13145 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
13146 : 0 : fprintf(stderr, "Flag name too long\n");
13147 : 0 : return;
13148 : : }
13149 : 0 : desc_flag.flags = 0;
13150 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
13151 : 0 : if (flag < 0) {
13152 : 0 : fprintf(stderr, "Can't register flag\n");
13153 : 0 : return;
13154 : : }
13155 : 0 : strcpy(dynf_names[flag], desc_flag.name);
13156 : : }
13157 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
13158 : 0 : if (!strcmp(res->value, "set")) {
13159 : 0 : ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
13160 : 0 : if (old_port_flags == 0)
13161 : 0 : add_tx_dynf_callback(res->port_id);
13162 : : } else {
13163 : 0 : ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
13164 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
13165 : 0 : remove_tx_dynf_callback(res->port_id);
13166 : : }
13167 : : }
13168 : :
13169 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
13170 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13171 : : keyword, "port");
13172 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
13173 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13174 : : keyword, "config");
13175 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
13176 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13177 : : port_id, RTE_UINT16);
13178 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
13179 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13180 : : item, "dynf");
13181 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
13182 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13183 : : name, NULL);
13184 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
13185 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13186 : : value, "set#clear");
13187 : :
13188 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
13189 : : .f = cmd_config_dynf_specific_parsed,
13190 : : .data = NULL,
13191 : : .help_str = "port config <port id> dynf <name> set|clear",
13192 : : .tokens = {
13193 : : (void *)&cmd_config_tx_dynf_specific_port,
13194 : : (void *)&cmd_config_tx_dynf_specific_keyword,
13195 : : (void *)&cmd_config_tx_dynf_specific_port_id,
13196 : : (void *)&cmd_config_tx_dynf_specific_item,
13197 : : (void *)&cmd_config_tx_dynf_specific_name,
13198 : : (void *)&cmd_config_tx_dynf_specific_value,
13199 : : NULL,
13200 : : },
13201 : : };
13202 : :
13203 : : /* *** display tx_metadata per port configuration *** */
13204 : : struct cmd_show_tx_metadata_result {
13205 : : cmdline_fixed_string_t cmd_show;
13206 : : cmdline_fixed_string_t cmd_port;
13207 : : cmdline_fixed_string_t cmd_keyword;
13208 : : portid_t cmd_pid;
13209 : : };
13210 : :
13211 : : static void
13212 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
13213 : : __rte_unused struct cmdline *cl,
13214 : : __rte_unused void *data)
13215 : : {
13216 : : struct cmd_show_tx_metadata_result *res = parsed_result;
13217 : :
13218 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13219 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
13220 : 0 : return;
13221 : : }
13222 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
13223 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
13224 : 0 : ports[res->cmd_pid].tx_metadata);
13225 : : }
13226 : : }
13227 : :
13228 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
13229 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13230 : : cmd_show, "show");
13231 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
13232 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13233 : : cmd_port, "port");
13234 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
13235 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
13236 : : cmd_pid, RTE_UINT16);
13237 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
13238 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13239 : : cmd_keyword, "tx_metadata");
13240 : :
13241 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
13242 : : .f = cmd_show_tx_metadata_parsed,
13243 : : .data = NULL,
13244 : : .help_str = "show port <port_id> tx_metadata",
13245 : : .tokens = {
13246 : : (void *)&cmd_show_tx_metadata_show,
13247 : : (void *)&cmd_show_tx_metadata_port,
13248 : : (void *)&cmd_show_tx_metadata_pid,
13249 : : (void *)&cmd_show_tx_metadata_keyword,
13250 : : NULL,
13251 : : },
13252 : : };
13253 : :
13254 : : /* *** show fec capability per port configuration *** */
13255 : : struct cmd_show_fec_capability_result {
13256 : : cmdline_fixed_string_t cmd_show;
13257 : : cmdline_fixed_string_t cmd_port;
13258 : : cmdline_fixed_string_t cmd_fec;
13259 : : cmdline_fixed_string_t cmd_keyword;
13260 : : portid_t cmd_pid;
13261 : : };
13262 : :
13263 : : static void
13264 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
13265 : : __rte_unused struct cmdline *cl,
13266 : : __rte_unused void *data)
13267 : : {
13268 : : struct cmd_show_fec_capability_result *res = parsed_result;
13269 : : struct rte_eth_fec_capa *speed_fec_capa;
13270 : : unsigned int num;
13271 : : int ret;
13272 : :
13273 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13274 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13275 : 0 : return;
13276 : : }
13277 : :
13278 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
13279 : 0 : if (ret == -ENOTSUP) {
13280 : 0 : fprintf(stderr, "Function not implemented\n");
13281 : 0 : return;
13282 : 0 : } else if (ret < 0) {
13283 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
13284 : 0 : return;
13285 : : }
13286 : :
13287 : 0 : num = (unsigned int)ret;
13288 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
13289 : 0 : if (speed_fec_capa == NULL) {
13290 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
13291 : 0 : return;
13292 : : }
13293 : :
13294 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
13295 : 0 : if (ret < 0) {
13296 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
13297 : 0 : goto out;
13298 : : }
13299 : :
13300 : 0 : show_fec_capability(num, speed_fec_capa);
13301 : 0 : out:
13302 : 0 : free(speed_fec_capa);
13303 : : }
13304 : :
13305 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
13306 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13307 : : cmd_show, "show");
13308 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
13309 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13310 : : cmd_port, "port");
13311 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
13312 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
13313 : : cmd_pid, RTE_UINT16);
13314 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
13315 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13316 : : cmd_fec, "fec");
13317 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
13318 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13319 : : cmd_keyword, "capabilities");
13320 : :
13321 : : static cmdline_parse_inst_t cmd_show_capability = {
13322 : : .f = cmd_show_fec_capability_parsed,
13323 : : .data = NULL,
13324 : : .help_str = "show port <port_id> fec capabilities",
13325 : : .tokens = {
13326 : : (void *)&cmd_show_fec_capability_show,
13327 : : (void *)&cmd_show_fec_capability_port,
13328 : : (void *)&cmd_show_fec_capability_pid,
13329 : : (void *)&cmd_show_fec_capability_fec,
13330 : : (void *)&cmd_show_fec_capability_keyword,
13331 : : NULL,
13332 : : },
13333 : : };
13334 : :
13335 : : /* *** show fec mode per port configuration *** */
13336 : : struct cmd_show_fec_metadata_result {
13337 : : cmdline_fixed_string_t cmd_show;
13338 : : cmdline_fixed_string_t cmd_port;
13339 : : cmdline_fixed_string_t cmd_keyword;
13340 : : portid_t cmd_pid;
13341 : : };
13342 : :
13343 : : static void
13344 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
13345 : : __rte_unused struct cmdline *cl,
13346 : : __rte_unused void *data)
13347 : : {
13348 : : #define FEC_NAME_SIZE 16
13349 : : struct cmd_show_fec_metadata_result *res = parsed_result;
13350 : : uint32_t mode;
13351 : : char buf[FEC_NAME_SIZE];
13352 : : int ret;
13353 : :
13354 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13355 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13356 : 0 : return;
13357 : : }
13358 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
13359 : 0 : if (ret == -ENOTSUP) {
13360 : 0 : fprintf(stderr, "Function not implemented\n");
13361 : 0 : return;
13362 : 0 : } else if (ret < 0) {
13363 : 0 : fprintf(stderr, "Get FEC mode failed\n");
13364 : 0 : return;
13365 : : }
13366 : :
13367 : 0 : switch (mode) {
13368 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
13369 : : strlcpy(buf, "off", sizeof(buf));
13370 : : break;
13371 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
13372 : : strlcpy(buf, "auto", sizeof(buf));
13373 : : break;
13374 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
13375 : : strlcpy(buf, "baser", sizeof(buf));
13376 : : break;
13377 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
13378 : : strlcpy(buf, "rs", sizeof(buf));
13379 : : break;
13380 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
13381 : : strlcpy(buf, "llrs", sizeof(buf));
13382 : : break;
13383 : : default:
13384 : : return;
13385 : : }
13386 : :
13387 : : printf("%s\n", buf);
13388 : : }
13389 : :
13390 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
13391 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13392 : : cmd_show, "show");
13393 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
13394 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13395 : : cmd_port, "port");
13396 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
13397 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
13398 : : cmd_pid, RTE_UINT16);
13399 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
13400 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13401 : : cmd_keyword, "fec_mode");
13402 : :
13403 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
13404 : : .f = cmd_show_fec_mode_parsed,
13405 : : .data = NULL,
13406 : : .help_str = "show port <port_id> fec_mode",
13407 : : .tokens = {
13408 : : (void *)&cmd_show_fec_mode_show,
13409 : : (void *)&cmd_show_fec_mode_port,
13410 : : (void *)&cmd_show_fec_mode_pid,
13411 : : (void *)&cmd_show_fec_mode_keyword,
13412 : : NULL,
13413 : : },
13414 : : };
13415 : :
13416 : : /* *** set fec mode per port configuration *** */
13417 : : struct cmd_set_port_fec_mode {
13418 : : cmdline_fixed_string_t set;
13419 : : cmdline_fixed_string_t port;
13420 : : portid_t port_id;
13421 : : cmdline_fixed_string_t fec_mode;
13422 : : cmdline_fixed_string_t fec_value;
13423 : : };
13424 : :
13425 : : /* Common CLI fields for set fec mode */
13426 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
13427 : : TOKEN_STRING_INITIALIZER
13428 : : (struct cmd_set_port_fec_mode,
13429 : : set, "set");
13430 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
13431 : : TOKEN_STRING_INITIALIZER
13432 : : (struct cmd_set_port_fec_mode,
13433 : : port, "port");
13434 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
13435 : : TOKEN_NUM_INITIALIZER
13436 : : (struct cmd_set_port_fec_mode,
13437 : : port_id, RTE_UINT16);
13438 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
13439 : : TOKEN_STRING_INITIALIZER
13440 : : (struct cmd_set_port_fec_mode,
13441 : : fec_mode, "fec_mode");
13442 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
13443 : : TOKEN_STRING_INITIALIZER
13444 : : (struct cmd_set_port_fec_mode,
13445 : : fec_value, NULL);
13446 : :
13447 : : static void
13448 : 0 : cmd_set_port_fec_mode_parsed(
13449 : : void *parsed_result,
13450 : : __rte_unused struct cmdline *cl,
13451 : : __rte_unused void *data)
13452 : : {
13453 : : struct cmd_set_port_fec_mode *res = parsed_result;
13454 : 0 : uint16_t port_id = res->port_id;
13455 : : uint32_t fec_capa;
13456 : : int ret;
13457 : :
13458 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
13459 : 0 : if (ret < 0) {
13460 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
13461 : : res->fec_value, port_id);
13462 : 0 : return;
13463 : : }
13464 : :
13465 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
13466 : 0 : if (ret == -ENOTSUP) {
13467 : 0 : fprintf(stderr, "Function not implemented\n");
13468 : 0 : return;
13469 : 0 : } else if (ret < 0) {
13470 : 0 : fprintf(stderr, "Set FEC mode failed\n");
13471 : 0 : return;
13472 : : }
13473 : : }
13474 : :
13475 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
13476 : : .f = cmd_set_port_fec_mode_parsed,
13477 : : .data = NULL,
13478 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
13479 : : .tokens = {
13480 : : (void *)&cmd_set_port_fec_mode_set,
13481 : : (void *)&cmd_set_port_fec_mode_port,
13482 : : (void *)&cmd_set_port_fec_mode_port_id,
13483 : : (void *)&cmd_set_port_fec_mode_str,
13484 : : (void *)&cmd_set_port_fec_mode_value,
13485 : : NULL,
13486 : : },
13487 : : };
13488 : :
13489 : : /* *** set available descriptors threshold for an RxQ of a port *** */
13490 : : struct cmd_set_rxq_avail_thresh_result {
13491 : : cmdline_fixed_string_t set;
13492 : : cmdline_fixed_string_t port;
13493 : : uint16_t port_num;
13494 : : cmdline_fixed_string_t rxq;
13495 : : uint16_t rxq_num;
13496 : : cmdline_fixed_string_t avail_thresh;
13497 : : uint8_t avail_thresh_num;
13498 : : };
13499 : :
13500 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
13501 : : __rte_unused struct cmdline *cl,
13502 : : __rte_unused void *data)
13503 : : {
13504 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
13505 : : int ret = 0;
13506 : :
13507 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
13508 : 0 : && (strcmp(res->rxq, "rxq") == 0)
13509 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
13510 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
13511 : 0 : res->avail_thresh_num);
13512 : 0 : if (ret < 0)
13513 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
13514 : :
13515 : 0 : }
13516 : :
13517 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
13518 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13519 : : set, "set");
13520 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
13521 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13522 : : port, "port");
13523 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
13524 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13525 : : port_num, RTE_UINT16);
13526 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
13527 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13528 : : rxq, "rxq");
13529 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
13530 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13531 : : rxq_num, RTE_UINT16);
13532 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
13533 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13534 : : avail_thresh, "avail_thresh");
13535 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
13536 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13537 : : avail_thresh_num, RTE_UINT8);
13538 : :
13539 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
13540 : : .f = cmd_set_rxq_avail_thresh_parsed,
13541 : : .data = (void *)0,
13542 : : .help_str =
13543 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
13544 : : "Set available descriptors threshold for Rx queue",
13545 : : .tokens = {
13546 : : (void *)&cmd_set_rxq_avail_thresh_set,
13547 : : (void *)&cmd_set_rxq_avail_thresh_port,
13548 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
13549 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
13550 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
13551 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
13552 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
13553 : : NULL,
13554 : : },
13555 : : };
13556 : :
13557 : : /* show port supported ptypes */
13558 : :
13559 : : /* Common result structure for show port ptypes */
13560 : : struct cmd_show_port_supported_ptypes_result {
13561 : : cmdline_fixed_string_t show;
13562 : : cmdline_fixed_string_t port;
13563 : : portid_t port_id;
13564 : : cmdline_fixed_string_t ptypes;
13565 : : };
13566 : :
13567 : : /* Common CLI fields for show port ptypes */
13568 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
13569 : : TOKEN_STRING_INITIALIZER
13570 : : (struct cmd_show_port_supported_ptypes_result,
13571 : : show, "show");
13572 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
13573 : : TOKEN_STRING_INITIALIZER
13574 : : (struct cmd_show_port_supported_ptypes_result,
13575 : : port, "port");
13576 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
13577 : : TOKEN_NUM_INITIALIZER
13578 : : (struct cmd_show_port_supported_ptypes_result,
13579 : : port_id, RTE_UINT16);
13580 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
13581 : : TOKEN_STRING_INITIALIZER
13582 : : (struct cmd_show_port_supported_ptypes_result,
13583 : : ptypes, "ptypes");
13584 : :
13585 : : static void
13586 : 0 : cmd_show_port_supported_ptypes_parsed(
13587 : : void *parsed_result,
13588 : : __rte_unused struct cmdline *cl,
13589 : : __rte_unused void *data)
13590 : : {
13591 : : #define RSVD_PTYPE_MASK 0xf0000000
13592 : : #define MAX_PTYPES_PER_LAYER 16
13593 : : #define LTYPE_NAMESIZE 32
13594 : : #define PTYPE_NAMESIZE 256
13595 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
13596 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
13597 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
13598 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
13599 : 0 : uint16_t port_id = res->port_id;
13600 : : int ret, i;
13601 : :
13602 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
13603 : 0 : if (ret < 0)
13604 : 0 : return;
13605 : :
13606 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
13607 : :
13608 : 0 : switch (ptype_mask) {
13609 : : case RTE_PTYPE_L2_MASK:
13610 : : strlcpy(ltype, "L2", sizeof(ltype));
13611 : : break;
13612 : : case RTE_PTYPE_L3_MASK:
13613 : : strlcpy(ltype, "L3", sizeof(ltype));
13614 : : break;
13615 : : case RTE_PTYPE_L4_MASK:
13616 : : strlcpy(ltype, "L4", sizeof(ltype));
13617 : : break;
13618 : : case RTE_PTYPE_TUNNEL_MASK:
13619 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
13620 : : break;
13621 : : case RTE_PTYPE_INNER_L2_MASK:
13622 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
13623 : : break;
13624 : : case RTE_PTYPE_INNER_L3_MASK:
13625 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
13626 : : break;
13627 : : case RTE_PTYPE_INNER_L4_MASK:
13628 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
13629 : : break;
13630 : : default:
13631 : : return;
13632 : : }
13633 : :
13634 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
13635 : : ptype_mask, ptypes,
13636 : : MAX_PTYPES_PER_LAYER);
13637 : :
13638 : 0 : if (ret > 0)
13639 : : printf("Supported %s ptypes:\n", ltype);
13640 : : else
13641 : : printf("%s ptypes unsupported\n", ltype);
13642 : :
13643 : 0 : for (i = 0; i < ret; ++i) {
13644 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
13645 : : printf("%s\n", buf);
13646 : : }
13647 : :
13648 : 0 : ptype_mask <<= 4;
13649 : : }
13650 : : }
13651 : :
13652 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
13653 : : .f = cmd_show_port_supported_ptypes_parsed,
13654 : : .data = NULL,
13655 : : .help_str = "show port <port_id> ptypes",
13656 : : .tokens = {
13657 : : (void *)&cmd_show_port_supported_ptypes_show,
13658 : : (void *)&cmd_show_port_supported_ptypes_port,
13659 : : (void *)&cmd_show_port_supported_ptypes_port_id,
13660 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
13661 : : NULL,
13662 : : },
13663 : : };
13664 : :
13665 : : /* *** display rx/tx descriptor status *** */
13666 : : struct cmd_show_rx_tx_desc_status_result {
13667 : : cmdline_fixed_string_t cmd_show;
13668 : : cmdline_fixed_string_t cmd_port;
13669 : : cmdline_fixed_string_t cmd_keyword;
13670 : : cmdline_fixed_string_t cmd_desc;
13671 : : cmdline_fixed_string_t cmd_status;
13672 : : portid_t cmd_pid;
13673 : : portid_t cmd_qid;
13674 : : portid_t cmd_did;
13675 : : };
13676 : :
13677 : : static void
13678 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
13679 : : __rte_unused struct cmdline *cl,
13680 : : __rte_unused void *data)
13681 : : {
13682 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
13683 : : int rc;
13684 : :
13685 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
13686 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13687 : 0 : fprintf(stderr,
13688 : : "Invalid input: port id = %d, queue id = %d\n",
13689 : 0 : res->cmd_pid, res->cmd_qid);
13690 : 0 : return;
13691 : : }
13692 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
13693 : 0 : res->cmd_did);
13694 : 0 : if (rc < 0) {
13695 : 0 : fprintf(stderr,
13696 : : "Invalid input: queue id = %d, desc id = %d\n",
13697 : 0 : res->cmd_qid, res->cmd_did);
13698 : 0 : return;
13699 : : }
13700 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
13701 : : printf("Desc status = AVAILABLE\n");
13702 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
13703 : : printf("Desc status = DONE\n");
13704 : : else
13705 : : printf("Desc status = UNAVAILABLE\n");
13706 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
13707 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13708 : 0 : fprintf(stderr,
13709 : : "Invalid input: port id = %d, queue id = %d\n",
13710 : 0 : res->cmd_pid, res->cmd_qid);
13711 : 0 : return;
13712 : : }
13713 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
13714 : 0 : res->cmd_did);
13715 : 0 : if (rc < 0) {
13716 : 0 : fprintf(stderr,
13717 : : "Invalid input: queue id = %d, desc id = %d\n",
13718 : 0 : res->cmd_qid, res->cmd_did);
13719 : 0 : return;
13720 : : }
13721 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
13722 : : printf("Desc status = FULL\n");
13723 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
13724 : : printf("Desc status = DONE\n");
13725 : : else
13726 : : printf("Desc status = UNAVAILABLE\n");
13727 : : }
13728 : : }
13729 : :
13730 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
13731 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13732 : : cmd_show, "show");
13733 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
13734 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13735 : : cmd_port, "port");
13736 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
13737 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13738 : : cmd_pid, RTE_UINT16);
13739 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
13740 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13741 : : cmd_keyword, "rxq#txq");
13742 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
13743 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13744 : : cmd_qid, RTE_UINT16);
13745 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
13746 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13747 : : cmd_desc, "desc");
13748 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
13749 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13750 : : cmd_did, RTE_UINT16);
13751 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
13752 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13753 : : cmd_status, "status");
13754 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
13755 : : .f = cmd_show_rx_tx_desc_status_parsed,
13756 : : .data = NULL,
13757 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
13758 : : "status",
13759 : : .tokens = {
13760 : : (void *)&cmd_show_rx_tx_desc_status_show,
13761 : : (void *)&cmd_show_rx_tx_desc_status_port,
13762 : : (void *)&cmd_show_rx_tx_desc_status_pid,
13763 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
13764 : : (void *)&cmd_show_rx_tx_desc_status_qid,
13765 : : (void *)&cmd_show_rx_tx_desc_status_desc,
13766 : : (void *)&cmd_show_rx_tx_desc_status_did,
13767 : : (void *)&cmd_show_rx_tx_desc_status_status,
13768 : : NULL,
13769 : : },
13770 : : };
13771 : :
13772 : : /* *** display rx/tx queue descriptor used count *** */
13773 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
13774 : : cmdline_fixed_string_t cmd_show;
13775 : : cmdline_fixed_string_t cmd_port;
13776 : : cmdline_fixed_string_t cmd_dir;
13777 : : cmdline_fixed_string_t cmd_desc;
13778 : : cmdline_fixed_string_t cmd_used;
13779 : : cmdline_fixed_string_t cmd_count;
13780 : : portid_t cmd_pid;
13781 : : portid_t cmd_qid;
13782 : : };
13783 : :
13784 : : static void
13785 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
13786 : : __rte_unused void *data)
13787 : : {
13788 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
13789 : : int rc;
13790 : :
13791 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
13792 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13793 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13794 : 0 : res->cmd_pid, res->cmd_qid);
13795 : 0 : return;
13796 : : }
13797 : :
13798 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
13799 : 0 : if (rc < 0) {
13800 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
13801 : 0 : res->cmd_qid);
13802 : 0 : return;
13803 : : }
13804 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
13805 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
13806 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13807 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13808 : 0 : res->cmd_pid, res->cmd_qid);
13809 : 0 : return;
13810 : : }
13811 : :
13812 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
13813 : 0 : if (rc < 0) {
13814 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
13815 : 0 : res->cmd_qid);
13816 : 0 : return;
13817 : : }
13818 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
13819 : : }
13820 : : }
13821 : :
13822 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
13823 : : TOKEN_STRING_INITIALIZER
13824 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13825 : : cmd_show, "show");
13826 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
13827 : : TOKEN_STRING_INITIALIZER
13828 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13829 : : cmd_port, "port");
13830 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
13831 : : TOKEN_NUM_INITIALIZER
13832 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13833 : : cmd_pid, RTE_UINT16);
13834 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
13835 : : TOKEN_STRING_INITIALIZER
13836 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13837 : : cmd_dir, "rxq#txq");
13838 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
13839 : : TOKEN_NUM_INITIALIZER
13840 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13841 : : cmd_qid, RTE_UINT16);
13842 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
13843 : : TOKEN_STRING_INITIALIZER
13844 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13845 : : cmd_desc, "desc");
13846 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
13847 : : TOKEN_STRING_INITIALIZER
13848 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13849 : : cmd_count, "used");
13850 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
13851 : : TOKEN_STRING_INITIALIZER
13852 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13853 : : cmd_count, "count");
13854 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
13855 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
13856 : : .data = NULL,
13857 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
13858 : : .tokens = {
13859 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
13860 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
13861 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
13862 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
13863 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
13864 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
13865 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
13866 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
13867 : : NULL,
13868 : : },
13869 : : };
13870 : :
13871 : : /* Common result structure for set port ptypes */
13872 : : struct cmd_set_port_ptypes_result {
13873 : : cmdline_fixed_string_t set;
13874 : : cmdline_fixed_string_t port;
13875 : : portid_t port_id;
13876 : : cmdline_fixed_string_t ptype_mask;
13877 : : uint32_t mask;
13878 : : };
13879 : :
13880 : : /* Common CLI fields for set port ptypes */
13881 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
13882 : : TOKEN_STRING_INITIALIZER
13883 : : (struct cmd_set_port_ptypes_result,
13884 : : set, "set");
13885 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
13886 : : TOKEN_STRING_INITIALIZER
13887 : : (struct cmd_set_port_ptypes_result,
13888 : : port, "port");
13889 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
13890 : : TOKEN_NUM_INITIALIZER
13891 : : (struct cmd_set_port_ptypes_result,
13892 : : port_id, RTE_UINT16);
13893 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
13894 : : TOKEN_STRING_INITIALIZER
13895 : : (struct cmd_set_port_ptypes_result,
13896 : : ptype_mask, "ptype_mask");
13897 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
13898 : : TOKEN_NUM_INITIALIZER
13899 : : (struct cmd_set_port_ptypes_result,
13900 : : mask, RTE_UINT32);
13901 : :
13902 : : static void
13903 : 0 : cmd_set_port_ptypes_parsed(
13904 : : void *parsed_result,
13905 : : __rte_unused struct cmdline *cl,
13906 : : __rte_unused void *data)
13907 : : {
13908 : : struct cmd_set_port_ptypes_result *res = parsed_result;
13909 : : #define PTYPE_NAMESIZE 256
13910 : : char ptype_name[PTYPE_NAMESIZE];
13911 : 0 : uint16_t port_id = res->port_id;
13912 : 0 : uint32_t ptype_mask = res->mask;
13913 : : int ret, i;
13914 : :
13915 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
13916 : : NULL, 0);
13917 : 0 : if (ret <= 0) {
13918 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
13919 : : port_id);
13920 : 0 : return;
13921 : : }
13922 : :
13923 : 0 : uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
13924 : :
13925 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
13926 : 0 : if (ret < 0) {
13927 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
13928 : : port_id);
13929 : 0 : return;
13930 : : }
13931 : :
13932 : : printf("Successfully set following ptypes for Port %d\n", port_id);
13933 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
13934 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
13935 : : printf("%s\n", ptype_name);
13936 : : }
13937 : :
13938 : 0 : clear_ptypes = false;
13939 : : }
13940 : :
13941 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
13942 : : .f = cmd_set_port_ptypes_parsed,
13943 : : .data = NULL,
13944 : : .help_str = "set port <port_id> ptype_mask <mask>",
13945 : : .tokens = {
13946 : : (void *)&cmd_set_port_ptypes_set,
13947 : : (void *)&cmd_set_port_ptypes_port,
13948 : : (void *)&cmd_set_port_ptypes_port_id,
13949 : : (void *)&cmd_set_port_ptypes_mask_str,
13950 : : (void *)&cmd_set_port_ptypes_mask_u32,
13951 : : NULL,
13952 : : },
13953 : : };
13954 : :
13955 : : /* *** display mac addresses added to a port *** */
13956 : : struct cmd_showport_macs_result {
13957 : : cmdline_fixed_string_t cmd_show;
13958 : : cmdline_fixed_string_t cmd_port;
13959 : : cmdline_fixed_string_t cmd_keyword;
13960 : : portid_t cmd_pid;
13961 : : };
13962 : :
13963 : : static void
13964 : 0 : cmd_showport_macs_parsed(void *parsed_result,
13965 : : __rte_unused struct cmdline *cl,
13966 : : __rte_unused void *data)
13967 : : {
13968 : : struct cmd_showport_macs_result *res = parsed_result;
13969 : :
13970 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
13971 : : return;
13972 : :
13973 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
13974 : 0 : show_macs(res->cmd_pid);
13975 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
13976 : 0 : show_mcast_macs(res->cmd_pid);
13977 : : }
13978 : :
13979 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
13980 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13981 : : cmd_show, "show");
13982 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
13983 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13984 : : cmd_port, "port");
13985 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
13986 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
13987 : : cmd_pid, RTE_UINT16);
13988 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
13989 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13990 : : cmd_keyword, "macs#mcast_macs");
13991 : :
13992 : : static cmdline_parse_inst_t cmd_showport_macs = {
13993 : : .f = cmd_showport_macs_parsed,
13994 : : .data = NULL,
13995 : : .help_str = "show port <port_id> macs|mcast_macs",
13996 : : .tokens = {
13997 : : (void *)&cmd_showport_macs_show,
13998 : : (void *)&cmd_showport_macs_port,
13999 : : (void *)&cmd_showport_macs_pid,
14000 : : (void *)&cmd_showport_macs_keyword,
14001 : : NULL,
14002 : : },
14003 : : };
14004 : :
14005 : : /* *** show flow transfer proxy port ID for the given port *** */
14006 : : struct cmd_show_port_flow_transfer_proxy_result {
14007 : : cmdline_fixed_string_t show;
14008 : : cmdline_fixed_string_t port;
14009 : : portid_t port_id;
14010 : : cmdline_fixed_string_t flow;
14011 : : cmdline_fixed_string_t transfer;
14012 : : cmdline_fixed_string_t proxy;
14013 : : };
14014 : :
14015 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
14016 : : TOKEN_STRING_INITIALIZER
14017 : : (struct cmd_show_port_flow_transfer_proxy_result,
14018 : : show, "show");
14019 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
14020 : : TOKEN_STRING_INITIALIZER
14021 : : (struct cmd_show_port_flow_transfer_proxy_result,
14022 : : port, "port");
14023 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
14024 : : TOKEN_NUM_INITIALIZER
14025 : : (struct cmd_show_port_flow_transfer_proxy_result,
14026 : : port_id, RTE_UINT16);
14027 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
14028 : : TOKEN_STRING_INITIALIZER
14029 : : (struct cmd_show_port_flow_transfer_proxy_result,
14030 : : flow, "flow");
14031 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
14032 : : TOKEN_STRING_INITIALIZER
14033 : : (struct cmd_show_port_flow_transfer_proxy_result,
14034 : : transfer, "transfer");
14035 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
14036 : : TOKEN_STRING_INITIALIZER
14037 : : (struct cmd_show_port_flow_transfer_proxy_result,
14038 : : proxy, "proxy");
14039 : :
14040 : : static void
14041 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
14042 : : __rte_unused struct cmdline *cl,
14043 : : __rte_unused void *data)
14044 : : {
14045 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
14046 : : portid_t proxy_port_id;
14047 : : int ret;
14048 : :
14049 : : printf("\n");
14050 : :
14051 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
14052 : 0 : if (ret != 0) {
14053 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
14054 : : rte_strerror(-ret));
14055 : 0 : return;
14056 : : }
14057 : :
14058 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
14059 : : }
14060 : :
14061 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
14062 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
14063 : : .data = NULL,
14064 : : .help_str = "show port <port_id> flow transfer proxy",
14065 : : .tokens = {
14066 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
14067 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
14068 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
14069 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
14070 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
14071 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
14072 : : NULL,
14073 : : }
14074 : : };
14075 : :
14076 : : /* *** configure port txq affinity value *** */
14077 : : struct cmd_config_tx_affinity_map {
14078 : : cmdline_fixed_string_t port;
14079 : : cmdline_fixed_string_t config;
14080 : : portid_t portid;
14081 : : cmdline_fixed_string_t txq;
14082 : : uint16_t qid;
14083 : : cmdline_fixed_string_t affinity;
14084 : : uint8_t value;
14085 : : };
14086 : :
14087 : : static void
14088 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
14089 : : __rte_unused struct cmdline *cl,
14090 : : __rte_unused void *data)
14091 : : {
14092 : : struct cmd_config_tx_affinity_map *res = parsed_result;
14093 : : int ret;
14094 : :
14095 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
14096 : : return;
14097 : :
14098 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
14099 : : printf("Invalid port id\n");
14100 : 0 : return;
14101 : : }
14102 : :
14103 : 0 : if (strcmp(res->txq, "txq")) {
14104 : : printf("Unknown parameter\n");
14105 : 0 : return;
14106 : : }
14107 : 0 : if (tx_queue_id_is_invalid(res->qid))
14108 : : return;
14109 : :
14110 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
14111 : 0 : if (ret < 0) {
14112 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
14113 : : strerror(-ret));
14114 : 0 : return;
14115 : : }
14116 : :
14117 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
14118 : 0 : if (ret != 0) {
14119 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
14120 : : rte_strerror(-ret));
14121 : 0 : return;
14122 : : }
14123 : : }
14124 : :
14125 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
14126 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14127 : : port, "port");
14128 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
14129 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14130 : : config, "config");
14131 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
14132 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14133 : : portid, RTE_UINT16);
14134 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
14135 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14136 : : txq, "txq");
14137 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
14138 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14139 : : qid, RTE_UINT16);
14140 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
14141 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14142 : : affinity, "affinity");
14143 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
14144 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14145 : : value, RTE_UINT8);
14146 : :
14147 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
14148 : : .f = cmd_config_tx_affinity_map_parsed,
14149 : : .data = (void *)0,
14150 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
14151 : : .tokens = {
14152 : : (void *)&cmd_config_tx_affinity_map_port,
14153 : : (void *)&cmd_config_tx_affinity_map_config,
14154 : : (void *)&cmd_config_tx_affinity_map_portid,
14155 : : (void *)&cmd_config_tx_affinity_map_txq,
14156 : : (void *)&cmd_config_tx_affinity_map_qid,
14157 : : (void *)&cmd_config_tx_affinity_map_affinity,
14158 : : (void *)&cmd_config_tx_affinity_map_value,
14159 : : NULL,
14160 : : },
14161 : : };
14162 : :
14163 : : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
14164 : : struct cmd_dev_led_result {
14165 : : cmdline_fixed_string_t set;
14166 : : cmdline_fixed_string_t port;
14167 : : portid_t port_id;
14168 : : cmdline_fixed_string_t led;
14169 : : cmdline_fixed_string_t state;
14170 : : };
14171 : :
14172 : : static void
14173 : 0 : cmd_set_dev_led_parsed(void *parsed_result,
14174 : : __rte_unused struct cmdline *cl,
14175 : : __rte_unused void *data)
14176 : : {
14177 : : struct cmd_dev_led_result *res = parsed_result;
14178 : :
14179 : 0 : if (strcmp(res->state, "on") == 0)
14180 : 0 : set_dev_led(res->port_id, true);
14181 : : else
14182 : 0 : set_dev_led(res->port_id, false);
14183 : 0 : }
14184 : :
14185 : : static cmdline_parse_token_string_t cmd_dev_led_set =
14186 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
14187 : : static cmdline_parse_token_string_t cmd_dev_led_port =
14188 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
14189 : : static cmdline_parse_token_num_t cmd_dev_led_port_id =
14190 : : TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
14191 : : static cmdline_parse_token_string_t cmd_dev_led =
14192 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
14193 : : static cmdline_parse_token_string_t cmd_dev_state =
14194 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
14195 : :
14196 : : static cmdline_parse_inst_t cmd_set_dev_led = {
14197 : : .f = cmd_set_dev_led_parsed,
14198 : : .data = NULL,
14199 : : .help_str = "set port <port_id> led <on/off>",
14200 : : .tokens = {
14201 : : (void *)&cmd_dev_led_set,
14202 : : (void *)&cmd_dev_led_port,
14203 : : (void *)&cmd_dev_led_port_id,
14204 : : (void *)&cmd_dev_led,
14205 : : (void *)&cmd_dev_state,
14206 : : NULL,
14207 : : },
14208 : : };
14209 : :
14210 : : /* ******************************************************************************** */
14211 : :
14212 : : /* list of instructions */
14213 : : static cmdline_parse_ctx_t builtin_ctx[] = {
14214 : : &cmd_help_brief,
14215 : : &cmd_help_long,
14216 : : &cmd_quit,
14217 : : &cmd_load_from_file,
14218 : : &cmd_load_echo_file,
14219 : : &cmd_showport,
14220 : : &cmd_showqueue,
14221 : : &cmd_showeeprom,
14222 : : &cmd_seteeprom,
14223 : : &cmd_showportall,
14224 : : &cmd_representor_info,
14225 : : &cmd_showdevice,
14226 : : &cmd_showcfg,
14227 : : &cmd_showfwdall,
14228 : : &cmd_start,
14229 : : &cmd_start_tx_first,
14230 : : &cmd_start_tx_first_n,
14231 : : &cmd_set_link_up,
14232 : : &cmd_set_link_down,
14233 : : &cmd_reset,
14234 : : &cmd_set_numbers,
14235 : : &cmd_set_log,
14236 : : &cmd_set_rxoffs,
14237 : : &cmd_set_rxpkts,
14238 : : &cmd_set_rxhdrs,
14239 : : &cmd_set_txflows,
14240 : : &cmd_set_txpkts,
14241 : : &cmd_set_txsplit,
14242 : : &cmd_set_txtimes,
14243 : : &cmd_set_fwd_list,
14244 : : &cmd_set_fwd_mask,
14245 : : &cmd_set_fwd_mode,
14246 : : &cmd_set_fwd_retry_mode,
14247 : : &cmd_set_dcb_fwd_tc,
14248 : : &cmd_set_dcb_fwd_tc_cores,
14249 : : &cmd_set_burst_tx_retry,
14250 : : &cmd_set_promisc_mode_one,
14251 : : &cmd_set_promisc_mode_all,
14252 : : &cmd_set_allmulti_mode_one,
14253 : : &cmd_set_allmulti_mode_all,
14254 : : &cmd_set_flush_rx,
14255 : : &cmd_set_link_check,
14256 : : &cmd_vlan_offload,
14257 : : &cmd_vlan_tpid,
14258 : : &cmd_rx_vlan_filter_all,
14259 : : &cmd_rx_vlan_filter,
14260 : : &cmd_tx_vlan_set,
14261 : : &cmd_tx_vlan_set_qinq,
14262 : : &cmd_tx_vlan_reset,
14263 : : &cmd_tx_vlan_set_pvid,
14264 : : &cmd_csum_set,
14265 : : &cmd_csum_show,
14266 : : &cmd_csum_tunnel,
14267 : : &cmd_csum_mac_swap,
14268 : : &cmd_tso_set,
14269 : : &cmd_tso_show,
14270 : : &cmd_tunnel_tso_set,
14271 : : &cmd_tunnel_tso_show,
14272 : : #ifdef RTE_LIB_GRO
14273 : : &cmd_gro_enable,
14274 : : &cmd_gro_flush,
14275 : : &cmd_gro_show,
14276 : : #endif
14277 : : #ifdef RTE_LIB_GSO
14278 : : &cmd_gso_enable,
14279 : : &cmd_gso_size,
14280 : : &cmd_gso_show,
14281 : : #endif
14282 : : &cmd_link_flow_control_set,
14283 : : &cmd_link_flow_control_set_rx,
14284 : : &cmd_link_flow_control_set_tx,
14285 : : &cmd_link_flow_control_set_hw,
14286 : : &cmd_link_flow_control_set_lw,
14287 : : &cmd_link_flow_control_set_pt,
14288 : : &cmd_link_flow_control_set_xon,
14289 : : &cmd_link_flow_control_set_macfwd,
14290 : : &cmd_link_flow_control_set_autoneg,
14291 : : &cmd_link_flow_control_show,
14292 : : &cmd_priority_flow_control_set,
14293 : : &cmd_queue_priority_flow_control_set,
14294 : : &cmd_config_dcb,
14295 : : &cmd_read_rxd_txd,
14296 : : &cmd_stop,
14297 : : &cmd_mac_addr,
14298 : : &cmd_set_fwd_eth_peer,
14299 : : &cmd_set_xstats_hide_zero,
14300 : : &cmd_set_xstats_show_state,
14301 : : &cmd_set_xstats_hide_disabled,
14302 : : &cmd_operate_set_counter,
14303 : : &cmd_set_record_core_cycles,
14304 : : &cmd_set_record_burst_stats,
14305 : : &cmd_operate_port,
14306 : : &cmd_operate_specific_port,
14307 : : &cmd_operate_attach_port,
14308 : : &cmd_operate_detach_port,
14309 : : &cmd_operate_detach_device,
14310 : : &cmd_set_port_setup_on,
14311 : : &cmd_config_speed_all,
14312 : : &cmd_config_speed_specific,
14313 : : &cmd_config_speed_lanes_all,
14314 : : &cmd_config_speed_lanes_specific,
14315 : : &cmd_show_speed_lanes,
14316 : : &cmd_config_loopback_all,
14317 : : &cmd_config_loopback_specific,
14318 : : &cmd_config_rx_tx,
14319 : : &cmd_config_mtu,
14320 : : &cmd_config_max_pkt_len,
14321 : : &cmd_config_max_lro_pkt_size,
14322 : : &cmd_config_rx_mode_flag,
14323 : : &cmd_config_rss,
14324 : : &cmd_config_rxtx_ring_size,
14325 : : &cmd_config_rxtx_queue,
14326 : : &cmd_config_deferred_start_rxtx_queue,
14327 : : &cmd_setup_rxtx_queue,
14328 : : &cmd_config_rss_reta,
14329 : : &cmd_showport_reta,
14330 : : &cmd_showport_macs,
14331 : : &cmd_show_port_flow_transfer_proxy,
14332 : : &cmd_config_burst,
14333 : : &cmd_config_thresh,
14334 : : &cmd_config_threshold,
14335 : : &cmd_set_uc_hash_filter,
14336 : : &cmd_set_uc_all_hash_filter,
14337 : : &cmd_vf_mac_addr_filter,
14338 : : &cmd_queue_rate_limit,
14339 : : &cmd_show_queue_rate_limit,
14340 : : &cmd_tunnel_udp_config,
14341 : : &cmd_showport_rss_hash,
14342 : : &cmd_showport_rss_hash_key,
14343 : : &cmd_showport_rss_hash_algo,
14344 : : &cmd_config_rss_hash_key,
14345 : : &cmd_config_rss_hash_algo,
14346 : : &cmd_cleanup_txq_mbufs,
14347 : : &cmd_dump_simple,
14348 : : &cmd_dump_named,
14349 : : &cmd_dump_mbuf_history_stdout,
14350 : : &cmd_dump_mbuf_history_to_file,
14351 : : &cmd_dump_mbuf_pool_history_stdout,
14352 : : &cmd_dump_mbuf_pool_history_to_file,
14353 : : &cmd_flow,
14354 : : &cmd_show_port_meter_cap,
14355 : : &cmd_add_port_meter_profile_srtcm,
14356 : : &cmd_add_port_meter_profile_trtcm,
14357 : : &cmd_add_port_meter_profile_trtcm_rfc4115,
14358 : : &cmd_del_port_meter_profile,
14359 : : &cmd_create_port_meter,
14360 : : &cmd_enable_port_meter,
14361 : : &cmd_disable_port_meter,
14362 : : &cmd_del_port_meter,
14363 : : &cmd_del_port_meter_policy,
14364 : : &cmd_set_port_meter_profile,
14365 : : &cmd_set_port_meter_dscp_table,
14366 : : &cmd_set_port_meter_vlan_table,
14367 : : &cmd_set_port_meter_in_proto,
14368 : : &cmd_get_port_meter_in_proto,
14369 : : &cmd_get_port_meter_in_proto_prio,
14370 : : &cmd_set_port_meter_stats_mask,
14371 : : &cmd_show_port_meter_stats,
14372 : : &cmd_mcast_addr,
14373 : : &cmd_mcast_addr_flush,
14374 : : &cmd_set_vf_vlan_anti_spoof,
14375 : : &cmd_set_vf_mac_anti_spoof,
14376 : : &cmd_set_vf_vlan_stripq,
14377 : : &cmd_set_vf_vlan_insert,
14378 : : &cmd_set_tx_loopback,
14379 : : &cmd_set_all_queues_drop_en,
14380 : : &cmd_set_vf_traffic,
14381 : : &cmd_set_vf_rxmode,
14382 : : &cmd_vf_rate_limit,
14383 : : &cmd_vf_rxvlan_filter,
14384 : : &cmd_set_vf_mac_addr,
14385 : : &cmd_set_vxlan,
14386 : : &cmd_set_vxlan_tos_ttl,
14387 : : &cmd_set_vxlan_with_vlan,
14388 : : &cmd_set_nvgre,
14389 : : &cmd_set_nvgre_with_vlan,
14390 : : &cmd_set_l2_encap,
14391 : : &cmd_set_l2_encap_with_vlan,
14392 : : &cmd_set_l2_decap,
14393 : : &cmd_set_l2_decap_with_vlan,
14394 : : &cmd_set_mplsogre_encap,
14395 : : &cmd_set_mplsogre_encap_with_vlan,
14396 : : &cmd_set_mplsogre_decap,
14397 : : &cmd_set_mplsogre_decap_with_vlan,
14398 : : &cmd_set_mplsoudp_encap,
14399 : : &cmd_set_mplsoudp_encap_with_vlan,
14400 : : &cmd_set_mplsoudp_decap,
14401 : : &cmd_set_mplsoudp_decap_with_vlan,
14402 : : &cmd_set_conntrack_common,
14403 : : &cmd_set_conntrack_dir,
14404 : : &cmd_show_vf_stats,
14405 : : &cmd_clear_vf_stats,
14406 : : &cmd_show_port_supported_ptypes,
14407 : : &cmd_set_port_ptypes,
14408 : : &cmd_show_port_tm_cap,
14409 : : &cmd_show_port_tm_level_cap,
14410 : : &cmd_show_port_tm_node,
14411 : : &cmd_show_port_tm_node_cap,
14412 : : &cmd_show_port_tm_node_type,
14413 : : &cmd_show_port_tm_node_stats,
14414 : : &cmd_add_port_tm_node_shaper_profile,
14415 : : &cmd_del_port_tm_node_shaper_profile,
14416 : : &cmd_add_port_tm_node_shared_shaper,
14417 : : &cmd_del_port_tm_node_shared_shaper,
14418 : : &cmd_add_port_tm_node_wred_profile,
14419 : : &cmd_del_port_tm_node_wred_profile,
14420 : : &cmd_set_port_tm_node_shaper_profile,
14421 : : &cmd_add_port_tm_nonleaf_node,
14422 : : &cmd_add_port_tm_nonleaf_node_pmode,
14423 : : &cmd_add_port_tm_leaf_node,
14424 : : &cmd_del_port_tm_node,
14425 : : &cmd_set_port_tm_node_parent,
14426 : : &cmd_suspend_port_tm_node,
14427 : : &cmd_resume_port_tm_node,
14428 : : &cmd_port_tm_hierarchy_commit,
14429 : : &cmd_port_tm_mark_ip_ecn,
14430 : : &cmd_port_tm_mark_ip_dscp,
14431 : : &cmd_port_tm_mark_vlan_dei,
14432 : : &cmd_cfg_tunnel_udp_port,
14433 : : &cmd_rx_offload_get_capa,
14434 : : &cmd_rx_offload_get_configuration,
14435 : : &cmd_config_per_port_rx_offload,
14436 : : &cmd_config_all_port_rx_offload,
14437 : : &cmd_config_per_queue_rx_offload,
14438 : : &cmd_tx_offload_get_capa,
14439 : : &cmd_tx_offload_get_configuration,
14440 : : &cmd_config_per_port_tx_offload,
14441 : : &cmd_config_all_port_tx_offload,
14442 : : &cmd_config_per_queue_tx_offload,
14443 : : #ifdef RTE_LIB_BPF
14444 : : &cmd_operate_bpf_ld_parse,
14445 : : &cmd_operate_bpf_unld_parse,
14446 : : #endif
14447 : : &cmd_config_tx_metadata_specific,
14448 : : &cmd_show_tx_metadata,
14449 : : &cmd_show_rx_tx_desc_status,
14450 : : &cmd_show_rx_tx_queue_desc_used_count,
14451 : : &cmd_set_raw,
14452 : : &cmd_show_set_raw,
14453 : : &cmd_show_set_raw_all,
14454 : : &cmd_config_tx_dynf_specific,
14455 : : &cmd_show_fec_mode,
14456 : : &cmd_set_fec_mode,
14457 : : &cmd_set_rxq_avail_thresh,
14458 : : &cmd_show_capability,
14459 : : &cmd_set_flex_is_pattern,
14460 : : &cmd_set_flex_spec_pattern,
14461 : : &cmd_show_port_cman_capa,
14462 : : &cmd_show_port_cman_config,
14463 : : &cmd_set_port_cman_config,
14464 : : &cmd_config_tx_affinity_map,
14465 : : &cmd_set_dev_led,
14466 : : NULL,
14467 : : };
14468 : :
14469 : : void
14470 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
14471 : : {
14472 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
14473 : 0 : }
14474 : :
14475 : : int
14476 : 0 : init_cmdline(void)
14477 : : {
14478 : : struct testpmd_driver_commands *c;
14479 : : unsigned int count;
14480 : : unsigned int i;
14481 : :
14482 : : /* initialize non-constant commands */
14483 : 0 : cmd_set_fwd_mode_init();
14484 : 0 : cmd_set_fwd_retry_mode_init();
14485 : :
14486 : : count = 0;
14487 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
14488 : 0 : count++;
14489 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14490 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
14491 : 0 : count++;
14492 : : }
14493 : :
14494 : : /* cmdline expects a NULL terminated array */
14495 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
14496 : 0 : if (main_ctx == NULL)
14497 : : return -1;
14498 : :
14499 : : count = 0;
14500 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
14501 : 0 : main_ctx[count] = builtin_ctx[i];
14502 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14503 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
14504 : 0 : main_ctx[count] = c->commands[i].ctx;
14505 : : }
14506 : :
14507 : : return 0;
14508 : : }
14509 : :
14510 : : /* read cmdline commands from file */
14511 : : int
14512 : 0 : cmdline_read_from_file(const char *filename, bool echo)
14513 : : {
14514 : : struct cmdline *cl;
14515 : : int fd = -1;
14516 : : int ret = 0;
14517 : :
14518 : : /* cmdline_file_new does not produce any output
14519 : : * so when echoing is requested we open filename directly
14520 : : * and then pass that to cmdline_new with stdout as the output path.
14521 : : */
14522 : 0 : if (!echo) {
14523 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14524 : : } else {
14525 : : /* use basename(filename) as prompt */
14526 : 0 : char prompt[32] = "[] ";
14527 : :
14528 : 0 : rte_basename(filename, &prompt[1], sizeof(prompt) - strlen(prompt));
14529 : 0 : strlcat(prompt, "] ", sizeof(prompt));
14530 : :
14531 : : fd = open(filename, O_RDONLY);
14532 : 0 : if (fd < 0) {
14533 : 0 : fprintf(stderr, "Failed to open file %s: %s\n",
14534 : 0 : filename, strerror(errno));
14535 : 0 : return -1;
14536 : : }
14537 : :
14538 : 0 : cl = cmdline_new(main_ctx, prompt, fd, STDOUT_FILENO);
14539 : : }
14540 : 0 : if (cl == NULL) {
14541 : 0 : fprintf(stderr,
14542 : : "Failed to create file based cmdline context: %s\n",
14543 : : filename);
14544 : : ret = -1;
14545 : 0 : goto end;
14546 : : }
14547 : :
14548 : 0 : cmdline_interact(cl);
14549 : : /* when done, if we have echo, we only need to print end of file,
14550 : : * but if no echo, we need to use printf and include the filename.
14551 : : */
14552 : 0 : if (echo)
14553 : 0 : cmdline_printf(cl, "<End-Of-File>\n");
14554 : : else
14555 : : printf("Finished reading CLI commands from %s\n", filename);
14556 : :
14557 : 0 : cmdline_quit(cl);
14558 : 0 : cmdline_free(cl);
14559 : :
14560 : :
14561 : 0 : end:
14562 : 0 : if (fd >= 0)
14563 : 0 : close(fd);
14564 : : return ret;
14565 : : }
14566 : :
14567 : : void
14568 : 0 : prompt_exit(void)
14569 : : {
14570 : 0 : cmdline_quit(testpmd_cl);
14571 : 0 : }
14572 : :
14573 : : /* prompt function, called from main on MAIN lcore */
14574 : : void
14575 : 0 : prompt(void)
14576 : : {
14577 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14578 : 0 : if (testpmd_cl == NULL) {
14579 : 0 : fprintf(stderr,
14580 : : "Failed to create stdin based cmdline context\n");
14581 : 0 : return;
14582 : : }
14583 : :
14584 : 0 : cmdline_interact(testpmd_cl);
14585 : 0 : cmdline_stdin_exit(testpmd_cl);
14586 : : }
14587 : :
14588 : : void
14589 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14590 : : {
14591 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
14592 : : portid_t pid;
14593 : :
14594 : 0 : RTE_ETH_FOREACH_DEV(pid) {
14595 : : /* check if need_reconfig has been set to 1 */
14596 : 0 : if (ports[pid].need_reconfig == 0)
14597 : 0 : ports[pid].need_reconfig = dev;
14598 : : /* check if need_reconfig_queues has been set to 1 */
14599 : 0 : if (ports[pid].need_reconfig_queues == 0)
14600 : 0 : ports[pid].need_reconfig_queues = queue;
14601 : : }
14602 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14603 : : /* check if need_reconfig has been set to 1 */
14604 : 0 : if (ports[id].need_reconfig == 0)
14605 : 0 : ports[id].need_reconfig = dev;
14606 : : /* check if need_reconfig_queues has been set to 1 */
14607 : 0 : if (ports[id].need_reconfig_queues == 0)
14608 : 0 : ports[id].need_reconfig_queues = queue;
14609 : : }
14610 : 0 : }
|