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_id[, vlan_id_outer]\n"
451 : : " Set hardware insertion of VLAN IDs (single or double VLAN "
452 : : "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
453 : :
454 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
455 : : " Set port based TX VLAN insertion.\n\n"
456 : :
457 : : "tx_vlan reset (port_id)\n"
458 : : " Disable hardware insertion of a VLAN header in"
459 : : " packets sent on a port.\n\n"
460 : :
461 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
462 : : " Select hardware or software calculation of the"
463 : : " checksum when transmitting a packet using the"
464 : : " csum forward engine.\n"
465 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
466 : : " outer-ip concerns the outer IP layer in"
467 : : " outer-udp concerns the outer UDP layer in"
468 : : " case the packet is recognized as a tunnel packet by"
469 : : " the forward engine (vxlan, gre and ipip are supported)\n"
470 : : " Please check the NIC datasheet for HW limits.\n\n"
471 : :
472 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
473 : : " If disabled, treat tunnel packets as non-tunneled"
474 : : " packets (treat inner headers as payload). The port\n"
475 : : " argument is the port used for TX in csum forward"
476 : : " engine.\n\n"
477 : :
478 : : "csum show (port_id)\n"
479 : : " Display tx checksum offload configuration\n\n"
480 : :
481 : : "tso set (segsize) (portid)\n"
482 : : " Enable TCP Segmentation Offload in csum forward"
483 : : " engine.\n"
484 : : " Please check the NIC datasheet for HW limits.\n\n"
485 : :
486 : : "tso show (portid)"
487 : : " Display the status of TCP Segmentation Offload.\n\n"
488 : :
489 : : #ifdef RTE_LIB_GRO
490 : : "set port (port_id) gro on|off\n"
491 : : " Enable or disable Generic Receive Offload in"
492 : : " csum forwarding engine.\n\n"
493 : :
494 : : "show port (port_id) gro\n"
495 : : " Display GRO configuration.\n\n"
496 : :
497 : : "set gro flush (cycles)\n"
498 : : " Set the cycle to flush GROed packets from"
499 : : " reassembly tables.\n\n"
500 : : #endif
501 : :
502 : : #ifdef RTE_LIB_GSO
503 : : "set port (port_id) gso (on|off)"
504 : : " Enable or disable Generic Segmentation Offload in"
505 : : " csum forwarding engine.\n\n"
506 : :
507 : : "set gso segsz (length)\n"
508 : : " Set max packet length for output GSO segments,"
509 : : " including packet header and payload.\n\n"
510 : :
511 : : "show port (port_id) gso\n"
512 : : " Show GSO configuration.\n\n"
513 : : #endif
514 : :
515 : : "set fwd (%s)\n"
516 : : " Set packet forwarding mode.\n\n"
517 : :
518 : : "set dcb fwd_tc (tc_mask)\n"
519 : : " Set DCB forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled\n\n"
520 : :
521 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
522 : : " Add a MAC address on port_id.\n\n"
523 : :
524 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
525 : : " Remove a MAC address from port_id.\n\n"
526 : :
527 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
528 : : " Set the default MAC address for port_id.\n\n"
529 : :
530 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
531 : : " Add a MAC address for a VF on the port.\n\n"
532 : :
533 : : "mcast_addr add (port_id) (mcast_addr)\n"
534 : : " Add a multicast MAC addresses on port_id.\n\n"
535 : :
536 : : "mcast_addr remove (port_id) (mcast_addr)\n"
537 : : " Remove a multicast MAC address from port_id.\n\n"
538 : :
539 : : "mcast_addr flush (port_id)\n"
540 : : " Flush all multicast MAC addresses on port_id.\n\n"
541 : :
542 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
543 : : " Set the MAC address for a VF from the PF.\n\n"
544 : :
545 : : "set eth-peer (port_id) (peer_addr)\n"
546 : : " set the peer address for certain port.\n\n"
547 : :
548 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
549 : : " Add/Remove a or all unicast hash filter(s)"
550 : : "from port X.\n\n"
551 : :
552 : : "set promisc (port_id|all) (on|off)\n"
553 : : " Set the promiscuous mode on port_id, or all.\n\n"
554 : :
555 : : "set allmulti (port_id|all) (on|off)\n"
556 : : " Set the allmulti mode on port_id, or all.\n\n"
557 : :
558 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
559 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
560 : : " (on|off) autoneg (on|off) (port_id)\n"
561 : : "set flow_ctrl rx (on|off) (portid)\n"
562 : : "set flow_ctrl tx (on|off) (portid)\n"
563 : : "set flow_ctrl high_water (high_water) (portid)\n"
564 : : "set flow_ctrl low_water (low_water) (portid)\n"
565 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
566 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
567 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
568 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
569 : : " Set the link flow control parameter on a port.\n\n"
570 : :
571 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
572 : : " (low_water) (pause_time) (priority) (port_id)\n"
573 : : " Set the priority flow control parameter on a"
574 : : " port.\n\n"
575 : :
576 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
577 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
578 : : " Set the queue priority flow control parameter on a"
579 : : " given Rx and Tx queues of a port.\n\n"
580 : :
581 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
582 : : " set available descriptors threshold for Rx queue\n\n"
583 : :
584 : : "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
585 : : " Set statistics mapping (qmapping 0..15) for RX/TX"
586 : : " queue on port.\n"
587 : : " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
588 : : " on port 0 to mapping 5.\n\n"
589 : :
590 : : "set xstats-hide-zero on|off\n"
591 : : " Set the option to hide the zero values"
592 : : " for xstats display.\n"
593 : :
594 : : "set record-core-cycles on|off\n"
595 : : " Set the option to enable measurement of CPU cycles.\n"
596 : :
597 : : "set record-burst-stats on|off\n"
598 : : " Set the option to enable display of RX and TX bursts.\n"
599 : :
600 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
601 : : " Enable/Disable a VF receive/transmit from a port\n\n"
602 : :
603 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
604 : : "|MPE) (on|off)\n"
605 : : " AUPE:accepts untagged VLAN;"
606 : : "ROPE:accept unicast hash\n\n"
607 : : " BAM:accepts broadcast packets;"
608 : : "MPE:accepts all multicast packets\n\n"
609 : : " Enable/Disable a VF receive mode of a port\n\n"
610 : :
611 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
612 : : " Set rate limit for a queue of a port\n\n"
613 : :
614 : : "set port (port_id) vf (vf_id) rate (rate_num) "
615 : : "queue_mask (queue_mask_value)\n"
616 : : " Set rate limit for queues in VF of a port\n\n"
617 : :
618 : : "set flush_rx (on|off)\n"
619 : : " Flush (default) or don't flush RX streams before"
620 : : " forwarding. Mainly used with PCAP drivers.\n\n"
621 : :
622 : : "set link-up port (port_id)\n"
623 : : " Set link up for a port.\n\n"
624 : :
625 : : "set link-down port (port_id)\n"
626 : : " Set link down for a port.\n\n"
627 : :
628 : : "set port (port_id) ptype_mask (ptype_mask)\n"
629 : : " set packet types classification for a specific port\n\n"
630 : :
631 : : "show port meter cap (port_id)\n"
632 : : " Show port meter capability information\n\n"
633 : :
634 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
635 : : " meter profile add - srtcm rfc 2697\n\n"
636 : :
637 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
638 : : " meter profile add - trtcm rfc 2698\n\n"
639 : :
640 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
641 : : " meter profile add - trtcm rfc 4115\n\n"
642 : :
643 : : "del port meter profile (port_id) (profile_id)\n"
644 : : " meter profile delete\n\n"
645 : :
646 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
647 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
648 : : "(dscp_tbl_entry63)]\n"
649 : : " meter create\n\n"
650 : :
651 : : "enable port meter (port_id) (mtr_id)\n"
652 : : " meter enable\n\n"
653 : :
654 : : "disable port meter (port_id) (mtr_id)\n"
655 : : " meter disable\n\n"
656 : :
657 : : "del port meter (port_id) (mtr_id)\n"
658 : : " meter delete\n\n"
659 : :
660 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
661 : : "y_actions (actions) r_actions (actions)\n"
662 : : " meter policy add\n\n"
663 : :
664 : : "del port meter policy (port_id) (policy_id)\n"
665 : : " meter policy delete\n\n"
666 : :
667 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
668 : : " meter update meter profile\n\n"
669 : :
670 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
671 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
672 : : " update meter dscp table entries\n\n"
673 : :
674 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
675 : : "(action0) [(action1) (action2)]\n"
676 : : " meter update policer action\n\n"
677 : :
678 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
679 : : " meter update stats\n\n"
680 : :
681 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
682 : : " set fec mode for a specific port\n\n"
683 : :
684 : : "show port cman capa (port_id)\n"
685 : : " Show congestion management capabilities\n\n"
686 : :
687 : : "show port cman config (port_id)\n"
688 : : " Show congestion management configuration\n\n"
689 : :
690 : : "set port cman config (port_id) (queue_id) default | "
691 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
692 : : "(max_thresh) (prob_inv)]\n"
693 : : " Set congestion management configuration\n\n"
694 : :
695 : : "set port (port_id) led (on|off)\n"
696 : : " Set a controllable LED associated with a certain"
697 : : " port on or off.\n\n"
698 : :
699 : : , list_pkt_forwarding_modes()
700 : : );
701 : : }
702 : :
703 : 0 : if (show_all || !strcmp(res->section, "ports")) {
704 : :
705 : 0 : cmdline_printf(
706 : : cl,
707 : : "\n"
708 : : "Port Operations:\n"
709 : : "----------------\n\n"
710 : :
711 : : "port start (port_id|all)\n"
712 : : " Start all ports or port_id.\n\n"
713 : :
714 : : "port stop (port_id|all)\n"
715 : : " Stop all ports or port_id.\n\n"
716 : :
717 : : "port close (port_id|all)\n"
718 : : " Close all ports or port_id.\n\n"
719 : :
720 : : "port reset (port_id|all)\n"
721 : : " Reset all ports or port_id.\n\n"
722 : :
723 : : "port attach (ident)\n"
724 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
725 : :
726 : : "port detach (port_id)\n"
727 : : " Detach physical or virtual dev by port_id\n\n"
728 : :
729 : : "port config (port_id|all)"
730 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|"
731 : : "100000|200000|400000|800000|auto)"
732 : : " duplex (half|full|auto)\n"
733 : : " Set speed and duplex for all ports or port_id\n\n"
734 : :
735 : : "port config (port_id|all) loopback (mode)\n"
736 : : " Set loopback mode for all ports or port_id\n\n"
737 : :
738 : : "port config all (rxq|txq|rxd|txd) (value)\n"
739 : : " Set number for rxq/txq/rxd/txd.\n\n"
740 : :
741 : : "port config all max-pkt-len (value)\n"
742 : : " Set the max packet length.\n\n"
743 : :
744 : : "port config all max-lro-pkt-size (value)\n"
745 : : " Set the max LRO aggregated packet size.\n\n"
746 : :
747 : : "port config all drop-en (on|off)\n"
748 : : " Enable or disable packet drop on all RX queues of all ports when no "
749 : : "receive buffers available.\n\n"
750 : :
751 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
752 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
753 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
754 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
755 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
756 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
757 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
758 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
759 : : " Set the RSS mode.\n\n"
760 : :
761 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
762 : : " Set the RSS redirection table.\n\n"
763 : :
764 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
765 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
766 : : " Set the RSS hash algorithm.\n\n"
767 : :
768 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
769 : : " pfc (on|off)\n"
770 : : " Set the DCB mode.\n\n"
771 : :
772 : : "port config all burst (value)\n"
773 : : " Set the number of packets per burst.\n\n"
774 : :
775 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
776 : : " (value)\n"
777 : : " Set the ring prefetch/host/writeback threshold"
778 : : " for tx/rx queue.\n\n"
779 : :
780 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
781 : : " Set free threshold for rx/tx, or set"
782 : : " tx rs bit threshold.\n\n"
783 : : "port config mtu X value\n"
784 : : " Set the MTU of port X to a given value\n\n"
785 : :
786 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
787 : : " Set a rx/tx queue's ring size configuration, the new"
788 : : " value will take effect after command that (re-)start the port"
789 : : " or command that setup the specific queue\n\n"
790 : :
791 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
792 : : " Start/stop a rx/tx queue of port X. Only take effect"
793 : : " when port X is started\n\n"
794 : :
795 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
796 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
797 : : " take effect when port X is stopped.\n\n"
798 : :
799 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
800 : : " Setup a rx/tx queue of port X.\n\n"
801 : :
802 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
803 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
804 : :
805 : : "port config (port_id|all) rx_offload all|vlan_strip|"
806 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
807 : : "outer_ipv4_cksum|macsec_strip|"
808 : : "vlan_filter|vlan_extend|scatter|"
809 : : "buffer_split|timestamp|security|keep_crc on|off\n"
810 : : " Enable or disable a per port Rx offloading"
811 : : " on all Rx queues of a port\n\n"
812 : :
813 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
814 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
815 : : "outer_ipv4_cksum|macsec_strip|"
816 : : "vlan_filter|vlan_extend|scatter|"
817 : : "buffer_split|timestamp|security|keep_crc on|off\n"
818 : : " Enable or disable a per queue Rx offloading"
819 : : " only on a specific Rx queue\n\n"
820 : :
821 : : "port config (port_id|all) tx_offload all|vlan_insert|"
822 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
823 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
824 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
825 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
826 : : "security on|off\n"
827 : : " Enable or disable a per port Tx offloading"
828 : : " on all Tx queues of a port\n\n"
829 : :
830 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
831 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
832 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
833 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
834 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
835 : : " on|off\n"
836 : : " Enable or disable a per queue Tx offloading"
837 : : " only on a specific Tx queue\n\n"
838 : :
839 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
840 : : " Load an eBPF program as a callback"
841 : : " for particular RX/TX queue\n\n"
842 : :
843 : : "bpf-unload rx|tx (port) (queue)\n"
844 : : " Unload previously loaded eBPF program"
845 : : " for particular RX/TX queue\n\n"
846 : :
847 : : "port config (port_id) tx_metadata (value)\n"
848 : : " Set Tx metadata value per port. Testpmd will add this value"
849 : : " to any Tx packet sent from this port\n\n"
850 : :
851 : : "port config (port_id) dynf (name) set|clear\n"
852 : : " Register a dynf and Set/clear this flag on Tx. "
853 : : "Testpmd will set this value to any Tx packet "
854 : : "sent from this port\n\n"
855 : :
856 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
857 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
858 : :
859 : : "port config (port_id) txq (queue_id) affinity (value)\n"
860 : : " Map a Tx queue with an aggregated port "
861 : : "of the DPDK port\n\n"
862 : :
863 : : "port config (port_id|all) speed_lanes (value)\n"
864 : : " Set number of lanes for all ports or port_id for a forced speed\n\n"
865 : : );
866 : : }
867 : :
868 : 0 : if (show_all || !strcmp(res->section, "filters")) {
869 : :
870 : 0 : cmdline_printf(
871 : : cl,
872 : : "\n"
873 : : "filters:\n"
874 : : "--------\n\n"
875 : :
876 : : "flow validate {port_id}"
877 : : " [group {group_id}] [priority {level}]"
878 : : " [ingress] [egress]"
879 : : " pattern {item} [/ {item} [...]] / end"
880 : : " actions {action} [/ {action} [...]] / end\n"
881 : : " Check whether a flow rule can be created.\n\n"
882 : :
883 : : "flow create {port_id}"
884 : : " [group {group_id}] [priority {level}]"
885 : : " [ingress] [egress]"
886 : : " pattern {item} [/ {item} [...]] / end"
887 : : " actions {action} [/ {action} [...]] / end\n"
888 : : " Create a flow rule.\n\n"
889 : :
890 : : "flow destroy {port_id} rule {rule_id} [...]\n"
891 : : " Destroy specific flow rules.\n\n"
892 : :
893 : : "flow update {port_id} {rule_id}"
894 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
895 : : " Update a flow rule with new actions.\n\n"
896 : :
897 : : "flow flush {port_id}\n"
898 : : " Destroy all flow rules.\n\n"
899 : :
900 : : "flow query {port_id} {rule_id} {action}\n"
901 : : " Query an existing flow rule.\n\n"
902 : :
903 : : "flow list {port_id} [group {group_id}] [...]\n"
904 : : " List existing flow rules sorted by priority,"
905 : : " filtered by group identifiers.\n\n"
906 : :
907 : : "flow isolate {port_id} {boolean}\n"
908 : : " Restrict ingress traffic to the defined"
909 : : " flow rules\n\n"
910 : :
911 : : "flow aged {port_id} [destroy]\n"
912 : : " List and destroy aged flows"
913 : : " flow rules\n\n"
914 : :
915 : : "flow indirect_action {port_id} create"
916 : : " [action_id {indirect_action_id}]"
917 : : " [ingress] [egress]"
918 : : " action {action} / end\n"
919 : : " Create indirect action.\n\n"
920 : :
921 : : "flow indirect_action {port_id} update"
922 : : " {indirect_action_id} action {action} / end\n"
923 : : " Update indirect action.\n\n"
924 : :
925 : : "flow indirect_action {port_id} destroy"
926 : : " action_id {indirect_action_id} [...]\n"
927 : : " Destroy specific indirect actions.\n\n"
928 : :
929 : : "flow indirect_action {port_id} query"
930 : : " {indirect_action_id}\n"
931 : : " Query an existing indirect action.\n\n"
932 : :
933 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
934 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
935 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
936 : : " Configure the VXLAN encapsulation for flows.\n\n"
937 : :
938 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
939 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
940 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
941 : : " eth-dst (eth-dst)\n"
942 : : " Configure the VXLAN encapsulation for flows.\n\n"
943 : :
944 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
945 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
946 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
947 : : " eth-dst (eth-dst)\n"
948 : : " Configure the VXLAN encapsulation for flows.\n\n"
949 : :
950 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
951 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
952 : : " (eth-dst)\n"
953 : : " Configure the NVGRE encapsulation for flows.\n\n"
954 : :
955 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
956 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
957 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
958 : : " Configure the NVGRE encapsulation for flows.\n\n"
959 : :
960 : : "set raw_encap {flow items}\n"
961 : : " Configure the encapsulation with raw data.\n\n"
962 : :
963 : : "set raw_decap {flow items}\n"
964 : : " Configure the decapsulation with raw data.\n\n"
965 : :
966 : : );
967 : : }
968 : :
969 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
970 : 0 : cmdline_printf(
971 : : cl,
972 : : "\n"
973 : : "Traffic Management:\n"
974 : : "--------------\n"
975 : : "show port tm cap (port_id)\n"
976 : : " Display the port TM capability.\n\n"
977 : :
978 : : "show port tm level cap (port_id) (level_id)\n"
979 : : " Display the port TM hierarchical level capability.\n\n"
980 : :
981 : : "show port tm node cap (port_id) (node_id)\n"
982 : : " Display the port TM node capability.\n\n"
983 : :
984 : : "show port tm node type (port_id) (node_id)\n"
985 : : " Display the port TM node type.\n\n"
986 : :
987 : : "show port tm node stats (port_id) (node_id) (clear)\n"
988 : : " Display the port TM node stats.\n\n"
989 : :
990 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
991 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
992 : : " (packet_length_adjust) (packet_mode)\n"
993 : : " Add port tm node private shaper profile.\n\n"
994 : :
995 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
996 : : " Delete port tm node private shaper profile.\n\n"
997 : :
998 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
999 : : " (shaper_profile_id)\n"
1000 : : " Add/update port tm node shared shaper.\n\n"
1001 : :
1002 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1003 : : " Delete port tm node shared shaper.\n\n"
1004 : :
1005 : : "set port tm node shaper profile (port_id) (node_id)"
1006 : : " (shaper_profile_id)\n"
1007 : : " Set port tm node shaper profile.\n\n"
1008 : :
1009 : : "add port tm node wred profile (port_id) (wred_profile_id)"
1010 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1011 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1012 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1013 : : " Add port tm node wred profile.\n\n"
1014 : :
1015 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
1016 : : " Delete port tm node wred profile.\n\n"
1017 : :
1018 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1019 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1020 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1021 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1022 : : " Add port tm nonleaf node.\n\n"
1023 : :
1024 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1025 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1026 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1027 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1028 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
1029 : :
1030 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1031 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1032 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1033 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1034 : : " Add port tm leaf node.\n\n"
1035 : :
1036 : : "del port tm node (port_id) (node_id)\n"
1037 : : " Delete port tm node.\n\n"
1038 : :
1039 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1040 : : " (priority) (weight)\n"
1041 : : " Set port tm node parent.\n\n"
1042 : :
1043 : : "suspend port tm node (port_id) (node_id)"
1044 : : " Suspend tm node.\n\n"
1045 : :
1046 : : "resume port tm node (port_id) (node_id)"
1047 : : " Resume tm node.\n\n"
1048 : :
1049 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1050 : : " Commit tm hierarchy.\n\n"
1051 : :
1052 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1053 : : " (red)\n"
1054 : : " Enables/Disables the traffic management marking"
1055 : : " for IP ECN (Explicit Congestion Notification)"
1056 : : " packets on a given port\n\n"
1057 : :
1058 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1059 : : " (red)\n"
1060 : : " Enables/Disables the traffic management marking"
1061 : : " on the port for IP dscp packets\n\n"
1062 : :
1063 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1064 : : " (red)\n"
1065 : : " Enables/Disables the traffic management marking"
1066 : : " on the port for VLAN packets with DEI enabled\n\n"
1067 : : );
1068 : : }
1069 : :
1070 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1071 : 0 : cmdline_printf(
1072 : : cl,
1073 : : "\n"
1074 : : "Device Operations:\n"
1075 : : "--------------\n"
1076 : : "device detach (identifier)\n"
1077 : : " Detach device by identifier.\n\n"
1078 : : );
1079 : : }
1080 : :
1081 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1082 : : struct testpmd_driver_commands *c;
1083 : : unsigned int i;
1084 : :
1085 : 0 : cmdline_printf(
1086 : : cl,
1087 : : "\n"
1088 : : "Driver specific:\n"
1089 : : "----------------\n"
1090 : : );
1091 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1092 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1093 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1094 : : }
1095 : : }
1096 : 0 : }
1097 : :
1098 : : static cmdline_parse_token_string_t cmd_help_long_help =
1099 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1100 : :
1101 : : static cmdline_parse_token_string_t cmd_help_long_section =
1102 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1103 : : "all#control#display#config#ports#"
1104 : : "filters#traffic_management#devices#drivers");
1105 : :
1106 : : static cmdline_parse_inst_t cmd_help_long = {
1107 : : .f = cmd_help_long_parsed,
1108 : : .data = NULL,
1109 : : .help_str = "help all|control|display|config|ports|"
1110 : : "filters|traffic_management|devices|drivers: "
1111 : : "Show help",
1112 : : .tokens = {
1113 : : (void *)&cmd_help_long_help,
1114 : : (void *)&cmd_help_long_section,
1115 : : NULL,
1116 : : },
1117 : : };
1118 : :
1119 : :
1120 : : /* *** start/stop/close all ports *** */
1121 : : struct cmd_operate_port_result {
1122 : : cmdline_fixed_string_t keyword;
1123 : : cmdline_fixed_string_t name;
1124 : : cmdline_fixed_string_t value;
1125 : : };
1126 : :
1127 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1128 : : __rte_unused struct cmdline *cl,
1129 : : __rte_unused void *data)
1130 : : {
1131 : : struct cmd_operate_port_result *res = parsed_result;
1132 : :
1133 : 0 : if (!strcmp(res->name, "start"))
1134 : 0 : start_port(RTE_PORT_ALL);
1135 : 0 : else if (!strcmp(res->name, "stop"))
1136 : 0 : stop_port(RTE_PORT_ALL);
1137 : 0 : else if (!strcmp(res->name, "close"))
1138 : 0 : close_port(RTE_PORT_ALL);
1139 : 0 : else if (!strcmp(res->name, "reset"))
1140 : 0 : reset_port(RTE_PORT_ALL);
1141 : : else
1142 : 0 : fprintf(stderr, "Unknown parameter\n");
1143 : 0 : }
1144 : :
1145 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1146 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1147 : : "port");
1148 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1149 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1150 : : "start#stop#close#reset");
1151 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1152 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1153 : :
1154 : : static cmdline_parse_inst_t cmd_operate_port = {
1155 : : .f = cmd_operate_port_parsed,
1156 : : .data = NULL,
1157 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1158 : : .tokens = {
1159 : : (void *)&cmd_operate_port_all_cmd,
1160 : : (void *)&cmd_operate_port_all_port,
1161 : : (void *)&cmd_operate_port_all_all,
1162 : : NULL,
1163 : : },
1164 : : };
1165 : :
1166 : : /* *** start/stop/close specific port *** */
1167 : : struct cmd_operate_specific_port_result {
1168 : : cmdline_fixed_string_t keyword;
1169 : : cmdline_fixed_string_t name;
1170 : : uint8_t value;
1171 : : };
1172 : :
1173 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1174 : : __rte_unused struct cmdline *cl,
1175 : : __rte_unused void *data)
1176 : : {
1177 : : struct cmd_operate_specific_port_result *res = parsed_result;
1178 : :
1179 : 0 : if (!strcmp(res->name, "start"))
1180 : 0 : start_port(res->value);
1181 : 0 : else if (!strcmp(res->name, "stop"))
1182 : 0 : stop_port(res->value);
1183 : 0 : else if (!strcmp(res->name, "close"))
1184 : 0 : close_port(res->value);
1185 : 0 : else if (!strcmp(res->name, "reset"))
1186 : 0 : reset_port(res->value);
1187 : : else
1188 : 0 : fprintf(stderr, "Unknown parameter\n");
1189 : 0 : }
1190 : :
1191 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1192 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1193 : : keyword, "port");
1194 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1195 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1196 : : name, "start#stop#close#reset");
1197 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1198 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1199 : : value, RTE_UINT8);
1200 : :
1201 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1202 : : .f = cmd_operate_specific_port_parsed,
1203 : : .data = NULL,
1204 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1205 : : .tokens = {
1206 : : (void *)&cmd_operate_specific_port_cmd,
1207 : : (void *)&cmd_operate_specific_port_port,
1208 : : (void *)&cmd_operate_specific_port_id,
1209 : : NULL,
1210 : : },
1211 : : };
1212 : :
1213 : : /* *** enable port setup (after attach) via iterator or event *** */
1214 : : struct cmd_set_port_setup_on_result {
1215 : : cmdline_fixed_string_t set;
1216 : : cmdline_fixed_string_t port;
1217 : : cmdline_fixed_string_t setup;
1218 : : cmdline_fixed_string_t on;
1219 : : cmdline_fixed_string_t mode;
1220 : : };
1221 : :
1222 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1223 : : __rte_unused struct cmdline *cl,
1224 : : __rte_unused void *data)
1225 : : {
1226 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1227 : :
1228 : 0 : if (strcmp(res->mode, "event") == 0)
1229 : 0 : setup_on_probe_event = true;
1230 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1231 : 0 : setup_on_probe_event = false;
1232 : : else
1233 : 0 : fprintf(stderr, "Unknown mode\n");
1234 : 0 : }
1235 : :
1236 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1237 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1238 : : set, "set");
1239 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1240 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1241 : : port, "port");
1242 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1243 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1244 : : setup, "setup");
1245 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1246 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1247 : : on, "on");
1248 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1249 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1250 : : mode, "iterator#event");
1251 : :
1252 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1253 : : .f = cmd_set_port_setup_on_parsed,
1254 : : .data = NULL,
1255 : : .help_str = "set port setup on iterator|event",
1256 : : .tokens = {
1257 : : (void *)&cmd_set_port_setup_on_set,
1258 : : (void *)&cmd_set_port_setup_on_port,
1259 : : (void *)&cmd_set_port_setup_on_setup,
1260 : : (void *)&cmd_set_port_setup_on_on,
1261 : : (void *)&cmd_set_port_setup_on_mode,
1262 : : NULL,
1263 : : },
1264 : : };
1265 : :
1266 : : /* *** attach a specified port *** */
1267 : : struct cmd_operate_attach_port_result {
1268 : : cmdline_fixed_string_t port;
1269 : : cmdline_fixed_string_t keyword;
1270 : : cmdline_multi_string_t identifier;
1271 : : };
1272 : :
1273 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1274 : : __rte_unused struct cmdline *cl,
1275 : : __rte_unused void *data)
1276 : : {
1277 : : struct cmd_operate_attach_port_result *res = parsed_result;
1278 : :
1279 : 0 : if (!strcmp(res->keyword, "attach"))
1280 : 0 : attach_port(res->identifier);
1281 : : else
1282 : 0 : fprintf(stderr, "Unknown parameter\n");
1283 : 0 : }
1284 : :
1285 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1286 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1287 : : port, "port");
1288 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1289 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1290 : : keyword, "attach");
1291 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1292 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1293 : : identifier, TOKEN_STRING_MULTI);
1294 : :
1295 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1296 : : .f = cmd_operate_attach_port_parsed,
1297 : : .data = NULL,
1298 : : .help_str = "port attach <identifier>: "
1299 : : "(identifier: pci address or virtual dev name)",
1300 : : .tokens = {
1301 : : (void *)&cmd_operate_attach_port_port,
1302 : : (void *)&cmd_operate_attach_port_keyword,
1303 : : (void *)&cmd_operate_attach_port_identifier,
1304 : : NULL,
1305 : : },
1306 : : };
1307 : :
1308 : : /* *** detach a specified port *** */
1309 : : struct cmd_operate_detach_port_result {
1310 : : cmdline_fixed_string_t port;
1311 : : cmdline_fixed_string_t keyword;
1312 : : portid_t port_id;
1313 : : };
1314 : :
1315 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1316 : : __rte_unused struct cmdline *cl,
1317 : : __rte_unused void *data)
1318 : : {
1319 : : struct cmd_operate_detach_port_result *res = parsed_result;
1320 : :
1321 : 0 : if (!strcmp(res->keyword, "detach")) {
1322 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1323 : 0 : detach_port_device(res->port_id);
1324 : : } else {
1325 : 0 : fprintf(stderr, "Unknown parameter\n");
1326 : : }
1327 : : }
1328 : :
1329 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1330 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1331 : : port, "port");
1332 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1333 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1334 : : keyword, "detach");
1335 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1336 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1337 : : port_id, RTE_UINT16);
1338 : :
1339 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1340 : : .f = cmd_operate_detach_port_parsed,
1341 : : .data = NULL,
1342 : : .help_str = "port detach <port_id>",
1343 : : .tokens = {
1344 : : (void *)&cmd_operate_detach_port_port,
1345 : : (void *)&cmd_operate_detach_port_keyword,
1346 : : (void *)&cmd_operate_detach_port_port_id,
1347 : : NULL,
1348 : : },
1349 : : };
1350 : :
1351 : : /* *** detach device by identifier *** */
1352 : : struct cmd_operate_detach_device_result {
1353 : : cmdline_fixed_string_t device;
1354 : : cmdline_fixed_string_t keyword;
1355 : : cmdline_fixed_string_t identifier;
1356 : : };
1357 : :
1358 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1359 : : __rte_unused struct cmdline *cl,
1360 : : __rte_unused void *data)
1361 : : {
1362 : : struct cmd_operate_detach_device_result *res = parsed_result;
1363 : :
1364 : 0 : if (!strcmp(res->keyword, "detach"))
1365 : 0 : detach_devargs(res->identifier);
1366 : : else
1367 : 0 : fprintf(stderr, "Unknown parameter\n");
1368 : 0 : }
1369 : :
1370 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1371 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1372 : : device, "device");
1373 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1374 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1375 : : keyword, "detach");
1376 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1377 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1378 : : identifier, NULL);
1379 : :
1380 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1381 : : .f = cmd_operate_detach_device_parsed,
1382 : : .data = NULL,
1383 : : .help_str = "device detach <identifier>:"
1384 : : "(identifier: pci address or virtual dev name)",
1385 : : .tokens = {
1386 : : (void *)&cmd_operate_detach_device_device,
1387 : : (void *)&cmd_operate_detach_device_keyword,
1388 : : (void *)&cmd_operate_detach_device_identifier,
1389 : : NULL,
1390 : : },
1391 : : };
1392 : : /* *** configure speed for all ports *** */
1393 : : struct cmd_config_speed_all {
1394 : : cmdline_fixed_string_t port;
1395 : : cmdline_fixed_string_t keyword;
1396 : : cmdline_fixed_string_t all;
1397 : : cmdline_fixed_string_t item1;
1398 : : cmdline_fixed_string_t item2;
1399 : : cmdline_fixed_string_t value1;
1400 : : cmdline_fixed_string_t value2;
1401 : : };
1402 : :
1403 : : static int
1404 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1405 : : {
1406 : :
1407 : : int duplex;
1408 : :
1409 : 0 : if (!strcmp(duplexstr, "half")) {
1410 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1411 : 0 : } else if (!strcmp(duplexstr, "full")) {
1412 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1413 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1414 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1415 : : } else {
1416 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1417 : 0 : return -1;
1418 : : }
1419 : :
1420 : 0 : if (!strcmp(speedstr, "10")) {
1421 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1422 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1423 : 0 : } else if (!strcmp(speedstr, "100")) {
1424 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1425 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1426 : : } else {
1427 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1428 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1429 : 0 : return -1;
1430 : : }
1431 : 0 : if (!strcmp(speedstr, "1000")) {
1432 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1433 : 0 : } else if (!strcmp(speedstr, "2500")) {
1434 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1435 : 0 : } else if (!strcmp(speedstr, "5000")) {
1436 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1437 : 0 : } else if (!strcmp(speedstr, "10000")) {
1438 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1439 : 0 : } else if (!strcmp(speedstr, "25000")) {
1440 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1441 : 0 : } else if (!strcmp(speedstr, "40000")) {
1442 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1443 : 0 : } else if (!strcmp(speedstr, "50000")) {
1444 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1445 : 0 : } else if (!strcmp(speedstr, "100000")) {
1446 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1447 : 0 : } else if (!strcmp(speedstr, "200000")) {
1448 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1449 : 0 : } else if (!strcmp(speedstr, "400000")) {
1450 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1451 : 0 : } else if (!strcmp(speedstr, "800000")) {
1452 : 0 : *speed = RTE_ETH_LINK_SPEED_800G;
1453 : 0 : } else if (!strcmp(speedstr, "auto")) {
1454 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1455 : : } else {
1456 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1457 : 0 : return -1;
1458 : : }
1459 : : }
1460 : :
1461 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1462 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1463 : :
1464 : : return 0;
1465 : : }
1466 : :
1467 : : static void
1468 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1469 : : __rte_unused struct cmdline *cl,
1470 : : __rte_unused void *data)
1471 : : {
1472 : : struct cmd_config_speed_all *res = parsed_result;
1473 : : uint32_t link_speed;
1474 : : portid_t pid;
1475 : :
1476 : 0 : if (!all_ports_stopped()) {
1477 : 0 : fprintf(stderr, "Please stop all ports first\n");
1478 : 0 : return;
1479 : : }
1480 : :
1481 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1482 : : &link_speed) < 0)
1483 : : return;
1484 : :
1485 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1486 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1487 : : }
1488 : :
1489 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1490 : : }
1491 : :
1492 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1493 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1494 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1495 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1496 : : "config");
1497 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1498 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1499 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1500 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1501 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1502 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1503 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1504 : : "100000#200000#400000#800000#auto");
1505 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1506 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1507 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1508 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1509 : : "half#full#auto");
1510 : :
1511 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1512 : : .f = cmd_config_speed_all_parsed,
1513 : : .data = NULL,
1514 : : .help_str = "port config all speed "
1515 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1516 : : "100000|200000|400000|800000|auto "
1517 : : "duplex half|full|auto",
1518 : : .tokens = {
1519 : : (void *)&cmd_config_speed_all_port,
1520 : : (void *)&cmd_config_speed_all_keyword,
1521 : : (void *)&cmd_config_speed_all_all,
1522 : : (void *)&cmd_config_speed_all_item1,
1523 : : (void *)&cmd_config_speed_all_value1,
1524 : : (void *)&cmd_config_speed_all_item2,
1525 : : (void *)&cmd_config_speed_all_value2,
1526 : : NULL,
1527 : : },
1528 : : };
1529 : :
1530 : : /* *** configure speed for specific port *** */
1531 : : struct cmd_config_speed_specific {
1532 : : cmdline_fixed_string_t port;
1533 : : cmdline_fixed_string_t keyword;
1534 : : portid_t id;
1535 : : cmdline_fixed_string_t item1;
1536 : : cmdline_fixed_string_t item2;
1537 : : cmdline_fixed_string_t value1;
1538 : : cmdline_fixed_string_t value2;
1539 : : };
1540 : :
1541 : : static void
1542 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1543 : : __rte_unused struct cmdline *cl,
1544 : : __rte_unused void *data)
1545 : : {
1546 : : struct cmd_config_speed_specific *res = parsed_result;
1547 : : uint32_t link_speed;
1548 : :
1549 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1550 : 0 : return;
1551 : :
1552 : 0 : if (!port_is_stopped(res->id)) {
1553 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1554 : 0 : return;
1555 : : }
1556 : :
1557 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1558 : : &link_speed) < 0)
1559 : : return;
1560 : :
1561 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1562 : :
1563 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1564 : : }
1565 : :
1566 : :
1567 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1568 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1569 : : "port");
1570 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1571 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1572 : : "config");
1573 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1574 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1575 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1576 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1577 : : "speed");
1578 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1579 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1580 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1581 : : "100000#200000#400000#800000#auto");
1582 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1583 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1584 : : "duplex");
1585 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1586 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1587 : : "half#full#auto");
1588 : :
1589 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1590 : : .f = cmd_config_speed_specific_parsed,
1591 : : .data = NULL,
1592 : : .help_str = "port config <port_id> speed "
1593 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1594 : : "100000|200000|400000|800000|auto "
1595 : : "duplex half|full|auto",
1596 : : .tokens = {
1597 : : (void *)&cmd_config_speed_specific_port,
1598 : : (void *)&cmd_config_speed_specific_keyword,
1599 : : (void *)&cmd_config_speed_specific_id,
1600 : : (void *)&cmd_config_speed_specific_item1,
1601 : : (void *)&cmd_config_speed_specific_value1,
1602 : : (void *)&cmd_config_speed_specific_item2,
1603 : : (void *)&cmd_config_speed_specific_value2,
1604 : : NULL,
1605 : : },
1606 : : };
1607 : :
1608 : : static int
1609 : 0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
1610 : : {
1611 : : int ret;
1612 : :
1613 : 0 : ret = rte_eth_speed_lanes_set(pid, lanes);
1614 : 0 : if (ret == -ENOTSUP) {
1615 : 0 : fprintf(stderr, "Function not implemented\n");
1616 : 0 : return -1;
1617 : 0 : } else if (ret < 0) {
1618 : 0 : fprintf(stderr, "Set speed lanes failed\n");
1619 : 0 : return -1;
1620 : : }
1621 : :
1622 : : return 0;
1623 : : }
1624 : :
1625 : : static void
1626 : 0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
1627 : : {
1628 : : unsigned int i;
1629 : : uint32_t capa;
1630 : :
1631 : : printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
1632 : : printf("\n-----------------------------------\n");
1633 : 0 : for (i = 0; i < num; i++) {
1634 : 0 : printf("%-17s ",
1635 : 0 : rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
1636 : 0 : capa = speed_lanes_capa[i].capa;
1637 : : int s = 0;
1638 : :
1639 : 0 : while (capa) {
1640 : 0 : if (capa & 0x1)
1641 : : printf("%-2d ", s);
1642 : 0 : s++;
1643 : 0 : capa = capa >> 1;
1644 : : }
1645 : : printf("\n");
1646 : : }
1647 : 0 : }
1648 : :
1649 : : /* *** display speed lanes per port capabilities *** */
1650 : : struct cmd_show_speed_lanes_result {
1651 : : cmdline_fixed_string_t cmd_show;
1652 : : cmdline_fixed_string_t cmd_port;
1653 : : cmdline_fixed_string_t cmd_keyword;
1654 : : portid_t cmd_pid;
1655 : : };
1656 : :
1657 : : static void
1658 : 0 : cmd_show_speed_lanes_parsed(void *parsed_result,
1659 : : __rte_unused struct cmdline *cl,
1660 : : __rte_unused void *data)
1661 : : {
1662 : : struct cmd_show_speed_lanes_result *res = parsed_result;
1663 : : struct rte_eth_speed_lanes_capa *speed_lanes_capa;
1664 : : unsigned int num;
1665 : : int ret;
1666 : :
1667 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
1668 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
1669 : 0 : return;
1670 : : }
1671 : :
1672 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
1673 : 0 : if (ret == -ENOTSUP) {
1674 : 0 : fprintf(stderr, "Function not implemented\n");
1675 : 0 : return;
1676 : 0 : } else if (ret < 0) {
1677 : 0 : fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
1678 : 0 : return;
1679 : : }
1680 : :
1681 : 0 : num = (unsigned int)ret;
1682 : 0 : speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
1683 : 0 : if (speed_lanes_capa == NULL) {
1684 : 0 : fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
1685 : 0 : return;
1686 : : }
1687 : :
1688 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
1689 : 0 : if (ret < 0) {
1690 : 0 : fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
1691 : 0 : goto out;
1692 : : }
1693 : :
1694 : 0 : show_speed_lanes_capability(num, speed_lanes_capa);
1695 : 0 : out:
1696 : 0 : free(speed_lanes_capa);
1697 : : }
1698 : :
1699 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
1700 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1701 : : cmd_show, "show");
1702 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
1703 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1704 : : cmd_port, "port");
1705 : : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
1706 : : TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
1707 : : cmd_pid, RTE_UINT16);
1708 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
1709 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1710 : : cmd_keyword, "speed_lanes");
1711 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
1712 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1713 : : cmd_keyword, "capabilities");
1714 : :
1715 : : static cmdline_parse_inst_t cmd_show_speed_lanes = {
1716 : : .f = cmd_show_speed_lanes_parsed,
1717 : : .data = NULL,
1718 : : .help_str = "show port <port_id> speed_lanes capabilities",
1719 : : .tokens = {
1720 : : (void *)&cmd_show_speed_lanes_show,
1721 : : (void *)&cmd_show_speed_lanes_port,
1722 : : (void *)&cmd_show_speed_lanes_pid,
1723 : : (void *)&cmd_show_speed_lanes_keyword,
1724 : : (void *)&cmd_show_speed_lanes_cap_keyword,
1725 : : NULL,
1726 : : },
1727 : : };
1728 : :
1729 : : /* *** configure speed_lanes for all ports *** */
1730 : : struct cmd_config_speed_lanes_all {
1731 : : cmdline_fixed_string_t port;
1732 : : cmdline_fixed_string_t keyword;
1733 : : cmdline_fixed_string_t all;
1734 : : cmdline_fixed_string_t item;
1735 : : uint32_t lanes;
1736 : : };
1737 : :
1738 : : static void
1739 : 0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
1740 : : __rte_unused struct cmdline *cl,
1741 : : __rte_unused void *data)
1742 : : {
1743 : : struct cmd_config_speed_lanes_all *res = parsed_result;
1744 : : portid_t pid;
1745 : :
1746 : 0 : if (!all_ports_stopped()) {
1747 : 0 : fprintf(stderr, "Please stop all ports first\n");
1748 : 0 : return;
1749 : : }
1750 : :
1751 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1752 : 0 : if (parse_speed_lanes_cfg(pid, res->lanes))
1753 : : return;
1754 : : }
1755 : :
1756 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1757 : : }
1758 : :
1759 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
1760 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
1761 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
1762 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
1763 : : "config");
1764 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
1765 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
1766 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
1767 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
1768 : : "speed_lanes");
1769 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
1770 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
1771 : :
1772 : : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
1773 : : .f = cmd_config_speed_lanes_all_parsed,
1774 : : .data = NULL,
1775 : : .help_str = "port config all speed_lanes <value>",
1776 : : .tokens = {
1777 : : (void *)&cmd_config_speed_lanes_all_port,
1778 : : (void *)&cmd_config_speed_lanes_all_keyword,
1779 : : (void *)&cmd_config_speed_lanes_all_all,
1780 : : (void *)&cmd_config_speed_lanes_all_item,
1781 : : (void *)&cmd_config_speed_lanes_all_lanes,
1782 : : NULL,
1783 : : },
1784 : : };
1785 : :
1786 : : /* *** configure speed_lanes for specific port *** */
1787 : : struct cmd_config_speed_lanes_specific {
1788 : : cmdline_fixed_string_t port;
1789 : : cmdline_fixed_string_t keyword;
1790 : : uint16_t port_id;
1791 : : cmdline_fixed_string_t item;
1792 : : uint32_t lanes;
1793 : : };
1794 : :
1795 : : static void
1796 : 0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
1797 : : __rte_unused struct cmdline *cl,
1798 : : __rte_unused void *data)
1799 : : {
1800 : : struct cmd_config_speed_lanes_specific *res = parsed_result;
1801 : :
1802 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1803 : : return;
1804 : :
1805 : 0 : if (!port_is_stopped(res->port_id)) {
1806 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1807 : 0 : return;
1808 : : }
1809 : :
1810 : 0 : if (parse_speed_lanes_cfg(res->port_id, res->lanes))
1811 : : return;
1812 : :
1813 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1814 : : }
1815 : :
1816 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
1817 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
1818 : : "port");
1819 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
1820 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
1821 : : "config");
1822 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
1823 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
1824 : : RTE_UINT16);
1825 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
1826 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
1827 : : "speed_lanes");
1828 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
1829 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
1830 : : RTE_UINT32);
1831 : :
1832 : : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
1833 : : .f = cmd_config_speed_lanes_specific_parsed,
1834 : : .data = NULL,
1835 : : .help_str = "port config <port_id> speed_lanes <value>",
1836 : : .tokens = {
1837 : : (void *)&cmd_config_speed_lanes_specific_port,
1838 : : (void *)&cmd_config_speed_lanes_specific_keyword,
1839 : : (void *)&cmd_config_speed_lanes_specific_id,
1840 : : (void *)&cmd_config_speed_lanes_specific_item,
1841 : : (void *)&cmd_config_speed_lanes_specific_lanes,
1842 : : NULL,
1843 : : },
1844 : : };
1845 : :
1846 : : /* *** configure loopback for all ports *** */
1847 : : struct cmd_config_loopback_all {
1848 : : cmdline_fixed_string_t port;
1849 : : cmdline_fixed_string_t keyword;
1850 : : cmdline_fixed_string_t all;
1851 : : cmdline_fixed_string_t item;
1852 : : uint32_t mode;
1853 : : };
1854 : :
1855 : : static void
1856 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1857 : : __rte_unused struct cmdline *cl,
1858 : : __rte_unused void *data)
1859 : : {
1860 : : struct cmd_config_loopback_all *res = parsed_result;
1861 : : portid_t pid;
1862 : :
1863 : 0 : if (!all_ports_stopped()) {
1864 : 0 : fprintf(stderr, "Please stop all ports first\n");
1865 : 0 : return;
1866 : : }
1867 : :
1868 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1869 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1870 : : }
1871 : :
1872 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1873 : : }
1874 : :
1875 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1876 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1877 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1878 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1879 : : "config");
1880 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1881 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1882 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1883 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1884 : : "loopback");
1885 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1886 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1887 : :
1888 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1889 : : .f = cmd_config_loopback_all_parsed,
1890 : : .data = NULL,
1891 : : .help_str = "port config all loopback <mode>",
1892 : : .tokens = {
1893 : : (void *)&cmd_config_loopback_all_port,
1894 : : (void *)&cmd_config_loopback_all_keyword,
1895 : : (void *)&cmd_config_loopback_all_all,
1896 : : (void *)&cmd_config_loopback_all_item,
1897 : : (void *)&cmd_config_loopback_all_mode,
1898 : : NULL,
1899 : : },
1900 : : };
1901 : :
1902 : : /* *** configure loopback for specific port *** */
1903 : : struct cmd_config_loopback_specific {
1904 : : cmdline_fixed_string_t port;
1905 : : cmdline_fixed_string_t keyword;
1906 : : uint16_t port_id;
1907 : : cmdline_fixed_string_t item;
1908 : : uint32_t mode;
1909 : : };
1910 : :
1911 : : static void
1912 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1913 : : __rte_unused struct cmdline *cl,
1914 : : __rte_unused void *data)
1915 : : {
1916 : : struct cmd_config_loopback_specific *res = parsed_result;
1917 : :
1918 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1919 : : return;
1920 : :
1921 : 0 : if (!port_is_stopped(res->port_id)) {
1922 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1923 : 0 : return;
1924 : : }
1925 : :
1926 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1927 : :
1928 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1929 : : }
1930 : :
1931 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1932 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1933 : : "port");
1934 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1935 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1936 : : "config");
1937 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1938 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1939 : : RTE_UINT16);
1940 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1941 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1942 : : "loopback");
1943 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1944 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1945 : : RTE_UINT32);
1946 : :
1947 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1948 : : .f = cmd_config_loopback_specific_parsed,
1949 : : .data = NULL,
1950 : : .help_str = "port config <port_id> loopback <mode>",
1951 : : .tokens = {
1952 : : (void *)&cmd_config_loopback_specific_port,
1953 : : (void *)&cmd_config_loopback_specific_keyword,
1954 : : (void *)&cmd_config_loopback_specific_id,
1955 : : (void *)&cmd_config_loopback_specific_item,
1956 : : (void *)&cmd_config_loopback_specific_mode,
1957 : : NULL,
1958 : : },
1959 : : };
1960 : :
1961 : : /* *** configure txq/rxq, txd/rxd *** */
1962 : : struct cmd_config_rx_tx {
1963 : : cmdline_fixed_string_t port;
1964 : : cmdline_fixed_string_t keyword;
1965 : : cmdline_fixed_string_t all;
1966 : : cmdline_fixed_string_t name;
1967 : : uint16_t value;
1968 : : };
1969 : :
1970 : : static void
1971 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1972 : : __rte_unused struct cmdline *cl,
1973 : : __rte_unused void *data)
1974 : : {
1975 : : struct cmd_config_rx_tx *res = parsed_result;
1976 : :
1977 : 0 : if (!all_ports_stopped()) {
1978 : 0 : fprintf(stderr, "Please stop all ports first\n");
1979 : 0 : return;
1980 : : }
1981 : 0 : if (!strcmp(res->name, "rxq")) {
1982 : 0 : if (!res->value && !nb_txq) {
1983 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1984 : 0 : return;
1985 : : }
1986 : 0 : if (check_nb_rxq(res->value) != 0)
1987 : : return;
1988 : 0 : nb_rxq = res->value;
1989 : : }
1990 : 0 : else if (!strcmp(res->name, "txq")) {
1991 : 0 : if (!res->value && !nb_rxq) {
1992 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1993 : 0 : return;
1994 : : }
1995 : 0 : if (check_nb_txq(res->value) != 0)
1996 : : return;
1997 : 0 : nb_txq = res->value;
1998 : : }
1999 : 0 : else if (!strcmp(res->name, "rxd")) {
2000 : 0 : if (check_nb_rxd(res->value) != 0)
2001 : : return;
2002 : 0 : nb_rxd = res->value;
2003 : 0 : } else if (!strcmp(res->name, "txd")) {
2004 : 0 : if (check_nb_txd(res->value) != 0)
2005 : : return;
2006 : :
2007 : 0 : nb_txd = res->value;
2008 : : } else {
2009 : 0 : fprintf(stderr, "Unknown parameter\n");
2010 : 0 : return;
2011 : : }
2012 : :
2013 : 0 : fwd_config_setup();
2014 : :
2015 : 0 : init_port_config();
2016 : :
2017 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2018 : : }
2019 : :
2020 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
2021 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2022 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2023 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2024 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
2025 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2026 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
2027 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2028 : : "rxq#txq#rxd#txd");
2029 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
2030 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
2031 : :
2032 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
2033 : : .f = cmd_config_rx_tx_parsed,
2034 : : .data = NULL,
2035 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
2036 : : .tokens = {
2037 : : (void *)&cmd_config_rx_tx_port,
2038 : : (void *)&cmd_config_rx_tx_keyword,
2039 : : (void *)&cmd_config_rx_tx_all,
2040 : : (void *)&cmd_config_rx_tx_name,
2041 : : (void *)&cmd_config_rx_tx_value,
2042 : : NULL,
2043 : : },
2044 : : };
2045 : :
2046 : : /* *** config max packet length *** */
2047 : : struct cmd_config_max_pkt_len_result {
2048 : : cmdline_fixed_string_t port;
2049 : : cmdline_fixed_string_t keyword;
2050 : : cmdline_fixed_string_t all;
2051 : : cmdline_fixed_string_t name;
2052 : : uint32_t value;
2053 : : };
2054 : :
2055 : : static void
2056 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
2057 : : __rte_unused struct cmdline *cl,
2058 : : __rte_unused void *data)
2059 : : {
2060 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
2061 : : portid_t port_id;
2062 : : int ret;
2063 : :
2064 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
2065 : : printf("Unknown parameter\n");
2066 : 0 : return;
2067 : : }
2068 : :
2069 : 0 : if (!all_ports_stopped()) {
2070 : 0 : fprintf(stderr, "Please stop all ports first\n");
2071 : 0 : return;
2072 : : }
2073 : :
2074 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
2075 : 0 : struct rte_port *port = &ports[port_id];
2076 : :
2077 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
2078 : 0 : fprintf(stderr,
2079 : : "max-pkt-len can not be less than %d\n",
2080 : : RTE_ETHER_MIN_LEN);
2081 : 0 : return;
2082 : : }
2083 : :
2084 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
2085 : 0 : if (ret != 0) {
2086 : 0 : fprintf(stderr,
2087 : : "rte_eth_dev_info_get() failed for port %u\n",
2088 : : port_id);
2089 : 0 : return;
2090 : : }
2091 : :
2092 : 0 : update_mtu_from_frame_size(port_id, res->value);
2093 : : }
2094 : :
2095 : 0 : init_port_config();
2096 : :
2097 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2098 : : }
2099 : :
2100 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2101 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2102 : : "port");
2103 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2104 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2105 : : "config");
2106 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2107 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2108 : : "all");
2109 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2110 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2111 : : "max-pkt-len");
2112 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2113 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2114 : : RTE_UINT32);
2115 : :
2116 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
2117 : : .f = cmd_config_max_pkt_len_parsed,
2118 : : .data = NULL,
2119 : : .help_str = "port config all max-pkt-len <value>",
2120 : : .tokens = {
2121 : : (void *)&cmd_config_max_pkt_len_port,
2122 : : (void *)&cmd_config_max_pkt_len_keyword,
2123 : : (void *)&cmd_config_max_pkt_len_all,
2124 : : (void *)&cmd_config_max_pkt_len_name,
2125 : : (void *)&cmd_config_max_pkt_len_value,
2126 : : NULL,
2127 : : },
2128 : : };
2129 : :
2130 : : /* *** config max LRO aggregated packet size *** */
2131 : : struct cmd_config_max_lro_pkt_size_result {
2132 : : cmdline_fixed_string_t port;
2133 : : cmdline_fixed_string_t keyword;
2134 : : cmdline_fixed_string_t all;
2135 : : cmdline_fixed_string_t name;
2136 : : uint32_t value;
2137 : : };
2138 : :
2139 : : static void
2140 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2141 : : __rte_unused struct cmdline *cl,
2142 : : __rte_unused void *data)
2143 : : {
2144 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2145 : : portid_t pid;
2146 : :
2147 : 0 : if (!all_ports_stopped()) {
2148 : 0 : fprintf(stderr, "Please stop all ports first\n");
2149 : 0 : return;
2150 : : }
2151 : :
2152 : 0 : RTE_ETH_FOREACH_DEV(pid) {
2153 : 0 : struct rte_port *port = &ports[pid];
2154 : :
2155 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
2156 : 0 : if (res->value ==
2157 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
2158 : : return;
2159 : :
2160 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2161 : : } else {
2162 : 0 : fprintf(stderr, "Unknown parameter\n");
2163 : 0 : return;
2164 : : }
2165 : : }
2166 : :
2167 : 0 : init_port_config();
2168 : :
2169 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2170 : : }
2171 : :
2172 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2173 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2174 : : port, "port");
2175 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2176 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2177 : : keyword, "config");
2178 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2179 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2180 : : all, "all");
2181 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2182 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2183 : : name, "max-lro-pkt-size");
2184 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2185 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2186 : : value, RTE_UINT32);
2187 : :
2188 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2189 : : .f = cmd_config_max_lro_pkt_size_parsed,
2190 : : .data = NULL,
2191 : : .help_str = "port config all max-lro-pkt-size <value>",
2192 : : .tokens = {
2193 : : (void *)&cmd_config_max_lro_pkt_size_port,
2194 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
2195 : : (void *)&cmd_config_max_lro_pkt_size_all,
2196 : : (void *)&cmd_config_max_lro_pkt_size_name,
2197 : : (void *)&cmd_config_max_lro_pkt_size_value,
2198 : : NULL,
2199 : : },
2200 : : };
2201 : :
2202 : : /* *** configure port MTU *** */
2203 : : struct cmd_config_mtu_result {
2204 : : cmdline_fixed_string_t port;
2205 : : cmdline_fixed_string_t keyword;
2206 : : cmdline_fixed_string_t mtu;
2207 : : portid_t port_id;
2208 : : uint16_t value;
2209 : : };
2210 : :
2211 : : static void
2212 : 0 : cmd_config_mtu_parsed(void *parsed_result,
2213 : : __rte_unused struct cmdline *cl,
2214 : : __rte_unused void *data)
2215 : : {
2216 : : struct cmd_config_mtu_result *res = parsed_result;
2217 : :
2218 : 0 : port_mtu_set(res->port_id, res->value);
2219 : 0 : }
2220 : :
2221 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
2222 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2223 : : "port");
2224 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2225 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2226 : : "config");
2227 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2228 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2229 : : "mtu");
2230 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2231 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2232 : : RTE_UINT16);
2233 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
2234 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2235 : : RTE_UINT16);
2236 : :
2237 : : static cmdline_parse_inst_t cmd_config_mtu = {
2238 : : .f = cmd_config_mtu_parsed,
2239 : : .data = NULL,
2240 : : .help_str = "port config mtu <port_id> <value>",
2241 : : .tokens = {
2242 : : (void *)&cmd_config_mtu_port,
2243 : : (void *)&cmd_config_mtu_keyword,
2244 : : (void *)&cmd_config_mtu_mtu,
2245 : : (void *)&cmd_config_mtu_port_id,
2246 : : (void *)&cmd_config_mtu_value,
2247 : : NULL,
2248 : : },
2249 : : };
2250 : :
2251 : : /* *** configure rx mode *** */
2252 : : struct cmd_config_rx_mode_flag {
2253 : : cmdline_fixed_string_t port;
2254 : : cmdline_fixed_string_t keyword;
2255 : : cmdline_fixed_string_t all;
2256 : : cmdline_fixed_string_t name;
2257 : : cmdline_fixed_string_t value;
2258 : : };
2259 : :
2260 : : static void
2261 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
2262 : : __rte_unused struct cmdline *cl,
2263 : : __rte_unused void *data)
2264 : : {
2265 : : struct cmd_config_rx_mode_flag *res = parsed_result;
2266 : :
2267 : 0 : if (!all_ports_stopped()) {
2268 : 0 : fprintf(stderr, "Please stop all ports first\n");
2269 : 0 : return;
2270 : : }
2271 : :
2272 : 0 : if (!strcmp(res->name, "drop-en")) {
2273 : 0 : if (!strcmp(res->value, "on"))
2274 : 0 : rx_drop_en = 1;
2275 : 0 : else if (!strcmp(res->value, "off"))
2276 : 0 : rx_drop_en = 0;
2277 : : else {
2278 : 0 : fprintf(stderr, "Unknown parameter\n");
2279 : 0 : return;
2280 : : }
2281 : : } else {
2282 : 0 : fprintf(stderr, "Unknown parameter\n");
2283 : 0 : return;
2284 : : }
2285 : :
2286 : 0 : init_port_config();
2287 : :
2288 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2289 : : }
2290 : :
2291 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2292 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2293 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2294 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2295 : : "config");
2296 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2297 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2298 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2299 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2300 : : "drop-en");
2301 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2302 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2303 : : "on#off");
2304 : :
2305 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2306 : : .f = cmd_config_rx_mode_flag_parsed,
2307 : : .data = NULL,
2308 : : .help_str = "port config all drop-en on|off",
2309 : : .tokens = {
2310 : : (void *)&cmd_config_rx_mode_flag_port,
2311 : : (void *)&cmd_config_rx_mode_flag_keyword,
2312 : : (void *)&cmd_config_rx_mode_flag_all,
2313 : : (void *)&cmd_config_rx_mode_flag_name,
2314 : : (void *)&cmd_config_rx_mode_flag_value,
2315 : : NULL,
2316 : : },
2317 : : };
2318 : :
2319 : : /* *** configure rss *** */
2320 : : struct cmd_config_rss {
2321 : : cmdline_fixed_string_t port;
2322 : : cmdline_fixed_string_t keyword;
2323 : : cmdline_fixed_string_t all;
2324 : : cmdline_fixed_string_t name;
2325 : : cmdline_fixed_string_t value;
2326 : : };
2327 : :
2328 : : static void
2329 : 0 : cmd_config_rss_parsed(void *parsed_result,
2330 : : __rte_unused struct cmdline *cl,
2331 : : __rte_unused void *data)
2332 : : {
2333 : : struct cmd_config_rss *res = parsed_result;
2334 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2335 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2336 : : int use_default = 0;
2337 : : int all_updated = 1;
2338 : : int diag;
2339 : : uint16_t i;
2340 : : int ret;
2341 : :
2342 : 0 : if (!strcmp(res->value, "level-default")) {
2343 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2344 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2345 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2346 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2347 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2348 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2349 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2350 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2351 : 0 : } else if (!strcmp(res->value, "default")) {
2352 : : use_default = 1;
2353 : 0 : } else if (isdigit(res->value[0])) {
2354 : : int value = atoi(res->value);
2355 : 0 : if (value > 0 && value < 64)
2356 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2357 : : else {
2358 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2359 : 0 : return;
2360 : : }
2361 : 0 : } else if (!strcmp(res->value, "none")) {
2362 : : rss_conf.rss_hf = 0;
2363 : : } else {
2364 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2365 : 0 : if (rss_conf.rss_hf == 0) {
2366 : 0 : fprintf(stderr, "Unknown parameter\n");
2367 : 0 : return;
2368 : : }
2369 : : }
2370 : : rss_conf.rss_key = NULL;
2371 : : /* Update global configuration for RSS types. */
2372 : 0 : RTE_ETH_FOREACH_DEV(i) {
2373 : : struct rte_eth_rss_conf local_rss_conf;
2374 : :
2375 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2376 : 0 : if (ret != 0)
2377 : 0 : return;
2378 : :
2379 : 0 : if (use_default)
2380 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2381 : :
2382 : 0 : local_rss_conf = rss_conf;
2383 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2384 : 0 : dev_info.flow_type_rss_offloads;
2385 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2386 : : printf("Port %u modified RSS hash function based on hardware support,"
2387 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2388 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2389 : : }
2390 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2391 : 0 : if (diag < 0) {
2392 : : all_updated = 0;
2393 : 0 : fprintf(stderr,
2394 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2395 : : i, -diag, strerror(-diag));
2396 : : }
2397 : : }
2398 : 0 : if (all_updated && !use_default) {
2399 : 0 : rss_hf = rss_conf.rss_hf;
2400 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2401 : : }
2402 : : }
2403 : :
2404 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2405 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2406 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2407 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2408 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2409 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2410 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2411 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2412 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2413 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2414 : :
2415 : : static cmdline_parse_inst_t cmd_config_rss = {
2416 : : .f = cmd_config_rss_parsed,
2417 : : .data = NULL,
2418 : : .help_str = "port config all rss "
2419 : : "all|default|level-default|level-outer|level-inner|"
2420 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2421 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2422 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2423 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2424 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2425 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2426 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2427 : : .tokens = {
2428 : : (void *)&cmd_config_rss_port,
2429 : : (void *)&cmd_config_rss_keyword,
2430 : : (void *)&cmd_config_rss_all,
2431 : : (void *)&cmd_config_rss_name,
2432 : : (void *)&cmd_config_rss_value,
2433 : : NULL,
2434 : : },
2435 : : };
2436 : :
2437 : : /* *** configure rss hash key *** */
2438 : : struct cmd_config_rss_hash_key {
2439 : : cmdline_fixed_string_t port;
2440 : : cmdline_fixed_string_t config;
2441 : : portid_t port_id;
2442 : : cmdline_fixed_string_t rss_hash_key;
2443 : : cmdline_fixed_string_t rss_type;
2444 : : cmdline_fixed_string_t key;
2445 : : };
2446 : :
2447 : : static uint8_t
2448 : : hexa_digit_to_value(char hexa_digit)
2449 : : {
2450 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2451 : : return (uint8_t) (hexa_digit - '0');
2452 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2453 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2454 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2455 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2456 : : /* Invalid hexa digit */
2457 : : return 0xFF;
2458 : : }
2459 : :
2460 : : static uint8_t
2461 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2462 : : {
2463 : : uint8_t hexa_v;
2464 : :
2465 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2466 : : if (hexa_v == 0xFF)
2467 : 0 : fprintf(stderr,
2468 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2469 : : key[idx], idx);
2470 : 0 : return hexa_v;
2471 : : }
2472 : :
2473 : : static void
2474 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2475 : : __rte_unused struct cmdline *cl,
2476 : : __rte_unused void *data)
2477 : : {
2478 : : struct cmd_config_rss_hash_key *res = parsed_result;
2479 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2480 : : uint8_t xdgt0;
2481 : : uint8_t xdgt1;
2482 : : int i;
2483 : : struct rte_eth_dev_info dev_info;
2484 : : uint8_t hash_key_size;
2485 : : uint32_t key_len;
2486 : : int ret;
2487 : :
2488 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2489 : 0 : if (ret != 0)
2490 : 0 : return;
2491 : :
2492 : 0 : if (dev_info.hash_key_size > 0 &&
2493 : : dev_info.hash_key_size <= sizeof(hash_key))
2494 : : hash_key_size = dev_info.hash_key_size;
2495 : : else {
2496 : 0 : fprintf(stderr,
2497 : : "dev_info did not provide a valid hash key size\n");
2498 : 0 : return;
2499 : : }
2500 : : /* Check the length of the RSS hash key */
2501 : 0 : key_len = strlen(res->key);
2502 : 0 : if (key_len != (hash_key_size * 2)) {
2503 : 0 : fprintf(stderr,
2504 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2505 : : (int)key_len, hash_key_size * 2);
2506 : 0 : return;
2507 : : }
2508 : : /* Translate RSS hash key into binary representation */
2509 : 0 : for (i = 0; i < hash_key_size; i++) {
2510 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2511 : 0 : if (xdgt0 == 0xFF)
2512 : : return;
2513 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2514 : 0 : if (xdgt1 == 0xFF)
2515 : : return;
2516 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2517 : : }
2518 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2519 : : hash_key_size);
2520 : : }
2521 : :
2522 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2523 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2524 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2525 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2526 : : "config");
2527 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2528 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2529 : : RTE_UINT16);
2530 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2531 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2532 : : rss_hash_key, "rss-hash-key");
2533 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2534 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2535 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2536 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2537 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2538 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2539 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2540 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2541 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2542 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2543 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2544 : :
2545 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2546 : : .f = cmd_config_rss_hash_key_parsed,
2547 : : .data = NULL,
2548 : : .help_str = "port config <port_id> rss-hash-key "
2549 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2550 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2551 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2552 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2553 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2554 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2555 : : "<string of hex digits (variable length, NIC dependent)>",
2556 : : .tokens = {
2557 : : (void *)&cmd_config_rss_hash_key_port,
2558 : : (void *)&cmd_config_rss_hash_key_config,
2559 : : (void *)&cmd_config_rss_hash_key_port_id,
2560 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2561 : : (void *)&cmd_config_rss_hash_key_rss_type,
2562 : : (void *)&cmd_config_rss_hash_key_value,
2563 : : NULL,
2564 : : },
2565 : : };
2566 : :
2567 : : /* *** configure rss hash algorithm *** */
2568 : : struct cmd_config_rss_hash_algo {
2569 : : cmdline_fixed_string_t port;
2570 : : cmdline_fixed_string_t config;
2571 : : portid_t port_id;
2572 : : cmdline_fixed_string_t rss_hash_algo;
2573 : : cmdline_fixed_string_t algo;
2574 : : };
2575 : :
2576 : : static void
2577 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2578 : : __rte_unused struct cmdline *cl,
2579 : : __rte_unused void *data)
2580 : : {
2581 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2582 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2583 : : struct rte_eth_rss_conf rss_conf;
2584 : : uint32_t algorithm;
2585 : : int ret;
2586 : :
2587 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2588 : 0 : rss_conf.rss_key = rss_key;
2589 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2590 : 0 : if (ret != 0) {
2591 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2592 : 0 : res->port_id);
2593 : 0 : return;
2594 : : }
2595 : :
2596 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2597 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2598 : 0 : if (ret != 0) {
2599 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2600 : 0 : res->port_id, res->algo);
2601 : 0 : return;
2602 : : }
2603 : :
2604 : 0 : rss_conf.algorithm = algorithm;
2605 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2606 : 0 : if (ret != 0) {
2607 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2608 : 0 : res->port_id);
2609 : 0 : return;
2610 : : }
2611 : : }
2612 : :
2613 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2614 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2615 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2616 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2617 : : "config");
2618 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2619 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2620 : : RTE_UINT16);
2621 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2622 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2623 : : rss_hash_algo, "rss-hash-algo");
2624 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2625 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2626 : : "default#simple_xor#toeplitz#"
2627 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2628 : :
2629 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2630 : : .f = cmd_config_rss_hash_algo_parsed,
2631 : : .data = NULL,
2632 : : .help_str = "port config <port_id> rss-hash-algo "
2633 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2634 : : .tokens = {
2635 : : (void *)&cmd_config_rss_hash_algo_port,
2636 : : (void *)&cmd_config_rss_hash_algo_config,
2637 : : (void *)&cmd_config_rss_hash_algo_port_id,
2638 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2639 : : (void *)&cmd_config_rss_hash_algo_algo,
2640 : : NULL,
2641 : : },
2642 : : };
2643 : :
2644 : : /* *** cleanup txq mbufs *** */
2645 : : struct cmd_cleanup_txq_mbufs_result {
2646 : : cmdline_fixed_string_t port;
2647 : : cmdline_fixed_string_t keyword;
2648 : : cmdline_fixed_string_t name;
2649 : : uint16_t port_id;
2650 : : uint16_t queue_id;
2651 : : uint32_t free_cnt;
2652 : : };
2653 : :
2654 : : static void
2655 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2656 : : __rte_unused struct cmdline *cl,
2657 : : __rte_unused void *data)
2658 : : {
2659 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2660 : 0 : uint16_t port_id = res->port_id;
2661 : 0 : uint16_t queue_id = res->queue_id;
2662 : 0 : uint32_t free_cnt = res->free_cnt;
2663 : : struct rte_eth_txq_info qinfo;
2664 : : int ret;
2665 : :
2666 : 0 : if (test_done == 0) {
2667 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2668 : 0 : return;
2669 : : }
2670 : :
2671 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2672 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2673 : : port_id, queue_id);
2674 : 0 : return;
2675 : : }
2676 : :
2677 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2678 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2679 : 0 : return;
2680 : : }
2681 : :
2682 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2683 : 0 : if (ret < 0) {
2684 : 0 : fprintf(stderr,
2685 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2686 : : port_id, queue_id, strerror(-ret), ret);
2687 : 0 : return;
2688 : : }
2689 : :
2690 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2691 : : port_id, queue_id, ret);
2692 : : }
2693 : :
2694 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2695 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2696 : : "port");
2697 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2698 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2699 : : "cleanup");
2700 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2701 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2702 : : RTE_UINT16);
2703 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2704 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2705 : : "txq");
2706 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2707 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2708 : : RTE_UINT16);
2709 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2710 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2711 : : RTE_UINT32);
2712 : :
2713 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2714 : : .f = cmd_cleanup_txq_mbufs_parsed,
2715 : : .data = NULL,
2716 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2717 : : .tokens = {
2718 : : (void *)&cmd_cleanup_txq_mbufs_port,
2719 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2720 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2721 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2722 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2723 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2724 : : NULL,
2725 : : },
2726 : : };
2727 : :
2728 : : /* *** configure port rxq/txq ring size *** */
2729 : : struct cmd_config_rxtx_ring_size {
2730 : : cmdline_fixed_string_t port;
2731 : : cmdline_fixed_string_t config;
2732 : : portid_t portid;
2733 : : cmdline_fixed_string_t rxtxq;
2734 : : uint16_t qid;
2735 : : cmdline_fixed_string_t rsize;
2736 : : uint16_t size;
2737 : : };
2738 : :
2739 : : static void
2740 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2741 : : __rte_unused struct cmdline *cl,
2742 : : __rte_unused void *data)
2743 : : {
2744 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2745 : : struct rte_port *port;
2746 : : uint8_t isrx;
2747 : :
2748 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2749 : : return;
2750 : :
2751 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2752 : 0 : fprintf(stderr, "Invalid port id\n");
2753 : 0 : return;
2754 : : }
2755 : :
2756 : 0 : port = &ports[res->portid];
2757 : :
2758 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2759 : : isrx = 1;
2760 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2761 : : isrx = 0;
2762 : : else {
2763 : 0 : fprintf(stderr, "Unknown parameter\n");
2764 : 0 : return;
2765 : : }
2766 : :
2767 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2768 : : return;
2769 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2770 : : return;
2771 : :
2772 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2773 : 0 : fprintf(stderr,
2774 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2775 : : rx_free_thresh);
2776 : 0 : return;
2777 : : }
2778 : :
2779 : 0 : if (isrx)
2780 : 0 : port->nb_rx_desc[res->qid] = res->size;
2781 : : else
2782 : 0 : port->nb_tx_desc[res->qid] = res->size;
2783 : :
2784 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2785 : : }
2786 : :
2787 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2788 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2789 : : port, "port");
2790 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2791 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2792 : : config, "config");
2793 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2794 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2795 : : portid, RTE_UINT16);
2796 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2797 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2798 : : rxtxq, "rxq#txq");
2799 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2800 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2801 : : qid, RTE_UINT16);
2802 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2803 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2804 : : rsize, "ring_size");
2805 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2806 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2807 : : size, RTE_UINT16);
2808 : :
2809 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2810 : : .f = cmd_config_rxtx_ring_size_parsed,
2811 : : .data = NULL,
2812 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2813 : : .tokens = {
2814 : : (void *)&cmd_config_rxtx_ring_size_port,
2815 : : (void *)&cmd_config_rxtx_ring_size_config,
2816 : : (void *)&cmd_config_rxtx_ring_size_portid,
2817 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2818 : : (void *)&cmd_config_rxtx_ring_size_qid,
2819 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2820 : : (void *)&cmd_config_rxtx_ring_size_size,
2821 : : NULL,
2822 : : },
2823 : : };
2824 : :
2825 : : /* *** configure port rxq/txq start/stop *** */
2826 : : struct cmd_config_rxtx_queue {
2827 : : cmdline_fixed_string_t port;
2828 : : portid_t portid;
2829 : : cmdline_fixed_string_t rxtxq;
2830 : : uint16_t qid;
2831 : : cmdline_fixed_string_t opname;
2832 : : };
2833 : :
2834 : : static void
2835 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2836 : : __rte_unused struct cmdline *cl,
2837 : : __rte_unused void *data)
2838 : : {
2839 : : struct cmd_config_rxtx_queue *res = parsed_result;
2840 : : struct rte_port *port;
2841 : : uint8_t isrx;
2842 : : uint8_t isstart;
2843 : : uint8_t *state;
2844 : : int ret = 0;
2845 : :
2846 : 0 : if (test_done == 0) {
2847 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2848 : 0 : return;
2849 : : }
2850 : :
2851 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2852 : : return;
2853 : :
2854 : 0 : if (port_is_started(res->portid) != 1) {
2855 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2856 : 0 : return;
2857 : : }
2858 : :
2859 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2860 : : isrx = 1;
2861 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2862 : : isrx = 0;
2863 : : else {
2864 : 0 : fprintf(stderr, "Unknown parameter\n");
2865 : 0 : return;
2866 : : }
2867 : :
2868 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2869 : : return;
2870 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2871 : : return;
2872 : :
2873 : 0 : if (!strcmp(res->opname, "start"))
2874 : : isstart = 1;
2875 : 0 : else if (!strcmp(res->opname, "stop"))
2876 : : isstart = 0;
2877 : : else {
2878 : 0 : fprintf(stderr, "Unknown parameter\n");
2879 : 0 : return;
2880 : : }
2881 : :
2882 : 0 : if (isstart && isrx)
2883 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2884 : 0 : else if (!isstart && isrx)
2885 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2886 : 0 : else if (isstart && !isrx)
2887 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2888 : : else
2889 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2890 : :
2891 : 0 : if (ret == -ENOTSUP) {
2892 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2893 : 0 : return;
2894 : : }
2895 : :
2896 : 0 : port = &ports[res->portid];
2897 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2898 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2899 : : RTE_ETH_QUEUE_STATE_STOPPED;
2900 : : }
2901 : :
2902 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2903 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2904 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2905 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2906 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2907 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2908 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2909 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2910 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2911 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2912 : : "start#stop");
2913 : :
2914 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2915 : : .f = cmd_config_rxtx_queue_parsed,
2916 : : .data = NULL,
2917 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2918 : : .tokens = {
2919 : : (void *)&cmd_config_rxtx_queue_port,
2920 : : (void *)&cmd_config_rxtx_queue_portid,
2921 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2922 : : (void *)&cmd_config_rxtx_queue_qid,
2923 : : (void *)&cmd_config_rxtx_queue_opname,
2924 : : NULL,
2925 : : },
2926 : : };
2927 : :
2928 : : /* *** configure port rxq/txq deferred start on/off *** */
2929 : : struct cmd_config_deferred_start_rxtx_queue {
2930 : : cmdline_fixed_string_t port;
2931 : : portid_t port_id;
2932 : : cmdline_fixed_string_t rxtxq;
2933 : : uint16_t qid;
2934 : : cmdline_fixed_string_t opname;
2935 : : cmdline_fixed_string_t state;
2936 : : };
2937 : :
2938 : : static void
2939 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2940 : : __rte_unused struct cmdline *cl,
2941 : : __rte_unused void *data)
2942 : : {
2943 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2944 : : struct rte_port *port;
2945 : : uint8_t isrx;
2946 : : uint8_t ison;
2947 : : uint8_t needreconfig = 0;
2948 : :
2949 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2950 : : return;
2951 : :
2952 : 0 : if (port_is_started(res->port_id) != 0) {
2953 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2954 : 0 : return;
2955 : : }
2956 : :
2957 : 0 : port = &ports[res->port_id];
2958 : :
2959 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2960 : :
2961 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2962 : : return;
2963 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2964 : : return;
2965 : :
2966 : 0 : ison = !strcmp(res->state, "on");
2967 : :
2968 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2969 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2970 : : needreconfig = 1;
2971 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2972 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2973 : : needreconfig = 1;
2974 : : }
2975 : :
2976 : : if (needreconfig)
2977 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2978 : : }
2979 : :
2980 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2981 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2982 : : port, "port");
2983 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2984 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2985 : : port_id, RTE_UINT16);
2986 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2987 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2988 : : rxtxq, "rxq#txq");
2989 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2990 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2991 : : qid, RTE_UINT16);
2992 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2993 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2994 : : opname, "deferred_start");
2995 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2996 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2997 : : state, "on#off");
2998 : :
2999 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
3000 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
3001 : : .data = NULL,
3002 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
3003 : : .tokens = {
3004 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
3005 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
3006 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
3007 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
3008 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
3009 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
3010 : : NULL,
3011 : : },
3012 : : };
3013 : :
3014 : : /* *** configure port rxq/txq setup *** */
3015 : : struct cmd_setup_rxtx_queue {
3016 : : cmdline_fixed_string_t port;
3017 : : portid_t portid;
3018 : : cmdline_fixed_string_t rxtxq;
3019 : : uint16_t qid;
3020 : : cmdline_fixed_string_t setup;
3021 : : };
3022 : :
3023 : : /* Common CLI fields for queue setup */
3024 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
3025 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
3026 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
3027 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
3028 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
3029 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
3030 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
3031 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
3032 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
3033 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
3034 : :
3035 : : static void
3036 : 0 : cmd_setup_rxtx_queue_parsed(
3037 : : void *parsed_result,
3038 : : __rte_unused struct cmdline *cl,
3039 : : __rte_unused void *data)
3040 : : {
3041 : : struct cmd_setup_rxtx_queue *res = parsed_result;
3042 : : struct rte_port *port;
3043 : : struct rte_mempool *mp;
3044 : : unsigned int socket_id;
3045 : : uint8_t isrx = 0;
3046 : : int ret;
3047 : :
3048 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
3049 : : return;
3050 : :
3051 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
3052 : 0 : fprintf(stderr, "Invalid port id\n");
3053 : 0 : return;
3054 : : }
3055 : :
3056 : 0 : if (!strcmp(res->rxtxq, "rxq"))
3057 : : isrx = 1;
3058 : 0 : else if (!strcmp(res->rxtxq, "txq"))
3059 : : isrx = 0;
3060 : : else {
3061 : 0 : fprintf(stderr, "Unknown parameter\n");
3062 : 0 : return;
3063 : : }
3064 : :
3065 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
3066 : 0 : fprintf(stderr, "Invalid rx queue\n");
3067 : 0 : return;
3068 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
3069 : 0 : fprintf(stderr, "Invalid tx queue\n");
3070 : 0 : return;
3071 : : }
3072 : :
3073 : 0 : port = &ports[res->portid];
3074 : 0 : if (isrx) {
3075 : 0 : socket_id = rxring_numa[res->portid];
3076 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3077 : 0 : socket_id = port->socket_id;
3078 : :
3079 : : mp = mbuf_pool_find(socket_id, 0);
3080 : 0 : if (mp == NULL) {
3081 : 0 : fprintf(stderr,
3082 : : "Failed to setup RX queue: No mempool allocation on the socket %d\n",
3083 : 0 : rxring_numa[res->portid]);
3084 : 0 : return;
3085 : : }
3086 : 0 : ret = rx_queue_setup(res->portid,
3087 : : res->qid,
3088 : 0 : port->nb_rx_desc[res->qid],
3089 : : socket_id,
3090 : 0 : &port->rxq[res->qid].conf,
3091 : : mp);
3092 : 0 : if (ret)
3093 : 0 : fprintf(stderr, "Failed to setup RX queue\n");
3094 : : } else {
3095 : 0 : socket_id = txring_numa[res->portid];
3096 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3097 : 0 : socket_id = port->socket_id;
3098 : :
3099 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
3100 : 0 : fprintf(stderr,
3101 : : "Failed to setup TX queue: not enough descriptors\n");
3102 : 0 : return;
3103 : : }
3104 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
3105 : : res->qid,
3106 : : port->nb_tx_desc[res->qid],
3107 : : socket_id,
3108 : 0 : &port->txq[res->qid].conf);
3109 : 0 : if (ret)
3110 : 0 : fprintf(stderr, "Failed to setup TX queue\n");
3111 : : }
3112 : : }
3113 : :
3114 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
3115 : : .f = cmd_setup_rxtx_queue_parsed,
3116 : : .data = NULL,
3117 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
3118 : : .tokens = {
3119 : : (void *)&cmd_setup_rxtx_queue_port,
3120 : : (void *)&cmd_setup_rxtx_queue_portid,
3121 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
3122 : : (void *)&cmd_setup_rxtx_queue_qid,
3123 : : (void *)&cmd_setup_rxtx_queue_setup,
3124 : : NULL,
3125 : : },
3126 : : };
3127 : :
3128 : :
3129 : : /* *** Configure RSS RETA *** */
3130 : : struct cmd_config_rss_reta {
3131 : : cmdline_fixed_string_t port;
3132 : : cmdline_fixed_string_t keyword;
3133 : : portid_t port_id;
3134 : : cmdline_fixed_string_t name;
3135 : : cmdline_fixed_string_t list_name;
3136 : : cmdline_fixed_string_t list_of_items;
3137 : : };
3138 : :
3139 : : static int
3140 : 0 : parse_reta_config(const char *str,
3141 : : struct rte_eth_rss_reta_entry64 *reta_conf,
3142 : : uint16_t nb_entries)
3143 : : {
3144 : : int i;
3145 : : unsigned size;
3146 : : uint16_t hash_index, idx, shift;
3147 : : uint16_t nb_queue;
3148 : : char s[256];
3149 : : const char *p, *p0 = str;
3150 : : char *end;
3151 : : enum fieldnames {
3152 : : FLD_HASH_INDEX = 0,
3153 : : FLD_QUEUE,
3154 : : _NUM_FLD
3155 : : };
3156 : : unsigned long int_fld[_NUM_FLD];
3157 : : char *str_fld[_NUM_FLD];
3158 : :
3159 : 0 : while ((p = strchr(p0,'(')) != NULL) {
3160 : 0 : ++p;
3161 : 0 : if((p0 = strchr(p,')')) == NULL)
3162 : : return -1;
3163 : :
3164 : 0 : size = p0 - p;
3165 : 0 : if(size >= sizeof(s))
3166 : : return -1;
3167 : :
3168 : : snprintf(s, sizeof(s), "%.*s", size, p);
3169 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3170 : : return -1;
3171 : 0 : for (i = 0; i < _NUM_FLD; i++) {
3172 : 0 : errno = 0;
3173 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
3174 : 0 : if (errno != 0 || end == str_fld[i] ||
3175 : : int_fld[i] > 65535)
3176 : : return -1;
3177 : : }
3178 : :
3179 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3180 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3181 : :
3182 : 0 : if (hash_index >= nb_entries) {
3183 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
3184 : : hash_index);
3185 : 0 : return -1;
3186 : : }
3187 : :
3188 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3189 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3190 : 0 : reta_conf[idx].mask |= (1ULL << shift);
3191 : 0 : reta_conf[idx].reta[shift] = nb_queue;
3192 : : }
3193 : :
3194 : : return 0;
3195 : : }
3196 : :
3197 : : static void
3198 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
3199 : : __rte_unused struct cmdline *cl,
3200 : : __rte_unused void *data)
3201 : : {
3202 : : int ret;
3203 : : struct rte_eth_dev_info dev_info;
3204 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3205 : : struct cmd_config_rss_reta *res = parsed_result;
3206 : :
3207 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3208 : 0 : if (ret != 0)
3209 : 0 : return;
3210 : :
3211 : 0 : if (dev_info.reta_size == 0) {
3212 : 0 : fprintf(stderr,
3213 : : "Redirection table size is 0 which is invalid for RSS\n");
3214 : 0 : return;
3215 : : } else
3216 : 0 : printf("The reta size of port %d is %u\n",
3217 : 0 : res->port_id, dev_info.reta_size);
3218 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3219 : 0 : fprintf(stderr,
3220 : : "Currently do not support more than %u entries of redirection table\n",
3221 : : RTE_ETH_RSS_RETA_SIZE_512);
3222 : 0 : return;
3223 : : }
3224 : :
3225 : : memset(reta_conf, 0, sizeof(reta_conf));
3226 : 0 : if (!strcmp(res->list_name, "reta")) {
3227 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
3228 : : dev_info.reta_size)) {
3229 : 0 : fprintf(stderr,
3230 : : "Invalid RSS Redirection Table config entered\n");
3231 : 0 : return;
3232 : : }
3233 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
3234 : 0 : reta_conf, dev_info.reta_size);
3235 : 0 : if (ret != 0)
3236 : 0 : fprintf(stderr,
3237 : : "Bad redirection table parameter, return code = %d\n",
3238 : : ret);
3239 : : }
3240 : : }
3241 : :
3242 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3243 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3244 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3245 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3246 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3247 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3248 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3249 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3250 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3251 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3252 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3253 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3254 : : NULL);
3255 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
3256 : : .f = cmd_set_rss_reta_parsed,
3257 : : .data = NULL,
3258 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3259 : : .tokens = {
3260 : : (void *)&cmd_config_rss_reta_port,
3261 : : (void *)&cmd_config_rss_reta_keyword,
3262 : : (void *)&cmd_config_rss_reta_port_id,
3263 : : (void *)&cmd_config_rss_reta_name,
3264 : : (void *)&cmd_config_rss_reta_list_name,
3265 : : (void *)&cmd_config_rss_reta_list_of_items,
3266 : : NULL,
3267 : : },
3268 : : };
3269 : :
3270 : : /* *** SHOW PORT RETA INFO *** */
3271 : : struct cmd_showport_reta {
3272 : : cmdline_fixed_string_t show;
3273 : : cmdline_fixed_string_t port;
3274 : : portid_t port_id;
3275 : : cmdline_fixed_string_t rss;
3276 : : cmdline_fixed_string_t reta;
3277 : : uint16_t size;
3278 : : cmdline_fixed_string_t list_of_items;
3279 : : };
3280 : :
3281 : : static int
3282 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3283 : : uint16_t nb_entries,
3284 : : char *str)
3285 : : {
3286 : : uint32_t size;
3287 : : const char *p, *p0 = str;
3288 : : char s[256];
3289 : : char *end;
3290 : : char *str_fld[8];
3291 : : uint16_t i;
3292 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3293 : : RTE_ETH_RETA_GROUP_SIZE;
3294 : : int ret;
3295 : :
3296 : 0 : p = strchr(p0, '(');
3297 : 0 : if (p == NULL)
3298 : : return -1;
3299 : 0 : p++;
3300 : 0 : p0 = strchr(p, ')');
3301 : 0 : if (p0 == NULL)
3302 : : return -1;
3303 : 0 : size = p0 - p;
3304 : 0 : if (size >= sizeof(s)) {
3305 : 0 : fprintf(stderr,
3306 : : "The string size exceeds the internal buffer size\n");
3307 : 0 : return -1;
3308 : : }
3309 : : snprintf(s, sizeof(s), "%.*s", size, p);
3310 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3311 : 0 : if (ret <= 0 || ret != num) {
3312 : 0 : fprintf(stderr,
3313 : : "The bits of masks do not match the number of reta entries: %u\n",
3314 : : num);
3315 : 0 : return -1;
3316 : : }
3317 : 0 : for (i = 0; i < ret; i++)
3318 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3319 : :
3320 : : return 0;
3321 : : }
3322 : :
3323 : : static void
3324 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3325 : : __rte_unused struct cmdline *cl,
3326 : : __rte_unused void *data)
3327 : : {
3328 : : struct cmd_showport_reta *res = parsed_result;
3329 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3330 : : struct rte_eth_dev_info dev_info;
3331 : : uint16_t max_reta_size;
3332 : : int ret;
3333 : :
3334 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3335 : 0 : if (ret != 0)
3336 : 0 : return;
3337 : :
3338 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3339 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3340 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3341 : : res->size, max_reta_size);
3342 : 0 : return;
3343 : : }
3344 : :
3345 : : memset(reta_conf, 0, sizeof(reta_conf));
3346 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3347 : 0 : res->list_of_items) < 0) {
3348 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3349 : : res->list_of_items);
3350 : 0 : return;
3351 : : }
3352 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3353 : : }
3354 : :
3355 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3356 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3357 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3358 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3359 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3360 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3361 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3362 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3363 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3364 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3365 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3366 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3367 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3368 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3369 : : list_of_items, NULL);
3370 : :
3371 : : static cmdline_parse_inst_t cmd_showport_reta = {
3372 : : .f = cmd_showport_reta_parsed,
3373 : : .data = NULL,
3374 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3375 : : .tokens = {
3376 : : (void *)&cmd_showport_reta_show,
3377 : : (void *)&cmd_showport_reta_port,
3378 : : (void *)&cmd_showport_reta_port_id,
3379 : : (void *)&cmd_showport_reta_rss,
3380 : : (void *)&cmd_showport_reta_reta,
3381 : : (void *)&cmd_showport_reta_size,
3382 : : (void *)&cmd_showport_reta_list_of_items,
3383 : : NULL,
3384 : : },
3385 : : };
3386 : :
3387 : : /* *** Show RSS hash configuration *** */
3388 : : struct cmd_showport_rss_hash {
3389 : : cmdline_fixed_string_t show;
3390 : : cmdline_fixed_string_t port;
3391 : : portid_t port_id;
3392 : : cmdline_fixed_string_t rss_hash;
3393 : : cmdline_fixed_string_t rss_type;
3394 : : cmdline_fixed_string_t key; /* optional argument */
3395 : : cmdline_fixed_string_t algorithm; /* optional argument */
3396 : : };
3397 : :
3398 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3399 : : __rte_unused struct cmdline *cl,
3400 : : __rte_unused void *data)
3401 : : {
3402 : : struct cmd_showport_rss_hash *res = parsed_result;
3403 : :
3404 : 0 : port_rss_hash_conf_show(res->port_id,
3405 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3406 : 0 : }
3407 : :
3408 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3409 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3410 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3411 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3412 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3413 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3414 : : RTE_UINT16);
3415 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3416 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3417 : : "rss-hash");
3418 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3419 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3420 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3421 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3422 : :
3423 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3424 : : .f = cmd_showport_rss_hash_parsed,
3425 : : .data = NULL,
3426 : : .help_str = "show port <port_id> rss-hash",
3427 : : .tokens = {
3428 : : (void *)&cmd_showport_rss_hash_show,
3429 : : (void *)&cmd_showport_rss_hash_port,
3430 : : (void *)&cmd_showport_rss_hash_port_id,
3431 : : (void *)&cmd_showport_rss_hash_rss_hash,
3432 : : NULL,
3433 : : },
3434 : : };
3435 : :
3436 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3437 : : .f = cmd_showport_rss_hash_parsed,
3438 : : .data = NULL,
3439 : : .help_str = "show port <port_id> rss-hash key",
3440 : : .tokens = {
3441 : : (void *)&cmd_showport_rss_hash_show,
3442 : : (void *)&cmd_showport_rss_hash_port,
3443 : : (void *)&cmd_showport_rss_hash_port_id,
3444 : : (void *)&cmd_showport_rss_hash_rss_hash,
3445 : : (void *)&cmd_showport_rss_hash_rss_key,
3446 : : NULL,
3447 : : },
3448 : : };
3449 : :
3450 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3451 : : .f = cmd_showport_rss_hash_parsed,
3452 : : .data = NULL,
3453 : : .help_str = "show port <port_id> rss-hash algorithm",
3454 : : .tokens = {
3455 : : (void *)&cmd_showport_rss_hash_show,
3456 : : (void *)&cmd_showport_rss_hash_port,
3457 : : (void *)&cmd_showport_rss_hash_port_id,
3458 : : (void *)&cmd_showport_rss_hash_rss_hash,
3459 : : (void *)&cmd_showport_rss_hash_rss_algo,
3460 : : NULL,
3461 : : },
3462 : : };
3463 : :
3464 : : /* *** Configure DCB *** */
3465 : : struct cmd_config_dcb {
3466 : : cmdline_fixed_string_t port;
3467 : : cmdline_fixed_string_t config;
3468 : : portid_t port_id;
3469 : : cmdline_fixed_string_t dcb;
3470 : : cmdline_fixed_string_t vt;
3471 : : cmdline_fixed_string_t vt_en;
3472 : : uint8_t num_tcs;
3473 : : cmdline_fixed_string_t pfc;
3474 : : cmdline_multi_string_t token_str;
3475 : : };
3476 : :
3477 : : static int
3478 : 0 : parse_dcb_token_prio_tc(char *param_str[], int param_num,
3479 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3480 : : uint8_t *prio_tc_en)
3481 : : {
3482 : : unsigned long prio, tc;
3483 : : int prio_tc_maps = 0;
3484 : : char *param, *end;
3485 : : int i;
3486 : :
3487 : 0 : for (i = 0; i < param_num; i++) {
3488 : 0 : param = param_str[i];
3489 : 0 : prio = strtoul(param, &end, 10);
3490 : 0 : if (prio >= RTE_ETH_DCB_NUM_USER_PRIORITIES) {
3491 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO %lu\n", prio);
3492 : 0 : return -1;
3493 : : }
3494 : 0 : if ((*end != ':') || (strlen(end + 1) == 0)) {
3495 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3496 : 0 : return -1;
3497 : : }
3498 : 0 : tc = strtoul(end + 1, &end, 10);
3499 : 0 : if (tc >= RTE_ETH_8_TCS) {
3500 : 0 : fprintf(stderr, "Bad Argument: invalid TC %lu\n", tc);
3501 : 0 : return -1;
3502 : : }
3503 : 0 : if (*end != '\0') {
3504 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3505 : 0 : return -1;
3506 : : }
3507 : 0 : prio_tc[prio] = tc;
3508 : 0 : prio_tc_maps++;
3509 : : } while (0);
3510 : :
3511 : 0 : if (prio_tc_maps == 0) {
3512 : 0 : fprintf(stderr, "Bad Argument: no PRIO:TC provided\n");
3513 : 0 : return -1;
3514 : : }
3515 : 0 : *prio_tc_en = 1;
3516 : :
3517 : 0 : return 0;
3518 : : }
3519 : :
3520 : : #define DCB_TOKEN_PRIO_TC "prio-tc"
3521 : : #define DCB_TOKEN_KEEP_QNUM "keep-qnum"
3522 : :
3523 : : static int
3524 : 0 : parse_dcb_token_find(char *split_str[], int split_num, int *param_num)
3525 : : {
3526 : : int i;
3527 : :
3528 : 0 : if (strcmp(split_str[0], DCB_TOKEN_KEEP_QNUM) == 0) {
3529 : 0 : *param_num = 0;
3530 : 0 : return 0;
3531 : : }
3532 : :
3533 : 0 : if (strcmp(split_str[0], DCB_TOKEN_PRIO_TC) != 0) {
3534 : 0 : fprintf(stderr, "Bad Argument: unknown token %s\n", split_str[0]);
3535 : 0 : return -EINVAL;
3536 : : }
3537 : :
3538 : 0 : for (i = 1; i < split_num; i++) {
3539 : 0 : if ((strcmp(split_str[i], DCB_TOKEN_PRIO_TC) != 0) &&
3540 : 0 : (strcmp(split_str[i], DCB_TOKEN_KEEP_QNUM) != 0))
3541 : : continue;
3542 : : /* find another optional parameter, then exit. */
3543 : : break;
3544 : : }
3545 : :
3546 : 0 : *param_num = i - 1;
3547 : :
3548 : 0 : return 0;
3549 : : }
3550 : :
3551 : : static int
3552 : 0 : parse_dcb_token_value(char *token_str,
3553 : : uint8_t *pfc_en,
3554 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3555 : : uint8_t *prio_tc_en,
3556 : : uint8_t *keep_qnum)
3557 : : {
3558 : : #define MAX_TOKEN_NUM 128
3559 : : char *split_str[MAX_TOKEN_NUM];
3560 : : int param_num, start, ret;
3561 : : int split_num = 0;
3562 : : char *token;
3563 : :
3564 : : /* split multiple token to split str. */
3565 : : do {
3566 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
3567 : 0 : if (token == NULL)
3568 : : break;
3569 : 0 : if (split_num >= MAX_TOKEN_NUM) {
3570 : 0 : fprintf(stderr, "Bad Argument: too much argument\n");
3571 : 0 : return -1;
3572 : : }
3573 : 0 : split_str[split_num++] = token;
3574 : : } while (1);
3575 : :
3576 : : /* parse fixed parameter "pfc-en" first. */
3577 : 0 : token = split_str[0];
3578 : 0 : if (strcmp(token, "on") == 0)
3579 : 0 : *pfc_en = 1;
3580 : 0 : else if (strcmp(token, "off") == 0)
3581 : 0 : *pfc_en = 0;
3582 : : else {
3583 : 0 : fprintf(stderr, "Bad Argument: pfc-en must be on or off\n");
3584 : 0 : return -EINVAL;
3585 : : }
3586 : :
3587 : 0 : if (split_num == 1)
3588 : : return 0;
3589 : :
3590 : : /* start parse optional parameter. */
3591 : : start = 1;
3592 : : do {
3593 : 0 : param_num = 0;
3594 : 0 : ret = parse_dcb_token_find(&split_str[start], split_num - start, ¶m_num);
3595 : 0 : if (ret != 0)
3596 : 0 : return ret;
3597 : :
3598 : 0 : token = split_str[start];
3599 : 0 : if (strcmp(token, DCB_TOKEN_PRIO_TC) == 0) {
3600 : 0 : if (*prio_tc_en == 1) {
3601 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3602 : : DCB_TOKEN_PRIO_TC);
3603 : 0 : return -1;
3604 : : }
3605 : 0 : ret = parse_dcb_token_prio_tc(&split_str[start + 1], param_num, prio_tc,
3606 : : prio_tc_en);
3607 : 0 : if (ret != 0)
3608 : 0 : return ret;
3609 : : } else {
3610 : : /* this must be keep-qnum. */
3611 : 0 : if (*keep_qnum == 1) {
3612 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3613 : : DCB_TOKEN_KEEP_QNUM);
3614 : 0 : return -1;
3615 : : }
3616 : 0 : *keep_qnum = 1;
3617 : : }
3618 : :
3619 : 0 : start += param_num + 1;
3620 : 0 : if (start >= split_num)
3621 : : break;
3622 : : } while (1);
3623 : :
3624 : : return 0;
3625 : : }
3626 : :
3627 : : static void
3628 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3629 : : __rte_unused struct cmdline *cl,
3630 : : __rte_unused void *data)
3631 : : {
3632 : 0 : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES] = {0};
3633 : : struct cmd_config_dcb *res = parsed_result;
3634 : : struct rte_eth_dcb_info dcb_info;
3635 : 0 : portid_t port_id = res->port_id;
3636 : 0 : uint8_t prio_tc_en = 0;
3637 : 0 : uint8_t keep_qnum = 0;
3638 : : struct rte_port *port;
3639 : 0 : uint8_t pfc_en = 0;
3640 : : int ret;
3641 : :
3642 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
3643 : 0 : return;
3644 : :
3645 : 0 : port = &ports[port_id];
3646 : : /** Check if the port is not started **/
3647 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3648 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3649 : 0 : return;
3650 : : }
3651 : :
3652 : 0 : if (res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS) {
3653 : 0 : fprintf(stderr,
3654 : : "The invalid number of traffic class, only 1~8 allowed.\n");
3655 : 0 : return;
3656 : : }
3657 : :
3658 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3659 : 0 : fprintf(stderr,
3660 : : "nb_cores shouldn't be less than number of TCs.\n");
3661 : 0 : return;
3662 : : }
3663 : :
3664 : : /* Check whether the port supports the report of DCB info. */
3665 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3666 : 0 : if (ret == -ENOTSUP) {
3667 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3668 : 0 : return;
3669 : : }
3670 : :
3671 : 0 : ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en, &keep_qnum);
3672 : 0 : if (ret != 0)
3673 : : return;
3674 : :
3675 : : /* DCB in VT mode */
3676 : 0 : if (!strncmp(res->vt_en, "on", 2))
3677 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3678 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3679 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3680 : : else
3681 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3682 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3683 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3684 : 0 : if (ret != 0) {
3685 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3686 : 0 : return;
3687 : : }
3688 : :
3689 : 0 : fwd_config_setup();
3690 : :
3691 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3692 : : }
3693 : :
3694 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3695 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3696 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3697 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3698 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3699 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3700 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3701 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3702 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3703 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3704 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3705 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3706 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3707 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3708 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3709 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3710 : : static cmdline_parse_token_string_t cmd_config_dcb_token_str =
3711 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, token_str, TOKEN_STRING_MULTI);
3712 : :
3713 : : static cmdline_parse_inst_t cmd_config_dcb = {
3714 : : .f = cmd_config_dcb_parsed,
3715 : : .data = NULL,
3716 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP keep-qnum\n"
3717 : : "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
3718 : : " PRIO-MAPPING := PRIO:TC\n"
3719 : : " PRIO: { 0 .. 7 }\n"
3720 : : " TC: { 0 .. 7 }",
3721 : : .tokens = {
3722 : : (void *)&cmd_config_dcb_port,
3723 : : (void *)&cmd_config_dcb_config,
3724 : : (void *)&cmd_config_dcb_port_id,
3725 : : (void *)&cmd_config_dcb_dcb,
3726 : : (void *)&cmd_config_dcb_vt,
3727 : : (void *)&cmd_config_dcb_vt_en,
3728 : : (void *)&cmd_config_dcb_num_tcs,
3729 : : (void *)&cmd_config_dcb_pfc,
3730 : : (void *)&cmd_config_dcb_token_str,
3731 : : NULL,
3732 : : },
3733 : : };
3734 : :
3735 : : /* *** configure number of packets per burst *** */
3736 : : struct cmd_config_burst {
3737 : : cmdline_fixed_string_t port;
3738 : : cmdline_fixed_string_t keyword;
3739 : : cmdline_fixed_string_t all;
3740 : : cmdline_fixed_string_t name;
3741 : : uint16_t value;
3742 : : };
3743 : :
3744 : : static void
3745 : 0 : cmd_config_burst_parsed(void *parsed_result,
3746 : : __rte_unused struct cmdline *cl,
3747 : : __rte_unused void *data)
3748 : : {
3749 : : struct cmd_config_burst *res = parsed_result;
3750 : : struct rte_eth_dev_info dev_info;
3751 : : uint16_t rec_nb_pkts;
3752 : : int ret;
3753 : :
3754 : 0 : if (!all_ports_stopped()) {
3755 : 0 : fprintf(stderr, "Please stop all ports first\n");
3756 : 0 : return;
3757 : : }
3758 : :
3759 : 0 : if (!strcmp(res->name, "burst")) {
3760 : 0 : if (res->value == 0) {
3761 : : /* If user gives a value of zero, query the PMD for
3762 : : * its recommended Rx burst size. Testpmd uses a single
3763 : : * size for all ports, so assume all ports are the same
3764 : : * NIC model and use the values from Port 0.
3765 : : */
3766 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3767 : 0 : if (ret != 0)
3768 : : return;
3769 : :
3770 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3771 : :
3772 : 0 : if (rec_nb_pkts == 0) {
3773 : : printf("PMD does not recommend a burst size.\n"
3774 : : "User provided value must be between"
3775 : : " 1 and %d\n", MAX_PKT_BURST);
3776 : 0 : return;
3777 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3778 : 0 : printf("PMD recommended burst size of %d"
3779 : : " exceeds maximum value of %d\n",
3780 : : rec_nb_pkts, MAX_PKT_BURST);
3781 : 0 : return;
3782 : : }
3783 : 0 : printf("Using PMD-provided burst value of %d\n",
3784 : : rec_nb_pkts);
3785 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3786 : 0 : } else if (res->value > MAX_PKT_BURST) {
3787 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3788 : : MAX_PKT_BURST);
3789 : 0 : return;
3790 : : } else
3791 : 0 : nb_pkt_per_burst = res->value;
3792 : : } else {
3793 : 0 : fprintf(stderr, "Unknown parameter\n");
3794 : 0 : return;
3795 : : }
3796 : :
3797 : 0 : init_port_config();
3798 : :
3799 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3800 : : }
3801 : :
3802 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3803 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3804 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3805 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3806 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3807 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3808 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3809 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3810 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3811 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3812 : :
3813 : : static cmdline_parse_inst_t cmd_config_burst = {
3814 : : .f = cmd_config_burst_parsed,
3815 : : .data = NULL,
3816 : : .help_str = "port config all burst <value>",
3817 : : .tokens = {
3818 : : (void *)&cmd_config_burst_port,
3819 : : (void *)&cmd_config_burst_keyword,
3820 : : (void *)&cmd_config_burst_all,
3821 : : (void *)&cmd_config_burst_name,
3822 : : (void *)&cmd_config_burst_value,
3823 : : NULL,
3824 : : },
3825 : : };
3826 : :
3827 : : /* *** configure rx/tx queues *** */
3828 : : struct cmd_config_thresh {
3829 : : cmdline_fixed_string_t port;
3830 : : cmdline_fixed_string_t keyword;
3831 : : cmdline_fixed_string_t all;
3832 : : cmdline_fixed_string_t name;
3833 : : uint8_t value;
3834 : : };
3835 : :
3836 : : static void
3837 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3838 : : __rte_unused struct cmdline *cl,
3839 : : __rte_unused void *data)
3840 : : {
3841 : : struct cmd_config_thresh *res = parsed_result;
3842 : :
3843 : 0 : if (!all_ports_stopped()) {
3844 : 0 : fprintf(stderr, "Please stop all ports first\n");
3845 : 0 : return;
3846 : : }
3847 : :
3848 : 0 : if (!strcmp(res->name, "txpt"))
3849 : 0 : tx_pthresh = res->value;
3850 : 0 : else if(!strcmp(res->name, "txht"))
3851 : 0 : tx_hthresh = res->value;
3852 : 0 : else if(!strcmp(res->name, "txwt"))
3853 : 0 : tx_wthresh = res->value;
3854 : 0 : else if(!strcmp(res->name, "rxpt"))
3855 : 0 : rx_pthresh = res->value;
3856 : 0 : else if(!strcmp(res->name, "rxht"))
3857 : 0 : rx_hthresh = res->value;
3858 : 0 : else if(!strcmp(res->name, "rxwt"))
3859 : 0 : rx_wthresh = res->value;
3860 : : else {
3861 : 0 : fprintf(stderr, "Unknown parameter\n");
3862 : 0 : return;
3863 : : }
3864 : :
3865 : 0 : init_port_config();
3866 : :
3867 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3868 : : }
3869 : :
3870 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3871 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3872 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3873 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3874 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3875 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3876 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3877 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3878 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3879 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3880 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3881 : :
3882 : : static cmdline_parse_inst_t cmd_config_thresh = {
3883 : : .f = cmd_config_thresh_parsed,
3884 : : .data = NULL,
3885 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3886 : : .tokens = {
3887 : : (void *)&cmd_config_thresh_port,
3888 : : (void *)&cmd_config_thresh_keyword,
3889 : : (void *)&cmd_config_thresh_all,
3890 : : (void *)&cmd_config_thresh_name,
3891 : : (void *)&cmd_config_thresh_value,
3892 : : NULL,
3893 : : },
3894 : : };
3895 : :
3896 : : /* *** configure free/rs threshold *** */
3897 : : struct cmd_config_threshold {
3898 : : cmdline_fixed_string_t port;
3899 : : cmdline_fixed_string_t keyword;
3900 : : cmdline_fixed_string_t all;
3901 : : cmdline_fixed_string_t name;
3902 : : uint16_t value;
3903 : : };
3904 : :
3905 : : static void
3906 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3907 : : __rte_unused struct cmdline *cl,
3908 : : __rte_unused void *data)
3909 : : {
3910 : : struct cmd_config_threshold *res = parsed_result;
3911 : :
3912 : 0 : if (!all_ports_stopped()) {
3913 : 0 : fprintf(stderr, "Please stop all ports first\n");
3914 : 0 : return;
3915 : : }
3916 : :
3917 : 0 : if (!strcmp(res->name, "txfreet"))
3918 : 0 : tx_free_thresh = res->value;
3919 : 0 : else if (!strcmp(res->name, "txrst"))
3920 : 0 : tx_rs_thresh = res->value;
3921 : 0 : else if (!strcmp(res->name, "rxfreet"))
3922 : 0 : rx_free_thresh = res->value;
3923 : : else {
3924 : 0 : fprintf(stderr, "Unknown parameter\n");
3925 : 0 : return;
3926 : : }
3927 : :
3928 : 0 : init_port_config();
3929 : :
3930 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3931 : : }
3932 : :
3933 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3934 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3935 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3936 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3937 : : "config");
3938 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3939 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3940 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3941 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3942 : : "txfreet#txrst#rxfreet");
3943 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3944 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3945 : :
3946 : : static cmdline_parse_inst_t cmd_config_threshold = {
3947 : : .f = cmd_config_threshold_parsed,
3948 : : .data = NULL,
3949 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3950 : : .tokens = {
3951 : : (void *)&cmd_config_threshold_port,
3952 : : (void *)&cmd_config_threshold_keyword,
3953 : : (void *)&cmd_config_threshold_all,
3954 : : (void *)&cmd_config_threshold_name,
3955 : : (void *)&cmd_config_threshold_value,
3956 : : NULL,
3957 : : },
3958 : : };
3959 : :
3960 : : /* *** stop *** */
3961 : : struct cmd_stop_result {
3962 : : cmdline_fixed_string_t stop;
3963 : : };
3964 : :
3965 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3966 : : __rte_unused struct cmdline *cl,
3967 : : __rte_unused void *data)
3968 : : {
3969 : 0 : stop_packet_forwarding();
3970 : 0 : }
3971 : :
3972 : : static cmdline_parse_token_string_t cmd_stop_stop =
3973 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3974 : :
3975 : : static cmdline_parse_inst_t cmd_stop = {
3976 : : .f = cmd_stop_parsed,
3977 : : .data = NULL,
3978 : : .help_str = "stop: Stop packet forwarding",
3979 : : .tokens = {
3980 : : (void *)&cmd_stop_stop,
3981 : : NULL,
3982 : : },
3983 : : };
3984 : :
3985 : : static unsigned int
3986 : 0 : get_ptype(char *value)
3987 : : {
3988 : : uint32_t protocol;
3989 : :
3990 : 0 : if (!strcmp(value, "eth"))
3991 : : protocol = RTE_PTYPE_L2_ETHER;
3992 : 0 : else if (!strcmp(value, "ipv4"))
3993 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3994 : 0 : else if (!strcmp(value, "ipv6"))
3995 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3996 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3997 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3998 : 0 : else if (!strcmp(value, "ipv4-udp"))
3999 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
4000 : 0 : else if (!strcmp(value, "ipv4-sctp"))
4001 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4002 : 0 : else if (!strcmp(value, "ipv6-tcp"))
4003 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
4004 : 0 : else if (!strcmp(value, "ipv6-udp"))
4005 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
4006 : 0 : else if (!strcmp(value, "ipv6-sctp"))
4007 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4008 : 0 : else if (!strcmp(value, "grenat"))
4009 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
4010 : 0 : else if (!strcmp(value, "inner-eth"))
4011 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
4012 : 0 : else if (!strcmp(value, "inner-ipv4"))
4013 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4014 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
4015 : 0 : else if (!strcmp(value, "inner-ipv6"))
4016 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4017 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
4018 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
4019 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4020 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4021 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
4022 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4023 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4024 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
4025 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4026 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4027 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
4028 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4029 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4030 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
4031 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4032 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4033 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
4034 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4035 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4036 : : else {
4037 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
4038 : : protocol = RTE_PTYPE_UNKNOWN;
4039 : : }
4040 : :
4041 : 0 : return protocol;
4042 : : }
4043 : :
4044 : : /* *** SET RXHDRSLIST *** */
4045 : :
4046 : : unsigned int
4047 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
4048 : : unsigned int *parsed_items)
4049 : : {
4050 : : unsigned int nb_item;
4051 : : char *cur;
4052 : : char *tmp;
4053 : :
4054 : : nb_item = 0;
4055 : 0 : char *str2 = strdup(str);
4056 : 0 : if (str2 == NULL)
4057 : : return nb_item;
4058 : 0 : cur = strtok_r(str2, ",", &tmp);
4059 : 0 : while (cur != NULL) {
4060 : 0 : parsed_items[nb_item] = get_ptype(cur);
4061 : 0 : cur = strtok_r(NULL, ",", &tmp);
4062 : 0 : nb_item++;
4063 : : }
4064 : 0 : if (nb_item > max_items)
4065 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4066 : : item_name, nb_item + 1, max_items);
4067 : 0 : free(str2);
4068 : 0 : return nb_item;
4069 : : }
4070 : :
4071 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
4072 : :
4073 : : unsigned int
4074 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
4075 : : unsigned int *parsed_items, int check_unique_values)
4076 : : {
4077 : : unsigned int nb_item;
4078 : : unsigned int value;
4079 : : unsigned int i;
4080 : : unsigned int j;
4081 : : int value_ok;
4082 : : char c;
4083 : :
4084 : : /*
4085 : : * First parse all items in the list and store their value.
4086 : : */
4087 : : value = 0;
4088 : : nb_item = 0;
4089 : : value_ok = 0;
4090 : 0 : for (i = 0; i < strnlen(str, STR_MULTI_TOKEN_SIZE); i++) {
4091 : 0 : c = str[i];
4092 : 0 : if ((c >= '0') && (c <= '9')) {
4093 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
4094 : : value_ok = 1;
4095 : 0 : continue;
4096 : : }
4097 : 0 : if (c != ',') {
4098 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
4099 : 0 : return 0;
4100 : : }
4101 : 0 : if (! value_ok) {
4102 : 0 : fprintf(stderr, "No valid value before comma\n");
4103 : 0 : return 0;
4104 : : }
4105 : 0 : if (nb_item < max_items) {
4106 : 0 : parsed_items[nb_item] = value;
4107 : : value_ok = 0;
4108 : : value = 0;
4109 : : }
4110 : 0 : nb_item++;
4111 : : }
4112 : 0 : if (nb_item >= max_items) {
4113 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4114 : : item_name, nb_item + 1, max_items);
4115 : 0 : return 0;
4116 : : }
4117 : 0 : parsed_items[nb_item++] = value;
4118 : 0 : if (! check_unique_values)
4119 : : return nb_item;
4120 : :
4121 : : /*
4122 : : * Then, check that all values in the list are different.
4123 : : * No optimization here...
4124 : : */
4125 : 0 : for (i = 0; i < nb_item; i++) {
4126 : 0 : for (j = i + 1; j < nb_item; j++) {
4127 : 0 : if (parsed_items[j] == parsed_items[i]) {
4128 : 0 : fprintf(stderr,
4129 : : "duplicated %s %u at index %u and %u\n",
4130 : : item_name, parsed_items[i], i, j);
4131 : 0 : return 0;
4132 : : }
4133 : : }
4134 : : }
4135 : : return nb_item;
4136 : : }
4137 : :
4138 : : struct cmd_set_list_result {
4139 : : cmdline_fixed_string_t cmd_keyword;
4140 : : cmdline_fixed_string_t list_name;
4141 : : cmdline_multi_string_t list_of_items;
4142 : : };
4143 : :
4144 : 0 : static void cmd_set_list_parsed(void *parsed_result,
4145 : : __rte_unused struct cmdline *cl,
4146 : : __rte_unused void *data)
4147 : : {
4148 : : struct cmd_set_list_result *res;
4149 : : union {
4150 : : unsigned int lcorelist[RTE_MAX_LCORE];
4151 : : unsigned int portlist[RTE_MAX_ETHPORTS];
4152 : : } parsed_items;
4153 : : unsigned int nb_item;
4154 : :
4155 : 0 : if (test_done == 0) {
4156 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4157 : 0 : return;
4158 : : }
4159 : :
4160 : : res = parsed_result;
4161 : 0 : if (!strcmp(res->list_name, "corelist")) {
4162 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
4163 : : RTE_MAX_LCORE,
4164 : : parsed_items.lcorelist, 1);
4165 : 0 : if (nb_item > 0) {
4166 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
4167 : 0 : fwd_config_setup();
4168 : : }
4169 : 0 : return;
4170 : : }
4171 : 0 : if (!strcmp(res->list_name, "portlist")) {
4172 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
4173 : : RTE_MAX_ETHPORTS,
4174 : : parsed_items.portlist, 1);
4175 : 0 : if (nb_item > 0) {
4176 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
4177 : 0 : fwd_config_setup();
4178 : : }
4179 : : }
4180 : : }
4181 : :
4182 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
4183 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
4184 : : "set");
4185 : : static cmdline_parse_token_string_t cmd_set_list_name =
4186 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
4187 : : "corelist#portlist");
4188 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
4189 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
4190 : : TOKEN_STRING_MULTI);
4191 : :
4192 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
4193 : : .f = cmd_set_list_parsed,
4194 : : .data = NULL,
4195 : : .help_str = "set corelist|portlist <list0[,list1]*>",
4196 : : .tokens = {
4197 : : (void *)&cmd_set_list_keyword,
4198 : : (void *)&cmd_set_list_name,
4199 : : (void *)&cmd_set_list_of_items,
4200 : : NULL,
4201 : : },
4202 : : };
4203 : :
4204 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
4205 : :
4206 : : struct cmd_setmask_result {
4207 : : cmdline_fixed_string_t set;
4208 : : cmdline_fixed_string_t mask;
4209 : : uint64_t hexavalue;
4210 : : };
4211 : :
4212 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
4213 : : __rte_unused struct cmdline *cl,
4214 : : __rte_unused void *data)
4215 : : {
4216 : : struct cmd_setmask_result *res = parsed_result;
4217 : :
4218 : 0 : if (test_done == 0) {
4219 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4220 : 0 : return;
4221 : : }
4222 : 0 : if (!strcmp(res->mask, "coremask")) {
4223 : 0 : set_fwd_lcores_mask(res->hexavalue);
4224 : 0 : fwd_config_setup();
4225 : 0 : } else if (!strcmp(res->mask, "portmask")) {
4226 : 0 : set_fwd_ports_mask(res->hexavalue);
4227 : 0 : fwd_config_setup();
4228 : : }
4229 : : }
4230 : :
4231 : : static cmdline_parse_token_string_t cmd_setmask_set =
4232 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
4233 : : static cmdline_parse_token_string_t cmd_setmask_mask =
4234 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
4235 : : "coremask#portmask");
4236 : : static cmdline_parse_token_num_t cmd_setmask_value =
4237 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
4238 : :
4239 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
4240 : : .f = cmd_set_mask_parsed,
4241 : : .data = NULL,
4242 : : .help_str = "set coremask|portmask <hexadecimal value>",
4243 : : .tokens = {
4244 : : (void *)&cmd_setmask_set,
4245 : : (void *)&cmd_setmask_mask,
4246 : : (void *)&cmd_setmask_value,
4247 : : NULL,
4248 : : },
4249 : : };
4250 : :
4251 : : /*
4252 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
4253 : : */
4254 : : struct cmd_set_result {
4255 : : cmdline_fixed_string_t set;
4256 : : cmdline_fixed_string_t what;
4257 : : uint16_t value;
4258 : : };
4259 : :
4260 : 0 : static void cmd_set_parsed(void *parsed_result,
4261 : : __rte_unused struct cmdline *cl,
4262 : : __rte_unused void *data)
4263 : : {
4264 : : struct cmd_set_result *res = parsed_result;
4265 : 0 : if (!strcmp(res->what, "nbport")) {
4266 : 0 : set_fwd_ports_number(res->value);
4267 : 0 : fwd_config_setup();
4268 : 0 : } else if (!strcmp(res->what, "nbcore")) {
4269 : 0 : set_fwd_lcores_number(res->value);
4270 : 0 : fwd_config_setup();
4271 : 0 : } else if (!strcmp(res->what, "burst"))
4272 : 0 : set_nb_pkt_per_burst(res->value);
4273 : 0 : else if (!strcmp(res->what, "verbose"))
4274 : 0 : set_verbose_level(res->value);
4275 : 0 : }
4276 : :
4277 : : static cmdline_parse_token_string_t cmd_set_set =
4278 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
4279 : : static cmdline_parse_token_string_t cmd_set_what =
4280 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
4281 : : "nbport#nbcore#burst#verbose");
4282 : : static cmdline_parse_token_num_t cmd_set_value =
4283 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
4284 : :
4285 : : static cmdline_parse_inst_t cmd_set_numbers = {
4286 : : .f = cmd_set_parsed,
4287 : : .data = NULL,
4288 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
4289 : : .tokens = {
4290 : : (void *)&cmd_set_set,
4291 : : (void *)&cmd_set_what,
4292 : : (void *)&cmd_set_value,
4293 : : NULL,
4294 : : },
4295 : : };
4296 : :
4297 : : /* *** SET LOG LEVEL CONFIGURATION *** */
4298 : :
4299 : : struct cmd_set_log_result {
4300 : : cmdline_fixed_string_t set;
4301 : : cmdline_fixed_string_t log;
4302 : : cmdline_fixed_string_t type;
4303 : : uint32_t level;
4304 : : };
4305 : :
4306 : : static void
4307 : 0 : cmd_set_log_parsed(void *parsed_result,
4308 : : __rte_unused struct cmdline *cl,
4309 : : __rte_unused void *data)
4310 : : {
4311 : : struct cmd_set_log_result *res;
4312 : : int ret;
4313 : :
4314 : : res = parsed_result;
4315 : 0 : if (!strcmp(res->type, "global"))
4316 : 0 : rte_log_set_global_level(res->level);
4317 : : else {
4318 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
4319 : 0 : if (ret < 0)
4320 : 0 : fprintf(stderr, "Unable to set log level\n");
4321 : : }
4322 : 0 : }
4323 : :
4324 : : static cmdline_parse_token_string_t cmd_set_log_set =
4325 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
4326 : : static cmdline_parse_token_string_t cmd_set_log_log =
4327 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
4328 : : static cmdline_parse_token_string_t cmd_set_log_type =
4329 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
4330 : : static cmdline_parse_token_num_t cmd_set_log_level =
4331 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
4332 : :
4333 : : static cmdline_parse_inst_t cmd_set_log = {
4334 : : .f = cmd_set_log_parsed,
4335 : : .data = NULL,
4336 : : .help_str = "set log global|<type> <level>",
4337 : : .tokens = {
4338 : : (void *)&cmd_set_log_set,
4339 : : (void *)&cmd_set_log_log,
4340 : : (void *)&cmd_set_log_type,
4341 : : (void *)&cmd_set_log_level,
4342 : : NULL,
4343 : : },
4344 : : };
4345 : :
4346 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
4347 : :
4348 : : struct cmd_set_rxoffs_result {
4349 : : cmdline_fixed_string_t cmd_keyword;
4350 : : cmdline_fixed_string_t rxoffs;
4351 : : cmdline_fixed_string_t seg_offsets;
4352 : : };
4353 : :
4354 : : static void
4355 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
4356 : : __rte_unused struct cmdline *cl,
4357 : : __rte_unused void *data)
4358 : : {
4359 : : struct cmd_set_rxoffs_result *res;
4360 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
4361 : : unsigned int nb_segs;
4362 : :
4363 : : res = parsed_result;
4364 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
4365 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
4366 : 0 : if (nb_segs > 0)
4367 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
4368 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4369 : 0 : }
4370 : :
4371 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
4372 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4373 : : cmd_keyword, "set");
4374 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
4375 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4376 : : rxoffs, "rxoffs");
4377 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
4378 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4379 : : seg_offsets, NULL);
4380 : :
4381 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
4382 : : .f = cmd_set_rxoffs_parsed,
4383 : : .data = NULL,
4384 : : .help_str = "set rxoffs <len0[,len1]*>",
4385 : : .tokens = {
4386 : : (void *)&cmd_set_rxoffs_keyword,
4387 : : (void *)&cmd_set_rxoffs_name,
4388 : : (void *)&cmd_set_rxoffs_offsets,
4389 : : NULL,
4390 : : },
4391 : : };
4392 : :
4393 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
4394 : :
4395 : : struct cmd_set_rxpkts_result {
4396 : : cmdline_fixed_string_t cmd_keyword;
4397 : : cmdline_fixed_string_t rxpkts;
4398 : : cmdline_fixed_string_t seg_lengths;
4399 : : };
4400 : :
4401 : : static void
4402 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
4403 : : __rte_unused struct cmdline *cl,
4404 : : __rte_unused void *data)
4405 : : {
4406 : : struct cmd_set_rxpkts_result *res;
4407 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
4408 : : unsigned int nb_segs;
4409 : :
4410 : : res = parsed_result;
4411 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4412 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
4413 : 0 : if (nb_segs > 0)
4414 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
4415 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4416 : 0 : }
4417 : :
4418 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
4419 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4420 : : cmd_keyword, "set");
4421 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
4422 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4423 : : rxpkts, "rxpkts");
4424 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4425 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4426 : : seg_lengths, NULL);
4427 : :
4428 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
4429 : : .f = cmd_set_rxpkts_parsed,
4430 : : .data = NULL,
4431 : : .help_str = "set rxpkts <len0[,len1]*>",
4432 : : .tokens = {
4433 : : (void *)&cmd_set_rxpkts_keyword,
4434 : : (void *)&cmd_set_rxpkts_name,
4435 : : (void *)&cmd_set_rxpkts_lengths,
4436 : : NULL,
4437 : : },
4438 : : };
4439 : :
4440 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4441 : : struct cmd_set_rxhdrs_result {
4442 : : cmdline_fixed_string_t set;
4443 : : cmdline_fixed_string_t rxhdrs;
4444 : : cmdline_fixed_string_t values;
4445 : : };
4446 : :
4447 : : static void
4448 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4449 : : __rte_unused struct cmdline *cl,
4450 : : __rte_unused void *data)
4451 : : {
4452 : : struct cmd_set_rxhdrs_result *res;
4453 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4454 : : unsigned int nb_segs;
4455 : :
4456 : : res = parsed_result;
4457 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4458 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4459 : 0 : if (nb_segs > 0)
4460 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4461 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4462 : 0 : }
4463 : :
4464 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4465 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4466 : : set, "set");
4467 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4468 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4469 : : rxhdrs, "rxhdrs");
4470 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4471 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4472 : : values, NULL);
4473 : :
4474 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4475 : : .f = cmd_set_rxhdrs_parsed,
4476 : : .data = NULL,
4477 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4478 : : .tokens = {
4479 : : (void *)&cmd_set_rxhdrs_set,
4480 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4481 : : (void *)&cmd_set_rxhdrs_values,
4482 : : NULL,
4483 : : },
4484 : : };
4485 : :
4486 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4487 : :
4488 : : struct cmd_set_txpkts_result {
4489 : : cmdline_fixed_string_t cmd_keyword;
4490 : : cmdline_fixed_string_t txpkts;
4491 : : cmdline_fixed_string_t seg_lengths;
4492 : : };
4493 : :
4494 : : static void
4495 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4496 : : __rte_unused struct cmdline *cl,
4497 : : __rte_unused void *data)
4498 : : {
4499 : : struct cmd_set_txpkts_result *res;
4500 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4501 : : unsigned int nb_segs;
4502 : :
4503 : : res = parsed_result;
4504 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4505 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4506 : 0 : if (nb_segs > 0)
4507 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4508 : 0 : }
4509 : :
4510 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4511 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4512 : : cmd_keyword, "set");
4513 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4514 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4515 : : txpkts, "txpkts");
4516 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4517 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4518 : : seg_lengths, NULL);
4519 : :
4520 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4521 : : .f = cmd_set_txpkts_parsed,
4522 : : .data = NULL,
4523 : : .help_str = "set txpkts <len0[,len1]*>",
4524 : : .tokens = {
4525 : : (void *)&cmd_set_txpkts_keyword,
4526 : : (void *)&cmd_set_txpkts_name,
4527 : : (void *)&cmd_set_txpkts_lengths,
4528 : : NULL,
4529 : : },
4530 : : };
4531 : :
4532 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4533 : :
4534 : : struct cmd_set_txsplit_result {
4535 : : cmdline_fixed_string_t cmd_keyword;
4536 : : cmdline_fixed_string_t txsplit;
4537 : : cmdline_fixed_string_t mode;
4538 : : };
4539 : :
4540 : : static void
4541 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4542 : : __rte_unused struct cmdline *cl,
4543 : : __rte_unused void *data)
4544 : : {
4545 : : struct cmd_set_txsplit_result *res;
4546 : :
4547 : : res = parsed_result;
4548 : 0 : set_tx_pkt_split(res->mode);
4549 : 0 : }
4550 : :
4551 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4552 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4553 : : cmd_keyword, "set");
4554 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4555 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4556 : : txsplit, "txsplit");
4557 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4558 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4559 : : mode, NULL);
4560 : :
4561 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4562 : : .f = cmd_set_txsplit_parsed,
4563 : : .data = NULL,
4564 : : .help_str = "set txsplit on|off|rand",
4565 : : .tokens = {
4566 : : (void *)&cmd_set_txsplit_keyword,
4567 : : (void *)&cmd_set_txsplit_name,
4568 : : (void *)&cmd_set_txsplit_mode,
4569 : : NULL,
4570 : : },
4571 : : };
4572 : :
4573 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4574 : :
4575 : : struct cmd_set_txtimes_result {
4576 : : cmdline_fixed_string_t cmd_keyword;
4577 : : cmdline_fixed_string_t txtimes;
4578 : : cmdline_fixed_string_t tx_times;
4579 : : };
4580 : :
4581 : : static void
4582 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4583 : : __rte_unused struct cmdline *cl,
4584 : : __rte_unused void *data)
4585 : : {
4586 : : struct cmd_set_txtimes_result *res;
4587 : 0 : unsigned int tx_times[2] = {0, 0};
4588 : : unsigned int n_times;
4589 : :
4590 : : res = parsed_result;
4591 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4592 : : 2, tx_times, 0);
4593 : 0 : if (n_times == 2)
4594 : 0 : set_tx_pkt_times(tx_times);
4595 : 0 : }
4596 : :
4597 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4598 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4599 : : cmd_keyword, "set");
4600 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4601 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4602 : : txtimes, "txtimes");
4603 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4604 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4605 : : tx_times, NULL);
4606 : :
4607 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4608 : : .f = cmd_set_txtimes_parsed,
4609 : : .data = NULL,
4610 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4611 : : .tokens = {
4612 : : (void *)&cmd_set_txtimes_keyword,
4613 : : (void *)&cmd_set_txtimes_name,
4614 : : (void *)&cmd_set_txtimes_value,
4615 : : NULL,
4616 : : },
4617 : : };
4618 : :
4619 : : /* *** SET NUMBER OF FLOWS IN TXONLY MULTI-FLOW MODE *** */
4620 : :
4621 : : struct cmd_set_txflows_result {
4622 : : cmdline_fixed_string_t cmd_keyword;
4623 : : cmdline_fixed_string_t name;
4624 : : uint16_t value;
4625 : : };
4626 : :
4627 : : static void
4628 : 0 : cmd_set_txflows_parsed(void *parsed_result,
4629 : : __rte_unused struct cmdline *cl,
4630 : : __rte_unused void *data)
4631 : : {
4632 : : struct cmd_set_txflows_result *res = parsed_result;
4633 : :
4634 : 0 : if (res->value < 1 || res->value > 64) {
4635 : 0 : fprintf(stderr, "txonly-flows must be >= 1 and <= 64\n");
4636 : 0 : return;
4637 : : }
4638 : 0 : txonly_flows = res->value;
4639 : : }
4640 : :
4641 : : static cmdline_parse_token_string_t cmd_set_txflows_keyword =
4642 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txflows_result,
4643 : : cmd_keyword, "set");
4644 : : static cmdline_parse_token_string_t cmd_set_txflows_name =
4645 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txflows_result,
4646 : : name, "txonly-flows");
4647 : : static cmdline_parse_token_num_t cmd_set_txflows_value =
4648 : : TOKEN_NUM_INITIALIZER(struct cmd_set_txflows_result,
4649 : : value, RTE_UINT16);
4650 : :
4651 : : static cmdline_parse_inst_t cmd_set_txflows = {
4652 : : .f = cmd_set_txflows_parsed,
4653 : : .data = NULL,
4654 : : .help_str = "set txonly-flows <N>",
4655 : : .tokens = {
4656 : : (void *)&cmd_set_txflows_keyword,
4657 : : (void *)&cmd_set_txflows_name,
4658 : : (void *)&cmd_set_txflows_value,
4659 : : NULL,
4660 : : },
4661 : : };
4662 : :
4663 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4664 : : struct cmd_rx_vlan_filter_all_result {
4665 : : cmdline_fixed_string_t rx_vlan;
4666 : : cmdline_fixed_string_t what;
4667 : : cmdline_fixed_string_t all;
4668 : : portid_t port_id;
4669 : : };
4670 : :
4671 : : static void
4672 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4673 : : __rte_unused struct cmdline *cl,
4674 : : __rte_unused void *data)
4675 : : {
4676 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4677 : :
4678 : 0 : if (!strcmp(res->what, "add"))
4679 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4680 : : else
4681 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4682 : 0 : }
4683 : :
4684 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4685 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4686 : : rx_vlan, "rx_vlan");
4687 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4688 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4689 : : what, "add#rm");
4690 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4691 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4692 : : all, "all");
4693 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4694 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4695 : : port_id, RTE_UINT16);
4696 : :
4697 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4698 : : .f = cmd_rx_vlan_filter_all_parsed,
4699 : : .data = NULL,
4700 : : .help_str = "rx_vlan add|rm all <port_id>: "
4701 : : "Add/Remove all identifiers to/from the set of VLAN "
4702 : : "identifiers filtered by a port",
4703 : : .tokens = {
4704 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4705 : : (void *)&cmd_rx_vlan_filter_all_what,
4706 : : (void *)&cmd_rx_vlan_filter_all_all,
4707 : : (void *)&cmd_rx_vlan_filter_all_portid,
4708 : : NULL,
4709 : : },
4710 : : };
4711 : :
4712 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4713 : : struct cmd_vlan_offload_result {
4714 : : cmdline_fixed_string_t vlan;
4715 : : cmdline_fixed_string_t set;
4716 : : cmdline_fixed_string_t vlan_type;
4717 : : cmdline_fixed_string_t what;
4718 : : cmdline_fixed_string_t on;
4719 : : cmdline_fixed_string_t port_id;
4720 : : };
4721 : :
4722 : : static void
4723 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4724 : : __rte_unused struct cmdline *cl,
4725 : : __rte_unused void *data)
4726 : : {
4727 : : int on;
4728 : : struct cmd_vlan_offload_result *res = parsed_result;
4729 : : char *str;
4730 : : int i, len = 0;
4731 : : portid_t port_id = 0;
4732 : : unsigned int tmp;
4733 : :
4734 : 0 : str = res->port_id;
4735 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4736 : : i = 0;
4737 : : /* Get port_id first */
4738 : 0 : while(i < len){
4739 : 0 : if(str[i] == ',')
4740 : : break;
4741 : :
4742 : 0 : i++;
4743 : : }
4744 : 0 : str[i]='\0';
4745 : 0 : tmp = strtoul(str, NULL, 0);
4746 : : /* If port_id greater that what portid_t can represent, return */
4747 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4748 : : return;
4749 : 0 : port_id = (portid_t)tmp;
4750 : :
4751 : 0 : if (!strcmp(res->on, "on"))
4752 : : on = 1;
4753 : : else
4754 : : on = 0;
4755 : :
4756 : 0 : if (!strcmp(res->what, "strip"))
4757 : 0 : rx_vlan_strip_set(port_id, on);
4758 : 0 : else if(!strcmp(res->what, "stripq")){
4759 : : uint16_t queue_id = 0;
4760 : :
4761 : : /* No queue_id, return */
4762 : 0 : if(i + 1 >= len) {
4763 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4764 : 0 : return;
4765 : : }
4766 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4767 : : /* If queue_id greater that what 16-bits can represent, return */
4768 : 0 : if(tmp > 0xffff)
4769 : : return;
4770 : :
4771 : 0 : queue_id = (uint16_t)tmp;
4772 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4773 : : }
4774 : 0 : else if (!strcmp(res->what, "filter"))
4775 : 0 : rx_vlan_filter_set(port_id, on);
4776 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4777 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4778 : : else
4779 : 0 : vlan_extend_set(port_id, on);
4780 : :
4781 : : return;
4782 : : }
4783 : :
4784 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4785 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4786 : : vlan, "vlan");
4787 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4788 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4789 : : set, "set");
4790 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4791 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4792 : : what, "strip#filter#qinq_strip#extend#stripq");
4793 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4794 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4795 : : on, "on#off");
4796 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4797 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4798 : : port_id, NULL);
4799 : :
4800 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4801 : : .f = cmd_vlan_offload_parsed,
4802 : : .data = NULL,
4803 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4804 : : "<port_id[,queue_id]>: "
4805 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4806 : : .tokens = {
4807 : : (void *)&cmd_vlan_offload_vlan,
4808 : : (void *)&cmd_vlan_offload_set,
4809 : : (void *)&cmd_vlan_offload_what,
4810 : : (void *)&cmd_vlan_offload_on,
4811 : : (void *)&cmd_vlan_offload_portid,
4812 : : NULL,
4813 : : },
4814 : : };
4815 : :
4816 : : /* *** VLAN TPID SET ON A PORT *** */
4817 : : struct cmd_vlan_tpid_result {
4818 : : cmdline_fixed_string_t vlan;
4819 : : cmdline_fixed_string_t set;
4820 : : cmdline_fixed_string_t vlan_type;
4821 : : cmdline_fixed_string_t what;
4822 : : uint16_t tp_id;
4823 : : portid_t port_id;
4824 : : };
4825 : :
4826 : : static void
4827 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4828 : : __rte_unused struct cmdline *cl,
4829 : : __rte_unused void *data)
4830 : : {
4831 : : struct cmd_vlan_tpid_result *res = parsed_result;
4832 : : enum rte_vlan_type vlan_type;
4833 : :
4834 : 0 : if (!strcmp(res->vlan_type, "inner"))
4835 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4836 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4837 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4838 : : else {
4839 : 0 : fprintf(stderr, "Unknown vlan type\n");
4840 : 0 : return;
4841 : : }
4842 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4843 : : }
4844 : :
4845 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4846 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4847 : : vlan, "vlan");
4848 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4849 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4850 : : set, "set");
4851 : : static cmdline_parse_token_string_t cmd_vlan_type =
4852 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4853 : : vlan_type, "inner#outer");
4854 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4855 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4856 : : what, "tpid");
4857 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4858 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4859 : : tp_id, RTE_UINT16);
4860 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4861 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4862 : : port_id, RTE_UINT16);
4863 : :
4864 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4865 : : .f = cmd_vlan_tpid_parsed,
4866 : : .data = NULL,
4867 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4868 : : "Set the VLAN Ether type",
4869 : : .tokens = {
4870 : : (void *)&cmd_vlan_tpid_vlan,
4871 : : (void *)&cmd_vlan_tpid_set,
4872 : : (void *)&cmd_vlan_type,
4873 : : (void *)&cmd_vlan_tpid_what,
4874 : : (void *)&cmd_vlan_tpid_tpid,
4875 : : (void *)&cmd_vlan_tpid_portid,
4876 : : NULL,
4877 : : },
4878 : : };
4879 : :
4880 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4881 : : struct cmd_rx_vlan_filter_result {
4882 : : cmdline_fixed_string_t rx_vlan;
4883 : : cmdline_fixed_string_t what;
4884 : : uint16_t vlan_id;
4885 : : portid_t port_id;
4886 : : };
4887 : :
4888 : : static void
4889 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4890 : : __rte_unused struct cmdline *cl,
4891 : : __rte_unused void *data)
4892 : : {
4893 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4894 : :
4895 : 0 : if (!strcmp(res->what, "add"))
4896 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4897 : : else
4898 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4899 : 0 : }
4900 : :
4901 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4902 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4903 : : rx_vlan, "rx_vlan");
4904 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4905 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4906 : : what, "add#rm");
4907 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4908 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4909 : : vlan_id, RTE_UINT16);
4910 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4911 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4912 : : port_id, RTE_UINT16);
4913 : :
4914 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4915 : : .f = cmd_rx_vlan_filter_parsed,
4916 : : .data = NULL,
4917 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4918 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4919 : : "identifiers filtered by a port",
4920 : : .tokens = {
4921 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4922 : : (void *)&cmd_rx_vlan_filter_what,
4923 : : (void *)&cmd_rx_vlan_filter_vlanid,
4924 : : (void *)&cmd_rx_vlan_filter_portid,
4925 : : NULL,
4926 : : },
4927 : : };
4928 : :
4929 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4930 : : struct cmd_tx_vlan_set_result {
4931 : : cmdline_fixed_string_t tx_vlan;
4932 : : cmdline_fixed_string_t set;
4933 : : portid_t port_id;
4934 : : uint16_t vlan_id;
4935 : : };
4936 : :
4937 : : static void
4938 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4939 : : __rte_unused struct cmdline *cl,
4940 : : __rte_unused void *data)
4941 : : {
4942 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4943 : :
4944 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4945 : : return;
4946 : :
4947 : 0 : if (!port_is_stopped(res->port_id)) {
4948 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4949 : 0 : return;
4950 : : }
4951 : :
4952 : 0 : tx_vlan_set(res->port_id, res->vlan_id);
4953 : :
4954 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4955 : : }
4956 : :
4957 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4958 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4959 : : tx_vlan, "tx_vlan");
4960 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4961 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4962 : : set, "set");
4963 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4964 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4965 : : port_id, RTE_UINT16);
4966 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4967 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4968 : : vlan_id, RTE_UINT16);
4969 : :
4970 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4971 : : .f = cmd_tx_vlan_set_parsed,
4972 : : .data = NULL,
4973 : : .help_str = "tx_vlan set <port_id> <vlan_id>: "
4974 : : "Enable hardware insertion of a single VLAN header "
4975 : : "with a given TAG Identifier in packets sent on a port",
4976 : : .tokens = {
4977 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4978 : : (void *)&cmd_tx_vlan_set_set,
4979 : : (void *)&cmd_tx_vlan_set_portid,
4980 : : (void *)&cmd_tx_vlan_set_vlanid,
4981 : : NULL,
4982 : : },
4983 : : };
4984 : :
4985 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4986 : : struct cmd_tx_vlan_set_qinq_result {
4987 : : cmdline_fixed_string_t tx_vlan;
4988 : : cmdline_fixed_string_t set;
4989 : : portid_t port_id;
4990 : : uint16_t vlan_id;
4991 : : uint16_t vlan_id_outer;
4992 : : };
4993 : :
4994 : : static void
4995 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4996 : : __rte_unused struct cmdline *cl,
4997 : : __rte_unused void *data)
4998 : : {
4999 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
5000 : :
5001 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5002 : : return;
5003 : :
5004 : 0 : if (!port_is_stopped(res->port_id)) {
5005 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5006 : 0 : return;
5007 : : }
5008 : :
5009 : 0 : tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
5010 : :
5011 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5012 : : }
5013 : :
5014 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
5015 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5016 : : tx_vlan, "tx_vlan");
5017 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
5018 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5019 : : set, "set");
5020 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
5021 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5022 : : port_id, RTE_UINT16);
5023 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
5024 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5025 : : vlan_id, RTE_UINT16);
5026 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
5027 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5028 : : vlan_id_outer, RTE_UINT16);
5029 : :
5030 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
5031 : : .f = cmd_tx_vlan_set_qinq_parsed,
5032 : : .data = NULL,
5033 : : .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
5034 : : "Enable hardware insertion of double VLAN header "
5035 : : "with given TAG Identifiers in packets sent on a port",
5036 : : .tokens = {
5037 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
5038 : : (void *)&cmd_tx_vlan_set_qinq_set,
5039 : : (void *)&cmd_tx_vlan_set_qinq_portid,
5040 : : (void *)&cmd_tx_vlan_set_qinq_vlanid,
5041 : : (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
5042 : : NULL,
5043 : : },
5044 : : };
5045 : :
5046 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
5047 : : struct cmd_tx_vlan_set_pvid_result {
5048 : : cmdline_fixed_string_t tx_vlan;
5049 : : cmdline_fixed_string_t set;
5050 : : cmdline_fixed_string_t pvid;
5051 : : portid_t port_id;
5052 : : uint16_t vlan_id;
5053 : : cmdline_fixed_string_t mode;
5054 : : };
5055 : :
5056 : : static void
5057 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
5058 : : __rte_unused struct cmdline *cl,
5059 : : __rte_unused void *data)
5060 : : {
5061 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
5062 : :
5063 : 0 : if (strcmp(res->mode, "on") == 0)
5064 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
5065 : : else
5066 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
5067 : 0 : }
5068 : :
5069 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
5070 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5071 : : tx_vlan, "tx_vlan");
5072 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
5073 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5074 : : set, "set");
5075 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
5076 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5077 : : pvid, "pvid");
5078 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
5079 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5080 : : port_id, RTE_UINT16);
5081 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
5082 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5083 : : vlan_id, RTE_UINT16);
5084 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
5085 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5086 : : mode, "on#off");
5087 : :
5088 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
5089 : : .f = cmd_tx_vlan_set_pvid_parsed,
5090 : : .data = NULL,
5091 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
5092 : : .tokens = {
5093 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
5094 : : (void *)&cmd_tx_vlan_set_pvid_set,
5095 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
5096 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
5097 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
5098 : : (void *)&cmd_tx_vlan_set_pvid_mode,
5099 : : NULL,
5100 : : },
5101 : : };
5102 : :
5103 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
5104 : : struct cmd_tx_vlan_reset_result {
5105 : : cmdline_fixed_string_t tx_vlan;
5106 : : cmdline_fixed_string_t reset;
5107 : : portid_t port_id;
5108 : : };
5109 : :
5110 : : static void
5111 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
5112 : : __rte_unused struct cmdline *cl,
5113 : : __rte_unused void *data)
5114 : : {
5115 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
5116 : :
5117 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5118 : : return;
5119 : :
5120 : 0 : if (!port_is_stopped(res->port_id)) {
5121 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5122 : 0 : return;
5123 : : }
5124 : :
5125 : 0 : tx_vlan_reset(res->port_id);
5126 : :
5127 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5128 : : }
5129 : :
5130 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
5131 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5132 : : tx_vlan, "tx_vlan");
5133 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
5134 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5135 : : reset, "reset");
5136 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
5137 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
5138 : : port_id, RTE_UINT16);
5139 : :
5140 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
5141 : : .f = cmd_tx_vlan_reset_parsed,
5142 : : .data = NULL,
5143 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
5144 : : "VLAN header in packets sent on a port",
5145 : : .tokens = {
5146 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
5147 : : (void *)&cmd_tx_vlan_reset_reset,
5148 : : (void *)&cmd_tx_vlan_reset_portid,
5149 : : NULL,
5150 : : },
5151 : : };
5152 : :
5153 : :
5154 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
5155 : : struct cmd_csum_result {
5156 : : cmdline_fixed_string_t csum;
5157 : : cmdline_fixed_string_t mode;
5158 : : cmdline_fixed_string_t proto;
5159 : : cmdline_fixed_string_t hwsw;
5160 : : portid_t port_id;
5161 : : };
5162 : :
5163 : : static void
5164 : 0 : csum_show(int port_id)
5165 : : {
5166 : : struct rte_eth_dev_info dev_info;
5167 : : uint64_t tx_offloads;
5168 : : int ret;
5169 : :
5170 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
5171 : 0 : printf("Parse tunnel is %s\n",
5172 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
5173 : 0 : printf("IP checksum offload is %s\n",
5174 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
5175 : 0 : printf("UDP checksum offload is %s\n",
5176 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
5177 : 0 : printf("TCP checksum offload is %s\n",
5178 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
5179 : 0 : printf("SCTP checksum offload is %s\n",
5180 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
5181 : 0 : printf("Outer-Ip checksum offload is %s\n",
5182 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
5183 : 0 : printf("Outer-Udp checksum offload is %s\n",
5184 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
5185 : :
5186 : : /* display warnings if configuration is not supported by the NIC */
5187 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
5188 : 0 : if (ret != 0)
5189 : 0 : return;
5190 : :
5191 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
5192 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
5193 : 0 : fprintf(stderr,
5194 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
5195 : : port_id);
5196 : : }
5197 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
5198 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
5199 : 0 : fprintf(stderr,
5200 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
5201 : : port_id);
5202 : : }
5203 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
5204 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
5205 : 0 : fprintf(stderr,
5206 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
5207 : : port_id);
5208 : : }
5209 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
5210 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
5211 : 0 : fprintf(stderr,
5212 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
5213 : : port_id);
5214 : : }
5215 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
5216 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
5217 : 0 : fprintf(stderr,
5218 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
5219 : : port_id);
5220 : : }
5221 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
5222 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
5223 : : == 0) {
5224 : 0 : fprintf(stderr,
5225 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
5226 : : port_id);
5227 : : }
5228 : : }
5229 : :
5230 : : static void
5231 : : cmd_config_queue_tx_offloads(struct rte_port *port)
5232 : : {
5233 : : int k;
5234 : :
5235 : : /* Apply queue tx offloads configuration */
5236 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
5237 : 0 : port->txq[k].conf.offloads =
5238 : 0 : port->dev_conf.txmode.offloads;
5239 : : }
5240 : :
5241 : : static void
5242 : 0 : cmd_csum_parsed(void *parsed_result,
5243 : : __rte_unused struct cmdline *cl,
5244 : : __rte_unused void *data)
5245 : : {
5246 : : struct cmd_csum_result *res = parsed_result;
5247 : : int hw = 0;
5248 : : uint64_t csum_offloads = 0;
5249 : : struct rte_eth_dev_info dev_info;
5250 : : int ret;
5251 : :
5252 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
5253 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
5254 : 0 : return;
5255 : : }
5256 : 0 : if (!port_is_stopped(res->port_id)) {
5257 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5258 : 0 : return;
5259 : : }
5260 : :
5261 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5262 : 0 : if (ret != 0)
5263 : : return;
5264 : :
5265 : 0 : if (!strcmp(res->mode, "set")) {
5266 : :
5267 : 0 : if (!strcmp(res->hwsw, "hw"))
5268 : : hw = 1;
5269 : :
5270 : 0 : if (!strcmp(res->proto, "ip")) {
5271 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5272 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
5273 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
5274 : : } else {
5275 : 0 : fprintf(stderr,
5276 : : "IP checksum offload is not supported by port %u\n",
5277 : 0 : res->port_id);
5278 : : }
5279 : 0 : } else if (!strcmp(res->proto, "udp")) {
5280 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5281 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
5282 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
5283 : : } else {
5284 : 0 : fprintf(stderr,
5285 : : "UDP checksum offload is not supported by port %u\n",
5286 : 0 : res->port_id);
5287 : : }
5288 : 0 : } else if (!strcmp(res->proto, "tcp")) {
5289 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5290 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
5291 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
5292 : : } else {
5293 : 0 : fprintf(stderr,
5294 : : "TCP checksum offload is not supported by port %u\n",
5295 : 0 : res->port_id);
5296 : : }
5297 : 0 : } else if (!strcmp(res->proto, "sctp")) {
5298 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5299 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
5300 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
5301 : : } else {
5302 : 0 : fprintf(stderr,
5303 : : "SCTP checksum offload is not supported by port %u\n",
5304 : 0 : res->port_id);
5305 : : }
5306 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
5307 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5308 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5309 : : csum_offloads |=
5310 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
5311 : : } else {
5312 : 0 : fprintf(stderr,
5313 : : "Outer IP checksum offload is not supported by port %u\n",
5314 : 0 : res->port_id);
5315 : : }
5316 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
5317 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5318 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
5319 : : csum_offloads |=
5320 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
5321 : : } else {
5322 : 0 : fprintf(stderr,
5323 : : "Outer UDP checksum offload is not supported by port %u\n",
5324 : 0 : res->port_id);
5325 : : }
5326 : : }
5327 : :
5328 : 0 : if (hw) {
5329 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5330 : : csum_offloads;
5331 : : } else {
5332 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5333 : 0 : (~csum_offloads);
5334 : : }
5335 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5336 : : }
5337 : 0 : csum_show(res->port_id);
5338 : :
5339 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5340 : : }
5341 : :
5342 : : static cmdline_parse_token_string_t cmd_csum_csum =
5343 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5344 : : csum, "csum");
5345 : : static cmdline_parse_token_string_t cmd_csum_mode =
5346 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5347 : : mode, "set");
5348 : : static cmdline_parse_token_string_t cmd_csum_proto =
5349 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5350 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
5351 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
5352 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5353 : : hwsw, "hw#sw");
5354 : : static cmdline_parse_token_num_t cmd_csum_portid =
5355 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
5356 : : port_id, RTE_UINT16);
5357 : :
5358 : : static cmdline_parse_inst_t cmd_csum_set = {
5359 : : .f = cmd_csum_parsed,
5360 : : .data = NULL,
5361 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
5362 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
5363 : : "using csum forward engine",
5364 : : .tokens = {
5365 : : (void *)&cmd_csum_csum,
5366 : : (void *)&cmd_csum_mode,
5367 : : (void *)&cmd_csum_proto,
5368 : : (void *)&cmd_csum_hwsw,
5369 : : (void *)&cmd_csum_portid,
5370 : : NULL,
5371 : : },
5372 : : };
5373 : :
5374 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
5375 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5376 : : mode, "show");
5377 : :
5378 : : static cmdline_parse_inst_t cmd_csum_show = {
5379 : : .f = cmd_csum_parsed,
5380 : : .data = NULL,
5381 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
5382 : : .tokens = {
5383 : : (void *)&cmd_csum_csum,
5384 : : (void *)&cmd_csum_mode_show,
5385 : : (void *)&cmd_csum_portid,
5386 : : NULL,
5387 : : },
5388 : : };
5389 : :
5390 : : /* Enable/disable tunnel parsing */
5391 : : struct cmd_csum_tunnel_result {
5392 : : cmdline_fixed_string_t csum;
5393 : : cmdline_fixed_string_t parse;
5394 : : cmdline_fixed_string_t onoff;
5395 : : portid_t port_id;
5396 : : };
5397 : :
5398 : : static void
5399 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
5400 : : __rte_unused struct cmdline *cl,
5401 : : __rte_unused void *data)
5402 : : {
5403 : : struct cmd_csum_tunnel_result *res = parsed_result;
5404 : :
5405 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5406 : : return;
5407 : :
5408 : 0 : if (!strcmp(res->onoff, "on"))
5409 : 0 : ports[res->port_id].parse_tunnel = 1;
5410 : : else
5411 : 0 : ports[res->port_id].parse_tunnel = 0;
5412 : :
5413 : 0 : csum_show(res->port_id);
5414 : : }
5415 : :
5416 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
5417 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5418 : : csum, "csum");
5419 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
5420 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5421 : : parse, "parse-tunnel");
5422 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
5423 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5424 : : onoff, "on#off");
5425 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
5426 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
5427 : : port_id, RTE_UINT16);
5428 : :
5429 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
5430 : : .f = cmd_csum_tunnel_parsed,
5431 : : .data = NULL,
5432 : : .help_str = "csum parse-tunnel on|off <port_id>: "
5433 : : "Enable/Disable parsing of tunnels for csum engine",
5434 : : .tokens = {
5435 : : (void *)&cmd_csum_tunnel_csum,
5436 : : (void *)&cmd_csum_tunnel_parse,
5437 : : (void *)&cmd_csum_tunnel_onoff,
5438 : : (void *)&cmd_csum_tunnel_portid,
5439 : : NULL,
5440 : : },
5441 : : };
5442 : :
5443 : : struct cmd_csum_mac_swap_result {
5444 : : cmdline_fixed_string_t csum;
5445 : : cmdline_fixed_string_t parse;
5446 : : cmdline_fixed_string_t onoff;
5447 : : portid_t port_id;
5448 : : };
5449 : :
5450 : : static void
5451 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
5452 : : __rte_unused struct cmdline *cl,
5453 : : __rte_unused void *data)
5454 : : {
5455 : : struct cmd_csum_mac_swap_result *res = parsed_result;
5456 : :
5457 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5458 : : return;
5459 : 0 : if (strcmp(res->onoff, "on") == 0)
5460 : 0 : ports[res->port_id].fwd_mac_swap = 1;
5461 : : else
5462 : 0 : ports[res->port_id].fwd_mac_swap = 0;
5463 : : }
5464 : :
5465 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
5466 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5467 : : csum, "csum");
5468 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
5469 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5470 : : parse, "mac-swap");
5471 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
5472 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5473 : : onoff, "on#off");
5474 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
5475 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
5476 : : port_id, RTE_UINT16);
5477 : :
5478 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
5479 : : .f = cmd_csum_mac_swap_parsed,
5480 : : .data = NULL,
5481 : : .help_str = "csum mac-swap on|off <port_id>: "
5482 : : "Enable/Disable forward mac address swap",
5483 : : .tokens = {
5484 : : (void *)&cmd_csum_mac_swap_csum,
5485 : : (void *)&cmd_csum_mac_swap_parse,
5486 : : (void *)&cmd_csum_mac_swap_onoff,
5487 : : (void *)&cmd_csum_mac_swap_portid,
5488 : : NULL,
5489 : : },
5490 : : };
5491 : :
5492 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5493 : : struct cmd_tso_set_result {
5494 : : cmdline_fixed_string_t tso;
5495 : : cmdline_fixed_string_t mode;
5496 : : uint16_t tso_segsz;
5497 : : portid_t port_id;
5498 : : };
5499 : :
5500 : : static void
5501 : 0 : cmd_tso_set_parsed(void *parsed_result,
5502 : : __rte_unused struct cmdline *cl,
5503 : : __rte_unused void *data)
5504 : : {
5505 : : struct cmd_tso_set_result *res = parsed_result;
5506 : : struct rte_eth_dev_info dev_info;
5507 : : uint64_t offloads;
5508 : : int ret;
5509 : :
5510 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5511 : 0 : return;
5512 : 0 : if (!port_is_stopped(res->port_id)) {
5513 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5514 : 0 : return;
5515 : : }
5516 : :
5517 : 0 : if (!strcmp(res->mode, "set"))
5518 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5519 : :
5520 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5521 : 0 : if (ret != 0)
5522 : : return;
5523 : :
5524 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5525 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5526 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5527 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5528 : : res->port_id);
5529 : 0 : return;
5530 : : }
5531 : : /* display warnings if configuration is not supported by the NIC */
5532 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5533 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5534 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5535 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5536 : : }
5537 : :
5538 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5539 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5540 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5541 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5542 : : } else {
5543 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5544 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5545 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5546 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5547 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5548 : 0 : printf("segment size for non-tunneled packets is %d\n",
5549 : : ports[res->port_id].tso_segsz);
5550 : : }
5551 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5552 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5553 : : }
5554 : :
5555 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5556 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5557 : : tso, "tso");
5558 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5559 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5560 : : mode, "set");
5561 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5562 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5563 : : tso_segsz, RTE_UINT16);
5564 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5565 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5566 : : port_id, RTE_UINT16);
5567 : :
5568 : : static cmdline_parse_inst_t cmd_tso_set = {
5569 : : .f = cmd_tso_set_parsed,
5570 : : .data = NULL,
5571 : : .help_str = "tso set <tso_segsz> <port_id>: "
5572 : : "Set TSO segment size of non-tunneled packets for csum engine "
5573 : : "(0 to disable)",
5574 : : .tokens = {
5575 : : (void *)&cmd_tso_set_tso,
5576 : : (void *)&cmd_tso_set_mode,
5577 : : (void *)&cmd_tso_set_tso_segsz,
5578 : : (void *)&cmd_tso_set_portid,
5579 : : NULL,
5580 : : },
5581 : : };
5582 : :
5583 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5584 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5585 : : mode, "show");
5586 : :
5587 : :
5588 : : static cmdline_parse_inst_t cmd_tso_show = {
5589 : : .f = cmd_tso_set_parsed,
5590 : : .data = NULL,
5591 : : .help_str = "tso show <port_id>: "
5592 : : "Show TSO segment size of non-tunneled packets for csum engine",
5593 : : .tokens = {
5594 : : (void *)&cmd_tso_set_tso,
5595 : : (void *)&cmd_tso_show_mode,
5596 : : (void *)&cmd_tso_set_portid,
5597 : : NULL,
5598 : : },
5599 : : };
5600 : :
5601 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5602 : : struct cmd_tunnel_tso_set_result {
5603 : : cmdline_fixed_string_t tso;
5604 : : cmdline_fixed_string_t mode;
5605 : : uint16_t tso_segsz;
5606 : : portid_t port_id;
5607 : : };
5608 : :
5609 : : static void
5610 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5611 : : {
5612 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5613 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5614 : : port_id);
5615 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5616 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5617 : : port_id);
5618 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5619 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5620 : : port_id);
5621 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5622 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5623 : : port_id);
5624 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5625 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5626 : : port_id);
5627 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5628 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5629 : : port_id);
5630 : 0 : }
5631 : :
5632 : : static void
5633 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5634 : : __rte_unused struct cmdline *cl,
5635 : : __rte_unused void *data)
5636 : : {
5637 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5638 : : struct rte_eth_dev_info dev_info;
5639 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5640 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5641 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5642 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5643 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5644 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5645 : : int ret;
5646 : :
5647 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5648 : 0 : return;
5649 : 0 : if (!port_is_stopped(res->port_id)) {
5650 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5651 : 0 : return;
5652 : : }
5653 : :
5654 : 0 : if (!strcmp(res->mode, "set"))
5655 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5656 : :
5657 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5658 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5659 : : printf("TSO for tunneled packets is disabled\n");
5660 : : } else {
5661 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5662 : 0 : if (ret != 0)
5663 : : return;
5664 : :
5665 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5666 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5667 : 0 : res->port_id);
5668 : 0 : return;
5669 : : }
5670 : :
5671 : : /* Below conditions are needed to make it work:
5672 : : * (1) tunnel TSO is supported by the NIC;
5673 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5674 : : * are recognized;
5675 : : * (3) for tunneled pkts with outer L3 of IPv4,
5676 : : * "csum set outer-ip" must be set to hw, because after tso,
5677 : : * total_len of outer IP header is changed, and the checksum
5678 : : * of outer IP header calculated by sw should be wrong; that
5679 : : * is not necessary for IPv6 tunneled pkts because there's no
5680 : : * checksum in IP header anymore.
5681 : : */
5682 : 0 : if (!ports[res->port_id].parse_tunnel) {
5683 : 0 : fprintf(stderr,
5684 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5685 : 0 : return;
5686 : : }
5687 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5688 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5689 : 0 : fprintf(stderr,
5690 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5691 : 0 : return;
5692 : : }
5693 : :
5694 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5695 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5696 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5697 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5698 : 0 : ports[res->port_id].tunnel_tso_segsz);
5699 : : }
5700 : :
5701 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5702 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5703 : : }
5704 : :
5705 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5706 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5707 : : tso, "tunnel_tso");
5708 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5709 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5710 : : mode, "set");
5711 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5712 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5713 : : tso_segsz, RTE_UINT16);
5714 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5715 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5716 : : port_id, RTE_UINT16);
5717 : :
5718 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5719 : : .f = cmd_tunnel_tso_set_parsed,
5720 : : .data = NULL,
5721 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5722 : : "Set TSO segment size of tunneled packets for csum engine "
5723 : : "(0 to disable)",
5724 : : .tokens = {
5725 : : (void *)&cmd_tunnel_tso_set_tso,
5726 : : (void *)&cmd_tunnel_tso_set_mode,
5727 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5728 : : (void *)&cmd_tunnel_tso_set_portid,
5729 : : NULL,
5730 : : },
5731 : : };
5732 : :
5733 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5734 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5735 : : mode, "show");
5736 : :
5737 : :
5738 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5739 : : .f = cmd_tunnel_tso_set_parsed,
5740 : : .data = NULL,
5741 : : .help_str = "tunnel_tso show <port_id> "
5742 : : "Show TSO segment size of tunneled packets for csum engine",
5743 : : .tokens = {
5744 : : (void *)&cmd_tunnel_tso_set_tso,
5745 : : (void *)&cmd_tunnel_tso_show_mode,
5746 : : (void *)&cmd_tunnel_tso_set_portid,
5747 : : NULL,
5748 : : },
5749 : : };
5750 : :
5751 : : #ifdef RTE_LIB_GRO
5752 : : /* *** SET GRO FOR A PORT *** */
5753 : : struct cmd_gro_enable_result {
5754 : : cmdline_fixed_string_t cmd_set;
5755 : : cmdline_fixed_string_t cmd_port;
5756 : : cmdline_fixed_string_t cmd_keyword;
5757 : : cmdline_fixed_string_t cmd_onoff;
5758 : : portid_t cmd_pid;
5759 : : };
5760 : :
5761 : : static void
5762 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5763 : : __rte_unused struct cmdline *cl,
5764 : : __rte_unused void *data)
5765 : : {
5766 : : struct cmd_gro_enable_result *res;
5767 : :
5768 : : res = parsed_result;
5769 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5770 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5771 : 0 : }
5772 : :
5773 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5774 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5775 : : cmd_set, "set");
5776 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5777 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5778 : : cmd_keyword, "port");
5779 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5780 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5781 : : cmd_pid, RTE_UINT16);
5782 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5783 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5784 : : cmd_keyword, "gro");
5785 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5786 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5787 : : cmd_onoff, "on#off");
5788 : :
5789 : : static cmdline_parse_inst_t cmd_gro_enable = {
5790 : : .f = cmd_gro_enable_parsed,
5791 : : .data = NULL,
5792 : : .help_str = "set port <port_id> gro on|off",
5793 : : .tokens = {
5794 : : (void *)&cmd_gro_enable_set,
5795 : : (void *)&cmd_gro_enable_port,
5796 : : (void *)&cmd_gro_enable_pid,
5797 : : (void *)&cmd_gro_enable_keyword,
5798 : : (void *)&cmd_gro_enable_onoff,
5799 : : NULL,
5800 : : },
5801 : : };
5802 : :
5803 : : /* *** DISPLAY GRO CONFIGURATION *** */
5804 : : struct cmd_gro_show_result {
5805 : : cmdline_fixed_string_t cmd_show;
5806 : : cmdline_fixed_string_t cmd_port;
5807 : : cmdline_fixed_string_t cmd_keyword;
5808 : : portid_t cmd_pid;
5809 : : };
5810 : :
5811 : : static void
5812 : 0 : cmd_gro_show_parsed(void *parsed_result,
5813 : : __rte_unused struct cmdline *cl,
5814 : : __rte_unused void *data)
5815 : : {
5816 : : struct cmd_gro_show_result *res;
5817 : :
5818 : : res = parsed_result;
5819 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5820 : 0 : show_gro(res->cmd_pid);
5821 : 0 : }
5822 : :
5823 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5824 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5825 : : cmd_show, "show");
5826 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5827 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5828 : : cmd_port, "port");
5829 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5830 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5831 : : cmd_pid, RTE_UINT16);
5832 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5833 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5834 : : cmd_keyword, "gro");
5835 : :
5836 : : static cmdline_parse_inst_t cmd_gro_show = {
5837 : : .f = cmd_gro_show_parsed,
5838 : : .data = NULL,
5839 : : .help_str = "show port <port_id> gro",
5840 : : .tokens = {
5841 : : (void *)&cmd_gro_show_show,
5842 : : (void *)&cmd_gro_show_port,
5843 : : (void *)&cmd_gro_show_pid,
5844 : : (void *)&cmd_gro_show_keyword,
5845 : : NULL,
5846 : : },
5847 : : };
5848 : :
5849 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5850 : : struct cmd_gro_flush_result {
5851 : : cmdline_fixed_string_t cmd_set;
5852 : : cmdline_fixed_string_t cmd_keyword;
5853 : : cmdline_fixed_string_t cmd_flush;
5854 : : uint8_t cmd_cycles;
5855 : : };
5856 : :
5857 : : static void
5858 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5859 : : __rte_unused struct cmdline *cl,
5860 : : __rte_unused void *data)
5861 : : {
5862 : : struct cmd_gro_flush_result *res;
5863 : :
5864 : : res = parsed_result;
5865 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5866 : 0 : (!strcmp(res->cmd_flush, "flush")))
5867 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5868 : 0 : }
5869 : :
5870 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5871 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5872 : : cmd_set, "set");
5873 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5874 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5875 : : cmd_keyword, "gro");
5876 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5877 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5878 : : cmd_flush, "flush");
5879 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5880 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5881 : : cmd_cycles, RTE_UINT8);
5882 : :
5883 : : static cmdline_parse_inst_t cmd_gro_flush = {
5884 : : .f = cmd_gro_flush_parsed,
5885 : : .data = NULL,
5886 : : .help_str = "set gro flush <cycles>",
5887 : : .tokens = {
5888 : : (void *)&cmd_gro_flush_set,
5889 : : (void *)&cmd_gro_flush_keyword,
5890 : : (void *)&cmd_gro_flush_flush,
5891 : : (void *)&cmd_gro_flush_cycles,
5892 : : NULL,
5893 : : },
5894 : : };
5895 : : #endif /* RTE_LIB_GRO */
5896 : :
5897 : : #ifdef RTE_LIB_GSO
5898 : : /* *** ENABLE/DISABLE GSO *** */
5899 : : struct cmd_gso_enable_result {
5900 : : cmdline_fixed_string_t cmd_set;
5901 : : cmdline_fixed_string_t cmd_port;
5902 : : cmdline_fixed_string_t cmd_keyword;
5903 : : cmdline_fixed_string_t cmd_mode;
5904 : : portid_t cmd_pid;
5905 : : };
5906 : :
5907 : : static void
5908 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5909 : : __rte_unused struct cmdline *cl,
5910 : : __rte_unused void *data)
5911 : : {
5912 : : struct cmd_gso_enable_result *res;
5913 : :
5914 : : res = parsed_result;
5915 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5916 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5917 : 0 : }
5918 : :
5919 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5920 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5921 : : cmd_set, "set");
5922 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5923 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5924 : : cmd_port, "port");
5925 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5926 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5927 : : cmd_keyword, "gso");
5928 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5929 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5930 : : cmd_mode, "on#off");
5931 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5932 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5933 : : cmd_pid, RTE_UINT16);
5934 : :
5935 : : static cmdline_parse_inst_t cmd_gso_enable = {
5936 : : .f = cmd_gso_enable_parsed,
5937 : : .data = NULL,
5938 : : .help_str = "set port <port_id> gso on|off",
5939 : : .tokens = {
5940 : : (void *)&cmd_gso_enable_set,
5941 : : (void *)&cmd_gso_enable_port,
5942 : : (void *)&cmd_gso_enable_pid,
5943 : : (void *)&cmd_gso_enable_keyword,
5944 : : (void *)&cmd_gso_enable_mode,
5945 : : NULL,
5946 : : },
5947 : : };
5948 : :
5949 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5950 : : struct cmd_gso_size_result {
5951 : : cmdline_fixed_string_t cmd_set;
5952 : : cmdline_fixed_string_t cmd_keyword;
5953 : : cmdline_fixed_string_t cmd_segsz;
5954 : : uint16_t cmd_size;
5955 : : };
5956 : :
5957 : : static void
5958 : 0 : cmd_gso_size_parsed(void *parsed_result,
5959 : : __rte_unused struct cmdline *cl,
5960 : : __rte_unused void *data)
5961 : : {
5962 : : struct cmd_gso_size_result *res = parsed_result;
5963 : :
5964 : 0 : if (test_done == 0) {
5965 : 0 : fprintf(stderr,
5966 : : "Before setting GSO segsz, please first stop forwarding\n");
5967 : 0 : return;
5968 : : }
5969 : :
5970 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5971 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5972 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5973 : 0 : fprintf(stderr,
5974 : : "gso_size should be larger than %zu. Please input a legal value\n",
5975 : : RTE_GSO_SEG_SIZE_MIN);
5976 : : else
5977 : 0 : gso_max_segment_size = res->cmd_size;
5978 : : }
5979 : : }
5980 : :
5981 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5982 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5983 : : cmd_set, "set");
5984 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5985 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5986 : : cmd_keyword, "gso");
5987 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5988 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5989 : : cmd_segsz, "segsz");
5990 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5991 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5992 : : cmd_size, RTE_UINT16);
5993 : :
5994 : : static cmdline_parse_inst_t cmd_gso_size = {
5995 : : .f = cmd_gso_size_parsed,
5996 : : .data = NULL,
5997 : : .help_str = "set gso segsz <length>",
5998 : : .tokens = {
5999 : : (void *)&cmd_gso_size_set,
6000 : : (void *)&cmd_gso_size_keyword,
6001 : : (void *)&cmd_gso_size_segsz,
6002 : : (void *)&cmd_gso_size_size,
6003 : : NULL,
6004 : : },
6005 : : };
6006 : :
6007 : : /* *** SHOW GSO CONFIGURATION *** */
6008 : : struct cmd_gso_show_result {
6009 : : cmdline_fixed_string_t cmd_show;
6010 : : cmdline_fixed_string_t cmd_port;
6011 : : cmdline_fixed_string_t cmd_keyword;
6012 : : portid_t cmd_pid;
6013 : : };
6014 : :
6015 : : static void
6016 : 0 : cmd_gso_show_parsed(void *parsed_result,
6017 : : __rte_unused struct cmdline *cl,
6018 : : __rte_unused void *data)
6019 : : {
6020 : : struct cmd_gso_show_result *res = parsed_result;
6021 : :
6022 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
6023 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
6024 : 0 : return;
6025 : : }
6026 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
6027 : 0 : if (gso_ports[res->cmd_pid].enable) {
6028 : 0 : printf("Max GSO'd packet size: %uB\n"
6029 : : "Supported GSO types: TCP/IPv4, "
6030 : : "UDP/IPv4, VxLAN with inner "
6031 : : "TCP/IPv4 packet, GRE with inner "
6032 : : "TCP/IPv4 packet\n",
6033 : : gso_max_segment_size);
6034 : : } else
6035 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
6036 : : }
6037 : : }
6038 : :
6039 : : static cmdline_parse_token_string_t cmd_gso_show_show =
6040 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6041 : : cmd_show, "show");
6042 : : static cmdline_parse_token_string_t cmd_gso_show_port =
6043 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6044 : : cmd_port, "port");
6045 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
6046 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6047 : : cmd_keyword, "gso");
6048 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
6049 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
6050 : : cmd_pid, RTE_UINT16);
6051 : :
6052 : : static cmdline_parse_inst_t cmd_gso_show = {
6053 : : .f = cmd_gso_show_parsed,
6054 : : .data = NULL,
6055 : : .help_str = "show port <port_id> gso",
6056 : : .tokens = {
6057 : : (void *)&cmd_gso_show_show,
6058 : : (void *)&cmd_gso_show_port,
6059 : : (void *)&cmd_gso_show_pid,
6060 : : (void *)&cmd_gso_show_keyword,
6061 : : NULL,
6062 : : },
6063 : : };
6064 : : #endif /* RTE_LIB_GSO */
6065 : :
6066 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
6067 : : struct cmd_set_flush_rx {
6068 : : cmdline_fixed_string_t set;
6069 : : cmdline_fixed_string_t flush_rx;
6070 : : cmdline_fixed_string_t mode;
6071 : : };
6072 : :
6073 : : static void
6074 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
6075 : : __rte_unused struct cmdline *cl,
6076 : : __rte_unused void *data)
6077 : : {
6078 : : struct cmd_set_flush_rx *res = parsed_result;
6079 : :
6080 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
6081 : : printf("multi-process doesn't support to flush Rx queues.\n");
6082 : 0 : return;
6083 : : }
6084 : :
6085 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6086 : : }
6087 : :
6088 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
6089 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6090 : : set, "set");
6091 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
6092 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6093 : : flush_rx, "flush_rx");
6094 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
6095 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6096 : : mode, "on#off");
6097 : :
6098 : :
6099 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
6100 : : .f = cmd_set_flush_rx_parsed,
6101 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
6102 : : .data = NULL,
6103 : : .tokens = {
6104 : : (void *)&cmd_setflushrx_set,
6105 : : (void *)&cmd_setflushrx_flush_rx,
6106 : : (void *)&cmd_setflushrx_mode,
6107 : : NULL,
6108 : : },
6109 : : };
6110 : :
6111 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
6112 : : struct cmd_set_link_check {
6113 : : cmdline_fixed_string_t set;
6114 : : cmdline_fixed_string_t link_check;
6115 : : cmdline_fixed_string_t mode;
6116 : : };
6117 : :
6118 : : static void
6119 : 0 : cmd_set_link_check_parsed(void *parsed_result,
6120 : : __rte_unused struct cmdline *cl,
6121 : : __rte_unused void *data)
6122 : : {
6123 : : struct cmd_set_link_check *res = parsed_result;
6124 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6125 : 0 : }
6126 : :
6127 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
6128 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6129 : : set, "set");
6130 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
6131 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6132 : : link_check, "link_check");
6133 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
6134 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6135 : : mode, "on#off");
6136 : :
6137 : :
6138 : : static cmdline_parse_inst_t cmd_set_link_check = {
6139 : : .f = cmd_set_link_check_parsed,
6140 : : .help_str = "set link_check on|off: Enable/Disable link status check "
6141 : : "when starting/stopping a port",
6142 : : .data = NULL,
6143 : : .tokens = {
6144 : : (void *)&cmd_setlinkcheck_set,
6145 : : (void *)&cmd_setlinkcheck_link_check,
6146 : : (void *)&cmd_setlinkcheck_mode,
6147 : : NULL,
6148 : : },
6149 : : };
6150 : :
6151 : : /* *** SET FORWARDING MODE *** */
6152 : : struct cmd_set_fwd_mode_result {
6153 : : cmdline_fixed_string_t set;
6154 : : cmdline_fixed_string_t fwd;
6155 : : cmdline_fixed_string_t mode;
6156 : : };
6157 : :
6158 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
6159 : : __rte_unused struct cmdline *cl,
6160 : : __rte_unused void *data)
6161 : : {
6162 : : struct cmd_set_fwd_mode_result *res = parsed_result;
6163 : :
6164 : 0 : retry_enabled = 0;
6165 : 0 : set_pkt_forwarding_mode(res->mode);
6166 : 0 : }
6167 : :
6168 : : static cmdline_parse_token_string_t cmd_setfwd_set =
6169 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6170 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
6171 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6172 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
6173 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6174 : : "" /* defined at init */);
6175 : :
6176 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
6177 : : .f = cmd_set_fwd_mode_parsed,
6178 : : .data = NULL,
6179 : : .help_str = NULL, /* defined at init */
6180 : : .tokens = {
6181 : : (void *)&cmd_setfwd_set,
6182 : : (void *)&cmd_setfwd_fwd,
6183 : : (void *)&cmd_setfwd_mode,
6184 : : NULL,
6185 : : },
6186 : : };
6187 : :
6188 : 0 : static void cmd_set_fwd_mode_init(void)
6189 : : {
6190 : : char *modes, *c;
6191 : : static char token[128];
6192 : : static char help[256];
6193 : : cmdline_parse_token_string_t *token_struct;
6194 : :
6195 : 0 : modes = list_pkt_forwarding_modes();
6196 : : snprintf(help, sizeof(help), "set fwd %s: "
6197 : : "Set packet forwarding mode", modes);
6198 : 0 : cmd_set_fwd_mode.help_str = help;
6199 : :
6200 : : /* string token separator is # */
6201 : 0 : for (c = token; *modes != '\0'; modes++)
6202 : 0 : if (*modes == '|')
6203 : 0 : *c++ = '#';
6204 : : else
6205 : 0 : *c++ = *modes;
6206 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6207 : 0 : token_struct->string_data.str = token;
6208 : 0 : }
6209 : :
6210 : : /* *** SET RETRY FORWARDING MODE *** */
6211 : : struct cmd_set_fwd_retry_mode_result {
6212 : : cmdline_fixed_string_t set;
6213 : : cmdline_fixed_string_t fwd;
6214 : : cmdline_fixed_string_t mode;
6215 : : cmdline_fixed_string_t retry;
6216 : : };
6217 : :
6218 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6219 : : __rte_unused struct cmdline *cl,
6220 : : __rte_unused void *data)
6221 : : {
6222 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6223 : :
6224 : 0 : retry_enabled = 1;
6225 : 0 : set_pkt_forwarding_mode(res->mode);
6226 : 0 : }
6227 : :
6228 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6229 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6230 : : set, "set");
6231 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6232 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6233 : : fwd, "fwd");
6234 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6235 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6236 : : mode,
6237 : : "" /* defined at init */);
6238 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6239 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6240 : : retry, "retry");
6241 : :
6242 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6243 : : .f = cmd_set_fwd_retry_mode_parsed,
6244 : : .data = NULL,
6245 : : .help_str = NULL, /* defined at init */
6246 : : .tokens = {
6247 : : (void *)&cmd_setfwd_retry_set,
6248 : : (void *)&cmd_setfwd_retry_fwd,
6249 : : (void *)&cmd_setfwd_retry_mode,
6250 : : (void *)&cmd_setfwd_retry_retry,
6251 : : NULL,
6252 : : },
6253 : : };
6254 : :
6255 : 0 : static void cmd_set_fwd_retry_mode_init(void)
6256 : : {
6257 : : char *modes, *c;
6258 : : static char token[128];
6259 : : static char help[256];
6260 : : cmdline_parse_token_string_t *token_struct;
6261 : :
6262 : 0 : modes = list_pkt_forwarding_retry_modes();
6263 : : snprintf(help, sizeof(help), "set fwd %s retry: "
6264 : : "Set packet forwarding mode with retry", modes);
6265 : 0 : cmd_set_fwd_retry_mode.help_str = help;
6266 : :
6267 : : /* string token separator is # */
6268 : 0 : for (c = token; *modes != '\0'; modes++)
6269 : 0 : if (*modes == '|')
6270 : 0 : *c++ = '#';
6271 : : else
6272 : 0 : *c++ = *modes;
6273 : 0 : token_struct = (cmdline_parse_token_string_t *)
6274 : : cmd_set_fwd_retry_mode.tokens[2];
6275 : 0 : token_struct->string_data.str = token;
6276 : 0 : }
6277 : :
6278 : 0 : static void show_dcb_fwd_tc_config(void)
6279 : : {
6280 : : int i;
6281 : : printf("DCB forwarding TC list:");
6282 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6283 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6284 : : printf(" %d", i);
6285 : : }
6286 : : printf("\n");
6287 : 0 : printf("DCB forwarding cores per-TC: %u\n", dcb_fwd_tc_cores);
6288 : 0 : }
6289 : :
6290 : : /* *** set DCB forward TCs *** */
6291 : : struct cmd_set_dcb_fwd_tc_result {
6292 : : cmdline_fixed_string_t set;
6293 : : cmdline_fixed_string_t dcb;
6294 : : cmdline_fixed_string_t fwd_tc;
6295 : : uint8_t tc_mask;
6296 : : };
6297 : :
6298 : 0 : static void cmd_set_dcb_fwd_tc_parsed(void *parsed_result,
6299 : : __rte_unused struct cmdline *cl,
6300 : : __rte_unused void *data)
6301 : : {
6302 : : struct cmd_set_dcb_fwd_tc_result *res = parsed_result;
6303 : : int i;
6304 : 0 : if (test_done == 0) {
6305 : 0 : fprintf(stderr, "Please stop forwarding first\n");
6306 : 0 : return;
6307 : : }
6308 : 0 : if (res->tc_mask == 0) {
6309 : 0 : fprintf(stderr, "TC mask should not be zero!\n");
6310 : 0 : return;
6311 : : }
6312 : : printf("Enabled DCB forwarding TC list:");
6313 : 0 : dcb_fwd_tc_mask = res->tc_mask;
6314 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6315 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6316 : : printf(" %d", i);
6317 : : }
6318 : : printf("\n");
6319 : : }
6320 : :
6321 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_set =
6322 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6323 : : set, "set");
6324 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_dcb =
6325 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6326 : : dcb, "dcb");
6327 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_fwdtc =
6328 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6329 : : fwd_tc, "fwd_tc");
6330 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_tcmask =
6331 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6332 : : tc_mask, RTE_UINT8);
6333 : :
6334 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc = {
6335 : : .f = cmd_set_dcb_fwd_tc_parsed,
6336 : : .data = NULL,
6337 : : .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.",
6338 : : .tokens = {
6339 : : (void *)&cmd_set_dcb_fwd_tc_set,
6340 : : (void *)&cmd_set_dcb_fwd_tc_dcb,
6341 : : (void *)&cmd_set_dcb_fwd_tc_fwdtc,
6342 : : (void *)&cmd_set_dcb_fwd_tc_tcmask,
6343 : : NULL,
6344 : : },
6345 : : };
6346 : :
6347 : : /* *** set DCB forward cores per TC *** */
6348 : : struct cmd_set_dcb_fwd_tc_cores_result {
6349 : : cmdline_fixed_string_t set;
6350 : : cmdline_fixed_string_t dcb;
6351 : : cmdline_fixed_string_t fwd_tc_cores;
6352 : : uint8_t tc_cores;
6353 : : };
6354 : :
6355 : 0 : static void cmd_set_dcb_fwd_tc_cores_parsed(void *parsed_result,
6356 : : __rte_unused struct cmdline *cl,
6357 : : __rte_unused void *data)
6358 : : {
6359 : : struct cmd_set_dcb_fwd_tc_cores_result *res = parsed_result;
6360 : 0 : if (test_done == 0) {
6361 : 0 : fprintf(stderr, "Please stop forwarding first\n");
6362 : 0 : return;
6363 : : }
6364 : 0 : if (res->tc_cores == 0) {
6365 : 0 : fprintf(stderr, "Cores per-TC should not be zero!\n");
6366 : 0 : return;
6367 : : }
6368 : 0 : dcb_fwd_tc_cores = res->tc_cores;
6369 : 0 : printf("Set cores-per-TC: %u\n", dcb_fwd_tc_cores);
6370 : : }
6371 : :
6372 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_set =
6373 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6374 : : set, "set");
6375 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_dcb =
6376 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6377 : : dcb, "dcb");
6378 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_fwdtccores =
6379 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6380 : : fwd_tc_cores, "fwd_tc_cores");
6381 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_cores_tccores =
6382 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6383 : : tc_cores, RTE_UINT8);
6384 : :
6385 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc_cores = {
6386 : : .f = cmd_set_dcb_fwd_tc_cores_parsed,
6387 : : .data = NULL,
6388 : : .help_str = "config DCB forwarding cores per-TC, 1-means one core process all queues of a TC.",
6389 : : .tokens = {
6390 : : (void *)&cmd_set_dcb_fwd_tc_cores_set,
6391 : : (void *)&cmd_set_dcb_fwd_tc_cores_dcb,
6392 : : (void *)&cmd_set_dcb_fwd_tc_cores_fwdtccores,
6393 : : (void *)&cmd_set_dcb_fwd_tc_cores_tccores,
6394 : : NULL,
6395 : : },
6396 : : };
6397 : :
6398 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6399 : : struct cmd_set_burst_tx_retry_result {
6400 : : cmdline_fixed_string_t set;
6401 : : cmdline_fixed_string_t burst;
6402 : : cmdline_fixed_string_t tx;
6403 : : cmdline_fixed_string_t delay;
6404 : : uint32_t time;
6405 : : cmdline_fixed_string_t retry;
6406 : : uint32_t retry_num;
6407 : : };
6408 : :
6409 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6410 : : __rte_unused struct cmdline *cl,
6411 : : __rte_unused void *data)
6412 : : {
6413 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
6414 : :
6415 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6416 : 0 : && !strcmp(res->tx, "tx")) {
6417 : 0 : if (!strcmp(res->delay, "delay"))
6418 : 0 : burst_tx_delay_time = res->time;
6419 : 0 : if (!strcmp(res->retry, "retry"))
6420 : 0 : burst_tx_retry_num = res->retry_num;
6421 : : }
6422 : :
6423 : 0 : }
6424 : :
6425 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6426 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6427 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6428 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6429 : : "burst");
6430 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6431 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6432 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6433 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6434 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6435 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6436 : : RTE_UINT32);
6437 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6438 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6439 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6440 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6441 : : RTE_UINT32);
6442 : :
6443 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6444 : : .f = cmd_set_burst_tx_retry_parsed,
6445 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6446 : : .tokens = {
6447 : : (void *)&cmd_set_burst_tx_retry_set,
6448 : : (void *)&cmd_set_burst_tx_retry_burst,
6449 : : (void *)&cmd_set_burst_tx_retry_tx,
6450 : : (void *)&cmd_set_burst_tx_retry_delay,
6451 : : (void *)&cmd_set_burst_tx_retry_time,
6452 : : (void *)&cmd_set_burst_tx_retry_retry,
6453 : : (void *)&cmd_set_burst_tx_retry_retry_num,
6454 : : NULL,
6455 : : },
6456 : : };
6457 : :
6458 : : /* *** SET PROMISC MODE *** */
6459 : : struct cmd_set_promisc_mode_result {
6460 : : cmdline_fixed_string_t set;
6461 : : cmdline_fixed_string_t promisc;
6462 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6463 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6464 : : cmdline_fixed_string_t mode;
6465 : : };
6466 : :
6467 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
6468 : : __rte_unused struct cmdline *cl,
6469 : : void *allports)
6470 : : {
6471 : : struct cmd_set_promisc_mode_result *res = parsed_result;
6472 : : int enable;
6473 : : portid_t i;
6474 : :
6475 : 0 : if (!strcmp(res->mode, "on"))
6476 : : enable = 1;
6477 : : else
6478 : : enable = 0;
6479 : :
6480 : : /* all ports */
6481 : 0 : if (allports) {
6482 : 0 : RTE_ETH_FOREACH_DEV(i)
6483 : 0 : eth_set_promisc_mode(i, enable);
6484 : : } else {
6485 : 0 : eth_set_promisc_mode(res->port_num, enable);
6486 : : }
6487 : 0 : }
6488 : :
6489 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
6490 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6491 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
6492 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6493 : : "promisc");
6494 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
6495 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6496 : : "all");
6497 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
6498 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6499 : : RTE_UINT16);
6500 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
6501 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6502 : : "on#off");
6503 : :
6504 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6505 : : .f = cmd_set_promisc_mode_parsed,
6506 : : .data = (void *)1,
6507 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
6508 : : .tokens = {
6509 : : (void *)&cmd_setpromisc_set,
6510 : : (void *)&cmd_setpromisc_promisc,
6511 : : (void *)&cmd_setpromisc_portall,
6512 : : (void *)&cmd_setpromisc_mode,
6513 : : NULL,
6514 : : },
6515 : : };
6516 : :
6517 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6518 : : .f = cmd_set_promisc_mode_parsed,
6519 : : .data = (void *)0,
6520 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6521 : : .tokens = {
6522 : : (void *)&cmd_setpromisc_set,
6523 : : (void *)&cmd_setpromisc_promisc,
6524 : : (void *)&cmd_setpromisc_portnum,
6525 : : (void *)&cmd_setpromisc_mode,
6526 : : NULL,
6527 : : },
6528 : : };
6529 : :
6530 : : /* *** SET ALLMULTI MODE *** */
6531 : : struct cmd_set_allmulti_mode_result {
6532 : : cmdline_fixed_string_t set;
6533 : : cmdline_fixed_string_t allmulti;
6534 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6535 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6536 : : cmdline_fixed_string_t mode;
6537 : : };
6538 : :
6539 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6540 : : __rte_unused struct cmdline *cl,
6541 : : void *allports)
6542 : : {
6543 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
6544 : : int enable;
6545 : : portid_t i;
6546 : :
6547 : 0 : if (!strcmp(res->mode, "on"))
6548 : : enable = 1;
6549 : : else
6550 : : enable = 0;
6551 : :
6552 : : /* all ports */
6553 : 0 : if (allports) {
6554 : 0 : RTE_ETH_FOREACH_DEV(i) {
6555 : 0 : eth_set_allmulticast_mode(i, enable);
6556 : : }
6557 : : }
6558 : : else {
6559 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
6560 : : }
6561 : 0 : }
6562 : :
6563 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
6564 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6565 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6566 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6567 : : "allmulti");
6568 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
6569 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6570 : : "all");
6571 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
6572 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6573 : : RTE_UINT16);
6574 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
6575 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6576 : : "on#off");
6577 : :
6578 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6579 : : .f = cmd_set_allmulti_mode_parsed,
6580 : : .data = (void *)1,
6581 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6582 : : .tokens = {
6583 : : (void *)&cmd_setallmulti_set,
6584 : : (void *)&cmd_setallmulti_allmulti,
6585 : : (void *)&cmd_setallmulti_portall,
6586 : : (void *)&cmd_setallmulti_mode,
6587 : : NULL,
6588 : : },
6589 : : };
6590 : :
6591 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6592 : : .f = cmd_set_allmulti_mode_parsed,
6593 : : .data = (void *)0,
6594 : : .help_str = "set allmulti <port_id> on|off: "
6595 : : "Set allmulti mode on port_id",
6596 : : .tokens = {
6597 : : (void *)&cmd_setallmulti_set,
6598 : : (void *)&cmd_setallmulti_allmulti,
6599 : : (void *)&cmd_setallmulti_portnum,
6600 : : (void *)&cmd_setallmulti_mode,
6601 : : NULL,
6602 : : },
6603 : : };
6604 : :
6605 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6606 : : struct cmd_link_flow_ctrl_show {
6607 : : cmdline_fixed_string_t show;
6608 : : cmdline_fixed_string_t port;
6609 : : portid_t port_id;
6610 : : cmdline_fixed_string_t flow_ctrl;
6611 : : };
6612 : :
6613 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6614 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6615 : : show, "show");
6616 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6617 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6618 : : port, "port");
6619 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6620 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6621 : : port_id, RTE_UINT16);
6622 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6623 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6624 : : flow_ctrl, "flow_ctrl");
6625 : :
6626 : : static void
6627 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6628 : : __rte_unused struct cmdline *cl,
6629 : : __rte_unused void *data)
6630 : : {
6631 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6632 : : static const char *info_border = "*********************";
6633 : : struct rte_eth_fc_conf fc_conf;
6634 : : bool rx_fc_en = false;
6635 : : bool tx_fc_en = false;
6636 : : int ret;
6637 : :
6638 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6639 : 0 : if (ret != 0) {
6640 : 0 : fprintf(stderr,
6641 : : "Failed to get current flow ctrl information: err = %d\n",
6642 : : ret);
6643 : 0 : return;
6644 : : }
6645 : :
6646 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6647 : : rx_fc_en = true;
6648 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6649 : : tx_fc_en = true;
6650 : :
6651 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6652 : 0 : info_border, res->port_id, info_border);
6653 : : printf("FC mode:\n");
6654 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6655 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6656 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6657 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6658 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6659 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6660 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6661 : 0 : printf("Forward MAC control frames: %s\n",
6662 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6663 : 0 : printf("\n%s************** End ***********%s\n",
6664 : : info_border, info_border);
6665 : : }
6666 : :
6667 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6668 : : .f = cmd_link_flow_ctrl_show_parsed,
6669 : : .data = NULL,
6670 : : .help_str = "show port <port_id> flow_ctrl",
6671 : : .tokens = {
6672 : : (void *)&cmd_lfc_show_show,
6673 : : (void *)&cmd_lfc_show_port,
6674 : : (void *)&cmd_lfc_show_portid,
6675 : : (void *)&cmd_lfc_show_flow_ctrl,
6676 : : NULL,
6677 : : },
6678 : : };
6679 : :
6680 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6681 : : struct cmd_link_flow_ctrl_set_result {
6682 : : cmdline_fixed_string_t set;
6683 : : cmdline_fixed_string_t flow_ctrl;
6684 : : cmdline_fixed_string_t rx;
6685 : : cmdline_fixed_string_t rx_lfc_mode;
6686 : : cmdline_fixed_string_t tx;
6687 : : cmdline_fixed_string_t tx_lfc_mode;
6688 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6689 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6690 : : cmdline_fixed_string_t autoneg_str;
6691 : : cmdline_fixed_string_t autoneg;
6692 : : cmdline_fixed_string_t hw_str;
6693 : : uint32_t high_water;
6694 : : cmdline_fixed_string_t lw_str;
6695 : : uint32_t low_water;
6696 : : cmdline_fixed_string_t pt_str;
6697 : : uint16_t pause_time;
6698 : : cmdline_fixed_string_t xon_str;
6699 : : uint16_t send_xon;
6700 : : portid_t port_id;
6701 : : };
6702 : :
6703 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6704 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6705 : : set, "set");
6706 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6707 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6708 : : flow_ctrl, "flow_ctrl");
6709 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6710 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6711 : : rx, "rx");
6712 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6713 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6714 : : rx_lfc_mode, "on#off");
6715 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6716 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6717 : : tx, "tx");
6718 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6719 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6720 : : tx_lfc_mode, "on#off");
6721 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6722 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6723 : : hw_str, "high_water");
6724 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6725 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6726 : : high_water, RTE_UINT32);
6727 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6728 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6729 : : lw_str, "low_water");
6730 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6731 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6732 : : low_water, RTE_UINT32);
6733 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6734 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6735 : : pt_str, "pause_time");
6736 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6737 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6738 : : pause_time, RTE_UINT16);
6739 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6740 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6741 : : xon_str, "send_xon");
6742 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6743 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6744 : : send_xon, RTE_UINT16);
6745 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6746 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6747 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6748 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6749 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6750 : : mac_ctrl_frame_fwd_mode, "on#off");
6751 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6752 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6753 : : autoneg_str, "autoneg");
6754 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6755 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6756 : : autoneg, "on#off");
6757 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6758 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6759 : : port_id, RTE_UINT16);
6760 : :
6761 : : /* forward declaration */
6762 : : static void
6763 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6764 : : void *data);
6765 : :
6766 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6767 : : .f = cmd_link_flow_ctrl_set_parsed,
6768 : : .data = NULL,
6769 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6770 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6771 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6772 : : .tokens = {
6773 : : (void *)&cmd_lfc_set_set,
6774 : : (void *)&cmd_lfc_set_flow_ctrl,
6775 : : (void *)&cmd_lfc_set_rx,
6776 : : (void *)&cmd_lfc_set_rx_mode,
6777 : : (void *)&cmd_lfc_set_tx,
6778 : : (void *)&cmd_lfc_set_tx_mode,
6779 : : (void *)&cmd_lfc_set_high_water,
6780 : : (void *)&cmd_lfc_set_low_water,
6781 : : (void *)&cmd_lfc_set_pause_time,
6782 : : (void *)&cmd_lfc_set_send_xon,
6783 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6784 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6785 : : (void *)&cmd_lfc_set_autoneg_str,
6786 : : (void *)&cmd_lfc_set_autoneg,
6787 : : (void *)&cmd_lfc_set_portid,
6788 : : NULL,
6789 : : },
6790 : : };
6791 : :
6792 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6793 : : .f = cmd_link_flow_ctrl_set_parsed,
6794 : : .data = (void *)&cmd_link_flow_control_set_rx,
6795 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6796 : : "Change rx flow control parameter",
6797 : : .tokens = {
6798 : : (void *)&cmd_lfc_set_set,
6799 : : (void *)&cmd_lfc_set_flow_ctrl,
6800 : : (void *)&cmd_lfc_set_rx,
6801 : : (void *)&cmd_lfc_set_rx_mode,
6802 : : (void *)&cmd_lfc_set_portid,
6803 : : NULL,
6804 : : },
6805 : : };
6806 : :
6807 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6808 : : .f = cmd_link_flow_ctrl_set_parsed,
6809 : : .data = (void *)&cmd_link_flow_control_set_tx,
6810 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6811 : : "Change tx flow control parameter",
6812 : : .tokens = {
6813 : : (void *)&cmd_lfc_set_set,
6814 : : (void *)&cmd_lfc_set_flow_ctrl,
6815 : : (void *)&cmd_lfc_set_tx,
6816 : : (void *)&cmd_lfc_set_tx_mode,
6817 : : (void *)&cmd_lfc_set_portid,
6818 : : NULL,
6819 : : },
6820 : : };
6821 : :
6822 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6823 : : .f = cmd_link_flow_ctrl_set_parsed,
6824 : : .data = (void *)&cmd_link_flow_control_set_hw,
6825 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6826 : : "Change high water flow control parameter",
6827 : : .tokens = {
6828 : : (void *)&cmd_lfc_set_set,
6829 : : (void *)&cmd_lfc_set_flow_ctrl,
6830 : : (void *)&cmd_lfc_set_high_water_str,
6831 : : (void *)&cmd_lfc_set_high_water,
6832 : : (void *)&cmd_lfc_set_portid,
6833 : : NULL,
6834 : : },
6835 : : };
6836 : :
6837 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6838 : : .f = cmd_link_flow_ctrl_set_parsed,
6839 : : .data = (void *)&cmd_link_flow_control_set_lw,
6840 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6841 : : "Change low water flow control parameter",
6842 : : .tokens = {
6843 : : (void *)&cmd_lfc_set_set,
6844 : : (void *)&cmd_lfc_set_flow_ctrl,
6845 : : (void *)&cmd_lfc_set_low_water_str,
6846 : : (void *)&cmd_lfc_set_low_water,
6847 : : (void *)&cmd_lfc_set_portid,
6848 : : NULL,
6849 : : },
6850 : : };
6851 : :
6852 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6853 : : .f = cmd_link_flow_ctrl_set_parsed,
6854 : : .data = (void *)&cmd_link_flow_control_set_pt,
6855 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6856 : : "Change pause time flow control parameter",
6857 : : .tokens = {
6858 : : (void *)&cmd_lfc_set_set,
6859 : : (void *)&cmd_lfc_set_flow_ctrl,
6860 : : (void *)&cmd_lfc_set_pause_time_str,
6861 : : (void *)&cmd_lfc_set_pause_time,
6862 : : (void *)&cmd_lfc_set_portid,
6863 : : NULL,
6864 : : },
6865 : : };
6866 : :
6867 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6868 : : .f = cmd_link_flow_ctrl_set_parsed,
6869 : : .data = (void *)&cmd_link_flow_control_set_xon,
6870 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6871 : : "Change send_xon flow control parameter",
6872 : : .tokens = {
6873 : : (void *)&cmd_lfc_set_set,
6874 : : (void *)&cmd_lfc_set_flow_ctrl,
6875 : : (void *)&cmd_lfc_set_send_xon_str,
6876 : : (void *)&cmd_lfc_set_send_xon,
6877 : : (void *)&cmd_lfc_set_portid,
6878 : : NULL,
6879 : : },
6880 : : };
6881 : :
6882 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6883 : : .f = cmd_link_flow_ctrl_set_parsed,
6884 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6885 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6886 : : "Change mac ctrl fwd flow control parameter",
6887 : : .tokens = {
6888 : : (void *)&cmd_lfc_set_set,
6889 : : (void *)&cmd_lfc_set_flow_ctrl,
6890 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6891 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6892 : : (void *)&cmd_lfc_set_portid,
6893 : : NULL,
6894 : : },
6895 : : };
6896 : :
6897 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6898 : : .f = cmd_link_flow_ctrl_set_parsed,
6899 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6900 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6901 : : "Change autoneg flow control parameter",
6902 : : .tokens = {
6903 : : (void *)&cmd_lfc_set_set,
6904 : : (void *)&cmd_lfc_set_flow_ctrl,
6905 : : (void *)&cmd_lfc_set_autoneg_str,
6906 : : (void *)&cmd_lfc_set_autoneg,
6907 : : (void *)&cmd_lfc_set_portid,
6908 : : NULL,
6909 : : },
6910 : : };
6911 : :
6912 : : static void
6913 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6914 : : __rte_unused struct cmdline *cl,
6915 : : void *data)
6916 : : {
6917 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6918 : : cmdline_parse_inst_t *cmd = data;
6919 : : struct rte_eth_fc_conf fc_conf;
6920 : : int rx_fc_en = 0;
6921 : : int tx_fc_en = 0;
6922 : : int ret;
6923 : :
6924 : : /*
6925 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6926 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6927 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6928 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6929 : : */
6930 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6931 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6932 : : };
6933 : :
6934 : : /* Partial command line, retrieve current configuration */
6935 : 0 : if (cmd) {
6936 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6937 : 0 : if (ret != 0) {
6938 : 0 : fprintf(stderr,
6939 : : "cannot get current flow ctrl parameters, return code = %d\n",
6940 : : ret);
6941 : 0 : return;
6942 : : }
6943 : :
6944 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6945 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6946 : : rx_fc_en = 1;
6947 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6948 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6949 : : tx_fc_en = 1;
6950 : : }
6951 : :
6952 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6953 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6954 : :
6955 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6956 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6957 : :
6958 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6959 : :
6960 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6961 : 0 : fc_conf.high_water = res->high_water;
6962 : :
6963 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6964 : 0 : fc_conf.low_water = res->low_water;
6965 : :
6966 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6967 : 0 : fc_conf.pause_time = res->pause_time;
6968 : :
6969 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6970 : 0 : fc_conf.send_xon = res->send_xon;
6971 : :
6972 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6973 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6974 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6975 : : else
6976 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6977 : : }
6978 : :
6979 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6980 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6981 : :
6982 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6983 : 0 : if (ret != 0)
6984 : 0 : fprintf(stderr,
6985 : : "bad flow control parameter, return code = %d\n",
6986 : : ret);
6987 : : }
6988 : :
6989 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6990 : : struct cmd_priority_flow_ctrl_set_result {
6991 : : cmdline_fixed_string_t set;
6992 : : cmdline_fixed_string_t pfc_ctrl;
6993 : : cmdline_fixed_string_t rx;
6994 : : cmdline_fixed_string_t rx_pfc_mode;
6995 : : cmdline_fixed_string_t tx;
6996 : : cmdline_fixed_string_t tx_pfc_mode;
6997 : : uint32_t high_water;
6998 : : uint32_t low_water;
6999 : : uint16_t pause_time;
7000 : : uint8_t priority;
7001 : : portid_t port_id;
7002 : : };
7003 : :
7004 : : static void
7005 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7006 : : __rte_unused struct cmdline *cl,
7007 : : __rte_unused void *data)
7008 : : {
7009 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7010 : : struct rte_eth_pfc_conf pfc_conf;
7011 : : int rx_fc_enable, tx_fc_enable;
7012 : : int ret;
7013 : :
7014 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
7015 : 0 : return;
7016 : :
7017 : : /*
7018 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7019 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7020 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7021 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7022 : : */
7023 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7024 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7025 : : };
7026 : :
7027 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7028 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7029 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7030 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7031 : 0 : pfc_conf.fc.high_water = res->high_water;
7032 : 0 : pfc_conf.fc.low_water = res->low_water;
7033 : 0 : pfc_conf.fc.pause_time = res->pause_time;
7034 : 0 : pfc_conf.priority = res->priority;
7035 : :
7036 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7037 : 0 : if (ret != 0)
7038 : 0 : fprintf(stderr,
7039 : : "bad priority flow control parameter, return code = %d\n",
7040 : : ret);
7041 : : }
7042 : :
7043 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
7044 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7045 : : set, "set");
7046 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7047 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7048 : : pfc_ctrl, "pfc_ctrl");
7049 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
7050 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7051 : : rx, "rx");
7052 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7053 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7054 : : rx_pfc_mode, "on#off");
7055 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
7056 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7057 : : tx, "tx");
7058 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7059 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7060 : : tx_pfc_mode, "on#off");
7061 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
7062 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7063 : : high_water, RTE_UINT32);
7064 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
7065 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7066 : : low_water, RTE_UINT32);
7067 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7068 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7069 : : pause_time, RTE_UINT16);
7070 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
7071 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7072 : : priority, RTE_UINT8);
7073 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
7074 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7075 : : port_id, RTE_UINT16);
7076 : :
7077 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
7078 : : .f = cmd_priority_flow_ctrl_set_parsed,
7079 : : .data = NULL,
7080 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7081 : : "<pause_time> <priority> <port_id>: "
7082 : : "Configure the Ethernet priority flow control",
7083 : : .tokens = {
7084 : : (void *)&cmd_pfc_set_set,
7085 : : (void *)&cmd_pfc_set_flow_ctrl,
7086 : : (void *)&cmd_pfc_set_rx,
7087 : : (void *)&cmd_pfc_set_rx_mode,
7088 : : (void *)&cmd_pfc_set_tx,
7089 : : (void *)&cmd_pfc_set_tx_mode,
7090 : : (void *)&cmd_pfc_set_high_water,
7091 : : (void *)&cmd_pfc_set_low_water,
7092 : : (void *)&cmd_pfc_set_pause_time,
7093 : : (void *)&cmd_pfc_set_priority,
7094 : : (void *)&cmd_pfc_set_portid,
7095 : : NULL,
7096 : : },
7097 : : };
7098 : :
7099 : : struct cmd_queue_priority_flow_ctrl_set_result {
7100 : : cmdline_fixed_string_t set;
7101 : : cmdline_fixed_string_t pfc_queue_ctrl;
7102 : : portid_t port_id;
7103 : : cmdline_fixed_string_t rx;
7104 : : cmdline_fixed_string_t rx_pfc_mode;
7105 : : uint16_t tx_qid;
7106 : : uint8_t tx_tc;
7107 : : cmdline_fixed_string_t tx;
7108 : : cmdline_fixed_string_t tx_pfc_mode;
7109 : : uint16_t rx_qid;
7110 : : uint8_t rx_tc;
7111 : : uint16_t pause_time;
7112 : : };
7113 : :
7114 : : static void
7115 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7116 : : __rte_unused struct cmdline *cl,
7117 : : __rte_unused void *data)
7118 : : {
7119 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7120 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
7121 : : int rx_fc_enable, tx_fc_enable;
7122 : : int ret;
7123 : :
7124 : : /*
7125 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
7126 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7127 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
7128 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7129 : : * the Tx side.
7130 : : */
7131 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7132 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7133 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7134 : : };
7135 : :
7136 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7137 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7138 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7139 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7140 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
7141 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7142 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
7143 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7144 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7145 : :
7146 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7147 : : &pfc_queue_conf);
7148 : 0 : if (ret != 0) {
7149 : 0 : fprintf(stderr,
7150 : : "bad queue priority flow control parameter, rc = %d\n",
7151 : : ret);
7152 : : }
7153 : 0 : }
7154 : :
7155 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
7156 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7157 : : set, "set");
7158 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7159 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7160 : : pfc_queue_ctrl, "pfc_queue_ctrl");
7161 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7162 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7163 : : port_id, RTE_UINT16);
7164 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7165 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7166 : : rx, "rx");
7167 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7168 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7169 : : rx_pfc_mode, "on#off");
7170 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7171 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7172 : : tx_qid, RTE_UINT16);
7173 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7174 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7175 : : tx_tc, RTE_UINT8);
7176 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7177 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7178 : : tx, "tx");
7179 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7180 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7181 : : tx_pfc_mode, "on#off");
7182 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7183 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7184 : : rx_qid, RTE_UINT16);
7185 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7186 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7187 : : rx_tc, RTE_UINT8);
7188 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7189 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7190 : : pause_time, RTE_UINT16);
7191 : :
7192 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7193 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
7194 : : .data = NULL,
7195 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7196 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7197 : : "Configure the Ethernet queue priority flow control",
7198 : : .tokens = {
7199 : : (void *)&cmd_q_pfc_set_set,
7200 : : (void *)&cmd_q_pfc_set_flow_ctrl,
7201 : : (void *)&cmd_q_pfc_set_portid,
7202 : : (void *)&cmd_q_pfc_set_rx,
7203 : : (void *)&cmd_q_pfc_set_rx_mode,
7204 : : (void *)&cmd_q_pfc_set_tx_qid,
7205 : : (void *)&cmd_q_pfc_set_tx_tc,
7206 : : (void *)&cmd_q_pfc_set_tx,
7207 : : (void *)&cmd_q_pfc_set_tx_mode,
7208 : : (void *)&cmd_q_pfc_set_rx_qid,
7209 : : (void *)&cmd_q_pfc_set_rx_tc,
7210 : : (void *)&cmd_q_pfc_set_pause_time,
7211 : : NULL,
7212 : : },
7213 : : };
7214 : :
7215 : : /* *** RESET CONFIGURATION *** */
7216 : : struct cmd_reset_result {
7217 : : cmdline_fixed_string_t reset;
7218 : : cmdline_fixed_string_t def;
7219 : : };
7220 : :
7221 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
7222 : : struct cmdline *cl,
7223 : : __rte_unused void *data)
7224 : : {
7225 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7226 : 0 : set_def_fwd_config();
7227 : 0 : }
7228 : :
7229 : : static cmdline_parse_token_string_t cmd_reset_set =
7230 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7231 : : static cmdline_parse_token_string_t cmd_reset_def =
7232 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7233 : : "default");
7234 : :
7235 : : static cmdline_parse_inst_t cmd_reset = {
7236 : : .f = cmd_reset_parsed,
7237 : : .data = NULL,
7238 : : .help_str = "set default: Reset default forwarding configuration",
7239 : : .tokens = {
7240 : : (void *)&cmd_reset_set,
7241 : : (void *)&cmd_reset_def,
7242 : : NULL,
7243 : : },
7244 : : };
7245 : :
7246 : : /* *** START FORWARDING *** */
7247 : : struct cmd_start_result {
7248 : : cmdline_fixed_string_t start;
7249 : : };
7250 : :
7251 : : static cmdline_parse_token_string_t cmd_start_start =
7252 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7253 : :
7254 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
7255 : : __rte_unused struct cmdline *cl,
7256 : : __rte_unused void *data)
7257 : : {
7258 : 0 : start_packet_forwarding(0);
7259 : 0 : }
7260 : :
7261 : : static cmdline_parse_inst_t cmd_start = {
7262 : : .f = cmd_start_parsed,
7263 : : .data = NULL,
7264 : : .help_str = "start: Start packet forwarding",
7265 : : .tokens = {
7266 : : (void *)&cmd_start_start,
7267 : : NULL,
7268 : : },
7269 : : };
7270 : :
7271 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7272 : : struct cmd_start_tx_first_result {
7273 : : cmdline_fixed_string_t start;
7274 : : cmdline_fixed_string_t tx_first;
7275 : : };
7276 : :
7277 : : static void
7278 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7279 : : __rte_unused struct cmdline *cl,
7280 : : __rte_unused void *data)
7281 : : {
7282 : 0 : start_packet_forwarding(1);
7283 : 0 : }
7284 : :
7285 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
7286 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7287 : : "start");
7288 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7289 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7290 : : tx_first, "tx_first");
7291 : :
7292 : : static cmdline_parse_inst_t cmd_start_tx_first = {
7293 : : .f = cmd_start_tx_first_parsed,
7294 : : .data = NULL,
7295 : : .help_str = "start tx_first: Start packet forwarding, "
7296 : : "after sending 1 burst of packets",
7297 : : .tokens = {
7298 : : (void *)&cmd_start_tx_first_start,
7299 : : (void *)&cmd_start_tx_first_tx_first,
7300 : : NULL,
7301 : : },
7302 : : };
7303 : :
7304 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
7305 : : struct cmd_start_tx_first_n_result {
7306 : : cmdline_fixed_string_t start;
7307 : : cmdline_fixed_string_t tx_first;
7308 : : uint32_t tx_num;
7309 : : };
7310 : :
7311 : : static void
7312 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
7313 : : __rte_unused struct cmdline *cl,
7314 : : __rte_unused void *data)
7315 : : {
7316 : : struct cmd_start_tx_first_n_result *res = parsed_result;
7317 : :
7318 : 0 : start_packet_forwarding(res->tx_num);
7319 : 0 : }
7320 : :
7321 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7322 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7323 : : start, "start");
7324 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7325 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7326 : : tx_first, "tx_first");
7327 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7328 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7329 : : tx_num, RTE_UINT32);
7330 : :
7331 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
7332 : : .f = cmd_start_tx_first_n_parsed,
7333 : : .data = NULL,
7334 : : .help_str = "start tx_first <num>: "
7335 : : "packet forwarding, after sending <num> bursts of packets",
7336 : : .tokens = {
7337 : : (void *)&cmd_start_tx_first_n_start,
7338 : : (void *)&cmd_start_tx_first_n_tx_first,
7339 : : (void *)&cmd_start_tx_first_n_tx_num,
7340 : : NULL,
7341 : : },
7342 : : };
7343 : :
7344 : : /* *** SET LINK UP *** */
7345 : : struct cmd_set_link_up_result {
7346 : : cmdline_fixed_string_t set;
7347 : : cmdline_fixed_string_t link_up;
7348 : : cmdline_fixed_string_t port;
7349 : : portid_t port_id;
7350 : : };
7351 : :
7352 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
7353 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7354 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7355 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7356 : : "link-up");
7357 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
7358 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7359 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7360 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7361 : : RTE_UINT16);
7362 : :
7363 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7364 : : __rte_unused struct cmdline *cl,
7365 : : __rte_unused void *data)
7366 : : {
7367 : : struct cmd_set_link_up_result *res = parsed_result;
7368 : 0 : dev_set_link_up(res->port_id);
7369 : 0 : }
7370 : :
7371 : : static cmdline_parse_inst_t cmd_set_link_up = {
7372 : : .f = cmd_set_link_up_parsed,
7373 : : .data = NULL,
7374 : : .help_str = "set link-up port <port id>",
7375 : : .tokens = {
7376 : : (void *)&cmd_set_link_up_set,
7377 : : (void *)&cmd_set_link_up_link_up,
7378 : : (void *)&cmd_set_link_up_port,
7379 : : (void *)&cmd_set_link_up_port_id,
7380 : : NULL,
7381 : : },
7382 : : };
7383 : :
7384 : : /* *** SET LINK DOWN *** */
7385 : : struct cmd_set_link_down_result {
7386 : : cmdline_fixed_string_t set;
7387 : : cmdline_fixed_string_t link_down;
7388 : : cmdline_fixed_string_t port;
7389 : : portid_t port_id;
7390 : : };
7391 : :
7392 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
7393 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7394 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
7395 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7396 : : "link-down");
7397 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
7398 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7399 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
7400 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7401 : : RTE_UINT16);
7402 : :
7403 : 0 : static void cmd_set_link_down_parsed(
7404 : : __rte_unused void *parsed_result,
7405 : : __rte_unused struct cmdline *cl,
7406 : : __rte_unused void *data)
7407 : : {
7408 : : struct cmd_set_link_down_result *res = parsed_result;
7409 : 0 : dev_set_link_down(res->port_id);
7410 : 0 : }
7411 : :
7412 : : static cmdline_parse_inst_t cmd_set_link_down = {
7413 : : .f = cmd_set_link_down_parsed,
7414 : : .data = NULL,
7415 : : .help_str = "set link-down port <port id>",
7416 : : .tokens = {
7417 : : (void *)&cmd_set_link_down_set,
7418 : : (void *)&cmd_set_link_down_link_down,
7419 : : (void *)&cmd_set_link_down_port,
7420 : : (void *)&cmd_set_link_down_port_id,
7421 : : NULL,
7422 : : },
7423 : : };
7424 : :
7425 : : /* *** SHOW CFG *** */
7426 : : struct cmd_showcfg_result {
7427 : : cmdline_fixed_string_t show;
7428 : : cmdline_fixed_string_t cfg;
7429 : : cmdline_fixed_string_t what;
7430 : : };
7431 : :
7432 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
7433 : : __rte_unused struct cmdline *cl,
7434 : : __rte_unused void *data)
7435 : : {
7436 : : struct cmd_showcfg_result *res = parsed_result;
7437 : 0 : if (!strcmp(res->what, "rxtx"))
7438 : 0 : rxtx_config_display();
7439 : 0 : else if (!strcmp(res->what, "cores"))
7440 : 0 : fwd_lcores_config_display();
7441 : 0 : else if (!strcmp(res->what, "fwd"))
7442 : 0 : pkt_fwd_config_display(&cur_fwd_config);
7443 : 0 : else if (!strcmp(res->what, "rxoffs"))
7444 : 0 : show_rx_pkt_offsets();
7445 : 0 : else if (!strcmp(res->what, "rxpkts"))
7446 : 0 : show_rx_pkt_segments();
7447 : 0 : else if (!strcmp(res->what, "rxhdrs"))
7448 : 0 : show_rx_pkt_hdrs();
7449 : 0 : else if (!strcmp(res->what, "txpkts"))
7450 : 0 : show_tx_pkt_segments();
7451 : 0 : else if (!strcmp(res->what, "txtimes"))
7452 : 0 : show_tx_pkt_times();
7453 : 0 : else if (!strcmp(res->what, "dcbfwdtc"))
7454 : 0 : show_dcb_fwd_tc_config();
7455 : 0 : }
7456 : :
7457 : : static cmdline_parse_token_string_t cmd_showcfg_show =
7458 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7459 : : static cmdline_parse_token_string_t cmd_showcfg_port =
7460 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7461 : : static cmdline_parse_token_string_t cmd_showcfg_what =
7462 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7463 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes#dcbfwdtc");
7464 : :
7465 : : static cmdline_parse_inst_t cmd_showcfg = {
7466 : : .f = cmd_showcfg_parsed,
7467 : : .data = NULL,
7468 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes|dcbfwdtc",
7469 : : .tokens = {
7470 : : (void *)&cmd_showcfg_show,
7471 : : (void *)&cmd_showcfg_port,
7472 : : (void *)&cmd_showcfg_what,
7473 : : NULL,
7474 : : },
7475 : : };
7476 : :
7477 : : /* *** SHOW ALL PORT INFO *** */
7478 : : struct cmd_showportall_result {
7479 : : cmdline_fixed_string_t show;
7480 : : cmdline_fixed_string_t port;
7481 : : cmdline_fixed_string_t what;
7482 : : cmdline_fixed_string_t all;
7483 : : };
7484 : :
7485 : 0 : static void cmd_showportall_parsed(void *parsed_result,
7486 : : __rte_unused struct cmdline *cl,
7487 : : __rte_unused void *data)
7488 : : {
7489 : : portid_t i;
7490 : :
7491 : : struct cmd_showportall_result *res = parsed_result;
7492 : 0 : if (!strcmp(res->show, "clear")) {
7493 : 0 : if (!strcmp(res->what, "stats"))
7494 : 0 : RTE_ETH_FOREACH_DEV(i)
7495 : 0 : nic_stats_clear(i);
7496 : 0 : else if (!strcmp(res->what, "xstats"))
7497 : 0 : RTE_ETH_FOREACH_DEV(i)
7498 : 0 : nic_xstats_clear(i);
7499 : 0 : } else if (!strcmp(res->what, "info"))
7500 : 0 : RTE_ETH_FOREACH_DEV(i)
7501 : 0 : port_infos_display(i);
7502 : 0 : else if (!strcmp(res->what, "summary")) {
7503 : 0 : port_summary_header_display();
7504 : 0 : RTE_ETH_FOREACH_DEV(i)
7505 : 0 : port_summary_display(i);
7506 : : }
7507 : 0 : else if (!strcmp(res->what, "stats"))
7508 : 0 : RTE_ETH_FOREACH_DEV(i)
7509 : 0 : nic_stats_display(i);
7510 : 0 : else if (!strcmp(res->what, "xstats"))
7511 : 0 : RTE_ETH_FOREACH_DEV(i)
7512 : 0 : nic_xstats_display(i);
7513 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7514 : 0 : else if (!strcmp(res->what, "fdir"))
7515 : 0 : RTE_ETH_FOREACH_DEV(i)
7516 : 0 : fdir_get_infos(i);
7517 : : #endif
7518 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7519 : 0 : RTE_ETH_FOREACH_DEV(i)
7520 : 0 : port_dcb_info_display(i);
7521 : 0 : }
7522 : :
7523 : : static cmdline_parse_token_string_t cmd_showportall_show =
7524 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7525 : : "show#clear");
7526 : : static cmdline_parse_token_string_t cmd_showportall_port =
7527 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7528 : : static cmdline_parse_token_string_t cmd_showportall_what =
7529 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7530 : : "info#summary#stats#xstats#fdir#dcb_tc");
7531 : : static cmdline_parse_token_string_t cmd_showportall_all =
7532 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7533 : : static cmdline_parse_inst_t cmd_showportall = {
7534 : : .f = cmd_showportall_parsed,
7535 : : .data = NULL,
7536 : : .help_str = "show|clear port "
7537 : : "info|summary|stats|xstats|fdir|dcb_tc all",
7538 : : .tokens = {
7539 : : (void *)&cmd_showportall_show,
7540 : : (void *)&cmd_showportall_port,
7541 : : (void *)&cmd_showportall_what,
7542 : : (void *)&cmd_showportall_all,
7543 : : NULL,
7544 : : },
7545 : : };
7546 : :
7547 : : /* *** SHOW PORT INFO *** */
7548 : : struct cmd_showport_result {
7549 : : cmdline_fixed_string_t show;
7550 : : cmdline_fixed_string_t port;
7551 : : cmdline_fixed_string_t what;
7552 : : uint16_t portnum;
7553 : : };
7554 : :
7555 : 0 : static void cmd_showport_parsed(void *parsed_result,
7556 : : __rte_unused struct cmdline *cl,
7557 : : __rte_unused void *data)
7558 : : {
7559 : : struct cmd_showport_result *res = parsed_result;
7560 : 0 : if (!strcmp(res->show, "clear")) {
7561 : 0 : if (!strcmp(res->what, "stats"))
7562 : 0 : nic_stats_clear(res->portnum);
7563 : 0 : else if (!strcmp(res->what, "xstats"))
7564 : 0 : nic_xstats_clear(res->portnum);
7565 : 0 : } else if (!strcmp(res->what, "info"))
7566 : 0 : port_infos_display(res->portnum);
7567 : 0 : else if (!strcmp(res->what, "summary")) {
7568 : 0 : port_summary_header_display();
7569 : 0 : port_summary_display(res->portnum);
7570 : : }
7571 : 0 : else if (!strcmp(res->what, "stats"))
7572 : 0 : nic_stats_display(res->portnum);
7573 : 0 : else if (!strcmp(res->what, "xstats"))
7574 : 0 : nic_xstats_display(res->portnum);
7575 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7576 : 0 : else if (!strcmp(res->what, "fdir"))
7577 : 0 : fdir_get_infos(res->portnum);
7578 : : #endif
7579 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7580 : 0 : port_dcb_info_display(res->portnum);
7581 : 0 : }
7582 : :
7583 : : static cmdline_parse_token_string_t cmd_showport_show =
7584 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7585 : : "show#clear");
7586 : : static cmdline_parse_token_string_t cmd_showport_port =
7587 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7588 : : static cmdline_parse_token_string_t cmd_showport_what =
7589 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7590 : : "info#summary#stats#xstats#fdir#dcb_tc");
7591 : : static cmdline_parse_token_num_t cmd_showport_portnum =
7592 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7593 : :
7594 : : static cmdline_parse_inst_t cmd_showport = {
7595 : : .f = cmd_showport_parsed,
7596 : : .data = NULL,
7597 : : .help_str = "show|clear port "
7598 : : "info|summary|stats|xstats|fdir|dcb_tc "
7599 : : "<port_id>",
7600 : : .tokens = {
7601 : : (void *)&cmd_showport_show,
7602 : : (void *)&cmd_showport_port,
7603 : : (void *)&cmd_showport_what,
7604 : : (void *)&cmd_showport_portnum,
7605 : : NULL,
7606 : : },
7607 : : };
7608 : :
7609 : : /* *** show port representors information *** */
7610 : : struct cmd_representor_info_result {
7611 : : cmdline_fixed_string_t cmd_show;
7612 : : cmdline_fixed_string_t cmd_port;
7613 : : cmdline_fixed_string_t cmd_info;
7614 : : cmdline_fixed_string_t cmd_keyword;
7615 : : portid_t cmd_pid;
7616 : : };
7617 : :
7618 : : static void
7619 : 0 : cmd_representor_info_parsed(void *parsed_result,
7620 : : __rte_unused struct cmdline *cl,
7621 : : __rte_unused void *data)
7622 : : {
7623 : : struct cmd_representor_info_result *res = parsed_result;
7624 : : struct rte_eth_representor_info *info;
7625 : : struct rte_eth_representor_range *range;
7626 : : uint32_t range_diff;
7627 : : uint32_t i;
7628 : : int ret;
7629 : : int num;
7630 : :
7631 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7632 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7633 : 0 : return;
7634 : : }
7635 : :
7636 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7637 : 0 : if (ret < 0) {
7638 : 0 : fprintf(stderr,
7639 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7640 : 0 : res->cmd_pid, rte_strerror(-ret));
7641 : 0 : return;
7642 : : }
7643 : : num = ret;
7644 : :
7645 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7646 : 0 : if (info == NULL) {
7647 : 0 : fprintf(stderr,
7648 : : "Failed to allocate memory for representor info for port %hu\n",
7649 : 0 : res->cmd_pid);
7650 : 0 : return;
7651 : : }
7652 : 0 : info->nb_ranges_alloc = num;
7653 : :
7654 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7655 : 0 : if (ret < 0) {
7656 : 0 : fprintf(stderr,
7657 : : "Failed to get the representor info for port %hu: %s\n",
7658 : 0 : res->cmd_pid, rte_strerror(-ret));
7659 : 0 : free(info);
7660 : 0 : return;
7661 : : }
7662 : :
7663 : 0 : printf("Port controller: %hu\n", info->controller);
7664 : 0 : printf("Port PF: %hu\n", info->pf);
7665 : :
7666 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7667 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7668 : : range = &info->ranges[i];
7669 : 0 : range_diff = range->id_end - range->id_base;
7670 : :
7671 : 0 : printf("%u. ", i + 1);
7672 : 0 : printf("'%s' ", range->name);
7673 : 0 : if (range_diff > 0)
7674 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7675 : : else
7676 : 0 : printf("[%u]: ", range->id_base);
7677 : :
7678 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7679 : :
7680 : 0 : switch (range->type) {
7681 : : case RTE_ETH_REPRESENTOR_NONE:
7682 : : printf(", NONE\n");
7683 : : break;
7684 : 0 : case RTE_ETH_REPRESENTOR_VF:
7685 : 0 : if (range_diff > 0)
7686 : 0 : printf(", VF %d..%d\n", range->vf,
7687 : 0 : range->vf + range_diff);
7688 : : else
7689 : 0 : printf(", VF %d\n", range->vf);
7690 : : break;
7691 : 0 : case RTE_ETH_REPRESENTOR_SF:
7692 : 0 : printf(", SF %d\n", range->sf);
7693 : : break;
7694 : 0 : case RTE_ETH_REPRESENTOR_PF:
7695 : 0 : if (range_diff > 0)
7696 : 0 : printf("..%d\n", range->pf + range_diff);
7697 : : else
7698 : : printf("\n");
7699 : : break;
7700 : 0 : default:
7701 : : printf(", UNKNOWN TYPE %d\n", range->type);
7702 : : break;
7703 : : }
7704 : : }
7705 : :
7706 : 0 : free(info);
7707 : : }
7708 : :
7709 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7710 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7711 : : cmd_show, "show");
7712 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7713 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7714 : : cmd_port, "port");
7715 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7716 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7717 : : cmd_info, "info");
7718 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7719 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7720 : : cmd_pid, RTE_UINT16);
7721 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7722 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7723 : : cmd_keyword, "representor");
7724 : :
7725 : : static cmdline_parse_inst_t cmd_representor_info = {
7726 : : .f = cmd_representor_info_parsed,
7727 : : .data = NULL,
7728 : : .help_str = "show port info <port_id> representor",
7729 : : .tokens = {
7730 : : (void *)&cmd_representor_info_show,
7731 : : (void *)&cmd_representor_info_port,
7732 : : (void *)&cmd_representor_info_info,
7733 : : (void *)&cmd_representor_info_pid,
7734 : : (void *)&cmd_representor_info_keyword,
7735 : : NULL,
7736 : : },
7737 : : };
7738 : :
7739 : :
7740 : : /* *** SHOW DEVICE INFO *** */
7741 : : struct cmd_showdevice_result {
7742 : : cmdline_fixed_string_t show;
7743 : : cmdline_fixed_string_t device;
7744 : : cmdline_fixed_string_t what;
7745 : : cmdline_fixed_string_t identifier;
7746 : : };
7747 : :
7748 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7749 : : __rte_unused struct cmdline *cl,
7750 : : __rte_unused void *data)
7751 : : {
7752 : : struct cmd_showdevice_result *res = parsed_result;
7753 : 0 : if (!strcmp(res->what, "info")) {
7754 : 0 : if (!strcmp(res->identifier, "all"))
7755 : 0 : device_infos_display(NULL);
7756 : : else
7757 : 0 : device_infos_display(res->identifier);
7758 : : }
7759 : 0 : }
7760 : :
7761 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7762 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7763 : : "show");
7764 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7765 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7766 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7767 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7768 : : "info");
7769 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7770 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7771 : : identifier, NULL);
7772 : :
7773 : : static cmdline_parse_inst_t cmd_showdevice = {
7774 : : .f = cmd_showdevice_parsed,
7775 : : .data = NULL,
7776 : : .help_str = "show device info <identifier>|all",
7777 : : .tokens = {
7778 : : (void *)&cmd_showdevice_show,
7779 : : (void *)&cmd_showdevice_device,
7780 : : (void *)&cmd_showdevice_what,
7781 : : (void *)&cmd_showdevice_identifier,
7782 : : NULL,
7783 : : },
7784 : : };
7785 : :
7786 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7787 : : struct cmd_showeeprom_result {
7788 : : cmdline_fixed_string_t show;
7789 : : cmdline_fixed_string_t port;
7790 : : uint16_t portnum;
7791 : : cmdline_fixed_string_t type;
7792 : : };
7793 : :
7794 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7795 : : __rte_unused struct cmdline *cl,
7796 : : __rte_unused void *data)
7797 : : {
7798 : : struct cmd_showeeprom_result *res = parsed_result;
7799 : :
7800 : 0 : if (!strcmp(res->type, "eeprom"))
7801 : 0 : port_eeprom_display(res->portnum);
7802 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7803 : 0 : port_module_eeprom_display(res->portnum);
7804 : : else
7805 : 0 : fprintf(stderr, "Unknown argument\n");
7806 : 0 : }
7807 : :
7808 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7809 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7810 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7811 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7812 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7813 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7814 : : RTE_UINT16);
7815 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7816 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7817 : :
7818 : : static cmdline_parse_inst_t cmd_showeeprom = {
7819 : : .f = cmd_showeeprom_parsed,
7820 : : .data = NULL,
7821 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7822 : : .tokens = {
7823 : : (void *)&cmd_showeeprom_show,
7824 : : (void *)&cmd_showeeprom_port,
7825 : : (void *)&cmd_showeeprom_portnum,
7826 : : (void *)&cmd_showeeprom_type,
7827 : : NULL,
7828 : : },
7829 : : };
7830 : :
7831 : : /* *** SET PORT EEPROM *** */
7832 : : struct cmd_seteeprom_result {
7833 : : cmdline_fixed_string_t set;
7834 : : cmdline_fixed_string_t port;
7835 : : uint16_t portnum;
7836 : : cmdline_fixed_string_t eeprom;
7837 : : cmdline_fixed_string_t confirm_str;
7838 : : cmdline_fixed_string_t magic_str;
7839 : : uint32_t magic;
7840 : : cmdline_fixed_string_t value;
7841 : : cmdline_multi_string_t token_str;
7842 : : };
7843 : :
7844 : 0 : static void cmd_seteeprom_parsed(void *parsed_result,
7845 : : __rte_unused struct cmdline *cl,
7846 : : __rte_unused void *data)
7847 : : {
7848 : : struct cmd_seteeprom_result *res = parsed_result;
7849 : : uint32_t offset = 0;
7850 : : uint32_t length;
7851 : : uint8_t *value;
7852 : : char *token_str;
7853 : : char *token;
7854 : :
7855 : 0 : token_str = res->token_str;
7856 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7857 : :
7858 : : /* Parse Hex string to Byte data */
7859 : 0 : if (strlen(token) % 2 != 0) {
7860 : 0 : fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
7861 : : token);
7862 : 0 : return;
7863 : : }
7864 : :
7865 : 0 : length = strlen(token) / 2;
7866 : 0 : value = calloc(length, sizeof(uint8_t));
7867 : 0 : for (int count = 0; count < (int)(length); count++) {
7868 : 0 : if (sscanf(token, "%2hhx", &value[count]) != 1) {
7869 : 0 : fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
7870 : 0 : token - (count + 1));
7871 : 0 : goto out;
7872 : : }
7873 : 0 : token += 2;
7874 : : }
7875 : :
7876 : : /* Second token: offset string */
7877 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7878 : 0 : if (token != NULL) {
7879 : 0 : if (strcmp(token, "offset") == 0) {
7880 : : /* Third token: offset */
7881 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7882 : 0 : if (token == NULL) {
7883 : 0 : fprintf(stderr, "No offset specified\n");
7884 : 0 : goto out;
7885 : : }
7886 : :
7887 : : char *end;
7888 : 0 : offset = strtoul(token, &end, 10);
7889 : 0 : if (offset == 0 && strcmp(end, "") != 0) {
7890 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7891 : 0 : goto out;
7892 : : }
7893 : : } else {
7894 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7895 : 0 : goto out;
7896 : : }
7897 : : }
7898 : :
7899 : 0 : port_eeprom_set(res->portnum, res->magic, offset, length, value);
7900 : :
7901 : 0 : out:
7902 : 0 : free(value);
7903 : : }
7904 : :
7905 : : static cmdline_parse_token_string_t cmd_seteeprom_set =
7906 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
7907 : : static cmdline_parse_token_string_t cmd_seteeprom_port =
7908 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
7909 : : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
7910 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
7911 : : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
7912 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
7913 : : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
7914 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
7915 : : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
7916 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
7917 : : static cmdline_parse_token_num_t cmd_seteeprom_magic =
7918 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
7919 : : static cmdline_parse_token_string_t cmd_seteeprom_value =
7920 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
7921 : : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
7922 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
7923 : :
7924 : : static cmdline_parse_inst_t cmd_seteeprom = {
7925 : : .f = cmd_seteeprom_parsed,
7926 : : .data = NULL,
7927 : : .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
7928 : : "value <value> offset <offset>: Set eeprom value for port_id.\n"
7929 : : "Note:\n"
7930 : : "This is a high-risk command and its misuse may result in "
7931 : : "unexpected behaviour from the NIC.\n"
7932 : : "By inserting \"accept_risk\" into the command, the user is "
7933 : : "acknowledging and taking responsibility for this risk.",
7934 : : .tokens = {
7935 : : (void *)&cmd_seteeprom_set,
7936 : : (void *)&cmd_seteeprom_port,
7937 : : (void *)&cmd_seteeprom_portnum,
7938 : : (void *)&cmd_seteeprom_eeprom,
7939 : : (void *)&cmd_seteeprom_confirm_str,
7940 : : (void *)&cmd_seteeprom_magic_str,
7941 : : (void *)&cmd_seteeprom_magic,
7942 : : (void *)&cmd_seteeprom_value,
7943 : : (void *)&cmd_seteeprom_token_str,
7944 : : NULL,
7945 : : },
7946 : : };
7947 : :
7948 : : /* *** SHOW QUEUE INFO *** */
7949 : : struct cmd_showqueue_result {
7950 : : cmdline_fixed_string_t show;
7951 : : cmdline_fixed_string_t type;
7952 : : cmdline_fixed_string_t what;
7953 : : uint16_t portnum;
7954 : : uint16_t queuenum;
7955 : : };
7956 : :
7957 : : static void
7958 : 0 : cmd_showqueue_parsed(void *parsed_result,
7959 : : __rte_unused struct cmdline *cl,
7960 : : __rte_unused void *data)
7961 : : {
7962 : : struct cmd_showqueue_result *res = parsed_result;
7963 : :
7964 : 0 : if (!strcmp(res->type, "rxq"))
7965 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7966 : 0 : else if (!strcmp(res->type, "txq"))
7967 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7968 : 0 : }
7969 : :
7970 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7971 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7972 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7973 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7974 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7975 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7976 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7977 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7978 : : RTE_UINT16);
7979 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7980 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7981 : : RTE_UINT16);
7982 : :
7983 : : static cmdline_parse_inst_t cmd_showqueue = {
7984 : : .f = cmd_showqueue_parsed,
7985 : : .data = NULL,
7986 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7987 : : .tokens = {
7988 : : (void *)&cmd_showqueue_show,
7989 : : (void *)&cmd_showqueue_type,
7990 : : (void *)&cmd_showqueue_what,
7991 : : (void *)&cmd_showqueue_portnum,
7992 : : (void *)&cmd_showqueue_queuenum,
7993 : : NULL,
7994 : : },
7995 : : };
7996 : :
7997 : : /* show/clear fwd engine statistics */
7998 : : struct fwd_result {
7999 : : cmdline_fixed_string_t action;
8000 : : cmdline_fixed_string_t fwd;
8001 : : cmdline_fixed_string_t stats;
8002 : : cmdline_fixed_string_t all;
8003 : : };
8004 : :
8005 : : static cmdline_parse_token_string_t cmd_fwd_action =
8006 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8007 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
8008 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8009 : : static cmdline_parse_token_string_t cmd_fwd_stats =
8010 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8011 : : static cmdline_parse_token_string_t cmd_fwd_all =
8012 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8013 : :
8014 : : static void
8015 : 0 : cmd_showfwdall_parsed(void *parsed_result,
8016 : : __rte_unused struct cmdline *cl,
8017 : : __rte_unused void *data)
8018 : : {
8019 : : struct fwd_result *res = parsed_result;
8020 : :
8021 : 0 : if (!strcmp(res->action, "show"))
8022 : 0 : fwd_stats_display();
8023 : : else
8024 : 0 : fwd_stats_reset();
8025 : 0 : }
8026 : :
8027 : : static cmdline_parse_inst_t cmd_showfwdall = {
8028 : : .f = cmd_showfwdall_parsed,
8029 : : .data = NULL,
8030 : : .help_str = "show|clear fwd stats all",
8031 : : .tokens = {
8032 : : (void *)&cmd_fwd_action,
8033 : : (void *)&cmd_fwd_fwd,
8034 : : (void *)&cmd_fwd_stats,
8035 : : (void *)&cmd_fwd_all,
8036 : : NULL,
8037 : : },
8038 : : };
8039 : :
8040 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8041 : : struct cmd_read_rxd_txd_result {
8042 : : cmdline_fixed_string_t read;
8043 : : cmdline_fixed_string_t rxd_txd;
8044 : : portid_t port_id;
8045 : : uint16_t queue_id;
8046 : : uint16_t desc_id;
8047 : : };
8048 : :
8049 : : static void
8050 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
8051 : : __rte_unused struct cmdline *cl,
8052 : : __rte_unused void *data)
8053 : : {
8054 : : struct cmd_read_rxd_txd_result *res = parsed_result;
8055 : :
8056 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
8057 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8058 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
8059 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8060 : 0 : }
8061 : :
8062 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8063 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8064 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8065 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8066 : : "rxd#txd");
8067 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8068 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8069 : : RTE_UINT16);
8070 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8071 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8072 : : RTE_UINT16);
8073 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8074 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8075 : : RTE_UINT16);
8076 : :
8077 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
8078 : : .f = cmd_read_rxd_txd_parsed,
8079 : : .data = NULL,
8080 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8081 : : .tokens = {
8082 : : (void *)&cmd_read_rxd_txd_read,
8083 : : (void *)&cmd_read_rxd_txd_rxd_txd,
8084 : : (void *)&cmd_read_rxd_txd_port_id,
8085 : : (void *)&cmd_read_rxd_txd_queue_id,
8086 : : (void *)&cmd_read_rxd_txd_desc_id,
8087 : : NULL,
8088 : : },
8089 : : };
8090 : :
8091 : : /* *** QUIT *** */
8092 : : struct cmd_quit_result {
8093 : : cmdline_fixed_string_t quit;
8094 : : };
8095 : :
8096 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
8097 : : struct cmdline *cl,
8098 : : __rte_unused void *data)
8099 : : {
8100 : 0 : cmdline_quit(cl);
8101 : 0 : cl_quit = 1;
8102 : 0 : }
8103 : :
8104 : : static cmdline_parse_token_string_t cmd_quit_quit =
8105 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8106 : :
8107 : : static cmdline_parse_inst_t cmd_quit = {
8108 : : .f = cmd_quit_parsed,
8109 : : .data = NULL,
8110 : : .help_str = "quit: Exit application",
8111 : : .tokens = {
8112 : : (void *)&cmd_quit_quit,
8113 : : NULL,
8114 : : },
8115 : : };
8116 : :
8117 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8118 : : struct cmd_mac_addr_result {
8119 : : cmdline_fixed_string_t mac_addr_cmd;
8120 : : cmdline_fixed_string_t what;
8121 : : uint16_t port_num;
8122 : : struct rte_ether_addr address;
8123 : : };
8124 : :
8125 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
8126 : : __rte_unused struct cmdline *cl,
8127 : : __rte_unused void *data)
8128 : : {
8129 : : struct cmd_mac_addr_result *res = parsed_result;
8130 : : int ret;
8131 : :
8132 : 0 : if (strcmp(res->what, "add") == 0)
8133 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8134 : 0 : else if (strcmp(res->what, "set") == 0)
8135 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8136 : : &res->address);
8137 : : else
8138 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8139 : :
8140 : : /* check the return value and print it if is < 0 */
8141 : 0 : if(ret < 0)
8142 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8143 : :
8144 : 0 : }
8145 : :
8146 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
8147 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8148 : : "mac_addr");
8149 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
8150 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8151 : : "add#remove#set");
8152 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
8153 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8154 : : RTE_UINT16);
8155 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8156 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8157 : :
8158 : : static cmdline_parse_inst_t cmd_mac_addr = {
8159 : : .f = cmd_mac_addr_parsed,
8160 : : .data = (void *)0,
8161 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8162 : : "Add/Remove/Set MAC address on port_id",
8163 : : .tokens = {
8164 : : (void *)&cmd_mac_addr_cmd,
8165 : : (void *)&cmd_mac_addr_what,
8166 : : (void *)&cmd_mac_addr_portnum,
8167 : : (void *)&cmd_mac_addr_addr,
8168 : : NULL,
8169 : : },
8170 : : };
8171 : :
8172 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8173 : : struct cmd_eth_peer_result {
8174 : : cmdline_fixed_string_t set;
8175 : : cmdline_fixed_string_t eth_peer;
8176 : : portid_t port_id;
8177 : : cmdline_fixed_string_t peer_addr;
8178 : : };
8179 : :
8180 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
8181 : : __rte_unused struct cmdline *cl,
8182 : : __rte_unused void *data)
8183 : : {
8184 : : struct cmd_eth_peer_result *res = parsed_result;
8185 : :
8186 : 0 : if (test_done == 0) {
8187 : 0 : fprintf(stderr, "Please stop forwarding first\n");
8188 : 0 : return;
8189 : : }
8190 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
8191 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
8192 : 0 : fwd_config_setup();
8193 : : }
8194 : : }
8195 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
8196 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8197 : : static cmdline_parse_token_string_t cmd_eth_peer =
8198 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8199 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
8200 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8201 : : RTE_UINT16);
8202 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
8203 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8204 : :
8205 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8206 : : .f = cmd_set_eth_peer_parsed,
8207 : : .data = NULL,
8208 : : .help_str = "set eth-peer <port_id> <peer_mac>",
8209 : : .tokens = {
8210 : : (void *)&cmd_eth_peer_set,
8211 : : (void *)&cmd_eth_peer,
8212 : : (void *)&cmd_eth_peer_port_id,
8213 : : (void *)&cmd_eth_peer_addr,
8214 : : NULL,
8215 : : },
8216 : : };
8217 : :
8218 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8219 : : struct cmd_set_xstats_hide_zero_result {
8220 : : cmdline_fixed_string_t keyword;
8221 : : cmdline_fixed_string_t name;
8222 : : cmdline_fixed_string_t on_off;
8223 : : };
8224 : :
8225 : : static void
8226 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8227 : : __rte_unused struct cmdline *cl,
8228 : : __rte_unused void *data)
8229 : : {
8230 : : struct cmd_set_xstats_hide_zero_result *res;
8231 : : uint16_t on_off = 0;
8232 : :
8233 : : res = parsed_result;
8234 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8235 : 0 : set_xstats_hide_zero(on_off);
8236 : 0 : }
8237 : :
8238 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8239 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8240 : : keyword, "set");
8241 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8242 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8243 : : name, "xstats-hide-zero");
8244 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8245 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8246 : : on_off, "on#off");
8247 : :
8248 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8249 : : .f = cmd_set_xstats_hide_zero_parsed,
8250 : : .data = NULL,
8251 : : .help_str = "set xstats-hide-zero on|off",
8252 : : .tokens = {
8253 : : (void *)&cmd_set_xstats_hide_zero_keyword,
8254 : : (void *)&cmd_set_xstats_hide_zero_name,
8255 : : (void *)&cmd_set_xstats_hide_zero_on_off,
8256 : : NULL,
8257 : : },
8258 : : };
8259 : :
8260 : : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
8261 : : struct cmd_set_xstats_show_state_result {
8262 : : cmdline_fixed_string_t keyword;
8263 : : cmdline_fixed_string_t name;
8264 : : uint8_t on_off;
8265 : : };
8266 : : static void
8267 : 0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
8268 : : __rte_unused struct cmdline *cl,
8269 : : __rte_unused void *data)
8270 : : {
8271 : : struct cmd_set_xstats_show_state_result *res = parsed_result;
8272 : 0 : set_xstats_show_state(res->on_off);
8273 : 0 : }
8274 : :
8275 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
8276 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8277 : : keyword, "set");
8278 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
8279 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8280 : : name, "xstats-show-state");
8281 : : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
8282 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
8283 : : on_off);
8284 : :
8285 : : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
8286 : : .f = cmd_set_xstats_show_state_parsed,
8287 : : .data = NULL,
8288 : : .help_str = "set xstats-show-state on|off",
8289 : : .tokens = {
8290 : : (void *)&cmd_set_xstats_show_state_keyword,
8291 : : (void *)&cmd_set_xstats_show_state_name,
8292 : : (void *)&cmd_set_xstats_show_state_on_off,
8293 : : NULL,
8294 : : },
8295 : : };
8296 : :
8297 : : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
8298 : : struct cmd_set_xstats_hide_disabled_result {
8299 : : cmdline_fixed_string_t keyword;
8300 : : cmdline_fixed_string_t name;
8301 : : uint8_t on_off;
8302 : : };
8303 : :
8304 : : static void
8305 : 0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
8306 : : __rte_unused struct cmdline *cl,
8307 : : __rte_unused void *data)
8308 : : {
8309 : : struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
8310 : 0 : set_xstats_hide_disabled(res->on_off);
8311 : 0 : }
8312 : :
8313 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
8314 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8315 : : keyword, "set");
8316 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
8317 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8318 : : name, "xstats-hide-disabled");
8319 : : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
8320 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8321 : : on_off);
8322 : :
8323 : : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
8324 : : .f = cmd_set_xstats_hide_disabled_parsed,
8325 : : .data = NULL,
8326 : : .help_str = "set xstats-hide-disabled on|off",
8327 : : .tokens = {
8328 : : (void *)&cmd_set_xstats_hide_disabled_keyword,
8329 : : (void *)&cmd_set_xstats_hide_disabled_name,
8330 : : (void *)&cmd_set_xstats_hide_disabled_on_off,
8331 : : NULL,
8332 : : },
8333 : : };
8334 : :
8335 : : /* *** enable/disable counter by name *** */
8336 : : struct cmd_operate_set_counter_result {
8337 : : cmdline_fixed_string_t port;
8338 : : portid_t port_id;
8339 : : cmdline_fixed_string_t what;
8340 : : cmdline_multi_string_t counter_name;
8341 : : };
8342 : :
8343 : : static void
8344 : 0 : cmd_operate_set_counter_parsed(void *parsed_result,
8345 : : __rte_unused struct cmdline *cl,
8346 : : __rte_unused void *data)
8347 : : {
8348 : : struct cmd_operate_set_counter_result *res = parsed_result;
8349 : 0 : uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
8350 : :
8351 : 0 : if ((strcmp(res->port, "port") == 0))
8352 : 0 : nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
8353 : 0 : }
8354 : :
8355 : : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
8356 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8357 : : port, "port");
8358 : : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
8359 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
8360 : : port_id, RTE_UINT16);
8361 : : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
8362 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8363 : : what, "enable#disable");
8364 : : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
8365 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8366 : : counter_name, TOKEN_STRING_MULTI);
8367 : :
8368 : : static cmdline_parse_inst_t cmd_operate_set_counter = {
8369 : : .f = cmd_operate_set_counter_parsed,
8370 : : .data = NULL,
8371 : : .help_str = "port (port_id) enable|disable <counter_name>",
8372 : : .tokens = {
8373 : : (void *)&cmd_operate_set_counter_port,
8374 : : (void *)&cmd_operate_set_counter_port_id,
8375 : : (void *)&cmd_operate_set_counter_what,
8376 : : (void *)&cmd_operate_set_counter_name,
8377 : : NULL,
8378 : : },
8379 : : };
8380 : :
8381 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8382 : : struct cmd_set_record_core_cycles_result {
8383 : : cmdline_fixed_string_t keyword;
8384 : : cmdline_fixed_string_t name;
8385 : : cmdline_fixed_string_t on_off;
8386 : : };
8387 : :
8388 : : static void
8389 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
8390 : : __rte_unused struct cmdline *cl,
8391 : : __rte_unused void *data)
8392 : : {
8393 : : struct cmd_set_record_core_cycles_result *res;
8394 : : uint16_t on_off = 0;
8395 : :
8396 : : res = parsed_result;
8397 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8398 : 0 : set_record_core_cycles(on_off);
8399 : 0 : }
8400 : :
8401 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8402 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8403 : : keyword, "set");
8404 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8405 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8406 : : name, "record-core-cycles");
8407 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8408 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8409 : : on_off, "on#off");
8410 : :
8411 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
8412 : : .f = cmd_set_record_core_cycles_parsed,
8413 : : .data = NULL,
8414 : : .help_str = "set record-core-cycles on|off",
8415 : : .tokens = {
8416 : : (void *)&cmd_set_record_core_cycles_keyword,
8417 : : (void *)&cmd_set_record_core_cycles_name,
8418 : : (void *)&cmd_set_record_core_cycles_on_off,
8419 : : NULL,
8420 : : },
8421 : : };
8422 : :
8423 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8424 : : struct cmd_set_record_burst_stats_result {
8425 : : cmdline_fixed_string_t keyword;
8426 : : cmdline_fixed_string_t name;
8427 : : cmdline_fixed_string_t on_off;
8428 : : };
8429 : :
8430 : : static void
8431 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
8432 : : __rte_unused struct cmdline *cl,
8433 : : __rte_unused void *data)
8434 : : {
8435 : : struct cmd_set_record_burst_stats_result *res;
8436 : : uint16_t on_off = 0;
8437 : :
8438 : : res = parsed_result;
8439 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8440 : 0 : set_record_burst_stats(on_off);
8441 : 0 : }
8442 : :
8443 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8444 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8445 : : keyword, "set");
8446 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8447 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8448 : : name, "record-burst-stats");
8449 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8450 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8451 : : on_off, "on#off");
8452 : :
8453 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
8454 : : .f = cmd_set_record_burst_stats_parsed,
8455 : : .data = NULL,
8456 : : .help_str = "set record-burst-stats on|off",
8457 : : .tokens = {
8458 : : (void *)&cmd_set_record_burst_stats_keyword,
8459 : : (void *)&cmd_set_record_burst_stats_name,
8460 : : (void *)&cmd_set_record_burst_stats_on_off,
8461 : : NULL,
8462 : : },
8463 : : };
8464 : :
8465 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
8466 : : struct cmd_set_uc_hash_table {
8467 : : cmdline_fixed_string_t set;
8468 : : cmdline_fixed_string_t port;
8469 : : portid_t port_id;
8470 : : cmdline_fixed_string_t what;
8471 : : struct rte_ether_addr address;
8472 : : cmdline_fixed_string_t mode;
8473 : : };
8474 : :
8475 : : static void
8476 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
8477 : : __rte_unused struct cmdline *cl,
8478 : : __rte_unused void *data)
8479 : : {
8480 : : int ret=0;
8481 : : struct cmd_set_uc_hash_table *res = parsed_result;
8482 : :
8483 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8484 : :
8485 : 0 : if (strcmp(res->what, "uta") == 0)
8486 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8487 : : &res->address,(uint8_t)is_on);
8488 : 0 : if (ret < 0)
8489 : 0 : fprintf(stderr,
8490 : : "bad unicast hash table parameter, return code = %d\n",
8491 : : ret);
8492 : :
8493 : 0 : }
8494 : :
8495 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
8496 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8497 : : set, "set");
8498 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
8499 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8500 : : port, "port");
8501 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8502 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8503 : : port_id, RTE_UINT16);
8504 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
8505 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8506 : : what, "uta");
8507 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8508 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8509 : : address);
8510 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8511 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8512 : : mode, "on#off");
8513 : :
8514 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8515 : : .f = cmd_set_uc_hash_parsed,
8516 : : .data = NULL,
8517 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
8518 : : .tokens = {
8519 : : (void *)&cmd_set_uc_hash_set,
8520 : : (void *)&cmd_set_uc_hash_port,
8521 : : (void *)&cmd_set_uc_hash_portid,
8522 : : (void *)&cmd_set_uc_hash_what,
8523 : : (void *)&cmd_set_uc_hash_mac,
8524 : : (void *)&cmd_set_uc_hash_mode,
8525 : : NULL,
8526 : : },
8527 : : };
8528 : :
8529 : : struct cmd_set_uc_all_hash_table {
8530 : : cmdline_fixed_string_t set;
8531 : : cmdline_fixed_string_t port;
8532 : : portid_t port_id;
8533 : : cmdline_fixed_string_t what;
8534 : : cmdline_fixed_string_t value;
8535 : : cmdline_fixed_string_t mode;
8536 : : };
8537 : :
8538 : : static void
8539 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
8540 : : __rte_unused struct cmdline *cl,
8541 : : __rte_unused void *data)
8542 : : {
8543 : : int ret=0;
8544 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
8545 : :
8546 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8547 : :
8548 : 0 : if ((strcmp(res->what, "uta") == 0) &&
8549 : 0 : (strcmp(res->value, "all") == 0))
8550 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8551 : 0 : if (ret < 0)
8552 : 0 : fprintf(stderr,
8553 : : "bad unicast hash table parameter, return code = %d\n",
8554 : : ret);
8555 : 0 : }
8556 : :
8557 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8558 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8559 : : set, "set");
8560 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8561 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8562 : : port, "port");
8563 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8564 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8565 : : port_id, RTE_UINT16);
8566 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8567 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8568 : : what, "uta");
8569 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8570 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8571 : : value,"all");
8572 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8573 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8574 : : mode, "on#off");
8575 : :
8576 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8577 : : .f = cmd_set_uc_all_hash_parsed,
8578 : : .data = NULL,
8579 : : .help_str = "set port <port_id> uta all on|off",
8580 : : .tokens = {
8581 : : (void *)&cmd_set_uc_all_hash_set,
8582 : : (void *)&cmd_set_uc_all_hash_port,
8583 : : (void *)&cmd_set_uc_all_hash_portid,
8584 : : (void *)&cmd_set_uc_all_hash_what,
8585 : : (void *)&cmd_set_uc_all_hash_value,
8586 : : (void *)&cmd_set_uc_all_hash_mode,
8587 : : NULL,
8588 : : },
8589 : : };
8590 : :
8591 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8592 : : struct cmd_set_vf_traffic {
8593 : : cmdline_fixed_string_t set;
8594 : : cmdline_fixed_string_t port;
8595 : : portid_t port_id;
8596 : : cmdline_fixed_string_t vf;
8597 : : uint8_t vf_id;
8598 : : cmdline_fixed_string_t what;
8599 : : cmdline_fixed_string_t mode;
8600 : : };
8601 : :
8602 : : static void
8603 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
8604 : : __rte_unused struct cmdline *cl,
8605 : : __rte_unused void *data)
8606 : : {
8607 : : struct cmd_set_vf_traffic *res = parsed_result;
8608 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8609 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8610 : :
8611 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8612 : 0 : }
8613 : :
8614 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
8615 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8616 : : set, "set");
8617 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
8618 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8619 : : port, "port");
8620 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8621 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8622 : : port_id, RTE_UINT16);
8623 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8624 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8625 : : vf, "vf");
8626 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8627 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8628 : : vf_id, RTE_UINT8);
8629 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
8630 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8631 : : what, "tx#rx");
8632 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8633 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8634 : : mode, "on#off");
8635 : :
8636 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
8637 : : .f = cmd_set_vf_traffic_parsed,
8638 : : .data = NULL,
8639 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8640 : : .tokens = {
8641 : : (void *)&cmd_setvf_traffic_set,
8642 : : (void *)&cmd_setvf_traffic_port,
8643 : : (void *)&cmd_setvf_traffic_portid,
8644 : : (void *)&cmd_setvf_traffic_vf,
8645 : : (void *)&cmd_setvf_traffic_vfid,
8646 : : (void *)&cmd_setvf_traffic_what,
8647 : : (void *)&cmd_setvf_traffic_mode,
8648 : : NULL,
8649 : : },
8650 : : };
8651 : :
8652 : : /* *** CONFIGURE VF RECEIVE MODE *** */
8653 : : struct cmd_set_vf_rxmode {
8654 : : cmdline_fixed_string_t set;
8655 : : cmdline_fixed_string_t port;
8656 : : portid_t port_id;
8657 : : cmdline_fixed_string_t vf;
8658 : : uint8_t vf_id;
8659 : : cmdline_fixed_string_t what;
8660 : : cmdline_fixed_string_t mode;
8661 : : cmdline_fixed_string_t on;
8662 : : };
8663 : :
8664 : : static void
8665 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
8666 : : __rte_unused struct cmdline *cl,
8667 : : __rte_unused void *data)
8668 : : {
8669 : : int ret = -ENOTSUP;
8670 : : uint16_t vf_rxmode = 0;
8671 : : struct cmd_set_vf_rxmode *res = parsed_result;
8672 : :
8673 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8674 : 0 : if (!strcmp(res->what,"rxmode")) {
8675 : 0 : if (!strcmp(res->mode, "AUPE"))
8676 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
8677 : 0 : else if (!strcmp(res->mode, "ROPE"))
8678 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
8679 : 0 : else if (!strcmp(res->mode, "BAM"))
8680 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
8681 : 0 : else if (!strncmp(res->mode, "MPE",3))
8682 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
8683 : : }
8684 : :
8685 : : RTE_SET_USED(is_on);
8686 : : RTE_SET_USED(vf_rxmode);
8687 : :
8688 : : #ifdef RTE_NET_IXGBE
8689 : : if (ret == -ENOTSUP)
8690 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8691 : : vf_rxmode, (uint8_t)is_on);
8692 : : #endif
8693 : : #ifdef RTE_NET_BNXT
8694 : 0 : if (ret == -ENOTSUP)
8695 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8696 : : vf_rxmode, (uint8_t)is_on);
8697 : : #endif
8698 : 0 : if (ret < 0)
8699 : 0 : fprintf(stderr,
8700 : : "bad VF receive mode parameter, return code = %d\n",
8701 : : ret);
8702 : 0 : }
8703 : :
8704 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8705 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8706 : : set, "set");
8707 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8708 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8709 : : port, "port");
8710 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8711 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8712 : : port_id, RTE_UINT16);
8713 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8714 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8715 : : vf, "vf");
8716 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8717 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8718 : : vf_id, RTE_UINT8);
8719 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8720 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8721 : : what, "rxmode");
8722 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8723 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8724 : : mode, "AUPE#ROPE#BAM#MPE");
8725 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8726 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8727 : : on, "on#off");
8728 : :
8729 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
8730 : : .f = cmd_set_vf_rxmode_parsed,
8731 : : .data = NULL,
8732 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
8733 : : "AUPE|ROPE|BAM|MPE on|off",
8734 : : .tokens = {
8735 : : (void *)&cmd_set_vf_rxmode_set,
8736 : : (void *)&cmd_set_vf_rxmode_port,
8737 : : (void *)&cmd_set_vf_rxmode_portid,
8738 : : (void *)&cmd_set_vf_rxmode_vf,
8739 : : (void *)&cmd_set_vf_rxmode_vfid,
8740 : : (void *)&cmd_set_vf_rxmode_what,
8741 : : (void *)&cmd_set_vf_rxmode_mode,
8742 : : (void *)&cmd_set_vf_rxmode_on,
8743 : : NULL,
8744 : : },
8745 : : };
8746 : :
8747 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8748 : : struct cmd_vf_mac_addr_result {
8749 : : cmdline_fixed_string_t mac_addr_cmd;
8750 : : cmdline_fixed_string_t what;
8751 : : cmdline_fixed_string_t port;
8752 : : uint16_t port_num;
8753 : : cmdline_fixed_string_t vf;
8754 : : uint8_t vf_num;
8755 : : struct rte_ether_addr address;
8756 : : };
8757 : :
8758 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
8759 : : __rte_unused struct cmdline *cl,
8760 : : __rte_unused void *data)
8761 : : {
8762 : : struct cmd_vf_mac_addr_result *res = parsed_result;
8763 : : int ret = -ENOTSUP;
8764 : :
8765 : 0 : if (strcmp(res->what, "add") != 0)
8766 : : return;
8767 : :
8768 : : #ifdef RTE_NET_I40E
8769 : : if (ret == -ENOTSUP)
8770 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8771 : : &res->address);
8772 : : #endif
8773 : : #ifdef RTE_NET_BNXT
8774 : 0 : if (ret == -ENOTSUP)
8775 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8776 : 0 : res->vf_num);
8777 : : #endif
8778 : :
8779 : 0 : if(ret < 0)
8780 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8781 : :
8782 : : }
8783 : :
8784 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8785 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8786 : : mac_addr_cmd,"mac_addr");
8787 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8788 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8789 : : what,"add");
8790 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8791 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8792 : : port,"port");
8793 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8794 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8795 : : port_num, RTE_UINT16);
8796 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8797 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8798 : : vf,"vf");
8799 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8800 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8801 : : vf_num, RTE_UINT8);
8802 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8803 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8804 : : address);
8805 : :
8806 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8807 : : .f = cmd_vf_mac_addr_parsed,
8808 : : .data = (void *)0,
8809 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8810 : : "Add MAC address filtering for a VF on port_id",
8811 : : .tokens = {
8812 : : (void *)&cmd_vf_mac_addr_cmd,
8813 : : (void *)&cmd_vf_mac_addr_what,
8814 : : (void *)&cmd_vf_mac_addr_port,
8815 : : (void *)&cmd_vf_mac_addr_portnum,
8816 : : (void *)&cmd_vf_mac_addr_vf,
8817 : : (void *)&cmd_vf_mac_addr_vfnum,
8818 : : (void *)&cmd_vf_mac_addr_addr,
8819 : : NULL,
8820 : : },
8821 : : };
8822 : :
8823 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8824 : : struct cmd_vf_rx_vlan_filter {
8825 : : cmdline_fixed_string_t rx_vlan;
8826 : : cmdline_fixed_string_t what;
8827 : : uint16_t vlan_id;
8828 : : cmdline_fixed_string_t port;
8829 : : portid_t port_id;
8830 : : cmdline_fixed_string_t vf;
8831 : : uint64_t vf_mask;
8832 : : };
8833 : :
8834 : : static void
8835 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8836 : : __rte_unused struct cmdline *cl,
8837 : : __rte_unused void *data)
8838 : : {
8839 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8840 : : int ret = -ENOTSUP;
8841 : :
8842 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8843 : :
8844 : : #ifdef RTE_NET_IXGBE
8845 : : if (ret == -ENOTSUP)
8846 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8847 : 0 : res->vlan_id, res->vf_mask, is_add);
8848 : : #endif
8849 : : #ifdef RTE_NET_I40E
8850 : 0 : if (ret == -ENOTSUP)
8851 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8852 : 0 : res->vlan_id, res->vf_mask, is_add);
8853 : : #endif
8854 : : #ifdef RTE_NET_BNXT
8855 : 0 : if (ret == -ENOTSUP)
8856 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8857 : 0 : res->vlan_id, res->vf_mask, is_add);
8858 : : #endif
8859 : :
8860 : 0 : switch (ret) {
8861 : : case 0:
8862 : : break;
8863 : 0 : case -EINVAL:
8864 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8865 : 0 : res->vlan_id, res->vf_mask);
8866 : : break;
8867 : 0 : case -ENODEV:
8868 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8869 : : break;
8870 : 0 : case -ENOTSUP:
8871 : 0 : fprintf(stderr, "function not implemented or supported\n");
8872 : : break;
8873 : 0 : default:
8874 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8875 : : }
8876 : 0 : }
8877 : :
8878 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8879 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8880 : : rx_vlan, "rx_vlan");
8881 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8882 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8883 : : what, "add#rm");
8884 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8885 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8886 : : vlan_id, RTE_UINT16);
8887 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8888 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8889 : : port, "port");
8890 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8891 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8892 : : port_id, RTE_UINT16);
8893 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8894 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8895 : : vf, "vf");
8896 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8897 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8898 : : vf_mask, RTE_UINT64);
8899 : :
8900 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8901 : : .f = cmd_vf_rx_vlan_filter_parsed,
8902 : : .data = NULL,
8903 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8904 : : "(vf_mask = hexadecimal VF mask)",
8905 : : .tokens = {
8906 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8907 : : (void *)&cmd_vf_rx_vlan_filter_what,
8908 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8909 : : (void *)&cmd_vf_rx_vlan_filter_port,
8910 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8911 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8912 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8913 : : NULL,
8914 : : },
8915 : : };
8916 : :
8917 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8918 : : struct cmd_queue_rate_limit_result {
8919 : : cmdline_fixed_string_t set;
8920 : : cmdline_fixed_string_t port;
8921 : : uint16_t port_num;
8922 : : cmdline_fixed_string_t queue;
8923 : : uint8_t queue_num;
8924 : : cmdline_fixed_string_t rate;
8925 : : uint32_t rate_num;
8926 : : };
8927 : :
8928 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8929 : : __rte_unused struct cmdline *cl,
8930 : : __rte_unused void *data)
8931 : : {
8932 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8933 : : int ret = 0;
8934 : :
8935 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8936 : 0 : && (strcmp(res->queue, "queue") == 0)
8937 : 0 : && (strcmp(res->rate, "rate") == 0))
8938 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8939 : : res->rate_num);
8940 : 0 : if (ret < 0)
8941 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8942 : : strerror(-ret));
8943 : :
8944 : 0 : }
8945 : :
8946 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8947 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8948 : : set, "set");
8949 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8950 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8951 : : port, "port");
8952 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8953 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8954 : : port_num, RTE_UINT16);
8955 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8956 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8957 : : queue, "queue");
8958 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8959 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8960 : : queue_num, RTE_UINT8);
8961 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8962 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8963 : : rate, "rate");
8964 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8965 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8966 : : rate_num, RTE_UINT32);
8967 : :
8968 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8969 : : .f = cmd_queue_rate_limit_parsed,
8970 : : .data = (void *)0,
8971 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8972 : : "Set rate limit for a queue on port_id",
8973 : : .tokens = {
8974 : : (void *)&cmd_queue_rate_limit_set,
8975 : : (void *)&cmd_queue_rate_limit_port,
8976 : : (void *)&cmd_queue_rate_limit_portnum,
8977 : : (void *)&cmd_queue_rate_limit_queue,
8978 : : (void *)&cmd_queue_rate_limit_queuenum,
8979 : : (void *)&cmd_queue_rate_limit_rate,
8980 : : (void *)&cmd_queue_rate_limit_ratenum,
8981 : : NULL,
8982 : : },
8983 : : };
8984 : :
8985 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8986 : : struct cmd_vf_rate_limit_result {
8987 : : cmdline_fixed_string_t set;
8988 : : cmdline_fixed_string_t port;
8989 : : uint16_t port_num;
8990 : : cmdline_fixed_string_t vf;
8991 : : uint8_t vf_num;
8992 : : cmdline_fixed_string_t rate;
8993 : : uint32_t rate_num;
8994 : : cmdline_fixed_string_t q_msk;
8995 : : uint64_t q_msk_val;
8996 : : };
8997 : :
8998 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
8999 : : __rte_unused struct cmdline *cl,
9000 : : __rte_unused void *data)
9001 : : {
9002 : : struct cmd_vf_rate_limit_result *res = parsed_result;
9003 : : int ret = 0;
9004 : :
9005 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9006 : 0 : && (strcmp(res->vf, "vf") == 0)
9007 : 0 : && (strcmp(res->rate, "rate") == 0)
9008 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
9009 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
9010 : : res->rate_num, res->q_msk_val);
9011 : 0 : if (ret < 0)
9012 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9013 : : strerror(-ret));
9014 : :
9015 : 0 : }
9016 : :
9017 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9018 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9019 : : set, "set");
9020 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9021 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9022 : : port, "port");
9023 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9024 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9025 : : port_num, RTE_UINT16);
9026 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9027 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9028 : : vf, "vf");
9029 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9030 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9031 : : vf_num, RTE_UINT8);
9032 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9033 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9034 : : rate, "rate");
9035 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9036 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9037 : : rate_num, RTE_UINT32);
9038 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9039 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9040 : : q_msk, "queue_mask");
9041 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9042 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9043 : : q_msk_val, RTE_UINT64);
9044 : :
9045 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
9046 : : .f = cmd_vf_rate_limit_parsed,
9047 : : .data = (void *)0,
9048 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9049 : : "queue_mask <queue_mask_value>: "
9050 : : "Set rate limit for queues of VF on port_id",
9051 : : .tokens = {
9052 : : (void *)&cmd_vf_rate_limit_set,
9053 : : (void *)&cmd_vf_rate_limit_port,
9054 : : (void *)&cmd_vf_rate_limit_portnum,
9055 : : (void *)&cmd_vf_rate_limit_vf,
9056 : : (void *)&cmd_vf_rate_limit_vfnum,
9057 : : (void *)&cmd_vf_rate_limit_rate,
9058 : : (void *)&cmd_vf_rate_limit_ratenum,
9059 : : (void *)&cmd_vf_rate_limit_q_msk,
9060 : : (void *)&cmd_vf_rate_limit_q_msk_val,
9061 : : NULL,
9062 : : },
9063 : : };
9064 : :
9065 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
9066 : : struct cmd_tunnel_udp_config {
9067 : : cmdline_fixed_string_t rx_vxlan_port;
9068 : : cmdline_fixed_string_t what;
9069 : : uint16_t udp_port;
9070 : : portid_t port_id;
9071 : : };
9072 : :
9073 : : static void
9074 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
9075 : : __rte_unused struct cmdline *cl,
9076 : : __rte_unused void *data)
9077 : : {
9078 : : struct cmd_tunnel_udp_config *res = parsed_result;
9079 : : struct rte_eth_udp_tunnel tunnel_udp;
9080 : : int ret;
9081 : :
9082 : 0 : tunnel_udp.udp_port = res->udp_port;
9083 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9084 : :
9085 : 0 : if (!strcmp(res->what, "add"))
9086 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9087 : : &tunnel_udp);
9088 : : else
9089 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9090 : : &tunnel_udp);
9091 : :
9092 : 0 : if (ret < 0)
9093 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
9094 : : strerror(-ret));
9095 : 0 : }
9096 : :
9097 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9098 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9099 : : rx_vxlan_port, "rx_vxlan_port");
9100 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9101 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9102 : : what, "add#rm");
9103 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9104 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9105 : : udp_port, RTE_UINT16);
9106 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9107 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9108 : : port_id, RTE_UINT16);
9109 : :
9110 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
9111 : : .f = cmd_tunnel_udp_config_parsed,
9112 : : .data = (void *)0,
9113 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9114 : : "Add/Remove a tunneling UDP port filter",
9115 : : .tokens = {
9116 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9117 : : (void *)&cmd_tunnel_udp_config_what,
9118 : : (void *)&cmd_tunnel_udp_config_udp_port,
9119 : : (void *)&cmd_tunnel_udp_config_port_id,
9120 : : NULL,
9121 : : },
9122 : : };
9123 : :
9124 : : struct cmd_config_tunnel_udp_port {
9125 : : cmdline_fixed_string_t port;
9126 : : cmdline_fixed_string_t config;
9127 : : portid_t port_id;
9128 : : cmdline_fixed_string_t udp_tunnel_port;
9129 : : cmdline_fixed_string_t action;
9130 : : cmdline_fixed_string_t tunnel_type;
9131 : : uint16_t udp_port;
9132 : : };
9133 : :
9134 : : static void
9135 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9136 : : __rte_unused struct cmdline *cl,
9137 : : __rte_unused void *data)
9138 : : {
9139 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
9140 : : struct rte_eth_udp_tunnel tunnel_udp;
9141 : : int ret = 0;
9142 : :
9143 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9144 : 0 : return;
9145 : :
9146 : 0 : tunnel_udp.udp_port = res->udp_port;
9147 : :
9148 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
9149 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9150 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
9151 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9152 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9153 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9154 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
9155 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9156 : : } else {
9157 : 0 : fprintf(stderr, "Invalid tunnel type\n");
9158 : 0 : return;
9159 : : }
9160 : :
9161 : 0 : if (!strcmp(res->action, "add"))
9162 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9163 : : &tunnel_udp);
9164 : : else
9165 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9166 : : &tunnel_udp);
9167 : :
9168 : 0 : if (ret < 0)
9169 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
9170 : : strerror(-ret));
9171 : : }
9172 : :
9173 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9174 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9175 : : "port");
9176 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9177 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9178 : : "config");
9179 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9180 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9181 : : RTE_UINT16);
9182 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9183 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9184 : : udp_tunnel_port,
9185 : : "udp_tunnel_port");
9186 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9187 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9188 : : "add#rm");
9189 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9190 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9191 : : "vxlan#geneve#vxlan-gpe#ecpri");
9192 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9193 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9194 : : RTE_UINT16);
9195 : :
9196 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9197 : : .f = cmd_cfg_tunnel_udp_port_parsed,
9198 : : .data = NULL,
9199 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9200 : : "geneve|vxlan-gpe|ecpri <udp_port>",
9201 : : .tokens = {
9202 : : (void *)&cmd_config_tunnel_udp_port_port,
9203 : : (void *)&cmd_config_tunnel_udp_port_config,
9204 : : (void *)&cmd_config_tunnel_udp_port_port_id,
9205 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9206 : : (void *)&cmd_config_tunnel_udp_port_action,
9207 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9208 : : (void *)&cmd_config_tunnel_udp_port_value,
9209 : : NULL,
9210 : : },
9211 : : };
9212 : :
9213 : : /* ******************************************************************************** */
9214 : :
9215 : : struct cmd_dump_simple_result {
9216 : : cmdline_fixed_string_t dump;
9217 : : cmdline_fixed_string_t obj;
9218 : : cmdline_fixed_string_t name;
9219 : : };
9220 : : static cmdline_parse_token_string_t cmd_dump_simple_dump =
9221 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, dump, "dump");
9222 : : static cmdline_parse_token_string_t cmd_dump_simple_obj =
9223 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9224 : : "physmem#"
9225 : : "socket_mem#"
9226 : : "memzone#"
9227 : : "struct_sizes#"
9228 : : "ring#"
9229 : : "mempool#"
9230 : : "devargs#"
9231 : : "lcores#"
9232 : : "trace#"
9233 : : "log_types"
9234 : : );
9235 : : static cmdline_parse_token_string_t cmd_dump_named_obj =
9236 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9237 : : "ring#"
9238 : : "mempool#"
9239 : : );
9240 : : static cmdline_parse_token_string_t cmd_dump_named_name =
9241 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, name, NULL);
9242 : :
9243 : : static void
9244 : 0 : dump_struct_sizes(void)
9245 : : {
9246 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9247 : : DUMP_SIZE(struct rte_mbuf);
9248 : : DUMP_SIZE(struct rte_mempool);
9249 : : DUMP_SIZE(struct rte_ring);
9250 : : #undef DUMP_SIZE
9251 : 0 : }
9252 : :
9253 : : /* Dump the socket memory statistics on console */
9254 : : static void
9255 : 0 : dump_socket_mem(FILE *f)
9256 : : {
9257 : : struct rte_malloc_socket_stats socket_stats;
9258 : : unsigned int i;
9259 : : size_t total = 0;
9260 : : size_t alloc = 0;
9261 : : size_t free = 0;
9262 : : unsigned int n_alloc = 0;
9263 : : unsigned int n_free = 0;
9264 : : static size_t last_allocs;
9265 : : static size_t last_total;
9266 : :
9267 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9268 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9269 : 0 : !socket_stats.heap_totalsz_bytes)
9270 : 0 : continue;
9271 : 0 : total += socket_stats.heap_totalsz_bytes;
9272 : 0 : alloc += socket_stats.heap_allocsz_bytes;
9273 : 0 : free += socket_stats.heap_freesz_bytes;
9274 : 0 : n_alloc += socket_stats.alloc_count;
9275 : 0 : n_free += socket_stats.free_count;
9276 : 0 : fprintf(f,
9277 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9278 : : i,
9279 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9280 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9281 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
9282 : 0 : (double)socket_stats.heap_totalsz_bytes,
9283 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9284 : : socket_stats.alloc_count,
9285 : : socket_stats.free_count);
9286 : : }
9287 : 0 : fprintf(f,
9288 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9289 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9290 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
9291 : 0 : (double)free / (1024 * 1024),
9292 : : n_alloc, n_free);
9293 : 0 : if (last_allocs)
9294 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9295 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
9296 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
9297 : 0 : last_allocs = alloc;
9298 : 0 : last_total = total;
9299 : 0 : }
9300 : :
9301 : 0 : static void cmd_dump_simple_parsed(void *parsed_result,
9302 : : struct cmdline *cl,
9303 : : __rte_unused void *data)
9304 : : {
9305 : : struct cmd_dump_simple_result *res = parsed_result;
9306 : :
9307 : 0 : if (strcmp(res->obj, "physmem") == 0)
9308 : 0 : rte_dump_physmem_layout(stdout);
9309 : 0 : else if (strcmp(res->obj, "socket_mem") == 0)
9310 : 0 : dump_socket_mem(stdout);
9311 : 0 : else if (strcmp(res->obj, "memzone") == 0)
9312 : 0 : rte_memzone_dump(stdout);
9313 : 0 : else if (strcmp(res->obj, "struct_sizes") == 0)
9314 : 0 : dump_struct_sizes();
9315 : 0 : else if (strcmp(res->obj, "ring") == 0) {
9316 : 0 : if (strcmp(res->name, "") == 0) {
9317 : 0 : rte_ring_list_dump(stdout);
9318 : : } else {
9319 : : struct rte_ring *r;
9320 : 0 : r = rte_ring_lookup(res->name);
9321 : 0 : if (r == NULL) {
9322 : 0 : cmdline_printf(cl, "Cannot find ring\n");
9323 : 0 : return;
9324 : : }
9325 : 0 : rte_ring_dump(stdout, r);
9326 : : }
9327 : 0 : } else if (strcmp(res->obj, "mempool") == 0) {
9328 : 0 : if (strcmp(res->name, "") == 0) {
9329 : 0 : rte_mempool_list_dump(stdout);
9330 : : } else {
9331 : : struct rte_mempool *mp;
9332 : 0 : mp = rte_mempool_lookup(res->name);
9333 : 0 : if (mp == NULL) {
9334 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
9335 : 0 : return;
9336 : : }
9337 : 0 : rte_mempool_dump(stdout, mp);
9338 : : }
9339 : 0 : } else if (strcmp(res->obj, "devargs") == 0)
9340 : 0 : rte_devargs_dump(stdout);
9341 : 0 : else if (strcmp(res->obj, "lcores") == 0)
9342 : 0 : rte_lcore_dump(stdout);
9343 : 0 : else if (strcmp(res->obj, "trace") == 0)
9344 : : #ifdef RTE_EXEC_ENV_WINDOWS
9345 : : cmdline_printf(cl, "trace is not supported on Windows\n");
9346 : : #else
9347 : 0 : rte_trace_save();
9348 : : #endif
9349 : 0 : else if (strcmp(res->obj, "log_types") == 0)
9350 : 0 : rte_log_dump(stdout);
9351 : : }
9352 : :
9353 : : static cmdline_parse_inst_t cmd_dump_simple = {
9354 : : .f = cmd_dump_simple_parsed,
9355 : : .help_str = "Dump objects",
9356 : : .tokens = {
9357 : : (void *)&cmd_dump_simple_dump,
9358 : : (void *)&cmd_dump_simple_obj,
9359 : : NULL,
9360 : : },
9361 : : };
9362 : : static cmdline_parse_inst_t cmd_dump_named = {
9363 : : .f = cmd_dump_simple_parsed,
9364 : : .help_str = "dump ring|mempool <name>: Dump one ring/mempool",
9365 : : .tokens = {
9366 : : (void *)&cmd_dump_simple_dump,
9367 : : (void *)&cmd_dump_named_obj,
9368 : : (void *)&cmd_dump_named_name,
9369 : : NULL,
9370 : : },
9371 : : };
9372 : :
9373 : : struct cmd_dump_mbuf_history_result {
9374 : : cmdline_fixed_string_t dump;
9375 : : cmdline_fixed_string_t mbuf;
9376 : : cmdline_fixed_string_t history;
9377 : : cmdline_fixed_string_t obj;
9378 : : cmdline_fixed_string_t name;
9379 : : cmdline_fixed_string_t addr;
9380 : : cmdline_fixed_string_t file;
9381 : : };
9382 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_dump =
9383 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, dump, "dump");
9384 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_mbuf =
9385 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, mbuf, "mbuf");
9386 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_history =
9387 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, history, "history");
9388 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_obj =
9389 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, NULL);
9390 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_pool =
9391 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, "pool");
9392 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_name =
9393 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, name, NULL);
9394 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_file =
9395 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, file, NULL);
9396 : :
9397 : 0 : static void cmd_dump_mbuf_history_parsed(void *parsed_result,
9398 : : struct cmdline *cl,
9399 : : __rte_unused void *data)
9400 : : {
9401 : : struct cmd_dump_mbuf_history_result *res = parsed_result;
9402 : 0 : FILE *out = stdout;
9403 : :
9404 : 0 : if (strcmp(res->file, "") != 0) {
9405 : 0 : out = fopen(res->file, "w");
9406 : 0 : if (out == NULL) {
9407 : 0 : cmdline_printf(cl,
9408 : : "Failed to open file '%s'\n",
9409 : : res->file);
9410 : 0 : return;
9411 : : }
9412 : : }
9413 : :
9414 : 0 : if (strcmp(res->obj, "all") == 0) {
9415 : 0 : rte_mbuf_history_dump_all(out);
9416 : 0 : if (out != stdout)
9417 : 0 : cmdline_printf(cl,
9418 : : "Dump written in '%s'\n",
9419 : 0 : res->file);
9420 : 0 : } else if (strcmp(res->obj, "pool") == 0) {
9421 : 0 : struct rte_mempool *mp = rte_mempool_lookup(res->name);
9422 : 0 : if (mp == NULL) {
9423 : 0 : cmdline_printf(cl,
9424 : : "Failed to find mempool '%s'\n",
9425 : : res->name);
9426 : 0 : goto out_close;
9427 : : }
9428 : 0 : rte_mbuf_history_dump_mempool(out, mp);
9429 : 0 : if (out != stdout)
9430 : 0 : cmdline_printf(cl,
9431 : : "Dump for mempool '%s' written in '%s'\n",
9432 : 0 : res->name, res->file);
9433 : : } else {
9434 : : struct rte_mbuf *mbuf;
9435 : : uintptr_t mbuf_addr;
9436 : 0 : if (sscanf(res->obj, "0x%" SCNxPTR, &mbuf_addr) != 1) {
9437 : 0 : cmdline_printf(cl,
9438 : : "Invalid mbuf pointer format. Use 0x<address>\n");
9439 : 0 : goto out_close;
9440 : : }
9441 : 0 : mbuf = (struct rte_mbuf *)mbuf_addr;
9442 : 0 : rte_mbuf_history_dump(out, mbuf);
9443 : 0 : if (out != stdout)
9444 : 0 : cmdline_printf(cl,
9445 : : "Dump for mbuf '%p' written in '%s'\n",
9446 : 0 : mbuf, res->file);
9447 : : }
9448 : :
9449 : 0 : out_close:
9450 : 0 : if (out != stdout)
9451 : 0 : fclose(out);
9452 : : }
9453 : :
9454 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_stdout = {
9455 : : .f = cmd_dump_mbuf_history_parsed,
9456 : : .help_str = "dump mbuf history all|<address>",
9457 : : .tokens = {
9458 : : (void *)&cmd_dump_mbuf_history_dump,
9459 : : (void *)&cmd_dump_mbuf_history_mbuf,
9460 : : (void *)&cmd_dump_mbuf_history_history,
9461 : : (void *)&cmd_dump_mbuf_history_obj,
9462 : : NULL,
9463 : : },
9464 : : };
9465 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_to_file = {
9466 : : .f = cmd_dump_mbuf_history_parsed,
9467 : : .help_str = "dump mbuf history all|<address> [file]",
9468 : : .tokens = {
9469 : : (void *)&cmd_dump_mbuf_history_dump,
9470 : : (void *)&cmd_dump_mbuf_history_mbuf,
9471 : : (void *)&cmd_dump_mbuf_history_history,
9472 : : (void *)&cmd_dump_mbuf_history_obj,
9473 : : (void *)&cmd_dump_mbuf_history_file,
9474 : : NULL,
9475 : : },
9476 : : };
9477 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_stdout = {
9478 : : .f = cmd_dump_mbuf_history_parsed,
9479 : : .help_str = "dump mbuf pool history <name>",
9480 : : .tokens = {
9481 : : (void *)&cmd_dump_mbuf_history_dump,
9482 : : (void *)&cmd_dump_mbuf_history_mbuf,
9483 : : (void *)&cmd_dump_mbuf_history_pool,
9484 : : (void *)&cmd_dump_mbuf_history_history,
9485 : : (void *)&cmd_dump_mbuf_history_name,
9486 : : NULL,
9487 : : },
9488 : : };
9489 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_to_file = {
9490 : : .f = cmd_dump_mbuf_history_parsed,
9491 : : .help_str = "dump mbuf pool history <name> [file]",
9492 : : .tokens = {
9493 : : (void *)&cmd_dump_mbuf_history_dump,
9494 : : (void *)&cmd_dump_mbuf_history_mbuf,
9495 : : (void *)&cmd_dump_mbuf_history_pool,
9496 : : (void *)&cmd_dump_mbuf_history_history,
9497 : : (void *)&cmd_dump_mbuf_history_name,
9498 : : (void *)&cmd_dump_mbuf_history_file,
9499 : : NULL,
9500 : : },
9501 : : };
9502 : :
9503 : : /* *** Filters Control *** */
9504 : :
9505 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9506 : : do { \
9507 : : if ((ip_addr).family == AF_INET) \
9508 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
9509 : : else { \
9510 : : fprintf(stderr, "invalid parameter.\n"); \
9511 : : return; \
9512 : : } \
9513 : : } while (0)
9514 : :
9515 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9516 : : do { \
9517 : : if ((ip_addr).family == AF_INET6) \
9518 : : ip = ip_addr.addr.ipv6; \
9519 : : else { \
9520 : : fprintf(stderr, "invalid parameter.\n"); \
9521 : : return; \
9522 : : } \
9523 : : } while (0)
9524 : :
9525 : : /* Generic flow interface command. */
9526 : : extern cmdline_parse_inst_t cmd_flow;
9527 : :
9528 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9529 : : struct cmd_mcast_addr_result {
9530 : : cmdline_fixed_string_t mcast_addr_cmd;
9531 : : cmdline_fixed_string_t what;
9532 : : uint16_t port_num;
9533 : : struct rte_ether_addr mc_addr;
9534 : : };
9535 : :
9536 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
9537 : : __rte_unused struct cmdline *cl,
9538 : : __rte_unused void *data)
9539 : : {
9540 : : struct cmd_mcast_addr_result *res = parsed_result;
9541 : :
9542 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
9543 : 0 : fprintf(stderr,
9544 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
9545 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
9546 : 0 : return;
9547 : : }
9548 : 0 : if (strcmp(res->what, "add") == 0)
9549 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
9550 : : else
9551 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
9552 : : }
9553 : :
9554 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9555 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9556 : : mcast_addr_cmd, "mcast_addr");
9557 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
9558 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9559 : : "add#remove");
9560 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9561 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9562 : : RTE_UINT16);
9563 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9564 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9565 : :
9566 : : static cmdline_parse_inst_t cmd_mcast_addr = {
9567 : : .f = cmd_mcast_addr_parsed,
9568 : : .data = (void *)0,
9569 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
9570 : : "Add/Remove multicast MAC address on port_id",
9571 : : .tokens = {
9572 : : (void *)&cmd_mcast_addr_cmd,
9573 : : (void *)&cmd_mcast_addr_what,
9574 : : (void *)&cmd_mcast_addr_portnum,
9575 : : (void *)&cmd_mcast_addr_addr,
9576 : : NULL,
9577 : : },
9578 : : };
9579 : :
9580 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
9581 : : struct cmd_mcast_addr_flush_result {
9582 : : cmdline_fixed_string_t mcast_addr_cmd;
9583 : : cmdline_fixed_string_t what;
9584 : : uint16_t port_num;
9585 : : };
9586 : :
9587 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
9588 : : __rte_unused struct cmdline *cl,
9589 : : __rte_unused void *data)
9590 : : {
9591 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
9592 : :
9593 : 0 : mcast_addr_flush(res->port_num);
9594 : 0 : }
9595 : :
9596 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
9597 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9598 : : mcast_addr_cmd, "mcast_addr");
9599 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
9600 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9601 : : "flush");
9602 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
9603 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9604 : : RTE_UINT16);
9605 : :
9606 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
9607 : : .f = cmd_mcast_addr_flush_parsed,
9608 : : .data = (void *)0,
9609 : : .help_str = "mcast_addr flush <port_id> : "
9610 : : "flush all multicast MAC addresses on port_id",
9611 : : .tokens = {
9612 : : (void *)&cmd_mcast_addr_flush_cmd,
9613 : : (void *)&cmd_mcast_addr_flush_what,
9614 : : (void *)&cmd_mcast_addr_flush_portnum,
9615 : : NULL,
9616 : : },
9617 : : };
9618 : :
9619 : : /* vf vlan anti spoof configuration */
9620 : :
9621 : : /* Common result structure for vf vlan anti spoof */
9622 : : struct cmd_vf_vlan_anti_spoof_result {
9623 : : cmdline_fixed_string_t set;
9624 : : cmdline_fixed_string_t vf;
9625 : : cmdline_fixed_string_t vlan;
9626 : : cmdline_fixed_string_t antispoof;
9627 : : portid_t port_id;
9628 : : uint32_t vf_id;
9629 : : cmdline_fixed_string_t on_off;
9630 : : };
9631 : :
9632 : : /* Common CLI fields for vf vlan anti spoof enable disable */
9633 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
9634 : : TOKEN_STRING_INITIALIZER
9635 : : (struct cmd_vf_vlan_anti_spoof_result,
9636 : : set, "set");
9637 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
9638 : : TOKEN_STRING_INITIALIZER
9639 : : (struct cmd_vf_vlan_anti_spoof_result,
9640 : : vf, "vf");
9641 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
9642 : : TOKEN_STRING_INITIALIZER
9643 : : (struct cmd_vf_vlan_anti_spoof_result,
9644 : : vlan, "vlan");
9645 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
9646 : : TOKEN_STRING_INITIALIZER
9647 : : (struct cmd_vf_vlan_anti_spoof_result,
9648 : : antispoof, "antispoof");
9649 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
9650 : : TOKEN_NUM_INITIALIZER
9651 : : (struct cmd_vf_vlan_anti_spoof_result,
9652 : : port_id, RTE_UINT16);
9653 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
9654 : : TOKEN_NUM_INITIALIZER
9655 : : (struct cmd_vf_vlan_anti_spoof_result,
9656 : : vf_id, RTE_UINT32);
9657 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
9658 : : TOKEN_STRING_INITIALIZER
9659 : : (struct cmd_vf_vlan_anti_spoof_result,
9660 : : on_off, "on#off");
9661 : :
9662 : : static void
9663 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
9664 : : void *parsed_result,
9665 : : __rte_unused struct cmdline *cl,
9666 : : __rte_unused void *data)
9667 : : {
9668 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
9669 : : int ret = -ENOTSUP;
9670 : :
9671 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9672 : :
9673 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9674 : : return;
9675 : :
9676 : : #ifdef RTE_NET_IXGBE
9677 : : if (ret == -ENOTSUP)
9678 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
9679 : 0 : res->vf_id, is_on);
9680 : : #endif
9681 : : #ifdef RTE_NET_I40E
9682 : 0 : if (ret == -ENOTSUP)
9683 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
9684 : 0 : res->vf_id, is_on);
9685 : : #endif
9686 : : #ifdef RTE_NET_BNXT
9687 : 0 : if (ret == -ENOTSUP)
9688 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
9689 : 0 : res->vf_id, is_on);
9690 : : #endif
9691 : :
9692 : 0 : switch (ret) {
9693 : : case 0:
9694 : : break;
9695 : 0 : case -EINVAL:
9696 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
9697 : : break;
9698 : 0 : case -ENODEV:
9699 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9700 : : break;
9701 : 0 : case -ENOTSUP:
9702 : 0 : fprintf(stderr, "function not implemented\n");
9703 : : break;
9704 : 0 : default:
9705 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9706 : : }
9707 : : }
9708 : :
9709 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
9710 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
9711 : : .data = NULL,
9712 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
9713 : : .tokens = {
9714 : : (void *)&cmd_vf_vlan_anti_spoof_set,
9715 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
9716 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
9717 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
9718 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
9719 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
9720 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
9721 : : NULL,
9722 : : },
9723 : : };
9724 : :
9725 : : /* vf mac anti spoof configuration */
9726 : :
9727 : : /* Common result structure for vf mac anti spoof */
9728 : : struct cmd_vf_mac_anti_spoof_result {
9729 : : cmdline_fixed_string_t set;
9730 : : cmdline_fixed_string_t vf;
9731 : : cmdline_fixed_string_t mac;
9732 : : cmdline_fixed_string_t antispoof;
9733 : : portid_t port_id;
9734 : : uint32_t vf_id;
9735 : : cmdline_fixed_string_t on_off;
9736 : : };
9737 : :
9738 : : /* Common CLI fields for vf mac anti spoof enable disable */
9739 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
9740 : : TOKEN_STRING_INITIALIZER
9741 : : (struct cmd_vf_mac_anti_spoof_result,
9742 : : set, "set");
9743 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
9744 : : TOKEN_STRING_INITIALIZER
9745 : : (struct cmd_vf_mac_anti_spoof_result,
9746 : : vf, "vf");
9747 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
9748 : : TOKEN_STRING_INITIALIZER
9749 : : (struct cmd_vf_mac_anti_spoof_result,
9750 : : mac, "mac");
9751 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
9752 : : TOKEN_STRING_INITIALIZER
9753 : : (struct cmd_vf_mac_anti_spoof_result,
9754 : : antispoof, "antispoof");
9755 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
9756 : : TOKEN_NUM_INITIALIZER
9757 : : (struct cmd_vf_mac_anti_spoof_result,
9758 : : port_id, RTE_UINT16);
9759 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
9760 : : TOKEN_NUM_INITIALIZER
9761 : : (struct cmd_vf_mac_anti_spoof_result,
9762 : : vf_id, RTE_UINT32);
9763 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
9764 : : TOKEN_STRING_INITIALIZER
9765 : : (struct cmd_vf_mac_anti_spoof_result,
9766 : : on_off, "on#off");
9767 : :
9768 : : static void
9769 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
9770 : : void *parsed_result,
9771 : : __rte_unused struct cmdline *cl,
9772 : : __rte_unused void *data)
9773 : : {
9774 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
9775 : : int ret = -ENOTSUP;
9776 : :
9777 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9778 : :
9779 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9780 : : return;
9781 : :
9782 : : #ifdef RTE_NET_IXGBE
9783 : : if (ret == -ENOTSUP)
9784 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
9785 : 0 : res->vf_id, is_on);
9786 : : #endif
9787 : : #ifdef RTE_NET_I40E
9788 : 0 : if (ret == -ENOTSUP)
9789 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
9790 : 0 : res->vf_id, is_on);
9791 : : #endif
9792 : : #ifdef RTE_NET_BNXT
9793 : 0 : if (ret == -ENOTSUP)
9794 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
9795 : 0 : res->vf_id, is_on);
9796 : : #endif
9797 : :
9798 : 0 : switch (ret) {
9799 : : case 0:
9800 : : break;
9801 : 0 : case -EINVAL:
9802 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9803 : : res->vf_id, is_on);
9804 : : break;
9805 : 0 : case -ENODEV:
9806 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9807 : : break;
9808 : 0 : case -ENOTSUP:
9809 : 0 : fprintf(stderr, "function not implemented\n");
9810 : : break;
9811 : 0 : default:
9812 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9813 : : }
9814 : : }
9815 : :
9816 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
9817 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
9818 : : .data = NULL,
9819 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
9820 : : .tokens = {
9821 : : (void *)&cmd_vf_mac_anti_spoof_set,
9822 : : (void *)&cmd_vf_mac_anti_spoof_vf,
9823 : : (void *)&cmd_vf_mac_anti_spoof_mac,
9824 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
9825 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
9826 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
9827 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
9828 : : NULL,
9829 : : },
9830 : : };
9831 : :
9832 : : /* vf vlan strip queue configuration */
9833 : :
9834 : : /* Common result structure for vf mac anti spoof */
9835 : : struct cmd_vf_vlan_stripq_result {
9836 : : cmdline_fixed_string_t set;
9837 : : cmdline_fixed_string_t vf;
9838 : : cmdline_fixed_string_t vlan;
9839 : : cmdline_fixed_string_t stripq;
9840 : : portid_t port_id;
9841 : : uint16_t vf_id;
9842 : : cmdline_fixed_string_t on_off;
9843 : : };
9844 : :
9845 : : /* Common CLI fields for vf vlan strip enable disable */
9846 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
9847 : : TOKEN_STRING_INITIALIZER
9848 : : (struct cmd_vf_vlan_stripq_result,
9849 : : set, "set");
9850 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
9851 : : TOKEN_STRING_INITIALIZER
9852 : : (struct cmd_vf_vlan_stripq_result,
9853 : : vf, "vf");
9854 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
9855 : : TOKEN_STRING_INITIALIZER
9856 : : (struct cmd_vf_vlan_stripq_result,
9857 : : vlan, "vlan");
9858 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
9859 : : TOKEN_STRING_INITIALIZER
9860 : : (struct cmd_vf_vlan_stripq_result,
9861 : : stripq, "stripq");
9862 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
9863 : : TOKEN_NUM_INITIALIZER
9864 : : (struct cmd_vf_vlan_stripq_result,
9865 : : port_id, RTE_UINT16);
9866 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
9867 : : TOKEN_NUM_INITIALIZER
9868 : : (struct cmd_vf_vlan_stripq_result,
9869 : : vf_id, RTE_UINT16);
9870 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
9871 : : TOKEN_STRING_INITIALIZER
9872 : : (struct cmd_vf_vlan_stripq_result,
9873 : : on_off, "on#off");
9874 : :
9875 : : static void
9876 : 0 : cmd_set_vf_vlan_stripq_parsed(
9877 : : void *parsed_result,
9878 : : __rte_unused struct cmdline *cl,
9879 : : __rte_unused void *data)
9880 : : {
9881 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
9882 : : int ret = -ENOTSUP;
9883 : :
9884 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9885 : :
9886 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9887 : : return;
9888 : :
9889 : : #ifdef RTE_NET_IXGBE
9890 : : if (ret == -ENOTSUP)
9891 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
9892 : 0 : res->vf_id, is_on);
9893 : : #endif
9894 : : #ifdef RTE_NET_I40E
9895 : 0 : if (ret == -ENOTSUP)
9896 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
9897 : 0 : res->vf_id, is_on);
9898 : : #endif
9899 : : #ifdef RTE_NET_BNXT
9900 : 0 : if (ret == -ENOTSUP)
9901 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
9902 : 0 : res->vf_id, is_on);
9903 : : #endif
9904 : :
9905 : 0 : switch (ret) {
9906 : : case 0:
9907 : : break;
9908 : 0 : case -EINVAL:
9909 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9910 : 0 : res->vf_id, is_on);
9911 : : break;
9912 : 0 : case -ENODEV:
9913 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9914 : : break;
9915 : 0 : case -ENOTSUP:
9916 : 0 : fprintf(stderr, "function not implemented\n");
9917 : : break;
9918 : 0 : default:
9919 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9920 : : }
9921 : : }
9922 : :
9923 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
9924 : : .f = cmd_set_vf_vlan_stripq_parsed,
9925 : : .data = NULL,
9926 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
9927 : : .tokens = {
9928 : : (void *)&cmd_vf_vlan_stripq_set,
9929 : : (void *)&cmd_vf_vlan_stripq_vf,
9930 : : (void *)&cmd_vf_vlan_stripq_vlan,
9931 : : (void *)&cmd_vf_vlan_stripq_stripq,
9932 : : (void *)&cmd_vf_vlan_stripq_port_id,
9933 : : (void *)&cmd_vf_vlan_stripq_vf_id,
9934 : : (void *)&cmd_vf_vlan_stripq_on_off,
9935 : : NULL,
9936 : : },
9937 : : };
9938 : :
9939 : : /* vf vlan insert configuration */
9940 : :
9941 : : /* Common result structure for vf vlan insert */
9942 : : struct cmd_vf_vlan_insert_result {
9943 : : cmdline_fixed_string_t set;
9944 : : cmdline_fixed_string_t vf;
9945 : : cmdline_fixed_string_t vlan;
9946 : : cmdline_fixed_string_t insert;
9947 : : portid_t port_id;
9948 : : uint16_t vf_id;
9949 : : uint16_t vlan_id;
9950 : : };
9951 : :
9952 : : /* Common CLI fields for vf vlan insert enable disable */
9953 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
9954 : : TOKEN_STRING_INITIALIZER
9955 : : (struct cmd_vf_vlan_insert_result,
9956 : : set, "set");
9957 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
9958 : : TOKEN_STRING_INITIALIZER
9959 : : (struct cmd_vf_vlan_insert_result,
9960 : : vf, "vf");
9961 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
9962 : : TOKEN_STRING_INITIALIZER
9963 : : (struct cmd_vf_vlan_insert_result,
9964 : : vlan, "vlan");
9965 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
9966 : : TOKEN_STRING_INITIALIZER
9967 : : (struct cmd_vf_vlan_insert_result,
9968 : : insert, "insert");
9969 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
9970 : : TOKEN_NUM_INITIALIZER
9971 : : (struct cmd_vf_vlan_insert_result,
9972 : : port_id, RTE_UINT16);
9973 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
9974 : : TOKEN_NUM_INITIALIZER
9975 : : (struct cmd_vf_vlan_insert_result,
9976 : : vf_id, RTE_UINT16);
9977 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
9978 : : TOKEN_NUM_INITIALIZER
9979 : : (struct cmd_vf_vlan_insert_result,
9980 : : vlan_id, RTE_UINT16);
9981 : :
9982 : : static void
9983 : 0 : cmd_set_vf_vlan_insert_parsed(
9984 : : void *parsed_result,
9985 : : __rte_unused struct cmdline *cl,
9986 : : __rte_unused void *data)
9987 : : {
9988 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
9989 : : int ret = -ENOTSUP;
9990 : :
9991 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9992 : : return;
9993 : :
9994 : : #ifdef RTE_NET_IXGBE
9995 : : if (ret == -ENOTSUP)
9996 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
9997 : 0 : res->vlan_id);
9998 : : #endif
9999 : : #ifdef RTE_NET_I40E
10000 : 0 : if (ret == -ENOTSUP)
10001 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
10002 : 0 : res->vlan_id);
10003 : : #endif
10004 : : #ifdef RTE_NET_BNXT
10005 : 0 : if (ret == -ENOTSUP)
10006 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
10007 : 0 : res->vlan_id);
10008 : : #endif
10009 : :
10010 : 0 : switch (ret) {
10011 : : case 0:
10012 : : break;
10013 : 0 : case -EINVAL:
10014 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
10015 : 0 : res->vf_id, res->vlan_id);
10016 : : break;
10017 : 0 : case -ENODEV:
10018 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10019 : : break;
10020 : 0 : case -ENOTSUP:
10021 : 0 : fprintf(stderr, "function not implemented\n");
10022 : : break;
10023 : 0 : default:
10024 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10025 : : }
10026 : : }
10027 : :
10028 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
10029 : : .f = cmd_set_vf_vlan_insert_parsed,
10030 : : .data = NULL,
10031 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
10032 : : .tokens = {
10033 : : (void *)&cmd_vf_vlan_insert_set,
10034 : : (void *)&cmd_vf_vlan_insert_vf,
10035 : : (void *)&cmd_vf_vlan_insert_vlan,
10036 : : (void *)&cmd_vf_vlan_insert_insert,
10037 : : (void *)&cmd_vf_vlan_insert_port_id,
10038 : : (void *)&cmd_vf_vlan_insert_vf_id,
10039 : : (void *)&cmd_vf_vlan_insert_vlan_id,
10040 : : NULL,
10041 : : },
10042 : : };
10043 : :
10044 : : /* tx loopback configuration */
10045 : :
10046 : : /* Common result structure for tx loopback */
10047 : : struct cmd_tx_loopback_result {
10048 : : cmdline_fixed_string_t set;
10049 : : cmdline_fixed_string_t tx;
10050 : : cmdline_fixed_string_t loopback;
10051 : : portid_t port_id;
10052 : : cmdline_fixed_string_t on_off;
10053 : : };
10054 : :
10055 : : /* Common CLI fields for tx loopback enable disable */
10056 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
10057 : : TOKEN_STRING_INITIALIZER
10058 : : (struct cmd_tx_loopback_result,
10059 : : set, "set");
10060 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
10061 : : TOKEN_STRING_INITIALIZER
10062 : : (struct cmd_tx_loopback_result,
10063 : : tx, "tx");
10064 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
10065 : : TOKEN_STRING_INITIALIZER
10066 : : (struct cmd_tx_loopback_result,
10067 : : loopback, "loopback");
10068 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
10069 : : TOKEN_NUM_INITIALIZER
10070 : : (struct cmd_tx_loopback_result,
10071 : : port_id, RTE_UINT16);
10072 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
10073 : : TOKEN_STRING_INITIALIZER
10074 : : (struct cmd_tx_loopback_result,
10075 : : on_off, "on#off");
10076 : :
10077 : : static void
10078 : 0 : cmd_set_tx_loopback_parsed(
10079 : : void *parsed_result,
10080 : : __rte_unused struct cmdline *cl,
10081 : : __rte_unused void *data)
10082 : : {
10083 : : struct cmd_tx_loopback_result *res = parsed_result;
10084 : : int ret = -ENOTSUP;
10085 : :
10086 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10087 : :
10088 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10089 : : return;
10090 : :
10091 : : #ifdef RTE_NET_IXGBE
10092 : : if (ret == -ENOTSUP)
10093 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
10094 : : #endif
10095 : : #ifdef RTE_NET_I40E
10096 : 0 : if (ret == -ENOTSUP)
10097 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
10098 : : #endif
10099 : : #ifdef RTE_NET_BNXT
10100 : 0 : if (ret == -ENOTSUP)
10101 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
10102 : : #endif
10103 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
10104 : 0 : if (ret == -ENOTSUP)
10105 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
10106 : : #endif
10107 : :
10108 : 0 : switch (ret) {
10109 : : case 0:
10110 : : break;
10111 : 0 : case -EINVAL:
10112 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10113 : : break;
10114 : 0 : case -ENODEV:
10115 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10116 : : break;
10117 : 0 : case -ENOTSUP:
10118 : 0 : fprintf(stderr, "function not implemented\n");
10119 : : break;
10120 : 0 : default:
10121 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10122 : : }
10123 : : }
10124 : :
10125 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
10126 : : .f = cmd_set_tx_loopback_parsed,
10127 : : .data = NULL,
10128 : : .help_str = "set tx loopback <port_id> on|off",
10129 : : .tokens = {
10130 : : (void *)&cmd_tx_loopback_set,
10131 : : (void *)&cmd_tx_loopback_tx,
10132 : : (void *)&cmd_tx_loopback_loopback,
10133 : : (void *)&cmd_tx_loopback_port_id,
10134 : : (void *)&cmd_tx_loopback_on_off,
10135 : : NULL,
10136 : : },
10137 : : };
10138 : :
10139 : : /* all queues drop enable configuration */
10140 : :
10141 : : /* Common result structure for all queues drop enable */
10142 : : struct cmd_all_queues_drop_en_result {
10143 : : cmdline_fixed_string_t set;
10144 : : cmdline_fixed_string_t all;
10145 : : cmdline_fixed_string_t queues;
10146 : : cmdline_fixed_string_t drop;
10147 : : portid_t port_id;
10148 : : cmdline_fixed_string_t on_off;
10149 : : };
10150 : :
10151 : : /* Common CLI fields for tx loopback enable disable */
10152 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
10153 : : TOKEN_STRING_INITIALIZER
10154 : : (struct cmd_all_queues_drop_en_result,
10155 : : set, "set");
10156 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
10157 : : TOKEN_STRING_INITIALIZER
10158 : : (struct cmd_all_queues_drop_en_result,
10159 : : all, "all");
10160 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
10161 : : TOKEN_STRING_INITIALIZER
10162 : : (struct cmd_all_queues_drop_en_result,
10163 : : queues, "queues");
10164 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
10165 : : TOKEN_STRING_INITIALIZER
10166 : : (struct cmd_all_queues_drop_en_result,
10167 : : drop, "drop");
10168 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
10169 : : TOKEN_NUM_INITIALIZER
10170 : : (struct cmd_all_queues_drop_en_result,
10171 : : port_id, RTE_UINT16);
10172 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
10173 : : TOKEN_STRING_INITIALIZER
10174 : : (struct cmd_all_queues_drop_en_result,
10175 : : on_off, "on#off");
10176 : :
10177 : : static void
10178 : 0 : cmd_set_all_queues_drop_en_parsed(
10179 : : void *parsed_result,
10180 : : __rte_unused struct cmdline *cl,
10181 : : __rte_unused void *data)
10182 : : {
10183 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
10184 : : int ret = -ENOTSUP;
10185 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10186 : :
10187 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10188 : : return;
10189 : :
10190 : : #ifdef RTE_NET_IXGBE
10191 : : if (ret == -ENOTSUP)
10192 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
10193 : : #endif
10194 : : #ifdef RTE_NET_BNXT
10195 : 0 : if (ret == -ENOTSUP)
10196 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
10197 : : #endif
10198 : 0 : switch (ret) {
10199 : : case 0:
10200 : : break;
10201 : 0 : case -EINVAL:
10202 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10203 : : break;
10204 : 0 : case -ENODEV:
10205 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10206 : : break;
10207 : 0 : case -ENOTSUP:
10208 : 0 : fprintf(stderr, "function not implemented\n");
10209 : : break;
10210 : 0 : default:
10211 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10212 : : }
10213 : : }
10214 : :
10215 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
10216 : : .f = cmd_set_all_queues_drop_en_parsed,
10217 : : .data = NULL,
10218 : : .help_str = "set all queues drop <port_id> on|off",
10219 : : .tokens = {
10220 : : (void *)&cmd_all_queues_drop_en_set,
10221 : : (void *)&cmd_all_queues_drop_en_all,
10222 : : (void *)&cmd_all_queues_drop_en_queues,
10223 : : (void *)&cmd_all_queues_drop_en_drop,
10224 : : (void *)&cmd_all_queues_drop_en_port_id,
10225 : : (void *)&cmd_all_queues_drop_en_on_off,
10226 : : NULL,
10227 : : },
10228 : : };
10229 : :
10230 : : /* vf mac address configuration */
10231 : :
10232 : : /* Common result structure for vf mac address */
10233 : : struct cmd_set_vf_mac_addr_result {
10234 : : cmdline_fixed_string_t set;
10235 : : cmdline_fixed_string_t vf;
10236 : : cmdline_fixed_string_t mac;
10237 : : cmdline_fixed_string_t addr;
10238 : : portid_t port_id;
10239 : : uint16_t vf_id;
10240 : : struct rte_ether_addr mac_addr;
10241 : :
10242 : : };
10243 : :
10244 : : /* Common CLI fields for vf split drop enable disable */
10245 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
10246 : : TOKEN_STRING_INITIALIZER
10247 : : (struct cmd_set_vf_mac_addr_result,
10248 : : set, "set");
10249 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
10250 : : TOKEN_STRING_INITIALIZER
10251 : : (struct cmd_set_vf_mac_addr_result,
10252 : : vf, "vf");
10253 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
10254 : : TOKEN_STRING_INITIALIZER
10255 : : (struct cmd_set_vf_mac_addr_result,
10256 : : mac, "mac");
10257 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
10258 : : TOKEN_STRING_INITIALIZER
10259 : : (struct cmd_set_vf_mac_addr_result,
10260 : : addr, "addr");
10261 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
10262 : : TOKEN_NUM_INITIALIZER
10263 : : (struct cmd_set_vf_mac_addr_result,
10264 : : port_id, RTE_UINT16);
10265 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
10266 : : TOKEN_NUM_INITIALIZER
10267 : : (struct cmd_set_vf_mac_addr_result,
10268 : : vf_id, RTE_UINT16);
10269 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
10270 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
10271 : : mac_addr);
10272 : :
10273 : : static void
10274 : 0 : cmd_set_vf_mac_addr_parsed(
10275 : : void *parsed_result,
10276 : : __rte_unused struct cmdline *cl,
10277 : : __rte_unused void *data)
10278 : : {
10279 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
10280 : : int ret = -ENOTSUP;
10281 : :
10282 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10283 : : return;
10284 : :
10285 : : #ifdef RTE_NET_IXGBE
10286 : : if (ret == -ENOTSUP)
10287 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
10288 : : &res->mac_addr);
10289 : : #endif
10290 : : #ifdef RTE_NET_I40E
10291 : 0 : if (ret == -ENOTSUP)
10292 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
10293 : : &res->mac_addr);
10294 : : #endif
10295 : : #ifdef RTE_NET_BNXT
10296 : 0 : if (ret == -ENOTSUP)
10297 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
10298 : : &res->mac_addr);
10299 : : #endif
10300 : :
10301 : 0 : switch (ret) {
10302 : : case 0:
10303 : : break;
10304 : 0 : case -EINVAL:
10305 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
10306 : : break;
10307 : 0 : case -ENODEV:
10308 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10309 : : break;
10310 : 0 : case -ENOTSUP:
10311 : 0 : fprintf(stderr, "function not implemented\n");
10312 : : break;
10313 : 0 : default:
10314 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10315 : : }
10316 : : }
10317 : :
10318 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
10319 : : .f = cmd_set_vf_mac_addr_parsed,
10320 : : .data = NULL,
10321 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
10322 : : .tokens = {
10323 : : (void *)&cmd_set_vf_mac_addr_set,
10324 : : (void *)&cmd_set_vf_mac_addr_vf,
10325 : : (void *)&cmd_set_vf_mac_addr_mac,
10326 : : (void *)&cmd_set_vf_mac_addr_addr,
10327 : : (void *)&cmd_set_vf_mac_addr_port_id,
10328 : : (void *)&cmd_set_vf_mac_addr_vf_id,
10329 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
10330 : : NULL,
10331 : : },
10332 : : };
10333 : :
10334 : : /** Set VXLAN encapsulation details */
10335 : : struct cmd_set_vxlan_result {
10336 : : cmdline_fixed_string_t set;
10337 : : cmdline_fixed_string_t vxlan;
10338 : : cmdline_fixed_string_t pos_token;
10339 : : cmdline_fixed_string_t ip_version;
10340 : : uint32_t vlan_present:1;
10341 : : uint32_t vni;
10342 : : uint16_t udp_src;
10343 : : uint16_t udp_dst;
10344 : : cmdline_ipaddr_t ip_src;
10345 : : cmdline_ipaddr_t ip_dst;
10346 : : uint16_t tci;
10347 : : uint8_t tos;
10348 : : uint8_t ttl;
10349 : : struct rte_ether_addr eth_src;
10350 : : struct rte_ether_addr eth_dst;
10351 : : };
10352 : :
10353 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
10354 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
10355 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
10356 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
10357 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
10358 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10359 : : "vxlan-tos-ttl");
10360 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
10361 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10362 : : "vxlan-with-vlan");
10363 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
10364 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10365 : : "ip-version");
10366 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
10367 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
10368 : : "ipv4#ipv6");
10369 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
10370 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10371 : : "vni");
10372 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
10373 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
10374 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
10375 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10376 : : "udp-src");
10377 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
10378 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
10379 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
10380 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10381 : : "udp-dst");
10382 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
10383 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
10384 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
10385 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10386 : : "ip-tos");
10387 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
10388 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
10389 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
10390 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10391 : : "ip-ttl");
10392 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
10393 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
10394 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
10395 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10396 : : "ip-src");
10397 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
10398 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
10399 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
10400 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10401 : : "ip-dst");
10402 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
10403 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
10404 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
10405 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10406 : : "vlan-tci");
10407 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
10408 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
10409 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
10410 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10411 : : "eth-src");
10412 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
10413 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
10414 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
10415 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10416 : : "eth-dst");
10417 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
10418 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
10419 : :
10420 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
10421 : : __rte_unused struct cmdline *cl,
10422 : : __rte_unused void *data)
10423 : : {
10424 : : struct cmd_set_vxlan_result *res = parsed_result;
10425 : : union {
10426 : : uint32_t vxlan_id;
10427 : : uint8_t vni[4];
10428 : 0 : } id = {
10429 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
10430 : : };
10431 : :
10432 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
10433 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
10434 : 0 : vxlan_encap_conf.select_vlan = 0;
10435 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
10436 : 0 : vxlan_encap_conf.select_vlan = 1;
10437 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
10438 : 0 : vxlan_encap_conf.select_vlan = 0;
10439 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
10440 : : }
10441 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10442 : 0 : vxlan_encap_conf.select_ipv4 = 1;
10443 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10444 : 0 : vxlan_encap_conf.select_ipv4 = 0;
10445 : : else
10446 : 0 : return;
10447 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
10448 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10449 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10450 : 0 : vxlan_encap_conf.ip_tos = res->tos;
10451 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
10452 : 0 : if (vxlan_encap_conf.select_ipv4) {
10453 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
10454 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
10455 : : } else {
10456 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
10457 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
10458 : : }
10459 : 0 : if (vxlan_encap_conf.select_vlan)
10460 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10461 : 0 : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
10462 : : RTE_ETHER_ADDR_LEN);
10463 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10464 : : RTE_ETHER_ADDR_LEN);
10465 : : }
10466 : :
10467 : : static cmdline_parse_inst_t cmd_set_vxlan = {
10468 : : .f = cmd_set_vxlan_parsed,
10469 : : .data = NULL,
10470 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
10471 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
10472 : : " eth-src <eth-src> eth-dst <eth-dst>",
10473 : : .tokens = {
10474 : : (void *)&cmd_set_vxlan_set,
10475 : : (void *)&cmd_set_vxlan_vxlan,
10476 : : (void *)&cmd_set_vxlan_ip_version,
10477 : : (void *)&cmd_set_vxlan_ip_version_value,
10478 : : (void *)&cmd_set_vxlan_vni,
10479 : : (void *)&cmd_set_vxlan_vni_value,
10480 : : (void *)&cmd_set_vxlan_udp_src,
10481 : : (void *)&cmd_set_vxlan_udp_src_value,
10482 : : (void *)&cmd_set_vxlan_udp_dst,
10483 : : (void *)&cmd_set_vxlan_udp_dst_value,
10484 : : (void *)&cmd_set_vxlan_ip_src,
10485 : : (void *)&cmd_set_vxlan_ip_src_value,
10486 : : (void *)&cmd_set_vxlan_ip_dst,
10487 : : (void *)&cmd_set_vxlan_ip_dst_value,
10488 : : (void *)&cmd_set_vxlan_eth_src,
10489 : : (void *)&cmd_set_vxlan_eth_src_value,
10490 : : (void *)&cmd_set_vxlan_eth_dst,
10491 : : (void *)&cmd_set_vxlan_eth_dst_value,
10492 : : NULL,
10493 : : },
10494 : : };
10495 : :
10496 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
10497 : : .f = cmd_set_vxlan_parsed,
10498 : : .data = NULL,
10499 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
10500 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
10501 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10502 : : " eth-dst <eth-dst>",
10503 : : .tokens = {
10504 : : (void *)&cmd_set_vxlan_set,
10505 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
10506 : : (void *)&cmd_set_vxlan_ip_version,
10507 : : (void *)&cmd_set_vxlan_ip_version_value,
10508 : : (void *)&cmd_set_vxlan_vni,
10509 : : (void *)&cmd_set_vxlan_vni_value,
10510 : : (void *)&cmd_set_vxlan_udp_src,
10511 : : (void *)&cmd_set_vxlan_udp_src_value,
10512 : : (void *)&cmd_set_vxlan_udp_dst,
10513 : : (void *)&cmd_set_vxlan_udp_dst_value,
10514 : : (void *)&cmd_set_vxlan_ip_tos,
10515 : : (void *)&cmd_set_vxlan_ip_tos_value,
10516 : : (void *)&cmd_set_vxlan_ip_ttl,
10517 : : (void *)&cmd_set_vxlan_ip_ttl_value,
10518 : : (void *)&cmd_set_vxlan_ip_src,
10519 : : (void *)&cmd_set_vxlan_ip_src_value,
10520 : : (void *)&cmd_set_vxlan_ip_dst,
10521 : : (void *)&cmd_set_vxlan_ip_dst_value,
10522 : : (void *)&cmd_set_vxlan_eth_src,
10523 : : (void *)&cmd_set_vxlan_eth_src_value,
10524 : : (void *)&cmd_set_vxlan_eth_dst,
10525 : : (void *)&cmd_set_vxlan_eth_dst_value,
10526 : : NULL,
10527 : : },
10528 : : };
10529 : :
10530 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
10531 : : .f = cmd_set_vxlan_parsed,
10532 : : .data = NULL,
10533 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
10534 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
10535 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
10536 : : " <eth-dst>",
10537 : : .tokens = {
10538 : : (void *)&cmd_set_vxlan_set,
10539 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
10540 : : (void *)&cmd_set_vxlan_ip_version,
10541 : : (void *)&cmd_set_vxlan_ip_version_value,
10542 : : (void *)&cmd_set_vxlan_vni,
10543 : : (void *)&cmd_set_vxlan_vni_value,
10544 : : (void *)&cmd_set_vxlan_udp_src,
10545 : : (void *)&cmd_set_vxlan_udp_src_value,
10546 : : (void *)&cmd_set_vxlan_udp_dst,
10547 : : (void *)&cmd_set_vxlan_udp_dst_value,
10548 : : (void *)&cmd_set_vxlan_ip_src,
10549 : : (void *)&cmd_set_vxlan_ip_src_value,
10550 : : (void *)&cmd_set_vxlan_ip_dst,
10551 : : (void *)&cmd_set_vxlan_ip_dst_value,
10552 : : (void *)&cmd_set_vxlan_vlan,
10553 : : (void *)&cmd_set_vxlan_vlan_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 : : /** Set NVGRE encapsulation details */
10563 : : struct cmd_set_nvgre_result {
10564 : : cmdline_fixed_string_t set;
10565 : : cmdline_fixed_string_t nvgre;
10566 : : cmdline_fixed_string_t pos_token;
10567 : : cmdline_fixed_string_t ip_version;
10568 : : uint32_t tni;
10569 : : cmdline_ipaddr_t ip_src;
10570 : : cmdline_ipaddr_t ip_dst;
10571 : : uint16_t tci;
10572 : : struct rte_ether_addr eth_src;
10573 : : struct rte_ether_addr eth_dst;
10574 : : };
10575 : :
10576 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
10577 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
10578 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
10579 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
10580 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
10581 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
10582 : : "nvgre-with-vlan");
10583 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
10584 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10585 : : "ip-version");
10586 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
10587 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
10588 : : "ipv4#ipv6");
10589 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
10590 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10591 : : "tni");
10592 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
10593 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
10594 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
10595 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10596 : : "ip-src");
10597 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
10598 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
10599 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
10600 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10601 : : "ip-dst");
10602 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
10603 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
10604 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
10605 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10606 : : "vlan-tci");
10607 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
10608 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
10609 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
10610 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10611 : : "eth-src");
10612 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
10613 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
10614 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
10615 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10616 : : "eth-dst");
10617 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
10618 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
10619 : :
10620 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
10621 : : __rte_unused struct cmdline *cl,
10622 : : __rte_unused void *data)
10623 : : {
10624 : : struct cmd_set_nvgre_result *res = parsed_result;
10625 : : union {
10626 : : uint32_t nvgre_tni;
10627 : : uint8_t tni[4];
10628 : 0 : } id = {
10629 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
10630 : : };
10631 : :
10632 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
10633 : 0 : nvgre_encap_conf.select_vlan = 0;
10634 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
10635 : 0 : nvgre_encap_conf.select_vlan = 1;
10636 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10637 : 0 : nvgre_encap_conf.select_ipv4 = 1;
10638 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10639 : 0 : nvgre_encap_conf.select_ipv4 = 0;
10640 : : else
10641 : 0 : return;
10642 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
10643 : 0 : if (nvgre_encap_conf.select_ipv4) {
10644 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
10645 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
10646 : : } else {
10647 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
10648 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
10649 : : }
10650 : 0 : if (nvgre_encap_conf.select_vlan)
10651 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10652 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
10653 : : RTE_ETHER_ADDR_LEN);
10654 : 0 : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10655 : : RTE_ETHER_ADDR_LEN);
10656 : : }
10657 : :
10658 : : static cmdline_parse_inst_t cmd_set_nvgre = {
10659 : : .f = cmd_set_nvgre_parsed,
10660 : : .data = NULL,
10661 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
10662 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10663 : : " eth-dst <eth-dst>",
10664 : : .tokens = {
10665 : : (void *)&cmd_set_nvgre_set,
10666 : : (void *)&cmd_set_nvgre_nvgre,
10667 : : (void *)&cmd_set_nvgre_ip_version,
10668 : : (void *)&cmd_set_nvgre_ip_version_value,
10669 : : (void *)&cmd_set_nvgre_tni,
10670 : : (void *)&cmd_set_nvgre_tni_value,
10671 : : (void *)&cmd_set_nvgre_ip_src,
10672 : : (void *)&cmd_set_nvgre_ip_src_value,
10673 : : (void *)&cmd_set_nvgre_ip_dst,
10674 : : (void *)&cmd_set_nvgre_ip_dst_value,
10675 : : (void *)&cmd_set_nvgre_eth_src,
10676 : : (void *)&cmd_set_nvgre_eth_src_value,
10677 : : (void *)&cmd_set_nvgre_eth_dst,
10678 : : (void *)&cmd_set_nvgre_eth_dst_value,
10679 : : NULL,
10680 : : },
10681 : : };
10682 : :
10683 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
10684 : : .f = cmd_set_nvgre_parsed,
10685 : : .data = NULL,
10686 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
10687 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10688 : : " eth-src <eth-src> eth-dst <eth-dst>",
10689 : : .tokens = {
10690 : : (void *)&cmd_set_nvgre_set,
10691 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
10692 : : (void *)&cmd_set_nvgre_ip_version,
10693 : : (void *)&cmd_set_nvgre_ip_version_value,
10694 : : (void *)&cmd_set_nvgre_tni,
10695 : : (void *)&cmd_set_nvgre_tni_value,
10696 : : (void *)&cmd_set_nvgre_ip_src,
10697 : : (void *)&cmd_set_nvgre_ip_src_value,
10698 : : (void *)&cmd_set_nvgre_ip_dst,
10699 : : (void *)&cmd_set_nvgre_ip_dst_value,
10700 : : (void *)&cmd_set_nvgre_vlan,
10701 : : (void *)&cmd_set_nvgre_vlan_value,
10702 : : (void *)&cmd_set_nvgre_eth_src,
10703 : : (void *)&cmd_set_nvgre_eth_src_value,
10704 : : (void *)&cmd_set_nvgre_eth_dst,
10705 : : (void *)&cmd_set_nvgre_eth_dst_value,
10706 : : NULL,
10707 : : },
10708 : : };
10709 : :
10710 : : /** Set L2 encapsulation details */
10711 : : struct cmd_set_l2_encap_result {
10712 : : cmdline_fixed_string_t set;
10713 : : cmdline_fixed_string_t l2_encap;
10714 : : cmdline_fixed_string_t pos_token;
10715 : : cmdline_fixed_string_t ip_version;
10716 : : uint32_t vlan_present:1;
10717 : : uint16_t tci;
10718 : : struct rte_ether_addr eth_src;
10719 : : struct rte_ether_addr eth_dst;
10720 : : };
10721 : :
10722 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
10723 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
10724 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
10725 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
10726 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
10727 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
10728 : : "l2_encap-with-vlan");
10729 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
10730 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10731 : : "ip-version");
10732 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
10733 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
10734 : : "ipv4#ipv6");
10735 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
10736 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10737 : : "vlan-tci");
10738 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
10739 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
10740 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
10741 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10742 : : "eth-src");
10743 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
10744 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
10745 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
10746 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10747 : : "eth-dst");
10748 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
10749 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
10750 : :
10751 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
10752 : : __rte_unused struct cmdline *cl,
10753 : : __rte_unused void *data)
10754 : : {
10755 : : struct cmd_set_l2_encap_result *res = parsed_result;
10756 : :
10757 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
10758 : 0 : l2_encap_conf.select_vlan = 0;
10759 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
10760 : 0 : l2_encap_conf.select_vlan = 1;
10761 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10762 : 0 : l2_encap_conf.select_ipv4 = 1;
10763 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10764 : 0 : l2_encap_conf.select_ipv4 = 0;
10765 : : else
10766 : : return;
10767 : 0 : if (l2_encap_conf.select_vlan)
10768 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10769 : 0 : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
10770 : : RTE_ETHER_ADDR_LEN);
10771 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10772 : : RTE_ETHER_ADDR_LEN);
10773 : : }
10774 : :
10775 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
10776 : : .f = cmd_set_l2_encap_parsed,
10777 : : .data = NULL,
10778 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
10779 : : " eth-src <eth-src> eth-dst <eth-dst>",
10780 : : .tokens = {
10781 : : (void *)&cmd_set_l2_encap_set,
10782 : : (void *)&cmd_set_l2_encap_l2_encap,
10783 : : (void *)&cmd_set_l2_encap_ip_version,
10784 : : (void *)&cmd_set_l2_encap_ip_version_value,
10785 : : (void *)&cmd_set_l2_encap_eth_src,
10786 : : (void *)&cmd_set_l2_encap_eth_src_value,
10787 : : (void *)&cmd_set_l2_encap_eth_dst,
10788 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10789 : : NULL,
10790 : : },
10791 : : };
10792 : :
10793 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
10794 : : .f = cmd_set_l2_encap_parsed,
10795 : : .data = NULL,
10796 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
10797 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10798 : : .tokens = {
10799 : : (void *)&cmd_set_l2_encap_set,
10800 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
10801 : : (void *)&cmd_set_l2_encap_ip_version,
10802 : : (void *)&cmd_set_l2_encap_ip_version_value,
10803 : : (void *)&cmd_set_l2_encap_vlan,
10804 : : (void *)&cmd_set_l2_encap_vlan_value,
10805 : : (void *)&cmd_set_l2_encap_eth_src,
10806 : : (void *)&cmd_set_l2_encap_eth_src_value,
10807 : : (void *)&cmd_set_l2_encap_eth_dst,
10808 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10809 : : NULL,
10810 : : },
10811 : : };
10812 : :
10813 : : /** Set L2 decapsulation details */
10814 : : struct cmd_set_l2_decap_result {
10815 : : cmdline_fixed_string_t set;
10816 : : cmdline_fixed_string_t l2_decap;
10817 : : cmdline_fixed_string_t pos_token;
10818 : : uint32_t vlan_present:1;
10819 : : };
10820 : :
10821 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
10822 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
10823 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
10824 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10825 : : "l2_decap");
10826 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
10827 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10828 : : "l2_decap-with-vlan");
10829 : :
10830 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
10831 : : __rte_unused struct cmdline *cl,
10832 : : __rte_unused void *data)
10833 : : {
10834 : : struct cmd_set_l2_decap_result *res = parsed_result;
10835 : :
10836 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
10837 : 0 : l2_decap_conf.select_vlan = 0;
10838 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
10839 : 0 : l2_decap_conf.select_vlan = 1;
10840 : 0 : }
10841 : :
10842 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
10843 : : .f = cmd_set_l2_decap_parsed,
10844 : : .data = NULL,
10845 : : .help_str = "set l2_decap",
10846 : : .tokens = {
10847 : : (void *)&cmd_set_l2_decap_set,
10848 : : (void *)&cmd_set_l2_decap_l2_decap,
10849 : : NULL,
10850 : : },
10851 : : };
10852 : :
10853 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
10854 : : .f = cmd_set_l2_decap_parsed,
10855 : : .data = NULL,
10856 : : .help_str = "set l2_decap-with-vlan",
10857 : : .tokens = {
10858 : : (void *)&cmd_set_l2_decap_set,
10859 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
10860 : : NULL,
10861 : : },
10862 : : };
10863 : :
10864 : : /** Set MPLSoGRE encapsulation details */
10865 : : struct cmd_set_mplsogre_encap_result {
10866 : : cmdline_fixed_string_t set;
10867 : : cmdline_fixed_string_t mplsogre;
10868 : : cmdline_fixed_string_t pos_token;
10869 : : cmdline_fixed_string_t ip_version;
10870 : : uint32_t vlan_present:1;
10871 : : uint32_t label;
10872 : : cmdline_ipaddr_t ip_src;
10873 : : cmdline_ipaddr_t ip_dst;
10874 : : uint16_t tci;
10875 : : struct rte_ether_addr eth_src;
10876 : : struct rte_ether_addr eth_dst;
10877 : : };
10878 : :
10879 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
10880 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
10881 : : "set");
10882 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
10883 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
10884 : : "mplsogre_encap");
10885 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
10886 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10887 : : mplsogre, "mplsogre_encap-with-vlan");
10888 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
10889 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10890 : : pos_token, "ip-version");
10891 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
10892 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10893 : : ip_version, "ipv4#ipv6");
10894 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
10895 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10896 : : pos_token, "label");
10897 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
10898 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
10899 : : RTE_UINT32);
10900 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
10901 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10902 : : pos_token, "ip-src");
10903 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
10904 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
10905 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
10906 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10907 : : pos_token, "ip-dst");
10908 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
10909 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
10910 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
10911 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10912 : : pos_token, "vlan-tci");
10913 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
10914 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
10915 : : RTE_UINT16);
10916 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
10917 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10918 : : pos_token, "eth-src");
10919 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
10920 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10921 : : eth_src);
10922 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
10923 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10924 : : pos_token, "eth-dst");
10925 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
10926 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10927 : : eth_dst);
10928 : :
10929 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
10930 : : __rte_unused struct cmdline *cl,
10931 : : __rte_unused void *data)
10932 : : {
10933 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
10934 : : union {
10935 : : uint32_t mplsogre_label;
10936 : : uint8_t label[4];
10937 : 0 : } id = {
10938 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
10939 : : };
10940 : :
10941 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
10942 : 0 : mplsogre_encap_conf.select_vlan = 0;
10943 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
10944 : 0 : mplsogre_encap_conf.select_vlan = 1;
10945 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10946 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
10947 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10948 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
10949 : : else
10950 : 0 : return;
10951 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
10952 : 0 : if (mplsogre_encap_conf.select_ipv4) {
10953 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
10954 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
10955 : : } else {
10956 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
10957 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
10958 : : }
10959 : 0 : if (mplsogre_encap_conf.select_vlan)
10960 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10961 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
10962 : : RTE_ETHER_ADDR_LEN);
10963 : 0 : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10964 : : RTE_ETHER_ADDR_LEN);
10965 : : }
10966 : :
10967 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
10968 : : .f = cmd_set_mplsogre_encap_parsed,
10969 : : .data = NULL,
10970 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
10971 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10972 : : " eth-dst <eth-dst>",
10973 : : .tokens = {
10974 : : (void *)&cmd_set_mplsogre_encap_set,
10975 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
10976 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10977 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10978 : : (void *)&cmd_set_mplsogre_encap_label,
10979 : : (void *)&cmd_set_mplsogre_encap_label_value,
10980 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10981 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10982 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10983 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10984 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10985 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10986 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10987 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10988 : : NULL,
10989 : : },
10990 : : };
10991 : :
10992 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
10993 : : .f = cmd_set_mplsogre_encap_parsed,
10994 : : .data = NULL,
10995 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
10996 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
10997 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10998 : : .tokens = {
10999 : : (void *)&cmd_set_mplsogre_encap_set,
11000 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
11001 : : (void *)&cmd_set_mplsogre_encap_ip_version,
11002 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
11003 : : (void *)&cmd_set_mplsogre_encap_label,
11004 : : (void *)&cmd_set_mplsogre_encap_label_value,
11005 : : (void *)&cmd_set_mplsogre_encap_ip_src,
11006 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
11007 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
11008 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
11009 : : (void *)&cmd_set_mplsogre_encap_vlan,
11010 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
11011 : : (void *)&cmd_set_mplsogre_encap_eth_src,
11012 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
11013 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
11014 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
11015 : : NULL,
11016 : : },
11017 : : };
11018 : :
11019 : : /** Set MPLSoGRE decapsulation details */
11020 : : struct cmd_set_mplsogre_decap_result {
11021 : : cmdline_fixed_string_t set;
11022 : : cmdline_fixed_string_t mplsogre;
11023 : : cmdline_fixed_string_t pos_token;
11024 : : cmdline_fixed_string_t ip_version;
11025 : : uint32_t vlan_present:1;
11026 : : };
11027 : :
11028 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
11029 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
11030 : : "set");
11031 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
11032 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
11033 : : "mplsogre_decap");
11034 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
11035 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11036 : : mplsogre, "mplsogre_decap-with-vlan");
11037 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
11038 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11039 : : pos_token, "ip-version");
11040 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
11041 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11042 : : ip_version, "ipv4#ipv6");
11043 : :
11044 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
11045 : : __rte_unused struct cmdline *cl,
11046 : : __rte_unused void *data)
11047 : : {
11048 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
11049 : :
11050 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
11051 : 0 : mplsogre_decap_conf.select_vlan = 0;
11052 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
11053 : 0 : mplsogre_decap_conf.select_vlan = 1;
11054 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11055 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
11056 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11057 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
11058 : 0 : }
11059 : :
11060 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
11061 : : .f = cmd_set_mplsogre_decap_parsed,
11062 : : .data = NULL,
11063 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
11064 : : .tokens = {
11065 : : (void *)&cmd_set_mplsogre_decap_set,
11066 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
11067 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11068 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11069 : : NULL,
11070 : : },
11071 : : };
11072 : :
11073 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
11074 : : .f = cmd_set_mplsogre_decap_parsed,
11075 : : .data = NULL,
11076 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
11077 : : .tokens = {
11078 : : (void *)&cmd_set_mplsogre_decap_set,
11079 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
11080 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11081 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11082 : : NULL,
11083 : : },
11084 : : };
11085 : :
11086 : : /** Set MPLSoUDP encapsulation details */
11087 : : struct cmd_set_mplsoudp_encap_result {
11088 : : cmdline_fixed_string_t set;
11089 : : cmdline_fixed_string_t mplsoudp;
11090 : : cmdline_fixed_string_t pos_token;
11091 : : cmdline_fixed_string_t ip_version;
11092 : : uint32_t vlan_present:1;
11093 : : uint32_t label;
11094 : : uint16_t udp_src;
11095 : : uint16_t udp_dst;
11096 : : cmdline_ipaddr_t ip_src;
11097 : : cmdline_ipaddr_t ip_dst;
11098 : : uint16_t tci;
11099 : : struct rte_ether_addr eth_src;
11100 : : struct rte_ether_addr eth_dst;
11101 : : };
11102 : :
11103 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
11104 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
11105 : : "set");
11106 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
11107 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
11108 : : "mplsoudp_encap");
11109 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
11110 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11111 : : mplsoudp, "mplsoudp_encap-with-vlan");
11112 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
11113 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11114 : : pos_token, "ip-version");
11115 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
11116 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11117 : : ip_version, "ipv4#ipv6");
11118 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
11119 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11120 : : pos_token, "label");
11121 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
11122 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
11123 : : RTE_UINT32);
11124 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
11125 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11126 : : pos_token, "udp-src");
11127 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
11128 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
11129 : : RTE_UINT16);
11130 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
11131 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11132 : : pos_token, "udp-dst");
11133 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
11134 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
11135 : : RTE_UINT16);
11136 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
11137 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11138 : : pos_token, "ip-src");
11139 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
11140 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
11141 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
11142 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11143 : : pos_token, "ip-dst");
11144 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
11145 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
11146 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
11147 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11148 : : pos_token, "vlan-tci");
11149 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
11150 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
11151 : : RTE_UINT16);
11152 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
11153 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11154 : : pos_token, "eth-src");
11155 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
11156 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11157 : : eth_src);
11158 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
11159 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11160 : : pos_token, "eth-dst");
11161 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
11162 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11163 : : eth_dst);
11164 : :
11165 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
11166 : : __rte_unused struct cmdline *cl,
11167 : : __rte_unused void *data)
11168 : : {
11169 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
11170 : : union {
11171 : : uint32_t mplsoudp_label;
11172 : : uint8_t label[4];
11173 : 0 : } id = {
11174 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
11175 : : };
11176 : :
11177 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
11178 : 0 : mplsoudp_encap_conf.select_vlan = 0;
11179 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
11180 : 0 : mplsoudp_encap_conf.select_vlan = 1;
11181 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11182 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
11183 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11184 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
11185 : : else
11186 : 0 : return;
11187 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
11188 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
11189 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
11190 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
11191 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
11192 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
11193 : : } else {
11194 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
11195 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
11196 : : }
11197 : 0 : if (mplsoudp_encap_conf.select_vlan)
11198 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11199 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
11200 : : RTE_ETHER_ADDR_LEN);
11201 : 0 : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11202 : : RTE_ETHER_ADDR_LEN);
11203 : : }
11204 : :
11205 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
11206 : : .f = cmd_set_mplsoudp_encap_parsed,
11207 : : .data = NULL,
11208 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
11209 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
11210 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
11211 : : .tokens = {
11212 : : (void *)&cmd_set_mplsoudp_encap_set,
11213 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
11214 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11215 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11216 : : (void *)&cmd_set_mplsoudp_encap_label,
11217 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11218 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11219 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11220 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11221 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11222 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11223 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11224 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11225 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11226 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11227 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11228 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11229 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11230 : : NULL,
11231 : : },
11232 : : };
11233 : :
11234 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
11235 : : .f = cmd_set_mplsoudp_encap_parsed,
11236 : : .data = NULL,
11237 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
11238 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
11239 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
11240 : : " eth-src <eth-src> eth-dst <eth-dst>",
11241 : : .tokens = {
11242 : : (void *)&cmd_set_mplsoudp_encap_set,
11243 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
11244 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11245 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11246 : : (void *)&cmd_set_mplsoudp_encap_label,
11247 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11248 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11249 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11250 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11251 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11252 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11253 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11254 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11255 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11256 : : (void *)&cmd_set_mplsoudp_encap_vlan,
11257 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
11258 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11259 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11260 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11261 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11262 : : NULL,
11263 : : },
11264 : : };
11265 : :
11266 : : /** Set MPLSoUDP decapsulation details */
11267 : : struct cmd_set_mplsoudp_decap_result {
11268 : : cmdline_fixed_string_t set;
11269 : : cmdline_fixed_string_t mplsoudp;
11270 : : cmdline_fixed_string_t pos_token;
11271 : : cmdline_fixed_string_t ip_version;
11272 : : uint32_t vlan_present:1;
11273 : : };
11274 : :
11275 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
11276 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
11277 : : "set");
11278 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
11279 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
11280 : : "mplsoudp_decap");
11281 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
11282 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11283 : : mplsoudp, "mplsoudp_decap-with-vlan");
11284 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
11285 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11286 : : pos_token, "ip-version");
11287 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
11288 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11289 : : ip_version, "ipv4#ipv6");
11290 : :
11291 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
11292 : : __rte_unused struct cmdline *cl,
11293 : : __rte_unused void *data)
11294 : : {
11295 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
11296 : :
11297 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
11298 : 0 : mplsoudp_decap_conf.select_vlan = 0;
11299 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
11300 : 0 : mplsoudp_decap_conf.select_vlan = 1;
11301 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11302 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
11303 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11304 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
11305 : 0 : }
11306 : :
11307 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
11308 : : .f = cmd_set_mplsoudp_decap_parsed,
11309 : : .data = NULL,
11310 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
11311 : : .tokens = {
11312 : : (void *)&cmd_set_mplsoudp_decap_set,
11313 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
11314 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11315 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11316 : : NULL,
11317 : : },
11318 : : };
11319 : :
11320 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
11321 : : .f = cmd_set_mplsoudp_decap_parsed,
11322 : : .data = NULL,
11323 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
11324 : : .tokens = {
11325 : : (void *)&cmd_set_mplsoudp_decap_set,
11326 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
11327 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11328 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11329 : : NULL,
11330 : : },
11331 : : };
11332 : :
11333 : : /** Set connection tracking object common details */
11334 : : struct cmd_set_conntrack_common_result {
11335 : : cmdline_fixed_string_t set;
11336 : : cmdline_fixed_string_t conntrack;
11337 : : cmdline_fixed_string_t common;
11338 : : cmdline_fixed_string_t peer;
11339 : : cmdline_fixed_string_t is_orig;
11340 : : cmdline_fixed_string_t enable;
11341 : : cmdline_fixed_string_t live;
11342 : : cmdline_fixed_string_t sack;
11343 : : cmdline_fixed_string_t cack;
11344 : : cmdline_fixed_string_t last_dir;
11345 : : cmdline_fixed_string_t liberal;
11346 : : cmdline_fixed_string_t state;
11347 : : cmdline_fixed_string_t max_ack_win;
11348 : : cmdline_fixed_string_t retrans;
11349 : : cmdline_fixed_string_t last_win;
11350 : : cmdline_fixed_string_t last_seq;
11351 : : cmdline_fixed_string_t last_ack;
11352 : : cmdline_fixed_string_t last_end;
11353 : : cmdline_fixed_string_t last_index;
11354 : : uint8_t stat;
11355 : : uint8_t factor;
11356 : : uint16_t peer_port;
11357 : : uint32_t is_original;
11358 : : uint32_t en;
11359 : : uint32_t is_live;
11360 : : uint32_t s_ack;
11361 : : uint32_t c_ack;
11362 : : uint32_t ld;
11363 : : uint32_t lb;
11364 : : uint8_t re_num;
11365 : : uint8_t li;
11366 : : uint16_t lw;
11367 : : uint32_t ls;
11368 : : uint32_t la;
11369 : : uint32_t le;
11370 : : };
11371 : :
11372 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
11373 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11374 : : set, "set");
11375 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
11376 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11377 : : conntrack, "conntrack");
11378 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
11379 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11380 : : common, "com");
11381 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
11382 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11383 : : peer, "peer");
11384 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
11385 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11386 : : peer_port, RTE_UINT16);
11387 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
11388 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11389 : : is_orig, "is_orig");
11390 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
11391 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11392 : : is_original, RTE_UINT32);
11393 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
11394 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11395 : : enable, "enable");
11396 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
11397 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11398 : : en, RTE_UINT32);
11399 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
11400 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11401 : : live, "live");
11402 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
11403 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11404 : : is_live, RTE_UINT32);
11405 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
11406 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11407 : : sack, "sack");
11408 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
11409 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11410 : : s_ack, RTE_UINT32);
11411 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
11412 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11413 : : cack, "cack");
11414 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
11415 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11416 : : c_ack, RTE_UINT32);
11417 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
11418 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11419 : : last_dir, "last_dir");
11420 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
11421 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11422 : : ld, RTE_UINT32);
11423 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
11424 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11425 : : liberal, "liberal");
11426 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
11427 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11428 : : lb, RTE_UINT32);
11429 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
11430 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11431 : : state, "state");
11432 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
11433 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11434 : : stat, RTE_UINT8);
11435 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
11436 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11437 : : max_ack_win, "max_ack_win");
11438 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
11439 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11440 : : factor, RTE_UINT8);
11441 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
11442 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11443 : : retrans, "r_lim");
11444 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
11445 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11446 : : re_num, RTE_UINT8);
11447 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
11448 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11449 : : last_win, "last_win");
11450 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
11451 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11452 : : lw, RTE_UINT16);
11453 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
11454 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11455 : : last_seq, "last_seq");
11456 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
11457 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11458 : : ls, RTE_UINT32);
11459 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
11460 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11461 : : last_ack, "last_ack");
11462 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
11463 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11464 : : la, RTE_UINT32);
11465 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
11466 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11467 : : last_end, "last_end");
11468 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
11469 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11470 : : le, RTE_UINT32);
11471 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
11472 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11473 : : last_index, "last_index");
11474 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
11475 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11476 : : li, RTE_UINT8);
11477 : :
11478 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
11479 : : __rte_unused struct cmdline *cl,
11480 : : __rte_unused void *data)
11481 : : {
11482 : : struct cmd_set_conntrack_common_result *res = parsed_result;
11483 : :
11484 : : /* No need to swap to big endian. */
11485 : 0 : conntrack_context.peer_port = res->peer_port;
11486 : 0 : conntrack_context.is_original_dir = res->is_original;
11487 : 0 : conntrack_context.enable = res->en;
11488 : 0 : conntrack_context.live_connection = res->is_live;
11489 : 0 : conntrack_context.selective_ack = res->s_ack;
11490 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
11491 : 0 : conntrack_context.last_direction = res->ld;
11492 : 0 : conntrack_context.liberal_mode = res->lb;
11493 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
11494 : 0 : conntrack_context.max_ack_window = res->factor;
11495 : 0 : conntrack_context.retransmission_limit = res->re_num;
11496 : 0 : conntrack_context.last_window = res->lw;
11497 : 0 : conntrack_context.last_index =
11498 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
11499 : 0 : conntrack_context.last_seq = res->ls;
11500 : 0 : conntrack_context.last_ack = res->la;
11501 : 0 : conntrack_context.last_end = res->le;
11502 : 0 : }
11503 : :
11504 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
11505 : : .f = cmd_set_conntrack_common_parsed,
11506 : : .data = NULL,
11507 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
11508 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
11509 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
11510 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
11511 : : " last_index <flag>",
11512 : : .tokens = {
11513 : : (void *)&cmd_set_conntrack_set,
11514 : : (void *)&cmd_set_conntrack_conntrack,
11515 : : (void *)&cmd_set_conntrack_common_com,
11516 : : (void *)&cmd_set_conntrack_common_peer,
11517 : : (void *)&cmd_set_conntrack_common_peer_value,
11518 : : (void *)&cmd_set_conntrack_common_is_orig,
11519 : : (void *)&cmd_set_conntrack_common_is_orig_value,
11520 : : (void *)&cmd_set_conntrack_common_enable,
11521 : : (void *)&cmd_set_conntrack_common_enable_value,
11522 : : (void *)&cmd_set_conntrack_common_live,
11523 : : (void *)&cmd_set_conntrack_common_live_value,
11524 : : (void *)&cmd_set_conntrack_common_sack,
11525 : : (void *)&cmd_set_conntrack_common_sack_value,
11526 : : (void *)&cmd_set_conntrack_common_cack,
11527 : : (void *)&cmd_set_conntrack_common_cack_value,
11528 : : (void *)&cmd_set_conntrack_common_last_dir,
11529 : : (void *)&cmd_set_conntrack_common_last_dir_value,
11530 : : (void *)&cmd_set_conntrack_common_liberal,
11531 : : (void *)&cmd_set_conntrack_common_liberal_value,
11532 : : (void *)&cmd_set_conntrack_common_state,
11533 : : (void *)&cmd_set_conntrack_common_state_value,
11534 : : (void *)&cmd_set_conntrack_common_max_ackwin,
11535 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
11536 : : (void *)&cmd_set_conntrack_common_retrans,
11537 : : (void *)&cmd_set_conntrack_common_retrans_value,
11538 : : (void *)&cmd_set_conntrack_common_last_win,
11539 : : (void *)&cmd_set_conntrack_common_last_win_value,
11540 : : (void *)&cmd_set_conntrack_common_last_seq,
11541 : : (void *)&cmd_set_conntrack_common_last_seq_value,
11542 : : (void *)&cmd_set_conntrack_common_last_ack,
11543 : : (void *)&cmd_set_conntrack_common_last_ack_value,
11544 : : (void *)&cmd_set_conntrack_common_last_end,
11545 : : (void *)&cmd_set_conntrack_common_last_end_value,
11546 : : (void *)&cmd_set_conntrack_common_last_index,
11547 : : (void *)&cmd_set_conntrack_common_last_index_value,
11548 : : NULL,
11549 : : },
11550 : : };
11551 : :
11552 : : /** Set connection tracking object both directions' details */
11553 : : struct cmd_set_conntrack_dir_result {
11554 : : cmdline_fixed_string_t set;
11555 : : cmdline_fixed_string_t conntrack;
11556 : : cmdline_fixed_string_t dir;
11557 : : cmdline_fixed_string_t scale;
11558 : : cmdline_fixed_string_t fin;
11559 : : cmdline_fixed_string_t ack_seen;
11560 : : cmdline_fixed_string_t unack;
11561 : : cmdline_fixed_string_t sent_end;
11562 : : cmdline_fixed_string_t reply_end;
11563 : : cmdline_fixed_string_t max_win;
11564 : : cmdline_fixed_string_t max_ack;
11565 : : uint32_t factor;
11566 : : uint32_t f;
11567 : : uint32_t as;
11568 : : uint32_t un;
11569 : : uint32_t se;
11570 : : uint32_t re;
11571 : : uint32_t mw;
11572 : : uint32_t ma;
11573 : : };
11574 : :
11575 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
11576 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11577 : : dir, "orig#rply");
11578 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
11579 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11580 : : scale, "scale");
11581 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
11582 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11583 : : factor, RTE_UINT32);
11584 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
11585 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11586 : : fin, "fin");
11587 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
11588 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11589 : : f, RTE_UINT32);
11590 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
11591 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11592 : : ack_seen, "acked");
11593 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
11594 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11595 : : as, RTE_UINT32);
11596 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
11597 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11598 : : unack, "unack_data");
11599 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
11600 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11601 : : un, RTE_UINT32);
11602 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
11603 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11604 : : sent_end, "sent_end");
11605 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
11606 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11607 : : se, RTE_UINT32);
11608 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
11609 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11610 : : reply_end, "reply_end");
11611 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
11612 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11613 : : re, RTE_UINT32);
11614 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
11615 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11616 : : max_win, "max_win");
11617 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
11618 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11619 : : mw, RTE_UINT32);
11620 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
11621 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11622 : : max_ack, "max_ack");
11623 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
11624 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11625 : : ma, RTE_UINT32);
11626 : :
11627 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
11628 : : __rte_unused struct cmdline *cl,
11629 : : __rte_unused void *data)
11630 : : {
11631 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
11632 : : struct rte_flow_tcp_dir_param *dir = NULL;
11633 : :
11634 : 0 : if (strcmp(res->dir, "orig") == 0)
11635 : : dir = &conntrack_context.original_dir;
11636 : 0 : else if (strcmp(res->dir, "rply") == 0)
11637 : : dir = &conntrack_context.reply_dir;
11638 : : else
11639 : : return;
11640 : 0 : dir->scale = res->factor;
11641 : 0 : dir->close_initiated = res->f;
11642 : 0 : dir->last_ack_seen = res->as;
11643 : 0 : dir->data_unacked = res->un;
11644 : 0 : dir->sent_end = res->se;
11645 : 0 : dir->reply_end = res->re;
11646 : 0 : dir->max_ack = res->ma;
11647 : 0 : dir->max_win = res->mw;
11648 : : }
11649 : :
11650 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
11651 : : .f = cmd_set_conntrack_dir_parsed,
11652 : : .data = NULL,
11653 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
11654 : : " acked <seen> unack_data <unack> sent_end <sent>"
11655 : : " reply_end <reply> max_win <win> max_ack <ack>",
11656 : : .tokens = {
11657 : : (void *)&cmd_set_conntrack_set,
11658 : : (void *)&cmd_set_conntrack_conntrack,
11659 : : (void *)&cmd_set_conntrack_dir_dir,
11660 : : (void *)&cmd_set_conntrack_dir_scale,
11661 : : (void *)&cmd_set_conntrack_dir_scale_value,
11662 : : (void *)&cmd_set_conntrack_dir_fin,
11663 : : (void *)&cmd_set_conntrack_dir_fin_value,
11664 : : (void *)&cmd_set_conntrack_dir_ack,
11665 : : (void *)&cmd_set_conntrack_dir_ack_value,
11666 : : (void *)&cmd_set_conntrack_dir_unack_data,
11667 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
11668 : : (void *)&cmd_set_conntrack_dir_sent_end,
11669 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
11670 : : (void *)&cmd_set_conntrack_dir_reply_end,
11671 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
11672 : : (void *)&cmd_set_conntrack_dir_max_win,
11673 : : (void *)&cmd_set_conntrack_dir_max_win_value,
11674 : : (void *)&cmd_set_conntrack_dir_max_ack,
11675 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
11676 : : NULL,
11677 : : },
11678 : : };
11679 : :
11680 : : /* show vf stats */
11681 : :
11682 : : /* Common result structure for show vf stats */
11683 : : struct cmd_show_vf_stats_result {
11684 : : cmdline_fixed_string_t show;
11685 : : cmdline_fixed_string_t vf;
11686 : : cmdline_fixed_string_t stats;
11687 : : portid_t port_id;
11688 : : uint16_t vf_id;
11689 : : };
11690 : :
11691 : : /* Common CLI fields show vf stats*/
11692 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
11693 : : TOKEN_STRING_INITIALIZER
11694 : : (struct cmd_show_vf_stats_result,
11695 : : show, "show");
11696 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
11697 : : TOKEN_STRING_INITIALIZER
11698 : : (struct cmd_show_vf_stats_result,
11699 : : vf, "vf");
11700 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
11701 : : TOKEN_STRING_INITIALIZER
11702 : : (struct cmd_show_vf_stats_result,
11703 : : stats, "stats");
11704 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
11705 : : TOKEN_NUM_INITIALIZER
11706 : : (struct cmd_show_vf_stats_result,
11707 : : port_id, RTE_UINT16);
11708 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
11709 : : TOKEN_NUM_INITIALIZER
11710 : : (struct cmd_show_vf_stats_result,
11711 : : vf_id, RTE_UINT16);
11712 : :
11713 : : static void
11714 : 0 : cmd_show_vf_stats_parsed(
11715 : : void *parsed_result,
11716 : : __rte_unused struct cmdline *cl,
11717 : : __rte_unused void *data)
11718 : : {
11719 : : struct cmd_show_vf_stats_result *res = parsed_result;
11720 : : struct rte_eth_stats stats;
11721 : : int ret = -ENOTSUP;
11722 : : static const char *nic_stats_border = "########################";
11723 : :
11724 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11725 : 0 : return;
11726 : :
11727 : : memset(&stats, 0, sizeof(stats));
11728 : :
11729 : : #ifdef RTE_NET_I40E
11730 : : if (ret == -ENOTSUP)
11731 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
11732 : 0 : res->vf_id,
11733 : : &stats);
11734 : : #endif
11735 : : #ifdef RTE_NET_BNXT
11736 : 0 : if (ret == -ENOTSUP)
11737 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
11738 : 0 : res->vf_id,
11739 : : &stats);
11740 : : #endif
11741 : :
11742 : 0 : switch (ret) {
11743 : : case 0:
11744 : : break;
11745 : 0 : case -EINVAL:
11746 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11747 : : break;
11748 : 0 : case -ENODEV:
11749 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11750 : : break;
11751 : 0 : case -ENOTSUP:
11752 : 0 : fprintf(stderr, "function not implemented\n");
11753 : : break;
11754 : 0 : default:
11755 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11756 : : }
11757 : :
11758 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
11759 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
11760 : :
11761 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
11762 : : "%-"PRIu64"\n",
11763 : : stats.ipackets, stats.imissed, stats.ibytes);
11764 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
11765 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
11766 : : stats.rx_nombuf);
11767 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
11768 : : "%-"PRIu64"\n",
11769 : : stats.opackets, stats.oerrors, stats.obytes);
11770 : :
11771 : 0 : printf(" %s############################%s\n",
11772 : : nic_stats_border, nic_stats_border);
11773 : : }
11774 : :
11775 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
11776 : : .f = cmd_show_vf_stats_parsed,
11777 : : .data = NULL,
11778 : : .help_str = "show vf stats <port_id> <vf_id>",
11779 : : .tokens = {
11780 : : (void *)&cmd_show_vf_stats_show,
11781 : : (void *)&cmd_show_vf_stats_vf,
11782 : : (void *)&cmd_show_vf_stats_stats,
11783 : : (void *)&cmd_show_vf_stats_port_id,
11784 : : (void *)&cmd_show_vf_stats_vf_id,
11785 : : NULL,
11786 : : },
11787 : : };
11788 : :
11789 : : /* clear vf stats */
11790 : :
11791 : : /* Common result structure for clear vf stats */
11792 : : struct cmd_clear_vf_stats_result {
11793 : : cmdline_fixed_string_t clear;
11794 : : cmdline_fixed_string_t vf;
11795 : : cmdline_fixed_string_t stats;
11796 : : portid_t port_id;
11797 : : uint16_t vf_id;
11798 : : };
11799 : :
11800 : : /* Common CLI fields clear vf stats*/
11801 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
11802 : : TOKEN_STRING_INITIALIZER
11803 : : (struct cmd_clear_vf_stats_result,
11804 : : clear, "clear");
11805 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
11806 : : TOKEN_STRING_INITIALIZER
11807 : : (struct cmd_clear_vf_stats_result,
11808 : : vf, "vf");
11809 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
11810 : : TOKEN_STRING_INITIALIZER
11811 : : (struct cmd_clear_vf_stats_result,
11812 : : stats, "stats");
11813 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
11814 : : TOKEN_NUM_INITIALIZER
11815 : : (struct cmd_clear_vf_stats_result,
11816 : : port_id, RTE_UINT16);
11817 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
11818 : : TOKEN_NUM_INITIALIZER
11819 : : (struct cmd_clear_vf_stats_result,
11820 : : vf_id, RTE_UINT16);
11821 : :
11822 : : static void
11823 : 0 : cmd_clear_vf_stats_parsed(
11824 : : void *parsed_result,
11825 : : __rte_unused struct cmdline *cl,
11826 : : __rte_unused void *data)
11827 : : {
11828 : : struct cmd_clear_vf_stats_result *res = parsed_result;
11829 : : int ret = -ENOTSUP;
11830 : :
11831 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11832 : : return;
11833 : :
11834 : : #ifdef RTE_NET_I40E
11835 : : if (ret == -ENOTSUP)
11836 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
11837 : 0 : res->vf_id);
11838 : : #endif
11839 : : #ifdef RTE_NET_BNXT
11840 : 0 : if (ret == -ENOTSUP)
11841 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
11842 : 0 : res->vf_id);
11843 : : #endif
11844 : :
11845 : 0 : switch (ret) {
11846 : : case 0:
11847 : : break;
11848 : 0 : case -EINVAL:
11849 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11850 : : break;
11851 : 0 : case -ENODEV:
11852 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11853 : : break;
11854 : 0 : case -ENOTSUP:
11855 : 0 : fprintf(stderr, "function not implemented\n");
11856 : : break;
11857 : 0 : default:
11858 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11859 : : }
11860 : : }
11861 : :
11862 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
11863 : : .f = cmd_clear_vf_stats_parsed,
11864 : : .data = NULL,
11865 : : .help_str = "clear vf stats <port_id> <vf_id>",
11866 : : .tokens = {
11867 : : (void *)&cmd_clear_vf_stats_clear,
11868 : : (void *)&cmd_clear_vf_stats_vf,
11869 : : (void *)&cmd_clear_vf_stats_stats,
11870 : : (void *)&cmd_clear_vf_stats_port_id,
11871 : : (void *)&cmd_clear_vf_stats_vf_id,
11872 : : NULL,
11873 : : },
11874 : : };
11875 : :
11876 : : /* Common result structure for file commands */
11877 : : struct cmd_cmdfile_result {
11878 : : cmdline_fixed_string_t load;
11879 : : cmdline_fixed_string_t filename;
11880 : : };
11881 : :
11882 : : /* Common CLI fields for file commands */
11883 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
11884 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
11885 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
11886 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
11887 : :
11888 : : static void
11889 : 0 : cmd_load_from_file_parsed(
11890 : : void *parsed_result,
11891 : : __rte_unused struct cmdline *cl,
11892 : : __rte_unused void *data)
11893 : : {
11894 : : struct cmd_cmdfile_result *res = parsed_result;
11895 : :
11896 : 0 : if (cmdline_read_from_file(res->filename, false) != 0) {
11897 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
11898 : : }
11899 : 0 : }
11900 : :
11901 : : static cmdline_parse_inst_t cmd_load_from_file = {
11902 : : .f = cmd_load_from_file_parsed,
11903 : : .data = NULL,
11904 : : .help_str = "load <filename>",
11905 : : .tokens = {
11906 : : (void *)&cmd_load_cmdfile,
11907 : : (void *)&cmd_load_cmdfile_filename,
11908 : : NULL,
11909 : : },
11910 : : };
11911 : :
11912 : : /* command to load a file with echoing commands */
11913 : : struct cmd_load_echo_result {
11914 : : cmdline_fixed_string_t load_echo;
11915 : : cmdline_fixed_string_t filename;
11916 : : };
11917 : :
11918 : : /* CLI fields for file load with echo command */
11919 : : static cmdline_parse_token_string_t cmd_load_echo =
11920 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, load_echo, "load_echo");
11921 : : static cmdline_parse_token_string_t cmd_load_echo_filename =
11922 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, filename, NULL);
11923 : :
11924 : : static void
11925 : 0 : cmd_load_echo_file_parsed(
11926 : : void *parsed_result,
11927 : : __rte_unused struct cmdline *cl,
11928 : : __rte_unused void *data)
11929 : : {
11930 : : struct cmd_load_echo_result *res = parsed_result;
11931 : :
11932 : 0 : if (cmdline_read_from_file(res->filename, true) != 0)
11933 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
11934 : 0 : }
11935 : :
11936 : : static cmdline_parse_inst_t cmd_load_echo_file = {
11937 : : .f = cmd_load_echo_file_parsed,
11938 : : .data = NULL,
11939 : : .help_str = "load_echo <filename>",
11940 : : .tokens = {
11941 : : (void *)&cmd_load_echo,
11942 : : (void *)&cmd_load_echo_filename,
11943 : : NULL,
11944 : : },
11945 : : };
11946 : :
11947 : : /* Get Rx offloads capabilities */
11948 : : struct cmd_rx_offload_get_capa_result {
11949 : : cmdline_fixed_string_t show;
11950 : : cmdline_fixed_string_t port;
11951 : : portid_t port_id;
11952 : : cmdline_fixed_string_t rx_offload;
11953 : : cmdline_fixed_string_t capabilities;
11954 : : };
11955 : :
11956 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
11957 : : TOKEN_STRING_INITIALIZER
11958 : : (struct cmd_rx_offload_get_capa_result,
11959 : : show, "show");
11960 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
11961 : : TOKEN_STRING_INITIALIZER
11962 : : (struct cmd_rx_offload_get_capa_result,
11963 : : port, "port");
11964 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
11965 : : TOKEN_NUM_INITIALIZER
11966 : : (struct cmd_rx_offload_get_capa_result,
11967 : : port_id, RTE_UINT16);
11968 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
11969 : : TOKEN_STRING_INITIALIZER
11970 : : (struct cmd_rx_offload_get_capa_result,
11971 : : rx_offload, "rx_offload");
11972 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
11973 : : TOKEN_STRING_INITIALIZER
11974 : : (struct cmd_rx_offload_get_capa_result,
11975 : : capabilities, "capabilities");
11976 : :
11977 : : static void
11978 : 0 : print_rx_offloads(uint64_t offloads)
11979 : : {
11980 : : uint64_t single_offload;
11981 : : int begin;
11982 : : int end;
11983 : : int bit;
11984 : :
11985 : 0 : if (offloads == 0)
11986 : : return;
11987 : :
11988 : : begin = rte_ctz64(offloads);
11989 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11990 : :
11991 : 0 : single_offload = 1ULL << begin;
11992 : 0 : for (bit = begin; bit < end; bit++) {
11993 : 0 : if (offloads & single_offload)
11994 : 0 : printf(" %s",
11995 : : rte_eth_dev_rx_offload_name(single_offload));
11996 : 0 : single_offload <<= 1;
11997 : : }
11998 : : }
11999 : :
12000 : : static void
12001 : 0 : cmd_rx_offload_get_capa_parsed(
12002 : : void *parsed_result,
12003 : : __rte_unused struct cmdline *cl,
12004 : : __rte_unused void *data)
12005 : : {
12006 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
12007 : : struct rte_eth_dev_info dev_info;
12008 : 0 : portid_t port_id = res->port_id;
12009 : : uint64_t queue_offloads;
12010 : : uint64_t port_offloads;
12011 : : int ret;
12012 : :
12013 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12014 : 0 : if (ret != 0)
12015 : 0 : return;
12016 : :
12017 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
12018 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
12019 : :
12020 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
12021 : : printf(" Per Queue :");
12022 : 0 : print_rx_offloads(queue_offloads);
12023 : :
12024 : : printf("\n");
12025 : : printf(" Per Port :");
12026 : 0 : print_rx_offloads(port_offloads);
12027 : : printf("\n\n");
12028 : : }
12029 : :
12030 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
12031 : : .f = cmd_rx_offload_get_capa_parsed,
12032 : : .data = NULL,
12033 : : .help_str = "show port <port_id> rx_offload capabilities",
12034 : : .tokens = {
12035 : : (void *)&cmd_rx_offload_get_capa_show,
12036 : : (void *)&cmd_rx_offload_get_capa_port,
12037 : : (void *)&cmd_rx_offload_get_capa_port_id,
12038 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
12039 : : (void *)&cmd_rx_offload_get_capa_capabilities,
12040 : : NULL,
12041 : : }
12042 : : };
12043 : :
12044 : : /* Get Rx offloads configuration */
12045 : : struct cmd_rx_offload_get_configuration_result {
12046 : : cmdline_fixed_string_t show;
12047 : : cmdline_fixed_string_t port;
12048 : : portid_t port_id;
12049 : : cmdline_fixed_string_t rx_offload;
12050 : : cmdline_fixed_string_t configuration;
12051 : : };
12052 : :
12053 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
12054 : : TOKEN_STRING_INITIALIZER
12055 : : (struct cmd_rx_offload_get_configuration_result,
12056 : : show, "show");
12057 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
12058 : : TOKEN_STRING_INITIALIZER
12059 : : (struct cmd_rx_offload_get_configuration_result,
12060 : : port, "port");
12061 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
12062 : : TOKEN_NUM_INITIALIZER
12063 : : (struct cmd_rx_offload_get_configuration_result,
12064 : : port_id, RTE_UINT16);
12065 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
12066 : : TOKEN_STRING_INITIALIZER
12067 : : (struct cmd_rx_offload_get_configuration_result,
12068 : : rx_offload, "rx_offload");
12069 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
12070 : : TOKEN_STRING_INITIALIZER
12071 : : (struct cmd_rx_offload_get_configuration_result,
12072 : : configuration, "configuration");
12073 : :
12074 : : static void
12075 : 0 : cmd_rx_offload_get_configuration_parsed(
12076 : : void *parsed_result,
12077 : : __rte_unused struct cmdline *cl,
12078 : : __rte_unused void *data)
12079 : : {
12080 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
12081 : : struct rte_eth_dev_info dev_info;
12082 : 0 : portid_t port_id = res->port_id;
12083 : : struct rte_port *port;
12084 : : struct rte_eth_conf dev_conf;
12085 : : uint64_t port_offloads;
12086 : : uint64_t queue_offloads;
12087 : : uint16_t nb_rx_queues;
12088 : : int q;
12089 : : int ret;
12090 : :
12091 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12092 : 0 : if (ret != 0)
12093 : 0 : return;
12094 : :
12095 : 0 : port = &ports[port_id];
12096 : : printf("Rx Offloading Configuration of port %d :\n", port_id);
12097 : :
12098 : 0 : port_offloads = dev_conf.rxmode.offloads;
12099 : : printf(" Port :");
12100 : 0 : print_rx_offloads(port_offloads);
12101 : : printf("\n");
12102 : :
12103 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12104 : 0 : if (ret != 0)
12105 : : return;
12106 : :
12107 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12108 : 0 : for (q = 0; q < nb_rx_queues; q++) {
12109 : 0 : queue_offloads = port->rxq[q].conf.offloads;
12110 : : printf(" Queue[%2d] :", q);
12111 : 0 : print_rx_offloads(queue_offloads);
12112 : : printf("\n");
12113 : : }
12114 : : printf("\n");
12115 : : }
12116 : :
12117 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
12118 : : .f = cmd_rx_offload_get_configuration_parsed,
12119 : : .data = NULL,
12120 : : .help_str = "show port <port_id> rx_offload configuration",
12121 : : .tokens = {
12122 : : (void *)&cmd_rx_offload_get_configuration_show,
12123 : : (void *)&cmd_rx_offload_get_configuration_port,
12124 : : (void *)&cmd_rx_offload_get_configuration_port_id,
12125 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
12126 : : (void *)&cmd_rx_offload_get_configuration_configuration,
12127 : : NULL,
12128 : : }
12129 : : };
12130 : :
12131 : : /* Enable/Disable a per port offloading */
12132 : : struct cmd_config_per_port_rx_offload_result {
12133 : : cmdline_fixed_string_t port;
12134 : : cmdline_fixed_string_t config;
12135 : : portid_t port_id;
12136 : : cmdline_fixed_string_t rx_offload;
12137 : : cmdline_fixed_string_t offload;
12138 : : cmdline_fixed_string_t on_off;
12139 : : };
12140 : :
12141 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
12142 : : TOKEN_STRING_INITIALIZER
12143 : : (struct cmd_config_per_port_rx_offload_result,
12144 : : port, "port");
12145 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
12146 : : TOKEN_STRING_INITIALIZER
12147 : : (struct cmd_config_per_port_rx_offload_result,
12148 : : config, "config");
12149 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
12150 : : TOKEN_NUM_INITIALIZER
12151 : : (struct cmd_config_per_port_rx_offload_result,
12152 : : port_id, RTE_UINT16);
12153 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
12154 : : TOKEN_STRING_INITIALIZER
12155 : : (struct cmd_config_per_port_rx_offload_result,
12156 : : rx_offload, "rx_offload");
12157 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
12158 : : TOKEN_STRING_INITIALIZER
12159 : : (struct cmd_config_per_port_rx_offload_result,
12160 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12161 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12162 : : "vlan_filter#vlan_extend#"
12163 : : "scatter#buffer_split#timestamp#security#"
12164 : : "keep_crc#rss_hash");
12165 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
12166 : : TOKEN_STRING_INITIALIZER
12167 : : (struct cmd_config_per_port_rx_offload_result,
12168 : : on_off, "on#off");
12169 : :
12170 : : static uint64_t
12171 : 0 : search_rx_offload(const char *name)
12172 : : {
12173 : : uint64_t single_offload;
12174 : : const char *single_name;
12175 : : int found = 0;
12176 : : unsigned int bit;
12177 : :
12178 : : single_offload = 1;
12179 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12180 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
12181 : 0 : if (!strcasecmp(single_name, name)) {
12182 : : found = 1;
12183 : : break;
12184 : : }
12185 : 0 : single_offload <<= 1;
12186 : : }
12187 : :
12188 : 0 : if (found)
12189 : 0 : return single_offload;
12190 : :
12191 : : return 0;
12192 : : }
12193 : :
12194 : : static void
12195 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
12196 : : {
12197 : : struct rte_eth_dev_info dev_info;
12198 : : struct rte_port *port;
12199 : : uint16_t nb_rx_queues;
12200 : : uint64_t offload;
12201 : : int q;
12202 : : int ret;
12203 : :
12204 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12205 : 0 : if (ret != 0)
12206 : 0 : return;
12207 : :
12208 : 0 : port = &ports[port_id];
12209 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12210 : 0 : fprintf(stderr,
12211 : : "Error: Can't config offload when Port %d is not stopped\n",
12212 : : port_id);
12213 : 0 : return;
12214 : : }
12215 : :
12216 : 0 : if (!strcmp(name, "all")) {
12217 : 0 : offload = dev_info.rx_offload_capa;
12218 : : } else {
12219 : 0 : offload = search_rx_offload(name);
12220 : 0 : if (offload == 0) {
12221 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12222 : 0 : return;
12223 : : }
12224 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
12225 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12226 : : port_id, name);
12227 : 0 : return;
12228 : : }
12229 : : }
12230 : :
12231 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12232 : 0 : if (on) {
12233 : 0 : port->dev_conf.rxmode.offloads |= offload;
12234 : 0 : for (q = 0; q < nb_rx_queues; q++)
12235 : 0 : port->rxq[q].conf.offloads |= offload;
12236 : : } else {
12237 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
12238 : 0 : for (q = 0; q < nb_rx_queues; q++)
12239 : 0 : port->rxq[q].conf.offloads &= ~offload;
12240 : : }
12241 : :
12242 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12243 : : }
12244 : :
12245 : : static void
12246 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
12247 : : __rte_unused struct cmdline *cl,
12248 : : __rte_unused void *data)
12249 : : {
12250 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
12251 : : bool on;
12252 : :
12253 : 0 : on = strcmp(res->on_off, "on") == 0;
12254 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
12255 : 0 : }
12256 : :
12257 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
12258 : : .f = cmd_config_per_port_rx_offload_parsed,
12259 : : .data = NULL,
12260 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
12261 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12262 : : "macsec_strip|vlan_filter|vlan_extend|"
12263 : : "scatter|buffer_split|timestamp|security|"
12264 : : "keep_crc|rss_hash on|off",
12265 : : .tokens = {
12266 : : (void *)&cmd_config_per_port_rx_offload_result_port,
12267 : : (void *)&cmd_config_per_port_rx_offload_result_config,
12268 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
12269 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
12270 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
12271 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
12272 : : NULL,
12273 : : }
12274 : : };
12275 : :
12276 : : /* Enable/Disable all port Rx offloading */
12277 : : struct cmd_config_all_port_rx_offload_result {
12278 : : cmdline_fixed_string_t port;
12279 : : cmdline_fixed_string_t config;
12280 : : cmdline_fixed_string_t port_all;
12281 : : cmdline_fixed_string_t rx_offload;
12282 : : cmdline_fixed_string_t offload;
12283 : : cmdline_fixed_string_t on_off;
12284 : : };
12285 : :
12286 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
12287 : : TOKEN_STRING_INITIALIZER
12288 : : (struct cmd_config_all_port_rx_offload_result,
12289 : : port, "port");
12290 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
12291 : : TOKEN_STRING_INITIALIZER
12292 : : (struct cmd_config_all_port_rx_offload_result,
12293 : : config, "config");
12294 : :
12295 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
12296 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
12297 : : port_all, "all");
12298 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
12299 : : TOKEN_STRING_INITIALIZER
12300 : : (struct cmd_config_all_port_rx_offload_result,
12301 : : rx_offload, "rx_offload");
12302 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
12303 : : TOKEN_STRING_INITIALIZER
12304 : : (struct cmd_config_all_port_rx_offload_result,
12305 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12306 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12307 : : "vlan_filter#vlan_extend#"
12308 : : "scatter#buffer_split#timestamp#security#"
12309 : : "keep_crc#rss_hash");
12310 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
12311 : : TOKEN_STRING_INITIALIZER
12312 : : (struct cmd_config_all_port_rx_offload_result,
12313 : : on_off, "on#off");
12314 : :
12315 : : static void
12316 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
12317 : : __rte_unused struct cmdline *cl,
12318 : : __rte_unused void *data)
12319 : : {
12320 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
12321 : : bool on_off;
12322 : : portid_t i;
12323 : :
12324 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12325 : 0 : RTE_ETH_FOREACH_DEV(i)
12326 : 0 : config_port_rx_offload(i, res->offload, on_off);
12327 : :
12328 : 0 : }
12329 : :
12330 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
12331 : : .f = cmd_config_all_port_rx_offload_parsed,
12332 : : .data = NULL,
12333 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
12334 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12335 : : "macsec_strip|vlan_filter|vlan_extend|"
12336 : : "scatter|buffer_split|timestamp|security|"
12337 : : "keep_crc|rss_hash on|off",
12338 : : .tokens = {
12339 : : (void *)&cmd_config_all_port_rx_offload_result_port,
12340 : : (void *)&cmd_config_all_port_rx_offload_result_config,
12341 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
12342 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
12343 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
12344 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
12345 : : NULL,
12346 : : }
12347 : : };
12348 : :
12349 : : /* Enable/Disable a per queue offloading */
12350 : : struct cmd_config_per_queue_rx_offload_result {
12351 : : cmdline_fixed_string_t port;
12352 : : portid_t port_id;
12353 : : cmdline_fixed_string_t rxq;
12354 : : uint16_t queue_id;
12355 : : cmdline_fixed_string_t rx_offload;
12356 : : cmdline_fixed_string_t offload;
12357 : : cmdline_fixed_string_t on_off;
12358 : : };
12359 : :
12360 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
12361 : : TOKEN_STRING_INITIALIZER
12362 : : (struct cmd_config_per_queue_rx_offload_result,
12363 : : port, "port");
12364 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
12365 : : TOKEN_NUM_INITIALIZER
12366 : : (struct cmd_config_per_queue_rx_offload_result,
12367 : : port_id, RTE_UINT16);
12368 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
12369 : : TOKEN_STRING_INITIALIZER
12370 : : (struct cmd_config_per_queue_rx_offload_result,
12371 : : rxq, "rxq");
12372 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
12373 : : TOKEN_NUM_INITIALIZER
12374 : : (struct cmd_config_per_queue_rx_offload_result,
12375 : : queue_id, RTE_UINT16);
12376 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
12377 : : TOKEN_STRING_INITIALIZER
12378 : : (struct cmd_config_per_queue_rx_offload_result,
12379 : : rx_offload, "rx_offload");
12380 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
12381 : : TOKEN_STRING_INITIALIZER
12382 : : (struct cmd_config_per_queue_rx_offload_result,
12383 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12384 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12385 : : "vlan_filter#vlan_extend#"
12386 : : "scatter#buffer_split#timestamp#security#keep_crc");
12387 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
12388 : : TOKEN_STRING_INITIALIZER
12389 : : (struct cmd_config_per_queue_rx_offload_result,
12390 : : on_off, "on#off");
12391 : :
12392 : : static void
12393 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
12394 : : __rte_unused struct cmdline *cl,
12395 : : __rte_unused void *data)
12396 : : {
12397 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
12398 : : struct rte_eth_dev_info dev_info;
12399 : 0 : portid_t port_id = res->port_id;
12400 : 0 : uint16_t queue_id = res->queue_id;
12401 : : struct rte_port *port;
12402 : : uint64_t offload;
12403 : : int ret;
12404 : :
12405 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12406 : 0 : if (ret != 0)
12407 : 0 : return;
12408 : :
12409 : 0 : port = &ports[port_id];
12410 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12411 : 0 : fprintf(stderr,
12412 : : "Error: Can't config offload when Port %d is not stopped\n",
12413 : : port_id);
12414 : 0 : return;
12415 : : }
12416 : :
12417 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
12418 : 0 : fprintf(stderr,
12419 : : "Error: input queue_id should be 0 ... %d\n",
12420 : 0 : dev_info.nb_rx_queues - 1);
12421 : 0 : return;
12422 : : }
12423 : :
12424 : 0 : if (!strcmp(res->offload, "all")) {
12425 : 0 : offload = dev_info.rx_queue_offload_capa;
12426 : : } else {
12427 : 0 : offload = search_rx_offload(res->offload);
12428 : 0 : if (offload == 0) {
12429 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12430 : 0 : return;
12431 : : }
12432 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
12433 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12434 : : port_id, res->offload);
12435 : 0 : return;
12436 : : }
12437 : : }
12438 : :
12439 : 0 : if (!strcmp(res->on_off, "on"))
12440 : 0 : port->rxq[queue_id].conf.offloads |= offload;
12441 : : else
12442 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
12443 : :
12444 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12445 : : }
12446 : :
12447 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
12448 : : .f = cmd_config_per_queue_rx_offload_parsed,
12449 : : .data = NULL,
12450 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
12451 : : "all|vlan_strip|ipv4_cksum|"
12452 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12453 : : "macsec_strip|vlan_filter|vlan_extend|"
12454 : : "scatter|buffer_split|timestamp|security|"
12455 : : "keep_crc on|off",
12456 : : .tokens = {
12457 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
12458 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
12459 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
12460 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
12461 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
12462 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
12463 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
12464 : : NULL,
12465 : : }
12466 : : };
12467 : :
12468 : : /* Get Tx offloads capabilities */
12469 : : struct cmd_tx_offload_get_capa_result {
12470 : : cmdline_fixed_string_t show;
12471 : : cmdline_fixed_string_t port;
12472 : : portid_t port_id;
12473 : : cmdline_fixed_string_t tx_offload;
12474 : : cmdline_fixed_string_t capabilities;
12475 : : };
12476 : :
12477 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
12478 : : TOKEN_STRING_INITIALIZER
12479 : : (struct cmd_tx_offload_get_capa_result,
12480 : : show, "show");
12481 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
12482 : : TOKEN_STRING_INITIALIZER
12483 : : (struct cmd_tx_offload_get_capa_result,
12484 : : port, "port");
12485 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
12486 : : TOKEN_NUM_INITIALIZER
12487 : : (struct cmd_tx_offload_get_capa_result,
12488 : : port_id, RTE_UINT16);
12489 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
12490 : : TOKEN_STRING_INITIALIZER
12491 : : (struct cmd_tx_offload_get_capa_result,
12492 : : tx_offload, "tx_offload");
12493 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
12494 : : TOKEN_STRING_INITIALIZER
12495 : : (struct cmd_tx_offload_get_capa_result,
12496 : : capabilities, "capabilities");
12497 : :
12498 : : static void
12499 : 0 : print_tx_offloads(uint64_t offloads)
12500 : : {
12501 : : uint64_t single_offload;
12502 : : int begin;
12503 : : int end;
12504 : : int bit;
12505 : :
12506 : 0 : if (offloads == 0)
12507 : : return;
12508 : :
12509 : : begin = rte_ctz64(offloads);
12510 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12511 : :
12512 : 0 : single_offload = 1ULL << begin;
12513 : 0 : for (bit = begin; bit < end; bit++) {
12514 : 0 : if (offloads & single_offload)
12515 : 0 : printf(" %s",
12516 : : rte_eth_dev_tx_offload_name(single_offload));
12517 : 0 : single_offload <<= 1;
12518 : : }
12519 : : }
12520 : :
12521 : : static void
12522 : 0 : cmd_tx_offload_get_capa_parsed(
12523 : : void *parsed_result,
12524 : : __rte_unused struct cmdline *cl,
12525 : : __rte_unused void *data)
12526 : : {
12527 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
12528 : : struct rte_eth_dev_info dev_info;
12529 : 0 : portid_t port_id = res->port_id;
12530 : : uint64_t queue_offloads;
12531 : : uint64_t port_offloads;
12532 : : int ret;
12533 : :
12534 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12535 : 0 : if (ret != 0)
12536 : 0 : return;
12537 : :
12538 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
12539 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
12540 : :
12541 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
12542 : : printf(" Per Queue :");
12543 : 0 : print_tx_offloads(queue_offloads);
12544 : :
12545 : : printf("\n");
12546 : : printf(" Per Port :");
12547 : 0 : print_tx_offloads(port_offloads);
12548 : : printf("\n\n");
12549 : : }
12550 : :
12551 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
12552 : : .f = cmd_tx_offload_get_capa_parsed,
12553 : : .data = NULL,
12554 : : .help_str = "show port <port_id> tx_offload capabilities",
12555 : : .tokens = {
12556 : : (void *)&cmd_tx_offload_get_capa_show,
12557 : : (void *)&cmd_tx_offload_get_capa_port,
12558 : : (void *)&cmd_tx_offload_get_capa_port_id,
12559 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
12560 : : (void *)&cmd_tx_offload_get_capa_capabilities,
12561 : : NULL,
12562 : : }
12563 : : };
12564 : :
12565 : : /* Get Tx offloads configuration */
12566 : : struct cmd_tx_offload_get_configuration_result {
12567 : : cmdline_fixed_string_t show;
12568 : : cmdline_fixed_string_t port;
12569 : : portid_t port_id;
12570 : : cmdline_fixed_string_t tx_offload;
12571 : : cmdline_fixed_string_t configuration;
12572 : : };
12573 : :
12574 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
12575 : : TOKEN_STRING_INITIALIZER
12576 : : (struct cmd_tx_offload_get_configuration_result,
12577 : : show, "show");
12578 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
12579 : : TOKEN_STRING_INITIALIZER
12580 : : (struct cmd_tx_offload_get_configuration_result,
12581 : : port, "port");
12582 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
12583 : : TOKEN_NUM_INITIALIZER
12584 : : (struct cmd_tx_offload_get_configuration_result,
12585 : : port_id, RTE_UINT16);
12586 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
12587 : : TOKEN_STRING_INITIALIZER
12588 : : (struct cmd_tx_offload_get_configuration_result,
12589 : : tx_offload, "tx_offload");
12590 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
12591 : : TOKEN_STRING_INITIALIZER
12592 : : (struct cmd_tx_offload_get_configuration_result,
12593 : : configuration, "configuration");
12594 : :
12595 : : static void
12596 : 0 : cmd_tx_offload_get_configuration_parsed(
12597 : : void *parsed_result,
12598 : : __rte_unused struct cmdline *cl,
12599 : : __rte_unused void *data)
12600 : : {
12601 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
12602 : : struct rte_eth_dev_info dev_info;
12603 : 0 : portid_t port_id = res->port_id;
12604 : : struct rte_port *port;
12605 : : struct rte_eth_conf dev_conf;
12606 : : uint64_t port_offloads;
12607 : : uint64_t queue_offloads;
12608 : : uint16_t nb_tx_queues;
12609 : : int q;
12610 : : int ret;
12611 : :
12612 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12613 : 0 : if (ret != 0)
12614 : 0 : return;
12615 : :
12616 : : printf("Tx Offloading Configuration of port %d :\n", port_id);
12617 : 0 : port = &ports[port_id];
12618 : 0 : port_offloads = dev_conf.txmode.offloads;
12619 : : printf(" Port :");
12620 : 0 : print_tx_offloads(port_offloads);
12621 : : printf("\n");
12622 : :
12623 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12624 : 0 : if (ret != 0)
12625 : : return;
12626 : :
12627 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12628 : 0 : for (q = 0; q < nb_tx_queues; q++) {
12629 : 0 : queue_offloads = port->txq[q].conf.offloads;
12630 : : printf(" Queue[%2d] :", q);
12631 : 0 : print_tx_offloads(queue_offloads);
12632 : : printf("\n");
12633 : : }
12634 : : printf("\n");
12635 : : }
12636 : :
12637 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
12638 : : .f = cmd_tx_offload_get_configuration_parsed,
12639 : : .data = NULL,
12640 : : .help_str = "show port <port_id> tx_offload configuration",
12641 : : .tokens = {
12642 : : (void *)&cmd_tx_offload_get_configuration_show,
12643 : : (void *)&cmd_tx_offload_get_configuration_port,
12644 : : (void *)&cmd_tx_offload_get_configuration_port_id,
12645 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
12646 : : (void *)&cmd_tx_offload_get_configuration_configuration,
12647 : : NULL,
12648 : : }
12649 : : };
12650 : :
12651 : : /* Enable/Disable a per port offloading */
12652 : : struct cmd_config_per_port_tx_offload_result {
12653 : : cmdline_fixed_string_t port;
12654 : : cmdline_fixed_string_t config;
12655 : : portid_t port_id;
12656 : : cmdline_fixed_string_t tx_offload;
12657 : : cmdline_fixed_string_t offload;
12658 : : cmdline_fixed_string_t on_off;
12659 : : };
12660 : :
12661 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
12662 : : TOKEN_STRING_INITIALIZER
12663 : : (struct cmd_config_per_port_tx_offload_result,
12664 : : port, "port");
12665 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
12666 : : TOKEN_STRING_INITIALIZER
12667 : : (struct cmd_config_per_port_tx_offload_result,
12668 : : config, "config");
12669 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
12670 : : TOKEN_NUM_INITIALIZER
12671 : : (struct cmd_config_per_port_tx_offload_result,
12672 : : port_id, RTE_UINT16);
12673 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
12674 : : TOKEN_STRING_INITIALIZER
12675 : : (struct cmd_config_per_port_tx_offload_result,
12676 : : tx_offload, "tx_offload");
12677 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
12678 : : TOKEN_STRING_INITIALIZER
12679 : : (struct cmd_config_per_port_tx_offload_result,
12680 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12681 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12682 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12683 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12684 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12685 : : "send_on_timestamp");
12686 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
12687 : : TOKEN_STRING_INITIALIZER
12688 : : (struct cmd_config_per_port_tx_offload_result,
12689 : : on_off, "on#off");
12690 : :
12691 : : static uint64_t
12692 : 0 : search_tx_offload(const char *name)
12693 : : {
12694 : : uint64_t single_offload;
12695 : : const char *single_name;
12696 : : int found = 0;
12697 : : unsigned int bit;
12698 : :
12699 : : single_offload = 1;
12700 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12701 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
12702 : 0 : if (single_name == NULL)
12703 : : break;
12704 : 0 : if (!strcasecmp(single_name, name)) {
12705 : : found = 1;
12706 : : break;
12707 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
12708 : : break;
12709 : 0 : single_offload <<= 1;
12710 : : }
12711 : :
12712 : 0 : if (found)
12713 : 0 : return single_offload;
12714 : :
12715 : : return 0;
12716 : : }
12717 : :
12718 : : static void
12719 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
12720 : : {
12721 : : struct rte_eth_dev_info dev_info;
12722 : : struct rte_port *port;
12723 : : uint16_t nb_tx_queues;
12724 : : uint64_t offload;
12725 : : int q;
12726 : : int ret;
12727 : :
12728 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12729 : 0 : if (ret != 0)
12730 : 0 : return;
12731 : :
12732 : 0 : port = &ports[port_id];
12733 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12734 : 0 : fprintf(stderr,
12735 : : "Error: Can't config offload when Port %d is not stopped\n",
12736 : : port_id);
12737 : 0 : return;
12738 : : }
12739 : :
12740 : 0 : if (!strcmp(name, "all")) {
12741 : 0 : offload = dev_info.tx_offload_capa;
12742 : : } else {
12743 : 0 : offload = search_tx_offload(name);
12744 : 0 : if (offload == 0) {
12745 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12746 : 0 : return;
12747 : : }
12748 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
12749 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12750 : : port_id, name);
12751 : 0 : return;
12752 : : }
12753 : : }
12754 : :
12755 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12756 : 0 : if (on) {
12757 : 0 : port->dev_conf.txmode.offloads |= offload;
12758 : 0 : for (q = 0; q < nb_tx_queues; q++)
12759 : 0 : port->txq[q].conf.offloads |= offload;
12760 : : } else {
12761 : 0 : port->dev_conf.txmode.offloads &= ~offload;
12762 : 0 : for (q = 0; q < nb_tx_queues; q++)
12763 : 0 : port->txq[q].conf.offloads &= ~offload;
12764 : : }
12765 : :
12766 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12767 : : }
12768 : :
12769 : : static void
12770 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
12771 : : __rte_unused struct cmdline *cl,
12772 : : __rte_unused void *data)
12773 : : {
12774 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
12775 : : bool on;
12776 : :
12777 : 0 : on = strcmp(res->on_off, "on") == 0;
12778 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
12779 : 0 : }
12780 : :
12781 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
12782 : : .f = cmd_config_per_port_tx_offload_parsed,
12783 : : .data = NULL,
12784 : : .help_str = "port config <port_id> tx_offload "
12785 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12786 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12787 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12788 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12789 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12790 : : "send_on_timestamp on|off",
12791 : : .tokens = {
12792 : : (void *)&cmd_config_per_port_tx_offload_result_port,
12793 : : (void *)&cmd_config_per_port_tx_offload_result_config,
12794 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
12795 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
12796 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
12797 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
12798 : : NULL,
12799 : : }
12800 : : };
12801 : :
12802 : : /* Enable/Disable all port Tx offloading */
12803 : : struct cmd_config_all_port_tx_offload_result {
12804 : : cmdline_fixed_string_t port;
12805 : : cmdline_fixed_string_t config;
12806 : : cmdline_fixed_string_t port_all;
12807 : : cmdline_fixed_string_t tx_offload;
12808 : : cmdline_fixed_string_t offload;
12809 : : cmdline_fixed_string_t on_off;
12810 : : };
12811 : :
12812 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
12813 : : TOKEN_STRING_INITIALIZER
12814 : : (struct cmd_config_all_port_tx_offload_result,
12815 : : port, "port");
12816 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
12817 : : TOKEN_STRING_INITIALIZER
12818 : : (struct cmd_config_all_port_tx_offload_result,
12819 : : config, "config");
12820 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
12821 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
12822 : : port_all, "all");
12823 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
12824 : : TOKEN_STRING_INITIALIZER
12825 : : (struct cmd_config_all_port_tx_offload_result,
12826 : : tx_offload, "tx_offload");
12827 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
12828 : : TOKEN_STRING_INITIALIZER
12829 : : (struct cmd_config_all_port_tx_offload_result,
12830 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12831 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12832 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12833 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12834 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12835 : : "send_on_timestamp");
12836 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
12837 : : TOKEN_STRING_INITIALIZER
12838 : : (struct cmd_config_all_port_tx_offload_result,
12839 : : on_off, "on#off");
12840 : :
12841 : : static void
12842 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
12843 : : __rte_unused struct cmdline *cl,
12844 : : __rte_unused void *data)
12845 : : {
12846 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
12847 : : portid_t i;
12848 : : bool on_off;
12849 : :
12850 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12851 : 0 : RTE_ETH_FOREACH_DEV(i)
12852 : 0 : config_port_tx_offload(i, res->offload, on_off);
12853 : 0 : }
12854 : :
12855 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
12856 : : .f = cmd_config_all_port_tx_offload_parsed,
12857 : : .data = NULL,
12858 : : .help_str = "port config all tx_offload "
12859 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12860 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12861 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12862 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12863 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12864 : : "send_on_timestamp on|off",
12865 : : .tokens = {
12866 : : (void *)&cmd_config_all_port_tx_offload_result_port,
12867 : : (void *)&cmd_config_all_port_tx_offload_result_config,
12868 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
12869 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
12870 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
12871 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
12872 : : NULL,
12873 : : }
12874 : : };
12875 : :
12876 : : /* Enable/Disable a per queue offloading */
12877 : : struct cmd_config_per_queue_tx_offload_result {
12878 : : cmdline_fixed_string_t port;
12879 : : portid_t port_id;
12880 : : cmdline_fixed_string_t txq;
12881 : : uint16_t queue_id;
12882 : : cmdline_fixed_string_t tx_offload;
12883 : : cmdline_fixed_string_t offload;
12884 : : cmdline_fixed_string_t on_off;
12885 : : };
12886 : :
12887 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
12888 : : TOKEN_STRING_INITIALIZER
12889 : : (struct cmd_config_per_queue_tx_offload_result,
12890 : : port, "port");
12891 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
12892 : : TOKEN_NUM_INITIALIZER
12893 : : (struct cmd_config_per_queue_tx_offload_result,
12894 : : port_id, RTE_UINT16);
12895 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
12896 : : TOKEN_STRING_INITIALIZER
12897 : : (struct cmd_config_per_queue_tx_offload_result,
12898 : : txq, "txq");
12899 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
12900 : : TOKEN_NUM_INITIALIZER
12901 : : (struct cmd_config_per_queue_tx_offload_result,
12902 : : queue_id, RTE_UINT16);
12903 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
12904 : : TOKEN_STRING_INITIALIZER
12905 : : (struct cmd_config_per_queue_tx_offload_result,
12906 : : tx_offload, "tx_offload");
12907 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
12908 : : TOKEN_STRING_INITIALIZER
12909 : : (struct cmd_config_per_queue_tx_offload_result,
12910 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12911 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12912 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12913 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12914 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
12915 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
12916 : : TOKEN_STRING_INITIALIZER
12917 : : (struct cmd_config_per_queue_tx_offload_result,
12918 : : on_off, "on#off");
12919 : :
12920 : : static void
12921 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
12922 : : __rte_unused struct cmdline *cl,
12923 : : __rte_unused void *data)
12924 : : {
12925 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
12926 : : struct rte_eth_dev_info dev_info;
12927 : 0 : portid_t port_id = res->port_id;
12928 : 0 : uint16_t queue_id = res->queue_id;
12929 : : struct rte_port *port;
12930 : : uint64_t offload;
12931 : : int ret;
12932 : :
12933 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12934 : 0 : if (ret != 0)
12935 : 0 : return;
12936 : :
12937 : 0 : port = &ports[port_id];
12938 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12939 : 0 : fprintf(stderr,
12940 : : "Error: Can't config offload when Port %d is not stopped\n",
12941 : : port_id);
12942 : 0 : return;
12943 : : }
12944 : :
12945 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
12946 : 0 : fprintf(stderr,
12947 : : "Error: input queue_id should be 0 ... %d\n",
12948 : 0 : dev_info.nb_tx_queues - 1);
12949 : 0 : return;
12950 : : }
12951 : :
12952 : 0 : if (!strcmp(res->offload, "all")) {
12953 : 0 : offload = dev_info.tx_queue_offload_capa;
12954 : : } else {
12955 : 0 : offload = search_tx_offload(res->offload);
12956 : 0 : if (offload == 0) {
12957 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12958 : 0 : return;
12959 : : }
12960 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
12961 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12962 : : port_id, res->offload);
12963 : 0 : return;
12964 : : }
12965 : : }
12966 : :
12967 : 0 : if (!strcmp(res->on_off, "on"))
12968 : 0 : port->txq[queue_id].conf.offloads |= offload;
12969 : : else
12970 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
12971 : :
12972 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12973 : : }
12974 : :
12975 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
12976 : : .f = cmd_config_per_queue_tx_offload_parsed,
12977 : : .data = NULL,
12978 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
12979 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12980 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12981 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12982 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12983 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
12984 : : "on|off",
12985 : : .tokens = {
12986 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
12987 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
12988 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
12989 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
12990 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
12991 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
12992 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
12993 : : NULL,
12994 : : }
12995 : : };
12996 : :
12997 : : /* *** configure tx_metadata for specific port *** */
12998 : : struct cmd_config_tx_metadata_specific_result {
12999 : : cmdline_fixed_string_t port;
13000 : : cmdline_fixed_string_t keyword;
13001 : : uint16_t port_id;
13002 : : cmdline_fixed_string_t item;
13003 : : uint32_t value;
13004 : : };
13005 : :
13006 : : static void
13007 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
13008 : : __rte_unused struct cmdline *cl,
13009 : : __rte_unused void *data)
13010 : : {
13011 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
13012 : :
13013 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13014 : : return;
13015 : 0 : ports[res->port_id].tx_metadata = res->value;
13016 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
13017 : 0 : if (ports[res->port_id].tx_metadata)
13018 : 0 : add_tx_md_callback(res->port_id);
13019 : : else
13020 : 0 : remove_tx_md_callback(res->port_id);
13021 : 0 : rte_flow_dynf_metadata_register();
13022 : : }
13023 : :
13024 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
13025 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13026 : : port, "port");
13027 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
13028 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13029 : : keyword, "config");
13030 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
13031 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13032 : : port_id, RTE_UINT16);
13033 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
13034 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13035 : : item, "tx_metadata");
13036 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
13037 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13038 : : value, RTE_UINT32);
13039 : :
13040 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
13041 : : .f = cmd_config_tx_metadata_specific_parsed,
13042 : : .data = NULL,
13043 : : .help_str = "port config <port_id> tx_metadata <value>",
13044 : : .tokens = {
13045 : : (void *)&cmd_config_tx_metadata_specific_port,
13046 : : (void *)&cmd_config_tx_metadata_specific_keyword,
13047 : : (void *)&cmd_config_tx_metadata_specific_id,
13048 : : (void *)&cmd_config_tx_metadata_specific_item,
13049 : : (void *)&cmd_config_tx_metadata_specific_value,
13050 : : NULL,
13051 : : },
13052 : : };
13053 : :
13054 : : /* *** set dynf *** */
13055 : : struct cmd_config_tx_dynf_specific_result {
13056 : : cmdline_fixed_string_t port;
13057 : : cmdline_fixed_string_t keyword;
13058 : : uint16_t port_id;
13059 : : cmdline_fixed_string_t item;
13060 : : cmdline_fixed_string_t name;
13061 : : cmdline_fixed_string_t value;
13062 : : };
13063 : :
13064 : : static void
13065 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
13066 : : __rte_unused struct cmdline *cl,
13067 : : __rte_unused void *data)
13068 : : {
13069 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
13070 : : struct rte_mbuf_dynflag desc_flag;
13071 : : int flag;
13072 : : uint64_t old_port_flags;
13073 : :
13074 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13075 : 0 : return;
13076 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
13077 : 0 : if (flag <= 0) {
13078 : 0 : if (strlcpy(desc_flag.name, res->name,
13079 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
13080 : 0 : fprintf(stderr, "Flag name too long\n");
13081 : 0 : return;
13082 : : }
13083 : 0 : desc_flag.flags = 0;
13084 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
13085 : 0 : if (flag < 0) {
13086 : 0 : fprintf(stderr, "Can't register flag\n");
13087 : 0 : return;
13088 : : }
13089 : 0 : strcpy(dynf_names[flag], desc_flag.name);
13090 : : }
13091 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
13092 : 0 : if (!strcmp(res->value, "set")) {
13093 : 0 : ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
13094 : 0 : if (old_port_flags == 0)
13095 : 0 : add_tx_dynf_callback(res->port_id);
13096 : : } else {
13097 : 0 : ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
13098 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
13099 : 0 : remove_tx_dynf_callback(res->port_id);
13100 : : }
13101 : : }
13102 : :
13103 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
13104 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13105 : : keyword, "port");
13106 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
13107 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13108 : : keyword, "config");
13109 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
13110 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13111 : : port_id, RTE_UINT16);
13112 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
13113 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13114 : : item, "dynf");
13115 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
13116 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13117 : : name, NULL);
13118 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
13119 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13120 : : value, "set#clear");
13121 : :
13122 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
13123 : : .f = cmd_config_dynf_specific_parsed,
13124 : : .data = NULL,
13125 : : .help_str = "port config <port id> dynf <name> set|clear",
13126 : : .tokens = {
13127 : : (void *)&cmd_config_tx_dynf_specific_port,
13128 : : (void *)&cmd_config_tx_dynf_specific_keyword,
13129 : : (void *)&cmd_config_tx_dynf_specific_port_id,
13130 : : (void *)&cmd_config_tx_dynf_specific_item,
13131 : : (void *)&cmd_config_tx_dynf_specific_name,
13132 : : (void *)&cmd_config_tx_dynf_specific_value,
13133 : : NULL,
13134 : : },
13135 : : };
13136 : :
13137 : : /* *** display tx_metadata per port configuration *** */
13138 : : struct cmd_show_tx_metadata_result {
13139 : : cmdline_fixed_string_t cmd_show;
13140 : : cmdline_fixed_string_t cmd_port;
13141 : : cmdline_fixed_string_t cmd_keyword;
13142 : : portid_t cmd_pid;
13143 : : };
13144 : :
13145 : : static void
13146 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
13147 : : __rte_unused struct cmdline *cl,
13148 : : __rte_unused void *data)
13149 : : {
13150 : : struct cmd_show_tx_metadata_result *res = parsed_result;
13151 : :
13152 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13153 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
13154 : 0 : return;
13155 : : }
13156 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
13157 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
13158 : 0 : ports[res->cmd_pid].tx_metadata);
13159 : : }
13160 : : }
13161 : :
13162 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
13163 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13164 : : cmd_show, "show");
13165 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
13166 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13167 : : cmd_port, "port");
13168 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
13169 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
13170 : : cmd_pid, RTE_UINT16);
13171 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
13172 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13173 : : cmd_keyword, "tx_metadata");
13174 : :
13175 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
13176 : : .f = cmd_show_tx_metadata_parsed,
13177 : : .data = NULL,
13178 : : .help_str = "show port <port_id> tx_metadata",
13179 : : .tokens = {
13180 : : (void *)&cmd_show_tx_metadata_show,
13181 : : (void *)&cmd_show_tx_metadata_port,
13182 : : (void *)&cmd_show_tx_metadata_pid,
13183 : : (void *)&cmd_show_tx_metadata_keyword,
13184 : : NULL,
13185 : : },
13186 : : };
13187 : :
13188 : : /* *** show fec capability per port configuration *** */
13189 : : struct cmd_show_fec_capability_result {
13190 : : cmdline_fixed_string_t cmd_show;
13191 : : cmdline_fixed_string_t cmd_port;
13192 : : cmdline_fixed_string_t cmd_fec;
13193 : : cmdline_fixed_string_t cmd_keyword;
13194 : : portid_t cmd_pid;
13195 : : };
13196 : :
13197 : : static void
13198 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
13199 : : __rte_unused struct cmdline *cl,
13200 : : __rte_unused void *data)
13201 : : {
13202 : : struct cmd_show_fec_capability_result *res = parsed_result;
13203 : : struct rte_eth_fec_capa *speed_fec_capa;
13204 : : unsigned int num;
13205 : : int ret;
13206 : :
13207 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13208 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13209 : 0 : return;
13210 : : }
13211 : :
13212 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
13213 : 0 : if (ret == -ENOTSUP) {
13214 : 0 : fprintf(stderr, "Function not implemented\n");
13215 : 0 : return;
13216 : 0 : } else if (ret < 0) {
13217 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
13218 : 0 : return;
13219 : : }
13220 : :
13221 : 0 : num = (unsigned int)ret;
13222 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
13223 : 0 : if (speed_fec_capa == NULL) {
13224 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
13225 : 0 : return;
13226 : : }
13227 : :
13228 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
13229 : 0 : if (ret < 0) {
13230 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
13231 : 0 : goto out;
13232 : : }
13233 : :
13234 : 0 : show_fec_capability(num, speed_fec_capa);
13235 : 0 : out:
13236 : 0 : free(speed_fec_capa);
13237 : : }
13238 : :
13239 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
13240 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13241 : : cmd_show, "show");
13242 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
13243 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13244 : : cmd_port, "port");
13245 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
13246 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
13247 : : cmd_pid, RTE_UINT16);
13248 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
13249 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13250 : : cmd_fec, "fec");
13251 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
13252 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13253 : : cmd_keyword, "capabilities");
13254 : :
13255 : : static cmdline_parse_inst_t cmd_show_capability = {
13256 : : .f = cmd_show_fec_capability_parsed,
13257 : : .data = NULL,
13258 : : .help_str = "show port <port_id> fec capabilities",
13259 : : .tokens = {
13260 : : (void *)&cmd_show_fec_capability_show,
13261 : : (void *)&cmd_show_fec_capability_port,
13262 : : (void *)&cmd_show_fec_capability_pid,
13263 : : (void *)&cmd_show_fec_capability_fec,
13264 : : (void *)&cmd_show_fec_capability_keyword,
13265 : : NULL,
13266 : : },
13267 : : };
13268 : :
13269 : : /* *** show fec mode per port configuration *** */
13270 : : struct cmd_show_fec_metadata_result {
13271 : : cmdline_fixed_string_t cmd_show;
13272 : : cmdline_fixed_string_t cmd_port;
13273 : : cmdline_fixed_string_t cmd_keyword;
13274 : : portid_t cmd_pid;
13275 : : };
13276 : :
13277 : : static void
13278 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
13279 : : __rte_unused struct cmdline *cl,
13280 : : __rte_unused void *data)
13281 : : {
13282 : : #define FEC_NAME_SIZE 16
13283 : : struct cmd_show_fec_metadata_result *res = parsed_result;
13284 : : uint32_t mode;
13285 : : char buf[FEC_NAME_SIZE];
13286 : : int ret;
13287 : :
13288 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13289 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13290 : 0 : return;
13291 : : }
13292 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
13293 : 0 : if (ret == -ENOTSUP) {
13294 : 0 : fprintf(stderr, "Function not implemented\n");
13295 : 0 : return;
13296 : 0 : } else if (ret < 0) {
13297 : 0 : fprintf(stderr, "Get FEC mode failed\n");
13298 : 0 : return;
13299 : : }
13300 : :
13301 : 0 : switch (mode) {
13302 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
13303 : : strlcpy(buf, "off", sizeof(buf));
13304 : : break;
13305 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
13306 : : strlcpy(buf, "auto", sizeof(buf));
13307 : : break;
13308 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
13309 : : strlcpy(buf, "baser", sizeof(buf));
13310 : : break;
13311 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
13312 : : strlcpy(buf, "rs", sizeof(buf));
13313 : : break;
13314 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
13315 : : strlcpy(buf, "llrs", sizeof(buf));
13316 : : break;
13317 : : default:
13318 : : return;
13319 : : }
13320 : :
13321 : : printf("%s\n", buf);
13322 : : }
13323 : :
13324 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
13325 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13326 : : cmd_show, "show");
13327 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
13328 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13329 : : cmd_port, "port");
13330 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
13331 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
13332 : : cmd_pid, RTE_UINT16);
13333 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
13334 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13335 : : cmd_keyword, "fec_mode");
13336 : :
13337 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
13338 : : .f = cmd_show_fec_mode_parsed,
13339 : : .data = NULL,
13340 : : .help_str = "show port <port_id> fec_mode",
13341 : : .tokens = {
13342 : : (void *)&cmd_show_fec_mode_show,
13343 : : (void *)&cmd_show_fec_mode_port,
13344 : : (void *)&cmd_show_fec_mode_pid,
13345 : : (void *)&cmd_show_fec_mode_keyword,
13346 : : NULL,
13347 : : },
13348 : : };
13349 : :
13350 : : /* *** set fec mode per port configuration *** */
13351 : : struct cmd_set_port_fec_mode {
13352 : : cmdline_fixed_string_t set;
13353 : : cmdline_fixed_string_t port;
13354 : : portid_t port_id;
13355 : : cmdline_fixed_string_t fec_mode;
13356 : : cmdline_fixed_string_t fec_value;
13357 : : };
13358 : :
13359 : : /* Common CLI fields for set fec mode */
13360 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
13361 : : TOKEN_STRING_INITIALIZER
13362 : : (struct cmd_set_port_fec_mode,
13363 : : set, "set");
13364 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
13365 : : TOKEN_STRING_INITIALIZER
13366 : : (struct cmd_set_port_fec_mode,
13367 : : port, "port");
13368 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
13369 : : TOKEN_NUM_INITIALIZER
13370 : : (struct cmd_set_port_fec_mode,
13371 : : port_id, RTE_UINT16);
13372 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
13373 : : TOKEN_STRING_INITIALIZER
13374 : : (struct cmd_set_port_fec_mode,
13375 : : fec_mode, "fec_mode");
13376 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
13377 : : TOKEN_STRING_INITIALIZER
13378 : : (struct cmd_set_port_fec_mode,
13379 : : fec_value, NULL);
13380 : :
13381 : : static void
13382 : 0 : cmd_set_port_fec_mode_parsed(
13383 : : void *parsed_result,
13384 : : __rte_unused struct cmdline *cl,
13385 : : __rte_unused void *data)
13386 : : {
13387 : : struct cmd_set_port_fec_mode *res = parsed_result;
13388 : 0 : uint16_t port_id = res->port_id;
13389 : : uint32_t fec_capa;
13390 : : int ret;
13391 : :
13392 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
13393 : 0 : if (ret < 0) {
13394 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
13395 : : res->fec_value, port_id);
13396 : 0 : return;
13397 : : }
13398 : :
13399 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
13400 : 0 : if (ret == -ENOTSUP) {
13401 : 0 : fprintf(stderr, "Function not implemented\n");
13402 : 0 : return;
13403 : 0 : } else if (ret < 0) {
13404 : 0 : fprintf(stderr, "Set FEC mode failed\n");
13405 : 0 : return;
13406 : : }
13407 : : }
13408 : :
13409 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
13410 : : .f = cmd_set_port_fec_mode_parsed,
13411 : : .data = NULL,
13412 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
13413 : : .tokens = {
13414 : : (void *)&cmd_set_port_fec_mode_set,
13415 : : (void *)&cmd_set_port_fec_mode_port,
13416 : : (void *)&cmd_set_port_fec_mode_port_id,
13417 : : (void *)&cmd_set_port_fec_mode_str,
13418 : : (void *)&cmd_set_port_fec_mode_value,
13419 : : NULL,
13420 : : },
13421 : : };
13422 : :
13423 : : /* *** set available descriptors threshold for an RxQ of a port *** */
13424 : : struct cmd_set_rxq_avail_thresh_result {
13425 : : cmdline_fixed_string_t set;
13426 : : cmdline_fixed_string_t port;
13427 : : uint16_t port_num;
13428 : : cmdline_fixed_string_t rxq;
13429 : : uint16_t rxq_num;
13430 : : cmdline_fixed_string_t avail_thresh;
13431 : : uint8_t avail_thresh_num;
13432 : : };
13433 : :
13434 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
13435 : : __rte_unused struct cmdline *cl,
13436 : : __rte_unused void *data)
13437 : : {
13438 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
13439 : : int ret = 0;
13440 : :
13441 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
13442 : 0 : && (strcmp(res->rxq, "rxq") == 0)
13443 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
13444 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
13445 : 0 : res->avail_thresh_num);
13446 : 0 : if (ret < 0)
13447 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
13448 : :
13449 : 0 : }
13450 : :
13451 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
13452 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13453 : : set, "set");
13454 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
13455 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13456 : : port, "port");
13457 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
13458 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13459 : : port_num, RTE_UINT16);
13460 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
13461 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13462 : : rxq, "rxq");
13463 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
13464 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13465 : : rxq_num, RTE_UINT16);
13466 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
13467 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13468 : : avail_thresh, "avail_thresh");
13469 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
13470 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13471 : : avail_thresh_num, RTE_UINT8);
13472 : :
13473 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
13474 : : .f = cmd_set_rxq_avail_thresh_parsed,
13475 : : .data = (void *)0,
13476 : : .help_str =
13477 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
13478 : : "Set available descriptors threshold for Rx queue",
13479 : : .tokens = {
13480 : : (void *)&cmd_set_rxq_avail_thresh_set,
13481 : : (void *)&cmd_set_rxq_avail_thresh_port,
13482 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
13483 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
13484 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
13485 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
13486 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
13487 : : NULL,
13488 : : },
13489 : : };
13490 : :
13491 : : /* show port supported ptypes */
13492 : :
13493 : : /* Common result structure for show port ptypes */
13494 : : struct cmd_show_port_supported_ptypes_result {
13495 : : cmdline_fixed_string_t show;
13496 : : cmdline_fixed_string_t port;
13497 : : portid_t port_id;
13498 : : cmdline_fixed_string_t ptypes;
13499 : : };
13500 : :
13501 : : /* Common CLI fields for show port ptypes */
13502 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
13503 : : TOKEN_STRING_INITIALIZER
13504 : : (struct cmd_show_port_supported_ptypes_result,
13505 : : show, "show");
13506 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
13507 : : TOKEN_STRING_INITIALIZER
13508 : : (struct cmd_show_port_supported_ptypes_result,
13509 : : port, "port");
13510 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
13511 : : TOKEN_NUM_INITIALIZER
13512 : : (struct cmd_show_port_supported_ptypes_result,
13513 : : port_id, RTE_UINT16);
13514 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
13515 : : TOKEN_STRING_INITIALIZER
13516 : : (struct cmd_show_port_supported_ptypes_result,
13517 : : ptypes, "ptypes");
13518 : :
13519 : : static void
13520 : 0 : cmd_show_port_supported_ptypes_parsed(
13521 : : void *parsed_result,
13522 : : __rte_unused struct cmdline *cl,
13523 : : __rte_unused void *data)
13524 : : {
13525 : : #define RSVD_PTYPE_MASK 0xf0000000
13526 : : #define MAX_PTYPES_PER_LAYER 16
13527 : : #define LTYPE_NAMESIZE 32
13528 : : #define PTYPE_NAMESIZE 256
13529 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
13530 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
13531 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
13532 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
13533 : 0 : uint16_t port_id = res->port_id;
13534 : : int ret, i;
13535 : :
13536 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
13537 : 0 : if (ret < 0)
13538 : 0 : return;
13539 : :
13540 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
13541 : :
13542 : 0 : switch (ptype_mask) {
13543 : : case RTE_PTYPE_L2_MASK:
13544 : : strlcpy(ltype, "L2", sizeof(ltype));
13545 : : break;
13546 : : case RTE_PTYPE_L3_MASK:
13547 : : strlcpy(ltype, "L3", sizeof(ltype));
13548 : : break;
13549 : : case RTE_PTYPE_L4_MASK:
13550 : : strlcpy(ltype, "L4", sizeof(ltype));
13551 : : break;
13552 : : case RTE_PTYPE_TUNNEL_MASK:
13553 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
13554 : : break;
13555 : : case RTE_PTYPE_INNER_L2_MASK:
13556 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
13557 : : break;
13558 : : case RTE_PTYPE_INNER_L3_MASK:
13559 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
13560 : : break;
13561 : : case RTE_PTYPE_INNER_L4_MASK:
13562 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
13563 : : break;
13564 : : default:
13565 : : return;
13566 : : }
13567 : :
13568 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
13569 : : ptype_mask, ptypes,
13570 : : MAX_PTYPES_PER_LAYER);
13571 : :
13572 : 0 : if (ret > 0)
13573 : : printf("Supported %s ptypes:\n", ltype);
13574 : : else
13575 : : printf("%s ptypes unsupported\n", ltype);
13576 : :
13577 : 0 : for (i = 0; i < ret; ++i) {
13578 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
13579 : : printf("%s\n", buf);
13580 : : }
13581 : :
13582 : 0 : ptype_mask <<= 4;
13583 : : }
13584 : : }
13585 : :
13586 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
13587 : : .f = cmd_show_port_supported_ptypes_parsed,
13588 : : .data = NULL,
13589 : : .help_str = "show port <port_id> ptypes",
13590 : : .tokens = {
13591 : : (void *)&cmd_show_port_supported_ptypes_show,
13592 : : (void *)&cmd_show_port_supported_ptypes_port,
13593 : : (void *)&cmd_show_port_supported_ptypes_port_id,
13594 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
13595 : : NULL,
13596 : : },
13597 : : };
13598 : :
13599 : : /* *** display rx/tx descriptor status *** */
13600 : : struct cmd_show_rx_tx_desc_status_result {
13601 : : cmdline_fixed_string_t cmd_show;
13602 : : cmdline_fixed_string_t cmd_port;
13603 : : cmdline_fixed_string_t cmd_keyword;
13604 : : cmdline_fixed_string_t cmd_desc;
13605 : : cmdline_fixed_string_t cmd_status;
13606 : : portid_t cmd_pid;
13607 : : portid_t cmd_qid;
13608 : : portid_t cmd_did;
13609 : : };
13610 : :
13611 : : static void
13612 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
13613 : : __rte_unused struct cmdline *cl,
13614 : : __rte_unused void *data)
13615 : : {
13616 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
13617 : : int rc;
13618 : :
13619 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
13620 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13621 : 0 : fprintf(stderr,
13622 : : "Invalid input: port id = %d, queue id = %d\n",
13623 : 0 : res->cmd_pid, res->cmd_qid);
13624 : 0 : return;
13625 : : }
13626 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
13627 : 0 : res->cmd_did);
13628 : 0 : if (rc < 0) {
13629 : 0 : fprintf(stderr,
13630 : : "Invalid input: queue id = %d, desc id = %d\n",
13631 : 0 : res->cmd_qid, res->cmd_did);
13632 : 0 : return;
13633 : : }
13634 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
13635 : : printf("Desc status = AVAILABLE\n");
13636 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
13637 : : printf("Desc status = DONE\n");
13638 : : else
13639 : : printf("Desc status = UNAVAILABLE\n");
13640 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
13641 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13642 : 0 : fprintf(stderr,
13643 : : "Invalid input: port id = %d, queue id = %d\n",
13644 : 0 : res->cmd_pid, res->cmd_qid);
13645 : 0 : return;
13646 : : }
13647 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
13648 : 0 : res->cmd_did);
13649 : 0 : if (rc < 0) {
13650 : 0 : fprintf(stderr,
13651 : : "Invalid input: queue id = %d, desc id = %d\n",
13652 : 0 : res->cmd_qid, res->cmd_did);
13653 : 0 : return;
13654 : : }
13655 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
13656 : : printf("Desc status = FULL\n");
13657 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
13658 : : printf("Desc status = DONE\n");
13659 : : else
13660 : : printf("Desc status = UNAVAILABLE\n");
13661 : : }
13662 : : }
13663 : :
13664 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
13665 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13666 : : cmd_show, "show");
13667 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
13668 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13669 : : cmd_port, "port");
13670 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
13671 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13672 : : cmd_pid, RTE_UINT16);
13673 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
13674 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13675 : : cmd_keyword, "rxq#txq");
13676 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
13677 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13678 : : cmd_qid, RTE_UINT16);
13679 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
13680 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13681 : : cmd_desc, "desc");
13682 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
13683 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13684 : : cmd_did, RTE_UINT16);
13685 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
13686 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13687 : : cmd_status, "status");
13688 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
13689 : : .f = cmd_show_rx_tx_desc_status_parsed,
13690 : : .data = NULL,
13691 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
13692 : : "status",
13693 : : .tokens = {
13694 : : (void *)&cmd_show_rx_tx_desc_status_show,
13695 : : (void *)&cmd_show_rx_tx_desc_status_port,
13696 : : (void *)&cmd_show_rx_tx_desc_status_pid,
13697 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
13698 : : (void *)&cmd_show_rx_tx_desc_status_qid,
13699 : : (void *)&cmd_show_rx_tx_desc_status_desc,
13700 : : (void *)&cmd_show_rx_tx_desc_status_did,
13701 : : (void *)&cmd_show_rx_tx_desc_status_status,
13702 : : NULL,
13703 : : },
13704 : : };
13705 : :
13706 : : /* *** display rx/tx queue descriptor used count *** */
13707 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
13708 : : cmdline_fixed_string_t cmd_show;
13709 : : cmdline_fixed_string_t cmd_port;
13710 : : cmdline_fixed_string_t cmd_dir;
13711 : : cmdline_fixed_string_t cmd_desc;
13712 : : cmdline_fixed_string_t cmd_used;
13713 : : cmdline_fixed_string_t cmd_count;
13714 : : portid_t cmd_pid;
13715 : : portid_t cmd_qid;
13716 : : };
13717 : :
13718 : : static void
13719 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
13720 : : __rte_unused void *data)
13721 : : {
13722 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
13723 : : int rc;
13724 : :
13725 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
13726 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13727 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13728 : 0 : res->cmd_pid, res->cmd_qid);
13729 : 0 : return;
13730 : : }
13731 : :
13732 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
13733 : 0 : if (rc < 0) {
13734 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
13735 : 0 : res->cmd_qid);
13736 : 0 : return;
13737 : : }
13738 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
13739 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
13740 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13741 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13742 : 0 : res->cmd_pid, res->cmd_qid);
13743 : 0 : return;
13744 : : }
13745 : :
13746 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
13747 : 0 : if (rc < 0) {
13748 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
13749 : 0 : res->cmd_qid);
13750 : 0 : return;
13751 : : }
13752 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
13753 : : }
13754 : : }
13755 : :
13756 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
13757 : : TOKEN_STRING_INITIALIZER
13758 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13759 : : cmd_show, "show");
13760 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
13761 : : TOKEN_STRING_INITIALIZER
13762 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13763 : : cmd_port, "port");
13764 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
13765 : : TOKEN_NUM_INITIALIZER
13766 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13767 : : cmd_pid, RTE_UINT16);
13768 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
13769 : : TOKEN_STRING_INITIALIZER
13770 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13771 : : cmd_dir, "rxq#txq");
13772 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
13773 : : TOKEN_NUM_INITIALIZER
13774 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13775 : : cmd_qid, RTE_UINT16);
13776 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
13777 : : TOKEN_STRING_INITIALIZER
13778 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13779 : : cmd_desc, "desc");
13780 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
13781 : : TOKEN_STRING_INITIALIZER
13782 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13783 : : cmd_count, "used");
13784 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
13785 : : TOKEN_STRING_INITIALIZER
13786 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13787 : : cmd_count, "count");
13788 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
13789 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
13790 : : .data = NULL,
13791 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
13792 : : .tokens = {
13793 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
13794 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
13795 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
13796 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
13797 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
13798 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
13799 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
13800 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
13801 : : NULL,
13802 : : },
13803 : : };
13804 : :
13805 : : /* Common result structure for set port ptypes */
13806 : : struct cmd_set_port_ptypes_result {
13807 : : cmdline_fixed_string_t set;
13808 : : cmdline_fixed_string_t port;
13809 : : portid_t port_id;
13810 : : cmdline_fixed_string_t ptype_mask;
13811 : : uint32_t mask;
13812 : : };
13813 : :
13814 : : /* Common CLI fields for set port ptypes */
13815 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
13816 : : TOKEN_STRING_INITIALIZER
13817 : : (struct cmd_set_port_ptypes_result,
13818 : : set, "set");
13819 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
13820 : : TOKEN_STRING_INITIALIZER
13821 : : (struct cmd_set_port_ptypes_result,
13822 : : port, "port");
13823 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
13824 : : TOKEN_NUM_INITIALIZER
13825 : : (struct cmd_set_port_ptypes_result,
13826 : : port_id, RTE_UINT16);
13827 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
13828 : : TOKEN_STRING_INITIALIZER
13829 : : (struct cmd_set_port_ptypes_result,
13830 : : ptype_mask, "ptype_mask");
13831 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
13832 : : TOKEN_NUM_INITIALIZER
13833 : : (struct cmd_set_port_ptypes_result,
13834 : : mask, RTE_UINT32);
13835 : :
13836 : : static void
13837 : 0 : cmd_set_port_ptypes_parsed(
13838 : : void *parsed_result,
13839 : : __rte_unused struct cmdline *cl,
13840 : : __rte_unused void *data)
13841 : : {
13842 : : struct cmd_set_port_ptypes_result *res = parsed_result;
13843 : : #define PTYPE_NAMESIZE 256
13844 : : char ptype_name[PTYPE_NAMESIZE];
13845 : 0 : uint16_t port_id = res->port_id;
13846 : 0 : uint32_t ptype_mask = res->mask;
13847 : : int ret, i;
13848 : :
13849 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
13850 : : NULL, 0);
13851 : 0 : if (ret <= 0) {
13852 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
13853 : : port_id);
13854 : 0 : return;
13855 : : }
13856 : :
13857 : 0 : uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
13858 : :
13859 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
13860 : 0 : if (ret < 0) {
13861 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
13862 : : port_id);
13863 : 0 : return;
13864 : : }
13865 : :
13866 : : printf("Successfully set following ptypes for Port %d\n", port_id);
13867 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
13868 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
13869 : : printf("%s\n", ptype_name);
13870 : : }
13871 : :
13872 : 0 : clear_ptypes = false;
13873 : : }
13874 : :
13875 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
13876 : : .f = cmd_set_port_ptypes_parsed,
13877 : : .data = NULL,
13878 : : .help_str = "set port <port_id> ptype_mask <mask>",
13879 : : .tokens = {
13880 : : (void *)&cmd_set_port_ptypes_set,
13881 : : (void *)&cmd_set_port_ptypes_port,
13882 : : (void *)&cmd_set_port_ptypes_port_id,
13883 : : (void *)&cmd_set_port_ptypes_mask_str,
13884 : : (void *)&cmd_set_port_ptypes_mask_u32,
13885 : : NULL,
13886 : : },
13887 : : };
13888 : :
13889 : : /* *** display mac addresses added to a port *** */
13890 : : struct cmd_showport_macs_result {
13891 : : cmdline_fixed_string_t cmd_show;
13892 : : cmdline_fixed_string_t cmd_port;
13893 : : cmdline_fixed_string_t cmd_keyword;
13894 : : portid_t cmd_pid;
13895 : : };
13896 : :
13897 : : static void
13898 : 0 : cmd_showport_macs_parsed(void *parsed_result,
13899 : : __rte_unused struct cmdline *cl,
13900 : : __rte_unused void *data)
13901 : : {
13902 : : struct cmd_showport_macs_result *res = parsed_result;
13903 : :
13904 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
13905 : : return;
13906 : :
13907 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
13908 : 0 : show_macs(res->cmd_pid);
13909 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
13910 : 0 : show_mcast_macs(res->cmd_pid);
13911 : : }
13912 : :
13913 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
13914 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13915 : : cmd_show, "show");
13916 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
13917 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13918 : : cmd_port, "port");
13919 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
13920 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
13921 : : cmd_pid, RTE_UINT16);
13922 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
13923 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13924 : : cmd_keyword, "macs#mcast_macs");
13925 : :
13926 : : static cmdline_parse_inst_t cmd_showport_macs = {
13927 : : .f = cmd_showport_macs_parsed,
13928 : : .data = NULL,
13929 : : .help_str = "show port <port_id> macs|mcast_macs",
13930 : : .tokens = {
13931 : : (void *)&cmd_showport_macs_show,
13932 : : (void *)&cmd_showport_macs_port,
13933 : : (void *)&cmd_showport_macs_pid,
13934 : : (void *)&cmd_showport_macs_keyword,
13935 : : NULL,
13936 : : },
13937 : : };
13938 : :
13939 : : /* *** show flow transfer proxy port ID for the given port *** */
13940 : : struct cmd_show_port_flow_transfer_proxy_result {
13941 : : cmdline_fixed_string_t show;
13942 : : cmdline_fixed_string_t port;
13943 : : portid_t port_id;
13944 : : cmdline_fixed_string_t flow;
13945 : : cmdline_fixed_string_t transfer;
13946 : : cmdline_fixed_string_t proxy;
13947 : : };
13948 : :
13949 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
13950 : : TOKEN_STRING_INITIALIZER
13951 : : (struct cmd_show_port_flow_transfer_proxy_result,
13952 : : show, "show");
13953 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
13954 : : TOKEN_STRING_INITIALIZER
13955 : : (struct cmd_show_port_flow_transfer_proxy_result,
13956 : : port, "port");
13957 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
13958 : : TOKEN_NUM_INITIALIZER
13959 : : (struct cmd_show_port_flow_transfer_proxy_result,
13960 : : port_id, RTE_UINT16);
13961 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
13962 : : TOKEN_STRING_INITIALIZER
13963 : : (struct cmd_show_port_flow_transfer_proxy_result,
13964 : : flow, "flow");
13965 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
13966 : : TOKEN_STRING_INITIALIZER
13967 : : (struct cmd_show_port_flow_transfer_proxy_result,
13968 : : transfer, "transfer");
13969 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
13970 : : TOKEN_STRING_INITIALIZER
13971 : : (struct cmd_show_port_flow_transfer_proxy_result,
13972 : : proxy, "proxy");
13973 : :
13974 : : static void
13975 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
13976 : : __rte_unused struct cmdline *cl,
13977 : : __rte_unused void *data)
13978 : : {
13979 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
13980 : : portid_t proxy_port_id;
13981 : : int ret;
13982 : :
13983 : : printf("\n");
13984 : :
13985 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
13986 : 0 : if (ret != 0) {
13987 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
13988 : : rte_strerror(-ret));
13989 : 0 : return;
13990 : : }
13991 : :
13992 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
13993 : : }
13994 : :
13995 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
13996 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
13997 : : .data = NULL,
13998 : : .help_str = "show port <port_id> flow transfer proxy",
13999 : : .tokens = {
14000 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
14001 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
14002 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
14003 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
14004 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
14005 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
14006 : : NULL,
14007 : : }
14008 : : };
14009 : :
14010 : : /* *** configure port txq affinity value *** */
14011 : : struct cmd_config_tx_affinity_map {
14012 : : cmdline_fixed_string_t port;
14013 : : cmdline_fixed_string_t config;
14014 : : portid_t portid;
14015 : : cmdline_fixed_string_t txq;
14016 : : uint16_t qid;
14017 : : cmdline_fixed_string_t affinity;
14018 : : uint8_t value;
14019 : : };
14020 : :
14021 : : static void
14022 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
14023 : : __rte_unused struct cmdline *cl,
14024 : : __rte_unused void *data)
14025 : : {
14026 : : struct cmd_config_tx_affinity_map *res = parsed_result;
14027 : : int ret;
14028 : :
14029 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
14030 : : return;
14031 : :
14032 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
14033 : : printf("Invalid port id\n");
14034 : 0 : return;
14035 : : }
14036 : :
14037 : 0 : if (strcmp(res->txq, "txq")) {
14038 : : printf("Unknown parameter\n");
14039 : 0 : return;
14040 : : }
14041 : 0 : if (tx_queue_id_is_invalid(res->qid))
14042 : : return;
14043 : :
14044 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
14045 : 0 : if (ret < 0) {
14046 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
14047 : : strerror(-ret));
14048 : 0 : return;
14049 : : }
14050 : :
14051 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
14052 : 0 : if (ret != 0) {
14053 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
14054 : : rte_strerror(-ret));
14055 : 0 : return;
14056 : : }
14057 : : }
14058 : :
14059 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
14060 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14061 : : port, "port");
14062 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
14063 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14064 : : config, "config");
14065 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
14066 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14067 : : portid, RTE_UINT16);
14068 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
14069 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14070 : : txq, "txq");
14071 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
14072 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14073 : : qid, RTE_UINT16);
14074 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
14075 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14076 : : affinity, "affinity");
14077 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
14078 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14079 : : value, RTE_UINT8);
14080 : :
14081 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
14082 : : .f = cmd_config_tx_affinity_map_parsed,
14083 : : .data = (void *)0,
14084 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
14085 : : .tokens = {
14086 : : (void *)&cmd_config_tx_affinity_map_port,
14087 : : (void *)&cmd_config_tx_affinity_map_config,
14088 : : (void *)&cmd_config_tx_affinity_map_portid,
14089 : : (void *)&cmd_config_tx_affinity_map_txq,
14090 : : (void *)&cmd_config_tx_affinity_map_qid,
14091 : : (void *)&cmd_config_tx_affinity_map_affinity,
14092 : : (void *)&cmd_config_tx_affinity_map_value,
14093 : : NULL,
14094 : : },
14095 : : };
14096 : :
14097 : : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
14098 : : struct cmd_dev_led_result {
14099 : : cmdline_fixed_string_t set;
14100 : : cmdline_fixed_string_t port;
14101 : : portid_t port_id;
14102 : : cmdline_fixed_string_t led;
14103 : : cmdline_fixed_string_t state;
14104 : : };
14105 : :
14106 : : static void
14107 : 0 : cmd_set_dev_led_parsed(void *parsed_result,
14108 : : __rte_unused struct cmdline *cl,
14109 : : __rte_unused void *data)
14110 : : {
14111 : : struct cmd_dev_led_result *res = parsed_result;
14112 : :
14113 : 0 : if (strcmp(res->state, "on") == 0)
14114 : 0 : set_dev_led(res->port_id, true);
14115 : : else
14116 : 0 : set_dev_led(res->port_id, false);
14117 : 0 : }
14118 : :
14119 : : static cmdline_parse_token_string_t cmd_dev_led_set =
14120 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
14121 : : static cmdline_parse_token_string_t cmd_dev_led_port =
14122 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
14123 : : static cmdline_parse_token_num_t cmd_dev_led_port_id =
14124 : : TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
14125 : : static cmdline_parse_token_string_t cmd_dev_led =
14126 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
14127 : : static cmdline_parse_token_string_t cmd_dev_state =
14128 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
14129 : :
14130 : : static cmdline_parse_inst_t cmd_set_dev_led = {
14131 : : .f = cmd_set_dev_led_parsed,
14132 : : .data = NULL,
14133 : : .help_str = "set port <port_id> led <on/off>",
14134 : : .tokens = {
14135 : : (void *)&cmd_dev_led_set,
14136 : : (void *)&cmd_dev_led_port,
14137 : : (void *)&cmd_dev_led_port_id,
14138 : : (void *)&cmd_dev_led,
14139 : : (void *)&cmd_dev_state,
14140 : : NULL,
14141 : : },
14142 : : };
14143 : :
14144 : : /* ******************************************************************************** */
14145 : :
14146 : : /* list of instructions */
14147 : : static cmdline_parse_ctx_t builtin_ctx[] = {
14148 : : &cmd_help_brief,
14149 : : &cmd_help_long,
14150 : : &cmd_quit,
14151 : : &cmd_load_from_file,
14152 : : &cmd_load_echo_file,
14153 : : &cmd_showport,
14154 : : &cmd_showqueue,
14155 : : &cmd_showeeprom,
14156 : : &cmd_seteeprom,
14157 : : &cmd_showportall,
14158 : : &cmd_representor_info,
14159 : : &cmd_showdevice,
14160 : : &cmd_showcfg,
14161 : : &cmd_showfwdall,
14162 : : &cmd_start,
14163 : : &cmd_start_tx_first,
14164 : : &cmd_start_tx_first_n,
14165 : : &cmd_set_link_up,
14166 : : &cmd_set_link_down,
14167 : : &cmd_reset,
14168 : : &cmd_set_numbers,
14169 : : &cmd_set_log,
14170 : : &cmd_set_rxoffs,
14171 : : &cmd_set_rxpkts,
14172 : : &cmd_set_rxhdrs,
14173 : : &cmd_set_txflows,
14174 : : &cmd_set_txpkts,
14175 : : &cmd_set_txsplit,
14176 : : &cmd_set_txtimes,
14177 : : &cmd_set_fwd_list,
14178 : : &cmd_set_fwd_mask,
14179 : : &cmd_set_fwd_mode,
14180 : : &cmd_set_fwd_retry_mode,
14181 : : &cmd_set_dcb_fwd_tc,
14182 : : &cmd_set_dcb_fwd_tc_cores,
14183 : : &cmd_set_burst_tx_retry,
14184 : : &cmd_set_promisc_mode_one,
14185 : : &cmd_set_promisc_mode_all,
14186 : : &cmd_set_allmulti_mode_one,
14187 : : &cmd_set_allmulti_mode_all,
14188 : : &cmd_set_flush_rx,
14189 : : &cmd_set_link_check,
14190 : : &cmd_vlan_offload,
14191 : : &cmd_vlan_tpid,
14192 : : &cmd_rx_vlan_filter_all,
14193 : : &cmd_rx_vlan_filter,
14194 : : &cmd_tx_vlan_set,
14195 : : &cmd_tx_vlan_set_qinq,
14196 : : &cmd_tx_vlan_reset,
14197 : : &cmd_tx_vlan_set_pvid,
14198 : : &cmd_csum_set,
14199 : : &cmd_csum_show,
14200 : : &cmd_csum_tunnel,
14201 : : &cmd_csum_mac_swap,
14202 : : &cmd_tso_set,
14203 : : &cmd_tso_show,
14204 : : &cmd_tunnel_tso_set,
14205 : : &cmd_tunnel_tso_show,
14206 : : #ifdef RTE_LIB_GRO
14207 : : &cmd_gro_enable,
14208 : : &cmd_gro_flush,
14209 : : &cmd_gro_show,
14210 : : #endif
14211 : : #ifdef RTE_LIB_GSO
14212 : : &cmd_gso_enable,
14213 : : &cmd_gso_size,
14214 : : &cmd_gso_show,
14215 : : #endif
14216 : : &cmd_link_flow_control_set,
14217 : : &cmd_link_flow_control_set_rx,
14218 : : &cmd_link_flow_control_set_tx,
14219 : : &cmd_link_flow_control_set_hw,
14220 : : &cmd_link_flow_control_set_lw,
14221 : : &cmd_link_flow_control_set_pt,
14222 : : &cmd_link_flow_control_set_xon,
14223 : : &cmd_link_flow_control_set_macfwd,
14224 : : &cmd_link_flow_control_set_autoneg,
14225 : : &cmd_link_flow_control_show,
14226 : : &cmd_priority_flow_control_set,
14227 : : &cmd_queue_priority_flow_control_set,
14228 : : &cmd_config_dcb,
14229 : : &cmd_read_rxd_txd,
14230 : : &cmd_stop,
14231 : : &cmd_mac_addr,
14232 : : &cmd_set_fwd_eth_peer,
14233 : : &cmd_set_xstats_hide_zero,
14234 : : &cmd_set_xstats_show_state,
14235 : : &cmd_set_xstats_hide_disabled,
14236 : : &cmd_operate_set_counter,
14237 : : &cmd_set_record_core_cycles,
14238 : : &cmd_set_record_burst_stats,
14239 : : &cmd_operate_port,
14240 : : &cmd_operate_specific_port,
14241 : : &cmd_operate_attach_port,
14242 : : &cmd_operate_detach_port,
14243 : : &cmd_operate_detach_device,
14244 : : &cmd_set_port_setup_on,
14245 : : &cmd_config_speed_all,
14246 : : &cmd_config_speed_specific,
14247 : : &cmd_config_speed_lanes_all,
14248 : : &cmd_config_speed_lanes_specific,
14249 : : &cmd_show_speed_lanes,
14250 : : &cmd_config_loopback_all,
14251 : : &cmd_config_loopback_specific,
14252 : : &cmd_config_rx_tx,
14253 : : &cmd_config_mtu,
14254 : : &cmd_config_max_pkt_len,
14255 : : &cmd_config_max_lro_pkt_size,
14256 : : &cmd_config_rx_mode_flag,
14257 : : &cmd_config_rss,
14258 : : &cmd_config_rxtx_ring_size,
14259 : : &cmd_config_rxtx_queue,
14260 : : &cmd_config_deferred_start_rxtx_queue,
14261 : : &cmd_setup_rxtx_queue,
14262 : : &cmd_config_rss_reta,
14263 : : &cmd_showport_reta,
14264 : : &cmd_showport_macs,
14265 : : &cmd_show_port_flow_transfer_proxy,
14266 : : &cmd_config_burst,
14267 : : &cmd_config_thresh,
14268 : : &cmd_config_threshold,
14269 : : &cmd_set_uc_hash_filter,
14270 : : &cmd_set_uc_all_hash_filter,
14271 : : &cmd_vf_mac_addr_filter,
14272 : : &cmd_queue_rate_limit,
14273 : : &cmd_tunnel_udp_config,
14274 : : &cmd_showport_rss_hash,
14275 : : &cmd_showport_rss_hash_key,
14276 : : &cmd_showport_rss_hash_algo,
14277 : : &cmd_config_rss_hash_key,
14278 : : &cmd_config_rss_hash_algo,
14279 : : &cmd_cleanup_txq_mbufs,
14280 : : &cmd_dump_simple,
14281 : : &cmd_dump_named,
14282 : : &cmd_dump_mbuf_history_stdout,
14283 : : &cmd_dump_mbuf_history_to_file,
14284 : : &cmd_dump_mbuf_pool_history_stdout,
14285 : : &cmd_dump_mbuf_pool_history_to_file,
14286 : : &cmd_flow,
14287 : : &cmd_show_port_meter_cap,
14288 : : &cmd_add_port_meter_profile_srtcm,
14289 : : &cmd_add_port_meter_profile_trtcm,
14290 : : &cmd_add_port_meter_profile_trtcm_rfc4115,
14291 : : &cmd_del_port_meter_profile,
14292 : : &cmd_create_port_meter,
14293 : : &cmd_enable_port_meter,
14294 : : &cmd_disable_port_meter,
14295 : : &cmd_del_port_meter,
14296 : : &cmd_del_port_meter_policy,
14297 : : &cmd_set_port_meter_profile,
14298 : : &cmd_set_port_meter_dscp_table,
14299 : : &cmd_set_port_meter_vlan_table,
14300 : : &cmd_set_port_meter_in_proto,
14301 : : &cmd_get_port_meter_in_proto,
14302 : : &cmd_get_port_meter_in_proto_prio,
14303 : : &cmd_set_port_meter_stats_mask,
14304 : : &cmd_show_port_meter_stats,
14305 : : &cmd_mcast_addr,
14306 : : &cmd_mcast_addr_flush,
14307 : : &cmd_set_vf_vlan_anti_spoof,
14308 : : &cmd_set_vf_mac_anti_spoof,
14309 : : &cmd_set_vf_vlan_stripq,
14310 : : &cmd_set_vf_vlan_insert,
14311 : : &cmd_set_tx_loopback,
14312 : : &cmd_set_all_queues_drop_en,
14313 : : &cmd_set_vf_traffic,
14314 : : &cmd_set_vf_rxmode,
14315 : : &cmd_vf_rate_limit,
14316 : : &cmd_vf_rxvlan_filter,
14317 : : &cmd_set_vf_mac_addr,
14318 : : &cmd_set_vxlan,
14319 : : &cmd_set_vxlan_tos_ttl,
14320 : : &cmd_set_vxlan_with_vlan,
14321 : : &cmd_set_nvgre,
14322 : : &cmd_set_nvgre_with_vlan,
14323 : : &cmd_set_l2_encap,
14324 : : &cmd_set_l2_encap_with_vlan,
14325 : : &cmd_set_l2_decap,
14326 : : &cmd_set_l2_decap_with_vlan,
14327 : : &cmd_set_mplsogre_encap,
14328 : : &cmd_set_mplsogre_encap_with_vlan,
14329 : : &cmd_set_mplsogre_decap,
14330 : : &cmd_set_mplsogre_decap_with_vlan,
14331 : : &cmd_set_mplsoudp_encap,
14332 : : &cmd_set_mplsoudp_encap_with_vlan,
14333 : : &cmd_set_mplsoudp_decap,
14334 : : &cmd_set_mplsoudp_decap_with_vlan,
14335 : : &cmd_set_conntrack_common,
14336 : : &cmd_set_conntrack_dir,
14337 : : &cmd_show_vf_stats,
14338 : : &cmd_clear_vf_stats,
14339 : : &cmd_show_port_supported_ptypes,
14340 : : &cmd_set_port_ptypes,
14341 : : &cmd_show_port_tm_cap,
14342 : : &cmd_show_port_tm_level_cap,
14343 : : &cmd_show_port_tm_node,
14344 : : &cmd_show_port_tm_node_cap,
14345 : : &cmd_show_port_tm_node_type,
14346 : : &cmd_show_port_tm_node_stats,
14347 : : &cmd_add_port_tm_node_shaper_profile,
14348 : : &cmd_del_port_tm_node_shaper_profile,
14349 : : &cmd_add_port_tm_node_shared_shaper,
14350 : : &cmd_del_port_tm_node_shared_shaper,
14351 : : &cmd_add_port_tm_node_wred_profile,
14352 : : &cmd_del_port_tm_node_wred_profile,
14353 : : &cmd_set_port_tm_node_shaper_profile,
14354 : : &cmd_add_port_tm_nonleaf_node,
14355 : : &cmd_add_port_tm_nonleaf_node_pmode,
14356 : : &cmd_add_port_tm_leaf_node,
14357 : : &cmd_del_port_tm_node,
14358 : : &cmd_set_port_tm_node_parent,
14359 : : &cmd_suspend_port_tm_node,
14360 : : &cmd_resume_port_tm_node,
14361 : : &cmd_port_tm_hierarchy_commit,
14362 : : &cmd_port_tm_mark_ip_ecn,
14363 : : &cmd_port_tm_mark_ip_dscp,
14364 : : &cmd_port_tm_mark_vlan_dei,
14365 : : &cmd_cfg_tunnel_udp_port,
14366 : : &cmd_rx_offload_get_capa,
14367 : : &cmd_rx_offload_get_configuration,
14368 : : &cmd_config_per_port_rx_offload,
14369 : : &cmd_config_all_port_rx_offload,
14370 : : &cmd_config_per_queue_rx_offload,
14371 : : &cmd_tx_offload_get_capa,
14372 : : &cmd_tx_offload_get_configuration,
14373 : : &cmd_config_per_port_tx_offload,
14374 : : &cmd_config_all_port_tx_offload,
14375 : : &cmd_config_per_queue_tx_offload,
14376 : : #ifdef RTE_LIB_BPF
14377 : : &cmd_operate_bpf_ld_parse,
14378 : : &cmd_operate_bpf_unld_parse,
14379 : : #endif
14380 : : &cmd_config_tx_metadata_specific,
14381 : : &cmd_show_tx_metadata,
14382 : : &cmd_show_rx_tx_desc_status,
14383 : : &cmd_show_rx_tx_queue_desc_used_count,
14384 : : &cmd_set_raw,
14385 : : &cmd_show_set_raw,
14386 : : &cmd_show_set_raw_all,
14387 : : &cmd_config_tx_dynf_specific,
14388 : : &cmd_show_fec_mode,
14389 : : &cmd_set_fec_mode,
14390 : : &cmd_set_rxq_avail_thresh,
14391 : : &cmd_show_capability,
14392 : : &cmd_set_flex_is_pattern,
14393 : : &cmd_set_flex_spec_pattern,
14394 : : &cmd_show_port_cman_capa,
14395 : : &cmd_show_port_cman_config,
14396 : : &cmd_set_port_cman_config,
14397 : : &cmd_config_tx_affinity_map,
14398 : : &cmd_set_dev_led,
14399 : : NULL,
14400 : : };
14401 : :
14402 : : void
14403 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
14404 : : {
14405 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
14406 : 0 : }
14407 : :
14408 : : int
14409 : 0 : init_cmdline(void)
14410 : : {
14411 : : struct testpmd_driver_commands *c;
14412 : : unsigned int count;
14413 : : unsigned int i;
14414 : :
14415 : : /* initialize non-constant commands */
14416 : 0 : cmd_set_fwd_mode_init();
14417 : 0 : cmd_set_fwd_retry_mode_init();
14418 : :
14419 : : count = 0;
14420 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
14421 : 0 : count++;
14422 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14423 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
14424 : 0 : count++;
14425 : : }
14426 : :
14427 : : /* cmdline expects a NULL terminated array */
14428 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
14429 : 0 : if (main_ctx == NULL)
14430 : : return -1;
14431 : :
14432 : : count = 0;
14433 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
14434 : 0 : main_ctx[count] = builtin_ctx[i];
14435 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14436 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
14437 : 0 : main_ctx[count] = c->commands[i].ctx;
14438 : : }
14439 : :
14440 : : return 0;
14441 : : }
14442 : :
14443 : : /* read cmdline commands from file */
14444 : : int
14445 : 0 : cmdline_read_from_file(const char *filename, bool echo)
14446 : : {
14447 : : struct cmdline *cl;
14448 : : int fd = -1;
14449 : : int ret = 0;
14450 : :
14451 : : /* cmdline_file_new does not produce any output
14452 : : * so when echoing is requested we open filename directly
14453 : : * and then pass that to cmdline_new with stdout as the output path.
14454 : : */
14455 : 0 : if (!echo) {
14456 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14457 : : } else {
14458 : : /* use basename(filename) as prompt */
14459 : 0 : char prompt[32] = "[] ";
14460 : :
14461 : 0 : rte_basename(filename, &prompt[1], sizeof(prompt) - strlen(prompt));
14462 : 0 : strlcat(prompt, "] ", sizeof(prompt));
14463 : :
14464 : : fd = open(filename, O_RDONLY);
14465 : 0 : if (fd < 0) {
14466 : 0 : fprintf(stderr, "Failed to open file %s: %s\n",
14467 : 0 : filename, strerror(errno));
14468 : 0 : return -1;
14469 : : }
14470 : :
14471 : 0 : cl = cmdline_new(main_ctx, prompt, fd, STDOUT_FILENO);
14472 : : }
14473 : 0 : if (cl == NULL) {
14474 : 0 : fprintf(stderr,
14475 : : "Failed to create file based cmdline context: %s\n",
14476 : : filename);
14477 : : ret = -1;
14478 : 0 : goto end;
14479 : : }
14480 : :
14481 : 0 : cmdline_interact(cl);
14482 : : /* when done, if we have echo, we only need to print end of file,
14483 : : * but if no echo, we need to use printf and include the filename.
14484 : : */
14485 : 0 : if (echo)
14486 : 0 : cmdline_printf(cl, "<End-Of-File>\n");
14487 : : else
14488 : : printf("Finished reading CLI commands from %s\n", filename);
14489 : :
14490 : 0 : cmdline_quit(cl);
14491 : 0 : cmdline_free(cl);
14492 : :
14493 : :
14494 : 0 : end:
14495 : 0 : if (fd >= 0)
14496 : 0 : close(fd);
14497 : : return ret;
14498 : : }
14499 : :
14500 : : void
14501 : 0 : prompt_exit(void)
14502 : : {
14503 : 0 : cmdline_quit(testpmd_cl);
14504 : 0 : }
14505 : :
14506 : : /* prompt function, called from main on MAIN lcore */
14507 : : void
14508 : 0 : prompt(void)
14509 : : {
14510 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14511 : 0 : if (testpmd_cl == NULL) {
14512 : 0 : fprintf(stderr,
14513 : : "Failed to create stdin based cmdline context\n");
14514 : 0 : return;
14515 : : }
14516 : :
14517 : 0 : cmdline_interact(testpmd_cl);
14518 : 0 : cmdline_stdin_exit(testpmd_cl);
14519 : : }
14520 : :
14521 : : void
14522 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14523 : : {
14524 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
14525 : : portid_t pid;
14526 : :
14527 : 0 : RTE_ETH_FOREACH_DEV(pid) {
14528 : : /* check if need_reconfig has been set to 1 */
14529 : 0 : if (ports[pid].need_reconfig == 0)
14530 : 0 : ports[pid].need_reconfig = dev;
14531 : : /* check if need_reconfig_queues has been set to 1 */
14532 : 0 : if (ports[pid].need_reconfig_queues == 0)
14533 : 0 : ports[pid].need_reconfig_queues = queue;
14534 : : }
14535 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14536 : : /* check if need_reconfig has been set to 1 */
14537 : 0 : if (ports[id].need_reconfig == 0)
14538 : 0 : ports[id].need_reconfig = dev;
14539 : : /* check if need_reconfig_queues has been set to 1 */
14540 : 0 : if (ports[id].need_reconfig_queues == 0)
14541 : 0 : ports[id].need_reconfig_queues = queue;
14542 : : }
14543 : 0 : }
|