Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2016 Intel Corporation.
3 : : * Copyright(c) 2014 6WIND S.A.
4 : : */
5 : :
6 : : #include <ctype.h>
7 : : #include <stdarg.h>
8 : : #include <errno.h>
9 : : #include <fcntl.h>
10 : : #include <stdio.h>
11 : : #include <stdint.h>
12 : : #include <stdlib.h>
13 : : #include <string.h>
14 : : #include <unistd.h>
15 : : #include <inttypes.h>
16 : : #include <sys/queue.h>
17 : :
18 : : #include <rte_common.h>
19 : : #include <rte_byteorder.h>
20 : : #include <rte_log.h>
21 : : #include <rte_debug.h>
22 : : #include <rte_cycles.h>
23 : : #include <rte_memory.h>
24 : : #include <rte_memzone.h>
25 : : #include <rte_malloc.h>
26 : : #include <rte_launch.h>
27 : : #include <rte_eal.h>
28 : : #include <rte_per_lcore.h>
29 : : #include <rte_lcore.h>
30 : : #include <rte_branch_prediction.h>
31 : : #include <rte_ring.h>
32 : : #include <rte_mempool.h>
33 : : #include <rte_interrupts.h>
34 : : #include <rte_ether.h>
35 : : #include <rte_ethdev.h>
36 : : #include <rte_string_fns.h>
37 : : #include <rte_devargs.h>
38 : : #include <rte_flow.h>
39 : : #ifdef RTE_LIB_GRO
40 : : #include <rte_gro.h>
41 : : #endif
42 : : #include <rte_mbuf_dyn.h>
43 : : #include <rte_mbuf_history.h>
44 : : #include <rte_trace.h>
45 : :
46 : : #include <cmdline_rdline.h>
47 : : #include <cmdline_parse.h>
48 : : #include <cmdline_parse_num.h>
49 : : #include <cmdline_parse_bool.h>
50 : : #include <cmdline_parse_string.h>
51 : : #include <cmdline_parse_ipaddr.h>
52 : : #include <cmdline_parse_etheraddr.h>
53 : : #include <cmdline_socket.h>
54 : : #include <cmdline.h>
55 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
56 : : #include <rte_pmd_dpaa.h>
57 : : #endif
58 : : #ifdef RTE_NET_IXGBE
59 : : #include <rte_pmd_ixgbe.h>
60 : : #endif
61 : : #ifdef RTE_NET_I40E
62 : : #include <rte_pmd_i40e.h>
63 : : #endif
64 : : #ifdef RTE_NET_BNXT
65 : : #include <rte_pmd_bnxt.h>
66 : : #endif
67 : : #include "testpmd.h"
68 : : #include "cmdline_cman.h"
69 : : #include "cmdline_mtr.h"
70 : : #include "cmdline_tm.h"
71 : : #include "bpf_cmd.h"
72 : :
73 : : static struct cmdline *testpmd_cl;
74 : : static cmdline_parse_ctx_t *main_ctx;
75 : : static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
76 : : TAILQ_HEAD_INITIALIZER(driver_commands_head);
77 : :
78 : : /* *** Help command with introduction. *** */
79 : : struct cmd_help_brief_result {
80 : : cmdline_fixed_string_t help;
81 : : };
82 : :
83 : 0 : static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
84 : : struct cmdline *cl,
85 : : __rte_unused void *data)
86 : : {
87 : 0 : cmdline_printf(
88 : : cl,
89 : : "\n"
90 : : "Help is available for the following sections:\n\n"
91 : : " help control : Start and stop forwarding.\n"
92 : : " help display : Displaying port, stats and config "
93 : : "information.\n"
94 : : " help config : Configuration information.\n"
95 : : " help ports : Configuring ports.\n"
96 : : " help filters : Filters configuration help.\n"
97 : : " help traffic_management : Traffic Management commands.\n"
98 : : " help devices : Device related commands.\n"
99 : : " help drivers : Driver specific commands.\n"
100 : : " help all : All of the above sections.\n\n"
101 : : );
102 : :
103 : 0 : }
104 : :
105 : : static cmdline_parse_token_string_t cmd_help_brief_help =
106 : : TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
107 : :
108 : : static cmdline_parse_inst_t cmd_help_brief = {
109 : : .f = cmd_help_brief_parsed,
110 : : .data = NULL,
111 : : .help_str = "help: Show help",
112 : : .tokens = {
113 : : (void *)&cmd_help_brief_help,
114 : : NULL,
115 : : },
116 : : };
117 : :
118 : : /* *** Help command with help sections. *** */
119 : : struct cmd_help_long_result {
120 : : cmdline_fixed_string_t help;
121 : : cmdline_fixed_string_t section;
122 : : };
123 : :
124 : 0 : static void cmd_help_long_parsed(void *parsed_result,
125 : : struct cmdline *cl,
126 : : __rte_unused void *data)
127 : : {
128 : : int show_all = 0;
129 : : struct cmd_help_long_result *res = parsed_result;
130 : :
131 : 0 : if (!strcmp(res->section, "all"))
132 : : show_all = 1;
133 : :
134 : 0 : if (show_all || !strcmp(res->section, "control")) {
135 : :
136 : 0 : cmdline_printf(
137 : : cl,
138 : : "\n"
139 : : "Control forwarding:\n"
140 : : "-------------------\n\n"
141 : :
142 : : "start\n"
143 : : " Start packet forwarding with current configuration.\n\n"
144 : :
145 : : "start tx_first\n"
146 : : " Start packet forwarding with current config"
147 : : " after sending one burst of packets.\n\n"
148 : :
149 : : "stop\n"
150 : : " Stop packet forwarding, and display accumulated"
151 : : " statistics.\n\n"
152 : :
153 : : "quit\n"
154 : : " Quit to prompt.\n\n"
155 : : );
156 : : }
157 : :
158 : 0 : if (show_all || !strcmp(res->section, "display")) {
159 : :
160 : 0 : cmdline_printf(
161 : : cl,
162 : : "\n"
163 : : "Display:\n"
164 : : "--------\n\n"
165 : :
166 : : "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
167 : : " Display information for port_id, or all.\n\n"
168 : :
169 : : "show port info (port_id) representor\n"
170 : : " Show supported representors for a specific port\n\n"
171 : :
172 : : "show port port_id (module_eeprom|eeprom)\n"
173 : : " Display the module EEPROM or EEPROM information for port_id.\n\n"
174 : :
175 : : "show port (port_id) module_eeprom decode\n"
176 : : " Display the decoded module EEPROM of port_id.\n\n"
177 : :
178 : : "set port (port_id) eeprom (accept_risk) magic (magic_num)"
179 : : " value (value) offset (offset)\n"
180 : : " Set the device eeprom for certain port.\nNote:\n"
181 : : " This is a high-risk command and its misuse may"
182 : : " result in unexpected behaviour from the NIC.\n"
183 : : " By inserting \"accept_risk\" into the command, the"
184 : : " user is acknowledging and taking responsibility for"
185 : : " this risk.\n\n"
186 : :
187 : : "show port X rss reta (size) (mask0,mask1,...)\n"
188 : : " Display the rss redirection table entry indicated"
189 : : " by masks on port X. size is used to indicate the"
190 : : " hardware supported reta size\n\n"
191 : :
192 : : "show port (port_id) rss-hash [key | algorithm]\n"
193 : : " Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
194 : :
195 : : "clear port (info|stats|xstats|fdir) (port_id|all)\n"
196 : : " Clear information for port_id, or all.\n\n"
197 : :
198 : : "show (rxq|txq) info (port_id) (queue_id)\n"
199 : : " Display information for configured RX/TX queue.\n\n"
200 : :
201 : : "show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes|dcbfwdtc)\n"
202 : : " Display the given configuration.\n\n"
203 : :
204 : : "read rxd (port_id) (queue_id) (rxd_id)\n"
205 : : " Display an RX descriptor of a port RX queue.\n\n"
206 : :
207 : : "read txd (port_id) (queue_id) (txd_id)\n"
208 : : " Display a TX descriptor of a port TX queue.\n\n"
209 : :
210 : : "show vf stats (port_id) (vf_id)\n"
211 : : " Display a VF's statistics.\n\n"
212 : :
213 : : "clear vf stats (port_id) (vf_id)\n"
214 : : " Reset a VF's statistics.\n\n"
215 : :
216 : : "show port meter stats (port_id) (meter_id) (clear)\n"
217 : : " Get meter stats on a port\n\n"
218 : :
219 : : "show fwd stats all\n"
220 : : " Display statistics for all fwd engines.\n\n"
221 : :
222 : : "clear fwd stats all\n"
223 : : " Clear statistics for all fwd engines.\n\n"
224 : :
225 : : "show port (port_id) rx_offload capabilities\n"
226 : : " List all per queue and per port Rx offloading"
227 : : " capabilities of a port\n\n"
228 : :
229 : : "show port (port_id) rx_offload configuration\n"
230 : : " List port level and all queue level"
231 : : " Rx offloading configuration\n\n"
232 : :
233 : : "show port (port_id) tx_offload capabilities\n"
234 : : " List all per queue and per port"
235 : : " Tx offloading capabilities of a port\n\n"
236 : :
237 : : "show port (port_id) tx_offload configuration\n"
238 : : " List port level and all queue level"
239 : : " Tx offloading configuration\n\n"
240 : :
241 : : "show port (port_id) tx_metadata\n"
242 : : " Show Tx metadata value set"
243 : : " for a specific port\n\n"
244 : :
245 : : "show port (port_id) ptypes\n"
246 : : " Show port supported ptypes"
247 : : " for a specific port\n\n"
248 : :
249 : : "show device info (<identifier>|all)"
250 : : " Show general information about devices probed.\n\n"
251 : :
252 : : "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
253 : : " Show status of rx|tx descriptor.\n\n"
254 : :
255 : : "show port (port_id) rxq|txq (queue_id) desc used count\n"
256 : : " Show current number of used descriptor count for rx|tx.\n\n"
257 : :
258 : : "show port (port_id) macs|mcast_macs"
259 : : " Display list of mac addresses added to port.\n\n"
260 : :
261 : : "show port (port_id) flow transfer proxy\n"
262 : : " Display proxy port to manage transfer flows\n\n"
263 : :
264 : : "show port (port_id) fec capabilities"
265 : : " Show fec capabilities of a port.\n\n"
266 : :
267 : : "show port (port_id) fec_mode"
268 : : " Show fec mode of a port.\n\n"
269 : :
270 : : "show port (port_id) flow_ctrl"
271 : : " Show flow control info of a port.\n\n"
272 : :
273 : : "dump physmem\n"
274 : : " Dumps all physical memory segment layouts\n\n"
275 : :
276 : : "dump socket_mem\n"
277 : : " Dumps the memory usage of all sockets\n\n"
278 : :
279 : : "dump memzone\n"
280 : : " Dumps the layout of all memory zones\n\n"
281 : :
282 : : "dump struct_sizes\n"
283 : : " Dumps the size of all memory structures\n\n"
284 : :
285 : : "dump ring [name]\n"
286 : : " Dumps the status of all or specific element in DPDK rings\n\n"
287 : :
288 : : "dump mempool [name]\n"
289 : : " Dumps the statistics of all or specific memory pool\n\n"
290 : :
291 : : "dump devargs\n"
292 : : " Dumps the user device list\n\n"
293 : :
294 : : "dump lcores\n"
295 : : " Dumps the logical cores list\n\n"
296 : :
297 : : "dump trace\n"
298 : : " Dumps the tracing data to the folder according to the current EAL settings\n\n"
299 : :
300 : : "dump log_types\n"
301 : : " Dumps the log level for all the dpdk modules\n\n"
302 : :
303 : : "dump mbuf history all [file_name]\n"
304 : : " Dumps the mbuf history for all mempools\n\n"
305 : :
306 : : "dump mbuf history <mbuf_addr> [file_name]\n"
307 : : " Dumps the history for a specific mbuf (use 0x<address> format)\n\n"
308 : :
309 : : "dump mbuf pool history <mempool_name> [file_name]\n"
310 : : " Dumps the history for a specific mempool\n\n"
311 : :
312 : : "show port (port_id) speed_lanes capabilities"
313 : : " Show speed lanes capabilities of a port.\n\n"
314 : : );
315 : : }
316 : :
317 : 0 : if (show_all || !strcmp(res->section, "config")) {
318 : 0 : cmdline_printf(
319 : : cl,
320 : : "\n"
321 : : "Configuration:\n"
322 : : "--------------\n"
323 : : "Configuration changes only become active when"
324 : : " forwarding is started/restarted.\n\n"
325 : :
326 : : "set default\n"
327 : : " Reset forwarding to the default configuration.\n\n"
328 : :
329 : : "set verbose (level)\n"
330 : : " Set the debug verbosity level X.\n\n"
331 : :
332 : : "set log global|(type) (level)\n"
333 : : " Set the log level.\n\n"
334 : :
335 : : "set nbport (num)\n"
336 : : " Set number of ports.\n\n"
337 : :
338 : : "set nbcore (num)\n"
339 : : " Set number of cores.\n\n"
340 : :
341 : : "set coremask (mask)\n"
342 : : " Set the forwarding cores hexadecimal mask.\n\n"
343 : :
344 : : "set portmask (mask)\n"
345 : : " Set the forwarding ports hexadecimal mask.\n\n"
346 : :
347 : : "set burst (num)\n"
348 : : " Set number of packets per burst.\n\n"
349 : :
350 : : "set burst tx delay (microseconds) retry (num)\n"
351 : : " Set the transmit delay time and number of retries,"
352 : : " effective when retry is enabled.\n\n"
353 : :
354 : : "set rxoffs (x[,y]*)\n"
355 : : " Set the offset of each packet segment on"
356 : : " receiving if split feature is engaged."
357 : : " Affects only the queues configured with split"
358 : : " offloads.\n\n"
359 : :
360 : : "set rxpkts (x[,y]*)\n"
361 : : " Set the length of each segment to scatter"
362 : : " packets on receiving if split feature is engaged."
363 : : " Affects only the queues configured with split"
364 : : " offloads.\n\n"
365 : :
366 : : "set rxhdrs (eth[,ipv4])*\n"
367 : : " Set the protocol hdr of each segment to scatter"
368 : : " packets on receiving if split feature is engaged."
369 : : " Affects only the queues configured with split"
370 : : " offloads.\n"
371 : : " Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
372 : : "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
373 : : "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
374 : : "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
375 : : "inner-ipv4-sctp|inner-ipv6-sctp\n\n"
376 : :
377 : : "set txpkts (x[,y]*)\n"
378 : : " Set the length of each segment of TXONLY"
379 : : " and optionally CSUM packets.\n\n"
380 : :
381 : : "set txsplit (off|on|rand)\n"
382 : : " Set the split policy for the TX packets."
383 : : " Right now only applicable for CSUM and TXONLY"
384 : : " modes\n\n"
385 : :
386 : : "set txtimes (x, y)\n"
387 : : " Set the scheduling on timestamps"
388 : : " timings for the TXONLY mode\n\n"
389 : :
390 : : "set txflows (N)\n"
391 : : " Set the number of flows per lcore in"
392 : : " txonly multi-flow mode (1-64)\n\n"
393 : :
394 : : "set corelist (x[,y]*)\n"
395 : : " Set the list of forwarding cores.\n\n"
396 : :
397 : : "set portlist (x[,y]*)\n"
398 : : " Set the list of forwarding ports.\n\n"
399 : :
400 : : "set port setup on (iterator|event)\n"
401 : : " Select how attached port is retrieved for setup.\n\n"
402 : :
403 : : "set tx loopback (port_id) (on|off)\n"
404 : : " Enable or disable tx loopback.\n\n"
405 : :
406 : : "set all queues drop (port_id) (on|off)\n"
407 : : " Set drop enable bit for all queues.\n\n"
408 : :
409 : : "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
410 : : " Set MAC antispoof for a VF from the PF.\n\n"
411 : :
412 : : "vlan set stripq (on|off) (port_id,queue_id)\n"
413 : : " Set the VLAN strip for a queue on a port.\n\n"
414 : :
415 : : "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
416 : : " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
417 : :
418 : : "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
419 : : " Set VLAN insert for a VF from the PF.\n\n"
420 : :
421 : : "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
422 : : " Set VLAN antispoof for a VF from the PF.\n\n"
423 : :
424 : : "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
425 : : " Set the VLAN strip or filter or qinq strip or extend\n\n"
426 : :
427 : : "vlan set (inner|outer) tpid (value) (port_id)\n"
428 : : " Set the VLAN TPID for Packet Filtering on"
429 : : " a port\n\n"
430 : :
431 : : "rx_vlan add (vlan_id|all) (port_id)\n"
432 : : " Add a vlan_id, or all identifiers, to the set"
433 : : " of VLAN identifiers filtered by port_id.\n\n"
434 : :
435 : : "rx_vlan rm (vlan_id|all) (port_id)\n"
436 : : " Remove a vlan_id, or all identifiers, from the set"
437 : : " of VLAN identifiers filtered by port_id.\n\n"
438 : :
439 : : "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
440 : : " Add a vlan_id, to the set of VLAN identifiers"
441 : : "filtered for VF(s) from port_id.\n\n"
442 : :
443 : : "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
444 : : " Remove a vlan_id, to the set of VLAN identifiers"
445 : : "filtered for VF(s) from port_id.\n\n"
446 : :
447 : : "rx_vxlan_port add (udp_port) (port_id)\n"
448 : : " Add an UDP port for VXLAN packet filter on a port\n\n"
449 : :
450 : : "rx_vxlan_port rm (udp_port) (port_id)\n"
451 : : " Remove an UDP port for VXLAN packet filter on a port\n\n"
452 : :
453 : : "tx_vlan set (port_id) vlan_tci[, vlan_tci_outer]\n"
454 : : " Set hardware insertion of VLAN TCI (single or double VLAN "
455 : : "depends on the number of VLAN TCIs) in packets sent on a port.\n\n"
456 : :
457 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
458 : : " Set port based TX VLAN insertion.\n\n"
459 : :
460 : : "tx_vlan reset (port_id)\n"
461 : : " Disable hardware insertion of a VLAN header in"
462 : : " packets sent on a port.\n\n"
463 : :
464 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
465 : : " Select hardware or software calculation of the"
466 : : " checksum when transmitting a packet using the"
467 : : " csum forward engine.\n"
468 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
469 : : " outer-ip concerns the outer IP layer in"
470 : : " outer-udp concerns the outer UDP layer in"
471 : : " case the packet is recognized as a tunnel packet by"
472 : : " the forward engine (vxlan, gre and ipip are supported)\n"
473 : : " Please check the NIC datasheet for HW limits.\n\n"
474 : :
475 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
476 : : " If disabled, treat tunnel packets as non-tunneled"
477 : : " packets (treat inner headers as payload). The port\n"
478 : : " argument is the port used for TX in csum forward"
479 : : " engine.\n\n"
480 : :
481 : : "csum show (port_id)\n"
482 : : " Display tx checksum offload configuration\n\n"
483 : :
484 : : "tso set (segsize) (portid)\n"
485 : : " Enable TCP Segmentation Offload in csum forward"
486 : : " engine.\n"
487 : : " Please check the NIC datasheet for HW limits.\n\n"
488 : :
489 : : "tso show (portid)"
490 : : " Display the status of TCP Segmentation Offload.\n\n"
491 : :
492 : : #ifdef RTE_LIB_GRO
493 : : "set port (port_id) gro on|off\n"
494 : : " Enable or disable Generic Receive Offload in"
495 : : " csum forwarding engine.\n\n"
496 : :
497 : : "show port (port_id) gro\n"
498 : : " Display GRO configuration.\n\n"
499 : :
500 : : "set gro flush (cycles)\n"
501 : : " Set the cycle to flush GROed packets from"
502 : : " reassembly tables.\n\n"
503 : : #endif
504 : :
505 : : #ifdef RTE_LIB_GSO
506 : : "set port (port_id) gso (on|off)"
507 : : " Enable or disable Generic Segmentation Offload in"
508 : : " csum forwarding engine.\n\n"
509 : :
510 : : "set gso segsz (length)\n"
511 : : " Set max packet length for output GSO segments,"
512 : : " including packet header and payload.\n\n"
513 : :
514 : : "show port (port_id) gso\n"
515 : : " Show GSO configuration.\n\n"
516 : : #endif
517 : :
518 : : "set fwd (%s)\n"
519 : : " Set packet forwarding mode.\n\n"
520 : :
521 : : "set dcb fwd_tc (tc_mask)\n"
522 : : " Set DCB forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled\n\n"
523 : :
524 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
525 : : " Add a MAC address on port_id.\n\n"
526 : :
527 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
528 : : " Remove a MAC address from port_id.\n\n"
529 : :
530 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
531 : : " Set the default MAC address for port_id.\n\n"
532 : :
533 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
534 : : " Add a MAC address for a VF on the port.\n\n"
535 : :
536 : : "mcast_addr add (port_id) (mcast_addr)\n"
537 : : " Add a multicast MAC addresses on port_id.\n\n"
538 : :
539 : : "mcast_addr remove (port_id) (mcast_addr)\n"
540 : : " Remove a multicast MAC address from port_id.\n\n"
541 : :
542 : : "mcast_addr flush (port_id)\n"
543 : : " Flush all multicast MAC addresses on port_id.\n\n"
544 : :
545 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
546 : : " Set the MAC address for a VF from the PF.\n\n"
547 : :
548 : : "set eth-peer (port_id) (peer_addr)\n"
549 : : " set the peer address for certain port.\n\n"
550 : :
551 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
552 : : " Add/Remove a or all unicast hash filter(s)"
553 : : "from port X.\n\n"
554 : :
555 : : "set promisc (port_id|all) (on|off)\n"
556 : : " Set the promiscuous mode on port_id, or all.\n\n"
557 : :
558 : : "set allmulti (port_id|all) (on|off)\n"
559 : : " Set the allmulti mode on port_id, or all.\n\n"
560 : :
561 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
562 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
563 : : " (on|off) autoneg (on|off) (port_id)\n"
564 : : "set flow_ctrl rx (on|off) (portid)\n"
565 : : "set flow_ctrl tx (on|off) (portid)\n"
566 : : "set flow_ctrl high_water (high_water) (portid)\n"
567 : : "set flow_ctrl low_water (low_water) (portid)\n"
568 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
569 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
570 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
571 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
572 : : " Set the link flow control parameter on a port.\n\n"
573 : :
574 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
575 : : " (low_water) (pause_time) (priority) (port_id)\n"
576 : : " Set the priority flow control parameter on a"
577 : : " port.\n\n"
578 : :
579 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
580 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
581 : : " Set the queue priority flow control parameter on a"
582 : : " given Rx and Tx queues of a port.\n\n"
583 : :
584 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
585 : : " set available descriptors threshold for Rx queue\n\n"
586 : :
587 : : "set xstats-hide-zero on|off\n"
588 : : " Set the option to hide the zero values"
589 : : " for xstats display.\n"
590 : :
591 : : "set record-core-cycles on|off\n"
592 : : " Set the option to enable measurement of CPU cycles.\n"
593 : :
594 : : "set record-burst-stats on|off\n"
595 : : " Set the option to enable display of RX and TX bursts.\n"
596 : :
597 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
598 : : " Enable/Disable a VF receive/transmit from a port\n\n"
599 : :
600 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
601 : : "|MPE) (on|off)\n"
602 : : " AUPE:accepts untagged VLAN;"
603 : : "ROPE:accept unicast hash\n\n"
604 : : " BAM:accepts broadcast packets;"
605 : : "MPE:accepts all multicast packets\n\n"
606 : : " Enable/Disable a VF receive mode of a port\n\n"
607 : :
608 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
609 : : " Set rate limit for a queue of a port\n\n"
610 : :
611 : : "set port (port_id) vf (vf_id) rate (rate_num) "
612 : : "queue_mask (queue_mask_value)\n"
613 : : " Set rate limit for queues in VF of a port\n\n"
614 : :
615 : : "set flush_rx (on|off)\n"
616 : : " Flush (default) or don't flush RX streams before"
617 : : " forwarding. Mainly used with PCAP drivers.\n\n"
618 : :
619 : : "set link-up port (port_id)\n"
620 : : " Set link up for a port.\n\n"
621 : :
622 : : "set link-down port (port_id)\n"
623 : : " Set link down for a port.\n\n"
624 : :
625 : : "set port (port_id) ptype_mask (ptype_mask)\n"
626 : : " set packet types classification for a specific port\n\n"
627 : :
628 : : "show port meter cap (port_id)\n"
629 : : " Show port meter capability information\n\n"
630 : :
631 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
632 : : " meter profile add - srtcm rfc 2697\n\n"
633 : :
634 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
635 : : " meter profile add - trtcm rfc 2698\n\n"
636 : :
637 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
638 : : " meter profile add - trtcm rfc 4115\n\n"
639 : :
640 : : "del port meter profile (port_id) (profile_id)\n"
641 : : " meter profile delete\n\n"
642 : :
643 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
644 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
645 : : "(dscp_tbl_entry63)]\n"
646 : : " meter create\n\n"
647 : :
648 : : "enable port meter (port_id) (mtr_id)\n"
649 : : " meter enable\n\n"
650 : :
651 : : "disable port meter (port_id) (mtr_id)\n"
652 : : " meter disable\n\n"
653 : :
654 : : "del port meter (port_id) (mtr_id)\n"
655 : : " meter delete\n\n"
656 : :
657 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
658 : : "y_actions (actions) r_actions (actions)\n"
659 : : " meter policy add\n\n"
660 : :
661 : : "del port meter policy (port_id) (policy_id)\n"
662 : : " meter policy delete\n\n"
663 : :
664 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
665 : : " meter update meter profile\n\n"
666 : :
667 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
668 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
669 : : " update meter dscp table entries\n\n"
670 : :
671 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
672 : : "(action0) [(action1) (action2)]\n"
673 : : " meter update policer action\n\n"
674 : :
675 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
676 : : " meter update stats\n\n"
677 : :
678 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
679 : : " set fec mode for a specific port\n\n"
680 : :
681 : : "show port cman capa (port_id)\n"
682 : : " Show congestion management capabilities\n\n"
683 : :
684 : : "show port cman config (port_id)\n"
685 : : " Show congestion management configuration\n\n"
686 : :
687 : : "set port cman config (port_id) (queue_id) default | "
688 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
689 : : "(max_thresh) (prob_inv)]\n"
690 : : " Set congestion management configuration\n\n"
691 : :
692 : : "set port (port_id) led (on|off)\n"
693 : : " Set a controllable LED associated with a certain"
694 : : " port on or off.\n\n"
695 : :
696 : : , list_pkt_forwarding_modes()
697 : : );
698 : : }
699 : :
700 : 0 : if (show_all || !strcmp(res->section, "ports")) {
701 : :
702 : 0 : cmdline_printf(
703 : : cl,
704 : : "\n"
705 : : "Port Operations:\n"
706 : : "----------------\n\n"
707 : :
708 : : "port start (port_id|all)\n"
709 : : " Start all ports or port_id.\n\n"
710 : :
711 : : "port stop (port_id|all)\n"
712 : : " Stop all ports or port_id.\n\n"
713 : :
714 : : "port close (port_id|all)\n"
715 : : " Close all ports or port_id.\n\n"
716 : :
717 : : "port reset (port_id|all)\n"
718 : : " Reset all ports or port_id.\n\n"
719 : :
720 : : "port attach (ident)\n"
721 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
722 : :
723 : : "port detach (port_id)\n"
724 : : " Detach physical or virtual dev by port_id\n\n"
725 : :
726 : : "port config (port_id|all)"
727 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|"
728 : : "100000|200000|400000|800000|auto)"
729 : : " duplex (half|full|auto)\n"
730 : : " Set speed and duplex for all ports or port_id\n\n"
731 : :
732 : : "port config (port_id|all) loopback (mode)\n"
733 : : " Set loopback mode for all ports or port_id\n\n"
734 : :
735 : : "port config all (rxq|txq|rxd|txd) (value)\n"
736 : : " Set number for rxq/txq/rxd/txd.\n\n"
737 : :
738 : : "port config all max-pkt-len (value)\n"
739 : : " Set the max packet length.\n\n"
740 : :
741 : : "port config all max-lro-pkt-size (value)\n"
742 : : " Set the max LRO aggregated packet size.\n\n"
743 : :
744 : : "port config all drop-en (on|off)\n"
745 : : " Enable or disable packet drop on all RX queues of all ports when no "
746 : : "receive buffers available.\n\n"
747 : :
748 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
749 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
750 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
751 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
752 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
753 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
754 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
755 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
756 : : " Set the RSS mode.\n\n"
757 : :
758 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
759 : : " Set the RSS redirection table.\n\n"
760 : :
761 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
762 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
763 : : " Set the RSS hash algorithm.\n\n"
764 : :
765 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
766 : : " pfc (on|off)\n"
767 : : " Set the DCB mode.\n\n"
768 : :
769 : : "port config all burst (value)\n"
770 : : " Set the number of packets per burst.\n\n"
771 : :
772 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
773 : : " (value)\n"
774 : : " Set the ring prefetch/host/writeback threshold"
775 : : " for tx/rx queue.\n\n"
776 : :
777 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
778 : : " Set free threshold for rx/tx, or set"
779 : : " tx rs bit threshold.\n\n"
780 : : "port config mtu X value\n"
781 : : " Set the MTU of port X to a given value\n\n"
782 : :
783 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
784 : : " Set a rx/tx queue's ring size configuration, the new"
785 : : " value will take effect after command that (re-)start the port"
786 : : " or command that setup the specific queue\n\n"
787 : :
788 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
789 : : " Start/stop a rx/tx queue of port X. Only take effect"
790 : : " when port X is started\n\n"
791 : :
792 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
793 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
794 : : " take effect when port X is stopped.\n\n"
795 : :
796 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
797 : : " Setup a rx/tx queue of port X.\n\n"
798 : :
799 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
800 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
801 : :
802 : : "port config (port_id|all) rx_offload all|vlan_strip|"
803 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
804 : : "outer_ipv4_cksum|macsec_strip|"
805 : : "vlan_filter|vlan_extend|scatter|"
806 : : "buffer_split|timestamp|security|keep_crc on|off\n"
807 : : " Enable or disable a per port Rx offloading"
808 : : " on all Rx queues of a port\n\n"
809 : :
810 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
811 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
812 : : "outer_ipv4_cksum|macsec_strip|"
813 : : "vlan_filter|vlan_extend|scatter|"
814 : : "buffer_split|timestamp|security|keep_crc on|off\n"
815 : : " Enable or disable a per queue Rx offloading"
816 : : " only on a specific Rx queue\n\n"
817 : :
818 : : "port config (port_id|all) tx_offload all|vlan_insert|"
819 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
820 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
821 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
822 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
823 : : "security on|off\n"
824 : : " Enable or disable a per port Tx offloading"
825 : : " on all Tx queues of a port\n\n"
826 : :
827 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
828 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
829 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
830 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
831 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
832 : : " on|off\n"
833 : : " Enable or disable a per queue Tx offloading"
834 : : " only on a specific Tx queue\n\n"
835 : :
836 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
837 : : " Load an eBPF program as a callback"
838 : : " for particular RX/TX queue\n\n"
839 : :
840 : : "bpf-unload rx|tx (port) (queue)\n"
841 : : " Unload previously loaded eBPF program"
842 : : " for particular RX/TX queue\n\n"
843 : :
844 : : "port config (port_id) tx_metadata (value)\n"
845 : : " Set Tx metadata value per port. Testpmd will add this value"
846 : : " to any Tx packet sent from this port\n\n"
847 : :
848 : : "port config (port_id) dynf (name) set|clear\n"
849 : : " Register a dynf and Set/clear this flag on Tx. "
850 : : "Testpmd will set this value to any Tx packet "
851 : : "sent from this port\n\n"
852 : :
853 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
854 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
855 : :
856 : : "port config (port_id) txq (queue_id) affinity (value)\n"
857 : : " Map a Tx queue with an aggregated port "
858 : : "of the DPDK port\n\n"
859 : :
860 : : "port config (port_id|all) speed_lanes (value)\n"
861 : : " Set number of lanes for all ports or port_id for a forced speed\n\n"
862 : : );
863 : : }
864 : :
865 : 0 : if (show_all || !strcmp(res->section, "filters")) {
866 : :
867 : 0 : cmdline_printf(
868 : : cl,
869 : : "\n"
870 : : "filters:\n"
871 : : "--------\n\n"
872 : :
873 : : "flow validate {port_id}"
874 : : " [group {group_id}] [priority {level}]"
875 : : " [ingress] [egress]"
876 : : " pattern {item} [/ {item} [...]] / end"
877 : : " actions {action} [/ {action} [...]] / end\n"
878 : : " Check whether a flow rule can be created.\n\n"
879 : :
880 : : "flow create {port_id}"
881 : : " [group {group_id}] [priority {level}]"
882 : : " [ingress] [egress]"
883 : : " pattern {item} [/ {item} [...]] / end"
884 : : " actions {action} [/ {action} [...]] / end\n"
885 : : " Create a flow rule.\n\n"
886 : :
887 : : "flow destroy {port_id} rule {rule_id} [...]\n"
888 : : " Destroy specific flow rules.\n\n"
889 : :
890 : : "flow update {port_id} {rule_id}"
891 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
892 : : " Update a flow rule with new actions.\n\n"
893 : :
894 : : "flow flush {port_id}\n"
895 : : " Destroy all flow rules.\n\n"
896 : :
897 : : "flow query {port_id} {rule_id} {action}\n"
898 : : " Query an existing flow rule.\n\n"
899 : :
900 : : "flow list {port_id} [group {group_id}] [...]\n"
901 : : " List existing flow rules sorted by priority,"
902 : : " filtered by group identifiers.\n\n"
903 : :
904 : : "flow isolate {port_id} {boolean}\n"
905 : : " Restrict ingress traffic to the defined"
906 : : " flow rules\n\n"
907 : :
908 : : "flow aged {port_id} [destroy]\n"
909 : : " List and destroy aged flows"
910 : : " flow rules\n\n"
911 : :
912 : : "flow indirect_action {port_id} create"
913 : : " [action_id {indirect_action_id}]"
914 : : " [ingress] [egress]"
915 : : " action {action} / end\n"
916 : : " Create indirect action.\n\n"
917 : :
918 : : "flow indirect_action {port_id} update"
919 : : " {indirect_action_id} action {action} / end\n"
920 : : " Update indirect action.\n\n"
921 : :
922 : : "flow indirect_action {port_id} destroy"
923 : : " action_id {indirect_action_id} [...]\n"
924 : : " Destroy specific indirect actions.\n\n"
925 : :
926 : : "flow indirect_action {port_id} query"
927 : : " {indirect_action_id}\n"
928 : : " Query an existing indirect action.\n\n"
929 : :
930 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
931 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
932 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
933 : : " Configure the VXLAN encapsulation for flows.\n\n"
934 : :
935 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
936 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
937 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
938 : : " eth-dst (eth-dst)\n"
939 : : " Configure the VXLAN encapsulation for flows.\n\n"
940 : :
941 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
942 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
943 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
944 : : " eth-dst (eth-dst)\n"
945 : : " Configure the VXLAN encapsulation for flows.\n\n"
946 : :
947 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
948 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
949 : : " (eth-dst)\n"
950 : : " Configure the NVGRE encapsulation for flows.\n\n"
951 : :
952 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
953 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
954 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
955 : : " Configure the NVGRE encapsulation for flows.\n\n"
956 : :
957 : : "set raw_encap {flow items}\n"
958 : : " Configure the encapsulation with raw data.\n\n"
959 : :
960 : : "set raw_decap {flow items}\n"
961 : : " Configure the decapsulation with raw data.\n\n"
962 : :
963 : : );
964 : : }
965 : :
966 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
967 : 0 : cmdline_printf(
968 : : cl,
969 : : "\n"
970 : : "Traffic Management:\n"
971 : : "--------------\n"
972 : : "show port tm cap (port_id)\n"
973 : : " Display the port TM capability.\n\n"
974 : :
975 : : "show port tm level cap (port_id) (level_id)\n"
976 : : " Display the port TM hierarchical level capability.\n\n"
977 : :
978 : : "show port tm node cap (port_id) (node_id)\n"
979 : : " Display the port TM node capability.\n\n"
980 : :
981 : : "show port tm node type (port_id) (node_id)\n"
982 : : " Display the port TM node type.\n\n"
983 : :
984 : : "show port tm node stats (port_id) (node_id) (clear)\n"
985 : : " Display the port TM node stats.\n\n"
986 : :
987 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
988 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
989 : : " (packet_length_adjust) (packet_mode)\n"
990 : : " Add port tm node private shaper profile.\n\n"
991 : :
992 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
993 : : " Delete port tm node private shaper profile.\n\n"
994 : :
995 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
996 : : " (shaper_profile_id)\n"
997 : : " Add/update port tm node shared shaper.\n\n"
998 : :
999 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
1000 : : " Delete port tm node shared shaper.\n\n"
1001 : :
1002 : : "set port tm node shaper profile (port_id) (node_id)"
1003 : : " (shaper_profile_id)\n"
1004 : : " Set port tm node shaper profile.\n\n"
1005 : :
1006 : : "add port tm node wred profile (port_id) (wred_profile_id)"
1007 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1008 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1009 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1010 : : " Add port tm node wred profile.\n\n"
1011 : :
1012 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
1013 : : " Delete port tm node wred profile.\n\n"
1014 : :
1015 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1016 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1017 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1018 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1019 : : " Add port tm nonleaf node.\n\n"
1020 : :
1021 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1022 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1023 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1024 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1025 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
1026 : :
1027 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1028 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1029 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1030 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1031 : : " Add port tm leaf node.\n\n"
1032 : :
1033 : : "del port tm node (port_id) (node_id)\n"
1034 : : " Delete port tm node.\n\n"
1035 : :
1036 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1037 : : " (priority) (weight)\n"
1038 : : " Set port tm node parent.\n\n"
1039 : :
1040 : : "suspend port tm node (port_id) (node_id)"
1041 : : " Suspend tm node.\n\n"
1042 : :
1043 : : "resume port tm node (port_id) (node_id)"
1044 : : " Resume tm node.\n\n"
1045 : :
1046 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1047 : : " Commit tm hierarchy.\n\n"
1048 : :
1049 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1050 : : " (red)\n"
1051 : : " Enables/Disables the traffic management marking"
1052 : : " for IP ECN (Explicit Congestion Notification)"
1053 : : " packets on a given port\n\n"
1054 : :
1055 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1056 : : " (red)\n"
1057 : : " Enables/Disables the traffic management marking"
1058 : : " on the port for IP dscp packets\n\n"
1059 : :
1060 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1061 : : " (red)\n"
1062 : : " Enables/Disables the traffic management marking"
1063 : : " on the port for VLAN packets with DEI enabled\n\n"
1064 : : );
1065 : : }
1066 : :
1067 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1068 : 0 : cmdline_printf(
1069 : : cl,
1070 : : "\n"
1071 : : "Device Operations:\n"
1072 : : "--------------\n"
1073 : : "device detach (identifier)\n"
1074 : : " Detach device by identifier.\n\n"
1075 : : );
1076 : : }
1077 : :
1078 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1079 : : struct testpmd_driver_commands *c;
1080 : : unsigned int i;
1081 : :
1082 : 0 : cmdline_printf(
1083 : : cl,
1084 : : "\n"
1085 : : "Driver specific:\n"
1086 : : "----------------\n"
1087 : : );
1088 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1089 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1090 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1091 : : }
1092 : : }
1093 : 0 : }
1094 : :
1095 : : static cmdline_parse_token_string_t cmd_help_long_help =
1096 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1097 : :
1098 : : static cmdline_parse_token_string_t cmd_help_long_section =
1099 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1100 : : "all#control#display#config#ports#"
1101 : : "filters#traffic_management#devices#drivers");
1102 : :
1103 : : static cmdline_parse_inst_t cmd_help_long = {
1104 : : .f = cmd_help_long_parsed,
1105 : : .data = NULL,
1106 : : .help_str = "help all|control|display|config|ports|"
1107 : : "filters|traffic_management|devices|drivers: "
1108 : : "Show help",
1109 : : .tokens = {
1110 : : (void *)&cmd_help_long_help,
1111 : : (void *)&cmd_help_long_section,
1112 : : NULL,
1113 : : },
1114 : : };
1115 : :
1116 : :
1117 : : /* *** start/stop/close all ports *** */
1118 : : struct cmd_operate_port_result {
1119 : : cmdline_fixed_string_t keyword;
1120 : : cmdline_fixed_string_t name;
1121 : : cmdline_fixed_string_t value;
1122 : : };
1123 : :
1124 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1125 : : __rte_unused struct cmdline *cl,
1126 : : __rte_unused void *data)
1127 : : {
1128 : : struct cmd_operate_port_result *res = parsed_result;
1129 : :
1130 : 0 : if (!strcmp(res->name, "start"))
1131 : 0 : start_port(RTE_PORT_ALL);
1132 : 0 : else if (!strcmp(res->name, "stop"))
1133 : 0 : stop_port(RTE_PORT_ALL);
1134 : 0 : else if (!strcmp(res->name, "close"))
1135 : 0 : close_port(RTE_PORT_ALL);
1136 : 0 : else if (!strcmp(res->name, "reset"))
1137 : 0 : reset_port(RTE_PORT_ALL);
1138 : : else
1139 : 0 : fprintf(stderr, "Unknown parameter\n");
1140 : 0 : }
1141 : :
1142 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1143 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1144 : : "port");
1145 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1146 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1147 : : "start#stop#close#reset");
1148 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1149 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1150 : :
1151 : : static cmdline_parse_inst_t cmd_operate_port = {
1152 : : .f = cmd_operate_port_parsed,
1153 : : .data = NULL,
1154 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1155 : : .tokens = {
1156 : : (void *)&cmd_operate_port_all_cmd,
1157 : : (void *)&cmd_operate_port_all_port,
1158 : : (void *)&cmd_operate_port_all_all,
1159 : : NULL,
1160 : : },
1161 : : };
1162 : :
1163 : : /* *** start/stop/close specific port *** */
1164 : : struct cmd_operate_specific_port_result {
1165 : : cmdline_fixed_string_t keyword;
1166 : : cmdline_fixed_string_t name;
1167 : : uint8_t value;
1168 : : };
1169 : :
1170 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1171 : : __rte_unused struct cmdline *cl,
1172 : : __rte_unused void *data)
1173 : : {
1174 : : struct cmd_operate_specific_port_result *res = parsed_result;
1175 : :
1176 : 0 : if (!strcmp(res->name, "start"))
1177 : 0 : start_port(res->value);
1178 : 0 : else if (!strcmp(res->name, "stop"))
1179 : 0 : stop_port(res->value);
1180 : 0 : else if (!strcmp(res->name, "close"))
1181 : 0 : close_port(res->value);
1182 : 0 : else if (!strcmp(res->name, "reset"))
1183 : 0 : reset_port(res->value);
1184 : : else
1185 : 0 : fprintf(stderr, "Unknown parameter\n");
1186 : 0 : }
1187 : :
1188 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1189 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1190 : : keyword, "port");
1191 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1192 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1193 : : name, "start#stop#close#reset");
1194 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1195 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1196 : : value, RTE_UINT8);
1197 : :
1198 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1199 : : .f = cmd_operate_specific_port_parsed,
1200 : : .data = NULL,
1201 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1202 : : .tokens = {
1203 : : (void *)&cmd_operate_specific_port_cmd,
1204 : : (void *)&cmd_operate_specific_port_port,
1205 : : (void *)&cmd_operate_specific_port_id,
1206 : : NULL,
1207 : : },
1208 : : };
1209 : :
1210 : : /* *** enable port setup (after attach) via iterator or event *** */
1211 : : struct cmd_set_port_setup_on_result {
1212 : : cmdline_fixed_string_t set;
1213 : : cmdline_fixed_string_t port;
1214 : : cmdline_fixed_string_t setup;
1215 : : cmdline_fixed_string_t on;
1216 : : cmdline_fixed_string_t mode;
1217 : : };
1218 : :
1219 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1220 : : __rte_unused struct cmdline *cl,
1221 : : __rte_unused void *data)
1222 : : {
1223 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1224 : :
1225 : 0 : if (strcmp(res->mode, "event") == 0)
1226 : 0 : setup_on_probe_event = true;
1227 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1228 : 0 : setup_on_probe_event = false;
1229 : : else
1230 : 0 : fprintf(stderr, "Unknown mode\n");
1231 : 0 : }
1232 : :
1233 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1234 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1235 : : set, "set");
1236 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1237 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1238 : : port, "port");
1239 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1240 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1241 : : setup, "setup");
1242 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1243 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1244 : : on, "on");
1245 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1246 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1247 : : mode, "iterator#event");
1248 : :
1249 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1250 : : .f = cmd_set_port_setup_on_parsed,
1251 : : .data = NULL,
1252 : : .help_str = "set port setup on iterator|event",
1253 : : .tokens = {
1254 : : (void *)&cmd_set_port_setup_on_set,
1255 : : (void *)&cmd_set_port_setup_on_port,
1256 : : (void *)&cmd_set_port_setup_on_setup,
1257 : : (void *)&cmd_set_port_setup_on_on,
1258 : : (void *)&cmd_set_port_setup_on_mode,
1259 : : NULL,
1260 : : },
1261 : : };
1262 : :
1263 : : /* *** attach a specified port *** */
1264 : : struct cmd_operate_attach_port_result {
1265 : : cmdline_fixed_string_t port;
1266 : : cmdline_fixed_string_t keyword;
1267 : : cmdline_multi_string_t identifier;
1268 : : };
1269 : :
1270 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1271 : : __rte_unused struct cmdline *cl,
1272 : : __rte_unused void *data)
1273 : : {
1274 : : struct cmd_operate_attach_port_result *res = parsed_result;
1275 : :
1276 : 0 : if (!strcmp(res->keyword, "attach"))
1277 : 0 : attach_port(res->identifier);
1278 : : else
1279 : 0 : fprintf(stderr, "Unknown parameter\n");
1280 : 0 : }
1281 : :
1282 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1283 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1284 : : port, "port");
1285 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1286 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1287 : : keyword, "attach");
1288 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1289 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1290 : : identifier, TOKEN_STRING_MULTI);
1291 : :
1292 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1293 : : .f = cmd_operate_attach_port_parsed,
1294 : : .data = NULL,
1295 : : .help_str = "port attach <identifier>: "
1296 : : "(identifier: pci address or virtual dev name)",
1297 : : .tokens = {
1298 : : (void *)&cmd_operate_attach_port_port,
1299 : : (void *)&cmd_operate_attach_port_keyword,
1300 : : (void *)&cmd_operate_attach_port_identifier,
1301 : : NULL,
1302 : : },
1303 : : };
1304 : :
1305 : : /* *** detach a specified port *** */
1306 : : struct cmd_operate_detach_port_result {
1307 : : cmdline_fixed_string_t port;
1308 : : cmdline_fixed_string_t keyword;
1309 : : portid_t port_id;
1310 : : };
1311 : :
1312 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1313 : : __rte_unused struct cmdline *cl,
1314 : : __rte_unused void *data)
1315 : : {
1316 : : struct cmd_operate_detach_port_result *res = parsed_result;
1317 : :
1318 : 0 : if (!strcmp(res->keyword, "detach")) {
1319 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1320 : 0 : detach_port_device(res->port_id);
1321 : : } else {
1322 : 0 : fprintf(stderr, "Unknown parameter\n");
1323 : : }
1324 : : }
1325 : :
1326 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1327 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1328 : : port, "port");
1329 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1330 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1331 : : keyword, "detach");
1332 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1333 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1334 : : port_id, RTE_UINT16);
1335 : :
1336 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1337 : : .f = cmd_operate_detach_port_parsed,
1338 : : .data = NULL,
1339 : : .help_str = "port detach <port_id>",
1340 : : .tokens = {
1341 : : (void *)&cmd_operate_detach_port_port,
1342 : : (void *)&cmd_operate_detach_port_keyword,
1343 : : (void *)&cmd_operate_detach_port_port_id,
1344 : : NULL,
1345 : : },
1346 : : };
1347 : :
1348 : : /* *** detach device by identifier *** */
1349 : : struct cmd_operate_detach_device_result {
1350 : : cmdline_fixed_string_t device;
1351 : : cmdline_fixed_string_t keyword;
1352 : : cmdline_fixed_string_t identifier;
1353 : : };
1354 : :
1355 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1356 : : __rte_unused struct cmdline *cl,
1357 : : __rte_unused void *data)
1358 : : {
1359 : : struct cmd_operate_detach_device_result *res = parsed_result;
1360 : :
1361 : 0 : if (!strcmp(res->keyword, "detach"))
1362 : 0 : detach_devargs(res->identifier);
1363 : : else
1364 : 0 : fprintf(stderr, "Unknown parameter\n");
1365 : 0 : }
1366 : :
1367 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1368 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1369 : : device, "device");
1370 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1371 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1372 : : keyword, "detach");
1373 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1374 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1375 : : identifier, NULL);
1376 : :
1377 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1378 : : .f = cmd_operate_detach_device_parsed,
1379 : : .data = NULL,
1380 : : .help_str = "device detach <identifier>:"
1381 : : "(identifier: pci address or virtual dev name)",
1382 : : .tokens = {
1383 : : (void *)&cmd_operate_detach_device_device,
1384 : : (void *)&cmd_operate_detach_device_keyword,
1385 : : (void *)&cmd_operate_detach_device_identifier,
1386 : : NULL,
1387 : : },
1388 : : };
1389 : : /* *** configure speed for all ports *** */
1390 : : struct cmd_config_speed_all {
1391 : : cmdline_fixed_string_t port;
1392 : : cmdline_fixed_string_t keyword;
1393 : : cmdline_fixed_string_t all;
1394 : : cmdline_fixed_string_t item1;
1395 : : cmdline_fixed_string_t item2;
1396 : : cmdline_fixed_string_t value1;
1397 : : cmdline_fixed_string_t value2;
1398 : : };
1399 : :
1400 : : static int
1401 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1402 : : {
1403 : :
1404 : : int duplex;
1405 : :
1406 : 0 : if (!strcmp(duplexstr, "half")) {
1407 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1408 : 0 : } else if (!strcmp(duplexstr, "full")) {
1409 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1410 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1411 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1412 : : } else {
1413 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1414 : 0 : return -1;
1415 : : }
1416 : :
1417 : 0 : if (!strcmp(speedstr, "10")) {
1418 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1419 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1420 : 0 : } else if (!strcmp(speedstr, "100")) {
1421 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1422 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1423 : : } else {
1424 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1425 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1426 : 0 : return -1;
1427 : : }
1428 : 0 : if (!strcmp(speedstr, "1000")) {
1429 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1430 : 0 : } else if (!strcmp(speedstr, "2500")) {
1431 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1432 : 0 : } else if (!strcmp(speedstr, "5000")) {
1433 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1434 : 0 : } else if (!strcmp(speedstr, "10000")) {
1435 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1436 : 0 : } else if (!strcmp(speedstr, "25000")) {
1437 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1438 : 0 : } else if (!strcmp(speedstr, "40000")) {
1439 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1440 : 0 : } else if (!strcmp(speedstr, "50000")) {
1441 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1442 : 0 : } else if (!strcmp(speedstr, "100000")) {
1443 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1444 : 0 : } else if (!strcmp(speedstr, "200000")) {
1445 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1446 : 0 : } else if (!strcmp(speedstr, "400000")) {
1447 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1448 : 0 : } else if (!strcmp(speedstr, "800000")) {
1449 : 0 : *speed = RTE_ETH_LINK_SPEED_800G;
1450 : 0 : } else if (!strcmp(speedstr, "auto")) {
1451 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1452 : : } else {
1453 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1454 : 0 : return -1;
1455 : : }
1456 : : }
1457 : :
1458 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1459 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1460 : :
1461 : : return 0;
1462 : : }
1463 : :
1464 : : static void
1465 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1466 : : __rte_unused struct cmdline *cl,
1467 : : __rte_unused void *data)
1468 : : {
1469 : : struct cmd_config_speed_all *res = parsed_result;
1470 : : uint32_t link_speed;
1471 : : portid_t pid;
1472 : :
1473 : 0 : if (!all_ports_stopped()) {
1474 : 0 : fprintf(stderr, "Please stop all ports first\n");
1475 : 0 : return;
1476 : : }
1477 : :
1478 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1479 : : &link_speed) < 0)
1480 : : return;
1481 : :
1482 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1483 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1484 : : }
1485 : :
1486 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1487 : : }
1488 : :
1489 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1490 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1491 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1492 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1493 : : "config");
1494 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1495 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1496 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1497 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1498 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1499 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1500 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1501 : : "100000#200000#400000#800000#auto");
1502 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1503 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1504 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1505 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1506 : : "half#full#auto");
1507 : :
1508 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1509 : : .f = cmd_config_speed_all_parsed,
1510 : : .data = NULL,
1511 : : .help_str = "port config all speed "
1512 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1513 : : "100000|200000|400000|800000|auto "
1514 : : "duplex half|full|auto",
1515 : : .tokens = {
1516 : : (void *)&cmd_config_speed_all_port,
1517 : : (void *)&cmd_config_speed_all_keyword,
1518 : : (void *)&cmd_config_speed_all_all,
1519 : : (void *)&cmd_config_speed_all_item1,
1520 : : (void *)&cmd_config_speed_all_value1,
1521 : : (void *)&cmd_config_speed_all_item2,
1522 : : (void *)&cmd_config_speed_all_value2,
1523 : : NULL,
1524 : : },
1525 : : };
1526 : :
1527 : : /* *** configure speed for specific port *** */
1528 : : struct cmd_config_speed_specific {
1529 : : cmdline_fixed_string_t port;
1530 : : cmdline_fixed_string_t keyword;
1531 : : portid_t id;
1532 : : cmdline_fixed_string_t item1;
1533 : : cmdline_fixed_string_t item2;
1534 : : cmdline_fixed_string_t value1;
1535 : : cmdline_fixed_string_t value2;
1536 : : };
1537 : :
1538 : : static void
1539 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1540 : : __rte_unused struct cmdline *cl,
1541 : : __rte_unused void *data)
1542 : : {
1543 : : struct cmd_config_speed_specific *res = parsed_result;
1544 : : uint32_t link_speed;
1545 : :
1546 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1547 : 0 : return;
1548 : :
1549 : 0 : if (!port_is_stopped(res->id)) {
1550 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1551 : 0 : return;
1552 : : }
1553 : :
1554 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1555 : : &link_speed) < 0)
1556 : : return;
1557 : :
1558 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1559 : :
1560 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1561 : : }
1562 : :
1563 : :
1564 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1565 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1566 : : "port");
1567 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1568 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1569 : : "config");
1570 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1571 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1572 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1573 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1574 : : "speed");
1575 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1576 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1577 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1578 : : "100000#200000#400000#800000#auto");
1579 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1580 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1581 : : "duplex");
1582 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1583 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1584 : : "half#full#auto");
1585 : :
1586 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1587 : : .f = cmd_config_speed_specific_parsed,
1588 : : .data = NULL,
1589 : : .help_str = "port config <port_id> speed "
1590 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1591 : : "100000|200000|400000|800000|auto "
1592 : : "duplex half|full|auto",
1593 : : .tokens = {
1594 : : (void *)&cmd_config_speed_specific_port,
1595 : : (void *)&cmd_config_speed_specific_keyword,
1596 : : (void *)&cmd_config_speed_specific_id,
1597 : : (void *)&cmd_config_speed_specific_item1,
1598 : : (void *)&cmd_config_speed_specific_value1,
1599 : : (void *)&cmd_config_speed_specific_item2,
1600 : : (void *)&cmd_config_speed_specific_value2,
1601 : : NULL,
1602 : : },
1603 : : };
1604 : :
1605 : : static int
1606 : 0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
1607 : : {
1608 : : int ret;
1609 : :
1610 : 0 : ret = rte_eth_speed_lanes_set(pid, lanes);
1611 : 0 : if (ret == -ENOTSUP) {
1612 : 0 : fprintf(stderr, "Function not implemented\n");
1613 : 0 : return -1;
1614 : 0 : } else if (ret < 0) {
1615 : 0 : fprintf(stderr, "Set speed lanes failed\n");
1616 : 0 : return -1;
1617 : : }
1618 : :
1619 : : return 0;
1620 : : }
1621 : :
1622 : : static void
1623 : 0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
1624 : : {
1625 : : unsigned int i;
1626 : : uint32_t capa;
1627 : :
1628 : : printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
1629 : : printf("\n-----------------------------------\n");
1630 : 0 : for (i = 0; i < num; i++) {
1631 : 0 : printf("%-17s ",
1632 : 0 : rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
1633 : 0 : capa = speed_lanes_capa[i].capa;
1634 : : int s = 0;
1635 : :
1636 : 0 : while (capa) {
1637 : 0 : if (capa & 0x1)
1638 : : printf("%-2d ", s);
1639 : 0 : s++;
1640 : 0 : capa = capa >> 1;
1641 : : }
1642 : : printf("\n");
1643 : : }
1644 : 0 : }
1645 : :
1646 : : /* *** display speed lanes per port capabilities *** */
1647 : : struct cmd_show_speed_lanes_result {
1648 : : cmdline_fixed_string_t cmd_show;
1649 : : cmdline_fixed_string_t cmd_port;
1650 : : cmdline_fixed_string_t cmd_keyword;
1651 : : portid_t cmd_pid;
1652 : : };
1653 : :
1654 : : static void
1655 : 0 : cmd_show_speed_lanes_parsed(void *parsed_result,
1656 : : __rte_unused struct cmdline *cl,
1657 : : __rte_unused void *data)
1658 : : {
1659 : : struct cmd_show_speed_lanes_result *res = parsed_result;
1660 : : struct rte_eth_speed_lanes_capa *speed_lanes_capa;
1661 : : unsigned int num;
1662 : : int ret;
1663 : :
1664 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
1665 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
1666 : 0 : return;
1667 : : }
1668 : :
1669 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
1670 : 0 : if (ret == -ENOTSUP) {
1671 : 0 : fprintf(stderr, "Function not implemented\n");
1672 : 0 : return;
1673 : 0 : } else if (ret < 0) {
1674 : 0 : fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
1675 : 0 : return;
1676 : : }
1677 : :
1678 : 0 : num = (unsigned int)ret;
1679 : 0 : speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
1680 : 0 : if (speed_lanes_capa == NULL) {
1681 : 0 : fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
1682 : 0 : return;
1683 : : }
1684 : :
1685 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
1686 : 0 : if (ret < 0) {
1687 : 0 : fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
1688 : 0 : goto out;
1689 : : }
1690 : :
1691 : 0 : show_speed_lanes_capability(num, speed_lanes_capa);
1692 : 0 : out:
1693 : 0 : free(speed_lanes_capa);
1694 : : }
1695 : :
1696 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
1697 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1698 : : cmd_show, "show");
1699 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
1700 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1701 : : cmd_port, "port");
1702 : : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
1703 : : TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
1704 : : cmd_pid, RTE_UINT16);
1705 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
1706 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1707 : : cmd_keyword, "speed_lanes");
1708 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
1709 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1710 : : cmd_keyword, "capabilities");
1711 : :
1712 : : static cmdline_parse_inst_t cmd_show_speed_lanes = {
1713 : : .f = cmd_show_speed_lanes_parsed,
1714 : : .data = NULL,
1715 : : .help_str = "show port <port_id> speed_lanes capabilities",
1716 : : .tokens = {
1717 : : (void *)&cmd_show_speed_lanes_show,
1718 : : (void *)&cmd_show_speed_lanes_port,
1719 : : (void *)&cmd_show_speed_lanes_pid,
1720 : : (void *)&cmd_show_speed_lanes_keyword,
1721 : : (void *)&cmd_show_speed_lanes_cap_keyword,
1722 : : NULL,
1723 : : },
1724 : : };
1725 : :
1726 : : /* *** configure speed_lanes for all ports *** */
1727 : : struct cmd_config_speed_lanes_all {
1728 : : cmdline_fixed_string_t port;
1729 : : cmdline_fixed_string_t keyword;
1730 : : cmdline_fixed_string_t all;
1731 : : cmdline_fixed_string_t item;
1732 : : uint32_t lanes;
1733 : : };
1734 : :
1735 : : static void
1736 : 0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
1737 : : __rte_unused struct cmdline *cl,
1738 : : __rte_unused void *data)
1739 : : {
1740 : : struct cmd_config_speed_lanes_all *res = parsed_result;
1741 : : portid_t pid;
1742 : :
1743 : 0 : if (!all_ports_stopped()) {
1744 : 0 : fprintf(stderr, "Please stop all ports first\n");
1745 : 0 : return;
1746 : : }
1747 : :
1748 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1749 : 0 : if (parse_speed_lanes_cfg(pid, res->lanes))
1750 : : return;
1751 : : }
1752 : :
1753 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1754 : : }
1755 : :
1756 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
1757 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
1758 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
1759 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
1760 : : "config");
1761 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
1762 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
1763 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
1764 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
1765 : : "speed_lanes");
1766 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
1767 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
1768 : :
1769 : : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
1770 : : .f = cmd_config_speed_lanes_all_parsed,
1771 : : .data = NULL,
1772 : : .help_str = "port config all speed_lanes <value>",
1773 : : .tokens = {
1774 : : (void *)&cmd_config_speed_lanes_all_port,
1775 : : (void *)&cmd_config_speed_lanes_all_keyword,
1776 : : (void *)&cmd_config_speed_lanes_all_all,
1777 : : (void *)&cmd_config_speed_lanes_all_item,
1778 : : (void *)&cmd_config_speed_lanes_all_lanes,
1779 : : NULL,
1780 : : },
1781 : : };
1782 : :
1783 : : /* *** configure speed_lanes for specific port *** */
1784 : : struct cmd_config_speed_lanes_specific {
1785 : : cmdline_fixed_string_t port;
1786 : : cmdline_fixed_string_t keyword;
1787 : : uint16_t port_id;
1788 : : cmdline_fixed_string_t item;
1789 : : uint32_t lanes;
1790 : : };
1791 : :
1792 : : static void
1793 : 0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
1794 : : __rte_unused struct cmdline *cl,
1795 : : __rte_unused void *data)
1796 : : {
1797 : : struct cmd_config_speed_lanes_specific *res = parsed_result;
1798 : :
1799 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1800 : : return;
1801 : :
1802 : 0 : if (!port_is_stopped(res->port_id)) {
1803 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1804 : 0 : return;
1805 : : }
1806 : :
1807 : 0 : if (parse_speed_lanes_cfg(res->port_id, res->lanes))
1808 : : return;
1809 : :
1810 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1811 : : }
1812 : :
1813 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
1814 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
1815 : : "port");
1816 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
1817 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
1818 : : "config");
1819 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
1820 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
1821 : : RTE_UINT16);
1822 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
1823 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
1824 : : "speed_lanes");
1825 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
1826 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
1827 : : RTE_UINT32);
1828 : :
1829 : : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
1830 : : .f = cmd_config_speed_lanes_specific_parsed,
1831 : : .data = NULL,
1832 : : .help_str = "port config <port_id> speed_lanes <value>",
1833 : : .tokens = {
1834 : : (void *)&cmd_config_speed_lanes_specific_port,
1835 : : (void *)&cmd_config_speed_lanes_specific_keyword,
1836 : : (void *)&cmd_config_speed_lanes_specific_id,
1837 : : (void *)&cmd_config_speed_lanes_specific_item,
1838 : : (void *)&cmd_config_speed_lanes_specific_lanes,
1839 : : NULL,
1840 : : },
1841 : : };
1842 : :
1843 : : /* *** configure loopback for all ports *** */
1844 : : struct cmd_config_loopback_all {
1845 : : cmdline_fixed_string_t port;
1846 : : cmdline_fixed_string_t keyword;
1847 : : cmdline_fixed_string_t all;
1848 : : cmdline_fixed_string_t item;
1849 : : uint32_t mode;
1850 : : };
1851 : :
1852 : : static void
1853 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1854 : : __rte_unused struct cmdline *cl,
1855 : : __rte_unused void *data)
1856 : : {
1857 : : struct cmd_config_loopback_all *res = parsed_result;
1858 : : portid_t pid;
1859 : :
1860 : 0 : if (!all_ports_stopped()) {
1861 : 0 : fprintf(stderr, "Please stop all ports first\n");
1862 : 0 : return;
1863 : : }
1864 : :
1865 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1866 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1867 : : }
1868 : :
1869 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1870 : : }
1871 : :
1872 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1873 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1874 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1875 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1876 : : "config");
1877 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1878 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1879 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1880 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1881 : : "loopback");
1882 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1883 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1884 : :
1885 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1886 : : .f = cmd_config_loopback_all_parsed,
1887 : : .data = NULL,
1888 : : .help_str = "port config all loopback <mode>",
1889 : : .tokens = {
1890 : : (void *)&cmd_config_loopback_all_port,
1891 : : (void *)&cmd_config_loopback_all_keyword,
1892 : : (void *)&cmd_config_loopback_all_all,
1893 : : (void *)&cmd_config_loopback_all_item,
1894 : : (void *)&cmd_config_loopback_all_mode,
1895 : : NULL,
1896 : : },
1897 : : };
1898 : :
1899 : : /* *** configure loopback for specific port *** */
1900 : : struct cmd_config_loopback_specific {
1901 : : cmdline_fixed_string_t port;
1902 : : cmdline_fixed_string_t keyword;
1903 : : uint16_t port_id;
1904 : : cmdline_fixed_string_t item;
1905 : : uint32_t mode;
1906 : : };
1907 : :
1908 : : static void
1909 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1910 : : __rte_unused struct cmdline *cl,
1911 : : __rte_unused void *data)
1912 : : {
1913 : : struct cmd_config_loopback_specific *res = parsed_result;
1914 : :
1915 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1916 : : return;
1917 : :
1918 : 0 : if (!port_is_stopped(res->port_id)) {
1919 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1920 : 0 : return;
1921 : : }
1922 : :
1923 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1924 : :
1925 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1926 : : }
1927 : :
1928 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1929 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1930 : : "port");
1931 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1932 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1933 : : "config");
1934 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1935 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1936 : : RTE_UINT16);
1937 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1938 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1939 : : "loopback");
1940 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1941 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1942 : : RTE_UINT32);
1943 : :
1944 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1945 : : .f = cmd_config_loopback_specific_parsed,
1946 : : .data = NULL,
1947 : : .help_str = "port config <port_id> loopback <mode>",
1948 : : .tokens = {
1949 : : (void *)&cmd_config_loopback_specific_port,
1950 : : (void *)&cmd_config_loopback_specific_keyword,
1951 : : (void *)&cmd_config_loopback_specific_id,
1952 : : (void *)&cmd_config_loopback_specific_item,
1953 : : (void *)&cmd_config_loopback_specific_mode,
1954 : : NULL,
1955 : : },
1956 : : };
1957 : :
1958 : : /* *** configure txq/rxq, txd/rxd *** */
1959 : : struct cmd_config_rx_tx {
1960 : : cmdline_fixed_string_t port;
1961 : : cmdline_fixed_string_t keyword;
1962 : : cmdline_fixed_string_t all;
1963 : : cmdline_fixed_string_t name;
1964 : : uint16_t value;
1965 : : };
1966 : :
1967 : : static void
1968 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1969 : : __rte_unused struct cmdline *cl,
1970 : : __rte_unused void *data)
1971 : : {
1972 : : struct cmd_config_rx_tx *res = parsed_result;
1973 : :
1974 : 0 : if (!all_ports_stopped()) {
1975 : 0 : fprintf(stderr, "Please stop all ports first\n");
1976 : 0 : return;
1977 : : }
1978 : 0 : if (!strcmp(res->name, "rxq")) {
1979 : 0 : if (!res->value && !nb_txq) {
1980 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1981 : 0 : return;
1982 : : }
1983 : 0 : if (check_nb_rxq(res->value) != 0)
1984 : : return;
1985 : 0 : nb_rxq = res->value;
1986 : : }
1987 : 0 : else if (!strcmp(res->name, "txq")) {
1988 : 0 : if (!res->value && !nb_rxq) {
1989 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1990 : 0 : return;
1991 : : }
1992 : 0 : if (check_nb_txq(res->value) != 0)
1993 : : return;
1994 : 0 : nb_txq = res->value;
1995 : : }
1996 : 0 : else if (!strcmp(res->name, "rxd")) {
1997 : 0 : if (check_nb_rxd(res->value) != 0)
1998 : : return;
1999 : 0 : nb_rxd = res->value;
2000 : 0 : } else if (!strcmp(res->name, "txd")) {
2001 : 0 : if (check_nb_txd(res->value) != 0)
2002 : : return;
2003 : :
2004 : 0 : nb_txd = res->value;
2005 : : } else {
2006 : 0 : fprintf(stderr, "Unknown parameter\n");
2007 : 0 : return;
2008 : : }
2009 : :
2010 : 0 : init_port_config();
2011 : :
2012 : 0 : fwd_config_setup();
2013 : :
2014 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2015 : : }
2016 : :
2017 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
2018 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2019 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2020 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2021 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
2022 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2023 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
2024 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2025 : : "rxq#txq#rxd#txd");
2026 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
2027 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
2028 : :
2029 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
2030 : : .f = cmd_config_rx_tx_parsed,
2031 : : .data = NULL,
2032 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
2033 : : .tokens = {
2034 : : (void *)&cmd_config_rx_tx_port,
2035 : : (void *)&cmd_config_rx_tx_keyword,
2036 : : (void *)&cmd_config_rx_tx_all,
2037 : : (void *)&cmd_config_rx_tx_name,
2038 : : (void *)&cmd_config_rx_tx_value,
2039 : : NULL,
2040 : : },
2041 : : };
2042 : :
2043 : : /* *** config max packet length *** */
2044 : : struct cmd_config_max_pkt_len_result {
2045 : : cmdline_fixed_string_t port;
2046 : : cmdline_fixed_string_t keyword;
2047 : : cmdline_fixed_string_t all;
2048 : : cmdline_fixed_string_t name;
2049 : : uint32_t value;
2050 : : };
2051 : :
2052 : : static void
2053 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
2054 : : __rte_unused struct cmdline *cl,
2055 : : __rte_unused void *data)
2056 : : {
2057 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
2058 : : portid_t port_id;
2059 : : int ret;
2060 : :
2061 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
2062 : : printf("Unknown parameter\n");
2063 : 0 : return;
2064 : : }
2065 : :
2066 : 0 : if (!all_ports_stopped()) {
2067 : 0 : fprintf(stderr, "Please stop all ports first\n");
2068 : 0 : return;
2069 : : }
2070 : :
2071 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
2072 : 0 : struct rte_port *port = &ports[port_id];
2073 : :
2074 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
2075 : 0 : fprintf(stderr,
2076 : : "max-pkt-len can not be less than %d\n",
2077 : : RTE_ETHER_MIN_LEN);
2078 : 0 : return;
2079 : : }
2080 : :
2081 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
2082 : 0 : if (ret != 0) {
2083 : 0 : fprintf(stderr,
2084 : : "rte_eth_dev_info_get() failed for port %u\n",
2085 : : port_id);
2086 : 0 : return;
2087 : : }
2088 : :
2089 : 0 : update_mtu_from_frame_size(port_id, res->value);
2090 : : }
2091 : :
2092 : 0 : init_port_config();
2093 : :
2094 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2095 : : }
2096 : :
2097 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2098 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2099 : : "port");
2100 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2101 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2102 : : "config");
2103 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2104 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2105 : : "all");
2106 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2107 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2108 : : "max-pkt-len");
2109 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2110 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2111 : : RTE_UINT32);
2112 : :
2113 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
2114 : : .f = cmd_config_max_pkt_len_parsed,
2115 : : .data = NULL,
2116 : : .help_str = "port config all max-pkt-len <value>",
2117 : : .tokens = {
2118 : : (void *)&cmd_config_max_pkt_len_port,
2119 : : (void *)&cmd_config_max_pkt_len_keyword,
2120 : : (void *)&cmd_config_max_pkt_len_all,
2121 : : (void *)&cmd_config_max_pkt_len_name,
2122 : : (void *)&cmd_config_max_pkt_len_value,
2123 : : NULL,
2124 : : },
2125 : : };
2126 : :
2127 : : /* *** config max LRO aggregated packet size *** */
2128 : : struct cmd_config_max_lro_pkt_size_result {
2129 : : cmdline_fixed_string_t port;
2130 : : cmdline_fixed_string_t keyword;
2131 : : cmdline_fixed_string_t all;
2132 : : cmdline_fixed_string_t name;
2133 : : uint32_t value;
2134 : : };
2135 : :
2136 : : static void
2137 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2138 : : __rte_unused struct cmdline *cl,
2139 : : __rte_unused void *data)
2140 : : {
2141 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2142 : : portid_t pid;
2143 : :
2144 : 0 : if (!all_ports_stopped()) {
2145 : 0 : fprintf(stderr, "Please stop all ports first\n");
2146 : 0 : return;
2147 : : }
2148 : :
2149 : 0 : RTE_ETH_FOREACH_DEV(pid) {
2150 : 0 : struct rte_port *port = &ports[pid];
2151 : :
2152 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
2153 : 0 : if (res->value ==
2154 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
2155 : : return;
2156 : :
2157 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2158 : : } else {
2159 : 0 : fprintf(stderr, "Unknown parameter\n");
2160 : 0 : return;
2161 : : }
2162 : : }
2163 : :
2164 : 0 : init_port_config();
2165 : :
2166 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2167 : : }
2168 : :
2169 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2170 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2171 : : port, "port");
2172 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2173 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2174 : : keyword, "config");
2175 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2176 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2177 : : all, "all");
2178 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2179 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2180 : : name, "max-lro-pkt-size");
2181 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2182 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2183 : : value, RTE_UINT32);
2184 : :
2185 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2186 : : .f = cmd_config_max_lro_pkt_size_parsed,
2187 : : .data = NULL,
2188 : : .help_str = "port config all max-lro-pkt-size <value>",
2189 : : .tokens = {
2190 : : (void *)&cmd_config_max_lro_pkt_size_port,
2191 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
2192 : : (void *)&cmd_config_max_lro_pkt_size_all,
2193 : : (void *)&cmd_config_max_lro_pkt_size_name,
2194 : : (void *)&cmd_config_max_lro_pkt_size_value,
2195 : : NULL,
2196 : : },
2197 : : };
2198 : :
2199 : : /* *** configure port MTU *** */
2200 : : struct cmd_config_mtu_result {
2201 : : cmdline_fixed_string_t port;
2202 : : cmdline_fixed_string_t keyword;
2203 : : cmdline_fixed_string_t mtu;
2204 : : portid_t port_id;
2205 : : uint16_t value;
2206 : : };
2207 : :
2208 : : static void
2209 : 0 : cmd_config_mtu_parsed(void *parsed_result,
2210 : : __rte_unused struct cmdline *cl,
2211 : : __rte_unused void *data)
2212 : : {
2213 : : struct cmd_config_mtu_result *res = parsed_result;
2214 : :
2215 : 0 : port_mtu_set(res->port_id, res->value);
2216 : 0 : }
2217 : :
2218 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
2219 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2220 : : "port");
2221 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2222 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2223 : : "config");
2224 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2225 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2226 : : "mtu");
2227 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2228 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2229 : : RTE_UINT16);
2230 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
2231 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2232 : : RTE_UINT16);
2233 : :
2234 : : static cmdline_parse_inst_t cmd_config_mtu = {
2235 : : .f = cmd_config_mtu_parsed,
2236 : : .data = NULL,
2237 : : .help_str = "port config mtu <port_id> <value>",
2238 : : .tokens = {
2239 : : (void *)&cmd_config_mtu_port,
2240 : : (void *)&cmd_config_mtu_keyword,
2241 : : (void *)&cmd_config_mtu_mtu,
2242 : : (void *)&cmd_config_mtu_port_id,
2243 : : (void *)&cmd_config_mtu_value,
2244 : : NULL,
2245 : : },
2246 : : };
2247 : :
2248 : : /* *** configure rx mode *** */
2249 : : struct cmd_config_rx_mode_flag {
2250 : : cmdline_fixed_string_t port;
2251 : : cmdline_fixed_string_t keyword;
2252 : : cmdline_fixed_string_t all;
2253 : : cmdline_fixed_string_t name;
2254 : : cmdline_fixed_string_t value;
2255 : : };
2256 : :
2257 : : static void
2258 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
2259 : : __rte_unused struct cmdline *cl,
2260 : : __rte_unused void *data)
2261 : : {
2262 : : struct cmd_config_rx_mode_flag *res = parsed_result;
2263 : :
2264 : 0 : if (!all_ports_stopped()) {
2265 : 0 : fprintf(stderr, "Please stop all ports first\n");
2266 : 0 : return;
2267 : : }
2268 : :
2269 : 0 : if (!strcmp(res->name, "drop-en")) {
2270 : 0 : if (!strcmp(res->value, "on"))
2271 : 0 : rx_drop_en = 1;
2272 : 0 : else if (!strcmp(res->value, "off"))
2273 : 0 : rx_drop_en = 0;
2274 : : else {
2275 : 0 : fprintf(stderr, "Unknown parameter\n");
2276 : 0 : return;
2277 : : }
2278 : : } else {
2279 : 0 : fprintf(stderr, "Unknown parameter\n");
2280 : 0 : return;
2281 : : }
2282 : :
2283 : 0 : init_port_config();
2284 : :
2285 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2286 : : }
2287 : :
2288 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2289 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2290 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2291 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2292 : : "config");
2293 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2294 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2295 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2296 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2297 : : "drop-en");
2298 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2299 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2300 : : "on#off");
2301 : :
2302 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2303 : : .f = cmd_config_rx_mode_flag_parsed,
2304 : : .data = NULL,
2305 : : .help_str = "port config all drop-en on|off",
2306 : : .tokens = {
2307 : : (void *)&cmd_config_rx_mode_flag_port,
2308 : : (void *)&cmd_config_rx_mode_flag_keyword,
2309 : : (void *)&cmd_config_rx_mode_flag_all,
2310 : : (void *)&cmd_config_rx_mode_flag_name,
2311 : : (void *)&cmd_config_rx_mode_flag_value,
2312 : : NULL,
2313 : : },
2314 : : };
2315 : :
2316 : : /* *** configure rss *** */
2317 : : struct cmd_config_rss {
2318 : : cmdline_fixed_string_t port;
2319 : : cmdline_fixed_string_t keyword;
2320 : : cmdline_fixed_string_t all;
2321 : : cmdline_fixed_string_t name;
2322 : : cmdline_fixed_string_t value;
2323 : : };
2324 : :
2325 : : static void
2326 : 0 : cmd_config_rss_parsed(void *parsed_result,
2327 : : __rte_unused struct cmdline *cl,
2328 : : __rte_unused void *data)
2329 : : {
2330 : : struct cmd_config_rss *res = parsed_result;
2331 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2332 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2333 : : int use_default = 0;
2334 : : int all_updated = 1;
2335 : : int diag;
2336 : : uint16_t i;
2337 : : int ret;
2338 : :
2339 : 0 : if (!strcmp(res->value, "level-default")) {
2340 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2341 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2342 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2343 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2344 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2345 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2346 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2347 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2348 : 0 : } else if (!strcmp(res->value, "default")) {
2349 : : use_default = 1;
2350 : 0 : } else if (isdigit(res->value[0])) {
2351 : : int value = atoi(res->value);
2352 : 0 : if (value > 0 && value < 64)
2353 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2354 : : else {
2355 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2356 : 0 : return;
2357 : : }
2358 : 0 : } else if (!strcmp(res->value, "none")) {
2359 : : rss_conf.rss_hf = 0;
2360 : : } else {
2361 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2362 : 0 : if (rss_conf.rss_hf == 0) {
2363 : 0 : fprintf(stderr, "Unknown parameter\n");
2364 : 0 : return;
2365 : : }
2366 : : }
2367 : : rss_conf.rss_key = NULL;
2368 : : /* Update global configuration for RSS types. */
2369 : 0 : RTE_ETH_FOREACH_DEV(i) {
2370 : : struct rte_eth_rss_conf local_rss_conf;
2371 : :
2372 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2373 : 0 : if (ret != 0)
2374 : 0 : return;
2375 : :
2376 : 0 : if (use_default)
2377 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2378 : :
2379 : 0 : local_rss_conf = rss_conf;
2380 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2381 : 0 : dev_info.flow_type_rss_offloads;
2382 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2383 : : printf("Port %u modified RSS hash function based on hardware support,"
2384 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2385 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2386 : : }
2387 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2388 : 0 : if (diag < 0) {
2389 : : all_updated = 0;
2390 : 0 : fprintf(stderr,
2391 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2392 : : i, -diag, strerror(-diag));
2393 : : }
2394 : : }
2395 : 0 : if (all_updated && !use_default) {
2396 : 0 : rss_hf = rss_conf.rss_hf;
2397 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2398 : : }
2399 : : }
2400 : :
2401 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2402 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2403 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2404 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2405 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2406 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2407 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2408 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2409 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2410 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2411 : :
2412 : : static cmdline_parse_inst_t cmd_config_rss = {
2413 : : .f = cmd_config_rss_parsed,
2414 : : .data = NULL,
2415 : : .help_str = "port config all rss "
2416 : : "all|default|level-default|level-outer|level-inner|"
2417 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2418 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2419 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2420 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2421 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2422 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2423 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2424 : : .tokens = {
2425 : : (void *)&cmd_config_rss_port,
2426 : : (void *)&cmd_config_rss_keyword,
2427 : : (void *)&cmd_config_rss_all,
2428 : : (void *)&cmd_config_rss_name,
2429 : : (void *)&cmd_config_rss_value,
2430 : : NULL,
2431 : : },
2432 : : };
2433 : :
2434 : : /* *** configure rss hash key *** */
2435 : : struct cmd_config_rss_hash_key {
2436 : : cmdline_fixed_string_t port;
2437 : : cmdline_fixed_string_t config;
2438 : : portid_t port_id;
2439 : : cmdline_fixed_string_t rss_hash_key;
2440 : : cmdline_fixed_string_t rss_type;
2441 : : cmdline_fixed_string_t key;
2442 : : };
2443 : :
2444 : : static uint8_t
2445 : : hexa_digit_to_value(char hexa_digit)
2446 : : {
2447 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2448 : : return (uint8_t) (hexa_digit - '0');
2449 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2450 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2451 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2452 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2453 : : /* Invalid hexa digit */
2454 : : return 0xFF;
2455 : : }
2456 : :
2457 : : static uint8_t
2458 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2459 : : {
2460 : : uint8_t hexa_v;
2461 : :
2462 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2463 : : if (hexa_v == 0xFF)
2464 : 0 : fprintf(stderr,
2465 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2466 : : key[idx], idx);
2467 : 0 : return hexa_v;
2468 : : }
2469 : :
2470 : : static void
2471 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2472 : : __rte_unused struct cmdline *cl,
2473 : : __rte_unused void *data)
2474 : : {
2475 : : struct cmd_config_rss_hash_key *res = parsed_result;
2476 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2477 : : uint8_t xdgt0;
2478 : : uint8_t xdgt1;
2479 : : int i;
2480 : : struct rte_eth_dev_info dev_info;
2481 : : uint8_t hash_key_size;
2482 : : uint32_t key_len;
2483 : : int ret;
2484 : :
2485 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2486 : 0 : if (ret != 0)
2487 : 0 : return;
2488 : :
2489 : 0 : if (dev_info.hash_key_size > 0 &&
2490 : : dev_info.hash_key_size <= sizeof(hash_key))
2491 : : hash_key_size = dev_info.hash_key_size;
2492 : : else {
2493 : 0 : fprintf(stderr,
2494 : : "dev_info did not provide a valid hash key size\n");
2495 : 0 : return;
2496 : : }
2497 : : /* Check the length of the RSS hash key */
2498 : 0 : key_len = strlen(res->key);
2499 : 0 : if (key_len != (hash_key_size * 2)) {
2500 : 0 : fprintf(stderr,
2501 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2502 : : (int)key_len, hash_key_size * 2);
2503 : 0 : return;
2504 : : }
2505 : : /* Translate RSS hash key into binary representation */
2506 : 0 : for (i = 0; i < hash_key_size; i++) {
2507 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2508 : 0 : if (xdgt0 == 0xFF)
2509 : : return;
2510 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2511 : 0 : if (xdgt1 == 0xFF)
2512 : : return;
2513 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2514 : : }
2515 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2516 : : hash_key_size);
2517 : : }
2518 : :
2519 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2520 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2521 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2522 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2523 : : "config");
2524 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2525 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2526 : : RTE_UINT16);
2527 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2528 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2529 : : rss_hash_key, "rss-hash-key");
2530 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2531 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2532 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2533 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2534 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2535 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2536 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2537 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2538 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2539 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2540 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2541 : :
2542 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2543 : : .f = cmd_config_rss_hash_key_parsed,
2544 : : .data = NULL,
2545 : : .help_str = "port config <port_id> rss-hash-key "
2546 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2547 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2548 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2549 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2550 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2551 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2552 : : "<string of hex digits (variable length, NIC dependent)>",
2553 : : .tokens = {
2554 : : (void *)&cmd_config_rss_hash_key_port,
2555 : : (void *)&cmd_config_rss_hash_key_config,
2556 : : (void *)&cmd_config_rss_hash_key_port_id,
2557 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2558 : : (void *)&cmd_config_rss_hash_key_rss_type,
2559 : : (void *)&cmd_config_rss_hash_key_value,
2560 : : NULL,
2561 : : },
2562 : : };
2563 : :
2564 : : /* *** configure rss hash algorithm *** */
2565 : : struct cmd_config_rss_hash_algo {
2566 : : cmdline_fixed_string_t port;
2567 : : cmdline_fixed_string_t config;
2568 : : portid_t port_id;
2569 : : cmdline_fixed_string_t rss_hash_algo;
2570 : : cmdline_fixed_string_t algo;
2571 : : };
2572 : :
2573 : : static void
2574 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2575 : : __rte_unused struct cmdline *cl,
2576 : : __rte_unused void *data)
2577 : : {
2578 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2579 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2580 : : struct rte_eth_rss_conf rss_conf;
2581 : : uint32_t algorithm;
2582 : : int ret;
2583 : :
2584 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2585 : 0 : rss_conf.rss_key = rss_key;
2586 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2587 : 0 : if (ret != 0) {
2588 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2589 : 0 : res->port_id);
2590 : 0 : return;
2591 : : }
2592 : :
2593 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2594 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2595 : 0 : if (ret != 0) {
2596 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2597 : 0 : res->port_id, res->algo);
2598 : 0 : return;
2599 : : }
2600 : :
2601 : 0 : rss_conf.algorithm = algorithm;
2602 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2603 : 0 : if (ret != 0) {
2604 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2605 : 0 : res->port_id);
2606 : 0 : return;
2607 : : }
2608 : : }
2609 : :
2610 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2611 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2612 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2613 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2614 : : "config");
2615 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2616 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2617 : : RTE_UINT16);
2618 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2619 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2620 : : rss_hash_algo, "rss-hash-algo");
2621 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2622 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2623 : : "default#simple_xor#toeplitz#"
2624 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2625 : :
2626 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2627 : : .f = cmd_config_rss_hash_algo_parsed,
2628 : : .data = NULL,
2629 : : .help_str = "port config <port_id> rss-hash-algo "
2630 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2631 : : .tokens = {
2632 : : (void *)&cmd_config_rss_hash_algo_port,
2633 : : (void *)&cmd_config_rss_hash_algo_config,
2634 : : (void *)&cmd_config_rss_hash_algo_port_id,
2635 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2636 : : (void *)&cmd_config_rss_hash_algo_algo,
2637 : : NULL,
2638 : : },
2639 : : };
2640 : :
2641 : : /* *** cleanup txq mbufs *** */
2642 : : struct cmd_cleanup_txq_mbufs_result {
2643 : : cmdline_fixed_string_t port;
2644 : : cmdline_fixed_string_t keyword;
2645 : : cmdline_fixed_string_t name;
2646 : : uint16_t port_id;
2647 : : uint16_t queue_id;
2648 : : uint32_t free_cnt;
2649 : : };
2650 : :
2651 : : static void
2652 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2653 : : __rte_unused struct cmdline *cl,
2654 : : __rte_unused void *data)
2655 : : {
2656 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2657 : 0 : uint16_t port_id = res->port_id;
2658 : 0 : uint16_t queue_id = res->queue_id;
2659 : 0 : uint32_t free_cnt = res->free_cnt;
2660 : : struct rte_eth_txq_info qinfo;
2661 : : int ret;
2662 : :
2663 : 0 : if (test_done == 0) {
2664 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2665 : 0 : return;
2666 : : }
2667 : :
2668 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2669 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2670 : : port_id, queue_id);
2671 : 0 : return;
2672 : : }
2673 : :
2674 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2675 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2676 : 0 : return;
2677 : : }
2678 : :
2679 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2680 : 0 : if (ret < 0) {
2681 : 0 : fprintf(stderr,
2682 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2683 : : port_id, queue_id, strerror(-ret), ret);
2684 : 0 : return;
2685 : : }
2686 : :
2687 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2688 : : port_id, queue_id, ret);
2689 : : }
2690 : :
2691 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2692 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2693 : : "port");
2694 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2695 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2696 : : "cleanup");
2697 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2698 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2699 : : RTE_UINT16);
2700 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2701 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2702 : : "txq");
2703 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2704 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2705 : : RTE_UINT16);
2706 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2707 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2708 : : RTE_UINT32);
2709 : :
2710 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2711 : : .f = cmd_cleanup_txq_mbufs_parsed,
2712 : : .data = NULL,
2713 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2714 : : .tokens = {
2715 : : (void *)&cmd_cleanup_txq_mbufs_port,
2716 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2717 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2718 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2719 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2720 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2721 : : NULL,
2722 : : },
2723 : : };
2724 : :
2725 : : /* *** configure port rxq/txq ring size *** */
2726 : : struct cmd_config_rxtx_ring_size {
2727 : : cmdline_fixed_string_t port;
2728 : : cmdline_fixed_string_t config;
2729 : : portid_t portid;
2730 : : cmdline_fixed_string_t rxtxq;
2731 : : uint16_t qid;
2732 : : cmdline_fixed_string_t rsize;
2733 : : uint16_t size;
2734 : : };
2735 : :
2736 : : static void
2737 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2738 : : __rte_unused struct cmdline *cl,
2739 : : __rte_unused void *data)
2740 : : {
2741 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2742 : : struct rte_port *port;
2743 : : uint8_t isrx;
2744 : :
2745 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2746 : : return;
2747 : :
2748 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2749 : 0 : fprintf(stderr, "Invalid port id\n");
2750 : 0 : return;
2751 : : }
2752 : :
2753 : 0 : port = &ports[res->portid];
2754 : :
2755 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2756 : : isrx = 1;
2757 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2758 : : isrx = 0;
2759 : : else {
2760 : 0 : fprintf(stderr, "Unknown parameter\n");
2761 : 0 : return;
2762 : : }
2763 : :
2764 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2765 : : return;
2766 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2767 : : return;
2768 : :
2769 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2770 : 0 : fprintf(stderr,
2771 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2772 : : rx_free_thresh);
2773 : 0 : return;
2774 : : }
2775 : :
2776 : 0 : if (isrx)
2777 : 0 : port->nb_rx_desc[res->qid] = res->size;
2778 : : else
2779 : 0 : port->nb_tx_desc[res->qid] = res->size;
2780 : :
2781 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2782 : : }
2783 : :
2784 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2785 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2786 : : port, "port");
2787 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2788 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2789 : : config, "config");
2790 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2791 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2792 : : portid, RTE_UINT16);
2793 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2794 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2795 : : rxtxq, "rxq#txq");
2796 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2797 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2798 : : qid, RTE_UINT16);
2799 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2800 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2801 : : rsize, "ring_size");
2802 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2803 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2804 : : size, RTE_UINT16);
2805 : :
2806 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2807 : : .f = cmd_config_rxtx_ring_size_parsed,
2808 : : .data = NULL,
2809 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2810 : : .tokens = {
2811 : : (void *)&cmd_config_rxtx_ring_size_port,
2812 : : (void *)&cmd_config_rxtx_ring_size_config,
2813 : : (void *)&cmd_config_rxtx_ring_size_portid,
2814 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2815 : : (void *)&cmd_config_rxtx_ring_size_qid,
2816 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2817 : : (void *)&cmd_config_rxtx_ring_size_size,
2818 : : NULL,
2819 : : },
2820 : : };
2821 : :
2822 : : /* *** configure port rxq/txq start/stop *** */
2823 : : struct cmd_config_rxtx_queue {
2824 : : cmdline_fixed_string_t port;
2825 : : portid_t portid;
2826 : : cmdline_fixed_string_t rxtxq;
2827 : : uint16_t qid;
2828 : : cmdline_fixed_string_t opname;
2829 : : };
2830 : :
2831 : : static void
2832 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2833 : : __rte_unused struct cmdline *cl,
2834 : : __rte_unused void *data)
2835 : : {
2836 : : struct cmd_config_rxtx_queue *res = parsed_result;
2837 : : struct rte_port *port;
2838 : : uint8_t isrx;
2839 : : uint8_t isstart;
2840 : : uint8_t *state;
2841 : : int ret = 0;
2842 : :
2843 : 0 : if (test_done == 0) {
2844 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2845 : 0 : return;
2846 : : }
2847 : :
2848 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2849 : : return;
2850 : :
2851 : 0 : if (port_is_started(res->portid) != 1) {
2852 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2853 : 0 : return;
2854 : : }
2855 : :
2856 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2857 : : isrx = 1;
2858 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2859 : : isrx = 0;
2860 : : else {
2861 : 0 : fprintf(stderr, "Unknown parameter\n");
2862 : 0 : return;
2863 : : }
2864 : :
2865 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2866 : : return;
2867 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2868 : : return;
2869 : :
2870 : 0 : if (!strcmp(res->opname, "start"))
2871 : : isstart = 1;
2872 : 0 : else if (!strcmp(res->opname, "stop"))
2873 : : isstart = 0;
2874 : : else {
2875 : 0 : fprintf(stderr, "Unknown parameter\n");
2876 : 0 : return;
2877 : : }
2878 : :
2879 : 0 : if (isstart && isrx)
2880 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2881 : 0 : else if (!isstart && isrx)
2882 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2883 : 0 : else if (isstart && !isrx)
2884 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2885 : : else
2886 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2887 : :
2888 : 0 : if (ret == -ENOTSUP) {
2889 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2890 : 0 : return;
2891 : : }
2892 : :
2893 : 0 : port = &ports[res->portid];
2894 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2895 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2896 : : RTE_ETH_QUEUE_STATE_STOPPED;
2897 : : }
2898 : :
2899 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2900 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2901 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2902 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2903 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2904 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2905 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2906 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2907 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2908 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2909 : : "start#stop");
2910 : :
2911 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2912 : : .f = cmd_config_rxtx_queue_parsed,
2913 : : .data = NULL,
2914 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2915 : : .tokens = {
2916 : : (void *)&cmd_config_rxtx_queue_port,
2917 : : (void *)&cmd_config_rxtx_queue_portid,
2918 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2919 : : (void *)&cmd_config_rxtx_queue_qid,
2920 : : (void *)&cmd_config_rxtx_queue_opname,
2921 : : NULL,
2922 : : },
2923 : : };
2924 : :
2925 : : /* *** configure port rxq/txq deferred start on/off *** */
2926 : : struct cmd_config_deferred_start_rxtx_queue {
2927 : : cmdline_fixed_string_t port;
2928 : : portid_t port_id;
2929 : : cmdline_fixed_string_t rxtxq;
2930 : : uint16_t qid;
2931 : : cmdline_fixed_string_t opname;
2932 : : cmdline_fixed_string_t state;
2933 : : };
2934 : :
2935 : : static void
2936 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2937 : : __rte_unused struct cmdline *cl,
2938 : : __rte_unused void *data)
2939 : : {
2940 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2941 : : struct rte_port *port;
2942 : : uint8_t isrx;
2943 : : uint8_t ison;
2944 : : uint8_t needreconfig = 0;
2945 : :
2946 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2947 : : return;
2948 : :
2949 : 0 : if (port_is_started(res->port_id) != 0) {
2950 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2951 : 0 : return;
2952 : : }
2953 : :
2954 : 0 : port = &ports[res->port_id];
2955 : :
2956 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2957 : :
2958 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2959 : : return;
2960 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2961 : : return;
2962 : :
2963 : 0 : ison = !strcmp(res->state, "on");
2964 : :
2965 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2966 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2967 : : needreconfig = 1;
2968 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2969 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2970 : : needreconfig = 1;
2971 : : }
2972 : :
2973 : : if (needreconfig)
2974 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2975 : : }
2976 : :
2977 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2978 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2979 : : port, "port");
2980 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2981 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2982 : : port_id, RTE_UINT16);
2983 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2984 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2985 : : rxtxq, "rxq#txq");
2986 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2987 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2988 : : qid, RTE_UINT16);
2989 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2990 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2991 : : opname, "deferred_start");
2992 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2993 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2994 : : state, "on#off");
2995 : :
2996 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2997 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
2998 : : .data = NULL,
2999 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
3000 : : .tokens = {
3001 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
3002 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
3003 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
3004 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
3005 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
3006 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
3007 : : NULL,
3008 : : },
3009 : : };
3010 : :
3011 : : /* *** configure port rxq/txq setup *** */
3012 : : struct cmd_setup_rxtx_queue {
3013 : : cmdline_fixed_string_t port;
3014 : : portid_t portid;
3015 : : cmdline_fixed_string_t rxtxq;
3016 : : uint16_t qid;
3017 : : cmdline_fixed_string_t setup;
3018 : : };
3019 : :
3020 : : /* Common CLI fields for queue setup */
3021 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
3022 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
3023 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
3024 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
3025 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
3026 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
3027 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
3028 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
3029 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
3030 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
3031 : :
3032 : : static void
3033 : 0 : cmd_setup_rxtx_queue_parsed(
3034 : : void *parsed_result,
3035 : : __rte_unused struct cmdline *cl,
3036 : : __rte_unused void *data)
3037 : : {
3038 : : struct cmd_setup_rxtx_queue *res = parsed_result;
3039 : : struct rte_port *port;
3040 : : struct rte_mempool *mp;
3041 : : unsigned int socket_id;
3042 : : uint8_t isrx = 0;
3043 : : int ret;
3044 : :
3045 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
3046 : : return;
3047 : :
3048 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
3049 : 0 : fprintf(stderr, "Invalid port id\n");
3050 : 0 : return;
3051 : : }
3052 : :
3053 : 0 : if (!strcmp(res->rxtxq, "rxq"))
3054 : : isrx = 1;
3055 : 0 : else if (!strcmp(res->rxtxq, "txq"))
3056 : : isrx = 0;
3057 : : else {
3058 : 0 : fprintf(stderr, "Unknown parameter\n");
3059 : 0 : return;
3060 : : }
3061 : :
3062 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
3063 : 0 : fprintf(stderr, "Invalid rx queue\n");
3064 : 0 : return;
3065 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
3066 : 0 : fprintf(stderr, "Invalid tx queue\n");
3067 : 0 : return;
3068 : : }
3069 : :
3070 : 0 : port = &ports[res->portid];
3071 : 0 : if (isrx) {
3072 : 0 : socket_id = rxring_numa[res->portid];
3073 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3074 : 0 : socket_id = port->socket_id;
3075 : :
3076 : 0 : mp = mbuf_pool_find_first(socket_id);
3077 : 0 : if (mp == NULL) {
3078 : : char buf[16];
3079 : :
3080 : 0 : fprintf(stderr,
3081 : : "Failed to setup RX queue: No mempool allocation on the socket %s\n",
3082 : : socket_id_str(socket_id, buf, sizeof(buf)));
3083 : : return;
3084 : : }
3085 : 0 : ret = rx_queue_setup(res->portid,
3086 : : res->qid,
3087 : 0 : port->nb_rx_desc[res->qid],
3088 : : socket_id,
3089 : 0 : &port->rxq[res->qid].conf,
3090 : : mp);
3091 : 0 : if (ret)
3092 : 0 : fprintf(stderr, "Failed to setup RX queue: %s\n",
3093 : : rte_strerror(-ret));
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: %s\n",
3111 : : rte_strerror(-ret));
3112 : : }
3113 : : }
3114 : :
3115 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
3116 : : .f = cmd_setup_rxtx_queue_parsed,
3117 : : .data = NULL,
3118 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
3119 : : .tokens = {
3120 : : (void *)&cmd_setup_rxtx_queue_port,
3121 : : (void *)&cmd_setup_rxtx_queue_portid,
3122 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
3123 : : (void *)&cmd_setup_rxtx_queue_qid,
3124 : : (void *)&cmd_setup_rxtx_queue_setup,
3125 : : NULL,
3126 : : },
3127 : : };
3128 : :
3129 : :
3130 : : /* *** Configure RSS RETA *** */
3131 : : struct cmd_config_rss_reta {
3132 : : cmdline_fixed_string_t port;
3133 : : cmdline_fixed_string_t keyword;
3134 : : portid_t port_id;
3135 : : cmdline_fixed_string_t name;
3136 : : cmdline_fixed_string_t list_name;
3137 : : cmdline_fixed_string_t list_of_items;
3138 : : };
3139 : :
3140 : : static int
3141 : 0 : parse_reta_config(const char *str,
3142 : : struct rte_eth_rss_reta_entry64 *reta_conf,
3143 : : uint16_t nb_entries)
3144 : : {
3145 : : int i;
3146 : : unsigned size;
3147 : : uint16_t hash_index, idx, shift;
3148 : : uint16_t nb_queue;
3149 : : char s[256];
3150 : : const char *p, *p0 = str;
3151 : : char *end;
3152 : : enum fieldnames {
3153 : : FLD_HASH_INDEX = 0,
3154 : : FLD_QUEUE,
3155 : : _NUM_FLD
3156 : : };
3157 : : unsigned long int_fld[_NUM_FLD];
3158 : : char *str_fld[_NUM_FLD];
3159 : :
3160 : 0 : while ((p = strchr(p0,'(')) != NULL) {
3161 : 0 : ++p;
3162 : 0 : if((p0 = strchr(p,')')) == NULL)
3163 : : return -1;
3164 : :
3165 : 0 : size = p0 - p;
3166 : 0 : if(size >= sizeof(s))
3167 : : return -1;
3168 : :
3169 : : snprintf(s, sizeof(s), "%.*s", size, p);
3170 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3171 : : return -1;
3172 : 0 : for (i = 0; i < _NUM_FLD; i++) {
3173 : 0 : errno = 0;
3174 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
3175 : 0 : if (errno != 0 || end == str_fld[i] ||
3176 : : int_fld[i] > 65535)
3177 : : return -1;
3178 : : }
3179 : :
3180 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3181 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3182 : :
3183 : 0 : if (hash_index >= nb_entries) {
3184 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
3185 : : hash_index);
3186 : 0 : return -1;
3187 : : }
3188 : :
3189 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3190 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3191 : 0 : reta_conf[idx].mask |= (1ULL << shift);
3192 : 0 : reta_conf[idx].reta[shift] = nb_queue;
3193 : : }
3194 : :
3195 : : return 0;
3196 : : }
3197 : :
3198 : : static void
3199 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
3200 : : __rte_unused struct cmdline *cl,
3201 : : __rte_unused void *data)
3202 : : {
3203 : : int ret;
3204 : : struct rte_eth_dev_info dev_info;
3205 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3206 : : struct cmd_config_rss_reta *res = parsed_result;
3207 : :
3208 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3209 : 0 : if (ret != 0)
3210 : 0 : return;
3211 : :
3212 : 0 : if (dev_info.reta_size == 0) {
3213 : 0 : fprintf(stderr,
3214 : : "Redirection table size is 0 which is invalid for RSS\n");
3215 : 0 : return;
3216 : : } else
3217 : 0 : printf("The reta size of port %d is %u\n",
3218 : 0 : res->port_id, dev_info.reta_size);
3219 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3220 : 0 : fprintf(stderr,
3221 : : "Currently do not support more than %u entries of redirection table\n",
3222 : : RTE_ETH_RSS_RETA_SIZE_512);
3223 : 0 : return;
3224 : : }
3225 : :
3226 : : memset(reta_conf, 0, sizeof(reta_conf));
3227 : 0 : if (!strcmp(res->list_name, "reta")) {
3228 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
3229 : : dev_info.reta_size)) {
3230 : 0 : fprintf(stderr,
3231 : : "Invalid RSS Redirection Table config entered\n");
3232 : 0 : return;
3233 : : }
3234 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
3235 : 0 : reta_conf, dev_info.reta_size);
3236 : 0 : if (ret != 0)
3237 : 0 : fprintf(stderr,
3238 : : "Bad redirection table parameter, return code = %d\n",
3239 : : ret);
3240 : : }
3241 : : }
3242 : :
3243 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3244 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3245 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3246 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3247 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3248 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3249 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3250 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3251 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3252 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3253 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3254 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3255 : : NULL);
3256 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
3257 : : .f = cmd_set_rss_reta_parsed,
3258 : : .data = NULL,
3259 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3260 : : .tokens = {
3261 : : (void *)&cmd_config_rss_reta_port,
3262 : : (void *)&cmd_config_rss_reta_keyword,
3263 : : (void *)&cmd_config_rss_reta_port_id,
3264 : : (void *)&cmd_config_rss_reta_name,
3265 : : (void *)&cmd_config_rss_reta_list_name,
3266 : : (void *)&cmd_config_rss_reta_list_of_items,
3267 : : NULL,
3268 : : },
3269 : : };
3270 : :
3271 : : /* *** SHOW PORT RETA INFO *** */
3272 : : struct cmd_showport_reta {
3273 : : cmdline_fixed_string_t show;
3274 : : cmdline_fixed_string_t port;
3275 : : portid_t port_id;
3276 : : cmdline_fixed_string_t rss;
3277 : : cmdline_fixed_string_t reta;
3278 : : uint16_t size;
3279 : : cmdline_fixed_string_t list_of_items;
3280 : : };
3281 : :
3282 : : static int
3283 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3284 : : uint16_t nb_entries,
3285 : : char *str)
3286 : : {
3287 : : uint32_t size;
3288 : : const char *p, *p0 = str;
3289 : : char s[256];
3290 : : char *end;
3291 : : char *str_fld[8];
3292 : : uint16_t i;
3293 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3294 : : RTE_ETH_RETA_GROUP_SIZE;
3295 : : int ret;
3296 : :
3297 : 0 : p = strchr(p0, '(');
3298 : 0 : if (p == NULL)
3299 : : return -1;
3300 : 0 : p++;
3301 : 0 : p0 = strchr(p, ')');
3302 : 0 : if (p0 == NULL)
3303 : : return -1;
3304 : 0 : size = p0 - p;
3305 : 0 : if (size >= sizeof(s)) {
3306 : 0 : fprintf(stderr,
3307 : : "The string size exceeds the internal buffer size\n");
3308 : 0 : return -1;
3309 : : }
3310 : : snprintf(s, sizeof(s), "%.*s", size, p);
3311 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3312 : 0 : if (ret <= 0 || ret != num) {
3313 : 0 : fprintf(stderr,
3314 : : "The bits of masks do not match the number of reta entries: %u\n",
3315 : : num);
3316 : 0 : return -1;
3317 : : }
3318 : 0 : for (i = 0; i < ret; i++)
3319 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3320 : :
3321 : : return 0;
3322 : : }
3323 : :
3324 : : static void
3325 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3326 : : __rte_unused struct cmdline *cl,
3327 : : __rte_unused void *data)
3328 : : {
3329 : : struct cmd_showport_reta *res = parsed_result;
3330 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3331 : : struct rte_eth_dev_info dev_info;
3332 : : uint16_t max_reta_size;
3333 : : int ret;
3334 : :
3335 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3336 : 0 : if (ret != 0)
3337 : 0 : return;
3338 : :
3339 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3340 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3341 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3342 : : res->size, max_reta_size);
3343 : 0 : return;
3344 : : }
3345 : :
3346 : : memset(reta_conf, 0, sizeof(reta_conf));
3347 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3348 : 0 : res->list_of_items) < 0) {
3349 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3350 : : res->list_of_items);
3351 : 0 : return;
3352 : : }
3353 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3354 : : }
3355 : :
3356 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3357 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3358 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3359 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3360 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3361 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3362 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3363 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3364 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3365 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3366 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3367 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3368 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3369 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3370 : : list_of_items, NULL);
3371 : :
3372 : : static cmdline_parse_inst_t cmd_showport_reta = {
3373 : : .f = cmd_showport_reta_parsed,
3374 : : .data = NULL,
3375 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3376 : : .tokens = {
3377 : : (void *)&cmd_showport_reta_show,
3378 : : (void *)&cmd_showport_reta_port,
3379 : : (void *)&cmd_showport_reta_port_id,
3380 : : (void *)&cmd_showport_reta_rss,
3381 : : (void *)&cmd_showport_reta_reta,
3382 : : (void *)&cmd_showport_reta_size,
3383 : : (void *)&cmd_showport_reta_list_of_items,
3384 : : NULL,
3385 : : },
3386 : : };
3387 : :
3388 : : /* *** Show RSS hash configuration *** */
3389 : : struct cmd_showport_rss_hash {
3390 : : cmdline_fixed_string_t show;
3391 : : cmdline_fixed_string_t port;
3392 : : portid_t port_id;
3393 : : cmdline_fixed_string_t rss_hash;
3394 : : cmdline_fixed_string_t rss_type;
3395 : : cmdline_fixed_string_t key; /* optional argument */
3396 : : cmdline_fixed_string_t algorithm; /* optional argument */
3397 : : };
3398 : :
3399 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3400 : : __rte_unused struct cmdline *cl,
3401 : : __rte_unused void *data)
3402 : : {
3403 : : struct cmd_showport_rss_hash *res = parsed_result;
3404 : :
3405 : 0 : port_rss_hash_conf_show(res->port_id,
3406 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3407 : 0 : }
3408 : :
3409 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3410 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3411 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3412 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3413 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3414 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3415 : : RTE_UINT16);
3416 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3417 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3418 : : "rss-hash");
3419 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3420 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3421 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3422 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3423 : :
3424 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3425 : : .f = cmd_showport_rss_hash_parsed,
3426 : : .data = NULL,
3427 : : .help_str = "show port <port_id> rss-hash",
3428 : : .tokens = {
3429 : : (void *)&cmd_showport_rss_hash_show,
3430 : : (void *)&cmd_showport_rss_hash_port,
3431 : : (void *)&cmd_showport_rss_hash_port_id,
3432 : : (void *)&cmd_showport_rss_hash_rss_hash,
3433 : : NULL,
3434 : : },
3435 : : };
3436 : :
3437 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3438 : : .f = cmd_showport_rss_hash_parsed,
3439 : : .data = NULL,
3440 : : .help_str = "show port <port_id> rss-hash key",
3441 : : .tokens = {
3442 : : (void *)&cmd_showport_rss_hash_show,
3443 : : (void *)&cmd_showport_rss_hash_port,
3444 : : (void *)&cmd_showport_rss_hash_port_id,
3445 : : (void *)&cmd_showport_rss_hash_rss_hash,
3446 : : (void *)&cmd_showport_rss_hash_rss_key,
3447 : : NULL,
3448 : : },
3449 : : };
3450 : :
3451 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3452 : : .f = cmd_showport_rss_hash_parsed,
3453 : : .data = NULL,
3454 : : .help_str = "show port <port_id> rss-hash algorithm",
3455 : : .tokens = {
3456 : : (void *)&cmd_showport_rss_hash_show,
3457 : : (void *)&cmd_showport_rss_hash_port,
3458 : : (void *)&cmd_showport_rss_hash_port_id,
3459 : : (void *)&cmd_showport_rss_hash_rss_hash,
3460 : : (void *)&cmd_showport_rss_hash_rss_algo,
3461 : : NULL,
3462 : : },
3463 : : };
3464 : :
3465 : : /* *** Configure DCB *** */
3466 : : struct cmd_config_dcb {
3467 : : cmdline_fixed_string_t port;
3468 : : cmdline_fixed_string_t config;
3469 : : portid_t port_id;
3470 : : cmdline_fixed_string_t dcb;
3471 : : cmdline_fixed_string_t vt;
3472 : : cmdline_fixed_string_t vt_en;
3473 : : uint8_t num_tcs;
3474 : : cmdline_fixed_string_t pfc;
3475 : : cmdline_multi_string_t token_str;
3476 : : };
3477 : :
3478 : : static int
3479 : 0 : parse_dcb_token_prio_tc(char *param_str[], int param_num,
3480 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3481 : : uint8_t *prio_tc_en)
3482 : : {
3483 : : unsigned long prio, tc;
3484 : : int prio_tc_maps = 0;
3485 : : char *param, *end;
3486 : : int i;
3487 : :
3488 : 0 : for (i = 0; i < param_num; i++) {
3489 : 0 : param = param_str[i];
3490 : 0 : prio = strtoul(param, &end, 10);
3491 : 0 : if (prio >= RTE_ETH_DCB_NUM_USER_PRIORITIES) {
3492 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO %lu\n", prio);
3493 : 0 : return -1;
3494 : : }
3495 : 0 : if ((*end != ':') || (strlen(end + 1) == 0)) {
3496 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3497 : 0 : return -1;
3498 : : }
3499 : 0 : tc = strtoul(end + 1, &end, 10);
3500 : 0 : if (tc >= RTE_ETH_8_TCS) {
3501 : 0 : fprintf(stderr, "Bad Argument: invalid TC %lu\n", tc);
3502 : 0 : return -1;
3503 : : }
3504 : 0 : if (*end != '\0') {
3505 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3506 : 0 : return -1;
3507 : : }
3508 : 0 : prio_tc[prio] = tc;
3509 : 0 : prio_tc_maps++;
3510 : : } while (0);
3511 : :
3512 : 0 : if (prio_tc_maps == 0) {
3513 : 0 : fprintf(stderr, "Bad Argument: no PRIO:TC provided\n");
3514 : 0 : return -1;
3515 : : }
3516 : 0 : *prio_tc_en = 1;
3517 : :
3518 : 0 : return 0;
3519 : : }
3520 : :
3521 : : #define DCB_TOKEN_PRIO_TC "prio-tc"
3522 : : #define DCB_TOKEN_KEEP_QNUM "keep-qnum"
3523 : :
3524 : : static int
3525 : 0 : parse_dcb_token_find(char *split_str[], int split_num, int *param_num)
3526 : : {
3527 : : int i;
3528 : :
3529 : 0 : if (strcmp(split_str[0], DCB_TOKEN_KEEP_QNUM) == 0) {
3530 : 0 : *param_num = 0;
3531 : 0 : return 0;
3532 : : }
3533 : :
3534 : 0 : if (strcmp(split_str[0], DCB_TOKEN_PRIO_TC) != 0) {
3535 : 0 : fprintf(stderr, "Bad Argument: unknown token %s\n", split_str[0]);
3536 : 0 : return -EINVAL;
3537 : : }
3538 : :
3539 : 0 : for (i = 1; i < split_num; i++) {
3540 : 0 : if ((strcmp(split_str[i], DCB_TOKEN_PRIO_TC) != 0) &&
3541 : 0 : (strcmp(split_str[i], DCB_TOKEN_KEEP_QNUM) != 0))
3542 : : continue;
3543 : : /* find another optional parameter, then exit. */
3544 : : break;
3545 : : }
3546 : :
3547 : 0 : *param_num = i - 1;
3548 : :
3549 : 0 : return 0;
3550 : : }
3551 : :
3552 : : static int
3553 : 0 : parse_dcb_token_value(char *token_str,
3554 : : uint8_t *pfc_en,
3555 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3556 : : uint8_t *prio_tc_en,
3557 : : uint8_t *keep_qnum)
3558 : : {
3559 : : #define MAX_TOKEN_NUM 128
3560 : : char *split_str[MAX_TOKEN_NUM];
3561 : : int param_num, start, ret;
3562 : : int split_num = 0;
3563 : : char *token;
3564 : :
3565 : : /* split multiple token to split str. */
3566 : : do {
3567 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
3568 : 0 : if (token == NULL)
3569 : : break;
3570 : 0 : if (split_num >= MAX_TOKEN_NUM) {
3571 : 0 : fprintf(stderr, "Bad Argument: too much argument\n");
3572 : 0 : return -1;
3573 : : }
3574 : 0 : split_str[split_num++] = token;
3575 : : } while (1);
3576 : :
3577 : : /* parse fixed parameter "pfc-en" first. */
3578 : 0 : token = split_str[0];
3579 : 0 : if (strcmp(token, "on") == 0)
3580 : 0 : *pfc_en = 1;
3581 : 0 : else if (strcmp(token, "off") == 0)
3582 : 0 : *pfc_en = 0;
3583 : : else {
3584 : 0 : fprintf(stderr, "Bad Argument: pfc-en must be on or off\n");
3585 : 0 : return -EINVAL;
3586 : : }
3587 : :
3588 : 0 : if (split_num == 1)
3589 : : return 0;
3590 : :
3591 : : /* start parse optional parameter. */
3592 : : start = 1;
3593 : : do {
3594 : 0 : param_num = 0;
3595 : 0 : ret = parse_dcb_token_find(&split_str[start], split_num - start, ¶m_num);
3596 : 0 : if (ret != 0)
3597 : 0 : return ret;
3598 : :
3599 : 0 : token = split_str[start];
3600 : 0 : if (strcmp(token, DCB_TOKEN_PRIO_TC) == 0) {
3601 : 0 : if (*prio_tc_en == 1) {
3602 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3603 : : DCB_TOKEN_PRIO_TC);
3604 : 0 : return -1;
3605 : : }
3606 : 0 : ret = parse_dcb_token_prio_tc(&split_str[start + 1], param_num, prio_tc,
3607 : : prio_tc_en);
3608 : 0 : if (ret != 0)
3609 : 0 : return ret;
3610 : : } else {
3611 : : /* this must be keep-qnum. */
3612 : 0 : if (*keep_qnum == 1) {
3613 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3614 : : DCB_TOKEN_KEEP_QNUM);
3615 : 0 : return -1;
3616 : : }
3617 : 0 : *keep_qnum = 1;
3618 : : }
3619 : :
3620 : 0 : start += param_num + 1;
3621 : 0 : if (start >= split_num)
3622 : : break;
3623 : : } while (1);
3624 : :
3625 : : return 0;
3626 : : }
3627 : :
3628 : : static void
3629 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3630 : : __rte_unused struct cmdline *cl,
3631 : : __rte_unused void *data)
3632 : : {
3633 : 0 : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES] = {0};
3634 : : struct cmd_config_dcb *res = parsed_result;
3635 : : struct rte_eth_dcb_info dcb_info;
3636 : 0 : portid_t port_id = res->port_id;
3637 : 0 : uint8_t prio_tc_en = 0;
3638 : 0 : uint8_t keep_qnum = 0;
3639 : : struct rte_port *port;
3640 : 0 : uint8_t pfc_en = 0;
3641 : : int ret;
3642 : :
3643 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
3644 : 0 : return;
3645 : :
3646 : 0 : port = &ports[port_id];
3647 : : /** Check if the port is not started **/
3648 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3649 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3650 : 0 : return;
3651 : : }
3652 : :
3653 : 0 : if (res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS) {
3654 : 0 : fprintf(stderr,
3655 : : "The invalid number of traffic class, only 1~8 allowed.\n");
3656 : 0 : return;
3657 : : }
3658 : :
3659 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3660 : 0 : fprintf(stderr,
3661 : : "nb_cores shouldn't be less than number of TCs.\n");
3662 : 0 : return;
3663 : : }
3664 : :
3665 : : /* Check whether the port supports the report of DCB info. */
3666 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3667 : 0 : if (ret == -ENOTSUP) {
3668 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3669 : 0 : return;
3670 : : }
3671 : :
3672 : 0 : ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en, &keep_qnum);
3673 : 0 : if (ret != 0)
3674 : : return;
3675 : :
3676 : : /* DCB in VT mode */
3677 : 0 : if (!strncmp(res->vt_en, "on", 2))
3678 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3679 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3680 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3681 : : else
3682 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3683 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3684 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3685 : 0 : if (ret != 0) {
3686 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3687 : 0 : return;
3688 : : }
3689 : :
3690 : 0 : fwd_config_setup();
3691 : :
3692 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3693 : : }
3694 : :
3695 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3696 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3697 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3698 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3699 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3700 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3701 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3702 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3703 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3704 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3705 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3706 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3707 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3708 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3709 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3710 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3711 : : static cmdline_parse_token_string_t cmd_config_dcb_token_str =
3712 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, token_str, TOKEN_STRING_MULTI);
3713 : :
3714 : : static cmdline_parse_inst_t cmd_config_dcb = {
3715 : : .f = cmd_config_dcb_parsed,
3716 : : .data = NULL,
3717 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP keep-qnum\n"
3718 : : "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
3719 : : " PRIO-MAPPING := PRIO:TC\n"
3720 : : " PRIO: { 0 .. 7 }\n"
3721 : : " TC: { 0 .. 7 }",
3722 : : .tokens = {
3723 : : (void *)&cmd_config_dcb_port,
3724 : : (void *)&cmd_config_dcb_config,
3725 : : (void *)&cmd_config_dcb_port_id,
3726 : : (void *)&cmd_config_dcb_dcb,
3727 : : (void *)&cmd_config_dcb_vt,
3728 : : (void *)&cmd_config_dcb_vt_en,
3729 : : (void *)&cmd_config_dcb_num_tcs,
3730 : : (void *)&cmd_config_dcb_pfc,
3731 : : (void *)&cmd_config_dcb_token_str,
3732 : : NULL,
3733 : : },
3734 : : };
3735 : :
3736 : : /* *** configure number of packets per burst *** */
3737 : : struct cmd_config_burst {
3738 : : cmdline_fixed_string_t port;
3739 : : cmdline_fixed_string_t keyword;
3740 : : cmdline_fixed_string_t all;
3741 : : cmdline_fixed_string_t name;
3742 : : uint16_t value;
3743 : : };
3744 : :
3745 : : static void
3746 : 0 : cmd_config_burst_parsed(void *parsed_result,
3747 : : __rte_unused struct cmdline *cl,
3748 : : __rte_unused void *data)
3749 : : {
3750 : : struct cmd_config_burst *res = parsed_result;
3751 : : struct rte_eth_dev_info dev_info;
3752 : : uint16_t rec_nb_pkts;
3753 : : int ret;
3754 : :
3755 : 0 : if (!all_ports_stopped()) {
3756 : 0 : fprintf(stderr, "Please stop all ports first\n");
3757 : 0 : return;
3758 : : }
3759 : :
3760 : 0 : if (!strcmp(res->name, "burst")) {
3761 : 0 : if (res->value == 0) {
3762 : : /* If user gives a value of zero, query the PMD for
3763 : : * its recommended Rx burst size. Testpmd uses a single
3764 : : * size for all ports, so assume all ports are the same
3765 : : * NIC model and use the values from Port 0.
3766 : : */
3767 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3768 : 0 : if (ret != 0)
3769 : : return;
3770 : :
3771 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3772 : :
3773 : 0 : if (rec_nb_pkts == 0) {
3774 : : printf("PMD does not recommend a burst size.\n"
3775 : : "User provided value must be between"
3776 : : " 1 and %d\n", MAX_PKT_BURST);
3777 : 0 : return;
3778 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3779 : 0 : printf("PMD recommended burst size of %d"
3780 : : " exceeds maximum value of %d\n",
3781 : : rec_nb_pkts, MAX_PKT_BURST);
3782 : 0 : return;
3783 : : }
3784 : 0 : printf("Using PMD-provided burst value of %d\n",
3785 : : rec_nb_pkts);
3786 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3787 : 0 : } else if (res->value > MAX_PKT_BURST) {
3788 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3789 : : MAX_PKT_BURST);
3790 : 0 : return;
3791 : : } else
3792 : 0 : nb_pkt_per_burst = res->value;
3793 : : } else {
3794 : 0 : fprintf(stderr, "Unknown parameter\n");
3795 : 0 : return;
3796 : : }
3797 : :
3798 : 0 : init_port_config();
3799 : :
3800 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3801 : : }
3802 : :
3803 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3804 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3805 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3806 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3807 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3808 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3809 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3810 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3811 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3812 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3813 : :
3814 : : static cmdline_parse_inst_t cmd_config_burst = {
3815 : : .f = cmd_config_burst_parsed,
3816 : : .data = NULL,
3817 : : .help_str = "port config all burst <value>",
3818 : : .tokens = {
3819 : : (void *)&cmd_config_burst_port,
3820 : : (void *)&cmd_config_burst_keyword,
3821 : : (void *)&cmd_config_burst_all,
3822 : : (void *)&cmd_config_burst_name,
3823 : : (void *)&cmd_config_burst_value,
3824 : : NULL,
3825 : : },
3826 : : };
3827 : :
3828 : : /* *** configure rx/tx queues *** */
3829 : : struct cmd_config_thresh {
3830 : : cmdline_fixed_string_t port;
3831 : : cmdline_fixed_string_t keyword;
3832 : : cmdline_fixed_string_t all;
3833 : : cmdline_fixed_string_t name;
3834 : : uint8_t value;
3835 : : };
3836 : :
3837 : : static void
3838 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3839 : : __rte_unused struct cmdline *cl,
3840 : : __rte_unused void *data)
3841 : : {
3842 : : struct cmd_config_thresh *res = parsed_result;
3843 : :
3844 : 0 : if (!all_ports_stopped()) {
3845 : 0 : fprintf(stderr, "Please stop all ports first\n");
3846 : 0 : return;
3847 : : }
3848 : :
3849 : 0 : if (!strcmp(res->name, "txpt"))
3850 : 0 : tx_pthresh = res->value;
3851 : 0 : else if(!strcmp(res->name, "txht"))
3852 : 0 : tx_hthresh = res->value;
3853 : 0 : else if(!strcmp(res->name, "txwt"))
3854 : 0 : tx_wthresh = res->value;
3855 : 0 : else if(!strcmp(res->name, "rxpt"))
3856 : 0 : rx_pthresh = res->value;
3857 : 0 : else if(!strcmp(res->name, "rxht"))
3858 : 0 : rx_hthresh = res->value;
3859 : 0 : else if(!strcmp(res->name, "rxwt"))
3860 : 0 : rx_wthresh = res->value;
3861 : : else {
3862 : 0 : fprintf(stderr, "Unknown parameter\n");
3863 : 0 : return;
3864 : : }
3865 : :
3866 : 0 : init_port_config();
3867 : :
3868 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3869 : : }
3870 : :
3871 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3872 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3873 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3874 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3875 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3876 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3877 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3878 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3879 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3880 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3881 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3882 : :
3883 : : static cmdline_parse_inst_t cmd_config_thresh = {
3884 : : .f = cmd_config_thresh_parsed,
3885 : : .data = NULL,
3886 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3887 : : .tokens = {
3888 : : (void *)&cmd_config_thresh_port,
3889 : : (void *)&cmd_config_thresh_keyword,
3890 : : (void *)&cmd_config_thresh_all,
3891 : : (void *)&cmd_config_thresh_name,
3892 : : (void *)&cmd_config_thresh_value,
3893 : : NULL,
3894 : : },
3895 : : };
3896 : :
3897 : : /* *** configure free/rs threshold *** */
3898 : : struct cmd_config_threshold {
3899 : : cmdline_fixed_string_t port;
3900 : : cmdline_fixed_string_t keyword;
3901 : : cmdline_fixed_string_t all;
3902 : : cmdline_fixed_string_t name;
3903 : : uint16_t value;
3904 : : };
3905 : :
3906 : : static void
3907 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3908 : : __rte_unused struct cmdline *cl,
3909 : : __rte_unused void *data)
3910 : : {
3911 : : struct cmd_config_threshold *res = parsed_result;
3912 : :
3913 : 0 : if (!all_ports_stopped()) {
3914 : 0 : fprintf(stderr, "Please stop all ports first\n");
3915 : 0 : return;
3916 : : }
3917 : :
3918 : 0 : if (!strcmp(res->name, "txfreet"))
3919 : 0 : tx_free_thresh = res->value;
3920 : 0 : else if (!strcmp(res->name, "txrst"))
3921 : 0 : tx_rs_thresh = res->value;
3922 : 0 : else if (!strcmp(res->name, "rxfreet"))
3923 : 0 : rx_free_thresh = res->value;
3924 : : else {
3925 : 0 : fprintf(stderr, "Unknown parameter\n");
3926 : 0 : return;
3927 : : }
3928 : :
3929 : 0 : init_port_config();
3930 : :
3931 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3932 : : }
3933 : :
3934 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3935 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3936 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3937 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3938 : : "config");
3939 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3940 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3941 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3942 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3943 : : "txfreet#txrst#rxfreet");
3944 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3945 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3946 : :
3947 : : static cmdline_parse_inst_t cmd_config_threshold = {
3948 : : .f = cmd_config_threshold_parsed,
3949 : : .data = NULL,
3950 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3951 : : .tokens = {
3952 : : (void *)&cmd_config_threshold_port,
3953 : : (void *)&cmd_config_threshold_keyword,
3954 : : (void *)&cmd_config_threshold_all,
3955 : : (void *)&cmd_config_threshold_name,
3956 : : (void *)&cmd_config_threshold_value,
3957 : : NULL,
3958 : : },
3959 : : };
3960 : :
3961 : : /* *** stop *** */
3962 : : struct cmd_stop_result {
3963 : : cmdline_fixed_string_t stop;
3964 : : };
3965 : :
3966 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3967 : : __rte_unused struct cmdline *cl,
3968 : : __rte_unused void *data)
3969 : : {
3970 : 0 : stop_packet_forwarding();
3971 : 0 : }
3972 : :
3973 : : static cmdline_parse_token_string_t cmd_stop_stop =
3974 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3975 : :
3976 : : static cmdline_parse_inst_t cmd_stop = {
3977 : : .f = cmd_stop_parsed,
3978 : : .data = NULL,
3979 : : .help_str = "stop: Stop packet forwarding",
3980 : : .tokens = {
3981 : : (void *)&cmd_stop_stop,
3982 : : NULL,
3983 : : },
3984 : : };
3985 : :
3986 : : static unsigned int
3987 : 0 : get_ptype(char *value)
3988 : : {
3989 : : uint32_t protocol;
3990 : :
3991 : 0 : if (!strcmp(value, "eth"))
3992 : : protocol = RTE_PTYPE_L2_ETHER;
3993 : 0 : else if (!strcmp(value, "ipv4"))
3994 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3995 : 0 : else if (!strcmp(value, "ipv6"))
3996 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3997 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3998 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3999 : 0 : else if (!strcmp(value, "ipv4-udp"))
4000 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
4001 : 0 : else if (!strcmp(value, "ipv4-sctp"))
4002 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4003 : 0 : else if (!strcmp(value, "ipv6-tcp"))
4004 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
4005 : 0 : else if (!strcmp(value, "ipv6-udp"))
4006 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
4007 : 0 : else if (!strcmp(value, "ipv6-sctp"))
4008 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4009 : 0 : else if (!strcmp(value, "grenat"))
4010 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
4011 : 0 : else if (!strcmp(value, "inner-eth"))
4012 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
4013 : 0 : else if (!strcmp(value, "inner-ipv4"))
4014 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4015 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
4016 : 0 : else if (!strcmp(value, "inner-ipv6"))
4017 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4018 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
4019 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
4020 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4021 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4022 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
4023 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4024 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4025 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
4026 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4027 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4028 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
4029 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4030 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4031 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
4032 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4033 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4034 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
4035 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4036 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4037 : : else {
4038 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
4039 : : protocol = RTE_PTYPE_UNKNOWN;
4040 : : }
4041 : :
4042 : 0 : return protocol;
4043 : : }
4044 : :
4045 : : /* *** SET RXHDRSLIST *** */
4046 : :
4047 : : unsigned int
4048 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
4049 : : unsigned int *parsed_items)
4050 : : {
4051 : : unsigned int nb_item;
4052 : : char *cur;
4053 : : char *tmp;
4054 : :
4055 : : nb_item = 0;
4056 : 0 : char *str2 = strdup(str);
4057 : 0 : if (str2 == NULL)
4058 : : return nb_item;
4059 : 0 : cur = strtok_r(str2, ",", &tmp);
4060 : 0 : while (cur != NULL) {
4061 : 0 : parsed_items[nb_item] = get_ptype(cur);
4062 : 0 : cur = strtok_r(NULL, ",", &tmp);
4063 : 0 : nb_item++;
4064 : : }
4065 : 0 : if (nb_item > max_items)
4066 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4067 : : item_name, nb_item + 1, max_items);
4068 : 0 : free(str2);
4069 : 0 : return nb_item;
4070 : : }
4071 : :
4072 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
4073 : :
4074 : : unsigned int
4075 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
4076 : : unsigned int *parsed_items, int check_unique_values)
4077 : : {
4078 : : unsigned int nb_item;
4079 : : unsigned int value;
4080 : : unsigned int i;
4081 : : unsigned int j;
4082 : : int value_ok;
4083 : : char c;
4084 : :
4085 : : /*
4086 : : * First parse all items in the list and store their value.
4087 : : */
4088 : : value = 0;
4089 : : nb_item = 0;
4090 : : value_ok = 0;
4091 : 0 : for (i = 0; i < strnlen(str, STR_MULTI_TOKEN_SIZE); i++) {
4092 : 0 : c = str[i];
4093 : 0 : if ((c >= '0') && (c <= '9')) {
4094 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
4095 : : value_ok = 1;
4096 : 0 : continue;
4097 : : }
4098 : 0 : if (c != ',') {
4099 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
4100 : 0 : return 0;
4101 : : }
4102 : 0 : if (! value_ok) {
4103 : 0 : fprintf(stderr, "No valid value before comma\n");
4104 : 0 : return 0;
4105 : : }
4106 : 0 : if (nb_item < max_items) {
4107 : 0 : parsed_items[nb_item] = value;
4108 : : value_ok = 0;
4109 : : value = 0;
4110 : : }
4111 : 0 : nb_item++;
4112 : : }
4113 : 0 : if (nb_item >= max_items) {
4114 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4115 : : item_name, nb_item + 1, max_items);
4116 : 0 : return 0;
4117 : : }
4118 : 0 : parsed_items[nb_item++] = value;
4119 : 0 : if (! check_unique_values)
4120 : : return nb_item;
4121 : :
4122 : : /*
4123 : : * Then, check that all values in the list are different.
4124 : : * No optimization here...
4125 : : */
4126 : 0 : for (i = 0; i < nb_item; i++) {
4127 : 0 : for (j = i + 1; j < nb_item; j++) {
4128 : 0 : if (parsed_items[j] == parsed_items[i]) {
4129 : 0 : fprintf(stderr,
4130 : : "duplicated %s %u at index %u and %u\n",
4131 : : item_name, parsed_items[i], i, j);
4132 : 0 : return 0;
4133 : : }
4134 : : }
4135 : : }
4136 : : return nb_item;
4137 : : }
4138 : :
4139 : : struct cmd_set_list_result {
4140 : : cmdline_fixed_string_t cmd_keyword;
4141 : : cmdline_fixed_string_t list_name;
4142 : : cmdline_multi_string_t list_of_items;
4143 : : };
4144 : :
4145 : 0 : static void cmd_set_list_parsed(void *parsed_result,
4146 : : __rte_unused struct cmdline *cl,
4147 : : __rte_unused void *data)
4148 : : {
4149 : : struct cmd_set_list_result *res;
4150 : : union {
4151 : : unsigned int lcorelist[RTE_MAX_LCORE];
4152 : : unsigned int portlist[RTE_MAX_ETHPORTS];
4153 : : } parsed_items;
4154 : : unsigned int nb_item;
4155 : :
4156 : 0 : if (test_done == 0) {
4157 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4158 : 0 : return;
4159 : : }
4160 : :
4161 : : res = parsed_result;
4162 : 0 : if (!strcmp(res->list_name, "corelist")) {
4163 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
4164 : : RTE_MAX_LCORE,
4165 : : parsed_items.lcorelist, 1);
4166 : 0 : if (nb_item > 0) {
4167 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
4168 : 0 : fwd_config_setup();
4169 : : }
4170 : 0 : return;
4171 : : }
4172 : 0 : if (!strcmp(res->list_name, "portlist")) {
4173 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
4174 : : RTE_MAX_ETHPORTS,
4175 : : parsed_items.portlist, 1);
4176 : 0 : if (nb_item > 0) {
4177 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
4178 : 0 : fwd_config_setup();
4179 : : }
4180 : : }
4181 : : }
4182 : :
4183 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
4184 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
4185 : : "set");
4186 : : static cmdline_parse_token_string_t cmd_set_list_name =
4187 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
4188 : : "corelist#portlist");
4189 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
4190 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
4191 : : TOKEN_STRING_MULTI);
4192 : :
4193 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
4194 : : .f = cmd_set_list_parsed,
4195 : : .data = NULL,
4196 : : .help_str = "set corelist|portlist <list0[,list1]*>",
4197 : : .tokens = {
4198 : : (void *)&cmd_set_list_keyword,
4199 : : (void *)&cmd_set_list_name,
4200 : : (void *)&cmd_set_list_of_items,
4201 : : NULL,
4202 : : },
4203 : : };
4204 : :
4205 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
4206 : :
4207 : : struct cmd_setmask_result {
4208 : : cmdline_fixed_string_t set;
4209 : : cmdline_fixed_string_t mask;
4210 : : uint64_t hexavalue;
4211 : : };
4212 : :
4213 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
4214 : : __rte_unused struct cmdline *cl,
4215 : : __rte_unused void *data)
4216 : : {
4217 : : struct cmd_setmask_result *res = parsed_result;
4218 : :
4219 : 0 : if (test_done == 0) {
4220 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4221 : 0 : return;
4222 : : }
4223 : 0 : if (!strcmp(res->mask, "coremask")) {
4224 : 0 : set_fwd_lcores_mask(res->hexavalue);
4225 : 0 : fwd_config_setup();
4226 : 0 : } else if (!strcmp(res->mask, "portmask")) {
4227 : 0 : set_fwd_ports_mask(res->hexavalue);
4228 : 0 : fwd_config_setup();
4229 : : }
4230 : : }
4231 : :
4232 : : static cmdline_parse_token_string_t cmd_setmask_set =
4233 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
4234 : : static cmdline_parse_token_string_t cmd_setmask_mask =
4235 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
4236 : : "coremask#portmask");
4237 : : static cmdline_parse_token_num_t cmd_setmask_value =
4238 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
4239 : :
4240 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
4241 : : .f = cmd_set_mask_parsed,
4242 : : .data = NULL,
4243 : : .help_str = "set coremask|portmask <hexadecimal value>",
4244 : : .tokens = {
4245 : : (void *)&cmd_setmask_set,
4246 : : (void *)&cmd_setmask_mask,
4247 : : (void *)&cmd_setmask_value,
4248 : : NULL,
4249 : : },
4250 : : };
4251 : :
4252 : : /*
4253 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
4254 : : */
4255 : : struct cmd_set_result {
4256 : : cmdline_fixed_string_t set;
4257 : : cmdline_fixed_string_t what;
4258 : : uint16_t value;
4259 : : };
4260 : :
4261 : 0 : static void cmd_set_parsed(void *parsed_result,
4262 : : __rte_unused struct cmdline *cl,
4263 : : __rte_unused void *data)
4264 : : {
4265 : : struct cmd_set_result *res = parsed_result;
4266 : 0 : if (!strcmp(res->what, "nbport")) {
4267 : 0 : set_fwd_ports_number(res->value);
4268 : 0 : fwd_config_setup();
4269 : 0 : } else if (!strcmp(res->what, "nbcore")) {
4270 : 0 : set_fwd_lcores_number(res->value);
4271 : 0 : fwd_config_setup();
4272 : 0 : } else if (!strcmp(res->what, "burst"))
4273 : 0 : set_nb_pkt_per_burst(res->value);
4274 : 0 : else if (!strcmp(res->what, "verbose"))
4275 : 0 : set_verbose_level(res->value);
4276 : 0 : }
4277 : :
4278 : : static cmdline_parse_token_string_t cmd_set_set =
4279 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
4280 : : static cmdline_parse_token_string_t cmd_set_what =
4281 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
4282 : : "nbport#nbcore#burst#verbose");
4283 : : static cmdline_parse_token_num_t cmd_set_value =
4284 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
4285 : :
4286 : : static cmdline_parse_inst_t cmd_set_numbers = {
4287 : : .f = cmd_set_parsed,
4288 : : .data = NULL,
4289 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
4290 : : .tokens = {
4291 : : (void *)&cmd_set_set,
4292 : : (void *)&cmd_set_what,
4293 : : (void *)&cmd_set_value,
4294 : : NULL,
4295 : : },
4296 : : };
4297 : :
4298 : : /* *** SET LOG LEVEL CONFIGURATION *** */
4299 : :
4300 : : struct cmd_set_log_result {
4301 : : cmdline_fixed_string_t set;
4302 : : cmdline_fixed_string_t log;
4303 : : cmdline_fixed_string_t type;
4304 : : uint32_t level;
4305 : : };
4306 : :
4307 : : static void
4308 : 0 : cmd_set_log_parsed(void *parsed_result,
4309 : : __rte_unused struct cmdline *cl,
4310 : : __rte_unused void *data)
4311 : : {
4312 : : struct cmd_set_log_result *res;
4313 : : int ret;
4314 : :
4315 : : res = parsed_result;
4316 : 0 : if (!strcmp(res->type, "global"))
4317 : 0 : rte_log_set_global_level(res->level);
4318 : : else {
4319 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
4320 : 0 : if (ret < 0)
4321 : 0 : fprintf(stderr, "Unable to set log level\n");
4322 : : }
4323 : 0 : }
4324 : :
4325 : : static cmdline_parse_token_string_t cmd_set_log_set =
4326 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
4327 : : static cmdline_parse_token_string_t cmd_set_log_log =
4328 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
4329 : : static cmdline_parse_token_string_t cmd_set_log_type =
4330 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
4331 : : static cmdline_parse_token_num_t cmd_set_log_level =
4332 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
4333 : :
4334 : : static cmdline_parse_inst_t cmd_set_log = {
4335 : : .f = cmd_set_log_parsed,
4336 : : .data = NULL,
4337 : : .help_str = "set log global|<type> <level>",
4338 : : .tokens = {
4339 : : (void *)&cmd_set_log_set,
4340 : : (void *)&cmd_set_log_log,
4341 : : (void *)&cmd_set_log_type,
4342 : : (void *)&cmd_set_log_level,
4343 : : NULL,
4344 : : },
4345 : : };
4346 : :
4347 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
4348 : :
4349 : : struct cmd_set_rxoffs_result {
4350 : : cmdline_fixed_string_t cmd_keyword;
4351 : : cmdline_fixed_string_t rxoffs;
4352 : : cmdline_fixed_string_t seg_offsets;
4353 : : };
4354 : :
4355 : : static void
4356 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
4357 : : __rte_unused struct cmdline *cl,
4358 : : __rte_unused void *data)
4359 : : {
4360 : : struct cmd_set_rxoffs_result *res;
4361 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
4362 : : unsigned int nb_segs;
4363 : :
4364 : : res = parsed_result;
4365 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
4366 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
4367 : 0 : if (nb_segs > 0)
4368 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
4369 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4370 : 0 : }
4371 : :
4372 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
4373 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4374 : : cmd_keyword, "set");
4375 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
4376 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4377 : : rxoffs, "rxoffs");
4378 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
4379 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4380 : : seg_offsets, NULL);
4381 : :
4382 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
4383 : : .f = cmd_set_rxoffs_parsed,
4384 : : .data = NULL,
4385 : : .help_str = "set rxoffs <len0[,len1]*>",
4386 : : .tokens = {
4387 : : (void *)&cmd_set_rxoffs_keyword,
4388 : : (void *)&cmd_set_rxoffs_name,
4389 : : (void *)&cmd_set_rxoffs_offsets,
4390 : : NULL,
4391 : : },
4392 : : };
4393 : :
4394 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
4395 : :
4396 : : struct cmd_set_rxpkts_result {
4397 : : cmdline_fixed_string_t cmd_keyword;
4398 : : cmdline_fixed_string_t rxpkts;
4399 : : cmdline_fixed_string_t seg_lengths;
4400 : : };
4401 : :
4402 : : static void
4403 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
4404 : : __rte_unused struct cmdline *cl,
4405 : : __rte_unused void *data)
4406 : : {
4407 : : struct cmd_set_rxpkts_result *res;
4408 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
4409 : : unsigned int nb_segs;
4410 : :
4411 : : res = parsed_result;
4412 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4413 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
4414 : 0 : if (nb_segs > 0)
4415 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
4416 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4417 : 0 : }
4418 : :
4419 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
4420 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4421 : : cmd_keyword, "set");
4422 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
4423 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4424 : : rxpkts, "rxpkts");
4425 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4426 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4427 : : seg_lengths, NULL);
4428 : :
4429 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
4430 : : .f = cmd_set_rxpkts_parsed,
4431 : : .data = NULL,
4432 : : .help_str = "set rxpkts <len0[,len1]*>",
4433 : : .tokens = {
4434 : : (void *)&cmd_set_rxpkts_keyword,
4435 : : (void *)&cmd_set_rxpkts_name,
4436 : : (void *)&cmd_set_rxpkts_lengths,
4437 : : NULL,
4438 : : },
4439 : : };
4440 : :
4441 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4442 : : struct cmd_set_rxhdrs_result {
4443 : : cmdline_fixed_string_t set;
4444 : : cmdline_fixed_string_t rxhdrs;
4445 : : cmdline_fixed_string_t values;
4446 : : };
4447 : :
4448 : : static void
4449 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4450 : : __rte_unused struct cmdline *cl,
4451 : : __rte_unused void *data)
4452 : : {
4453 : : struct cmd_set_rxhdrs_result *res;
4454 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4455 : : unsigned int nb_segs;
4456 : :
4457 : : res = parsed_result;
4458 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4459 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4460 : 0 : if (nb_segs > 0)
4461 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4462 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4463 : 0 : }
4464 : :
4465 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4466 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4467 : : set, "set");
4468 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4469 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4470 : : rxhdrs, "rxhdrs");
4471 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4472 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4473 : : values, NULL);
4474 : :
4475 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4476 : : .f = cmd_set_rxhdrs_parsed,
4477 : : .data = NULL,
4478 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4479 : : .tokens = {
4480 : : (void *)&cmd_set_rxhdrs_set,
4481 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4482 : : (void *)&cmd_set_rxhdrs_values,
4483 : : NULL,
4484 : : },
4485 : : };
4486 : :
4487 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4488 : :
4489 : : struct cmd_set_txpkts_result {
4490 : : cmdline_fixed_string_t cmd_keyword;
4491 : : cmdline_fixed_string_t txpkts;
4492 : : cmdline_fixed_string_t seg_lengths;
4493 : : };
4494 : :
4495 : : static void
4496 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4497 : : __rte_unused struct cmdline *cl,
4498 : : __rte_unused void *data)
4499 : : {
4500 : : struct cmd_set_txpkts_result *res;
4501 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4502 : : unsigned int nb_segs;
4503 : :
4504 : : res = parsed_result;
4505 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4506 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4507 : 0 : if (nb_segs > 0)
4508 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4509 : 0 : }
4510 : :
4511 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4512 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4513 : : cmd_keyword, "set");
4514 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4515 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4516 : : txpkts, "txpkts");
4517 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4518 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4519 : : seg_lengths, NULL);
4520 : :
4521 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4522 : : .f = cmd_set_txpkts_parsed,
4523 : : .data = NULL,
4524 : : .help_str = "set txpkts <len0[,len1]*>",
4525 : : .tokens = {
4526 : : (void *)&cmd_set_txpkts_keyword,
4527 : : (void *)&cmd_set_txpkts_name,
4528 : : (void *)&cmd_set_txpkts_lengths,
4529 : : NULL,
4530 : : },
4531 : : };
4532 : :
4533 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4534 : :
4535 : : struct cmd_set_txsplit_result {
4536 : : cmdline_fixed_string_t cmd_keyword;
4537 : : cmdline_fixed_string_t txsplit;
4538 : : cmdline_fixed_string_t mode;
4539 : : };
4540 : :
4541 : : static void
4542 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4543 : : __rte_unused struct cmdline *cl,
4544 : : __rte_unused void *data)
4545 : : {
4546 : : struct cmd_set_txsplit_result *res;
4547 : :
4548 : : res = parsed_result;
4549 : 0 : set_tx_pkt_split(res->mode);
4550 : 0 : }
4551 : :
4552 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4553 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4554 : : cmd_keyword, "set");
4555 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4556 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4557 : : txsplit, "txsplit");
4558 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4559 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4560 : : mode, NULL);
4561 : :
4562 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4563 : : .f = cmd_set_txsplit_parsed,
4564 : : .data = NULL,
4565 : : .help_str = "set txsplit on|off|rand",
4566 : : .tokens = {
4567 : : (void *)&cmd_set_txsplit_keyword,
4568 : : (void *)&cmd_set_txsplit_name,
4569 : : (void *)&cmd_set_txsplit_mode,
4570 : : NULL,
4571 : : },
4572 : : };
4573 : :
4574 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4575 : :
4576 : : struct cmd_set_txtimes_result {
4577 : : cmdline_fixed_string_t cmd_keyword;
4578 : : cmdline_fixed_string_t txtimes;
4579 : : cmdline_fixed_string_t tx_times;
4580 : : };
4581 : :
4582 : : static void
4583 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4584 : : __rte_unused struct cmdline *cl,
4585 : : __rte_unused void *data)
4586 : : {
4587 : : struct cmd_set_txtimes_result *res;
4588 : 0 : unsigned int tx_times[2] = {0, 0};
4589 : : unsigned int n_times;
4590 : :
4591 : : res = parsed_result;
4592 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4593 : : 2, tx_times, 0);
4594 : 0 : if (n_times == 2)
4595 : 0 : set_tx_pkt_times(tx_times);
4596 : 0 : }
4597 : :
4598 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4599 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4600 : : cmd_keyword, "set");
4601 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4602 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4603 : : txtimes, "txtimes");
4604 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4605 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4606 : : tx_times, NULL);
4607 : :
4608 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4609 : : .f = cmd_set_txtimes_parsed,
4610 : : .data = NULL,
4611 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4612 : : .tokens = {
4613 : : (void *)&cmd_set_txtimes_keyword,
4614 : : (void *)&cmd_set_txtimes_name,
4615 : : (void *)&cmd_set_txtimes_value,
4616 : : NULL,
4617 : : },
4618 : : };
4619 : :
4620 : : /* *** SET NUMBER OF FLOWS IN TXONLY MULTI-FLOW MODE *** */
4621 : :
4622 : : struct cmd_set_txflows_result {
4623 : : cmdline_fixed_string_t cmd_keyword;
4624 : : cmdline_fixed_string_t name;
4625 : : uint16_t value;
4626 : : };
4627 : :
4628 : : static void
4629 : 0 : cmd_set_txflows_parsed(void *parsed_result,
4630 : : __rte_unused struct cmdline *cl,
4631 : : __rte_unused void *data)
4632 : : {
4633 : : struct cmd_set_txflows_result *res = parsed_result;
4634 : :
4635 : 0 : if (res->value < 1 || res->value > 64) {
4636 : 0 : fprintf(stderr, "txonly-flows must be >= 1 and <= 64\n");
4637 : 0 : return;
4638 : : }
4639 : 0 : txonly_flows = res->value;
4640 : : }
4641 : :
4642 : : static cmdline_parse_token_string_t cmd_set_txflows_keyword =
4643 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txflows_result,
4644 : : cmd_keyword, "set");
4645 : : static cmdline_parse_token_string_t cmd_set_txflows_name =
4646 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txflows_result,
4647 : : name, "txonly-flows");
4648 : : static cmdline_parse_token_num_t cmd_set_txflows_value =
4649 : : TOKEN_NUM_INITIALIZER(struct cmd_set_txflows_result,
4650 : : value, RTE_UINT16);
4651 : :
4652 : : static cmdline_parse_inst_t cmd_set_txflows = {
4653 : : .f = cmd_set_txflows_parsed,
4654 : : .data = NULL,
4655 : : .help_str = "set txonly-flows <N>",
4656 : : .tokens = {
4657 : : (void *)&cmd_set_txflows_keyword,
4658 : : (void *)&cmd_set_txflows_name,
4659 : : (void *)&cmd_set_txflows_value,
4660 : : NULL,
4661 : : },
4662 : : };
4663 : :
4664 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4665 : : struct cmd_rx_vlan_filter_all_result {
4666 : : cmdline_fixed_string_t rx_vlan;
4667 : : cmdline_fixed_string_t what;
4668 : : cmdline_fixed_string_t all;
4669 : : portid_t port_id;
4670 : : };
4671 : :
4672 : : static void
4673 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4674 : : __rte_unused struct cmdline *cl,
4675 : : __rte_unused void *data)
4676 : : {
4677 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4678 : :
4679 : 0 : if (!strcmp(res->what, "add"))
4680 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4681 : : else
4682 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4683 : 0 : }
4684 : :
4685 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4686 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4687 : : rx_vlan, "rx_vlan");
4688 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4689 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4690 : : what, "add#rm");
4691 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4692 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4693 : : all, "all");
4694 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4695 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4696 : : port_id, RTE_UINT16);
4697 : :
4698 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4699 : : .f = cmd_rx_vlan_filter_all_parsed,
4700 : : .data = NULL,
4701 : : .help_str = "rx_vlan add|rm all <port_id>: "
4702 : : "Add/Remove all identifiers to/from the set of VLAN "
4703 : : "identifiers filtered by a port",
4704 : : .tokens = {
4705 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4706 : : (void *)&cmd_rx_vlan_filter_all_what,
4707 : : (void *)&cmd_rx_vlan_filter_all_all,
4708 : : (void *)&cmd_rx_vlan_filter_all_portid,
4709 : : NULL,
4710 : : },
4711 : : };
4712 : :
4713 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4714 : : struct cmd_vlan_offload_result {
4715 : : cmdline_fixed_string_t vlan;
4716 : : cmdline_fixed_string_t set;
4717 : : cmdline_fixed_string_t vlan_type;
4718 : : cmdline_fixed_string_t what;
4719 : : cmdline_fixed_string_t on;
4720 : : cmdline_fixed_string_t port_id;
4721 : : };
4722 : :
4723 : : static void
4724 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4725 : : __rte_unused struct cmdline *cl,
4726 : : __rte_unused void *data)
4727 : : {
4728 : : int on;
4729 : : struct cmd_vlan_offload_result *res = parsed_result;
4730 : : char *str;
4731 : : int i, len = 0;
4732 : : portid_t port_id = 0;
4733 : : unsigned int tmp;
4734 : :
4735 : 0 : str = res->port_id;
4736 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4737 : : i = 0;
4738 : : /* Get port_id first */
4739 : 0 : while(i < len){
4740 : 0 : if(str[i] == ',')
4741 : : break;
4742 : :
4743 : 0 : i++;
4744 : : }
4745 : 0 : str[i]='\0';
4746 : 0 : tmp = strtoul(str, NULL, 0);
4747 : : /* If port_id greater that what portid_t can represent, return */
4748 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4749 : : return;
4750 : 0 : port_id = (portid_t)tmp;
4751 : :
4752 : 0 : if (!strcmp(res->on, "on"))
4753 : : on = 1;
4754 : : else
4755 : : on = 0;
4756 : :
4757 : 0 : if (!strcmp(res->what, "strip"))
4758 : 0 : rx_vlan_strip_set(port_id, on);
4759 : 0 : else if(!strcmp(res->what, "stripq")){
4760 : : uint16_t queue_id = 0;
4761 : :
4762 : : /* No queue_id, return */
4763 : 0 : if(i + 1 >= len) {
4764 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4765 : 0 : return;
4766 : : }
4767 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4768 : : /* If queue_id greater that what 16-bits can represent, return */
4769 : 0 : if(tmp > 0xffff)
4770 : : return;
4771 : :
4772 : 0 : queue_id = (uint16_t)tmp;
4773 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4774 : : }
4775 : 0 : else if (!strcmp(res->what, "filter"))
4776 : 0 : rx_vlan_filter_set(port_id, on);
4777 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4778 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4779 : : else
4780 : 0 : vlan_extend_set(port_id, on);
4781 : :
4782 : : return;
4783 : : }
4784 : :
4785 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4786 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4787 : : vlan, "vlan");
4788 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4789 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4790 : : set, "set");
4791 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4792 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4793 : : what, "strip#filter#qinq_strip#extend#stripq");
4794 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4795 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4796 : : on, "on#off");
4797 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4798 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4799 : : port_id, NULL);
4800 : :
4801 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4802 : : .f = cmd_vlan_offload_parsed,
4803 : : .data = NULL,
4804 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4805 : : "<port_id[,queue_id]>: "
4806 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4807 : : .tokens = {
4808 : : (void *)&cmd_vlan_offload_vlan,
4809 : : (void *)&cmd_vlan_offload_set,
4810 : : (void *)&cmd_vlan_offload_what,
4811 : : (void *)&cmd_vlan_offload_on,
4812 : : (void *)&cmd_vlan_offload_portid,
4813 : : NULL,
4814 : : },
4815 : : };
4816 : :
4817 : : /* *** VLAN TPID SET ON A PORT *** */
4818 : : struct cmd_vlan_tpid_result {
4819 : : cmdline_fixed_string_t vlan;
4820 : : cmdline_fixed_string_t set;
4821 : : cmdline_fixed_string_t vlan_type;
4822 : : cmdline_fixed_string_t what;
4823 : : uint16_t tp_id;
4824 : : portid_t port_id;
4825 : : };
4826 : :
4827 : : static void
4828 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4829 : : __rte_unused struct cmdline *cl,
4830 : : __rte_unused void *data)
4831 : : {
4832 : : struct cmd_vlan_tpid_result *res = parsed_result;
4833 : : enum rte_vlan_type vlan_type;
4834 : :
4835 : 0 : if (!strcmp(res->vlan_type, "inner"))
4836 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4837 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4838 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4839 : : else {
4840 : 0 : fprintf(stderr, "Unknown vlan type\n");
4841 : 0 : return;
4842 : : }
4843 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4844 : : }
4845 : :
4846 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4847 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4848 : : vlan, "vlan");
4849 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4850 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4851 : : set, "set");
4852 : : static cmdline_parse_token_string_t cmd_vlan_type =
4853 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4854 : : vlan_type, "inner#outer");
4855 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4856 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4857 : : what, "tpid");
4858 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4859 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4860 : : tp_id, RTE_UINT16);
4861 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4862 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4863 : : port_id, RTE_UINT16);
4864 : :
4865 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4866 : : .f = cmd_vlan_tpid_parsed,
4867 : : .data = NULL,
4868 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4869 : : "Set the VLAN Ether type",
4870 : : .tokens = {
4871 : : (void *)&cmd_vlan_tpid_vlan,
4872 : : (void *)&cmd_vlan_tpid_set,
4873 : : (void *)&cmd_vlan_type,
4874 : : (void *)&cmd_vlan_tpid_what,
4875 : : (void *)&cmd_vlan_tpid_tpid,
4876 : : (void *)&cmd_vlan_tpid_portid,
4877 : : NULL,
4878 : : },
4879 : : };
4880 : :
4881 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4882 : : struct cmd_rx_vlan_filter_result {
4883 : : cmdline_fixed_string_t rx_vlan;
4884 : : cmdline_fixed_string_t what;
4885 : : uint16_t vlan_id;
4886 : : portid_t port_id;
4887 : : };
4888 : :
4889 : : static void
4890 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4891 : : __rte_unused struct cmdline *cl,
4892 : : __rte_unused void *data)
4893 : : {
4894 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4895 : :
4896 : 0 : if (!strcmp(res->what, "add"))
4897 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4898 : : else
4899 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4900 : 0 : }
4901 : :
4902 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4903 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4904 : : rx_vlan, "rx_vlan");
4905 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4906 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4907 : : what, "add#rm");
4908 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4909 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4910 : : vlan_id, RTE_UINT16);
4911 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4912 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4913 : : port_id, RTE_UINT16);
4914 : :
4915 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4916 : : .f = cmd_rx_vlan_filter_parsed,
4917 : : .data = NULL,
4918 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4919 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4920 : : "identifiers filtered by a port",
4921 : : .tokens = {
4922 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4923 : : (void *)&cmd_rx_vlan_filter_what,
4924 : : (void *)&cmd_rx_vlan_filter_vlanid,
4925 : : (void *)&cmd_rx_vlan_filter_portid,
4926 : : NULL,
4927 : : },
4928 : : };
4929 : :
4930 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4931 : : struct cmd_tx_vlan_set_result {
4932 : : cmdline_fixed_string_t tx_vlan;
4933 : : cmdline_fixed_string_t set;
4934 : : portid_t port_id;
4935 : : uint16_t vlan_tci;
4936 : : };
4937 : :
4938 : : static void
4939 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4940 : : __rte_unused struct cmdline *cl,
4941 : : __rte_unused void *data)
4942 : : {
4943 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4944 : :
4945 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4946 : : return;
4947 : :
4948 : 0 : if (!port_is_stopped(res->port_id)) {
4949 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4950 : 0 : return;
4951 : : }
4952 : :
4953 : 0 : tx_vlan_set(res->port_id, res->vlan_tci);
4954 : :
4955 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4956 : : }
4957 : :
4958 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4959 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4960 : : tx_vlan, "tx_vlan");
4961 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4962 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4963 : : set, "set");
4964 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4965 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4966 : : port_id, RTE_UINT16);
4967 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlantci =
4968 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4969 : : vlan_tci, RTE_UINT16);
4970 : :
4971 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4972 : : .f = cmd_tx_vlan_set_parsed,
4973 : : .data = NULL,
4974 : : .help_str = "tx_vlan set <port_id> <vlan_tci>: "
4975 : : "Enable hardware insertion of a single VLAN header "
4976 : : "with a given TCI in packets sent on a port",
4977 : : .tokens = {
4978 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4979 : : (void *)&cmd_tx_vlan_set_set,
4980 : : (void *)&cmd_tx_vlan_set_portid,
4981 : : (void *)&cmd_tx_vlan_set_vlantci,
4982 : : NULL,
4983 : : },
4984 : : };
4985 : :
4986 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4987 : : struct cmd_tx_vlan_set_qinq_result {
4988 : : cmdline_fixed_string_t tx_vlan;
4989 : : cmdline_fixed_string_t set;
4990 : : portid_t port_id;
4991 : : uint16_t vlan_tci;
4992 : : uint16_t vlan_tci_outer;
4993 : : };
4994 : :
4995 : : static void
4996 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4997 : : __rte_unused struct cmdline *cl,
4998 : : __rte_unused void *data)
4999 : : {
5000 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
5001 : :
5002 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5003 : : return;
5004 : :
5005 : 0 : if (!port_is_stopped(res->port_id)) {
5006 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5007 : 0 : return;
5008 : : }
5009 : :
5010 : 0 : tx_qinq_set(res->port_id, res->vlan_tci, res->vlan_tci_outer);
5011 : :
5012 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5013 : : }
5014 : :
5015 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
5016 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5017 : : tx_vlan, "tx_vlan");
5018 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
5019 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5020 : : set, "set");
5021 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
5022 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5023 : : port_id, RTE_UINT16);
5024 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlantci =
5025 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5026 : : vlan_tci, RTE_UINT16);
5027 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlantci_outer =
5028 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
5029 : : vlan_tci_outer, RTE_UINT16);
5030 : :
5031 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
5032 : : .f = cmd_tx_vlan_set_qinq_parsed,
5033 : : .data = NULL,
5034 : : .help_str = "tx_vlan set <port_id> <vlan_tci> <vlan_tci_outer>: "
5035 : : "Enable hardware insertion of double VLAN header "
5036 : : "with given TCIs in packets sent on a port",
5037 : : .tokens = {
5038 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
5039 : : (void *)&cmd_tx_vlan_set_qinq_set,
5040 : : (void *)&cmd_tx_vlan_set_qinq_portid,
5041 : : (void *)&cmd_tx_vlan_set_qinq_vlantci,
5042 : : (void *)&cmd_tx_vlan_set_qinq_vlantci_outer,
5043 : : NULL,
5044 : : },
5045 : : };
5046 : :
5047 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
5048 : : struct cmd_tx_vlan_set_pvid_result {
5049 : : cmdline_fixed_string_t tx_vlan;
5050 : : cmdline_fixed_string_t set;
5051 : : cmdline_fixed_string_t pvid;
5052 : : portid_t port_id;
5053 : : uint16_t vlan_id;
5054 : : cmdline_fixed_string_t mode;
5055 : : };
5056 : :
5057 : : static void
5058 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
5059 : : __rte_unused struct cmdline *cl,
5060 : : __rte_unused void *data)
5061 : : {
5062 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
5063 : :
5064 : 0 : if (strcmp(res->mode, "on") == 0)
5065 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
5066 : : else
5067 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
5068 : 0 : }
5069 : :
5070 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
5071 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5072 : : tx_vlan, "tx_vlan");
5073 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
5074 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5075 : : set, "set");
5076 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
5077 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5078 : : pvid, "pvid");
5079 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
5080 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5081 : : port_id, RTE_UINT16);
5082 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
5083 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5084 : : vlan_id, RTE_UINT16);
5085 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
5086 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5087 : : mode, "on#off");
5088 : :
5089 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
5090 : : .f = cmd_tx_vlan_set_pvid_parsed,
5091 : : .data = NULL,
5092 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
5093 : : .tokens = {
5094 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
5095 : : (void *)&cmd_tx_vlan_set_pvid_set,
5096 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
5097 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
5098 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
5099 : : (void *)&cmd_tx_vlan_set_pvid_mode,
5100 : : NULL,
5101 : : },
5102 : : };
5103 : :
5104 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
5105 : : struct cmd_tx_vlan_reset_result {
5106 : : cmdline_fixed_string_t tx_vlan;
5107 : : cmdline_fixed_string_t reset;
5108 : : portid_t port_id;
5109 : : };
5110 : :
5111 : : static void
5112 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
5113 : : __rte_unused struct cmdline *cl,
5114 : : __rte_unused void *data)
5115 : : {
5116 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
5117 : :
5118 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5119 : : return;
5120 : :
5121 : 0 : if (!port_is_stopped(res->port_id)) {
5122 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5123 : 0 : return;
5124 : : }
5125 : :
5126 : 0 : tx_vlan_reset(res->port_id);
5127 : :
5128 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5129 : : }
5130 : :
5131 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
5132 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5133 : : tx_vlan, "tx_vlan");
5134 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
5135 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5136 : : reset, "reset");
5137 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
5138 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
5139 : : port_id, RTE_UINT16);
5140 : :
5141 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
5142 : : .f = cmd_tx_vlan_reset_parsed,
5143 : : .data = NULL,
5144 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
5145 : : "VLAN header in packets sent on a port",
5146 : : .tokens = {
5147 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
5148 : : (void *)&cmd_tx_vlan_reset_reset,
5149 : : (void *)&cmd_tx_vlan_reset_portid,
5150 : : NULL,
5151 : : },
5152 : : };
5153 : :
5154 : :
5155 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
5156 : : struct cmd_csum_result {
5157 : : cmdline_fixed_string_t csum;
5158 : : cmdline_fixed_string_t mode;
5159 : : cmdline_fixed_string_t proto;
5160 : : cmdline_fixed_string_t hwsw;
5161 : : portid_t port_id;
5162 : : };
5163 : :
5164 : : static void
5165 : 0 : csum_show(int port_id)
5166 : : {
5167 : : struct rte_eth_dev_info dev_info;
5168 : : uint64_t tx_offloads;
5169 : : int ret;
5170 : :
5171 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
5172 : 0 : printf("Parse tunnel is %s\n",
5173 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
5174 : 0 : printf("IP checksum offload is %s\n",
5175 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
5176 : 0 : printf("UDP checksum offload is %s\n",
5177 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
5178 : 0 : printf("TCP checksum offload is %s\n",
5179 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
5180 : 0 : printf("SCTP checksum offload is %s\n",
5181 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
5182 : 0 : printf("Outer-Ip checksum offload is %s\n",
5183 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
5184 : 0 : printf("Outer-Udp checksum offload is %s\n",
5185 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
5186 : :
5187 : : /* display warnings if configuration is not supported by the NIC */
5188 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
5189 : 0 : if (ret != 0)
5190 : 0 : return;
5191 : :
5192 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
5193 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
5194 : 0 : fprintf(stderr,
5195 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
5196 : : port_id);
5197 : : }
5198 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
5199 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
5200 : 0 : fprintf(stderr,
5201 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
5202 : : port_id);
5203 : : }
5204 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
5205 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
5206 : 0 : fprintf(stderr,
5207 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
5208 : : port_id);
5209 : : }
5210 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
5211 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
5212 : 0 : fprintf(stderr,
5213 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
5214 : : port_id);
5215 : : }
5216 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
5217 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
5218 : 0 : fprintf(stderr,
5219 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
5220 : : port_id);
5221 : : }
5222 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
5223 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
5224 : : == 0) {
5225 : 0 : fprintf(stderr,
5226 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
5227 : : port_id);
5228 : : }
5229 : : }
5230 : :
5231 : : static void
5232 : : cmd_config_queue_tx_offloads(struct rte_port *port)
5233 : : {
5234 : : int k;
5235 : :
5236 : : /* Apply queue tx offloads configuration */
5237 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
5238 : 0 : port->txq[k].conf.offloads =
5239 : 0 : port->dev_conf.txmode.offloads;
5240 : : }
5241 : :
5242 : : static void
5243 : 0 : cmd_csum_parsed(void *parsed_result,
5244 : : __rte_unused struct cmdline *cl,
5245 : : __rte_unused void *data)
5246 : : {
5247 : : struct cmd_csum_result *res = parsed_result;
5248 : : int hw = 0;
5249 : : uint64_t csum_offloads = 0;
5250 : : struct rte_eth_dev_info dev_info;
5251 : : int ret;
5252 : :
5253 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
5254 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
5255 : 0 : return;
5256 : : }
5257 : 0 : if (!port_is_stopped(res->port_id)) {
5258 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5259 : 0 : return;
5260 : : }
5261 : :
5262 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5263 : 0 : if (ret != 0)
5264 : : return;
5265 : :
5266 : 0 : if (!strcmp(res->mode, "set")) {
5267 : :
5268 : 0 : if (!strcmp(res->hwsw, "hw"))
5269 : : hw = 1;
5270 : :
5271 : 0 : if (!strcmp(res->proto, "ip")) {
5272 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5273 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
5274 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
5275 : : } else {
5276 : 0 : fprintf(stderr,
5277 : : "IP checksum offload is not supported by port %u\n",
5278 : 0 : res->port_id);
5279 : : }
5280 : 0 : } else if (!strcmp(res->proto, "udp")) {
5281 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5282 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
5283 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
5284 : : } else {
5285 : 0 : fprintf(stderr,
5286 : : "UDP checksum offload is not supported by port %u\n",
5287 : 0 : res->port_id);
5288 : : }
5289 : 0 : } else if (!strcmp(res->proto, "tcp")) {
5290 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5291 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
5292 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
5293 : : } else {
5294 : 0 : fprintf(stderr,
5295 : : "TCP checksum offload is not supported by port %u\n",
5296 : 0 : res->port_id);
5297 : : }
5298 : 0 : } else if (!strcmp(res->proto, "sctp")) {
5299 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5300 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
5301 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
5302 : : } else {
5303 : 0 : fprintf(stderr,
5304 : : "SCTP checksum offload is not supported by port %u\n",
5305 : 0 : res->port_id);
5306 : : }
5307 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
5308 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5309 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5310 : : csum_offloads |=
5311 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
5312 : : } else {
5313 : 0 : fprintf(stderr,
5314 : : "Outer IP checksum offload is not supported by port %u\n",
5315 : 0 : res->port_id);
5316 : : }
5317 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
5318 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5319 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
5320 : : csum_offloads |=
5321 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
5322 : : } else {
5323 : 0 : fprintf(stderr,
5324 : : "Outer UDP checksum offload is not supported by port %u\n",
5325 : 0 : res->port_id);
5326 : : }
5327 : : }
5328 : :
5329 : 0 : if (hw) {
5330 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5331 : : csum_offloads;
5332 : : } else {
5333 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5334 : 0 : (~csum_offloads);
5335 : : }
5336 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5337 : : }
5338 : 0 : csum_show(res->port_id);
5339 : :
5340 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5341 : : }
5342 : :
5343 : : static cmdline_parse_token_string_t cmd_csum_csum =
5344 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5345 : : csum, "csum");
5346 : : static cmdline_parse_token_string_t cmd_csum_mode =
5347 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5348 : : mode, "set");
5349 : : static cmdline_parse_token_string_t cmd_csum_proto =
5350 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5351 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
5352 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
5353 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5354 : : hwsw, "hw#sw");
5355 : : static cmdline_parse_token_num_t cmd_csum_portid =
5356 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
5357 : : port_id, RTE_UINT16);
5358 : :
5359 : : static cmdline_parse_inst_t cmd_csum_set = {
5360 : : .f = cmd_csum_parsed,
5361 : : .data = NULL,
5362 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
5363 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
5364 : : "using csum forward engine",
5365 : : .tokens = {
5366 : : (void *)&cmd_csum_csum,
5367 : : (void *)&cmd_csum_mode,
5368 : : (void *)&cmd_csum_proto,
5369 : : (void *)&cmd_csum_hwsw,
5370 : : (void *)&cmd_csum_portid,
5371 : : NULL,
5372 : : },
5373 : : };
5374 : :
5375 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
5376 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5377 : : mode, "show");
5378 : :
5379 : : static cmdline_parse_inst_t cmd_csum_show = {
5380 : : .f = cmd_csum_parsed,
5381 : : .data = NULL,
5382 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
5383 : : .tokens = {
5384 : : (void *)&cmd_csum_csum,
5385 : : (void *)&cmd_csum_mode_show,
5386 : : (void *)&cmd_csum_portid,
5387 : : NULL,
5388 : : },
5389 : : };
5390 : :
5391 : : /* Enable/disable tunnel parsing */
5392 : : struct cmd_csum_tunnel_result {
5393 : : cmdline_fixed_string_t csum;
5394 : : cmdline_fixed_string_t parse;
5395 : : cmdline_fixed_string_t onoff;
5396 : : portid_t port_id;
5397 : : };
5398 : :
5399 : : static void
5400 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
5401 : : __rte_unused struct cmdline *cl,
5402 : : __rte_unused void *data)
5403 : : {
5404 : : struct cmd_csum_tunnel_result *res = parsed_result;
5405 : :
5406 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5407 : : return;
5408 : :
5409 : 0 : if (!strcmp(res->onoff, "on"))
5410 : 0 : ports[res->port_id].parse_tunnel = 1;
5411 : : else
5412 : 0 : ports[res->port_id].parse_tunnel = 0;
5413 : :
5414 : 0 : csum_show(res->port_id);
5415 : : }
5416 : :
5417 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
5418 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5419 : : csum, "csum");
5420 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
5421 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5422 : : parse, "parse-tunnel");
5423 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
5424 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5425 : : onoff, "on#off");
5426 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
5427 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
5428 : : port_id, RTE_UINT16);
5429 : :
5430 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
5431 : : .f = cmd_csum_tunnel_parsed,
5432 : : .data = NULL,
5433 : : .help_str = "csum parse-tunnel on|off <port_id>: "
5434 : : "Enable/Disable parsing of tunnels for csum engine",
5435 : : .tokens = {
5436 : : (void *)&cmd_csum_tunnel_csum,
5437 : : (void *)&cmd_csum_tunnel_parse,
5438 : : (void *)&cmd_csum_tunnel_onoff,
5439 : : (void *)&cmd_csum_tunnel_portid,
5440 : : NULL,
5441 : : },
5442 : : };
5443 : :
5444 : : struct cmd_csum_mac_swap_result {
5445 : : cmdline_fixed_string_t csum;
5446 : : cmdline_fixed_string_t parse;
5447 : : cmdline_fixed_string_t onoff;
5448 : : portid_t port_id;
5449 : : };
5450 : :
5451 : : static void
5452 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
5453 : : __rte_unused struct cmdline *cl,
5454 : : __rte_unused void *data)
5455 : : {
5456 : : struct cmd_csum_mac_swap_result *res = parsed_result;
5457 : :
5458 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5459 : : return;
5460 : 0 : if (strcmp(res->onoff, "on") == 0)
5461 : 0 : ports[res->port_id].fwd_mac_swap = 1;
5462 : : else
5463 : 0 : ports[res->port_id].fwd_mac_swap = 0;
5464 : : }
5465 : :
5466 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
5467 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5468 : : csum, "csum");
5469 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
5470 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5471 : : parse, "mac-swap");
5472 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
5473 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5474 : : onoff, "on#off");
5475 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
5476 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
5477 : : port_id, RTE_UINT16);
5478 : :
5479 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
5480 : : .f = cmd_csum_mac_swap_parsed,
5481 : : .data = NULL,
5482 : : .help_str = "csum mac-swap on|off <port_id>: "
5483 : : "Enable/Disable forward mac address swap",
5484 : : .tokens = {
5485 : : (void *)&cmd_csum_mac_swap_csum,
5486 : : (void *)&cmd_csum_mac_swap_parse,
5487 : : (void *)&cmd_csum_mac_swap_onoff,
5488 : : (void *)&cmd_csum_mac_swap_portid,
5489 : : NULL,
5490 : : },
5491 : : };
5492 : :
5493 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5494 : : struct cmd_tso_set_result {
5495 : : cmdline_fixed_string_t tso;
5496 : : cmdline_fixed_string_t mode;
5497 : : uint16_t tso_segsz;
5498 : : portid_t port_id;
5499 : : };
5500 : :
5501 : : static void
5502 : 0 : cmd_tso_set_parsed(void *parsed_result,
5503 : : __rte_unused struct cmdline *cl,
5504 : : __rte_unused void *data)
5505 : : {
5506 : : struct cmd_tso_set_result *res = parsed_result;
5507 : : struct rte_eth_dev_info dev_info;
5508 : : uint64_t offloads;
5509 : : int ret;
5510 : :
5511 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5512 : 0 : return;
5513 : 0 : if (!port_is_stopped(res->port_id)) {
5514 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5515 : 0 : return;
5516 : : }
5517 : :
5518 : 0 : if (!strcmp(res->mode, "set"))
5519 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5520 : :
5521 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5522 : 0 : if (ret != 0)
5523 : : return;
5524 : :
5525 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5526 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5527 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5528 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5529 : : res->port_id);
5530 : 0 : return;
5531 : : }
5532 : : /* display warnings if configuration is not supported by the NIC */
5533 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5534 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5535 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5536 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5537 : : }
5538 : :
5539 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5540 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5541 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5542 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5543 : : } else {
5544 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5545 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5546 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5547 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5548 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5549 : 0 : printf("segment size for non-tunneled packets is %d\n",
5550 : : ports[res->port_id].tso_segsz);
5551 : : }
5552 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5553 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5554 : : }
5555 : :
5556 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5557 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5558 : : tso, "tso");
5559 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5560 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5561 : : mode, "set");
5562 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5563 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5564 : : tso_segsz, RTE_UINT16);
5565 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5566 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5567 : : port_id, RTE_UINT16);
5568 : :
5569 : : static cmdline_parse_inst_t cmd_tso_set = {
5570 : : .f = cmd_tso_set_parsed,
5571 : : .data = NULL,
5572 : : .help_str = "tso set <tso_segsz> <port_id>: "
5573 : : "Set TSO segment size of non-tunneled packets for csum engine "
5574 : : "(0 to disable)",
5575 : : .tokens = {
5576 : : (void *)&cmd_tso_set_tso,
5577 : : (void *)&cmd_tso_set_mode,
5578 : : (void *)&cmd_tso_set_tso_segsz,
5579 : : (void *)&cmd_tso_set_portid,
5580 : : NULL,
5581 : : },
5582 : : };
5583 : :
5584 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5585 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5586 : : mode, "show");
5587 : :
5588 : :
5589 : : static cmdline_parse_inst_t cmd_tso_show = {
5590 : : .f = cmd_tso_set_parsed,
5591 : : .data = NULL,
5592 : : .help_str = "tso show <port_id>: "
5593 : : "Show TSO segment size of non-tunneled packets for csum engine",
5594 : : .tokens = {
5595 : : (void *)&cmd_tso_set_tso,
5596 : : (void *)&cmd_tso_show_mode,
5597 : : (void *)&cmd_tso_set_portid,
5598 : : NULL,
5599 : : },
5600 : : };
5601 : :
5602 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5603 : : struct cmd_tunnel_tso_set_result {
5604 : : cmdline_fixed_string_t tso;
5605 : : cmdline_fixed_string_t mode;
5606 : : uint16_t tso_segsz;
5607 : : portid_t port_id;
5608 : : };
5609 : :
5610 : : static void
5611 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5612 : : {
5613 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5614 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5615 : : port_id);
5616 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5617 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5618 : : port_id);
5619 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5620 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5621 : : port_id);
5622 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5623 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5624 : : port_id);
5625 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5626 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5627 : : port_id);
5628 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5629 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5630 : : port_id);
5631 : 0 : }
5632 : :
5633 : : static void
5634 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5635 : : __rte_unused struct cmdline *cl,
5636 : : __rte_unused void *data)
5637 : : {
5638 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5639 : : struct rte_eth_dev_info dev_info;
5640 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5641 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5642 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5643 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5644 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5645 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5646 : : int ret;
5647 : :
5648 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5649 : 0 : return;
5650 : 0 : if (!port_is_stopped(res->port_id)) {
5651 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5652 : 0 : return;
5653 : : }
5654 : :
5655 : 0 : if (!strcmp(res->mode, "set"))
5656 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5657 : :
5658 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5659 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5660 : : printf("TSO for tunneled packets is disabled\n");
5661 : : } else {
5662 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5663 : 0 : if (ret != 0)
5664 : : return;
5665 : :
5666 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5667 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5668 : 0 : res->port_id);
5669 : 0 : return;
5670 : : }
5671 : :
5672 : : /* Below conditions are needed to make it work:
5673 : : * (1) tunnel TSO is supported by the NIC;
5674 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5675 : : * are recognized;
5676 : : * (3) for tunneled pkts with outer L3 of IPv4,
5677 : : * "csum set outer-ip" must be set to hw, because after tso,
5678 : : * total_len of outer IP header is changed, and the checksum
5679 : : * of outer IP header calculated by sw should be wrong; that
5680 : : * is not necessary for IPv6 tunneled pkts because there's no
5681 : : * checksum in IP header anymore.
5682 : : */
5683 : 0 : if (!ports[res->port_id].parse_tunnel) {
5684 : 0 : fprintf(stderr,
5685 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5686 : 0 : return;
5687 : : }
5688 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5689 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5690 : 0 : fprintf(stderr,
5691 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5692 : 0 : return;
5693 : : }
5694 : :
5695 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5696 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5697 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5698 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5699 : 0 : ports[res->port_id].tunnel_tso_segsz);
5700 : : }
5701 : :
5702 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5703 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5704 : : }
5705 : :
5706 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5707 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5708 : : tso, "tunnel_tso");
5709 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5710 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5711 : : mode, "set");
5712 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5713 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5714 : : tso_segsz, RTE_UINT16);
5715 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5716 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5717 : : port_id, RTE_UINT16);
5718 : :
5719 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5720 : : .f = cmd_tunnel_tso_set_parsed,
5721 : : .data = NULL,
5722 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5723 : : "Set TSO segment size of tunneled packets for csum engine "
5724 : : "(0 to disable)",
5725 : : .tokens = {
5726 : : (void *)&cmd_tunnel_tso_set_tso,
5727 : : (void *)&cmd_tunnel_tso_set_mode,
5728 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5729 : : (void *)&cmd_tunnel_tso_set_portid,
5730 : : NULL,
5731 : : },
5732 : : };
5733 : :
5734 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5735 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5736 : : mode, "show");
5737 : :
5738 : :
5739 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5740 : : .f = cmd_tunnel_tso_set_parsed,
5741 : : .data = NULL,
5742 : : .help_str = "tunnel_tso show <port_id> "
5743 : : "Show TSO segment size of tunneled packets for csum engine",
5744 : : .tokens = {
5745 : : (void *)&cmd_tunnel_tso_set_tso,
5746 : : (void *)&cmd_tunnel_tso_show_mode,
5747 : : (void *)&cmd_tunnel_tso_set_portid,
5748 : : NULL,
5749 : : },
5750 : : };
5751 : :
5752 : : #ifdef RTE_LIB_GRO
5753 : : /* *** SET GRO FOR A PORT *** */
5754 : : struct cmd_gro_enable_result {
5755 : : cmdline_fixed_string_t cmd_set;
5756 : : cmdline_fixed_string_t cmd_port;
5757 : : cmdline_fixed_string_t cmd_keyword;
5758 : : cmdline_fixed_string_t cmd_onoff;
5759 : : portid_t cmd_pid;
5760 : : };
5761 : :
5762 : : static void
5763 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5764 : : __rte_unused struct cmdline *cl,
5765 : : __rte_unused void *data)
5766 : : {
5767 : : struct cmd_gro_enable_result *res;
5768 : :
5769 : : res = parsed_result;
5770 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5771 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5772 : 0 : }
5773 : :
5774 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5775 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5776 : : cmd_set, "set");
5777 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5778 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5779 : : cmd_keyword, "port");
5780 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5781 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5782 : : cmd_pid, RTE_UINT16);
5783 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5784 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5785 : : cmd_keyword, "gro");
5786 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5787 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5788 : : cmd_onoff, "on#off");
5789 : :
5790 : : static cmdline_parse_inst_t cmd_gro_enable = {
5791 : : .f = cmd_gro_enable_parsed,
5792 : : .data = NULL,
5793 : : .help_str = "set port <port_id> gro on|off",
5794 : : .tokens = {
5795 : : (void *)&cmd_gro_enable_set,
5796 : : (void *)&cmd_gro_enable_port,
5797 : : (void *)&cmd_gro_enable_pid,
5798 : : (void *)&cmd_gro_enable_keyword,
5799 : : (void *)&cmd_gro_enable_onoff,
5800 : : NULL,
5801 : : },
5802 : : };
5803 : :
5804 : : /* *** DISPLAY GRO CONFIGURATION *** */
5805 : : struct cmd_gro_show_result {
5806 : : cmdline_fixed_string_t cmd_show;
5807 : : cmdline_fixed_string_t cmd_port;
5808 : : cmdline_fixed_string_t cmd_keyword;
5809 : : portid_t cmd_pid;
5810 : : };
5811 : :
5812 : : static void
5813 : 0 : cmd_gro_show_parsed(void *parsed_result,
5814 : : __rte_unused struct cmdline *cl,
5815 : : __rte_unused void *data)
5816 : : {
5817 : : struct cmd_gro_show_result *res;
5818 : :
5819 : : res = parsed_result;
5820 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5821 : 0 : show_gro(res->cmd_pid);
5822 : 0 : }
5823 : :
5824 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5825 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5826 : : cmd_show, "show");
5827 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5828 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5829 : : cmd_port, "port");
5830 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5831 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5832 : : cmd_pid, RTE_UINT16);
5833 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5834 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5835 : : cmd_keyword, "gro");
5836 : :
5837 : : static cmdline_parse_inst_t cmd_gro_show = {
5838 : : .f = cmd_gro_show_parsed,
5839 : : .data = NULL,
5840 : : .help_str = "show port <port_id> gro",
5841 : : .tokens = {
5842 : : (void *)&cmd_gro_show_show,
5843 : : (void *)&cmd_gro_show_port,
5844 : : (void *)&cmd_gro_show_pid,
5845 : : (void *)&cmd_gro_show_keyword,
5846 : : NULL,
5847 : : },
5848 : : };
5849 : :
5850 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5851 : : struct cmd_gro_flush_result {
5852 : : cmdline_fixed_string_t cmd_set;
5853 : : cmdline_fixed_string_t cmd_keyword;
5854 : : cmdline_fixed_string_t cmd_flush;
5855 : : uint8_t cmd_cycles;
5856 : : };
5857 : :
5858 : : static void
5859 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5860 : : __rte_unused struct cmdline *cl,
5861 : : __rte_unused void *data)
5862 : : {
5863 : : struct cmd_gro_flush_result *res;
5864 : :
5865 : : res = parsed_result;
5866 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5867 : 0 : (!strcmp(res->cmd_flush, "flush")))
5868 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5869 : 0 : }
5870 : :
5871 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5872 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5873 : : cmd_set, "set");
5874 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5875 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5876 : : cmd_keyword, "gro");
5877 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5878 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5879 : : cmd_flush, "flush");
5880 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5881 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5882 : : cmd_cycles, RTE_UINT8);
5883 : :
5884 : : static cmdline_parse_inst_t cmd_gro_flush = {
5885 : : .f = cmd_gro_flush_parsed,
5886 : : .data = NULL,
5887 : : .help_str = "set gro flush <cycles>",
5888 : : .tokens = {
5889 : : (void *)&cmd_gro_flush_set,
5890 : : (void *)&cmd_gro_flush_keyword,
5891 : : (void *)&cmd_gro_flush_flush,
5892 : : (void *)&cmd_gro_flush_cycles,
5893 : : NULL,
5894 : : },
5895 : : };
5896 : : #endif /* RTE_LIB_GRO */
5897 : :
5898 : : #ifdef RTE_LIB_GSO
5899 : : /* *** ENABLE/DISABLE GSO *** */
5900 : : struct cmd_gso_enable_result {
5901 : : cmdline_fixed_string_t cmd_set;
5902 : : cmdline_fixed_string_t cmd_port;
5903 : : cmdline_fixed_string_t cmd_keyword;
5904 : : cmdline_fixed_string_t cmd_mode;
5905 : : portid_t cmd_pid;
5906 : : };
5907 : :
5908 : : static void
5909 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5910 : : __rte_unused struct cmdline *cl,
5911 : : __rte_unused void *data)
5912 : : {
5913 : : struct cmd_gso_enable_result *res;
5914 : :
5915 : : res = parsed_result;
5916 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5917 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5918 : 0 : }
5919 : :
5920 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5921 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5922 : : cmd_set, "set");
5923 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5924 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5925 : : cmd_port, "port");
5926 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5927 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5928 : : cmd_keyword, "gso");
5929 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5930 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5931 : : cmd_mode, "on#off");
5932 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5933 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5934 : : cmd_pid, RTE_UINT16);
5935 : :
5936 : : static cmdline_parse_inst_t cmd_gso_enable = {
5937 : : .f = cmd_gso_enable_parsed,
5938 : : .data = NULL,
5939 : : .help_str = "set port <port_id> gso on|off",
5940 : : .tokens = {
5941 : : (void *)&cmd_gso_enable_set,
5942 : : (void *)&cmd_gso_enable_port,
5943 : : (void *)&cmd_gso_enable_pid,
5944 : : (void *)&cmd_gso_enable_keyword,
5945 : : (void *)&cmd_gso_enable_mode,
5946 : : NULL,
5947 : : },
5948 : : };
5949 : :
5950 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5951 : : struct cmd_gso_size_result {
5952 : : cmdline_fixed_string_t cmd_set;
5953 : : cmdline_fixed_string_t cmd_keyword;
5954 : : cmdline_fixed_string_t cmd_segsz;
5955 : : uint16_t cmd_size;
5956 : : };
5957 : :
5958 : : static void
5959 : 0 : cmd_gso_size_parsed(void *parsed_result,
5960 : : __rte_unused struct cmdline *cl,
5961 : : __rte_unused void *data)
5962 : : {
5963 : : struct cmd_gso_size_result *res = parsed_result;
5964 : :
5965 : 0 : if (test_done == 0) {
5966 : 0 : fprintf(stderr,
5967 : : "Before setting GSO segsz, please first stop forwarding\n");
5968 : 0 : return;
5969 : : }
5970 : :
5971 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5972 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5973 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5974 : 0 : fprintf(stderr,
5975 : : "gso_size should be larger than %zu. Please input a legal value\n",
5976 : : RTE_GSO_SEG_SIZE_MIN);
5977 : : else
5978 : 0 : gso_max_segment_size = res->cmd_size;
5979 : : }
5980 : : }
5981 : :
5982 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5983 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5984 : : cmd_set, "set");
5985 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5986 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5987 : : cmd_keyword, "gso");
5988 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5989 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5990 : : cmd_segsz, "segsz");
5991 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5992 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5993 : : cmd_size, RTE_UINT16);
5994 : :
5995 : : static cmdline_parse_inst_t cmd_gso_size = {
5996 : : .f = cmd_gso_size_parsed,
5997 : : .data = NULL,
5998 : : .help_str = "set gso segsz <length>",
5999 : : .tokens = {
6000 : : (void *)&cmd_gso_size_set,
6001 : : (void *)&cmd_gso_size_keyword,
6002 : : (void *)&cmd_gso_size_segsz,
6003 : : (void *)&cmd_gso_size_size,
6004 : : NULL,
6005 : : },
6006 : : };
6007 : :
6008 : : /* *** SHOW GSO CONFIGURATION *** */
6009 : : struct cmd_gso_show_result {
6010 : : cmdline_fixed_string_t cmd_show;
6011 : : cmdline_fixed_string_t cmd_port;
6012 : : cmdline_fixed_string_t cmd_keyword;
6013 : : portid_t cmd_pid;
6014 : : };
6015 : :
6016 : : static void
6017 : 0 : cmd_gso_show_parsed(void *parsed_result,
6018 : : __rte_unused struct cmdline *cl,
6019 : : __rte_unused void *data)
6020 : : {
6021 : : struct cmd_gso_show_result *res = parsed_result;
6022 : :
6023 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
6024 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
6025 : 0 : return;
6026 : : }
6027 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
6028 : 0 : if (gso_ports[res->cmd_pid].enable) {
6029 : 0 : printf("Max GSO'd packet size: %uB\n"
6030 : : "Supported GSO types: TCP/IPv4, "
6031 : : "UDP/IPv4, VxLAN with inner "
6032 : : "TCP/IPv4 packet, GRE with inner "
6033 : : "TCP/IPv4 packet\n",
6034 : : gso_max_segment_size);
6035 : : } else
6036 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
6037 : : }
6038 : : }
6039 : :
6040 : : static cmdline_parse_token_string_t cmd_gso_show_show =
6041 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6042 : : cmd_show, "show");
6043 : : static cmdline_parse_token_string_t cmd_gso_show_port =
6044 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6045 : : cmd_port, "port");
6046 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
6047 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
6048 : : cmd_keyword, "gso");
6049 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
6050 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
6051 : : cmd_pid, RTE_UINT16);
6052 : :
6053 : : static cmdline_parse_inst_t cmd_gso_show = {
6054 : : .f = cmd_gso_show_parsed,
6055 : : .data = NULL,
6056 : : .help_str = "show port <port_id> gso",
6057 : : .tokens = {
6058 : : (void *)&cmd_gso_show_show,
6059 : : (void *)&cmd_gso_show_port,
6060 : : (void *)&cmd_gso_show_pid,
6061 : : (void *)&cmd_gso_show_keyword,
6062 : : NULL,
6063 : : },
6064 : : };
6065 : : #endif /* RTE_LIB_GSO */
6066 : :
6067 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
6068 : : struct cmd_set_flush_rx {
6069 : : cmdline_fixed_string_t set;
6070 : : cmdline_fixed_string_t flush_rx;
6071 : : cmdline_fixed_string_t mode;
6072 : : };
6073 : :
6074 : : static void
6075 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
6076 : : __rte_unused struct cmdline *cl,
6077 : : __rte_unused void *data)
6078 : : {
6079 : : struct cmd_set_flush_rx *res = parsed_result;
6080 : :
6081 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
6082 : : printf("multi-process doesn't support to flush Rx queues.\n");
6083 : 0 : return;
6084 : : }
6085 : :
6086 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6087 : : }
6088 : :
6089 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
6090 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6091 : : set, "set");
6092 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
6093 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6094 : : flush_rx, "flush_rx");
6095 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
6096 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6097 : : mode, "on#off");
6098 : :
6099 : :
6100 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
6101 : : .f = cmd_set_flush_rx_parsed,
6102 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
6103 : : .data = NULL,
6104 : : .tokens = {
6105 : : (void *)&cmd_setflushrx_set,
6106 : : (void *)&cmd_setflushrx_flush_rx,
6107 : : (void *)&cmd_setflushrx_mode,
6108 : : NULL,
6109 : : },
6110 : : };
6111 : :
6112 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
6113 : : struct cmd_set_link_check {
6114 : : cmdline_fixed_string_t set;
6115 : : cmdline_fixed_string_t link_check;
6116 : : cmdline_fixed_string_t mode;
6117 : : };
6118 : :
6119 : : static void
6120 : 0 : cmd_set_link_check_parsed(void *parsed_result,
6121 : : __rte_unused struct cmdline *cl,
6122 : : __rte_unused void *data)
6123 : : {
6124 : : struct cmd_set_link_check *res = parsed_result;
6125 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6126 : 0 : }
6127 : :
6128 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
6129 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6130 : : set, "set");
6131 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
6132 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6133 : : link_check, "link_check");
6134 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
6135 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6136 : : mode, "on#off");
6137 : :
6138 : :
6139 : : static cmdline_parse_inst_t cmd_set_link_check = {
6140 : : .f = cmd_set_link_check_parsed,
6141 : : .help_str = "set link_check on|off: Enable/Disable link status check "
6142 : : "when starting/stopping a port",
6143 : : .data = NULL,
6144 : : .tokens = {
6145 : : (void *)&cmd_setlinkcheck_set,
6146 : : (void *)&cmd_setlinkcheck_link_check,
6147 : : (void *)&cmd_setlinkcheck_mode,
6148 : : NULL,
6149 : : },
6150 : : };
6151 : :
6152 : : /* *** SET FORWARDING MODE *** */
6153 : : struct cmd_set_fwd_mode_result {
6154 : : cmdline_fixed_string_t set;
6155 : : cmdline_fixed_string_t fwd;
6156 : : cmdline_fixed_string_t mode;
6157 : : };
6158 : :
6159 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
6160 : : __rte_unused struct cmdline *cl,
6161 : : __rte_unused void *data)
6162 : : {
6163 : : struct cmd_set_fwd_mode_result *res = parsed_result;
6164 : :
6165 : 0 : retry_enabled = 0;
6166 : 0 : set_pkt_forwarding_mode(res->mode);
6167 : 0 : }
6168 : :
6169 : : static cmdline_parse_token_string_t cmd_setfwd_set =
6170 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6171 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
6172 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6173 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
6174 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6175 : : "" /* defined at init */);
6176 : :
6177 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
6178 : : .f = cmd_set_fwd_mode_parsed,
6179 : : .data = NULL,
6180 : : .help_str = NULL, /* defined at init */
6181 : : .tokens = {
6182 : : (void *)&cmd_setfwd_set,
6183 : : (void *)&cmd_setfwd_fwd,
6184 : : (void *)&cmd_setfwd_mode,
6185 : : NULL,
6186 : : },
6187 : : };
6188 : :
6189 : 0 : static void cmd_set_fwd_mode_init(void)
6190 : : {
6191 : : char *modes, *c;
6192 : : static char token[128];
6193 : : static char help[256];
6194 : : cmdline_parse_token_string_t *token_struct;
6195 : :
6196 : 0 : modes = list_pkt_forwarding_modes();
6197 : : snprintf(help, sizeof(help), "set fwd %s: "
6198 : : "Set packet forwarding mode", modes);
6199 : 0 : cmd_set_fwd_mode.help_str = help;
6200 : :
6201 : : /* string token separator is # */
6202 : 0 : for (c = token; *modes != '\0'; modes++)
6203 : 0 : if (*modes == '|')
6204 : 0 : *c++ = '#';
6205 : : else
6206 : 0 : *c++ = *modes;
6207 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6208 : 0 : token_struct->string_data.str = token;
6209 : 0 : }
6210 : :
6211 : : /* *** SET RETRY FORWARDING MODE *** */
6212 : : struct cmd_set_fwd_retry_mode_result {
6213 : : cmdline_fixed_string_t set;
6214 : : cmdline_fixed_string_t fwd;
6215 : : cmdline_fixed_string_t mode;
6216 : : cmdline_fixed_string_t retry;
6217 : : };
6218 : :
6219 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6220 : : __rte_unused struct cmdline *cl,
6221 : : __rte_unused void *data)
6222 : : {
6223 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6224 : :
6225 : 0 : retry_enabled = 1;
6226 : 0 : set_pkt_forwarding_mode(res->mode);
6227 : 0 : }
6228 : :
6229 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6230 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6231 : : set, "set");
6232 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6233 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6234 : : fwd, "fwd");
6235 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6236 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6237 : : mode,
6238 : : "" /* defined at init */);
6239 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6240 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6241 : : retry, "retry");
6242 : :
6243 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6244 : : .f = cmd_set_fwd_retry_mode_parsed,
6245 : : .data = NULL,
6246 : : .help_str = NULL, /* defined at init */
6247 : : .tokens = {
6248 : : (void *)&cmd_setfwd_retry_set,
6249 : : (void *)&cmd_setfwd_retry_fwd,
6250 : : (void *)&cmd_setfwd_retry_mode,
6251 : : (void *)&cmd_setfwd_retry_retry,
6252 : : NULL,
6253 : : },
6254 : : };
6255 : :
6256 : 0 : static void cmd_set_fwd_retry_mode_init(void)
6257 : : {
6258 : : char *modes, *c;
6259 : : static char token[128];
6260 : : static char help[256];
6261 : : cmdline_parse_token_string_t *token_struct;
6262 : :
6263 : 0 : modes = list_pkt_forwarding_retry_modes();
6264 : : snprintf(help, sizeof(help), "set fwd %s retry: "
6265 : : "Set packet forwarding mode with retry", modes);
6266 : 0 : cmd_set_fwd_retry_mode.help_str = help;
6267 : :
6268 : : /* string token separator is # */
6269 : 0 : for (c = token; *modes != '\0'; modes++)
6270 : 0 : if (*modes == '|')
6271 : 0 : *c++ = '#';
6272 : : else
6273 : 0 : *c++ = *modes;
6274 : 0 : token_struct = (cmdline_parse_token_string_t *)
6275 : : cmd_set_fwd_retry_mode.tokens[2];
6276 : 0 : token_struct->string_data.str = token;
6277 : 0 : }
6278 : :
6279 : 0 : static void show_dcb_fwd_tc_config(void)
6280 : : {
6281 : : int i;
6282 : : printf("DCB forwarding TC list:");
6283 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6284 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6285 : : printf(" %d", i);
6286 : : }
6287 : : printf("\n");
6288 : 0 : printf("DCB forwarding cores per-TC: %u\n", dcb_fwd_tc_cores);
6289 : 0 : }
6290 : :
6291 : : /* *** set DCB forward TCs *** */
6292 : : struct cmd_set_dcb_fwd_tc_result {
6293 : : cmdline_fixed_string_t set;
6294 : : cmdline_fixed_string_t dcb;
6295 : : cmdline_fixed_string_t fwd_tc;
6296 : : uint8_t tc_mask;
6297 : : };
6298 : :
6299 : 0 : static void cmd_set_dcb_fwd_tc_parsed(void *parsed_result,
6300 : : __rte_unused struct cmdline *cl,
6301 : : __rte_unused void *data)
6302 : : {
6303 : : struct cmd_set_dcb_fwd_tc_result *res = parsed_result;
6304 : : int i;
6305 : 0 : if (test_done == 0) {
6306 : 0 : fprintf(stderr, "Please stop forwarding first\n");
6307 : 0 : return;
6308 : : }
6309 : 0 : if (res->tc_mask == 0) {
6310 : 0 : fprintf(stderr, "TC mask should not be zero!\n");
6311 : 0 : return;
6312 : : }
6313 : : printf("Enabled DCB forwarding TC list:");
6314 : 0 : dcb_fwd_tc_mask = res->tc_mask;
6315 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6316 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6317 : : printf(" %d", i);
6318 : : }
6319 : : printf("\n");
6320 : : }
6321 : :
6322 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_set =
6323 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6324 : : set, "set");
6325 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_dcb =
6326 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6327 : : dcb, "dcb");
6328 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_fwdtc =
6329 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6330 : : fwd_tc, "fwd_tc");
6331 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_tcmask =
6332 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6333 : : tc_mask, RTE_UINT8);
6334 : :
6335 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc = {
6336 : : .f = cmd_set_dcb_fwd_tc_parsed,
6337 : : .data = NULL,
6338 : : .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.",
6339 : : .tokens = {
6340 : : (void *)&cmd_set_dcb_fwd_tc_set,
6341 : : (void *)&cmd_set_dcb_fwd_tc_dcb,
6342 : : (void *)&cmd_set_dcb_fwd_tc_fwdtc,
6343 : : (void *)&cmd_set_dcb_fwd_tc_tcmask,
6344 : : NULL,
6345 : : },
6346 : : };
6347 : :
6348 : : /* *** set DCB forward cores per TC *** */
6349 : : struct cmd_set_dcb_fwd_tc_cores_result {
6350 : : cmdline_fixed_string_t set;
6351 : : cmdline_fixed_string_t dcb;
6352 : : cmdline_fixed_string_t fwd_tc_cores;
6353 : : uint8_t tc_cores;
6354 : : };
6355 : :
6356 : 0 : static void cmd_set_dcb_fwd_tc_cores_parsed(void *parsed_result,
6357 : : __rte_unused struct cmdline *cl,
6358 : : __rte_unused void *data)
6359 : : {
6360 : : struct cmd_set_dcb_fwd_tc_cores_result *res = parsed_result;
6361 : 0 : if (test_done == 0) {
6362 : 0 : fprintf(stderr, "Please stop forwarding first\n");
6363 : 0 : return;
6364 : : }
6365 : 0 : if (res->tc_cores == 0) {
6366 : 0 : fprintf(stderr, "Cores per-TC should not be zero!\n");
6367 : 0 : return;
6368 : : }
6369 : 0 : dcb_fwd_tc_cores = res->tc_cores;
6370 : 0 : printf("Set cores-per-TC: %u\n", dcb_fwd_tc_cores);
6371 : : }
6372 : :
6373 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_set =
6374 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6375 : : set, "set");
6376 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_dcb =
6377 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6378 : : dcb, "dcb");
6379 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_fwdtccores =
6380 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6381 : : fwd_tc_cores, "fwd_tc_cores");
6382 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_cores_tccores =
6383 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6384 : : tc_cores, RTE_UINT8);
6385 : :
6386 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc_cores = {
6387 : : .f = cmd_set_dcb_fwd_tc_cores_parsed,
6388 : : .data = NULL,
6389 : : .help_str = "config DCB forwarding cores per-TC, 1-means one core process all queues of a TC.",
6390 : : .tokens = {
6391 : : (void *)&cmd_set_dcb_fwd_tc_cores_set,
6392 : : (void *)&cmd_set_dcb_fwd_tc_cores_dcb,
6393 : : (void *)&cmd_set_dcb_fwd_tc_cores_fwdtccores,
6394 : : (void *)&cmd_set_dcb_fwd_tc_cores_tccores,
6395 : : NULL,
6396 : : },
6397 : : };
6398 : :
6399 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6400 : : struct cmd_set_burst_tx_retry_result {
6401 : : cmdline_fixed_string_t set;
6402 : : cmdline_fixed_string_t burst;
6403 : : cmdline_fixed_string_t tx;
6404 : : cmdline_fixed_string_t delay;
6405 : : uint32_t time;
6406 : : cmdline_fixed_string_t retry;
6407 : : uint32_t retry_num;
6408 : : };
6409 : :
6410 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6411 : : __rte_unused struct cmdline *cl,
6412 : : __rte_unused void *data)
6413 : : {
6414 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
6415 : :
6416 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6417 : 0 : && !strcmp(res->tx, "tx")) {
6418 : 0 : if (!strcmp(res->delay, "delay"))
6419 : 0 : burst_tx_delay_time = res->time;
6420 : 0 : if (!strcmp(res->retry, "retry"))
6421 : 0 : burst_tx_retry_num = res->retry_num;
6422 : : }
6423 : :
6424 : 0 : }
6425 : :
6426 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6427 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6428 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6429 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6430 : : "burst");
6431 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6432 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6433 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6434 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6435 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6436 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6437 : : RTE_UINT32);
6438 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6439 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6440 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6441 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6442 : : RTE_UINT32);
6443 : :
6444 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6445 : : .f = cmd_set_burst_tx_retry_parsed,
6446 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6447 : : .tokens = {
6448 : : (void *)&cmd_set_burst_tx_retry_set,
6449 : : (void *)&cmd_set_burst_tx_retry_burst,
6450 : : (void *)&cmd_set_burst_tx_retry_tx,
6451 : : (void *)&cmd_set_burst_tx_retry_delay,
6452 : : (void *)&cmd_set_burst_tx_retry_time,
6453 : : (void *)&cmd_set_burst_tx_retry_retry,
6454 : : (void *)&cmd_set_burst_tx_retry_retry_num,
6455 : : NULL,
6456 : : },
6457 : : };
6458 : :
6459 : : /* *** SET PROMISC MODE *** */
6460 : : struct cmd_set_promisc_mode_result {
6461 : : cmdline_fixed_string_t set;
6462 : : cmdline_fixed_string_t promisc;
6463 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6464 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6465 : : cmdline_fixed_string_t mode;
6466 : : };
6467 : :
6468 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
6469 : : __rte_unused struct cmdline *cl,
6470 : : void *allports)
6471 : : {
6472 : : struct cmd_set_promisc_mode_result *res = parsed_result;
6473 : : int enable;
6474 : : portid_t i;
6475 : :
6476 : 0 : if (!strcmp(res->mode, "on"))
6477 : : enable = 1;
6478 : : else
6479 : : enable = 0;
6480 : :
6481 : : /* all ports */
6482 : 0 : if (allports) {
6483 : 0 : RTE_ETH_FOREACH_DEV(i)
6484 : 0 : eth_set_promisc_mode(i, enable);
6485 : : } else {
6486 : 0 : eth_set_promisc_mode(res->port_num, enable);
6487 : : }
6488 : 0 : }
6489 : :
6490 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
6491 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6492 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
6493 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6494 : : "promisc");
6495 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
6496 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6497 : : "all");
6498 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
6499 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6500 : : RTE_UINT16);
6501 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
6502 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6503 : : "on#off");
6504 : :
6505 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6506 : : .f = cmd_set_promisc_mode_parsed,
6507 : : .data = (void *)1,
6508 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
6509 : : .tokens = {
6510 : : (void *)&cmd_setpromisc_set,
6511 : : (void *)&cmd_setpromisc_promisc,
6512 : : (void *)&cmd_setpromisc_portall,
6513 : : (void *)&cmd_setpromisc_mode,
6514 : : NULL,
6515 : : },
6516 : : };
6517 : :
6518 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6519 : : .f = cmd_set_promisc_mode_parsed,
6520 : : .data = (void *)0,
6521 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6522 : : .tokens = {
6523 : : (void *)&cmd_setpromisc_set,
6524 : : (void *)&cmd_setpromisc_promisc,
6525 : : (void *)&cmd_setpromisc_portnum,
6526 : : (void *)&cmd_setpromisc_mode,
6527 : : NULL,
6528 : : },
6529 : : };
6530 : :
6531 : : /* *** SET ALLMULTI MODE *** */
6532 : : struct cmd_set_allmulti_mode_result {
6533 : : cmdline_fixed_string_t set;
6534 : : cmdline_fixed_string_t allmulti;
6535 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6536 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6537 : : cmdline_fixed_string_t mode;
6538 : : };
6539 : :
6540 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6541 : : __rte_unused struct cmdline *cl,
6542 : : void *allports)
6543 : : {
6544 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
6545 : : int enable;
6546 : : portid_t i;
6547 : :
6548 : 0 : if (!strcmp(res->mode, "on"))
6549 : : enable = 1;
6550 : : else
6551 : : enable = 0;
6552 : :
6553 : : /* all ports */
6554 : 0 : if (allports) {
6555 : 0 : RTE_ETH_FOREACH_DEV(i) {
6556 : 0 : eth_set_allmulticast_mode(i, enable);
6557 : : }
6558 : : }
6559 : : else {
6560 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
6561 : : }
6562 : 0 : }
6563 : :
6564 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
6565 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6566 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6567 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6568 : : "allmulti");
6569 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
6570 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6571 : : "all");
6572 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
6573 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6574 : : RTE_UINT16);
6575 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
6576 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6577 : : "on#off");
6578 : :
6579 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6580 : : .f = cmd_set_allmulti_mode_parsed,
6581 : : .data = (void *)1,
6582 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6583 : : .tokens = {
6584 : : (void *)&cmd_setallmulti_set,
6585 : : (void *)&cmd_setallmulti_allmulti,
6586 : : (void *)&cmd_setallmulti_portall,
6587 : : (void *)&cmd_setallmulti_mode,
6588 : : NULL,
6589 : : },
6590 : : };
6591 : :
6592 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6593 : : .f = cmd_set_allmulti_mode_parsed,
6594 : : .data = (void *)0,
6595 : : .help_str = "set allmulti <port_id> on|off: "
6596 : : "Set allmulti mode on port_id",
6597 : : .tokens = {
6598 : : (void *)&cmd_setallmulti_set,
6599 : : (void *)&cmd_setallmulti_allmulti,
6600 : : (void *)&cmd_setallmulti_portnum,
6601 : : (void *)&cmd_setallmulti_mode,
6602 : : NULL,
6603 : : },
6604 : : };
6605 : :
6606 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6607 : : struct cmd_link_flow_ctrl_show {
6608 : : cmdline_fixed_string_t show;
6609 : : cmdline_fixed_string_t port;
6610 : : portid_t port_id;
6611 : : cmdline_fixed_string_t flow_ctrl;
6612 : : };
6613 : :
6614 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6615 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6616 : : show, "show");
6617 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6618 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6619 : : port, "port");
6620 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6621 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6622 : : port_id, RTE_UINT16);
6623 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6624 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6625 : : flow_ctrl, "flow_ctrl");
6626 : :
6627 : : static void
6628 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6629 : : __rte_unused struct cmdline *cl,
6630 : : __rte_unused void *data)
6631 : : {
6632 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6633 : : static const char *info_border = "*********************";
6634 : : struct rte_eth_fc_conf fc_conf;
6635 : : bool rx_fc_en = false;
6636 : : bool tx_fc_en = false;
6637 : : int ret;
6638 : :
6639 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6640 : 0 : if (ret != 0) {
6641 : 0 : fprintf(stderr,
6642 : : "Failed to get current flow ctrl information: err = %d\n",
6643 : : ret);
6644 : 0 : return;
6645 : : }
6646 : :
6647 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6648 : : rx_fc_en = true;
6649 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6650 : : tx_fc_en = true;
6651 : :
6652 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6653 : 0 : info_border, res->port_id, info_border);
6654 : : printf("FC mode:\n");
6655 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6656 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6657 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6658 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6659 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6660 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6661 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6662 : 0 : printf("Forward MAC control frames: %s\n",
6663 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6664 : 0 : printf("\n%s************** End ***********%s\n",
6665 : : info_border, info_border);
6666 : : }
6667 : :
6668 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6669 : : .f = cmd_link_flow_ctrl_show_parsed,
6670 : : .data = NULL,
6671 : : .help_str = "show port <port_id> flow_ctrl",
6672 : : .tokens = {
6673 : : (void *)&cmd_lfc_show_show,
6674 : : (void *)&cmd_lfc_show_port,
6675 : : (void *)&cmd_lfc_show_portid,
6676 : : (void *)&cmd_lfc_show_flow_ctrl,
6677 : : NULL,
6678 : : },
6679 : : };
6680 : :
6681 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6682 : : struct cmd_link_flow_ctrl_set_result {
6683 : : cmdline_fixed_string_t set;
6684 : : cmdline_fixed_string_t flow_ctrl;
6685 : : cmdline_fixed_string_t rx;
6686 : : cmdline_fixed_string_t rx_lfc_mode;
6687 : : cmdline_fixed_string_t tx;
6688 : : cmdline_fixed_string_t tx_lfc_mode;
6689 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6690 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6691 : : cmdline_fixed_string_t autoneg_str;
6692 : : cmdline_fixed_string_t autoneg;
6693 : : cmdline_fixed_string_t hw_str;
6694 : : uint32_t high_water;
6695 : : cmdline_fixed_string_t lw_str;
6696 : : uint32_t low_water;
6697 : : cmdline_fixed_string_t pt_str;
6698 : : uint16_t pause_time;
6699 : : cmdline_fixed_string_t xon_str;
6700 : : uint16_t send_xon;
6701 : : portid_t port_id;
6702 : : };
6703 : :
6704 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6705 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6706 : : set, "set");
6707 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6708 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6709 : : flow_ctrl, "flow_ctrl");
6710 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6711 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6712 : : rx, "rx");
6713 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6714 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6715 : : rx_lfc_mode, "on#off");
6716 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6717 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6718 : : tx, "tx");
6719 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6720 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6721 : : tx_lfc_mode, "on#off");
6722 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6723 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6724 : : hw_str, "high_water");
6725 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6726 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6727 : : high_water, RTE_UINT32);
6728 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6729 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6730 : : lw_str, "low_water");
6731 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6732 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6733 : : low_water, RTE_UINT32);
6734 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6735 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6736 : : pt_str, "pause_time");
6737 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6738 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6739 : : pause_time, RTE_UINT16);
6740 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6741 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6742 : : xon_str, "send_xon");
6743 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6744 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6745 : : send_xon, RTE_UINT16);
6746 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6747 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6748 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6749 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6750 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6751 : : mac_ctrl_frame_fwd_mode, "on#off");
6752 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6753 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6754 : : autoneg_str, "autoneg");
6755 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6756 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6757 : : autoneg, "on#off");
6758 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6759 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6760 : : port_id, RTE_UINT16);
6761 : :
6762 : : /* forward declaration */
6763 : : static void
6764 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6765 : : void *data);
6766 : :
6767 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6768 : : .f = cmd_link_flow_ctrl_set_parsed,
6769 : : .data = NULL,
6770 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6771 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6772 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6773 : : .tokens = {
6774 : : (void *)&cmd_lfc_set_set,
6775 : : (void *)&cmd_lfc_set_flow_ctrl,
6776 : : (void *)&cmd_lfc_set_rx,
6777 : : (void *)&cmd_lfc_set_rx_mode,
6778 : : (void *)&cmd_lfc_set_tx,
6779 : : (void *)&cmd_lfc_set_tx_mode,
6780 : : (void *)&cmd_lfc_set_high_water,
6781 : : (void *)&cmd_lfc_set_low_water,
6782 : : (void *)&cmd_lfc_set_pause_time,
6783 : : (void *)&cmd_lfc_set_send_xon,
6784 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6785 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6786 : : (void *)&cmd_lfc_set_autoneg_str,
6787 : : (void *)&cmd_lfc_set_autoneg,
6788 : : (void *)&cmd_lfc_set_portid,
6789 : : NULL,
6790 : : },
6791 : : };
6792 : :
6793 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6794 : : .f = cmd_link_flow_ctrl_set_parsed,
6795 : : .data = (void *)&cmd_link_flow_control_set_rx,
6796 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6797 : : "Change rx flow control parameter",
6798 : : .tokens = {
6799 : : (void *)&cmd_lfc_set_set,
6800 : : (void *)&cmd_lfc_set_flow_ctrl,
6801 : : (void *)&cmd_lfc_set_rx,
6802 : : (void *)&cmd_lfc_set_rx_mode,
6803 : : (void *)&cmd_lfc_set_portid,
6804 : : NULL,
6805 : : },
6806 : : };
6807 : :
6808 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6809 : : .f = cmd_link_flow_ctrl_set_parsed,
6810 : : .data = (void *)&cmd_link_flow_control_set_tx,
6811 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6812 : : "Change tx flow control parameter",
6813 : : .tokens = {
6814 : : (void *)&cmd_lfc_set_set,
6815 : : (void *)&cmd_lfc_set_flow_ctrl,
6816 : : (void *)&cmd_lfc_set_tx,
6817 : : (void *)&cmd_lfc_set_tx_mode,
6818 : : (void *)&cmd_lfc_set_portid,
6819 : : NULL,
6820 : : },
6821 : : };
6822 : :
6823 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6824 : : .f = cmd_link_flow_ctrl_set_parsed,
6825 : : .data = (void *)&cmd_link_flow_control_set_hw,
6826 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6827 : : "Change high water flow control parameter",
6828 : : .tokens = {
6829 : : (void *)&cmd_lfc_set_set,
6830 : : (void *)&cmd_lfc_set_flow_ctrl,
6831 : : (void *)&cmd_lfc_set_high_water_str,
6832 : : (void *)&cmd_lfc_set_high_water,
6833 : : (void *)&cmd_lfc_set_portid,
6834 : : NULL,
6835 : : },
6836 : : };
6837 : :
6838 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6839 : : .f = cmd_link_flow_ctrl_set_parsed,
6840 : : .data = (void *)&cmd_link_flow_control_set_lw,
6841 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6842 : : "Change low water flow control parameter",
6843 : : .tokens = {
6844 : : (void *)&cmd_lfc_set_set,
6845 : : (void *)&cmd_lfc_set_flow_ctrl,
6846 : : (void *)&cmd_lfc_set_low_water_str,
6847 : : (void *)&cmd_lfc_set_low_water,
6848 : : (void *)&cmd_lfc_set_portid,
6849 : : NULL,
6850 : : },
6851 : : };
6852 : :
6853 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6854 : : .f = cmd_link_flow_ctrl_set_parsed,
6855 : : .data = (void *)&cmd_link_flow_control_set_pt,
6856 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6857 : : "Change pause time flow control parameter",
6858 : : .tokens = {
6859 : : (void *)&cmd_lfc_set_set,
6860 : : (void *)&cmd_lfc_set_flow_ctrl,
6861 : : (void *)&cmd_lfc_set_pause_time_str,
6862 : : (void *)&cmd_lfc_set_pause_time,
6863 : : (void *)&cmd_lfc_set_portid,
6864 : : NULL,
6865 : : },
6866 : : };
6867 : :
6868 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6869 : : .f = cmd_link_flow_ctrl_set_parsed,
6870 : : .data = (void *)&cmd_link_flow_control_set_xon,
6871 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6872 : : "Change send_xon flow control parameter",
6873 : : .tokens = {
6874 : : (void *)&cmd_lfc_set_set,
6875 : : (void *)&cmd_lfc_set_flow_ctrl,
6876 : : (void *)&cmd_lfc_set_send_xon_str,
6877 : : (void *)&cmd_lfc_set_send_xon,
6878 : : (void *)&cmd_lfc_set_portid,
6879 : : NULL,
6880 : : },
6881 : : };
6882 : :
6883 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6884 : : .f = cmd_link_flow_ctrl_set_parsed,
6885 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6886 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6887 : : "Change mac ctrl fwd flow control parameter",
6888 : : .tokens = {
6889 : : (void *)&cmd_lfc_set_set,
6890 : : (void *)&cmd_lfc_set_flow_ctrl,
6891 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6892 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6893 : : (void *)&cmd_lfc_set_portid,
6894 : : NULL,
6895 : : },
6896 : : };
6897 : :
6898 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6899 : : .f = cmd_link_flow_ctrl_set_parsed,
6900 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6901 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6902 : : "Change autoneg flow control parameter",
6903 : : .tokens = {
6904 : : (void *)&cmd_lfc_set_set,
6905 : : (void *)&cmd_lfc_set_flow_ctrl,
6906 : : (void *)&cmd_lfc_set_autoneg_str,
6907 : : (void *)&cmd_lfc_set_autoneg,
6908 : : (void *)&cmd_lfc_set_portid,
6909 : : NULL,
6910 : : },
6911 : : };
6912 : :
6913 : : static void
6914 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6915 : : __rte_unused struct cmdline *cl,
6916 : : void *data)
6917 : : {
6918 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6919 : : cmdline_parse_inst_t *cmd = data;
6920 : : struct rte_eth_fc_conf fc_conf;
6921 : : int rx_fc_en = 0;
6922 : : int tx_fc_en = 0;
6923 : : int ret;
6924 : :
6925 : : /*
6926 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6927 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6928 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6929 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6930 : : */
6931 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6932 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6933 : : };
6934 : :
6935 : : /* Partial command line, retrieve current configuration */
6936 : 0 : if (cmd) {
6937 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6938 : 0 : if (ret != 0) {
6939 : 0 : fprintf(stderr,
6940 : : "cannot get current flow ctrl parameters, return code = %d\n",
6941 : : ret);
6942 : 0 : return;
6943 : : }
6944 : :
6945 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6946 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6947 : : rx_fc_en = 1;
6948 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6949 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6950 : : tx_fc_en = 1;
6951 : : }
6952 : :
6953 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6954 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6955 : :
6956 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6957 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6958 : :
6959 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6960 : :
6961 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6962 : 0 : fc_conf.high_water = res->high_water;
6963 : :
6964 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6965 : 0 : fc_conf.low_water = res->low_water;
6966 : :
6967 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6968 : 0 : fc_conf.pause_time = res->pause_time;
6969 : :
6970 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6971 : 0 : fc_conf.send_xon = res->send_xon;
6972 : :
6973 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6974 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6975 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6976 : : else
6977 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6978 : : }
6979 : :
6980 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6981 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6982 : :
6983 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6984 : 0 : if (ret != 0)
6985 : 0 : fprintf(stderr,
6986 : : "bad flow control parameter, return code = %d\n",
6987 : : ret);
6988 : : }
6989 : :
6990 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6991 : : struct cmd_priority_flow_ctrl_set_result {
6992 : : cmdline_fixed_string_t set;
6993 : : cmdline_fixed_string_t pfc_ctrl;
6994 : : cmdline_fixed_string_t rx;
6995 : : cmdline_fixed_string_t rx_pfc_mode;
6996 : : cmdline_fixed_string_t tx;
6997 : : cmdline_fixed_string_t tx_pfc_mode;
6998 : : uint32_t high_water;
6999 : : uint32_t low_water;
7000 : : uint16_t pause_time;
7001 : : uint8_t priority;
7002 : : portid_t port_id;
7003 : : };
7004 : :
7005 : : static void
7006 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
7007 : : __rte_unused struct cmdline *cl,
7008 : : __rte_unused void *data)
7009 : : {
7010 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
7011 : : struct rte_eth_pfc_conf pfc_conf;
7012 : : int rx_fc_enable, tx_fc_enable;
7013 : : int ret;
7014 : :
7015 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
7016 : 0 : return;
7017 : :
7018 : : /*
7019 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
7020 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
7021 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
7022 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
7023 : : */
7024 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
7025 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7026 : : };
7027 : :
7028 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
7029 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
7030 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
7031 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
7032 : 0 : pfc_conf.fc.high_water = res->high_water;
7033 : 0 : pfc_conf.fc.low_water = res->low_water;
7034 : 0 : pfc_conf.fc.pause_time = res->pause_time;
7035 : 0 : pfc_conf.priority = res->priority;
7036 : :
7037 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
7038 : 0 : if (ret != 0)
7039 : 0 : fprintf(stderr,
7040 : : "bad priority flow control parameter, return code = %d\n",
7041 : : ret);
7042 : : }
7043 : :
7044 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
7045 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7046 : : set, "set");
7047 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
7048 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7049 : : pfc_ctrl, "pfc_ctrl");
7050 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
7051 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7052 : : rx, "rx");
7053 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
7054 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7055 : : rx_pfc_mode, "on#off");
7056 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
7057 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7058 : : tx, "tx");
7059 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
7060 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7061 : : tx_pfc_mode, "on#off");
7062 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
7063 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7064 : : high_water, RTE_UINT32);
7065 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
7066 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7067 : : low_water, RTE_UINT32);
7068 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7069 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7070 : : pause_time, RTE_UINT16);
7071 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
7072 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7073 : : priority, RTE_UINT8);
7074 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
7075 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7076 : : port_id, RTE_UINT16);
7077 : :
7078 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
7079 : : .f = cmd_priority_flow_ctrl_set_parsed,
7080 : : .data = NULL,
7081 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7082 : : "<pause_time> <priority> <port_id>: "
7083 : : "Configure the Ethernet priority flow control",
7084 : : .tokens = {
7085 : : (void *)&cmd_pfc_set_set,
7086 : : (void *)&cmd_pfc_set_flow_ctrl,
7087 : : (void *)&cmd_pfc_set_rx,
7088 : : (void *)&cmd_pfc_set_rx_mode,
7089 : : (void *)&cmd_pfc_set_tx,
7090 : : (void *)&cmd_pfc_set_tx_mode,
7091 : : (void *)&cmd_pfc_set_high_water,
7092 : : (void *)&cmd_pfc_set_low_water,
7093 : : (void *)&cmd_pfc_set_pause_time,
7094 : : (void *)&cmd_pfc_set_priority,
7095 : : (void *)&cmd_pfc_set_portid,
7096 : : NULL,
7097 : : },
7098 : : };
7099 : :
7100 : : struct cmd_queue_priority_flow_ctrl_set_result {
7101 : : cmdline_fixed_string_t set;
7102 : : cmdline_fixed_string_t pfc_queue_ctrl;
7103 : : portid_t port_id;
7104 : : cmdline_fixed_string_t rx;
7105 : : cmdline_fixed_string_t rx_pfc_mode;
7106 : : uint16_t tx_qid;
7107 : : uint8_t tx_tc;
7108 : : cmdline_fixed_string_t tx;
7109 : : cmdline_fixed_string_t tx_pfc_mode;
7110 : : uint16_t rx_qid;
7111 : : uint8_t rx_tc;
7112 : : uint16_t pause_time;
7113 : : };
7114 : :
7115 : : static void
7116 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7117 : : __rte_unused struct cmdline *cl,
7118 : : __rte_unused void *data)
7119 : : {
7120 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7121 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
7122 : : int rx_fc_enable, tx_fc_enable;
7123 : : int ret;
7124 : :
7125 : : /*
7126 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
7127 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7128 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
7129 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7130 : : * the Tx side.
7131 : : */
7132 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7133 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7134 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7135 : : };
7136 : :
7137 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7138 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7139 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7140 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7141 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
7142 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7143 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
7144 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7145 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7146 : :
7147 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7148 : : &pfc_queue_conf);
7149 : 0 : if (ret != 0) {
7150 : 0 : fprintf(stderr,
7151 : : "bad queue priority flow control parameter, rc = %d\n",
7152 : : ret);
7153 : : }
7154 : 0 : }
7155 : :
7156 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
7157 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7158 : : set, "set");
7159 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7160 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7161 : : pfc_queue_ctrl, "pfc_queue_ctrl");
7162 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7163 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7164 : : port_id, RTE_UINT16);
7165 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7166 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7167 : : rx, "rx");
7168 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7169 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7170 : : rx_pfc_mode, "on#off");
7171 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7172 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7173 : : tx_qid, RTE_UINT16);
7174 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7175 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7176 : : tx_tc, RTE_UINT8);
7177 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7178 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7179 : : tx, "tx");
7180 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7181 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7182 : : tx_pfc_mode, "on#off");
7183 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7184 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7185 : : rx_qid, RTE_UINT16);
7186 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7187 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7188 : : rx_tc, RTE_UINT8);
7189 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7190 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7191 : : pause_time, RTE_UINT16);
7192 : :
7193 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7194 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
7195 : : .data = NULL,
7196 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7197 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7198 : : "Configure the Ethernet queue priority flow control",
7199 : : .tokens = {
7200 : : (void *)&cmd_q_pfc_set_set,
7201 : : (void *)&cmd_q_pfc_set_flow_ctrl,
7202 : : (void *)&cmd_q_pfc_set_portid,
7203 : : (void *)&cmd_q_pfc_set_rx,
7204 : : (void *)&cmd_q_pfc_set_rx_mode,
7205 : : (void *)&cmd_q_pfc_set_tx_qid,
7206 : : (void *)&cmd_q_pfc_set_tx_tc,
7207 : : (void *)&cmd_q_pfc_set_tx,
7208 : : (void *)&cmd_q_pfc_set_tx_mode,
7209 : : (void *)&cmd_q_pfc_set_rx_qid,
7210 : : (void *)&cmd_q_pfc_set_rx_tc,
7211 : : (void *)&cmd_q_pfc_set_pause_time,
7212 : : NULL,
7213 : : },
7214 : : };
7215 : :
7216 : : /* *** RESET CONFIGURATION *** */
7217 : : struct cmd_reset_result {
7218 : : cmdline_fixed_string_t reset;
7219 : : cmdline_fixed_string_t def;
7220 : : };
7221 : :
7222 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
7223 : : struct cmdline *cl,
7224 : : __rte_unused void *data)
7225 : : {
7226 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7227 : 0 : set_def_fwd_config();
7228 : 0 : }
7229 : :
7230 : : static cmdline_parse_token_string_t cmd_reset_set =
7231 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7232 : : static cmdline_parse_token_string_t cmd_reset_def =
7233 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7234 : : "default");
7235 : :
7236 : : static cmdline_parse_inst_t cmd_reset = {
7237 : : .f = cmd_reset_parsed,
7238 : : .data = NULL,
7239 : : .help_str = "set default: Reset default forwarding configuration",
7240 : : .tokens = {
7241 : : (void *)&cmd_reset_set,
7242 : : (void *)&cmd_reset_def,
7243 : : NULL,
7244 : : },
7245 : : };
7246 : :
7247 : : /* *** START FORWARDING *** */
7248 : : struct cmd_start_result {
7249 : : cmdline_fixed_string_t start;
7250 : : };
7251 : :
7252 : : static cmdline_parse_token_string_t cmd_start_start =
7253 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7254 : :
7255 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
7256 : : __rte_unused struct cmdline *cl,
7257 : : __rte_unused void *data)
7258 : : {
7259 : 0 : start_packet_forwarding(0);
7260 : 0 : }
7261 : :
7262 : : static cmdline_parse_inst_t cmd_start = {
7263 : : .f = cmd_start_parsed,
7264 : : .data = NULL,
7265 : : .help_str = "start: Start packet forwarding",
7266 : : .tokens = {
7267 : : (void *)&cmd_start_start,
7268 : : NULL,
7269 : : },
7270 : : };
7271 : :
7272 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7273 : : struct cmd_start_tx_first_result {
7274 : : cmdline_fixed_string_t start;
7275 : : cmdline_fixed_string_t tx_first;
7276 : : };
7277 : :
7278 : : static void
7279 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7280 : : __rte_unused struct cmdline *cl,
7281 : : __rte_unused void *data)
7282 : : {
7283 : 0 : start_packet_forwarding(1);
7284 : 0 : }
7285 : :
7286 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
7287 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7288 : : "start");
7289 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7290 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7291 : : tx_first, "tx_first");
7292 : :
7293 : : static cmdline_parse_inst_t cmd_start_tx_first = {
7294 : : .f = cmd_start_tx_first_parsed,
7295 : : .data = NULL,
7296 : : .help_str = "start tx_first: Start packet forwarding, "
7297 : : "after sending 1 burst of packets",
7298 : : .tokens = {
7299 : : (void *)&cmd_start_tx_first_start,
7300 : : (void *)&cmd_start_tx_first_tx_first,
7301 : : NULL,
7302 : : },
7303 : : };
7304 : :
7305 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
7306 : : struct cmd_start_tx_first_n_result {
7307 : : cmdline_fixed_string_t start;
7308 : : cmdline_fixed_string_t tx_first;
7309 : : uint32_t tx_num;
7310 : : };
7311 : :
7312 : : static void
7313 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
7314 : : __rte_unused struct cmdline *cl,
7315 : : __rte_unused void *data)
7316 : : {
7317 : : struct cmd_start_tx_first_n_result *res = parsed_result;
7318 : :
7319 : 0 : start_packet_forwarding(res->tx_num);
7320 : 0 : }
7321 : :
7322 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7323 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7324 : : start, "start");
7325 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7326 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7327 : : tx_first, "tx_first");
7328 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7329 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7330 : : tx_num, RTE_UINT32);
7331 : :
7332 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
7333 : : .f = cmd_start_tx_first_n_parsed,
7334 : : .data = NULL,
7335 : : .help_str = "start tx_first <num>: "
7336 : : "packet forwarding, after sending <num> bursts of packets",
7337 : : .tokens = {
7338 : : (void *)&cmd_start_tx_first_n_start,
7339 : : (void *)&cmd_start_tx_first_n_tx_first,
7340 : : (void *)&cmd_start_tx_first_n_tx_num,
7341 : : NULL,
7342 : : },
7343 : : };
7344 : :
7345 : : /* *** SET LINK UP *** */
7346 : : struct cmd_set_link_up_result {
7347 : : cmdline_fixed_string_t set;
7348 : : cmdline_fixed_string_t link_up;
7349 : : cmdline_fixed_string_t port;
7350 : : portid_t port_id;
7351 : : };
7352 : :
7353 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
7354 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7355 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7356 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7357 : : "link-up");
7358 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
7359 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7360 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7361 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7362 : : RTE_UINT16);
7363 : :
7364 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7365 : : __rte_unused struct cmdline *cl,
7366 : : __rte_unused void *data)
7367 : : {
7368 : : struct cmd_set_link_up_result *res = parsed_result;
7369 : 0 : dev_set_link_up(res->port_id);
7370 : 0 : }
7371 : :
7372 : : static cmdline_parse_inst_t cmd_set_link_up = {
7373 : : .f = cmd_set_link_up_parsed,
7374 : : .data = NULL,
7375 : : .help_str = "set link-up port <port id>",
7376 : : .tokens = {
7377 : : (void *)&cmd_set_link_up_set,
7378 : : (void *)&cmd_set_link_up_link_up,
7379 : : (void *)&cmd_set_link_up_port,
7380 : : (void *)&cmd_set_link_up_port_id,
7381 : : NULL,
7382 : : },
7383 : : };
7384 : :
7385 : : /* *** SET LINK DOWN *** */
7386 : : struct cmd_set_link_down_result {
7387 : : cmdline_fixed_string_t set;
7388 : : cmdline_fixed_string_t link_down;
7389 : : cmdline_fixed_string_t port;
7390 : : portid_t port_id;
7391 : : };
7392 : :
7393 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
7394 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7395 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
7396 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7397 : : "link-down");
7398 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
7399 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7400 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
7401 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7402 : : RTE_UINT16);
7403 : :
7404 : 0 : static void cmd_set_link_down_parsed(
7405 : : __rte_unused void *parsed_result,
7406 : : __rte_unused struct cmdline *cl,
7407 : : __rte_unused void *data)
7408 : : {
7409 : : struct cmd_set_link_down_result *res = parsed_result;
7410 : 0 : dev_set_link_down(res->port_id);
7411 : 0 : }
7412 : :
7413 : : static cmdline_parse_inst_t cmd_set_link_down = {
7414 : : .f = cmd_set_link_down_parsed,
7415 : : .data = NULL,
7416 : : .help_str = "set link-down port <port id>",
7417 : : .tokens = {
7418 : : (void *)&cmd_set_link_down_set,
7419 : : (void *)&cmd_set_link_down_link_down,
7420 : : (void *)&cmd_set_link_down_port,
7421 : : (void *)&cmd_set_link_down_port_id,
7422 : : NULL,
7423 : : },
7424 : : };
7425 : :
7426 : : /* *** SHOW CFG *** */
7427 : : struct cmd_showcfg_result {
7428 : : cmdline_fixed_string_t show;
7429 : : cmdline_fixed_string_t cfg;
7430 : : cmdline_fixed_string_t what;
7431 : : };
7432 : :
7433 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
7434 : : __rte_unused struct cmdline *cl,
7435 : : __rte_unused void *data)
7436 : : {
7437 : : struct cmd_showcfg_result *res = parsed_result;
7438 : 0 : if (!strcmp(res->what, "rxtx"))
7439 : 0 : rxtx_config_display();
7440 : 0 : else if (!strcmp(res->what, "cores"))
7441 : 0 : fwd_lcores_config_display();
7442 : 0 : else if (!strcmp(res->what, "fwd"))
7443 : 0 : pkt_fwd_config_display(&cur_fwd_config);
7444 : 0 : else if (!strcmp(res->what, "rxoffs"))
7445 : 0 : show_rx_pkt_offsets();
7446 : 0 : else if (!strcmp(res->what, "rxpkts"))
7447 : 0 : show_rx_pkt_segments();
7448 : 0 : else if (!strcmp(res->what, "rxhdrs"))
7449 : 0 : show_rx_pkt_hdrs();
7450 : 0 : else if (!strcmp(res->what, "txpkts"))
7451 : 0 : show_tx_pkt_segments();
7452 : 0 : else if (!strcmp(res->what, "txtimes"))
7453 : 0 : show_tx_pkt_times();
7454 : 0 : else if (!strcmp(res->what, "dcbfwdtc"))
7455 : 0 : show_dcb_fwd_tc_config();
7456 : 0 : }
7457 : :
7458 : : static cmdline_parse_token_string_t cmd_showcfg_show =
7459 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7460 : : static cmdline_parse_token_string_t cmd_showcfg_port =
7461 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7462 : : static cmdline_parse_token_string_t cmd_showcfg_what =
7463 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7464 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes#dcbfwdtc");
7465 : :
7466 : : static cmdline_parse_inst_t cmd_showcfg = {
7467 : : .f = cmd_showcfg_parsed,
7468 : : .data = NULL,
7469 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes|dcbfwdtc",
7470 : : .tokens = {
7471 : : (void *)&cmd_showcfg_show,
7472 : : (void *)&cmd_showcfg_port,
7473 : : (void *)&cmd_showcfg_what,
7474 : : NULL,
7475 : : },
7476 : : };
7477 : :
7478 : : /* *** SHOW ALL PORT INFO *** */
7479 : : struct cmd_showportall_result {
7480 : : cmdline_fixed_string_t show;
7481 : : cmdline_fixed_string_t port;
7482 : : cmdline_fixed_string_t what;
7483 : : cmdline_fixed_string_t all;
7484 : : };
7485 : :
7486 : 0 : static void cmd_showportall_parsed(void *parsed_result,
7487 : : __rte_unused struct cmdline *cl,
7488 : : __rte_unused void *data)
7489 : : {
7490 : : portid_t i;
7491 : :
7492 : : struct cmd_showportall_result *res = parsed_result;
7493 : 0 : if (!strcmp(res->show, "clear")) {
7494 : 0 : if (!strcmp(res->what, "stats"))
7495 : 0 : RTE_ETH_FOREACH_DEV(i)
7496 : 0 : nic_stats_clear(i);
7497 : 0 : else if (!strcmp(res->what, "xstats"))
7498 : 0 : RTE_ETH_FOREACH_DEV(i)
7499 : 0 : nic_xstats_clear(i);
7500 : 0 : } else if (!strcmp(res->what, "info"))
7501 : 0 : RTE_ETH_FOREACH_DEV(i)
7502 : 0 : port_infos_display(i);
7503 : 0 : else if (!strcmp(res->what, "summary")) {
7504 : 0 : port_summary_header_display();
7505 : 0 : RTE_ETH_FOREACH_DEV(i)
7506 : 0 : port_summary_display(i);
7507 : : }
7508 : 0 : else if (!strcmp(res->what, "stats"))
7509 : 0 : RTE_ETH_FOREACH_DEV(i)
7510 : 0 : nic_stats_display(i);
7511 : 0 : else if (!strcmp(res->what, "xstats"))
7512 : 0 : RTE_ETH_FOREACH_DEV(i)
7513 : 0 : nic_xstats_display(i);
7514 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7515 : 0 : else if (!strcmp(res->what, "fdir"))
7516 : 0 : RTE_ETH_FOREACH_DEV(i)
7517 : 0 : fdir_get_infos(i);
7518 : : #endif
7519 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7520 : 0 : RTE_ETH_FOREACH_DEV(i)
7521 : 0 : port_dcb_info_display(i);
7522 : 0 : }
7523 : :
7524 : : static cmdline_parse_token_string_t cmd_showportall_show =
7525 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7526 : : "show#clear");
7527 : : static cmdline_parse_token_string_t cmd_showportall_port =
7528 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7529 : : static cmdline_parse_token_string_t cmd_showportall_what =
7530 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7531 : : "info#summary#stats#xstats#fdir#dcb_tc");
7532 : : static cmdline_parse_token_string_t cmd_showportall_all =
7533 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7534 : : static cmdline_parse_inst_t cmd_showportall = {
7535 : : .f = cmd_showportall_parsed,
7536 : : .data = NULL,
7537 : : .help_str = "show|clear port "
7538 : : "info|summary|stats|xstats|fdir|dcb_tc all",
7539 : : .tokens = {
7540 : : (void *)&cmd_showportall_show,
7541 : : (void *)&cmd_showportall_port,
7542 : : (void *)&cmd_showportall_what,
7543 : : (void *)&cmd_showportall_all,
7544 : : NULL,
7545 : : },
7546 : : };
7547 : :
7548 : : /* *** SHOW PORT INFO *** */
7549 : : struct cmd_showport_result {
7550 : : cmdline_fixed_string_t show;
7551 : : cmdline_fixed_string_t port;
7552 : : cmdline_fixed_string_t what;
7553 : : uint16_t portnum;
7554 : : };
7555 : :
7556 : 0 : static void cmd_showport_parsed(void *parsed_result,
7557 : : __rte_unused struct cmdline *cl,
7558 : : __rte_unused void *data)
7559 : : {
7560 : : struct cmd_showport_result *res = parsed_result;
7561 : 0 : if (!strcmp(res->show, "clear")) {
7562 : 0 : if (!strcmp(res->what, "stats"))
7563 : 0 : nic_stats_clear(res->portnum);
7564 : 0 : else if (!strcmp(res->what, "xstats"))
7565 : 0 : nic_xstats_clear(res->portnum);
7566 : 0 : } else if (!strcmp(res->what, "info"))
7567 : 0 : port_infos_display(res->portnum);
7568 : 0 : else if (!strcmp(res->what, "summary")) {
7569 : 0 : port_summary_header_display();
7570 : 0 : port_summary_display(res->portnum);
7571 : : }
7572 : 0 : else if (!strcmp(res->what, "stats"))
7573 : 0 : nic_stats_display(res->portnum);
7574 : 0 : else if (!strcmp(res->what, "xstats"))
7575 : 0 : nic_xstats_display(res->portnum);
7576 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7577 : 0 : else if (!strcmp(res->what, "fdir"))
7578 : 0 : fdir_get_infos(res->portnum);
7579 : : #endif
7580 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7581 : 0 : port_dcb_info_display(res->portnum);
7582 : 0 : }
7583 : :
7584 : : static cmdline_parse_token_string_t cmd_showport_show =
7585 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7586 : : "show#clear");
7587 : : static cmdline_parse_token_string_t cmd_showport_port =
7588 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7589 : : static cmdline_parse_token_string_t cmd_showport_what =
7590 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7591 : : "info#summary#stats#xstats#fdir#dcb_tc");
7592 : : static cmdline_parse_token_num_t cmd_showport_portnum =
7593 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7594 : :
7595 : : static cmdline_parse_inst_t cmd_showport = {
7596 : : .f = cmd_showport_parsed,
7597 : : .data = NULL,
7598 : : .help_str = "show|clear port "
7599 : : "info|summary|stats|xstats|fdir|dcb_tc "
7600 : : "<port_id>",
7601 : : .tokens = {
7602 : : (void *)&cmd_showport_show,
7603 : : (void *)&cmd_showport_port,
7604 : : (void *)&cmd_showport_what,
7605 : : (void *)&cmd_showport_portnum,
7606 : : NULL,
7607 : : },
7608 : : };
7609 : :
7610 : : /* *** show port representors information *** */
7611 : : struct cmd_representor_info_result {
7612 : : cmdline_fixed_string_t cmd_show;
7613 : : cmdline_fixed_string_t cmd_port;
7614 : : cmdline_fixed_string_t cmd_info;
7615 : : cmdline_fixed_string_t cmd_keyword;
7616 : : portid_t cmd_pid;
7617 : : };
7618 : :
7619 : : static void
7620 : 0 : cmd_representor_info_parsed(void *parsed_result,
7621 : : __rte_unused struct cmdline *cl,
7622 : : __rte_unused void *data)
7623 : : {
7624 : : struct cmd_representor_info_result *res = parsed_result;
7625 : : struct rte_eth_representor_info *info;
7626 : : struct rte_eth_representor_range *range;
7627 : : uint32_t range_diff;
7628 : : uint32_t i;
7629 : : int ret;
7630 : : int num;
7631 : :
7632 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7633 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7634 : 0 : return;
7635 : : }
7636 : :
7637 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7638 : 0 : if (ret < 0) {
7639 : 0 : fprintf(stderr,
7640 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7641 : 0 : res->cmd_pid, rte_strerror(-ret));
7642 : 0 : return;
7643 : : }
7644 : : num = ret;
7645 : :
7646 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7647 : 0 : if (info == NULL) {
7648 : 0 : fprintf(stderr,
7649 : : "Failed to allocate memory for representor info for port %hu\n",
7650 : 0 : res->cmd_pid);
7651 : 0 : return;
7652 : : }
7653 : 0 : info->nb_ranges_alloc = num;
7654 : :
7655 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7656 : 0 : if (ret < 0) {
7657 : 0 : fprintf(stderr,
7658 : : "Failed to get the representor info for port %hu: %s\n",
7659 : 0 : res->cmd_pid, rte_strerror(-ret));
7660 : 0 : free(info);
7661 : 0 : return;
7662 : : }
7663 : :
7664 : 0 : printf("Port controller: %hu\n", info->controller);
7665 : 0 : printf("Port PF: %hu\n", info->pf);
7666 : :
7667 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7668 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7669 : : range = &info->ranges[i];
7670 : 0 : range_diff = range->id_end - range->id_base;
7671 : :
7672 : 0 : printf("%u. ", i + 1);
7673 : 0 : printf("'%s' ", range->name);
7674 : 0 : if (range_diff > 0)
7675 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7676 : : else
7677 : 0 : printf("[%u]: ", range->id_base);
7678 : :
7679 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7680 : :
7681 : 0 : switch (range->type) {
7682 : : case RTE_ETH_REPRESENTOR_NONE:
7683 : : printf(", NONE\n");
7684 : : break;
7685 : 0 : case RTE_ETH_REPRESENTOR_VF:
7686 : 0 : if (range_diff > 0)
7687 : 0 : printf(", VF %d..%d\n", range->vf,
7688 : 0 : range->vf + range_diff);
7689 : : else
7690 : 0 : printf(", VF %d\n", range->vf);
7691 : : break;
7692 : 0 : case RTE_ETH_REPRESENTOR_SF:
7693 : 0 : printf(", SF %d\n", range->sf);
7694 : : break;
7695 : 0 : case RTE_ETH_REPRESENTOR_PF:
7696 : 0 : if (range_diff > 0)
7697 : 0 : printf("..%d\n", range->pf + range_diff);
7698 : : else
7699 : : printf("\n");
7700 : : break;
7701 : 0 : default:
7702 : : printf(", UNKNOWN TYPE %d\n", range->type);
7703 : : break;
7704 : : }
7705 : : }
7706 : :
7707 : 0 : free(info);
7708 : : }
7709 : :
7710 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7711 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7712 : : cmd_show, "show");
7713 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7714 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7715 : : cmd_port, "port");
7716 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7717 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7718 : : cmd_info, "info");
7719 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7720 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7721 : : cmd_pid, RTE_UINT16);
7722 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7723 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7724 : : cmd_keyword, "representor");
7725 : :
7726 : : static cmdline_parse_inst_t cmd_representor_info = {
7727 : : .f = cmd_representor_info_parsed,
7728 : : .data = NULL,
7729 : : .help_str = "show port info <port_id> representor",
7730 : : .tokens = {
7731 : : (void *)&cmd_representor_info_show,
7732 : : (void *)&cmd_representor_info_port,
7733 : : (void *)&cmd_representor_info_info,
7734 : : (void *)&cmd_representor_info_pid,
7735 : : (void *)&cmd_representor_info_keyword,
7736 : : NULL,
7737 : : },
7738 : : };
7739 : :
7740 : :
7741 : : /* *** SHOW DEVICE INFO *** */
7742 : : struct cmd_showdevice_result {
7743 : : cmdline_fixed_string_t show;
7744 : : cmdline_fixed_string_t device;
7745 : : cmdline_fixed_string_t what;
7746 : : cmdline_fixed_string_t identifier;
7747 : : };
7748 : :
7749 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7750 : : __rte_unused struct cmdline *cl,
7751 : : __rte_unused void *data)
7752 : : {
7753 : : struct cmd_showdevice_result *res = parsed_result;
7754 : 0 : if (!strcmp(res->what, "info")) {
7755 : 0 : if (!strcmp(res->identifier, "all"))
7756 : 0 : device_infos_display(NULL);
7757 : : else
7758 : 0 : device_infos_display(res->identifier);
7759 : : }
7760 : 0 : }
7761 : :
7762 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7763 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7764 : : "show");
7765 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7766 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7767 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7768 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7769 : : "info");
7770 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7771 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7772 : : identifier, NULL);
7773 : :
7774 : : static cmdline_parse_inst_t cmd_showdevice = {
7775 : : .f = cmd_showdevice_parsed,
7776 : : .data = NULL,
7777 : : .help_str = "show device info <identifier>|all",
7778 : : .tokens = {
7779 : : (void *)&cmd_showdevice_show,
7780 : : (void *)&cmd_showdevice_device,
7781 : : (void *)&cmd_showdevice_what,
7782 : : (void *)&cmd_showdevice_identifier,
7783 : : NULL,
7784 : : },
7785 : : };
7786 : :
7787 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7788 : : struct cmd_showeeprom_result {
7789 : : cmdline_fixed_string_t show;
7790 : : cmdline_fixed_string_t port;
7791 : : uint16_t portnum;
7792 : : cmdline_fixed_string_t type;
7793 : : };
7794 : :
7795 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7796 : : __rte_unused struct cmdline *cl,
7797 : : __rte_unused void *data)
7798 : : {
7799 : : struct cmd_showeeprom_result *res = parsed_result;
7800 : :
7801 : 0 : if (!strcmp(res->type, "eeprom"))
7802 : 0 : port_eeprom_display(res->portnum);
7803 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7804 : 0 : port_module_eeprom_display(res->portnum);
7805 : : else
7806 : 0 : fprintf(stderr, "Unknown argument\n");
7807 : 0 : }
7808 : :
7809 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7810 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7811 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7812 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7813 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7814 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7815 : : RTE_UINT16);
7816 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7817 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7818 : :
7819 : : static cmdline_parse_inst_t cmd_showeeprom = {
7820 : : .f = cmd_showeeprom_parsed,
7821 : : .data = NULL,
7822 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7823 : : .tokens = {
7824 : : (void *)&cmd_showeeprom_show,
7825 : : (void *)&cmd_showeeprom_port,
7826 : : (void *)&cmd_showeeprom_portnum,
7827 : : (void *)&cmd_showeeprom_type,
7828 : : NULL,
7829 : : },
7830 : : };
7831 : :
7832 : : struct cmd_showeeprom_decode_result {
7833 : : cmdline_fixed_string_t show;
7834 : : cmdline_fixed_string_t port;
7835 : : uint16_t portnum;
7836 : : cmdline_fixed_string_t module_eeprom;
7837 : : cmdline_fixed_string_t decode;
7838 : : };
7839 : :
7840 : 0 : static void cmd_showeeprom_decode_parsed(void *parsed_result,
7841 : : __rte_unused struct cmdline *cl,
7842 : : __rte_unused void *data)
7843 : : {
7844 : : struct cmd_showeeprom_decode_result *res = parsed_result;
7845 : :
7846 : 0 : port_module_eeprom_decode_display(res->portnum);
7847 : 0 : }
7848 : :
7849 : : static cmdline_parse_token_string_t cmd_showeeprom_decode_show =
7850 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_decode_result, show, "show");
7851 : : static cmdline_parse_token_string_t cmd_showeeprom_decode_port =
7852 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_decode_result, port, "port");
7853 : : static cmdline_parse_token_num_t cmd_showeeprom_decode_portnum =
7854 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_decode_result, portnum,
7855 : : RTE_UINT16);
7856 : : static cmdline_parse_token_string_t cmd_showeeprom_decode_module_eeprom =
7857 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_decode_result, module_eeprom,
7858 : : "module_eeprom");
7859 : : static cmdline_parse_token_string_t cmd_showeeprom_decode_decode =
7860 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_decode_result, decode, "decode");
7861 : :
7862 : : static cmdline_parse_inst_t cmd_showeeprom_decode = {
7863 : : .f = cmd_showeeprom_decode_parsed,
7864 : : .data = NULL,
7865 : : .help_str = "show port <port_id> module_eeprom decode",
7866 : : .tokens = {
7867 : : (void *)&cmd_showeeprom_decode_show,
7868 : : (void *)&cmd_showeeprom_decode_port,
7869 : : (void *)&cmd_showeeprom_decode_portnum,
7870 : : (void *)&cmd_showeeprom_decode_module_eeprom,
7871 : : (void *)&cmd_showeeprom_decode_decode,
7872 : : NULL,
7873 : : },
7874 : : };
7875 : :
7876 : : /* *** SET PORT EEPROM *** */
7877 : : struct cmd_seteeprom_result {
7878 : : cmdline_fixed_string_t set;
7879 : : cmdline_fixed_string_t port;
7880 : : uint16_t portnum;
7881 : : cmdline_fixed_string_t eeprom;
7882 : : cmdline_fixed_string_t confirm_str;
7883 : : cmdline_fixed_string_t magic_str;
7884 : : uint32_t magic;
7885 : : cmdline_fixed_string_t value;
7886 : : cmdline_multi_string_t token_str;
7887 : : };
7888 : :
7889 : 0 : static void cmd_seteeprom_parsed(void *parsed_result,
7890 : : __rte_unused struct cmdline *cl,
7891 : : __rte_unused void *data)
7892 : : {
7893 : : struct cmd_seteeprom_result *res = parsed_result;
7894 : : uint32_t offset = 0;
7895 : : uint32_t length;
7896 : : uint8_t *value;
7897 : : char *token_str;
7898 : : char *token;
7899 : :
7900 : 0 : token_str = res->token_str;
7901 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7902 : :
7903 : : /* Parse Hex string to Byte data */
7904 : 0 : if (strlen(token) % 2 != 0) {
7905 : 0 : fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
7906 : : token);
7907 : 0 : return;
7908 : : }
7909 : :
7910 : 0 : length = strlen(token) / 2;
7911 : 0 : value = calloc(length, sizeof(uint8_t));
7912 : 0 : for (int count = 0; count < (int)(length); count++) {
7913 : 0 : if (sscanf(token, "%2hhx", &value[count]) != 1) {
7914 : 0 : fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
7915 : 0 : token - (count + 1));
7916 : 0 : goto out;
7917 : : }
7918 : 0 : token += 2;
7919 : : }
7920 : :
7921 : : /* Second token: offset string */
7922 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7923 : 0 : if (token != NULL) {
7924 : 0 : if (strcmp(token, "offset") == 0) {
7925 : : /* Third token: offset */
7926 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7927 : 0 : if (token == NULL) {
7928 : 0 : fprintf(stderr, "No offset specified\n");
7929 : 0 : goto out;
7930 : : }
7931 : :
7932 : : char *end;
7933 : 0 : offset = strtoul(token, &end, 10);
7934 : 0 : if (offset == 0 && strcmp(end, "") != 0) {
7935 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7936 : 0 : goto out;
7937 : : }
7938 : : } else {
7939 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7940 : 0 : goto out;
7941 : : }
7942 : : }
7943 : :
7944 : 0 : port_eeprom_set(res->portnum, res->magic, offset, length, value);
7945 : :
7946 : 0 : out:
7947 : 0 : free(value);
7948 : : }
7949 : :
7950 : : static cmdline_parse_token_string_t cmd_seteeprom_set =
7951 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
7952 : : static cmdline_parse_token_string_t cmd_seteeprom_port =
7953 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
7954 : : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
7955 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
7956 : : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
7957 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
7958 : : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
7959 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
7960 : : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
7961 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
7962 : : static cmdline_parse_token_num_t cmd_seteeprom_magic =
7963 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
7964 : : static cmdline_parse_token_string_t cmd_seteeprom_value =
7965 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
7966 : : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
7967 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
7968 : :
7969 : : static cmdline_parse_inst_t cmd_seteeprom = {
7970 : : .f = cmd_seteeprom_parsed,
7971 : : .data = NULL,
7972 : : .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
7973 : : "value <value> offset <offset>: Set eeprom value for port_id.\n"
7974 : : "Note:\n"
7975 : : "This is a high-risk command and its misuse may result in "
7976 : : "unexpected behaviour from the NIC.\n"
7977 : : "By inserting \"accept_risk\" into the command, the user is "
7978 : : "acknowledging and taking responsibility for this risk.",
7979 : : .tokens = {
7980 : : (void *)&cmd_seteeprom_set,
7981 : : (void *)&cmd_seteeprom_port,
7982 : : (void *)&cmd_seteeprom_portnum,
7983 : : (void *)&cmd_seteeprom_eeprom,
7984 : : (void *)&cmd_seteeprom_confirm_str,
7985 : : (void *)&cmd_seteeprom_magic_str,
7986 : : (void *)&cmd_seteeprom_magic,
7987 : : (void *)&cmd_seteeprom_value,
7988 : : (void *)&cmd_seteeprom_token_str,
7989 : : NULL,
7990 : : },
7991 : : };
7992 : :
7993 : : /* *** SHOW QUEUE INFO *** */
7994 : : struct cmd_showqueue_result {
7995 : : cmdline_fixed_string_t show;
7996 : : cmdline_fixed_string_t type;
7997 : : cmdline_fixed_string_t what;
7998 : : uint16_t portnum;
7999 : : uint16_t queuenum;
8000 : : };
8001 : :
8002 : : static void
8003 : 0 : cmd_showqueue_parsed(void *parsed_result,
8004 : : __rte_unused struct cmdline *cl,
8005 : : __rte_unused void *data)
8006 : : {
8007 : : struct cmd_showqueue_result *res = parsed_result;
8008 : :
8009 : 0 : if (!strcmp(res->type, "rxq"))
8010 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
8011 : 0 : else if (!strcmp(res->type, "txq"))
8012 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
8013 : 0 : }
8014 : :
8015 : : static cmdline_parse_token_string_t cmd_showqueue_show =
8016 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
8017 : : static cmdline_parse_token_string_t cmd_showqueue_type =
8018 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
8019 : : static cmdline_parse_token_string_t cmd_showqueue_what =
8020 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
8021 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
8022 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
8023 : : RTE_UINT16);
8024 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
8025 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
8026 : : RTE_UINT16);
8027 : :
8028 : : static cmdline_parse_inst_t cmd_showqueue = {
8029 : : .f = cmd_showqueue_parsed,
8030 : : .data = NULL,
8031 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
8032 : : .tokens = {
8033 : : (void *)&cmd_showqueue_show,
8034 : : (void *)&cmd_showqueue_type,
8035 : : (void *)&cmd_showqueue_what,
8036 : : (void *)&cmd_showqueue_portnum,
8037 : : (void *)&cmd_showqueue_queuenum,
8038 : : NULL,
8039 : : },
8040 : : };
8041 : :
8042 : : /* show/clear fwd engine statistics */
8043 : : struct fwd_result {
8044 : : cmdline_fixed_string_t action;
8045 : : cmdline_fixed_string_t fwd;
8046 : : cmdline_fixed_string_t stats;
8047 : : cmdline_fixed_string_t all;
8048 : : };
8049 : :
8050 : : static cmdline_parse_token_string_t cmd_fwd_action =
8051 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
8052 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
8053 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
8054 : : static cmdline_parse_token_string_t cmd_fwd_stats =
8055 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
8056 : : static cmdline_parse_token_string_t cmd_fwd_all =
8057 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
8058 : :
8059 : : static void
8060 : 0 : cmd_showfwdall_parsed(void *parsed_result,
8061 : : __rte_unused struct cmdline *cl,
8062 : : __rte_unused void *data)
8063 : : {
8064 : : struct fwd_result *res = parsed_result;
8065 : :
8066 : 0 : if (!strcmp(res->action, "show"))
8067 : 0 : fwd_stats_display();
8068 : : else
8069 : 0 : fwd_stats_reset();
8070 : 0 : }
8071 : :
8072 : : static cmdline_parse_inst_t cmd_showfwdall = {
8073 : : .f = cmd_showfwdall_parsed,
8074 : : .data = NULL,
8075 : : .help_str = "show|clear fwd stats all",
8076 : : .tokens = {
8077 : : (void *)&cmd_fwd_action,
8078 : : (void *)&cmd_fwd_fwd,
8079 : : (void *)&cmd_fwd_stats,
8080 : : (void *)&cmd_fwd_all,
8081 : : NULL,
8082 : : },
8083 : : };
8084 : :
8085 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
8086 : : struct cmd_read_rxd_txd_result {
8087 : : cmdline_fixed_string_t read;
8088 : : cmdline_fixed_string_t rxd_txd;
8089 : : portid_t port_id;
8090 : : uint16_t queue_id;
8091 : : uint16_t desc_id;
8092 : : };
8093 : :
8094 : : static void
8095 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
8096 : : __rte_unused struct cmdline *cl,
8097 : : __rte_unused void *data)
8098 : : {
8099 : : struct cmd_read_rxd_txd_result *res = parsed_result;
8100 : :
8101 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
8102 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8103 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
8104 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
8105 : 0 : }
8106 : :
8107 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
8108 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
8109 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
8110 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
8111 : : "rxd#txd");
8112 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
8113 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
8114 : : RTE_UINT16);
8115 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8116 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8117 : : RTE_UINT16);
8118 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8119 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8120 : : RTE_UINT16);
8121 : :
8122 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
8123 : : .f = cmd_read_rxd_txd_parsed,
8124 : : .data = NULL,
8125 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8126 : : .tokens = {
8127 : : (void *)&cmd_read_rxd_txd_read,
8128 : : (void *)&cmd_read_rxd_txd_rxd_txd,
8129 : : (void *)&cmd_read_rxd_txd_port_id,
8130 : : (void *)&cmd_read_rxd_txd_queue_id,
8131 : : (void *)&cmd_read_rxd_txd_desc_id,
8132 : : NULL,
8133 : : },
8134 : : };
8135 : :
8136 : : /* *** QUIT *** */
8137 : : struct cmd_quit_result {
8138 : : cmdline_fixed_string_t quit;
8139 : : };
8140 : :
8141 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
8142 : : struct cmdline *cl,
8143 : : __rte_unused void *data)
8144 : : {
8145 : 0 : cmdline_quit(cl);
8146 : 0 : cl_quit = 1;
8147 : 0 : }
8148 : :
8149 : : static cmdline_parse_token_string_t cmd_quit_quit =
8150 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8151 : :
8152 : : static cmdline_parse_inst_t cmd_quit = {
8153 : : .f = cmd_quit_parsed,
8154 : : .data = NULL,
8155 : : .help_str = "quit: Exit application",
8156 : : .tokens = {
8157 : : (void *)&cmd_quit_quit,
8158 : : NULL,
8159 : : },
8160 : : };
8161 : :
8162 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8163 : : struct cmd_mac_addr_result {
8164 : : cmdline_fixed_string_t mac_addr_cmd;
8165 : : cmdline_fixed_string_t what;
8166 : : uint16_t port_num;
8167 : : struct rte_ether_addr address;
8168 : : };
8169 : :
8170 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
8171 : : __rte_unused struct cmdline *cl,
8172 : : __rte_unused void *data)
8173 : : {
8174 : : struct cmd_mac_addr_result *res = parsed_result;
8175 : : int ret;
8176 : :
8177 : 0 : if (strcmp(res->what, "add") == 0)
8178 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8179 : 0 : else if (strcmp(res->what, "set") == 0)
8180 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8181 : : &res->address);
8182 : : else
8183 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8184 : :
8185 : : /* check the return value and print it if is < 0 */
8186 : 0 : if(ret < 0)
8187 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8188 : :
8189 : 0 : }
8190 : :
8191 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
8192 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8193 : : "mac_addr");
8194 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
8195 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8196 : : "add#remove#set");
8197 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
8198 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8199 : : RTE_UINT16);
8200 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8201 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8202 : :
8203 : : static cmdline_parse_inst_t cmd_mac_addr = {
8204 : : .f = cmd_mac_addr_parsed,
8205 : : .data = (void *)0,
8206 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8207 : : "Add/Remove/Set MAC address on port_id",
8208 : : .tokens = {
8209 : : (void *)&cmd_mac_addr_cmd,
8210 : : (void *)&cmd_mac_addr_what,
8211 : : (void *)&cmd_mac_addr_portnum,
8212 : : (void *)&cmd_mac_addr_addr,
8213 : : NULL,
8214 : : },
8215 : : };
8216 : :
8217 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8218 : : struct cmd_eth_peer_result {
8219 : : cmdline_fixed_string_t set;
8220 : : cmdline_fixed_string_t eth_peer;
8221 : : portid_t port_id;
8222 : : cmdline_fixed_string_t peer_addr;
8223 : : };
8224 : :
8225 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
8226 : : __rte_unused struct cmdline *cl,
8227 : : __rte_unused void *data)
8228 : : {
8229 : : struct cmd_eth_peer_result *res = parsed_result;
8230 : :
8231 : 0 : if (test_done == 0) {
8232 : 0 : fprintf(stderr, "Please stop forwarding first\n");
8233 : 0 : return;
8234 : : }
8235 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
8236 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
8237 : 0 : fwd_config_setup();
8238 : : }
8239 : : }
8240 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
8241 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8242 : : static cmdline_parse_token_string_t cmd_eth_peer =
8243 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8244 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
8245 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8246 : : RTE_UINT16);
8247 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
8248 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8249 : :
8250 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8251 : : .f = cmd_set_eth_peer_parsed,
8252 : : .data = NULL,
8253 : : .help_str = "set eth-peer <port_id> <peer_mac>",
8254 : : .tokens = {
8255 : : (void *)&cmd_eth_peer_set,
8256 : : (void *)&cmd_eth_peer,
8257 : : (void *)&cmd_eth_peer_port_id,
8258 : : (void *)&cmd_eth_peer_addr,
8259 : : NULL,
8260 : : },
8261 : : };
8262 : :
8263 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8264 : : struct cmd_set_xstats_hide_zero_result {
8265 : : cmdline_fixed_string_t keyword;
8266 : : cmdline_fixed_string_t name;
8267 : : cmdline_fixed_string_t on_off;
8268 : : };
8269 : :
8270 : : static void
8271 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8272 : : __rte_unused struct cmdline *cl,
8273 : : __rte_unused void *data)
8274 : : {
8275 : : struct cmd_set_xstats_hide_zero_result *res;
8276 : : uint16_t on_off = 0;
8277 : :
8278 : : res = parsed_result;
8279 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8280 : 0 : set_xstats_hide_zero(on_off);
8281 : 0 : }
8282 : :
8283 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8284 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8285 : : keyword, "set");
8286 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8287 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8288 : : name, "xstats-hide-zero");
8289 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8290 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8291 : : on_off, "on#off");
8292 : :
8293 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8294 : : .f = cmd_set_xstats_hide_zero_parsed,
8295 : : .data = NULL,
8296 : : .help_str = "set xstats-hide-zero on|off",
8297 : : .tokens = {
8298 : : (void *)&cmd_set_xstats_hide_zero_keyword,
8299 : : (void *)&cmd_set_xstats_hide_zero_name,
8300 : : (void *)&cmd_set_xstats_hide_zero_on_off,
8301 : : NULL,
8302 : : },
8303 : : };
8304 : :
8305 : : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
8306 : : struct cmd_set_xstats_show_state_result {
8307 : : cmdline_fixed_string_t keyword;
8308 : : cmdline_fixed_string_t name;
8309 : : uint8_t on_off;
8310 : : };
8311 : : static void
8312 : 0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
8313 : : __rte_unused struct cmdline *cl,
8314 : : __rte_unused void *data)
8315 : : {
8316 : : struct cmd_set_xstats_show_state_result *res = parsed_result;
8317 : 0 : set_xstats_show_state(res->on_off);
8318 : 0 : }
8319 : :
8320 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
8321 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8322 : : keyword, "set");
8323 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
8324 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8325 : : name, "xstats-show-state");
8326 : : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
8327 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
8328 : : on_off);
8329 : :
8330 : : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
8331 : : .f = cmd_set_xstats_show_state_parsed,
8332 : : .data = NULL,
8333 : : .help_str = "set xstats-show-state on|off",
8334 : : .tokens = {
8335 : : (void *)&cmd_set_xstats_show_state_keyword,
8336 : : (void *)&cmd_set_xstats_show_state_name,
8337 : : (void *)&cmd_set_xstats_show_state_on_off,
8338 : : NULL,
8339 : : },
8340 : : };
8341 : :
8342 : : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
8343 : : struct cmd_set_xstats_hide_disabled_result {
8344 : : cmdline_fixed_string_t keyword;
8345 : : cmdline_fixed_string_t name;
8346 : : uint8_t on_off;
8347 : : };
8348 : :
8349 : : static void
8350 : 0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
8351 : : __rte_unused struct cmdline *cl,
8352 : : __rte_unused void *data)
8353 : : {
8354 : : struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
8355 : 0 : set_xstats_hide_disabled(res->on_off);
8356 : 0 : }
8357 : :
8358 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
8359 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8360 : : keyword, "set");
8361 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
8362 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8363 : : name, "xstats-hide-disabled");
8364 : : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
8365 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8366 : : on_off);
8367 : :
8368 : : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
8369 : : .f = cmd_set_xstats_hide_disabled_parsed,
8370 : : .data = NULL,
8371 : : .help_str = "set xstats-hide-disabled on|off",
8372 : : .tokens = {
8373 : : (void *)&cmd_set_xstats_hide_disabled_keyword,
8374 : : (void *)&cmd_set_xstats_hide_disabled_name,
8375 : : (void *)&cmd_set_xstats_hide_disabled_on_off,
8376 : : NULL,
8377 : : },
8378 : : };
8379 : :
8380 : : /* *** enable/disable counter by name *** */
8381 : : struct cmd_operate_set_counter_result {
8382 : : cmdline_fixed_string_t port;
8383 : : portid_t port_id;
8384 : : cmdline_fixed_string_t what;
8385 : : cmdline_multi_string_t counter_name;
8386 : : };
8387 : :
8388 : : static void
8389 : 0 : cmd_operate_set_counter_parsed(void *parsed_result,
8390 : : __rte_unused struct cmdline *cl,
8391 : : __rte_unused void *data)
8392 : : {
8393 : : struct cmd_operate_set_counter_result *res = parsed_result;
8394 : 0 : uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
8395 : :
8396 : 0 : if ((strcmp(res->port, "port") == 0))
8397 : 0 : nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
8398 : 0 : }
8399 : :
8400 : : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
8401 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8402 : : port, "port");
8403 : : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
8404 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
8405 : : port_id, RTE_UINT16);
8406 : : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
8407 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8408 : : what, "enable#disable");
8409 : : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
8410 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8411 : : counter_name, TOKEN_STRING_MULTI);
8412 : :
8413 : : static cmdline_parse_inst_t cmd_operate_set_counter = {
8414 : : .f = cmd_operate_set_counter_parsed,
8415 : : .data = NULL,
8416 : : .help_str = "port (port_id) enable|disable <counter_name>",
8417 : : .tokens = {
8418 : : (void *)&cmd_operate_set_counter_port,
8419 : : (void *)&cmd_operate_set_counter_port_id,
8420 : : (void *)&cmd_operate_set_counter_what,
8421 : : (void *)&cmd_operate_set_counter_name,
8422 : : NULL,
8423 : : },
8424 : : };
8425 : :
8426 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8427 : : struct cmd_set_record_core_cycles_result {
8428 : : cmdline_fixed_string_t keyword;
8429 : : cmdline_fixed_string_t name;
8430 : : cmdline_fixed_string_t on_off;
8431 : : };
8432 : :
8433 : : static void
8434 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
8435 : : __rte_unused struct cmdline *cl,
8436 : : __rte_unused void *data)
8437 : : {
8438 : : struct cmd_set_record_core_cycles_result *res;
8439 : : uint16_t on_off = 0;
8440 : :
8441 : : res = parsed_result;
8442 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8443 : 0 : set_record_core_cycles(on_off);
8444 : 0 : }
8445 : :
8446 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8447 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8448 : : keyword, "set");
8449 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8450 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8451 : : name, "record-core-cycles");
8452 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8453 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8454 : : on_off, "on#off");
8455 : :
8456 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
8457 : : .f = cmd_set_record_core_cycles_parsed,
8458 : : .data = NULL,
8459 : : .help_str = "set record-core-cycles on|off",
8460 : : .tokens = {
8461 : : (void *)&cmd_set_record_core_cycles_keyword,
8462 : : (void *)&cmd_set_record_core_cycles_name,
8463 : : (void *)&cmd_set_record_core_cycles_on_off,
8464 : : NULL,
8465 : : },
8466 : : };
8467 : :
8468 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8469 : : struct cmd_set_record_burst_stats_result {
8470 : : cmdline_fixed_string_t keyword;
8471 : : cmdline_fixed_string_t name;
8472 : : cmdline_fixed_string_t on_off;
8473 : : };
8474 : :
8475 : : static void
8476 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
8477 : : __rte_unused struct cmdline *cl,
8478 : : __rte_unused void *data)
8479 : : {
8480 : : struct cmd_set_record_burst_stats_result *res;
8481 : : uint16_t on_off = 0;
8482 : :
8483 : : res = parsed_result;
8484 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8485 : 0 : set_record_burst_stats(on_off);
8486 : 0 : }
8487 : :
8488 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8489 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8490 : : keyword, "set");
8491 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8492 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8493 : : name, "record-burst-stats");
8494 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8495 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8496 : : on_off, "on#off");
8497 : :
8498 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
8499 : : .f = cmd_set_record_burst_stats_parsed,
8500 : : .data = NULL,
8501 : : .help_str = "set record-burst-stats on|off",
8502 : : .tokens = {
8503 : : (void *)&cmd_set_record_burst_stats_keyword,
8504 : : (void *)&cmd_set_record_burst_stats_name,
8505 : : (void *)&cmd_set_record_burst_stats_on_off,
8506 : : NULL,
8507 : : },
8508 : : };
8509 : :
8510 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
8511 : : struct cmd_set_uc_hash_table {
8512 : : cmdline_fixed_string_t set;
8513 : : cmdline_fixed_string_t port;
8514 : : portid_t port_id;
8515 : : cmdline_fixed_string_t what;
8516 : : struct rte_ether_addr address;
8517 : : cmdline_fixed_string_t mode;
8518 : : };
8519 : :
8520 : : static void
8521 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
8522 : : __rte_unused struct cmdline *cl,
8523 : : __rte_unused void *data)
8524 : : {
8525 : : int ret=0;
8526 : : struct cmd_set_uc_hash_table *res = parsed_result;
8527 : :
8528 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8529 : :
8530 : 0 : if (strcmp(res->what, "uta") == 0)
8531 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8532 : : &res->address,(uint8_t)is_on);
8533 : 0 : if (ret < 0)
8534 : 0 : fprintf(stderr,
8535 : : "bad unicast hash table parameter, return code = %d\n",
8536 : : ret);
8537 : :
8538 : 0 : }
8539 : :
8540 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
8541 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8542 : : set, "set");
8543 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
8544 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8545 : : port, "port");
8546 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8547 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8548 : : port_id, RTE_UINT16);
8549 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
8550 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8551 : : what, "uta");
8552 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8553 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8554 : : address);
8555 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8556 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8557 : : mode, "on#off");
8558 : :
8559 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8560 : : .f = cmd_set_uc_hash_parsed,
8561 : : .data = NULL,
8562 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
8563 : : .tokens = {
8564 : : (void *)&cmd_set_uc_hash_set,
8565 : : (void *)&cmd_set_uc_hash_port,
8566 : : (void *)&cmd_set_uc_hash_portid,
8567 : : (void *)&cmd_set_uc_hash_what,
8568 : : (void *)&cmd_set_uc_hash_mac,
8569 : : (void *)&cmd_set_uc_hash_mode,
8570 : : NULL,
8571 : : },
8572 : : };
8573 : :
8574 : : struct cmd_set_uc_all_hash_table {
8575 : : cmdline_fixed_string_t set;
8576 : : cmdline_fixed_string_t port;
8577 : : portid_t port_id;
8578 : : cmdline_fixed_string_t what;
8579 : : cmdline_fixed_string_t value;
8580 : : cmdline_fixed_string_t mode;
8581 : : };
8582 : :
8583 : : static void
8584 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
8585 : : __rte_unused struct cmdline *cl,
8586 : : __rte_unused void *data)
8587 : : {
8588 : : int ret=0;
8589 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
8590 : :
8591 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8592 : :
8593 : 0 : if ((strcmp(res->what, "uta") == 0) &&
8594 : 0 : (strcmp(res->value, "all") == 0))
8595 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8596 : 0 : if (ret < 0)
8597 : 0 : fprintf(stderr,
8598 : : "bad unicast hash table parameter, return code = %d\n",
8599 : : ret);
8600 : 0 : }
8601 : :
8602 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8603 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8604 : : set, "set");
8605 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8606 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8607 : : port, "port");
8608 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8609 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8610 : : port_id, RTE_UINT16);
8611 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8612 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8613 : : what, "uta");
8614 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8615 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8616 : : value,"all");
8617 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8618 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8619 : : mode, "on#off");
8620 : :
8621 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8622 : : .f = cmd_set_uc_all_hash_parsed,
8623 : : .data = NULL,
8624 : : .help_str = "set port <port_id> uta all on|off",
8625 : : .tokens = {
8626 : : (void *)&cmd_set_uc_all_hash_set,
8627 : : (void *)&cmd_set_uc_all_hash_port,
8628 : : (void *)&cmd_set_uc_all_hash_portid,
8629 : : (void *)&cmd_set_uc_all_hash_what,
8630 : : (void *)&cmd_set_uc_all_hash_value,
8631 : : (void *)&cmd_set_uc_all_hash_mode,
8632 : : NULL,
8633 : : },
8634 : : };
8635 : :
8636 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8637 : : struct cmd_set_vf_traffic {
8638 : : cmdline_fixed_string_t set;
8639 : : cmdline_fixed_string_t port;
8640 : : portid_t port_id;
8641 : : cmdline_fixed_string_t vf;
8642 : : uint8_t vf_id;
8643 : : cmdline_fixed_string_t what;
8644 : : cmdline_fixed_string_t mode;
8645 : : };
8646 : :
8647 : : static void
8648 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
8649 : : __rte_unused struct cmdline *cl,
8650 : : __rte_unused void *data)
8651 : : {
8652 : : struct cmd_set_vf_traffic *res = parsed_result;
8653 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8654 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8655 : :
8656 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8657 : 0 : }
8658 : :
8659 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
8660 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8661 : : set, "set");
8662 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
8663 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8664 : : port, "port");
8665 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8666 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8667 : : port_id, RTE_UINT16);
8668 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8669 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8670 : : vf, "vf");
8671 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8672 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8673 : : vf_id, RTE_UINT8);
8674 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
8675 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8676 : : what, "tx#rx");
8677 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8678 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8679 : : mode, "on#off");
8680 : :
8681 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
8682 : : .f = cmd_set_vf_traffic_parsed,
8683 : : .data = NULL,
8684 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8685 : : .tokens = {
8686 : : (void *)&cmd_setvf_traffic_set,
8687 : : (void *)&cmd_setvf_traffic_port,
8688 : : (void *)&cmd_setvf_traffic_portid,
8689 : : (void *)&cmd_setvf_traffic_vf,
8690 : : (void *)&cmd_setvf_traffic_vfid,
8691 : : (void *)&cmd_setvf_traffic_what,
8692 : : (void *)&cmd_setvf_traffic_mode,
8693 : : NULL,
8694 : : },
8695 : : };
8696 : :
8697 : : /* *** CONFIGURE VF RECEIVE MODE *** */
8698 : : struct cmd_set_vf_rxmode {
8699 : : cmdline_fixed_string_t set;
8700 : : cmdline_fixed_string_t port;
8701 : : portid_t port_id;
8702 : : cmdline_fixed_string_t vf;
8703 : : uint8_t vf_id;
8704 : : cmdline_fixed_string_t what;
8705 : : cmdline_fixed_string_t mode;
8706 : : cmdline_fixed_string_t on;
8707 : : };
8708 : :
8709 : : static void
8710 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
8711 : : __rte_unused struct cmdline *cl,
8712 : : __rte_unused void *data)
8713 : : {
8714 : : int ret = -ENOTSUP;
8715 : : uint16_t vf_rxmode = 0;
8716 : : struct cmd_set_vf_rxmode *res = parsed_result;
8717 : :
8718 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8719 : 0 : if (!strcmp(res->what,"rxmode")) {
8720 : 0 : if (!strcmp(res->mode, "AUPE"))
8721 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
8722 : 0 : else if (!strcmp(res->mode, "ROPE"))
8723 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
8724 : 0 : else if (!strcmp(res->mode, "BAM"))
8725 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
8726 : 0 : else if (!strncmp(res->mode, "MPE",3))
8727 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
8728 : : }
8729 : :
8730 : : RTE_SET_USED(is_on);
8731 : : RTE_SET_USED(vf_rxmode);
8732 : :
8733 : : #ifdef RTE_NET_IXGBE
8734 : : if (ret == -ENOTSUP)
8735 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8736 : : vf_rxmode, (uint8_t)is_on);
8737 : : #endif
8738 : : #ifdef RTE_NET_BNXT
8739 : 0 : if (ret == -ENOTSUP)
8740 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8741 : : vf_rxmode, (uint8_t)is_on);
8742 : : #endif
8743 : 0 : if (ret < 0)
8744 : 0 : fprintf(stderr,
8745 : : "bad VF receive mode parameter, return code = %d\n",
8746 : : ret);
8747 : 0 : }
8748 : :
8749 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8750 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8751 : : set, "set");
8752 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8753 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8754 : : port, "port");
8755 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8756 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8757 : : port_id, RTE_UINT16);
8758 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8759 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8760 : : vf, "vf");
8761 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8762 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8763 : : vf_id, RTE_UINT8);
8764 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8765 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8766 : : what, "rxmode");
8767 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8768 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8769 : : mode, "AUPE#ROPE#BAM#MPE");
8770 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8771 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8772 : : on, "on#off");
8773 : :
8774 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
8775 : : .f = cmd_set_vf_rxmode_parsed,
8776 : : .data = NULL,
8777 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
8778 : : "AUPE|ROPE|BAM|MPE on|off",
8779 : : .tokens = {
8780 : : (void *)&cmd_set_vf_rxmode_set,
8781 : : (void *)&cmd_set_vf_rxmode_port,
8782 : : (void *)&cmd_set_vf_rxmode_portid,
8783 : : (void *)&cmd_set_vf_rxmode_vf,
8784 : : (void *)&cmd_set_vf_rxmode_vfid,
8785 : : (void *)&cmd_set_vf_rxmode_what,
8786 : : (void *)&cmd_set_vf_rxmode_mode,
8787 : : (void *)&cmd_set_vf_rxmode_on,
8788 : : NULL,
8789 : : },
8790 : : };
8791 : :
8792 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8793 : : struct cmd_vf_mac_addr_result {
8794 : : cmdline_fixed_string_t mac_addr_cmd;
8795 : : cmdline_fixed_string_t what;
8796 : : cmdline_fixed_string_t port;
8797 : : uint16_t port_num;
8798 : : cmdline_fixed_string_t vf;
8799 : : uint8_t vf_num;
8800 : : struct rte_ether_addr address;
8801 : : };
8802 : :
8803 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
8804 : : __rte_unused struct cmdline *cl,
8805 : : __rte_unused void *data)
8806 : : {
8807 : : struct cmd_vf_mac_addr_result *res = parsed_result;
8808 : : int ret = -ENOTSUP;
8809 : :
8810 : 0 : if (strcmp(res->what, "add") != 0)
8811 : : return;
8812 : :
8813 : : #ifdef RTE_NET_I40E
8814 : : if (ret == -ENOTSUP)
8815 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8816 : : &res->address);
8817 : : #endif
8818 : : #ifdef RTE_NET_BNXT
8819 : 0 : if (ret == -ENOTSUP)
8820 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8821 : 0 : res->vf_num);
8822 : : #endif
8823 : :
8824 : 0 : if(ret < 0)
8825 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8826 : :
8827 : : }
8828 : :
8829 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8830 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8831 : : mac_addr_cmd,"mac_addr");
8832 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8833 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8834 : : what,"add");
8835 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8836 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8837 : : port,"port");
8838 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8839 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8840 : : port_num, RTE_UINT16);
8841 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8842 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8843 : : vf,"vf");
8844 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8845 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8846 : : vf_num, RTE_UINT8);
8847 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8848 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8849 : : address);
8850 : :
8851 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8852 : : .f = cmd_vf_mac_addr_parsed,
8853 : : .data = (void *)0,
8854 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8855 : : "Add MAC address filtering for a VF on port_id",
8856 : : .tokens = {
8857 : : (void *)&cmd_vf_mac_addr_cmd,
8858 : : (void *)&cmd_vf_mac_addr_what,
8859 : : (void *)&cmd_vf_mac_addr_port,
8860 : : (void *)&cmd_vf_mac_addr_portnum,
8861 : : (void *)&cmd_vf_mac_addr_vf,
8862 : : (void *)&cmd_vf_mac_addr_vfnum,
8863 : : (void *)&cmd_vf_mac_addr_addr,
8864 : : NULL,
8865 : : },
8866 : : };
8867 : :
8868 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8869 : : struct cmd_vf_rx_vlan_filter {
8870 : : cmdline_fixed_string_t rx_vlan;
8871 : : cmdline_fixed_string_t what;
8872 : : uint16_t vlan_id;
8873 : : cmdline_fixed_string_t port;
8874 : : portid_t port_id;
8875 : : cmdline_fixed_string_t vf;
8876 : : uint64_t vf_mask;
8877 : : };
8878 : :
8879 : : static void
8880 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8881 : : __rte_unused struct cmdline *cl,
8882 : : __rte_unused void *data)
8883 : : {
8884 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8885 : : int ret = -ENOTSUP;
8886 : :
8887 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8888 : :
8889 : : #ifdef RTE_NET_IXGBE
8890 : : if (ret == -ENOTSUP)
8891 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8892 : 0 : res->vlan_id, res->vf_mask, is_add);
8893 : : #endif
8894 : : #ifdef RTE_NET_I40E
8895 : 0 : if (ret == -ENOTSUP)
8896 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8897 : 0 : res->vlan_id, res->vf_mask, is_add);
8898 : : #endif
8899 : : #ifdef RTE_NET_BNXT
8900 : 0 : if (ret == -ENOTSUP)
8901 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8902 : 0 : res->vlan_id, res->vf_mask, is_add);
8903 : : #endif
8904 : :
8905 : 0 : switch (ret) {
8906 : : case 0:
8907 : : break;
8908 : 0 : case -EINVAL:
8909 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8910 : 0 : res->vlan_id, res->vf_mask);
8911 : : break;
8912 : 0 : case -ENODEV:
8913 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8914 : : break;
8915 : 0 : case -ENOTSUP:
8916 : 0 : fprintf(stderr, "function not implemented or supported\n");
8917 : : break;
8918 : 0 : default:
8919 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8920 : : }
8921 : 0 : }
8922 : :
8923 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8924 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8925 : : rx_vlan, "rx_vlan");
8926 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8927 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8928 : : what, "add#rm");
8929 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8930 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8931 : : vlan_id, RTE_UINT16);
8932 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8933 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8934 : : port, "port");
8935 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8936 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8937 : : port_id, RTE_UINT16);
8938 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8939 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8940 : : vf, "vf");
8941 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8942 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8943 : : vf_mask, RTE_UINT64);
8944 : :
8945 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8946 : : .f = cmd_vf_rx_vlan_filter_parsed,
8947 : : .data = NULL,
8948 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8949 : : "(vf_mask = hexadecimal VF mask)",
8950 : : .tokens = {
8951 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8952 : : (void *)&cmd_vf_rx_vlan_filter_what,
8953 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8954 : : (void *)&cmd_vf_rx_vlan_filter_port,
8955 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8956 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8957 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8958 : : NULL,
8959 : : },
8960 : : };
8961 : :
8962 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8963 : : struct cmd_queue_rate_limit_result {
8964 : : cmdline_fixed_string_t set;
8965 : : cmdline_fixed_string_t port;
8966 : : uint16_t port_num;
8967 : : cmdline_fixed_string_t queue;
8968 : : uint8_t queue_num;
8969 : : cmdline_fixed_string_t rate;
8970 : : uint32_t rate_num;
8971 : : };
8972 : :
8973 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8974 : : __rte_unused struct cmdline *cl,
8975 : : __rte_unused void *data)
8976 : : {
8977 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8978 : : int ret = 0;
8979 : :
8980 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8981 : 0 : && (strcmp(res->queue, "queue") == 0)
8982 : 0 : && (strcmp(res->rate, "rate") == 0))
8983 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8984 : : res->rate_num);
8985 : 0 : if (ret < 0)
8986 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8987 : : strerror(-ret));
8988 : :
8989 : 0 : }
8990 : :
8991 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8992 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8993 : : set, "set");
8994 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8995 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8996 : : port, "port");
8997 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8998 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8999 : : port_num, RTE_UINT16);
9000 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
9001 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9002 : : queue, "queue");
9003 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
9004 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9005 : : queue_num, RTE_UINT8);
9006 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
9007 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
9008 : : rate, "rate");
9009 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
9010 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
9011 : : rate_num, RTE_UINT32);
9012 : :
9013 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
9014 : : .f = cmd_queue_rate_limit_parsed,
9015 : : .data = (void *)0,
9016 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
9017 : : "Set rate limit for a queue on port_id",
9018 : : .tokens = {
9019 : : (void *)&cmd_queue_rate_limit_set,
9020 : : (void *)&cmd_queue_rate_limit_port,
9021 : : (void *)&cmd_queue_rate_limit_portnum,
9022 : : (void *)&cmd_queue_rate_limit_queue,
9023 : : (void *)&cmd_queue_rate_limit_queuenum,
9024 : : (void *)&cmd_queue_rate_limit_rate,
9025 : : (void *)&cmd_queue_rate_limit_ratenum,
9026 : : NULL,
9027 : : },
9028 : : };
9029 : :
9030 : : /* *** SHOW RATE LIMIT FOR A QUEUE OF A PORT *** */
9031 : : struct cmd_show_queue_rate_limit_result {
9032 : : cmdline_fixed_string_t show;
9033 : : cmdline_fixed_string_t port;
9034 : : uint16_t port_num;
9035 : : cmdline_fixed_string_t queue;
9036 : : uint16_t queue_num;
9037 : : cmdline_fixed_string_t rate;
9038 : : };
9039 : :
9040 : 0 : static void cmd_show_queue_rate_limit_parsed(void *parsed_result,
9041 : : __rte_unused struct cmdline *cl,
9042 : : __rte_unused void *data)
9043 : : {
9044 : : struct cmd_show_queue_rate_limit_result *res = parsed_result;
9045 : 0 : uint32_t tx_rate = 0;
9046 : : int ret;
9047 : :
9048 : 0 : ret = rte_eth_get_queue_rate_limit(res->port_num, res->queue_num,
9049 : : &tx_rate);
9050 : 0 : if (ret) {
9051 : 0 : fprintf(stderr, "Get queue rate limit failed: %s\n",
9052 : : rte_strerror(-ret));
9053 : 0 : return;
9054 : : }
9055 : 0 : if (tx_rate)
9056 : 0 : printf("Port %u Queue %u rate limit: %u Mbps\n",
9057 : 0 : res->port_num, res->queue_num, tx_rate);
9058 : : else
9059 : 0 : printf("Port %u Queue %u rate limit: disabled\n",
9060 : 0 : res->port_num, res->queue_num);
9061 : : }
9062 : :
9063 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_show =
9064 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9065 : : show, "show");
9066 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_port =
9067 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9068 : : port, "port");
9069 : : static cmdline_parse_token_num_t cmd_show_queue_rate_limit_portnum =
9070 : : TOKEN_NUM_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9071 : : port_num, RTE_UINT16);
9072 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_queue =
9073 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9074 : : queue, "queue");
9075 : : static cmdline_parse_token_num_t cmd_show_queue_rate_limit_queuenum =
9076 : : TOKEN_NUM_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9077 : : queue_num, RTE_UINT16);
9078 : : static cmdline_parse_token_string_t cmd_show_queue_rate_limit_rate =
9079 : : TOKEN_STRING_INITIALIZER(struct cmd_show_queue_rate_limit_result,
9080 : : rate, "rate");
9081 : :
9082 : : static cmdline_parse_inst_t cmd_show_queue_rate_limit = {
9083 : : .f = cmd_show_queue_rate_limit_parsed,
9084 : : .data = NULL,
9085 : : .help_str = "show port <port_id> queue <queue_id> rate: "
9086 : : "Show rate limit for a queue on port_id",
9087 : : .tokens = {
9088 : : (void *)&cmd_show_queue_rate_limit_show,
9089 : : (void *)&cmd_show_queue_rate_limit_port,
9090 : : (void *)&cmd_show_queue_rate_limit_portnum,
9091 : : (void *)&cmd_show_queue_rate_limit_queue,
9092 : : (void *)&cmd_show_queue_rate_limit_queuenum,
9093 : : (void *)&cmd_show_queue_rate_limit_rate,
9094 : : NULL,
9095 : : },
9096 : : };
9097 : :
9098 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
9099 : : struct cmd_vf_rate_limit_result {
9100 : : cmdline_fixed_string_t set;
9101 : : cmdline_fixed_string_t port;
9102 : : uint16_t port_num;
9103 : : cmdline_fixed_string_t vf;
9104 : : uint8_t vf_num;
9105 : : cmdline_fixed_string_t rate;
9106 : : uint32_t rate_num;
9107 : : cmdline_fixed_string_t q_msk;
9108 : : uint64_t q_msk_val;
9109 : : };
9110 : :
9111 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
9112 : : __rte_unused struct cmdline *cl,
9113 : : __rte_unused void *data)
9114 : : {
9115 : : struct cmd_vf_rate_limit_result *res = parsed_result;
9116 : : int ret = 0;
9117 : :
9118 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
9119 : 0 : && (strcmp(res->vf, "vf") == 0)
9120 : 0 : && (strcmp(res->rate, "rate") == 0)
9121 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
9122 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
9123 : : res->rate_num, res->q_msk_val);
9124 : 0 : if (ret < 0)
9125 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
9126 : : strerror(-ret));
9127 : :
9128 : 0 : }
9129 : :
9130 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
9131 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9132 : : set, "set");
9133 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
9134 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9135 : : port, "port");
9136 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
9137 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9138 : : port_num, RTE_UINT16);
9139 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
9140 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9141 : : vf, "vf");
9142 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
9143 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9144 : : vf_num, RTE_UINT8);
9145 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
9146 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9147 : : rate, "rate");
9148 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
9149 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9150 : : rate_num, RTE_UINT32);
9151 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
9152 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
9153 : : q_msk, "queue_mask");
9154 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
9155 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
9156 : : q_msk_val, RTE_UINT64);
9157 : :
9158 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
9159 : : .f = cmd_vf_rate_limit_parsed,
9160 : : .data = (void *)0,
9161 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
9162 : : "queue_mask <queue_mask_value>: "
9163 : : "Set rate limit for queues of VF on port_id",
9164 : : .tokens = {
9165 : : (void *)&cmd_vf_rate_limit_set,
9166 : : (void *)&cmd_vf_rate_limit_port,
9167 : : (void *)&cmd_vf_rate_limit_portnum,
9168 : : (void *)&cmd_vf_rate_limit_vf,
9169 : : (void *)&cmd_vf_rate_limit_vfnum,
9170 : : (void *)&cmd_vf_rate_limit_rate,
9171 : : (void *)&cmd_vf_rate_limit_ratenum,
9172 : : (void *)&cmd_vf_rate_limit_q_msk,
9173 : : (void *)&cmd_vf_rate_limit_q_msk_val,
9174 : : NULL,
9175 : : },
9176 : : };
9177 : :
9178 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
9179 : : struct cmd_tunnel_udp_config {
9180 : : cmdline_fixed_string_t rx_vxlan_port;
9181 : : cmdline_fixed_string_t what;
9182 : : uint16_t udp_port;
9183 : : portid_t port_id;
9184 : : };
9185 : :
9186 : : static void
9187 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
9188 : : __rte_unused struct cmdline *cl,
9189 : : __rte_unused void *data)
9190 : : {
9191 : : struct cmd_tunnel_udp_config *res = parsed_result;
9192 : : struct rte_eth_udp_tunnel tunnel_udp;
9193 : : int ret;
9194 : :
9195 : 0 : tunnel_udp.udp_port = res->udp_port;
9196 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9197 : :
9198 : 0 : if (!strcmp(res->what, "add"))
9199 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9200 : : &tunnel_udp);
9201 : : else
9202 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9203 : : &tunnel_udp);
9204 : :
9205 : 0 : if (ret < 0)
9206 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
9207 : : strerror(-ret));
9208 : 0 : }
9209 : :
9210 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9211 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9212 : : rx_vxlan_port, "rx_vxlan_port");
9213 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9214 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9215 : : what, "add#rm");
9216 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9217 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9218 : : udp_port, RTE_UINT16);
9219 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9220 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9221 : : port_id, RTE_UINT16);
9222 : :
9223 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
9224 : : .f = cmd_tunnel_udp_config_parsed,
9225 : : .data = (void *)0,
9226 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9227 : : "Add/Remove a tunneling UDP port filter",
9228 : : .tokens = {
9229 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9230 : : (void *)&cmd_tunnel_udp_config_what,
9231 : : (void *)&cmd_tunnel_udp_config_udp_port,
9232 : : (void *)&cmd_tunnel_udp_config_port_id,
9233 : : NULL,
9234 : : },
9235 : : };
9236 : :
9237 : : struct cmd_config_tunnel_udp_port {
9238 : : cmdline_fixed_string_t port;
9239 : : cmdline_fixed_string_t config;
9240 : : portid_t port_id;
9241 : : cmdline_fixed_string_t udp_tunnel_port;
9242 : : cmdline_fixed_string_t action;
9243 : : cmdline_fixed_string_t tunnel_type;
9244 : : uint16_t udp_port;
9245 : : };
9246 : :
9247 : : static void
9248 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9249 : : __rte_unused struct cmdline *cl,
9250 : : __rte_unused void *data)
9251 : : {
9252 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
9253 : : struct rte_eth_udp_tunnel tunnel_udp;
9254 : : int ret = 0;
9255 : :
9256 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9257 : 0 : return;
9258 : :
9259 : 0 : tunnel_udp.udp_port = res->udp_port;
9260 : :
9261 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
9262 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9263 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
9264 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9265 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9266 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9267 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
9268 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9269 : : } else {
9270 : 0 : fprintf(stderr, "Invalid tunnel type\n");
9271 : 0 : return;
9272 : : }
9273 : :
9274 : 0 : if (!strcmp(res->action, "add"))
9275 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9276 : : &tunnel_udp);
9277 : : else
9278 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9279 : : &tunnel_udp);
9280 : :
9281 : 0 : if (ret < 0)
9282 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
9283 : : strerror(-ret));
9284 : : }
9285 : :
9286 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9287 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9288 : : "port");
9289 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9290 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9291 : : "config");
9292 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9293 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9294 : : RTE_UINT16);
9295 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9296 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9297 : : udp_tunnel_port,
9298 : : "udp_tunnel_port");
9299 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9300 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9301 : : "add#rm");
9302 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9303 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9304 : : "vxlan#geneve#vxlan-gpe#ecpri");
9305 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9306 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9307 : : RTE_UINT16);
9308 : :
9309 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9310 : : .f = cmd_cfg_tunnel_udp_port_parsed,
9311 : : .data = NULL,
9312 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9313 : : "geneve|vxlan-gpe|ecpri <udp_port>",
9314 : : .tokens = {
9315 : : (void *)&cmd_config_tunnel_udp_port_port,
9316 : : (void *)&cmd_config_tunnel_udp_port_config,
9317 : : (void *)&cmd_config_tunnel_udp_port_port_id,
9318 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9319 : : (void *)&cmd_config_tunnel_udp_port_action,
9320 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9321 : : (void *)&cmd_config_tunnel_udp_port_value,
9322 : : NULL,
9323 : : },
9324 : : };
9325 : :
9326 : : /* ******************************************************************************** */
9327 : :
9328 : : struct cmd_dump_simple_result {
9329 : : cmdline_fixed_string_t dump;
9330 : : cmdline_fixed_string_t obj;
9331 : : cmdline_fixed_string_t name;
9332 : : };
9333 : : static cmdline_parse_token_string_t cmd_dump_simple_dump =
9334 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, dump, "dump");
9335 : : static cmdline_parse_token_string_t cmd_dump_simple_obj =
9336 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9337 : : "physmem#"
9338 : : "socket_mem#"
9339 : : "memzone#"
9340 : : "struct_sizes#"
9341 : : "ring#"
9342 : : "mempool#"
9343 : : "devargs#"
9344 : : "lcores#"
9345 : : "trace#"
9346 : : "log_types"
9347 : : );
9348 : : static cmdline_parse_token_string_t cmd_dump_named_obj =
9349 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9350 : : "ring#"
9351 : : "mempool#"
9352 : : );
9353 : : static cmdline_parse_token_string_t cmd_dump_named_name =
9354 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, name, NULL);
9355 : :
9356 : : static void
9357 : 0 : dump_struct_sizes(void)
9358 : : {
9359 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9360 : : DUMP_SIZE(struct rte_mbuf);
9361 : : DUMP_SIZE(struct rte_mempool);
9362 : : DUMP_SIZE(struct rte_ring);
9363 : : #undef DUMP_SIZE
9364 : 0 : }
9365 : :
9366 : : /* Dump the socket memory statistics on console */
9367 : : static void
9368 : 0 : dump_socket_mem(FILE *f)
9369 : : {
9370 : : struct rte_malloc_socket_stats socket_stats;
9371 : : unsigned int i;
9372 : : size_t total = 0;
9373 : : size_t alloc = 0;
9374 : : size_t free = 0;
9375 : : unsigned int n_alloc = 0;
9376 : : unsigned int n_free = 0;
9377 : : static size_t last_allocs;
9378 : : static size_t last_total;
9379 : :
9380 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9381 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9382 : 0 : !socket_stats.heap_totalsz_bytes)
9383 : 0 : continue;
9384 : 0 : total += socket_stats.heap_totalsz_bytes;
9385 : 0 : alloc += socket_stats.heap_allocsz_bytes;
9386 : 0 : free += socket_stats.heap_freesz_bytes;
9387 : 0 : n_alloc += socket_stats.alloc_count;
9388 : 0 : n_free += socket_stats.free_count;
9389 : 0 : fprintf(f,
9390 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9391 : : i,
9392 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9393 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9394 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
9395 : 0 : (double)socket_stats.heap_totalsz_bytes,
9396 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9397 : : socket_stats.alloc_count,
9398 : : socket_stats.free_count);
9399 : : }
9400 : 0 : fprintf(f,
9401 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9402 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9403 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
9404 : 0 : (double)free / (1024 * 1024),
9405 : : n_alloc, n_free);
9406 : 0 : if (last_allocs)
9407 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9408 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
9409 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
9410 : 0 : last_allocs = alloc;
9411 : 0 : last_total = total;
9412 : 0 : }
9413 : :
9414 : 0 : static void cmd_dump_simple_parsed(void *parsed_result,
9415 : : struct cmdline *cl,
9416 : : __rte_unused void *data)
9417 : : {
9418 : : struct cmd_dump_simple_result *res = parsed_result;
9419 : :
9420 : 0 : if (strcmp(res->obj, "physmem") == 0)
9421 : 0 : rte_dump_physmem_layout(stdout);
9422 : 0 : else if (strcmp(res->obj, "socket_mem") == 0)
9423 : 0 : dump_socket_mem(stdout);
9424 : 0 : else if (strcmp(res->obj, "memzone") == 0)
9425 : 0 : rte_memzone_dump(stdout);
9426 : 0 : else if (strcmp(res->obj, "struct_sizes") == 0)
9427 : 0 : dump_struct_sizes();
9428 : 0 : else if (strcmp(res->obj, "ring") == 0) {
9429 : 0 : if (strcmp(res->name, "") == 0) {
9430 : 0 : rte_ring_list_dump(stdout);
9431 : : } else {
9432 : : struct rte_ring *r;
9433 : 0 : r = rte_ring_lookup(res->name);
9434 : 0 : if (r == NULL) {
9435 : 0 : cmdline_printf(cl, "Cannot find ring\n");
9436 : 0 : return;
9437 : : }
9438 : 0 : rte_ring_dump(stdout, r);
9439 : : }
9440 : 0 : } else if (strcmp(res->obj, "mempool") == 0) {
9441 : 0 : if (strcmp(res->name, "") == 0) {
9442 : 0 : rte_mempool_list_dump(stdout);
9443 : : } else {
9444 : : struct rte_mempool *mp;
9445 : 0 : mp = rte_mempool_lookup(res->name);
9446 : 0 : if (mp == NULL) {
9447 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
9448 : 0 : return;
9449 : : }
9450 : 0 : rte_mempool_dump(stdout, mp);
9451 : : }
9452 : 0 : } else if (strcmp(res->obj, "devargs") == 0)
9453 : 0 : rte_devargs_dump(stdout);
9454 : 0 : else if (strcmp(res->obj, "lcores") == 0)
9455 : 0 : rte_lcore_dump(stdout);
9456 : 0 : else if (strcmp(res->obj, "trace") == 0)
9457 : : #ifdef RTE_EXEC_ENV_WINDOWS
9458 : : cmdline_printf(cl, "trace is not supported on Windows\n");
9459 : : #else
9460 : 0 : rte_trace_save();
9461 : : #endif
9462 : 0 : else if (strcmp(res->obj, "log_types") == 0)
9463 : 0 : rte_log_dump(stdout);
9464 : : }
9465 : :
9466 : : static cmdline_parse_inst_t cmd_dump_simple = {
9467 : : .f = cmd_dump_simple_parsed,
9468 : : .help_str = "Dump objects",
9469 : : .tokens = {
9470 : : (void *)&cmd_dump_simple_dump,
9471 : : (void *)&cmd_dump_simple_obj,
9472 : : NULL,
9473 : : },
9474 : : };
9475 : : static cmdline_parse_inst_t cmd_dump_named = {
9476 : : .f = cmd_dump_simple_parsed,
9477 : : .help_str = "dump ring|mempool <name>: Dump one ring/mempool",
9478 : : .tokens = {
9479 : : (void *)&cmd_dump_simple_dump,
9480 : : (void *)&cmd_dump_named_obj,
9481 : : (void *)&cmd_dump_named_name,
9482 : : NULL,
9483 : : },
9484 : : };
9485 : :
9486 : : struct cmd_dump_mbuf_history_result {
9487 : : cmdline_fixed_string_t dump;
9488 : : cmdline_fixed_string_t mbuf;
9489 : : cmdline_fixed_string_t history;
9490 : : cmdline_fixed_string_t obj;
9491 : : cmdline_fixed_string_t name;
9492 : : cmdline_fixed_string_t addr;
9493 : : cmdline_fixed_string_t file;
9494 : : };
9495 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_dump =
9496 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, dump, "dump");
9497 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_mbuf =
9498 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, mbuf, "mbuf");
9499 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_history =
9500 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, history, "history");
9501 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_obj =
9502 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, NULL);
9503 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_pool =
9504 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, "pool");
9505 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_name =
9506 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, name, NULL);
9507 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_file =
9508 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, file, NULL);
9509 : :
9510 : 0 : static void cmd_dump_mbuf_history_parsed(void *parsed_result,
9511 : : struct cmdline *cl,
9512 : : __rte_unused void *data)
9513 : : {
9514 : : struct cmd_dump_mbuf_history_result *res = parsed_result;
9515 : 0 : FILE *out = stdout;
9516 : :
9517 : 0 : if (strcmp(res->file, "") != 0) {
9518 : 0 : out = fopen(res->file, "w");
9519 : 0 : if (out == NULL) {
9520 : 0 : cmdline_printf(cl,
9521 : : "Failed to open file '%s'\n",
9522 : : res->file);
9523 : 0 : return;
9524 : : }
9525 : : }
9526 : :
9527 : 0 : if (strcmp(res->obj, "all") == 0) {
9528 : 0 : rte_mbuf_history_dump_all(out);
9529 : 0 : if (out != stdout)
9530 : 0 : cmdline_printf(cl,
9531 : : "Dump written in '%s'\n",
9532 : 0 : res->file);
9533 : 0 : } else if (strcmp(res->obj, "pool") == 0) {
9534 : 0 : struct rte_mempool *mp = rte_mempool_lookup(res->name);
9535 : 0 : if (mp == NULL) {
9536 : 0 : cmdline_printf(cl,
9537 : : "Failed to find mempool '%s'\n",
9538 : : res->name);
9539 : 0 : goto out_close;
9540 : : }
9541 : 0 : rte_mbuf_history_dump_mempool(out, mp);
9542 : 0 : if (out != stdout)
9543 : 0 : cmdline_printf(cl,
9544 : : "Dump for mempool '%s' written in '%s'\n",
9545 : 0 : res->name, res->file);
9546 : : } else {
9547 : : struct rte_mbuf *mbuf;
9548 : : uintptr_t mbuf_addr;
9549 : 0 : if (sscanf(res->obj, "0x%" SCNxPTR, &mbuf_addr) != 1) {
9550 : 0 : cmdline_printf(cl,
9551 : : "Invalid mbuf pointer format. Use 0x<address>\n");
9552 : 0 : goto out_close;
9553 : : }
9554 : 0 : mbuf = (struct rte_mbuf *)mbuf_addr;
9555 : 0 : rte_mbuf_history_dump(out, mbuf);
9556 : 0 : if (out != stdout)
9557 : 0 : cmdline_printf(cl,
9558 : : "Dump for mbuf '%p' written in '%s'\n",
9559 : 0 : mbuf, res->file);
9560 : : }
9561 : :
9562 : 0 : out_close:
9563 : 0 : if (out != stdout)
9564 : 0 : fclose(out);
9565 : : }
9566 : :
9567 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_stdout = {
9568 : : .f = cmd_dump_mbuf_history_parsed,
9569 : : .help_str = "dump mbuf history all|<address>",
9570 : : .tokens = {
9571 : : (void *)&cmd_dump_mbuf_history_dump,
9572 : : (void *)&cmd_dump_mbuf_history_mbuf,
9573 : : (void *)&cmd_dump_mbuf_history_history,
9574 : : (void *)&cmd_dump_mbuf_history_obj,
9575 : : NULL,
9576 : : },
9577 : : };
9578 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_to_file = {
9579 : : .f = cmd_dump_mbuf_history_parsed,
9580 : : .help_str = "dump mbuf history all|<address> [file]",
9581 : : .tokens = {
9582 : : (void *)&cmd_dump_mbuf_history_dump,
9583 : : (void *)&cmd_dump_mbuf_history_mbuf,
9584 : : (void *)&cmd_dump_mbuf_history_history,
9585 : : (void *)&cmd_dump_mbuf_history_obj,
9586 : : (void *)&cmd_dump_mbuf_history_file,
9587 : : NULL,
9588 : : },
9589 : : };
9590 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_stdout = {
9591 : : .f = cmd_dump_mbuf_history_parsed,
9592 : : .help_str = "dump mbuf pool history <name>",
9593 : : .tokens = {
9594 : : (void *)&cmd_dump_mbuf_history_dump,
9595 : : (void *)&cmd_dump_mbuf_history_mbuf,
9596 : : (void *)&cmd_dump_mbuf_history_pool,
9597 : : (void *)&cmd_dump_mbuf_history_history,
9598 : : (void *)&cmd_dump_mbuf_history_name,
9599 : : NULL,
9600 : : },
9601 : : };
9602 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_to_file = {
9603 : : .f = cmd_dump_mbuf_history_parsed,
9604 : : .help_str = "dump mbuf pool history <name> [file]",
9605 : : .tokens = {
9606 : : (void *)&cmd_dump_mbuf_history_dump,
9607 : : (void *)&cmd_dump_mbuf_history_mbuf,
9608 : : (void *)&cmd_dump_mbuf_history_pool,
9609 : : (void *)&cmd_dump_mbuf_history_history,
9610 : : (void *)&cmd_dump_mbuf_history_name,
9611 : : (void *)&cmd_dump_mbuf_history_file,
9612 : : NULL,
9613 : : },
9614 : : };
9615 : :
9616 : : /* *** Filters Control *** */
9617 : :
9618 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9619 : : do { \
9620 : : if ((ip_addr).family == AF_INET) \
9621 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
9622 : : else { \
9623 : : fprintf(stderr, "invalid parameter.\n"); \
9624 : : return; \
9625 : : } \
9626 : : } while (0)
9627 : :
9628 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9629 : : do { \
9630 : : if ((ip_addr).family == AF_INET6) \
9631 : : ip = ip_addr.addr.ipv6; \
9632 : : else { \
9633 : : fprintf(stderr, "invalid parameter.\n"); \
9634 : : return; \
9635 : : } \
9636 : : } while (0)
9637 : :
9638 : : /* Generic flow interface command. */
9639 : : extern cmdline_parse_inst_t cmd_flow;
9640 : :
9641 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9642 : : struct cmd_mcast_addr_result {
9643 : : cmdline_fixed_string_t mcast_addr_cmd;
9644 : : cmdline_fixed_string_t what;
9645 : : uint16_t port_num;
9646 : : struct rte_ether_addr mc_addr;
9647 : : };
9648 : :
9649 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
9650 : : __rte_unused struct cmdline *cl,
9651 : : __rte_unused void *data)
9652 : : {
9653 : : struct cmd_mcast_addr_result *res = parsed_result;
9654 : :
9655 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
9656 : 0 : fprintf(stderr,
9657 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
9658 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
9659 : 0 : return;
9660 : : }
9661 : 0 : if (strcmp(res->what, "add") == 0)
9662 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
9663 : : else
9664 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
9665 : : }
9666 : :
9667 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9668 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9669 : : mcast_addr_cmd, "mcast_addr");
9670 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
9671 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9672 : : "add#remove");
9673 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9674 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9675 : : RTE_UINT16);
9676 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9677 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9678 : :
9679 : : static cmdline_parse_inst_t cmd_mcast_addr = {
9680 : : .f = cmd_mcast_addr_parsed,
9681 : : .data = (void *)0,
9682 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
9683 : : "Add/Remove multicast MAC address on port_id",
9684 : : .tokens = {
9685 : : (void *)&cmd_mcast_addr_cmd,
9686 : : (void *)&cmd_mcast_addr_what,
9687 : : (void *)&cmd_mcast_addr_portnum,
9688 : : (void *)&cmd_mcast_addr_addr,
9689 : : NULL,
9690 : : },
9691 : : };
9692 : :
9693 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
9694 : : struct cmd_mcast_addr_flush_result {
9695 : : cmdline_fixed_string_t mcast_addr_cmd;
9696 : : cmdline_fixed_string_t what;
9697 : : uint16_t port_num;
9698 : : };
9699 : :
9700 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
9701 : : __rte_unused struct cmdline *cl,
9702 : : __rte_unused void *data)
9703 : : {
9704 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
9705 : :
9706 : 0 : mcast_addr_flush(res->port_num);
9707 : 0 : }
9708 : :
9709 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
9710 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9711 : : mcast_addr_cmd, "mcast_addr");
9712 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
9713 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9714 : : "flush");
9715 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
9716 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9717 : : RTE_UINT16);
9718 : :
9719 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
9720 : : .f = cmd_mcast_addr_flush_parsed,
9721 : : .data = (void *)0,
9722 : : .help_str = "mcast_addr flush <port_id> : "
9723 : : "flush all multicast MAC addresses on port_id",
9724 : : .tokens = {
9725 : : (void *)&cmd_mcast_addr_flush_cmd,
9726 : : (void *)&cmd_mcast_addr_flush_what,
9727 : : (void *)&cmd_mcast_addr_flush_portnum,
9728 : : NULL,
9729 : : },
9730 : : };
9731 : :
9732 : : /* vf vlan anti spoof configuration */
9733 : :
9734 : : /* Common result structure for vf vlan anti spoof */
9735 : : struct cmd_vf_vlan_anti_spoof_result {
9736 : : cmdline_fixed_string_t set;
9737 : : cmdline_fixed_string_t vf;
9738 : : cmdline_fixed_string_t vlan;
9739 : : cmdline_fixed_string_t antispoof;
9740 : : portid_t port_id;
9741 : : uint32_t vf_id;
9742 : : cmdline_fixed_string_t on_off;
9743 : : };
9744 : :
9745 : : /* Common CLI fields for vf vlan anti spoof enable disable */
9746 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
9747 : : TOKEN_STRING_INITIALIZER
9748 : : (struct cmd_vf_vlan_anti_spoof_result,
9749 : : set, "set");
9750 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
9751 : : TOKEN_STRING_INITIALIZER
9752 : : (struct cmd_vf_vlan_anti_spoof_result,
9753 : : vf, "vf");
9754 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
9755 : : TOKEN_STRING_INITIALIZER
9756 : : (struct cmd_vf_vlan_anti_spoof_result,
9757 : : vlan, "vlan");
9758 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
9759 : : TOKEN_STRING_INITIALIZER
9760 : : (struct cmd_vf_vlan_anti_spoof_result,
9761 : : antispoof, "antispoof");
9762 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
9763 : : TOKEN_NUM_INITIALIZER
9764 : : (struct cmd_vf_vlan_anti_spoof_result,
9765 : : port_id, RTE_UINT16);
9766 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
9767 : : TOKEN_NUM_INITIALIZER
9768 : : (struct cmd_vf_vlan_anti_spoof_result,
9769 : : vf_id, RTE_UINT32);
9770 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
9771 : : TOKEN_STRING_INITIALIZER
9772 : : (struct cmd_vf_vlan_anti_spoof_result,
9773 : : on_off, "on#off");
9774 : :
9775 : : static void
9776 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
9777 : : void *parsed_result,
9778 : : __rte_unused struct cmdline *cl,
9779 : : __rte_unused void *data)
9780 : : {
9781 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
9782 : : int ret = -ENOTSUP;
9783 : :
9784 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9785 : :
9786 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9787 : : return;
9788 : :
9789 : : #ifdef RTE_NET_IXGBE
9790 : : if (ret == -ENOTSUP)
9791 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
9792 : 0 : res->vf_id, is_on);
9793 : : #endif
9794 : : #ifdef RTE_NET_I40E
9795 : 0 : if (ret == -ENOTSUP)
9796 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
9797 : 0 : res->vf_id, is_on);
9798 : : #endif
9799 : : #ifdef RTE_NET_BNXT
9800 : 0 : if (ret == -ENOTSUP)
9801 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
9802 : 0 : res->vf_id, is_on);
9803 : : #endif
9804 : :
9805 : 0 : switch (ret) {
9806 : : case 0:
9807 : : break;
9808 : 0 : case -EINVAL:
9809 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
9810 : : break;
9811 : 0 : case -ENODEV:
9812 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9813 : : break;
9814 : 0 : case -ENOTSUP:
9815 : 0 : fprintf(stderr, "function not implemented\n");
9816 : : break;
9817 : 0 : default:
9818 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9819 : : }
9820 : : }
9821 : :
9822 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
9823 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
9824 : : .data = NULL,
9825 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
9826 : : .tokens = {
9827 : : (void *)&cmd_vf_vlan_anti_spoof_set,
9828 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
9829 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
9830 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
9831 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
9832 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
9833 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
9834 : : NULL,
9835 : : },
9836 : : };
9837 : :
9838 : : /* vf mac anti spoof configuration */
9839 : :
9840 : : /* Common result structure for vf mac anti spoof */
9841 : : struct cmd_vf_mac_anti_spoof_result {
9842 : : cmdline_fixed_string_t set;
9843 : : cmdline_fixed_string_t vf;
9844 : : cmdline_fixed_string_t mac;
9845 : : cmdline_fixed_string_t antispoof;
9846 : : portid_t port_id;
9847 : : uint32_t vf_id;
9848 : : cmdline_fixed_string_t on_off;
9849 : : };
9850 : :
9851 : : /* Common CLI fields for vf mac anti spoof enable disable */
9852 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
9853 : : TOKEN_STRING_INITIALIZER
9854 : : (struct cmd_vf_mac_anti_spoof_result,
9855 : : set, "set");
9856 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
9857 : : TOKEN_STRING_INITIALIZER
9858 : : (struct cmd_vf_mac_anti_spoof_result,
9859 : : vf, "vf");
9860 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
9861 : : TOKEN_STRING_INITIALIZER
9862 : : (struct cmd_vf_mac_anti_spoof_result,
9863 : : mac, "mac");
9864 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
9865 : : TOKEN_STRING_INITIALIZER
9866 : : (struct cmd_vf_mac_anti_spoof_result,
9867 : : antispoof, "antispoof");
9868 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
9869 : : TOKEN_NUM_INITIALIZER
9870 : : (struct cmd_vf_mac_anti_spoof_result,
9871 : : port_id, RTE_UINT16);
9872 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
9873 : : TOKEN_NUM_INITIALIZER
9874 : : (struct cmd_vf_mac_anti_spoof_result,
9875 : : vf_id, RTE_UINT32);
9876 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
9877 : : TOKEN_STRING_INITIALIZER
9878 : : (struct cmd_vf_mac_anti_spoof_result,
9879 : : on_off, "on#off");
9880 : :
9881 : : static void
9882 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
9883 : : void *parsed_result,
9884 : : __rte_unused struct cmdline *cl,
9885 : : __rte_unused void *data)
9886 : : {
9887 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
9888 : : int ret = -ENOTSUP;
9889 : :
9890 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9891 : :
9892 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9893 : : return;
9894 : :
9895 : : #ifdef RTE_NET_IXGBE
9896 : : if (ret == -ENOTSUP)
9897 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
9898 : 0 : res->vf_id, is_on);
9899 : : #endif
9900 : : #ifdef RTE_NET_I40E
9901 : 0 : if (ret == -ENOTSUP)
9902 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
9903 : 0 : res->vf_id, is_on);
9904 : : #endif
9905 : : #ifdef RTE_NET_BNXT
9906 : 0 : if (ret == -ENOTSUP)
9907 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
9908 : 0 : res->vf_id, is_on);
9909 : : #endif
9910 : :
9911 : 0 : switch (ret) {
9912 : : case 0:
9913 : : break;
9914 : 0 : case -EINVAL:
9915 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9916 : : res->vf_id, is_on);
9917 : : break;
9918 : 0 : case -ENODEV:
9919 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9920 : : break;
9921 : 0 : case -ENOTSUP:
9922 : 0 : fprintf(stderr, "function not implemented\n");
9923 : : break;
9924 : 0 : default:
9925 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9926 : : }
9927 : : }
9928 : :
9929 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
9930 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
9931 : : .data = NULL,
9932 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
9933 : : .tokens = {
9934 : : (void *)&cmd_vf_mac_anti_spoof_set,
9935 : : (void *)&cmd_vf_mac_anti_spoof_vf,
9936 : : (void *)&cmd_vf_mac_anti_spoof_mac,
9937 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
9938 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
9939 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
9940 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
9941 : : NULL,
9942 : : },
9943 : : };
9944 : :
9945 : : /* vf vlan strip queue configuration */
9946 : :
9947 : : /* Common result structure for vf mac anti spoof */
9948 : : struct cmd_vf_vlan_stripq_result {
9949 : : cmdline_fixed_string_t set;
9950 : : cmdline_fixed_string_t vf;
9951 : : cmdline_fixed_string_t vlan;
9952 : : cmdline_fixed_string_t stripq;
9953 : : portid_t port_id;
9954 : : uint16_t vf_id;
9955 : : cmdline_fixed_string_t on_off;
9956 : : };
9957 : :
9958 : : /* Common CLI fields for vf vlan strip enable disable */
9959 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
9960 : : TOKEN_STRING_INITIALIZER
9961 : : (struct cmd_vf_vlan_stripq_result,
9962 : : set, "set");
9963 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
9964 : : TOKEN_STRING_INITIALIZER
9965 : : (struct cmd_vf_vlan_stripq_result,
9966 : : vf, "vf");
9967 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
9968 : : TOKEN_STRING_INITIALIZER
9969 : : (struct cmd_vf_vlan_stripq_result,
9970 : : vlan, "vlan");
9971 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
9972 : : TOKEN_STRING_INITIALIZER
9973 : : (struct cmd_vf_vlan_stripq_result,
9974 : : stripq, "stripq");
9975 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
9976 : : TOKEN_NUM_INITIALIZER
9977 : : (struct cmd_vf_vlan_stripq_result,
9978 : : port_id, RTE_UINT16);
9979 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
9980 : : TOKEN_NUM_INITIALIZER
9981 : : (struct cmd_vf_vlan_stripq_result,
9982 : : vf_id, RTE_UINT16);
9983 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
9984 : : TOKEN_STRING_INITIALIZER
9985 : : (struct cmd_vf_vlan_stripq_result,
9986 : : on_off, "on#off");
9987 : :
9988 : : static void
9989 : 0 : cmd_set_vf_vlan_stripq_parsed(
9990 : : void *parsed_result,
9991 : : __rte_unused struct cmdline *cl,
9992 : : __rte_unused void *data)
9993 : : {
9994 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
9995 : : int ret = -ENOTSUP;
9996 : :
9997 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9998 : :
9999 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10000 : : return;
10001 : :
10002 : : #ifdef RTE_NET_IXGBE
10003 : : if (ret == -ENOTSUP)
10004 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
10005 : 0 : res->vf_id, is_on);
10006 : : #endif
10007 : : #ifdef RTE_NET_I40E
10008 : 0 : if (ret == -ENOTSUP)
10009 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
10010 : 0 : res->vf_id, is_on);
10011 : : #endif
10012 : : #ifdef RTE_NET_BNXT
10013 : 0 : if (ret == -ENOTSUP)
10014 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
10015 : 0 : res->vf_id, is_on);
10016 : : #endif
10017 : :
10018 : 0 : switch (ret) {
10019 : : case 0:
10020 : : break;
10021 : 0 : case -EINVAL:
10022 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
10023 : 0 : res->vf_id, is_on);
10024 : : break;
10025 : 0 : case -ENODEV:
10026 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10027 : : break;
10028 : 0 : case -ENOTSUP:
10029 : 0 : fprintf(stderr, "function not implemented\n");
10030 : : break;
10031 : 0 : default:
10032 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10033 : : }
10034 : : }
10035 : :
10036 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
10037 : : .f = cmd_set_vf_vlan_stripq_parsed,
10038 : : .data = NULL,
10039 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
10040 : : .tokens = {
10041 : : (void *)&cmd_vf_vlan_stripq_set,
10042 : : (void *)&cmd_vf_vlan_stripq_vf,
10043 : : (void *)&cmd_vf_vlan_stripq_vlan,
10044 : : (void *)&cmd_vf_vlan_stripq_stripq,
10045 : : (void *)&cmd_vf_vlan_stripq_port_id,
10046 : : (void *)&cmd_vf_vlan_stripq_vf_id,
10047 : : (void *)&cmd_vf_vlan_stripq_on_off,
10048 : : NULL,
10049 : : },
10050 : : };
10051 : :
10052 : : /* vf vlan insert configuration */
10053 : :
10054 : : /* Common result structure for vf vlan insert */
10055 : : struct cmd_vf_vlan_insert_result {
10056 : : cmdline_fixed_string_t set;
10057 : : cmdline_fixed_string_t vf;
10058 : : cmdline_fixed_string_t vlan;
10059 : : cmdline_fixed_string_t insert;
10060 : : portid_t port_id;
10061 : : uint16_t vf_id;
10062 : : uint16_t vlan_id;
10063 : : };
10064 : :
10065 : : /* Common CLI fields for vf vlan insert enable disable */
10066 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
10067 : : TOKEN_STRING_INITIALIZER
10068 : : (struct cmd_vf_vlan_insert_result,
10069 : : set, "set");
10070 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
10071 : : TOKEN_STRING_INITIALIZER
10072 : : (struct cmd_vf_vlan_insert_result,
10073 : : vf, "vf");
10074 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
10075 : : TOKEN_STRING_INITIALIZER
10076 : : (struct cmd_vf_vlan_insert_result,
10077 : : vlan, "vlan");
10078 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
10079 : : TOKEN_STRING_INITIALIZER
10080 : : (struct cmd_vf_vlan_insert_result,
10081 : : insert, "insert");
10082 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
10083 : : TOKEN_NUM_INITIALIZER
10084 : : (struct cmd_vf_vlan_insert_result,
10085 : : port_id, RTE_UINT16);
10086 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
10087 : : TOKEN_NUM_INITIALIZER
10088 : : (struct cmd_vf_vlan_insert_result,
10089 : : vf_id, RTE_UINT16);
10090 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
10091 : : TOKEN_NUM_INITIALIZER
10092 : : (struct cmd_vf_vlan_insert_result,
10093 : : vlan_id, RTE_UINT16);
10094 : :
10095 : : static void
10096 : 0 : cmd_set_vf_vlan_insert_parsed(
10097 : : void *parsed_result,
10098 : : __rte_unused struct cmdline *cl,
10099 : : __rte_unused void *data)
10100 : : {
10101 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
10102 : : int ret = -ENOTSUP;
10103 : :
10104 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10105 : : return;
10106 : :
10107 : : #ifdef RTE_NET_IXGBE
10108 : : if (ret == -ENOTSUP)
10109 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
10110 : 0 : res->vlan_id);
10111 : : #endif
10112 : : #ifdef RTE_NET_I40E
10113 : 0 : if (ret == -ENOTSUP)
10114 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
10115 : 0 : res->vlan_id);
10116 : : #endif
10117 : : #ifdef RTE_NET_BNXT
10118 : 0 : if (ret == -ENOTSUP)
10119 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
10120 : 0 : res->vlan_id);
10121 : : #endif
10122 : :
10123 : 0 : switch (ret) {
10124 : : case 0:
10125 : : break;
10126 : 0 : case -EINVAL:
10127 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
10128 : 0 : res->vf_id, res->vlan_id);
10129 : : break;
10130 : 0 : case -ENODEV:
10131 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10132 : : break;
10133 : 0 : case -ENOTSUP:
10134 : 0 : fprintf(stderr, "function not implemented\n");
10135 : : break;
10136 : 0 : default:
10137 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10138 : : }
10139 : : }
10140 : :
10141 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
10142 : : .f = cmd_set_vf_vlan_insert_parsed,
10143 : : .data = NULL,
10144 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
10145 : : .tokens = {
10146 : : (void *)&cmd_vf_vlan_insert_set,
10147 : : (void *)&cmd_vf_vlan_insert_vf,
10148 : : (void *)&cmd_vf_vlan_insert_vlan,
10149 : : (void *)&cmd_vf_vlan_insert_insert,
10150 : : (void *)&cmd_vf_vlan_insert_port_id,
10151 : : (void *)&cmd_vf_vlan_insert_vf_id,
10152 : : (void *)&cmd_vf_vlan_insert_vlan_id,
10153 : : NULL,
10154 : : },
10155 : : };
10156 : :
10157 : : /* tx loopback configuration */
10158 : :
10159 : : /* Common result structure for tx loopback */
10160 : : struct cmd_tx_loopback_result {
10161 : : cmdline_fixed_string_t set;
10162 : : cmdline_fixed_string_t tx;
10163 : : cmdline_fixed_string_t loopback;
10164 : : portid_t port_id;
10165 : : cmdline_fixed_string_t on_off;
10166 : : };
10167 : :
10168 : : /* Common CLI fields for tx loopback enable disable */
10169 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
10170 : : TOKEN_STRING_INITIALIZER
10171 : : (struct cmd_tx_loopback_result,
10172 : : set, "set");
10173 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
10174 : : TOKEN_STRING_INITIALIZER
10175 : : (struct cmd_tx_loopback_result,
10176 : : tx, "tx");
10177 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
10178 : : TOKEN_STRING_INITIALIZER
10179 : : (struct cmd_tx_loopback_result,
10180 : : loopback, "loopback");
10181 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
10182 : : TOKEN_NUM_INITIALIZER
10183 : : (struct cmd_tx_loopback_result,
10184 : : port_id, RTE_UINT16);
10185 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
10186 : : TOKEN_STRING_INITIALIZER
10187 : : (struct cmd_tx_loopback_result,
10188 : : on_off, "on#off");
10189 : :
10190 : : static void
10191 : 0 : cmd_set_tx_loopback_parsed(
10192 : : void *parsed_result,
10193 : : __rte_unused struct cmdline *cl,
10194 : : __rte_unused void *data)
10195 : : {
10196 : : struct cmd_tx_loopback_result *res = parsed_result;
10197 : : int ret = -ENOTSUP;
10198 : :
10199 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10200 : :
10201 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10202 : : return;
10203 : :
10204 : : #ifdef RTE_NET_IXGBE
10205 : : if (ret == -ENOTSUP)
10206 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
10207 : : #endif
10208 : : #ifdef RTE_NET_I40E
10209 : 0 : if (ret == -ENOTSUP)
10210 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
10211 : : #endif
10212 : : #ifdef RTE_NET_BNXT
10213 : 0 : if (ret == -ENOTSUP)
10214 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
10215 : : #endif
10216 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
10217 : 0 : if (ret == -ENOTSUP)
10218 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
10219 : : #endif
10220 : :
10221 : 0 : switch (ret) {
10222 : : case 0:
10223 : : break;
10224 : 0 : case -EINVAL:
10225 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10226 : : break;
10227 : 0 : case -ENODEV:
10228 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10229 : : break;
10230 : 0 : case -ENOTSUP:
10231 : 0 : fprintf(stderr, "function not implemented\n");
10232 : : break;
10233 : 0 : default:
10234 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10235 : : }
10236 : : }
10237 : :
10238 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
10239 : : .f = cmd_set_tx_loopback_parsed,
10240 : : .data = NULL,
10241 : : .help_str = "set tx loopback <port_id> on|off",
10242 : : .tokens = {
10243 : : (void *)&cmd_tx_loopback_set,
10244 : : (void *)&cmd_tx_loopback_tx,
10245 : : (void *)&cmd_tx_loopback_loopback,
10246 : : (void *)&cmd_tx_loopback_port_id,
10247 : : (void *)&cmd_tx_loopback_on_off,
10248 : : NULL,
10249 : : },
10250 : : };
10251 : :
10252 : : /* all queues drop enable configuration */
10253 : :
10254 : : /* Common result structure for all queues drop enable */
10255 : : struct cmd_all_queues_drop_en_result {
10256 : : cmdline_fixed_string_t set;
10257 : : cmdline_fixed_string_t all;
10258 : : cmdline_fixed_string_t queues;
10259 : : cmdline_fixed_string_t drop;
10260 : : portid_t port_id;
10261 : : cmdline_fixed_string_t on_off;
10262 : : };
10263 : :
10264 : : /* Common CLI fields for tx loopback enable disable */
10265 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
10266 : : TOKEN_STRING_INITIALIZER
10267 : : (struct cmd_all_queues_drop_en_result,
10268 : : set, "set");
10269 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
10270 : : TOKEN_STRING_INITIALIZER
10271 : : (struct cmd_all_queues_drop_en_result,
10272 : : all, "all");
10273 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
10274 : : TOKEN_STRING_INITIALIZER
10275 : : (struct cmd_all_queues_drop_en_result,
10276 : : queues, "queues");
10277 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
10278 : : TOKEN_STRING_INITIALIZER
10279 : : (struct cmd_all_queues_drop_en_result,
10280 : : drop, "drop");
10281 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
10282 : : TOKEN_NUM_INITIALIZER
10283 : : (struct cmd_all_queues_drop_en_result,
10284 : : port_id, RTE_UINT16);
10285 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
10286 : : TOKEN_STRING_INITIALIZER
10287 : : (struct cmd_all_queues_drop_en_result,
10288 : : on_off, "on#off");
10289 : :
10290 : : static void
10291 : 0 : cmd_set_all_queues_drop_en_parsed(
10292 : : void *parsed_result,
10293 : : __rte_unused struct cmdline *cl,
10294 : : __rte_unused void *data)
10295 : : {
10296 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
10297 : : int ret = -ENOTSUP;
10298 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10299 : :
10300 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10301 : : return;
10302 : :
10303 : : #ifdef RTE_NET_IXGBE
10304 : : if (ret == -ENOTSUP)
10305 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
10306 : : #endif
10307 : : #ifdef RTE_NET_BNXT
10308 : 0 : if (ret == -ENOTSUP)
10309 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
10310 : : #endif
10311 : 0 : switch (ret) {
10312 : : case 0:
10313 : : break;
10314 : 0 : case -EINVAL:
10315 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10316 : : break;
10317 : 0 : case -ENODEV:
10318 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10319 : : break;
10320 : 0 : case -ENOTSUP:
10321 : 0 : fprintf(stderr, "function not implemented\n");
10322 : : break;
10323 : 0 : default:
10324 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10325 : : }
10326 : : }
10327 : :
10328 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
10329 : : .f = cmd_set_all_queues_drop_en_parsed,
10330 : : .data = NULL,
10331 : : .help_str = "set all queues drop <port_id> on|off",
10332 : : .tokens = {
10333 : : (void *)&cmd_all_queues_drop_en_set,
10334 : : (void *)&cmd_all_queues_drop_en_all,
10335 : : (void *)&cmd_all_queues_drop_en_queues,
10336 : : (void *)&cmd_all_queues_drop_en_drop,
10337 : : (void *)&cmd_all_queues_drop_en_port_id,
10338 : : (void *)&cmd_all_queues_drop_en_on_off,
10339 : : NULL,
10340 : : },
10341 : : };
10342 : :
10343 : : /* vf mac address configuration */
10344 : :
10345 : : /* Common result structure for vf mac address */
10346 : : struct cmd_set_vf_mac_addr_result {
10347 : : cmdline_fixed_string_t set;
10348 : : cmdline_fixed_string_t vf;
10349 : : cmdline_fixed_string_t mac;
10350 : : cmdline_fixed_string_t addr;
10351 : : portid_t port_id;
10352 : : uint16_t vf_id;
10353 : : struct rte_ether_addr mac_addr;
10354 : :
10355 : : };
10356 : :
10357 : : /* Common CLI fields for vf split drop enable disable */
10358 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
10359 : : TOKEN_STRING_INITIALIZER
10360 : : (struct cmd_set_vf_mac_addr_result,
10361 : : set, "set");
10362 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
10363 : : TOKEN_STRING_INITIALIZER
10364 : : (struct cmd_set_vf_mac_addr_result,
10365 : : vf, "vf");
10366 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
10367 : : TOKEN_STRING_INITIALIZER
10368 : : (struct cmd_set_vf_mac_addr_result,
10369 : : mac, "mac");
10370 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
10371 : : TOKEN_STRING_INITIALIZER
10372 : : (struct cmd_set_vf_mac_addr_result,
10373 : : addr, "addr");
10374 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
10375 : : TOKEN_NUM_INITIALIZER
10376 : : (struct cmd_set_vf_mac_addr_result,
10377 : : port_id, RTE_UINT16);
10378 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
10379 : : TOKEN_NUM_INITIALIZER
10380 : : (struct cmd_set_vf_mac_addr_result,
10381 : : vf_id, RTE_UINT16);
10382 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
10383 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
10384 : : mac_addr);
10385 : :
10386 : : static void
10387 : 0 : cmd_set_vf_mac_addr_parsed(
10388 : : void *parsed_result,
10389 : : __rte_unused struct cmdline *cl,
10390 : : __rte_unused void *data)
10391 : : {
10392 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
10393 : : int ret = -ENOTSUP;
10394 : :
10395 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10396 : : return;
10397 : :
10398 : : #ifdef RTE_NET_IXGBE
10399 : : if (ret == -ENOTSUP)
10400 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
10401 : : &res->mac_addr);
10402 : : #endif
10403 : : #ifdef RTE_NET_I40E
10404 : 0 : if (ret == -ENOTSUP)
10405 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
10406 : : &res->mac_addr);
10407 : : #endif
10408 : : #ifdef RTE_NET_BNXT
10409 : 0 : if (ret == -ENOTSUP)
10410 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
10411 : : &res->mac_addr);
10412 : : #endif
10413 : :
10414 : 0 : switch (ret) {
10415 : : case 0:
10416 : : break;
10417 : 0 : case -EINVAL:
10418 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
10419 : : break;
10420 : 0 : case -ENODEV:
10421 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10422 : : break;
10423 : 0 : case -ENOTSUP:
10424 : 0 : fprintf(stderr, "function not implemented\n");
10425 : : break;
10426 : 0 : default:
10427 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10428 : : }
10429 : : }
10430 : :
10431 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
10432 : : .f = cmd_set_vf_mac_addr_parsed,
10433 : : .data = NULL,
10434 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
10435 : : .tokens = {
10436 : : (void *)&cmd_set_vf_mac_addr_set,
10437 : : (void *)&cmd_set_vf_mac_addr_vf,
10438 : : (void *)&cmd_set_vf_mac_addr_mac,
10439 : : (void *)&cmd_set_vf_mac_addr_addr,
10440 : : (void *)&cmd_set_vf_mac_addr_port_id,
10441 : : (void *)&cmd_set_vf_mac_addr_vf_id,
10442 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
10443 : : NULL,
10444 : : },
10445 : : };
10446 : :
10447 : : /** Set VXLAN encapsulation details */
10448 : : struct cmd_set_vxlan_result {
10449 : : cmdline_fixed_string_t set;
10450 : : cmdline_fixed_string_t vxlan;
10451 : : cmdline_fixed_string_t pos_token;
10452 : : cmdline_fixed_string_t ip_version;
10453 : : uint32_t vlan_present:1;
10454 : : uint32_t vni;
10455 : : uint16_t udp_src;
10456 : : uint16_t udp_dst;
10457 : : cmdline_ipaddr_t ip_src;
10458 : : cmdline_ipaddr_t ip_dst;
10459 : : uint16_t tci;
10460 : : uint8_t tos;
10461 : : uint8_t ttl;
10462 : : struct rte_ether_addr eth_src;
10463 : : struct rte_ether_addr eth_dst;
10464 : : };
10465 : :
10466 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
10467 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
10468 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
10469 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
10470 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
10471 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10472 : : "vxlan-tos-ttl");
10473 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
10474 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10475 : : "vxlan-with-vlan");
10476 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
10477 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10478 : : "ip-version");
10479 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
10480 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
10481 : : "ipv4#ipv6");
10482 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
10483 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10484 : : "vni");
10485 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
10486 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
10487 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
10488 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10489 : : "udp-src");
10490 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
10491 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
10492 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
10493 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10494 : : "udp-dst");
10495 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
10496 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
10497 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
10498 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10499 : : "ip-tos");
10500 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
10501 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
10502 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
10503 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10504 : : "ip-ttl");
10505 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
10506 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
10507 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
10508 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10509 : : "ip-src");
10510 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
10511 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
10512 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
10513 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10514 : : "ip-dst");
10515 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
10516 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
10517 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
10518 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10519 : : "vlan-tci");
10520 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
10521 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
10522 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
10523 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10524 : : "eth-src");
10525 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
10526 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
10527 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
10528 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10529 : : "eth-dst");
10530 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
10531 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
10532 : :
10533 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
10534 : : __rte_unused struct cmdline *cl,
10535 : : __rte_unused void *data)
10536 : : {
10537 : : struct cmd_set_vxlan_result *res = parsed_result;
10538 : : union {
10539 : : uint32_t vxlan_id;
10540 : : uint8_t vni[4];
10541 : : } id = {
10542 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
10543 : : };
10544 : :
10545 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
10546 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
10547 : 0 : vxlan_encap_conf.select_vlan = 0;
10548 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
10549 : 0 : vxlan_encap_conf.select_vlan = 1;
10550 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
10551 : 0 : vxlan_encap_conf.select_vlan = 0;
10552 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
10553 : : }
10554 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10555 : 0 : vxlan_encap_conf.select_ipv4 = 1;
10556 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10557 : 0 : vxlan_encap_conf.select_ipv4 = 0;
10558 : : else
10559 : : return;
10560 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
10561 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10562 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10563 : 0 : vxlan_encap_conf.ip_tos = res->tos;
10564 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
10565 : 0 : if (vxlan_encap_conf.select_ipv4) {
10566 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
10567 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
10568 : : } else {
10569 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
10570 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
10571 : : }
10572 : 0 : if (vxlan_encap_conf.select_vlan)
10573 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10574 : : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
10575 : : RTE_ETHER_ADDR_LEN);
10576 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10577 : : RTE_ETHER_ADDR_LEN);
10578 : : }
10579 : :
10580 : : static cmdline_parse_inst_t cmd_set_vxlan = {
10581 : : .f = cmd_set_vxlan_parsed,
10582 : : .data = NULL,
10583 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
10584 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
10585 : : " eth-src <eth-src> eth-dst <eth-dst>",
10586 : : .tokens = {
10587 : : (void *)&cmd_set_vxlan_set,
10588 : : (void *)&cmd_set_vxlan_vxlan,
10589 : : (void *)&cmd_set_vxlan_ip_version,
10590 : : (void *)&cmd_set_vxlan_ip_version_value,
10591 : : (void *)&cmd_set_vxlan_vni,
10592 : : (void *)&cmd_set_vxlan_vni_value,
10593 : : (void *)&cmd_set_vxlan_udp_src,
10594 : : (void *)&cmd_set_vxlan_udp_src_value,
10595 : : (void *)&cmd_set_vxlan_udp_dst,
10596 : : (void *)&cmd_set_vxlan_udp_dst_value,
10597 : : (void *)&cmd_set_vxlan_ip_src,
10598 : : (void *)&cmd_set_vxlan_ip_src_value,
10599 : : (void *)&cmd_set_vxlan_ip_dst,
10600 : : (void *)&cmd_set_vxlan_ip_dst_value,
10601 : : (void *)&cmd_set_vxlan_eth_src,
10602 : : (void *)&cmd_set_vxlan_eth_src_value,
10603 : : (void *)&cmd_set_vxlan_eth_dst,
10604 : : (void *)&cmd_set_vxlan_eth_dst_value,
10605 : : NULL,
10606 : : },
10607 : : };
10608 : :
10609 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
10610 : : .f = cmd_set_vxlan_parsed,
10611 : : .data = NULL,
10612 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
10613 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
10614 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10615 : : " eth-dst <eth-dst>",
10616 : : .tokens = {
10617 : : (void *)&cmd_set_vxlan_set,
10618 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
10619 : : (void *)&cmd_set_vxlan_ip_version,
10620 : : (void *)&cmd_set_vxlan_ip_version_value,
10621 : : (void *)&cmd_set_vxlan_vni,
10622 : : (void *)&cmd_set_vxlan_vni_value,
10623 : : (void *)&cmd_set_vxlan_udp_src,
10624 : : (void *)&cmd_set_vxlan_udp_src_value,
10625 : : (void *)&cmd_set_vxlan_udp_dst,
10626 : : (void *)&cmd_set_vxlan_udp_dst_value,
10627 : : (void *)&cmd_set_vxlan_ip_tos,
10628 : : (void *)&cmd_set_vxlan_ip_tos_value,
10629 : : (void *)&cmd_set_vxlan_ip_ttl,
10630 : : (void *)&cmd_set_vxlan_ip_ttl_value,
10631 : : (void *)&cmd_set_vxlan_ip_src,
10632 : : (void *)&cmd_set_vxlan_ip_src_value,
10633 : : (void *)&cmd_set_vxlan_ip_dst,
10634 : : (void *)&cmd_set_vxlan_ip_dst_value,
10635 : : (void *)&cmd_set_vxlan_eth_src,
10636 : : (void *)&cmd_set_vxlan_eth_src_value,
10637 : : (void *)&cmd_set_vxlan_eth_dst,
10638 : : (void *)&cmd_set_vxlan_eth_dst_value,
10639 : : NULL,
10640 : : },
10641 : : };
10642 : :
10643 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
10644 : : .f = cmd_set_vxlan_parsed,
10645 : : .data = NULL,
10646 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
10647 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
10648 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
10649 : : " <eth-dst>",
10650 : : .tokens = {
10651 : : (void *)&cmd_set_vxlan_set,
10652 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
10653 : : (void *)&cmd_set_vxlan_ip_version,
10654 : : (void *)&cmd_set_vxlan_ip_version_value,
10655 : : (void *)&cmd_set_vxlan_vni,
10656 : : (void *)&cmd_set_vxlan_vni_value,
10657 : : (void *)&cmd_set_vxlan_udp_src,
10658 : : (void *)&cmd_set_vxlan_udp_src_value,
10659 : : (void *)&cmd_set_vxlan_udp_dst,
10660 : : (void *)&cmd_set_vxlan_udp_dst_value,
10661 : : (void *)&cmd_set_vxlan_ip_src,
10662 : : (void *)&cmd_set_vxlan_ip_src_value,
10663 : : (void *)&cmd_set_vxlan_ip_dst,
10664 : : (void *)&cmd_set_vxlan_ip_dst_value,
10665 : : (void *)&cmd_set_vxlan_vlan,
10666 : : (void *)&cmd_set_vxlan_vlan_value,
10667 : : (void *)&cmd_set_vxlan_eth_src,
10668 : : (void *)&cmd_set_vxlan_eth_src_value,
10669 : : (void *)&cmd_set_vxlan_eth_dst,
10670 : : (void *)&cmd_set_vxlan_eth_dst_value,
10671 : : NULL,
10672 : : },
10673 : : };
10674 : :
10675 : : /** Set NVGRE encapsulation details */
10676 : : struct cmd_set_nvgre_result {
10677 : : cmdline_fixed_string_t set;
10678 : : cmdline_fixed_string_t nvgre;
10679 : : cmdline_fixed_string_t pos_token;
10680 : : cmdline_fixed_string_t ip_version;
10681 : : uint32_t tni;
10682 : : cmdline_ipaddr_t ip_src;
10683 : : cmdline_ipaddr_t ip_dst;
10684 : : uint16_t tci;
10685 : : struct rte_ether_addr eth_src;
10686 : : struct rte_ether_addr eth_dst;
10687 : : };
10688 : :
10689 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
10690 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
10691 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
10692 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
10693 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
10694 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
10695 : : "nvgre-with-vlan");
10696 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
10697 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10698 : : "ip-version");
10699 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
10700 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
10701 : : "ipv4#ipv6");
10702 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
10703 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10704 : : "tni");
10705 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
10706 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
10707 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
10708 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10709 : : "ip-src");
10710 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
10711 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
10712 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
10713 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10714 : : "ip-dst");
10715 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
10716 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
10717 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
10718 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10719 : : "vlan-tci");
10720 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
10721 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
10722 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
10723 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10724 : : "eth-src");
10725 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
10726 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
10727 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
10728 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10729 : : "eth-dst");
10730 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
10731 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
10732 : :
10733 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
10734 : : __rte_unused struct cmdline *cl,
10735 : : __rte_unused void *data)
10736 : : {
10737 : : struct cmd_set_nvgre_result *res = parsed_result;
10738 : : union {
10739 : : uint32_t nvgre_tni;
10740 : : uint8_t tni[4];
10741 : : } id = {
10742 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
10743 : : };
10744 : :
10745 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
10746 : 0 : nvgre_encap_conf.select_vlan = 0;
10747 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
10748 : 0 : nvgre_encap_conf.select_vlan = 1;
10749 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10750 : 0 : nvgre_encap_conf.select_ipv4 = 1;
10751 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10752 : 0 : nvgre_encap_conf.select_ipv4 = 0;
10753 : : else
10754 : : return;
10755 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
10756 : 0 : if (nvgre_encap_conf.select_ipv4) {
10757 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
10758 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
10759 : : } else {
10760 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
10761 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
10762 : : }
10763 : 0 : if (nvgre_encap_conf.select_vlan)
10764 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10765 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
10766 : : RTE_ETHER_ADDR_LEN);
10767 : : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10768 : : RTE_ETHER_ADDR_LEN);
10769 : : }
10770 : :
10771 : : static cmdline_parse_inst_t cmd_set_nvgre = {
10772 : : .f = cmd_set_nvgre_parsed,
10773 : : .data = NULL,
10774 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
10775 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10776 : : " eth-dst <eth-dst>",
10777 : : .tokens = {
10778 : : (void *)&cmd_set_nvgre_set,
10779 : : (void *)&cmd_set_nvgre_nvgre,
10780 : : (void *)&cmd_set_nvgre_ip_version,
10781 : : (void *)&cmd_set_nvgre_ip_version_value,
10782 : : (void *)&cmd_set_nvgre_tni,
10783 : : (void *)&cmd_set_nvgre_tni_value,
10784 : : (void *)&cmd_set_nvgre_ip_src,
10785 : : (void *)&cmd_set_nvgre_ip_src_value,
10786 : : (void *)&cmd_set_nvgre_ip_dst,
10787 : : (void *)&cmd_set_nvgre_ip_dst_value,
10788 : : (void *)&cmd_set_nvgre_eth_src,
10789 : : (void *)&cmd_set_nvgre_eth_src_value,
10790 : : (void *)&cmd_set_nvgre_eth_dst,
10791 : : (void *)&cmd_set_nvgre_eth_dst_value,
10792 : : NULL,
10793 : : },
10794 : : };
10795 : :
10796 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
10797 : : .f = cmd_set_nvgre_parsed,
10798 : : .data = NULL,
10799 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
10800 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10801 : : " eth-src <eth-src> eth-dst <eth-dst>",
10802 : : .tokens = {
10803 : : (void *)&cmd_set_nvgre_set,
10804 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
10805 : : (void *)&cmd_set_nvgre_ip_version,
10806 : : (void *)&cmd_set_nvgre_ip_version_value,
10807 : : (void *)&cmd_set_nvgre_tni,
10808 : : (void *)&cmd_set_nvgre_tni_value,
10809 : : (void *)&cmd_set_nvgre_ip_src,
10810 : : (void *)&cmd_set_nvgre_ip_src_value,
10811 : : (void *)&cmd_set_nvgre_ip_dst,
10812 : : (void *)&cmd_set_nvgre_ip_dst_value,
10813 : : (void *)&cmd_set_nvgre_vlan,
10814 : : (void *)&cmd_set_nvgre_vlan_value,
10815 : : (void *)&cmd_set_nvgre_eth_src,
10816 : : (void *)&cmd_set_nvgre_eth_src_value,
10817 : : (void *)&cmd_set_nvgre_eth_dst,
10818 : : (void *)&cmd_set_nvgre_eth_dst_value,
10819 : : NULL,
10820 : : },
10821 : : };
10822 : :
10823 : : /** Set L2 encapsulation details */
10824 : : struct cmd_set_l2_encap_result {
10825 : : cmdline_fixed_string_t set;
10826 : : cmdline_fixed_string_t l2_encap;
10827 : : cmdline_fixed_string_t pos_token;
10828 : : cmdline_fixed_string_t ip_version;
10829 : : uint32_t vlan_present:1;
10830 : : uint16_t tci;
10831 : : struct rte_ether_addr eth_src;
10832 : : struct rte_ether_addr eth_dst;
10833 : : };
10834 : :
10835 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
10836 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
10837 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
10838 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
10839 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
10840 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
10841 : : "l2_encap-with-vlan");
10842 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
10843 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10844 : : "ip-version");
10845 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
10846 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
10847 : : "ipv4#ipv6");
10848 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
10849 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10850 : : "vlan-tci");
10851 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
10852 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
10853 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
10854 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10855 : : "eth-src");
10856 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
10857 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
10858 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
10859 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10860 : : "eth-dst");
10861 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
10862 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
10863 : :
10864 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
10865 : : __rte_unused struct cmdline *cl,
10866 : : __rte_unused void *data)
10867 : : {
10868 : : struct cmd_set_l2_encap_result *res = parsed_result;
10869 : :
10870 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
10871 : 0 : l2_encap_conf.select_vlan = 0;
10872 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
10873 : 0 : l2_encap_conf.select_vlan = 1;
10874 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10875 : 0 : l2_encap_conf.select_ipv4 = 1;
10876 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10877 : 0 : l2_encap_conf.select_ipv4 = 0;
10878 : : else
10879 : : return;
10880 : 0 : if (l2_encap_conf.select_vlan)
10881 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10882 : : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
10883 : : RTE_ETHER_ADDR_LEN);
10884 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10885 : : RTE_ETHER_ADDR_LEN);
10886 : : }
10887 : :
10888 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
10889 : : .f = cmd_set_l2_encap_parsed,
10890 : : .data = NULL,
10891 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
10892 : : " eth-src <eth-src> eth-dst <eth-dst>",
10893 : : .tokens = {
10894 : : (void *)&cmd_set_l2_encap_set,
10895 : : (void *)&cmd_set_l2_encap_l2_encap,
10896 : : (void *)&cmd_set_l2_encap_ip_version,
10897 : : (void *)&cmd_set_l2_encap_ip_version_value,
10898 : : (void *)&cmd_set_l2_encap_eth_src,
10899 : : (void *)&cmd_set_l2_encap_eth_src_value,
10900 : : (void *)&cmd_set_l2_encap_eth_dst,
10901 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10902 : : NULL,
10903 : : },
10904 : : };
10905 : :
10906 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
10907 : : .f = cmd_set_l2_encap_parsed,
10908 : : .data = NULL,
10909 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
10910 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10911 : : .tokens = {
10912 : : (void *)&cmd_set_l2_encap_set,
10913 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
10914 : : (void *)&cmd_set_l2_encap_ip_version,
10915 : : (void *)&cmd_set_l2_encap_ip_version_value,
10916 : : (void *)&cmd_set_l2_encap_vlan,
10917 : : (void *)&cmd_set_l2_encap_vlan_value,
10918 : : (void *)&cmd_set_l2_encap_eth_src,
10919 : : (void *)&cmd_set_l2_encap_eth_src_value,
10920 : : (void *)&cmd_set_l2_encap_eth_dst,
10921 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10922 : : NULL,
10923 : : },
10924 : : };
10925 : :
10926 : : /** Set L2 decapsulation details */
10927 : : struct cmd_set_l2_decap_result {
10928 : : cmdline_fixed_string_t set;
10929 : : cmdline_fixed_string_t l2_decap;
10930 : : cmdline_fixed_string_t pos_token;
10931 : : uint32_t vlan_present:1;
10932 : : };
10933 : :
10934 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
10935 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
10936 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
10937 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10938 : : "l2_decap");
10939 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
10940 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10941 : : "l2_decap-with-vlan");
10942 : :
10943 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
10944 : : __rte_unused struct cmdline *cl,
10945 : : __rte_unused void *data)
10946 : : {
10947 : : struct cmd_set_l2_decap_result *res = parsed_result;
10948 : :
10949 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
10950 : 0 : l2_decap_conf.select_vlan = 0;
10951 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
10952 : 0 : l2_decap_conf.select_vlan = 1;
10953 : 0 : }
10954 : :
10955 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
10956 : : .f = cmd_set_l2_decap_parsed,
10957 : : .data = NULL,
10958 : : .help_str = "set l2_decap",
10959 : : .tokens = {
10960 : : (void *)&cmd_set_l2_decap_set,
10961 : : (void *)&cmd_set_l2_decap_l2_decap,
10962 : : NULL,
10963 : : },
10964 : : };
10965 : :
10966 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
10967 : : .f = cmd_set_l2_decap_parsed,
10968 : : .data = NULL,
10969 : : .help_str = "set l2_decap-with-vlan",
10970 : : .tokens = {
10971 : : (void *)&cmd_set_l2_decap_set,
10972 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
10973 : : NULL,
10974 : : },
10975 : : };
10976 : :
10977 : : /** Set MPLSoGRE encapsulation details */
10978 : : struct cmd_set_mplsogre_encap_result {
10979 : : cmdline_fixed_string_t set;
10980 : : cmdline_fixed_string_t mplsogre;
10981 : : cmdline_fixed_string_t pos_token;
10982 : : cmdline_fixed_string_t ip_version;
10983 : : uint32_t vlan_present:1;
10984 : : uint32_t label;
10985 : : cmdline_ipaddr_t ip_src;
10986 : : cmdline_ipaddr_t ip_dst;
10987 : : uint16_t tci;
10988 : : struct rte_ether_addr eth_src;
10989 : : struct rte_ether_addr eth_dst;
10990 : : };
10991 : :
10992 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
10993 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
10994 : : "set");
10995 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
10996 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
10997 : : "mplsogre_encap");
10998 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
10999 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11000 : : mplsogre, "mplsogre_encap-with-vlan");
11001 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
11002 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11003 : : pos_token, "ip-version");
11004 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
11005 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11006 : : ip_version, "ipv4#ipv6");
11007 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
11008 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11009 : : pos_token, "label");
11010 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
11011 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
11012 : : RTE_UINT32);
11013 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
11014 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11015 : : pos_token, "ip-src");
11016 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
11017 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
11018 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
11019 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11020 : : pos_token, "ip-dst");
11021 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
11022 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
11023 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
11024 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11025 : : pos_token, "vlan-tci");
11026 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
11027 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
11028 : : RTE_UINT16);
11029 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
11030 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11031 : : pos_token, "eth-src");
11032 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
11033 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11034 : : eth_src);
11035 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
11036 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11037 : : pos_token, "eth-dst");
11038 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
11039 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
11040 : : eth_dst);
11041 : :
11042 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
11043 : : __rte_unused struct cmdline *cl,
11044 : : __rte_unused void *data)
11045 : : {
11046 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
11047 : : union {
11048 : : uint32_t mplsogre_label;
11049 : : uint8_t label[4];
11050 : : } id = {
11051 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
11052 : : };
11053 : :
11054 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
11055 : 0 : mplsogre_encap_conf.select_vlan = 0;
11056 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
11057 : 0 : mplsogre_encap_conf.select_vlan = 1;
11058 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11059 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
11060 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11061 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
11062 : : else
11063 : : return;
11064 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
11065 : 0 : if (mplsogre_encap_conf.select_ipv4) {
11066 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
11067 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
11068 : : } else {
11069 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
11070 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
11071 : : }
11072 : 0 : if (mplsogre_encap_conf.select_vlan)
11073 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11074 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
11075 : : RTE_ETHER_ADDR_LEN);
11076 : : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11077 : : RTE_ETHER_ADDR_LEN);
11078 : : }
11079 : :
11080 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
11081 : : .f = cmd_set_mplsogre_encap_parsed,
11082 : : .data = NULL,
11083 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
11084 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
11085 : : " eth-dst <eth-dst>",
11086 : : .tokens = {
11087 : : (void *)&cmd_set_mplsogre_encap_set,
11088 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
11089 : : (void *)&cmd_set_mplsogre_encap_ip_version,
11090 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
11091 : : (void *)&cmd_set_mplsogre_encap_label,
11092 : : (void *)&cmd_set_mplsogre_encap_label_value,
11093 : : (void *)&cmd_set_mplsogre_encap_ip_src,
11094 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
11095 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
11096 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
11097 : : (void *)&cmd_set_mplsogre_encap_eth_src,
11098 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
11099 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
11100 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
11101 : : NULL,
11102 : : },
11103 : : };
11104 : :
11105 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
11106 : : .f = cmd_set_mplsogre_encap_parsed,
11107 : : .data = NULL,
11108 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
11109 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
11110 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
11111 : : .tokens = {
11112 : : (void *)&cmd_set_mplsogre_encap_set,
11113 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
11114 : : (void *)&cmd_set_mplsogre_encap_ip_version,
11115 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
11116 : : (void *)&cmd_set_mplsogre_encap_label,
11117 : : (void *)&cmd_set_mplsogre_encap_label_value,
11118 : : (void *)&cmd_set_mplsogre_encap_ip_src,
11119 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
11120 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
11121 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
11122 : : (void *)&cmd_set_mplsogre_encap_vlan,
11123 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
11124 : : (void *)&cmd_set_mplsogre_encap_eth_src,
11125 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
11126 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
11127 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
11128 : : NULL,
11129 : : },
11130 : : };
11131 : :
11132 : : /** Set MPLSoGRE decapsulation details */
11133 : : struct cmd_set_mplsogre_decap_result {
11134 : : cmdline_fixed_string_t set;
11135 : : cmdline_fixed_string_t mplsogre;
11136 : : cmdline_fixed_string_t pos_token;
11137 : : cmdline_fixed_string_t ip_version;
11138 : : uint32_t vlan_present:1;
11139 : : };
11140 : :
11141 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
11142 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
11143 : : "set");
11144 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
11145 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
11146 : : "mplsogre_decap");
11147 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
11148 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11149 : : mplsogre, "mplsogre_decap-with-vlan");
11150 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
11151 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11152 : : pos_token, "ip-version");
11153 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
11154 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
11155 : : ip_version, "ipv4#ipv6");
11156 : :
11157 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
11158 : : __rte_unused struct cmdline *cl,
11159 : : __rte_unused void *data)
11160 : : {
11161 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
11162 : :
11163 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
11164 : 0 : mplsogre_decap_conf.select_vlan = 0;
11165 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
11166 : 0 : mplsogre_decap_conf.select_vlan = 1;
11167 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11168 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
11169 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11170 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
11171 : 0 : }
11172 : :
11173 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
11174 : : .f = cmd_set_mplsogre_decap_parsed,
11175 : : .data = NULL,
11176 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
11177 : : .tokens = {
11178 : : (void *)&cmd_set_mplsogre_decap_set,
11179 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
11180 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11181 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11182 : : NULL,
11183 : : },
11184 : : };
11185 : :
11186 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
11187 : : .f = cmd_set_mplsogre_decap_parsed,
11188 : : .data = NULL,
11189 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
11190 : : .tokens = {
11191 : : (void *)&cmd_set_mplsogre_decap_set,
11192 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
11193 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11194 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11195 : : NULL,
11196 : : },
11197 : : };
11198 : :
11199 : : /** Set MPLSoUDP encapsulation details */
11200 : : struct cmd_set_mplsoudp_encap_result {
11201 : : cmdline_fixed_string_t set;
11202 : : cmdline_fixed_string_t mplsoudp;
11203 : : cmdline_fixed_string_t pos_token;
11204 : : cmdline_fixed_string_t ip_version;
11205 : : uint32_t vlan_present:1;
11206 : : uint32_t label;
11207 : : uint16_t udp_src;
11208 : : uint16_t udp_dst;
11209 : : cmdline_ipaddr_t ip_src;
11210 : : cmdline_ipaddr_t ip_dst;
11211 : : uint16_t tci;
11212 : : struct rte_ether_addr eth_src;
11213 : : struct rte_ether_addr eth_dst;
11214 : : };
11215 : :
11216 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
11217 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
11218 : : "set");
11219 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
11220 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
11221 : : "mplsoudp_encap");
11222 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
11223 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11224 : : mplsoudp, "mplsoudp_encap-with-vlan");
11225 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
11226 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11227 : : pos_token, "ip-version");
11228 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
11229 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11230 : : ip_version, "ipv4#ipv6");
11231 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
11232 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11233 : : pos_token, "label");
11234 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
11235 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
11236 : : RTE_UINT32);
11237 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
11238 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11239 : : pos_token, "udp-src");
11240 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
11241 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
11242 : : RTE_UINT16);
11243 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
11244 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11245 : : pos_token, "udp-dst");
11246 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
11247 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
11248 : : RTE_UINT16);
11249 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
11250 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11251 : : pos_token, "ip-src");
11252 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
11253 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
11254 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
11255 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11256 : : pos_token, "ip-dst");
11257 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
11258 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
11259 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
11260 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11261 : : pos_token, "vlan-tci");
11262 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
11263 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
11264 : : RTE_UINT16);
11265 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
11266 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11267 : : pos_token, "eth-src");
11268 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
11269 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11270 : : eth_src);
11271 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
11272 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11273 : : pos_token, "eth-dst");
11274 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
11275 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11276 : : eth_dst);
11277 : :
11278 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
11279 : : __rte_unused struct cmdline *cl,
11280 : : __rte_unused void *data)
11281 : : {
11282 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
11283 : : union {
11284 : : uint32_t mplsoudp_label;
11285 : : uint8_t label[4];
11286 : : } id = {
11287 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
11288 : : };
11289 : :
11290 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
11291 : 0 : mplsoudp_encap_conf.select_vlan = 0;
11292 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
11293 : 0 : mplsoudp_encap_conf.select_vlan = 1;
11294 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11295 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
11296 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11297 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
11298 : : else
11299 : : return;
11300 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
11301 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
11302 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
11303 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
11304 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
11305 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
11306 : : } else {
11307 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
11308 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
11309 : : }
11310 : 0 : if (mplsoudp_encap_conf.select_vlan)
11311 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11312 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
11313 : : RTE_ETHER_ADDR_LEN);
11314 : : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11315 : : RTE_ETHER_ADDR_LEN);
11316 : : }
11317 : :
11318 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
11319 : : .f = cmd_set_mplsoudp_encap_parsed,
11320 : : .data = NULL,
11321 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
11322 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
11323 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
11324 : : .tokens = {
11325 : : (void *)&cmd_set_mplsoudp_encap_set,
11326 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
11327 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11328 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11329 : : (void *)&cmd_set_mplsoudp_encap_label,
11330 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11331 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11332 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11333 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11334 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11335 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11336 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11337 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11338 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11339 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11340 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11341 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11342 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11343 : : NULL,
11344 : : },
11345 : : };
11346 : :
11347 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
11348 : : .f = cmd_set_mplsoudp_encap_parsed,
11349 : : .data = NULL,
11350 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
11351 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
11352 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
11353 : : " eth-src <eth-src> eth-dst <eth-dst>",
11354 : : .tokens = {
11355 : : (void *)&cmd_set_mplsoudp_encap_set,
11356 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
11357 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11358 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11359 : : (void *)&cmd_set_mplsoudp_encap_label,
11360 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11361 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11362 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11363 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11364 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11365 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11366 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11367 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11368 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11369 : : (void *)&cmd_set_mplsoudp_encap_vlan,
11370 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
11371 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11372 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11373 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11374 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11375 : : NULL,
11376 : : },
11377 : : };
11378 : :
11379 : : /** Set MPLSoUDP decapsulation details */
11380 : : struct cmd_set_mplsoudp_decap_result {
11381 : : cmdline_fixed_string_t set;
11382 : : cmdline_fixed_string_t mplsoudp;
11383 : : cmdline_fixed_string_t pos_token;
11384 : : cmdline_fixed_string_t ip_version;
11385 : : uint32_t vlan_present:1;
11386 : : };
11387 : :
11388 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
11389 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
11390 : : "set");
11391 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
11392 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
11393 : : "mplsoudp_decap");
11394 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
11395 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11396 : : mplsoudp, "mplsoudp_decap-with-vlan");
11397 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
11398 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11399 : : pos_token, "ip-version");
11400 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
11401 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11402 : : ip_version, "ipv4#ipv6");
11403 : :
11404 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
11405 : : __rte_unused struct cmdline *cl,
11406 : : __rte_unused void *data)
11407 : : {
11408 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
11409 : :
11410 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
11411 : 0 : mplsoudp_decap_conf.select_vlan = 0;
11412 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
11413 : 0 : mplsoudp_decap_conf.select_vlan = 1;
11414 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11415 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
11416 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11417 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
11418 : 0 : }
11419 : :
11420 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
11421 : : .f = cmd_set_mplsoudp_decap_parsed,
11422 : : .data = NULL,
11423 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
11424 : : .tokens = {
11425 : : (void *)&cmd_set_mplsoudp_decap_set,
11426 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
11427 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11428 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11429 : : NULL,
11430 : : },
11431 : : };
11432 : :
11433 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
11434 : : .f = cmd_set_mplsoudp_decap_parsed,
11435 : : .data = NULL,
11436 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
11437 : : .tokens = {
11438 : : (void *)&cmd_set_mplsoudp_decap_set,
11439 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
11440 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11441 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11442 : : NULL,
11443 : : },
11444 : : };
11445 : :
11446 : : /** Set connection tracking object common details */
11447 : : struct cmd_set_conntrack_common_result {
11448 : : cmdline_fixed_string_t set;
11449 : : cmdline_fixed_string_t conntrack;
11450 : : cmdline_fixed_string_t common;
11451 : : cmdline_fixed_string_t peer;
11452 : : cmdline_fixed_string_t is_orig;
11453 : : cmdline_fixed_string_t enable;
11454 : : cmdline_fixed_string_t live;
11455 : : cmdline_fixed_string_t sack;
11456 : : cmdline_fixed_string_t cack;
11457 : : cmdline_fixed_string_t last_dir;
11458 : : cmdline_fixed_string_t liberal;
11459 : : cmdline_fixed_string_t state;
11460 : : cmdline_fixed_string_t max_ack_win;
11461 : : cmdline_fixed_string_t retrans;
11462 : : cmdline_fixed_string_t last_win;
11463 : : cmdline_fixed_string_t last_seq;
11464 : : cmdline_fixed_string_t last_ack;
11465 : : cmdline_fixed_string_t last_end;
11466 : : cmdline_fixed_string_t last_index;
11467 : : uint8_t stat;
11468 : : uint8_t factor;
11469 : : uint16_t peer_port;
11470 : : uint32_t is_original;
11471 : : uint32_t en;
11472 : : uint32_t is_live;
11473 : : uint32_t s_ack;
11474 : : uint32_t c_ack;
11475 : : uint32_t ld;
11476 : : uint32_t lb;
11477 : : uint8_t re_num;
11478 : : uint8_t li;
11479 : : uint16_t lw;
11480 : : uint32_t ls;
11481 : : uint32_t la;
11482 : : uint32_t le;
11483 : : };
11484 : :
11485 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
11486 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11487 : : set, "set");
11488 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
11489 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11490 : : conntrack, "conntrack");
11491 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
11492 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11493 : : common, "com");
11494 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
11495 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11496 : : peer, "peer");
11497 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
11498 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11499 : : peer_port, RTE_UINT16);
11500 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
11501 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11502 : : is_orig, "is_orig");
11503 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
11504 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11505 : : is_original, RTE_UINT32);
11506 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
11507 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11508 : : enable, "enable");
11509 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
11510 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11511 : : en, RTE_UINT32);
11512 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
11513 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11514 : : live, "live");
11515 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
11516 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11517 : : is_live, RTE_UINT32);
11518 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
11519 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11520 : : sack, "sack");
11521 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
11522 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11523 : : s_ack, RTE_UINT32);
11524 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
11525 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11526 : : cack, "cack");
11527 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
11528 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11529 : : c_ack, RTE_UINT32);
11530 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
11531 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11532 : : last_dir, "last_dir");
11533 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
11534 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11535 : : ld, RTE_UINT32);
11536 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
11537 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11538 : : liberal, "liberal");
11539 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
11540 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11541 : : lb, RTE_UINT32);
11542 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
11543 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11544 : : state, "state");
11545 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
11546 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11547 : : stat, RTE_UINT8);
11548 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
11549 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11550 : : max_ack_win, "max_ack_win");
11551 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
11552 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11553 : : factor, RTE_UINT8);
11554 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
11555 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11556 : : retrans, "r_lim");
11557 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
11558 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11559 : : re_num, RTE_UINT8);
11560 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
11561 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11562 : : last_win, "last_win");
11563 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
11564 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11565 : : lw, RTE_UINT16);
11566 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
11567 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11568 : : last_seq, "last_seq");
11569 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
11570 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11571 : : ls, RTE_UINT32);
11572 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
11573 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11574 : : last_ack, "last_ack");
11575 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
11576 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11577 : : la, RTE_UINT32);
11578 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
11579 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11580 : : last_end, "last_end");
11581 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
11582 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11583 : : le, RTE_UINT32);
11584 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
11585 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11586 : : last_index, "last_index");
11587 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
11588 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11589 : : li, RTE_UINT8);
11590 : :
11591 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
11592 : : __rte_unused struct cmdline *cl,
11593 : : __rte_unused void *data)
11594 : : {
11595 : : struct cmd_set_conntrack_common_result *res = parsed_result;
11596 : :
11597 : : /* No need to swap to big endian. */
11598 : 0 : conntrack_context.peer_port = res->peer_port;
11599 : 0 : conntrack_context.is_original_dir = res->is_original;
11600 : 0 : conntrack_context.enable = res->en;
11601 : 0 : conntrack_context.live_connection = res->is_live;
11602 : 0 : conntrack_context.selective_ack = res->s_ack;
11603 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
11604 : 0 : conntrack_context.last_direction = res->ld;
11605 : 0 : conntrack_context.liberal_mode = res->lb;
11606 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
11607 : 0 : conntrack_context.max_ack_window = res->factor;
11608 : 0 : conntrack_context.retransmission_limit = res->re_num;
11609 : 0 : conntrack_context.last_window = res->lw;
11610 : 0 : conntrack_context.last_index =
11611 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
11612 : 0 : conntrack_context.last_seq = res->ls;
11613 : 0 : conntrack_context.last_ack = res->la;
11614 : 0 : conntrack_context.last_end = res->le;
11615 : 0 : }
11616 : :
11617 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
11618 : : .f = cmd_set_conntrack_common_parsed,
11619 : : .data = NULL,
11620 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
11621 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
11622 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
11623 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
11624 : : " last_index <flag>",
11625 : : .tokens = {
11626 : : (void *)&cmd_set_conntrack_set,
11627 : : (void *)&cmd_set_conntrack_conntrack,
11628 : : (void *)&cmd_set_conntrack_common_com,
11629 : : (void *)&cmd_set_conntrack_common_peer,
11630 : : (void *)&cmd_set_conntrack_common_peer_value,
11631 : : (void *)&cmd_set_conntrack_common_is_orig,
11632 : : (void *)&cmd_set_conntrack_common_is_orig_value,
11633 : : (void *)&cmd_set_conntrack_common_enable,
11634 : : (void *)&cmd_set_conntrack_common_enable_value,
11635 : : (void *)&cmd_set_conntrack_common_live,
11636 : : (void *)&cmd_set_conntrack_common_live_value,
11637 : : (void *)&cmd_set_conntrack_common_sack,
11638 : : (void *)&cmd_set_conntrack_common_sack_value,
11639 : : (void *)&cmd_set_conntrack_common_cack,
11640 : : (void *)&cmd_set_conntrack_common_cack_value,
11641 : : (void *)&cmd_set_conntrack_common_last_dir,
11642 : : (void *)&cmd_set_conntrack_common_last_dir_value,
11643 : : (void *)&cmd_set_conntrack_common_liberal,
11644 : : (void *)&cmd_set_conntrack_common_liberal_value,
11645 : : (void *)&cmd_set_conntrack_common_state,
11646 : : (void *)&cmd_set_conntrack_common_state_value,
11647 : : (void *)&cmd_set_conntrack_common_max_ackwin,
11648 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
11649 : : (void *)&cmd_set_conntrack_common_retrans,
11650 : : (void *)&cmd_set_conntrack_common_retrans_value,
11651 : : (void *)&cmd_set_conntrack_common_last_win,
11652 : : (void *)&cmd_set_conntrack_common_last_win_value,
11653 : : (void *)&cmd_set_conntrack_common_last_seq,
11654 : : (void *)&cmd_set_conntrack_common_last_seq_value,
11655 : : (void *)&cmd_set_conntrack_common_last_ack,
11656 : : (void *)&cmd_set_conntrack_common_last_ack_value,
11657 : : (void *)&cmd_set_conntrack_common_last_end,
11658 : : (void *)&cmd_set_conntrack_common_last_end_value,
11659 : : (void *)&cmd_set_conntrack_common_last_index,
11660 : : (void *)&cmd_set_conntrack_common_last_index_value,
11661 : : NULL,
11662 : : },
11663 : : };
11664 : :
11665 : : /** Set connection tracking object both directions' details */
11666 : : struct cmd_set_conntrack_dir_result {
11667 : : cmdline_fixed_string_t set;
11668 : : cmdline_fixed_string_t conntrack;
11669 : : cmdline_fixed_string_t dir;
11670 : : cmdline_fixed_string_t scale;
11671 : : cmdline_fixed_string_t fin;
11672 : : cmdline_fixed_string_t ack_seen;
11673 : : cmdline_fixed_string_t unack;
11674 : : cmdline_fixed_string_t sent_end;
11675 : : cmdline_fixed_string_t reply_end;
11676 : : cmdline_fixed_string_t max_win;
11677 : : cmdline_fixed_string_t max_ack;
11678 : : uint32_t factor;
11679 : : uint32_t f;
11680 : : uint32_t as;
11681 : : uint32_t un;
11682 : : uint32_t se;
11683 : : uint32_t re;
11684 : : uint32_t mw;
11685 : : uint32_t ma;
11686 : : };
11687 : :
11688 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
11689 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11690 : : dir, "orig#rply");
11691 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
11692 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11693 : : scale, "scale");
11694 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
11695 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11696 : : factor, RTE_UINT32);
11697 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
11698 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11699 : : fin, "fin");
11700 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
11701 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11702 : : f, RTE_UINT32);
11703 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
11704 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11705 : : ack_seen, "acked");
11706 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
11707 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11708 : : as, RTE_UINT32);
11709 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
11710 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11711 : : unack, "unack_data");
11712 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
11713 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11714 : : un, RTE_UINT32);
11715 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
11716 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11717 : : sent_end, "sent_end");
11718 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
11719 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11720 : : se, RTE_UINT32);
11721 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
11722 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11723 : : reply_end, "reply_end");
11724 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
11725 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11726 : : re, RTE_UINT32);
11727 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
11728 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11729 : : max_win, "max_win");
11730 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
11731 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11732 : : mw, RTE_UINT32);
11733 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
11734 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11735 : : max_ack, "max_ack");
11736 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
11737 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11738 : : ma, RTE_UINT32);
11739 : :
11740 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
11741 : : __rte_unused struct cmdline *cl,
11742 : : __rte_unused void *data)
11743 : : {
11744 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
11745 : : struct rte_flow_tcp_dir_param *dir = NULL;
11746 : :
11747 : 0 : if (strcmp(res->dir, "orig") == 0)
11748 : : dir = &conntrack_context.original_dir;
11749 : 0 : else if (strcmp(res->dir, "rply") == 0)
11750 : : dir = &conntrack_context.reply_dir;
11751 : : else
11752 : : return;
11753 : 0 : dir->scale = res->factor;
11754 : 0 : dir->close_initiated = res->f;
11755 : 0 : dir->last_ack_seen = res->as;
11756 : 0 : dir->data_unacked = res->un;
11757 : 0 : dir->sent_end = res->se;
11758 : 0 : dir->reply_end = res->re;
11759 : 0 : dir->max_ack = res->ma;
11760 : 0 : dir->max_win = res->mw;
11761 : : }
11762 : :
11763 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
11764 : : .f = cmd_set_conntrack_dir_parsed,
11765 : : .data = NULL,
11766 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
11767 : : " acked <seen> unack_data <unack> sent_end <sent>"
11768 : : " reply_end <reply> max_win <win> max_ack <ack>",
11769 : : .tokens = {
11770 : : (void *)&cmd_set_conntrack_set,
11771 : : (void *)&cmd_set_conntrack_conntrack,
11772 : : (void *)&cmd_set_conntrack_dir_dir,
11773 : : (void *)&cmd_set_conntrack_dir_scale,
11774 : : (void *)&cmd_set_conntrack_dir_scale_value,
11775 : : (void *)&cmd_set_conntrack_dir_fin,
11776 : : (void *)&cmd_set_conntrack_dir_fin_value,
11777 : : (void *)&cmd_set_conntrack_dir_ack,
11778 : : (void *)&cmd_set_conntrack_dir_ack_value,
11779 : : (void *)&cmd_set_conntrack_dir_unack_data,
11780 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
11781 : : (void *)&cmd_set_conntrack_dir_sent_end,
11782 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
11783 : : (void *)&cmd_set_conntrack_dir_reply_end,
11784 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
11785 : : (void *)&cmd_set_conntrack_dir_max_win,
11786 : : (void *)&cmd_set_conntrack_dir_max_win_value,
11787 : : (void *)&cmd_set_conntrack_dir_max_ack,
11788 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
11789 : : NULL,
11790 : : },
11791 : : };
11792 : :
11793 : : /* show vf stats */
11794 : :
11795 : : /* Common result structure for show vf stats */
11796 : : struct cmd_show_vf_stats_result {
11797 : : cmdline_fixed_string_t show;
11798 : : cmdline_fixed_string_t vf;
11799 : : cmdline_fixed_string_t stats;
11800 : : portid_t port_id;
11801 : : uint16_t vf_id;
11802 : : };
11803 : :
11804 : : /* Common CLI fields show vf stats*/
11805 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
11806 : : TOKEN_STRING_INITIALIZER
11807 : : (struct cmd_show_vf_stats_result,
11808 : : show, "show");
11809 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
11810 : : TOKEN_STRING_INITIALIZER
11811 : : (struct cmd_show_vf_stats_result,
11812 : : vf, "vf");
11813 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
11814 : : TOKEN_STRING_INITIALIZER
11815 : : (struct cmd_show_vf_stats_result,
11816 : : stats, "stats");
11817 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
11818 : : TOKEN_NUM_INITIALIZER
11819 : : (struct cmd_show_vf_stats_result,
11820 : : port_id, RTE_UINT16);
11821 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
11822 : : TOKEN_NUM_INITIALIZER
11823 : : (struct cmd_show_vf_stats_result,
11824 : : vf_id, RTE_UINT16);
11825 : :
11826 : : static void
11827 : 0 : cmd_show_vf_stats_parsed(
11828 : : void *parsed_result,
11829 : : __rte_unused struct cmdline *cl,
11830 : : __rte_unused void *data)
11831 : : {
11832 : : struct cmd_show_vf_stats_result *res = parsed_result;
11833 : : struct rte_eth_stats stats;
11834 : : int ret = -ENOTSUP;
11835 : : static const char *nic_stats_border = "########################";
11836 : :
11837 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11838 : 0 : return;
11839 : :
11840 : : memset(&stats, 0, sizeof(stats));
11841 : :
11842 : : #ifdef RTE_NET_I40E
11843 : : if (ret == -ENOTSUP)
11844 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
11845 : 0 : res->vf_id,
11846 : : &stats);
11847 : : #endif
11848 : : #ifdef RTE_NET_BNXT
11849 : 0 : if (ret == -ENOTSUP)
11850 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
11851 : 0 : res->vf_id,
11852 : : &stats);
11853 : : #endif
11854 : :
11855 : 0 : switch (ret) {
11856 : : case 0:
11857 : : break;
11858 : 0 : case -EINVAL:
11859 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11860 : : break;
11861 : 0 : case -ENODEV:
11862 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11863 : : break;
11864 : 0 : case -ENOTSUP:
11865 : 0 : fprintf(stderr, "function not implemented\n");
11866 : : break;
11867 : 0 : default:
11868 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11869 : : }
11870 : :
11871 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
11872 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
11873 : :
11874 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
11875 : : "%-"PRIu64"\n",
11876 : : stats.ipackets, stats.imissed, stats.ibytes);
11877 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
11878 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
11879 : : stats.rx_nombuf);
11880 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
11881 : : "%-"PRIu64"\n",
11882 : : stats.opackets, stats.oerrors, stats.obytes);
11883 : :
11884 : 0 : printf(" %s############################%s\n",
11885 : : nic_stats_border, nic_stats_border);
11886 : : }
11887 : :
11888 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
11889 : : .f = cmd_show_vf_stats_parsed,
11890 : : .data = NULL,
11891 : : .help_str = "show vf stats <port_id> <vf_id>",
11892 : : .tokens = {
11893 : : (void *)&cmd_show_vf_stats_show,
11894 : : (void *)&cmd_show_vf_stats_vf,
11895 : : (void *)&cmd_show_vf_stats_stats,
11896 : : (void *)&cmd_show_vf_stats_port_id,
11897 : : (void *)&cmd_show_vf_stats_vf_id,
11898 : : NULL,
11899 : : },
11900 : : };
11901 : :
11902 : : /* clear vf stats */
11903 : :
11904 : : /* Common result structure for clear vf stats */
11905 : : struct cmd_clear_vf_stats_result {
11906 : : cmdline_fixed_string_t clear;
11907 : : cmdline_fixed_string_t vf;
11908 : : cmdline_fixed_string_t stats;
11909 : : portid_t port_id;
11910 : : uint16_t vf_id;
11911 : : };
11912 : :
11913 : : /* Common CLI fields clear vf stats*/
11914 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
11915 : : TOKEN_STRING_INITIALIZER
11916 : : (struct cmd_clear_vf_stats_result,
11917 : : clear, "clear");
11918 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
11919 : : TOKEN_STRING_INITIALIZER
11920 : : (struct cmd_clear_vf_stats_result,
11921 : : vf, "vf");
11922 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
11923 : : TOKEN_STRING_INITIALIZER
11924 : : (struct cmd_clear_vf_stats_result,
11925 : : stats, "stats");
11926 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
11927 : : TOKEN_NUM_INITIALIZER
11928 : : (struct cmd_clear_vf_stats_result,
11929 : : port_id, RTE_UINT16);
11930 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
11931 : : TOKEN_NUM_INITIALIZER
11932 : : (struct cmd_clear_vf_stats_result,
11933 : : vf_id, RTE_UINT16);
11934 : :
11935 : : static void
11936 : 0 : cmd_clear_vf_stats_parsed(
11937 : : void *parsed_result,
11938 : : __rte_unused struct cmdline *cl,
11939 : : __rte_unused void *data)
11940 : : {
11941 : : struct cmd_clear_vf_stats_result *res = parsed_result;
11942 : : int ret = -ENOTSUP;
11943 : :
11944 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11945 : : return;
11946 : :
11947 : : #ifdef RTE_NET_I40E
11948 : : if (ret == -ENOTSUP)
11949 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
11950 : 0 : res->vf_id);
11951 : : #endif
11952 : : #ifdef RTE_NET_BNXT
11953 : 0 : if (ret == -ENOTSUP)
11954 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
11955 : 0 : res->vf_id);
11956 : : #endif
11957 : :
11958 : 0 : switch (ret) {
11959 : : case 0:
11960 : : break;
11961 : 0 : case -EINVAL:
11962 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11963 : : break;
11964 : 0 : case -ENODEV:
11965 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11966 : : break;
11967 : 0 : case -ENOTSUP:
11968 : 0 : fprintf(stderr, "function not implemented\n");
11969 : : break;
11970 : 0 : default:
11971 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11972 : : }
11973 : : }
11974 : :
11975 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
11976 : : .f = cmd_clear_vf_stats_parsed,
11977 : : .data = NULL,
11978 : : .help_str = "clear vf stats <port_id> <vf_id>",
11979 : : .tokens = {
11980 : : (void *)&cmd_clear_vf_stats_clear,
11981 : : (void *)&cmd_clear_vf_stats_vf,
11982 : : (void *)&cmd_clear_vf_stats_stats,
11983 : : (void *)&cmd_clear_vf_stats_port_id,
11984 : : (void *)&cmd_clear_vf_stats_vf_id,
11985 : : NULL,
11986 : : },
11987 : : };
11988 : :
11989 : : /* Common result structure for file commands */
11990 : : struct cmd_cmdfile_result {
11991 : : cmdline_fixed_string_t load;
11992 : : cmdline_fixed_string_t filename;
11993 : : };
11994 : :
11995 : : /* Common CLI fields for file commands */
11996 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
11997 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
11998 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
11999 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
12000 : :
12001 : : static void
12002 : 0 : cmd_load_from_file_parsed(
12003 : : void *parsed_result,
12004 : : __rte_unused struct cmdline *cl,
12005 : : __rte_unused void *data)
12006 : : {
12007 : : struct cmd_cmdfile_result *res = parsed_result;
12008 : :
12009 : 0 : if (cmdline_read_from_file(res->filename, false) != 0) {
12010 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
12011 : : }
12012 : 0 : }
12013 : :
12014 : : static cmdline_parse_inst_t cmd_load_from_file = {
12015 : : .f = cmd_load_from_file_parsed,
12016 : : .data = NULL,
12017 : : .help_str = "load <filename>",
12018 : : .tokens = {
12019 : : (void *)&cmd_load_cmdfile,
12020 : : (void *)&cmd_load_cmdfile_filename,
12021 : : NULL,
12022 : : },
12023 : : };
12024 : :
12025 : : /* command to load a file with echoing commands */
12026 : : struct cmd_load_echo_result {
12027 : : cmdline_fixed_string_t load_echo;
12028 : : cmdline_fixed_string_t filename;
12029 : : };
12030 : :
12031 : : /* CLI fields for file load with echo command */
12032 : : static cmdline_parse_token_string_t cmd_load_echo =
12033 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, load_echo, "load_echo");
12034 : : static cmdline_parse_token_string_t cmd_load_echo_filename =
12035 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, filename, NULL);
12036 : :
12037 : : static void
12038 : 0 : cmd_load_echo_file_parsed(
12039 : : void *parsed_result,
12040 : : __rte_unused struct cmdline *cl,
12041 : : __rte_unused void *data)
12042 : : {
12043 : : struct cmd_load_echo_result *res = parsed_result;
12044 : :
12045 : 0 : if (cmdline_read_from_file(res->filename, true) != 0)
12046 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
12047 : 0 : }
12048 : :
12049 : : static cmdline_parse_inst_t cmd_load_echo_file = {
12050 : : .f = cmd_load_echo_file_parsed,
12051 : : .data = NULL,
12052 : : .help_str = "load_echo <filename>",
12053 : : .tokens = {
12054 : : (void *)&cmd_load_echo,
12055 : : (void *)&cmd_load_echo_filename,
12056 : : NULL,
12057 : : },
12058 : : };
12059 : :
12060 : : /* Get Rx offloads capabilities */
12061 : : struct cmd_rx_offload_get_capa_result {
12062 : : cmdline_fixed_string_t show;
12063 : : cmdline_fixed_string_t port;
12064 : : portid_t port_id;
12065 : : cmdline_fixed_string_t rx_offload;
12066 : : cmdline_fixed_string_t capabilities;
12067 : : };
12068 : :
12069 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
12070 : : TOKEN_STRING_INITIALIZER
12071 : : (struct cmd_rx_offload_get_capa_result,
12072 : : show, "show");
12073 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
12074 : : TOKEN_STRING_INITIALIZER
12075 : : (struct cmd_rx_offload_get_capa_result,
12076 : : port, "port");
12077 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
12078 : : TOKEN_NUM_INITIALIZER
12079 : : (struct cmd_rx_offload_get_capa_result,
12080 : : port_id, RTE_UINT16);
12081 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
12082 : : TOKEN_STRING_INITIALIZER
12083 : : (struct cmd_rx_offload_get_capa_result,
12084 : : rx_offload, "rx_offload");
12085 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
12086 : : TOKEN_STRING_INITIALIZER
12087 : : (struct cmd_rx_offload_get_capa_result,
12088 : : capabilities, "capabilities");
12089 : :
12090 : : static void
12091 : 0 : print_rx_offloads(uint64_t offloads)
12092 : : {
12093 : : uint64_t single_offload;
12094 : : int begin;
12095 : : int end;
12096 : : int bit;
12097 : :
12098 : 0 : if (offloads == 0)
12099 : : return;
12100 : :
12101 : : begin = rte_ctz64(offloads);
12102 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12103 : :
12104 : 0 : single_offload = 1ULL << begin;
12105 : 0 : for (bit = begin; bit < end; bit++) {
12106 : 0 : if (offloads & single_offload)
12107 : 0 : printf(" %s",
12108 : : rte_eth_dev_rx_offload_name(single_offload));
12109 : 0 : single_offload <<= 1;
12110 : : }
12111 : : }
12112 : :
12113 : : static void
12114 : 0 : cmd_rx_offload_get_capa_parsed(
12115 : : void *parsed_result,
12116 : : __rte_unused struct cmdline *cl,
12117 : : __rte_unused void *data)
12118 : : {
12119 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
12120 : : struct rte_eth_dev_info dev_info;
12121 : 0 : portid_t port_id = res->port_id;
12122 : : uint64_t queue_offloads;
12123 : : uint64_t port_offloads;
12124 : : int ret;
12125 : :
12126 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12127 : 0 : if (ret != 0)
12128 : 0 : return;
12129 : :
12130 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
12131 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
12132 : :
12133 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
12134 : : printf(" Per Queue :");
12135 : 0 : print_rx_offloads(queue_offloads);
12136 : :
12137 : : printf("\n");
12138 : : printf(" Per Port :");
12139 : 0 : print_rx_offloads(port_offloads);
12140 : : printf("\n\n");
12141 : : }
12142 : :
12143 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
12144 : : .f = cmd_rx_offload_get_capa_parsed,
12145 : : .data = NULL,
12146 : : .help_str = "show port <port_id> rx_offload capabilities",
12147 : : .tokens = {
12148 : : (void *)&cmd_rx_offload_get_capa_show,
12149 : : (void *)&cmd_rx_offload_get_capa_port,
12150 : : (void *)&cmd_rx_offload_get_capa_port_id,
12151 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
12152 : : (void *)&cmd_rx_offload_get_capa_capabilities,
12153 : : NULL,
12154 : : }
12155 : : };
12156 : :
12157 : : /* Get Rx offloads configuration */
12158 : : struct cmd_rx_offload_get_configuration_result {
12159 : : cmdline_fixed_string_t show;
12160 : : cmdline_fixed_string_t port;
12161 : : portid_t port_id;
12162 : : cmdline_fixed_string_t rx_offload;
12163 : : cmdline_fixed_string_t configuration;
12164 : : };
12165 : :
12166 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
12167 : : TOKEN_STRING_INITIALIZER
12168 : : (struct cmd_rx_offload_get_configuration_result,
12169 : : show, "show");
12170 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
12171 : : TOKEN_STRING_INITIALIZER
12172 : : (struct cmd_rx_offload_get_configuration_result,
12173 : : port, "port");
12174 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
12175 : : TOKEN_NUM_INITIALIZER
12176 : : (struct cmd_rx_offload_get_configuration_result,
12177 : : port_id, RTE_UINT16);
12178 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
12179 : : TOKEN_STRING_INITIALIZER
12180 : : (struct cmd_rx_offload_get_configuration_result,
12181 : : rx_offload, "rx_offload");
12182 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
12183 : : TOKEN_STRING_INITIALIZER
12184 : : (struct cmd_rx_offload_get_configuration_result,
12185 : : configuration, "configuration");
12186 : :
12187 : : static void
12188 : 0 : cmd_rx_offload_get_configuration_parsed(
12189 : : void *parsed_result,
12190 : : __rte_unused struct cmdline *cl,
12191 : : __rte_unused void *data)
12192 : : {
12193 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
12194 : : struct rte_eth_dev_info dev_info;
12195 : 0 : portid_t port_id = res->port_id;
12196 : : struct rte_port *port;
12197 : : struct rte_eth_conf dev_conf;
12198 : : uint64_t port_offloads;
12199 : : uint64_t queue_offloads;
12200 : : uint16_t nb_rx_queues;
12201 : : int q;
12202 : : int ret;
12203 : :
12204 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12205 : 0 : if (ret != 0)
12206 : 0 : return;
12207 : :
12208 : 0 : port = &ports[port_id];
12209 : : printf("Rx Offloading Configuration of port %d :\n", port_id);
12210 : :
12211 : 0 : port_offloads = dev_conf.rxmode.offloads;
12212 : : printf(" Port :");
12213 : 0 : print_rx_offloads(port_offloads);
12214 : : printf("\n");
12215 : :
12216 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12217 : 0 : if (ret != 0)
12218 : : return;
12219 : :
12220 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12221 : 0 : for (q = 0; q < nb_rx_queues; q++) {
12222 : 0 : queue_offloads = port->rxq[q].conf.offloads;
12223 : : printf(" Queue[%2d] :", q);
12224 : 0 : print_rx_offloads(queue_offloads);
12225 : : printf("\n");
12226 : : }
12227 : : printf("\n");
12228 : : }
12229 : :
12230 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
12231 : : .f = cmd_rx_offload_get_configuration_parsed,
12232 : : .data = NULL,
12233 : : .help_str = "show port <port_id> rx_offload configuration",
12234 : : .tokens = {
12235 : : (void *)&cmd_rx_offload_get_configuration_show,
12236 : : (void *)&cmd_rx_offload_get_configuration_port,
12237 : : (void *)&cmd_rx_offload_get_configuration_port_id,
12238 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
12239 : : (void *)&cmd_rx_offload_get_configuration_configuration,
12240 : : NULL,
12241 : : }
12242 : : };
12243 : :
12244 : : /* Enable/Disable a per port offloading */
12245 : : struct cmd_config_per_port_rx_offload_result {
12246 : : cmdline_fixed_string_t port;
12247 : : cmdline_fixed_string_t config;
12248 : : portid_t port_id;
12249 : : cmdline_fixed_string_t rx_offload;
12250 : : cmdline_fixed_string_t offload;
12251 : : cmdline_fixed_string_t on_off;
12252 : : };
12253 : :
12254 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
12255 : : TOKEN_STRING_INITIALIZER
12256 : : (struct cmd_config_per_port_rx_offload_result,
12257 : : port, "port");
12258 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
12259 : : TOKEN_STRING_INITIALIZER
12260 : : (struct cmd_config_per_port_rx_offload_result,
12261 : : config, "config");
12262 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
12263 : : TOKEN_NUM_INITIALIZER
12264 : : (struct cmd_config_per_port_rx_offload_result,
12265 : : port_id, RTE_UINT16);
12266 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
12267 : : TOKEN_STRING_INITIALIZER
12268 : : (struct cmd_config_per_port_rx_offload_result,
12269 : : rx_offload, "rx_offload");
12270 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
12271 : : TOKEN_STRING_INITIALIZER
12272 : : (struct cmd_config_per_port_rx_offload_result,
12273 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12274 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12275 : : "vlan_filter#vlan_extend#"
12276 : : "scatter#buffer_split#timestamp#security#"
12277 : : "keep_crc#rss_hash");
12278 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
12279 : : TOKEN_STRING_INITIALIZER
12280 : : (struct cmd_config_per_port_rx_offload_result,
12281 : : on_off, "on#off");
12282 : :
12283 : : static uint64_t
12284 : 0 : search_rx_offload(const char *name)
12285 : : {
12286 : : uint64_t single_offload;
12287 : : const char *single_name;
12288 : : int found = 0;
12289 : : unsigned int bit;
12290 : :
12291 : : single_offload = 1;
12292 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12293 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
12294 : 0 : if (!strcasecmp(single_name, name)) {
12295 : : found = 1;
12296 : : break;
12297 : : }
12298 : 0 : single_offload <<= 1;
12299 : : }
12300 : :
12301 : 0 : if (found)
12302 : 0 : return single_offload;
12303 : :
12304 : : return 0;
12305 : : }
12306 : :
12307 : : static void
12308 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
12309 : : {
12310 : : struct rte_eth_dev_info dev_info;
12311 : : struct rte_port *port;
12312 : : uint16_t nb_rx_queues;
12313 : : uint64_t offload;
12314 : : int q;
12315 : : int ret;
12316 : :
12317 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12318 : 0 : if (ret != 0)
12319 : 0 : return;
12320 : :
12321 : 0 : port = &ports[port_id];
12322 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12323 : 0 : fprintf(stderr,
12324 : : "Error: Can't config offload when Port %d is not stopped\n",
12325 : : port_id);
12326 : 0 : return;
12327 : : }
12328 : :
12329 : 0 : if (!strcmp(name, "all")) {
12330 : 0 : offload = dev_info.rx_offload_capa;
12331 : : } else {
12332 : 0 : offload = search_rx_offload(name);
12333 : 0 : if (offload == 0) {
12334 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12335 : 0 : return;
12336 : : }
12337 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
12338 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12339 : : port_id, name);
12340 : 0 : return;
12341 : : }
12342 : : }
12343 : :
12344 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12345 : 0 : if (on) {
12346 : 0 : port->dev_conf.rxmode.offloads |= offload;
12347 : 0 : for (q = 0; q < nb_rx_queues; q++)
12348 : 0 : port->rxq[q].conf.offloads |= offload;
12349 : : } else {
12350 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
12351 : 0 : for (q = 0; q < nb_rx_queues; q++)
12352 : 0 : port->rxq[q].conf.offloads &= ~offload;
12353 : : }
12354 : :
12355 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12356 : : }
12357 : :
12358 : : static void
12359 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
12360 : : __rte_unused struct cmdline *cl,
12361 : : __rte_unused void *data)
12362 : : {
12363 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
12364 : : bool on;
12365 : :
12366 : 0 : on = strcmp(res->on_off, "on") == 0;
12367 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
12368 : 0 : }
12369 : :
12370 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
12371 : : .f = cmd_config_per_port_rx_offload_parsed,
12372 : : .data = NULL,
12373 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
12374 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12375 : : "macsec_strip|vlan_filter|vlan_extend|"
12376 : : "scatter|buffer_split|timestamp|security|"
12377 : : "keep_crc|rss_hash on|off",
12378 : : .tokens = {
12379 : : (void *)&cmd_config_per_port_rx_offload_result_port,
12380 : : (void *)&cmd_config_per_port_rx_offload_result_config,
12381 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
12382 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
12383 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
12384 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
12385 : : NULL,
12386 : : }
12387 : : };
12388 : :
12389 : : /* Enable/Disable all port Rx offloading */
12390 : : struct cmd_config_all_port_rx_offload_result {
12391 : : cmdline_fixed_string_t port;
12392 : : cmdline_fixed_string_t config;
12393 : : cmdline_fixed_string_t port_all;
12394 : : cmdline_fixed_string_t rx_offload;
12395 : : cmdline_fixed_string_t offload;
12396 : : cmdline_fixed_string_t on_off;
12397 : : };
12398 : :
12399 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
12400 : : TOKEN_STRING_INITIALIZER
12401 : : (struct cmd_config_all_port_rx_offload_result,
12402 : : port, "port");
12403 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
12404 : : TOKEN_STRING_INITIALIZER
12405 : : (struct cmd_config_all_port_rx_offload_result,
12406 : : config, "config");
12407 : :
12408 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
12409 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
12410 : : port_all, "all");
12411 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
12412 : : TOKEN_STRING_INITIALIZER
12413 : : (struct cmd_config_all_port_rx_offload_result,
12414 : : rx_offload, "rx_offload");
12415 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
12416 : : TOKEN_STRING_INITIALIZER
12417 : : (struct cmd_config_all_port_rx_offload_result,
12418 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12419 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12420 : : "vlan_filter#vlan_extend#"
12421 : : "scatter#buffer_split#timestamp#security#"
12422 : : "keep_crc#rss_hash");
12423 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
12424 : : TOKEN_STRING_INITIALIZER
12425 : : (struct cmd_config_all_port_rx_offload_result,
12426 : : on_off, "on#off");
12427 : :
12428 : : static void
12429 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
12430 : : __rte_unused struct cmdline *cl,
12431 : : __rte_unused void *data)
12432 : : {
12433 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
12434 : : bool on_off;
12435 : : portid_t i;
12436 : :
12437 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12438 : 0 : RTE_ETH_FOREACH_DEV(i)
12439 : 0 : config_port_rx_offload(i, res->offload, on_off);
12440 : :
12441 : 0 : }
12442 : :
12443 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
12444 : : .f = cmd_config_all_port_rx_offload_parsed,
12445 : : .data = NULL,
12446 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
12447 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12448 : : "macsec_strip|vlan_filter|vlan_extend|"
12449 : : "scatter|buffer_split|timestamp|security|"
12450 : : "keep_crc|rss_hash on|off",
12451 : : .tokens = {
12452 : : (void *)&cmd_config_all_port_rx_offload_result_port,
12453 : : (void *)&cmd_config_all_port_rx_offload_result_config,
12454 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
12455 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
12456 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
12457 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
12458 : : NULL,
12459 : : }
12460 : : };
12461 : :
12462 : : /* Enable/Disable a per queue offloading */
12463 : : struct cmd_config_per_queue_rx_offload_result {
12464 : : cmdline_fixed_string_t port;
12465 : : portid_t port_id;
12466 : : cmdline_fixed_string_t rxq;
12467 : : uint16_t queue_id;
12468 : : cmdline_fixed_string_t rx_offload;
12469 : : cmdline_fixed_string_t offload;
12470 : : cmdline_fixed_string_t on_off;
12471 : : };
12472 : :
12473 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
12474 : : TOKEN_STRING_INITIALIZER
12475 : : (struct cmd_config_per_queue_rx_offload_result,
12476 : : port, "port");
12477 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
12478 : : TOKEN_NUM_INITIALIZER
12479 : : (struct cmd_config_per_queue_rx_offload_result,
12480 : : port_id, RTE_UINT16);
12481 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
12482 : : TOKEN_STRING_INITIALIZER
12483 : : (struct cmd_config_per_queue_rx_offload_result,
12484 : : rxq, "rxq");
12485 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
12486 : : TOKEN_NUM_INITIALIZER
12487 : : (struct cmd_config_per_queue_rx_offload_result,
12488 : : queue_id, RTE_UINT16);
12489 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
12490 : : TOKEN_STRING_INITIALIZER
12491 : : (struct cmd_config_per_queue_rx_offload_result,
12492 : : rx_offload, "rx_offload");
12493 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
12494 : : TOKEN_STRING_INITIALIZER
12495 : : (struct cmd_config_per_queue_rx_offload_result,
12496 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12497 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12498 : : "vlan_filter#vlan_extend#"
12499 : : "scatter#buffer_split#timestamp#security#keep_crc");
12500 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
12501 : : TOKEN_STRING_INITIALIZER
12502 : : (struct cmd_config_per_queue_rx_offload_result,
12503 : : on_off, "on#off");
12504 : :
12505 : : static void
12506 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
12507 : : __rte_unused struct cmdline *cl,
12508 : : __rte_unused void *data)
12509 : : {
12510 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
12511 : : struct rte_eth_dev_info dev_info;
12512 : 0 : portid_t port_id = res->port_id;
12513 : 0 : uint16_t queue_id = res->queue_id;
12514 : : struct rte_port *port;
12515 : : uint64_t offload;
12516 : : int ret;
12517 : :
12518 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12519 : 0 : if (ret != 0)
12520 : 0 : return;
12521 : :
12522 : 0 : port = &ports[port_id];
12523 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12524 : 0 : fprintf(stderr,
12525 : : "Error: Can't config offload when Port %d is not stopped\n",
12526 : : port_id);
12527 : 0 : return;
12528 : : }
12529 : :
12530 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
12531 : 0 : fprintf(stderr,
12532 : : "Error: input queue_id should be 0 ... %d\n",
12533 : 0 : dev_info.nb_rx_queues - 1);
12534 : 0 : return;
12535 : : }
12536 : :
12537 : 0 : if (!strcmp(res->offload, "all")) {
12538 : 0 : offload = dev_info.rx_queue_offload_capa;
12539 : : } else {
12540 : 0 : offload = search_rx_offload(res->offload);
12541 : 0 : if (offload == 0) {
12542 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12543 : 0 : return;
12544 : : }
12545 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
12546 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12547 : : port_id, res->offload);
12548 : 0 : return;
12549 : : }
12550 : : }
12551 : :
12552 : 0 : if (!strcmp(res->on_off, "on"))
12553 : 0 : port->rxq[queue_id].conf.offloads |= offload;
12554 : : else
12555 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
12556 : :
12557 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12558 : : }
12559 : :
12560 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
12561 : : .f = cmd_config_per_queue_rx_offload_parsed,
12562 : : .data = NULL,
12563 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
12564 : : "all|vlan_strip|ipv4_cksum|"
12565 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12566 : : "macsec_strip|vlan_filter|vlan_extend|"
12567 : : "scatter|buffer_split|timestamp|security|"
12568 : : "keep_crc on|off",
12569 : : .tokens = {
12570 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
12571 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
12572 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
12573 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
12574 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
12575 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
12576 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
12577 : : NULL,
12578 : : }
12579 : : };
12580 : :
12581 : : /* Get Tx offloads capabilities */
12582 : : struct cmd_tx_offload_get_capa_result {
12583 : : cmdline_fixed_string_t show;
12584 : : cmdline_fixed_string_t port;
12585 : : portid_t port_id;
12586 : : cmdline_fixed_string_t tx_offload;
12587 : : cmdline_fixed_string_t capabilities;
12588 : : };
12589 : :
12590 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
12591 : : TOKEN_STRING_INITIALIZER
12592 : : (struct cmd_tx_offload_get_capa_result,
12593 : : show, "show");
12594 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
12595 : : TOKEN_STRING_INITIALIZER
12596 : : (struct cmd_tx_offload_get_capa_result,
12597 : : port, "port");
12598 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
12599 : : TOKEN_NUM_INITIALIZER
12600 : : (struct cmd_tx_offload_get_capa_result,
12601 : : port_id, RTE_UINT16);
12602 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
12603 : : TOKEN_STRING_INITIALIZER
12604 : : (struct cmd_tx_offload_get_capa_result,
12605 : : tx_offload, "tx_offload");
12606 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
12607 : : TOKEN_STRING_INITIALIZER
12608 : : (struct cmd_tx_offload_get_capa_result,
12609 : : capabilities, "capabilities");
12610 : :
12611 : : static void
12612 : 0 : print_tx_offloads(uint64_t offloads)
12613 : : {
12614 : : uint64_t single_offload;
12615 : : int begin;
12616 : : int end;
12617 : : int bit;
12618 : :
12619 : 0 : if (offloads == 0)
12620 : : return;
12621 : :
12622 : : begin = rte_ctz64(offloads);
12623 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12624 : :
12625 : 0 : single_offload = 1ULL << begin;
12626 : 0 : for (bit = begin; bit < end; bit++) {
12627 : 0 : if (offloads & single_offload)
12628 : 0 : printf(" %s",
12629 : : rte_eth_dev_tx_offload_name(single_offload));
12630 : 0 : single_offload <<= 1;
12631 : : }
12632 : : }
12633 : :
12634 : : static void
12635 : 0 : cmd_tx_offload_get_capa_parsed(
12636 : : void *parsed_result,
12637 : : __rte_unused struct cmdline *cl,
12638 : : __rte_unused void *data)
12639 : : {
12640 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
12641 : : struct rte_eth_dev_info dev_info;
12642 : 0 : portid_t port_id = res->port_id;
12643 : : uint64_t queue_offloads;
12644 : : uint64_t port_offloads;
12645 : : int ret;
12646 : :
12647 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12648 : 0 : if (ret != 0)
12649 : 0 : return;
12650 : :
12651 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
12652 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
12653 : :
12654 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
12655 : : printf(" Per Queue :");
12656 : 0 : print_tx_offloads(queue_offloads);
12657 : :
12658 : : printf("\n");
12659 : : printf(" Per Port :");
12660 : 0 : print_tx_offloads(port_offloads);
12661 : : printf("\n\n");
12662 : : }
12663 : :
12664 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
12665 : : .f = cmd_tx_offload_get_capa_parsed,
12666 : : .data = NULL,
12667 : : .help_str = "show port <port_id> tx_offload capabilities",
12668 : : .tokens = {
12669 : : (void *)&cmd_tx_offload_get_capa_show,
12670 : : (void *)&cmd_tx_offload_get_capa_port,
12671 : : (void *)&cmd_tx_offload_get_capa_port_id,
12672 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
12673 : : (void *)&cmd_tx_offload_get_capa_capabilities,
12674 : : NULL,
12675 : : }
12676 : : };
12677 : :
12678 : : /* Get Tx offloads configuration */
12679 : : struct cmd_tx_offload_get_configuration_result {
12680 : : cmdline_fixed_string_t show;
12681 : : cmdline_fixed_string_t port;
12682 : : portid_t port_id;
12683 : : cmdline_fixed_string_t tx_offload;
12684 : : cmdline_fixed_string_t configuration;
12685 : : };
12686 : :
12687 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
12688 : : TOKEN_STRING_INITIALIZER
12689 : : (struct cmd_tx_offload_get_configuration_result,
12690 : : show, "show");
12691 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
12692 : : TOKEN_STRING_INITIALIZER
12693 : : (struct cmd_tx_offload_get_configuration_result,
12694 : : port, "port");
12695 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
12696 : : TOKEN_NUM_INITIALIZER
12697 : : (struct cmd_tx_offload_get_configuration_result,
12698 : : port_id, RTE_UINT16);
12699 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
12700 : : TOKEN_STRING_INITIALIZER
12701 : : (struct cmd_tx_offload_get_configuration_result,
12702 : : tx_offload, "tx_offload");
12703 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
12704 : : TOKEN_STRING_INITIALIZER
12705 : : (struct cmd_tx_offload_get_configuration_result,
12706 : : configuration, "configuration");
12707 : :
12708 : : static void
12709 : 0 : cmd_tx_offload_get_configuration_parsed(
12710 : : void *parsed_result,
12711 : : __rte_unused struct cmdline *cl,
12712 : : __rte_unused void *data)
12713 : : {
12714 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
12715 : : struct rte_eth_dev_info dev_info;
12716 : 0 : portid_t port_id = res->port_id;
12717 : : struct rte_port *port;
12718 : : struct rte_eth_conf dev_conf;
12719 : : uint64_t port_offloads;
12720 : : uint64_t queue_offloads;
12721 : : uint16_t nb_tx_queues;
12722 : : int q;
12723 : : int ret;
12724 : :
12725 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12726 : 0 : if (ret != 0)
12727 : 0 : return;
12728 : :
12729 : : printf("Tx Offloading Configuration of port %d :\n", port_id);
12730 : 0 : port = &ports[port_id];
12731 : 0 : port_offloads = dev_conf.txmode.offloads;
12732 : : printf(" Port :");
12733 : 0 : print_tx_offloads(port_offloads);
12734 : : printf("\n");
12735 : :
12736 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12737 : 0 : if (ret != 0)
12738 : : return;
12739 : :
12740 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12741 : 0 : for (q = 0; q < nb_tx_queues; q++) {
12742 : 0 : queue_offloads = port->txq[q].conf.offloads;
12743 : : printf(" Queue[%2d] :", q);
12744 : 0 : print_tx_offloads(queue_offloads);
12745 : : printf("\n");
12746 : : }
12747 : : printf("\n");
12748 : : }
12749 : :
12750 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
12751 : : .f = cmd_tx_offload_get_configuration_parsed,
12752 : : .data = NULL,
12753 : : .help_str = "show port <port_id> tx_offload configuration",
12754 : : .tokens = {
12755 : : (void *)&cmd_tx_offload_get_configuration_show,
12756 : : (void *)&cmd_tx_offload_get_configuration_port,
12757 : : (void *)&cmd_tx_offload_get_configuration_port_id,
12758 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
12759 : : (void *)&cmd_tx_offload_get_configuration_configuration,
12760 : : NULL,
12761 : : }
12762 : : };
12763 : :
12764 : : /* Enable/Disable a per port offloading */
12765 : : struct cmd_config_per_port_tx_offload_result {
12766 : : cmdline_fixed_string_t port;
12767 : : cmdline_fixed_string_t config;
12768 : : portid_t port_id;
12769 : : cmdline_fixed_string_t tx_offload;
12770 : : cmdline_fixed_string_t offload;
12771 : : cmdline_fixed_string_t on_off;
12772 : : };
12773 : :
12774 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
12775 : : TOKEN_STRING_INITIALIZER
12776 : : (struct cmd_config_per_port_tx_offload_result,
12777 : : port, "port");
12778 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
12779 : : TOKEN_STRING_INITIALIZER
12780 : : (struct cmd_config_per_port_tx_offload_result,
12781 : : config, "config");
12782 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
12783 : : TOKEN_NUM_INITIALIZER
12784 : : (struct cmd_config_per_port_tx_offload_result,
12785 : : port_id, RTE_UINT16);
12786 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
12787 : : TOKEN_STRING_INITIALIZER
12788 : : (struct cmd_config_per_port_tx_offload_result,
12789 : : tx_offload, "tx_offload");
12790 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
12791 : : TOKEN_STRING_INITIALIZER
12792 : : (struct cmd_config_per_port_tx_offload_result,
12793 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12794 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12795 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12796 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12797 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12798 : : "send_on_timestamp");
12799 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
12800 : : TOKEN_STRING_INITIALIZER
12801 : : (struct cmd_config_per_port_tx_offload_result,
12802 : : on_off, "on#off");
12803 : :
12804 : : static uint64_t
12805 : 0 : search_tx_offload(const char *name)
12806 : : {
12807 : : uint64_t single_offload;
12808 : : const char *single_name;
12809 : : int found = 0;
12810 : : unsigned int bit;
12811 : :
12812 : : single_offload = 1;
12813 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12814 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
12815 : 0 : if (single_name == NULL)
12816 : : break;
12817 : 0 : if (!strcasecmp(single_name, name)) {
12818 : : found = 1;
12819 : : break;
12820 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
12821 : : break;
12822 : 0 : single_offload <<= 1;
12823 : : }
12824 : :
12825 : 0 : if (found)
12826 : 0 : return single_offload;
12827 : :
12828 : : return 0;
12829 : : }
12830 : :
12831 : : static void
12832 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
12833 : : {
12834 : : struct rte_eth_dev_info dev_info;
12835 : : struct rte_port *port;
12836 : : uint16_t nb_tx_queues;
12837 : : uint64_t offload;
12838 : : int q;
12839 : : int ret;
12840 : :
12841 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12842 : 0 : if (ret != 0)
12843 : 0 : return;
12844 : :
12845 : 0 : port = &ports[port_id];
12846 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12847 : 0 : fprintf(stderr,
12848 : : "Error: Can't config offload when Port %d is not stopped\n",
12849 : : port_id);
12850 : 0 : return;
12851 : : }
12852 : :
12853 : 0 : if (!strcmp(name, "all")) {
12854 : 0 : offload = dev_info.tx_offload_capa;
12855 : : } else {
12856 : 0 : offload = search_tx_offload(name);
12857 : 0 : if (offload == 0) {
12858 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12859 : 0 : return;
12860 : : }
12861 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
12862 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12863 : : port_id, name);
12864 : 0 : return;
12865 : : }
12866 : : }
12867 : :
12868 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12869 : 0 : if (on) {
12870 : 0 : port->dev_conf.txmode.offloads |= offload;
12871 : 0 : for (q = 0; q < nb_tx_queues; q++)
12872 : 0 : port->txq[q].conf.offloads |= offload;
12873 : : } else {
12874 : 0 : port->dev_conf.txmode.offloads &= ~offload;
12875 : 0 : for (q = 0; q < nb_tx_queues; q++)
12876 : 0 : port->txq[q].conf.offloads &= ~offload;
12877 : : }
12878 : :
12879 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12880 : : }
12881 : :
12882 : : static void
12883 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
12884 : : __rte_unused struct cmdline *cl,
12885 : : __rte_unused void *data)
12886 : : {
12887 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
12888 : : bool on;
12889 : :
12890 : 0 : on = strcmp(res->on_off, "on") == 0;
12891 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
12892 : 0 : }
12893 : :
12894 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
12895 : : .f = cmd_config_per_port_tx_offload_parsed,
12896 : : .data = NULL,
12897 : : .help_str = "port config <port_id> tx_offload "
12898 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12899 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12900 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12901 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12902 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12903 : : "send_on_timestamp on|off",
12904 : : .tokens = {
12905 : : (void *)&cmd_config_per_port_tx_offload_result_port,
12906 : : (void *)&cmd_config_per_port_tx_offload_result_config,
12907 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
12908 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
12909 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
12910 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
12911 : : NULL,
12912 : : }
12913 : : };
12914 : :
12915 : : /* Enable/Disable all port Tx offloading */
12916 : : struct cmd_config_all_port_tx_offload_result {
12917 : : cmdline_fixed_string_t port;
12918 : : cmdline_fixed_string_t config;
12919 : : cmdline_fixed_string_t port_all;
12920 : : cmdline_fixed_string_t tx_offload;
12921 : : cmdline_fixed_string_t offload;
12922 : : cmdline_fixed_string_t on_off;
12923 : : };
12924 : :
12925 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
12926 : : TOKEN_STRING_INITIALIZER
12927 : : (struct cmd_config_all_port_tx_offload_result,
12928 : : port, "port");
12929 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
12930 : : TOKEN_STRING_INITIALIZER
12931 : : (struct cmd_config_all_port_tx_offload_result,
12932 : : config, "config");
12933 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
12934 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
12935 : : port_all, "all");
12936 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
12937 : : TOKEN_STRING_INITIALIZER
12938 : : (struct cmd_config_all_port_tx_offload_result,
12939 : : tx_offload, "tx_offload");
12940 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
12941 : : TOKEN_STRING_INITIALIZER
12942 : : (struct cmd_config_all_port_tx_offload_result,
12943 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12944 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12945 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12946 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12947 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12948 : : "send_on_timestamp");
12949 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
12950 : : TOKEN_STRING_INITIALIZER
12951 : : (struct cmd_config_all_port_tx_offload_result,
12952 : : on_off, "on#off");
12953 : :
12954 : : static void
12955 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
12956 : : __rte_unused struct cmdline *cl,
12957 : : __rte_unused void *data)
12958 : : {
12959 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
12960 : : portid_t i;
12961 : : bool on_off;
12962 : :
12963 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12964 : 0 : RTE_ETH_FOREACH_DEV(i)
12965 : 0 : config_port_tx_offload(i, res->offload, on_off);
12966 : 0 : }
12967 : :
12968 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
12969 : : .f = cmd_config_all_port_tx_offload_parsed,
12970 : : .data = NULL,
12971 : : .help_str = "port config all tx_offload "
12972 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12973 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12974 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12975 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12976 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12977 : : "send_on_timestamp on|off",
12978 : : .tokens = {
12979 : : (void *)&cmd_config_all_port_tx_offload_result_port,
12980 : : (void *)&cmd_config_all_port_tx_offload_result_config,
12981 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
12982 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
12983 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
12984 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
12985 : : NULL,
12986 : : }
12987 : : };
12988 : :
12989 : : /* Enable/Disable a per queue offloading */
12990 : : struct cmd_config_per_queue_tx_offload_result {
12991 : : cmdline_fixed_string_t port;
12992 : : portid_t port_id;
12993 : : cmdline_fixed_string_t txq;
12994 : : uint16_t queue_id;
12995 : : cmdline_fixed_string_t tx_offload;
12996 : : cmdline_fixed_string_t offload;
12997 : : cmdline_fixed_string_t on_off;
12998 : : };
12999 : :
13000 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
13001 : : TOKEN_STRING_INITIALIZER
13002 : : (struct cmd_config_per_queue_tx_offload_result,
13003 : : port, "port");
13004 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
13005 : : TOKEN_NUM_INITIALIZER
13006 : : (struct cmd_config_per_queue_tx_offload_result,
13007 : : port_id, RTE_UINT16);
13008 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
13009 : : TOKEN_STRING_INITIALIZER
13010 : : (struct cmd_config_per_queue_tx_offload_result,
13011 : : txq, "txq");
13012 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
13013 : : TOKEN_NUM_INITIALIZER
13014 : : (struct cmd_config_per_queue_tx_offload_result,
13015 : : queue_id, RTE_UINT16);
13016 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
13017 : : TOKEN_STRING_INITIALIZER
13018 : : (struct cmd_config_per_queue_tx_offload_result,
13019 : : tx_offload, "tx_offload");
13020 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
13021 : : TOKEN_STRING_INITIALIZER
13022 : : (struct cmd_config_per_queue_tx_offload_result,
13023 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
13024 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
13025 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
13026 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
13027 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
13028 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
13029 : : TOKEN_STRING_INITIALIZER
13030 : : (struct cmd_config_per_queue_tx_offload_result,
13031 : : on_off, "on#off");
13032 : :
13033 : : static void
13034 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
13035 : : __rte_unused struct cmdline *cl,
13036 : : __rte_unused void *data)
13037 : : {
13038 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
13039 : : struct rte_eth_dev_info dev_info;
13040 : 0 : portid_t port_id = res->port_id;
13041 : 0 : uint16_t queue_id = res->queue_id;
13042 : : struct rte_port *port;
13043 : : uint64_t offload;
13044 : : int ret;
13045 : :
13046 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
13047 : 0 : if (ret != 0)
13048 : 0 : return;
13049 : :
13050 : 0 : port = &ports[port_id];
13051 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
13052 : 0 : fprintf(stderr,
13053 : : "Error: Can't config offload when Port %d is not stopped\n",
13054 : : port_id);
13055 : 0 : return;
13056 : : }
13057 : :
13058 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
13059 : 0 : fprintf(stderr,
13060 : : "Error: input queue_id should be 0 ... %d\n",
13061 : 0 : dev_info.nb_tx_queues - 1);
13062 : 0 : return;
13063 : : }
13064 : :
13065 : 0 : if (!strcmp(res->offload, "all")) {
13066 : 0 : offload = dev_info.tx_queue_offload_capa;
13067 : : } else {
13068 : 0 : offload = search_tx_offload(res->offload);
13069 : 0 : if (offload == 0) {
13070 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
13071 : 0 : return;
13072 : : }
13073 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
13074 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
13075 : : port_id, res->offload);
13076 : 0 : return;
13077 : : }
13078 : : }
13079 : :
13080 : 0 : if (!strcmp(res->on_off, "on"))
13081 : 0 : port->txq[queue_id].conf.offloads |= offload;
13082 : : else
13083 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
13084 : :
13085 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
13086 : : }
13087 : :
13088 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
13089 : : .f = cmd_config_per_queue_tx_offload_parsed,
13090 : : .data = NULL,
13091 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
13092 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
13093 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
13094 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
13095 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
13096 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
13097 : : "on|off",
13098 : : .tokens = {
13099 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
13100 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
13101 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
13102 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
13103 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
13104 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
13105 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
13106 : : NULL,
13107 : : }
13108 : : };
13109 : :
13110 : : /* *** configure tx_metadata for specific port *** */
13111 : : struct cmd_config_tx_metadata_specific_result {
13112 : : cmdline_fixed_string_t port;
13113 : : cmdline_fixed_string_t keyword;
13114 : : uint16_t port_id;
13115 : : cmdline_fixed_string_t item;
13116 : : uint32_t value;
13117 : : };
13118 : :
13119 : : static void
13120 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
13121 : : __rte_unused struct cmdline *cl,
13122 : : __rte_unused void *data)
13123 : : {
13124 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
13125 : :
13126 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13127 : : return;
13128 : 0 : ports[res->port_id].tx_metadata = res->value;
13129 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
13130 : 0 : if (ports[res->port_id].tx_metadata)
13131 : 0 : add_tx_md_callback(res->port_id);
13132 : : else
13133 : 0 : remove_tx_md_callback(res->port_id);
13134 : 0 : rte_flow_dynf_metadata_register();
13135 : : }
13136 : :
13137 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
13138 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13139 : : port, "port");
13140 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
13141 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13142 : : keyword, "config");
13143 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
13144 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13145 : : port_id, RTE_UINT16);
13146 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
13147 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13148 : : item, "tx_metadata");
13149 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
13150 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
13151 : : value, RTE_UINT32);
13152 : :
13153 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
13154 : : .f = cmd_config_tx_metadata_specific_parsed,
13155 : : .data = NULL,
13156 : : .help_str = "port config <port_id> tx_metadata <value>",
13157 : : .tokens = {
13158 : : (void *)&cmd_config_tx_metadata_specific_port,
13159 : : (void *)&cmd_config_tx_metadata_specific_keyword,
13160 : : (void *)&cmd_config_tx_metadata_specific_id,
13161 : : (void *)&cmd_config_tx_metadata_specific_item,
13162 : : (void *)&cmd_config_tx_metadata_specific_value,
13163 : : NULL,
13164 : : },
13165 : : };
13166 : :
13167 : : /* *** set dynf *** */
13168 : : struct cmd_config_tx_dynf_specific_result {
13169 : : cmdline_fixed_string_t port;
13170 : : cmdline_fixed_string_t keyword;
13171 : : uint16_t port_id;
13172 : : cmdline_fixed_string_t item;
13173 : : cmdline_fixed_string_t name;
13174 : : cmdline_fixed_string_t value;
13175 : : };
13176 : :
13177 : : static void
13178 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
13179 : : __rte_unused struct cmdline *cl,
13180 : : __rte_unused void *data)
13181 : : {
13182 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
13183 : : struct rte_mbuf_dynflag desc_flag;
13184 : : int flag;
13185 : : uint64_t old_port_flags;
13186 : :
13187 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13188 : 0 : return;
13189 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
13190 : 0 : if (flag <= 0) {
13191 : 0 : if (strlcpy(desc_flag.name, res->name,
13192 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
13193 : 0 : fprintf(stderr, "Flag name too long\n");
13194 : 0 : return;
13195 : : }
13196 : 0 : desc_flag.flags = 0;
13197 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
13198 : 0 : if (flag < 0) {
13199 : 0 : fprintf(stderr, "Can't register flag\n");
13200 : 0 : return;
13201 : : }
13202 : 0 : strcpy(dynf_names[flag], desc_flag.name);
13203 : : }
13204 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
13205 : 0 : if (!strcmp(res->value, "set")) {
13206 : 0 : ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
13207 : 0 : if (old_port_flags == 0)
13208 : 0 : add_tx_dynf_callback(res->port_id);
13209 : : } else {
13210 : 0 : ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
13211 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
13212 : 0 : remove_tx_dynf_callback(res->port_id);
13213 : : }
13214 : : }
13215 : :
13216 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
13217 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13218 : : keyword, "port");
13219 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
13220 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13221 : : keyword, "config");
13222 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
13223 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13224 : : port_id, RTE_UINT16);
13225 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
13226 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13227 : : item, "dynf");
13228 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
13229 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13230 : : name, NULL);
13231 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
13232 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13233 : : value, "set#clear");
13234 : :
13235 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
13236 : : .f = cmd_config_dynf_specific_parsed,
13237 : : .data = NULL,
13238 : : .help_str = "port config <port id> dynf <name> set|clear",
13239 : : .tokens = {
13240 : : (void *)&cmd_config_tx_dynf_specific_port,
13241 : : (void *)&cmd_config_tx_dynf_specific_keyword,
13242 : : (void *)&cmd_config_tx_dynf_specific_port_id,
13243 : : (void *)&cmd_config_tx_dynf_specific_item,
13244 : : (void *)&cmd_config_tx_dynf_specific_name,
13245 : : (void *)&cmd_config_tx_dynf_specific_value,
13246 : : NULL,
13247 : : },
13248 : : };
13249 : :
13250 : : /* *** display tx_metadata per port configuration *** */
13251 : : struct cmd_show_tx_metadata_result {
13252 : : cmdline_fixed_string_t cmd_show;
13253 : : cmdline_fixed_string_t cmd_port;
13254 : : cmdline_fixed_string_t cmd_keyword;
13255 : : portid_t cmd_pid;
13256 : : };
13257 : :
13258 : : static void
13259 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
13260 : : __rte_unused struct cmdline *cl,
13261 : : __rte_unused void *data)
13262 : : {
13263 : : struct cmd_show_tx_metadata_result *res = parsed_result;
13264 : :
13265 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13266 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
13267 : 0 : return;
13268 : : }
13269 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
13270 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
13271 : 0 : ports[res->cmd_pid].tx_metadata);
13272 : : }
13273 : : }
13274 : :
13275 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
13276 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13277 : : cmd_show, "show");
13278 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
13279 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13280 : : cmd_port, "port");
13281 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
13282 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
13283 : : cmd_pid, RTE_UINT16);
13284 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
13285 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13286 : : cmd_keyword, "tx_metadata");
13287 : :
13288 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
13289 : : .f = cmd_show_tx_metadata_parsed,
13290 : : .data = NULL,
13291 : : .help_str = "show port <port_id> tx_metadata",
13292 : : .tokens = {
13293 : : (void *)&cmd_show_tx_metadata_show,
13294 : : (void *)&cmd_show_tx_metadata_port,
13295 : : (void *)&cmd_show_tx_metadata_pid,
13296 : : (void *)&cmd_show_tx_metadata_keyword,
13297 : : NULL,
13298 : : },
13299 : : };
13300 : :
13301 : : /* *** show fec capability per port configuration *** */
13302 : : struct cmd_show_fec_capability_result {
13303 : : cmdline_fixed_string_t cmd_show;
13304 : : cmdline_fixed_string_t cmd_port;
13305 : : cmdline_fixed_string_t cmd_fec;
13306 : : cmdline_fixed_string_t cmd_keyword;
13307 : : portid_t cmd_pid;
13308 : : };
13309 : :
13310 : : static void
13311 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
13312 : : __rte_unused struct cmdline *cl,
13313 : : __rte_unused void *data)
13314 : : {
13315 : : struct cmd_show_fec_capability_result *res = parsed_result;
13316 : : struct rte_eth_fec_capa *speed_fec_capa;
13317 : : unsigned int num;
13318 : : int ret;
13319 : :
13320 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13321 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13322 : 0 : return;
13323 : : }
13324 : :
13325 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
13326 : 0 : if (ret == -ENOTSUP) {
13327 : 0 : fprintf(stderr, "Function not implemented\n");
13328 : 0 : return;
13329 : 0 : } else if (ret < 0) {
13330 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
13331 : 0 : return;
13332 : : }
13333 : :
13334 : 0 : num = (unsigned int)ret;
13335 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
13336 : 0 : if (speed_fec_capa == NULL) {
13337 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
13338 : 0 : return;
13339 : : }
13340 : :
13341 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
13342 : 0 : if (ret < 0) {
13343 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
13344 : 0 : goto out;
13345 : : }
13346 : :
13347 : 0 : show_fec_capability(num, speed_fec_capa);
13348 : 0 : out:
13349 : 0 : free(speed_fec_capa);
13350 : : }
13351 : :
13352 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
13353 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13354 : : cmd_show, "show");
13355 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
13356 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13357 : : cmd_port, "port");
13358 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
13359 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
13360 : : cmd_pid, RTE_UINT16);
13361 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
13362 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13363 : : cmd_fec, "fec");
13364 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
13365 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13366 : : cmd_keyword, "capabilities");
13367 : :
13368 : : static cmdline_parse_inst_t cmd_show_capability = {
13369 : : .f = cmd_show_fec_capability_parsed,
13370 : : .data = NULL,
13371 : : .help_str = "show port <port_id> fec capabilities",
13372 : : .tokens = {
13373 : : (void *)&cmd_show_fec_capability_show,
13374 : : (void *)&cmd_show_fec_capability_port,
13375 : : (void *)&cmd_show_fec_capability_pid,
13376 : : (void *)&cmd_show_fec_capability_fec,
13377 : : (void *)&cmd_show_fec_capability_keyword,
13378 : : NULL,
13379 : : },
13380 : : };
13381 : :
13382 : : /* *** show fec mode per port configuration *** */
13383 : : struct cmd_show_fec_metadata_result {
13384 : : cmdline_fixed_string_t cmd_show;
13385 : : cmdline_fixed_string_t cmd_port;
13386 : : cmdline_fixed_string_t cmd_keyword;
13387 : : portid_t cmd_pid;
13388 : : };
13389 : :
13390 : : static void
13391 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
13392 : : __rte_unused struct cmdline *cl,
13393 : : __rte_unused void *data)
13394 : : {
13395 : : #define FEC_NAME_SIZE 16
13396 : : struct cmd_show_fec_metadata_result *res = parsed_result;
13397 : : uint32_t mode;
13398 : : char buf[FEC_NAME_SIZE];
13399 : : int ret;
13400 : :
13401 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13402 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13403 : 0 : return;
13404 : : }
13405 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
13406 : 0 : if (ret == -ENOTSUP) {
13407 : 0 : fprintf(stderr, "Function not implemented\n");
13408 : 0 : return;
13409 : 0 : } else if (ret < 0) {
13410 : 0 : fprintf(stderr, "Get FEC mode failed\n");
13411 : 0 : return;
13412 : : }
13413 : :
13414 : 0 : switch (mode) {
13415 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
13416 : : strlcpy(buf, "off", sizeof(buf));
13417 : : break;
13418 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
13419 : : strlcpy(buf, "auto", sizeof(buf));
13420 : : break;
13421 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
13422 : : strlcpy(buf, "baser", sizeof(buf));
13423 : : break;
13424 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
13425 : : strlcpy(buf, "rs", sizeof(buf));
13426 : : break;
13427 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
13428 : : strlcpy(buf, "llrs", sizeof(buf));
13429 : : break;
13430 : : default:
13431 : : return;
13432 : : }
13433 : :
13434 : : printf("%s\n", buf);
13435 : : }
13436 : :
13437 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
13438 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13439 : : cmd_show, "show");
13440 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
13441 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13442 : : cmd_port, "port");
13443 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
13444 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
13445 : : cmd_pid, RTE_UINT16);
13446 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
13447 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13448 : : cmd_keyword, "fec_mode");
13449 : :
13450 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
13451 : : .f = cmd_show_fec_mode_parsed,
13452 : : .data = NULL,
13453 : : .help_str = "show port <port_id> fec_mode",
13454 : : .tokens = {
13455 : : (void *)&cmd_show_fec_mode_show,
13456 : : (void *)&cmd_show_fec_mode_port,
13457 : : (void *)&cmd_show_fec_mode_pid,
13458 : : (void *)&cmd_show_fec_mode_keyword,
13459 : : NULL,
13460 : : },
13461 : : };
13462 : :
13463 : : /* *** set fec mode per port configuration *** */
13464 : : struct cmd_set_port_fec_mode {
13465 : : cmdline_fixed_string_t set;
13466 : : cmdline_fixed_string_t port;
13467 : : portid_t port_id;
13468 : : cmdline_fixed_string_t fec_mode;
13469 : : cmdline_fixed_string_t fec_value;
13470 : : };
13471 : :
13472 : : /* Common CLI fields for set fec mode */
13473 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
13474 : : TOKEN_STRING_INITIALIZER
13475 : : (struct cmd_set_port_fec_mode,
13476 : : set, "set");
13477 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
13478 : : TOKEN_STRING_INITIALIZER
13479 : : (struct cmd_set_port_fec_mode,
13480 : : port, "port");
13481 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
13482 : : TOKEN_NUM_INITIALIZER
13483 : : (struct cmd_set_port_fec_mode,
13484 : : port_id, RTE_UINT16);
13485 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
13486 : : TOKEN_STRING_INITIALIZER
13487 : : (struct cmd_set_port_fec_mode,
13488 : : fec_mode, "fec_mode");
13489 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
13490 : : TOKEN_STRING_INITIALIZER
13491 : : (struct cmd_set_port_fec_mode,
13492 : : fec_value, NULL);
13493 : :
13494 : : static void
13495 : 0 : cmd_set_port_fec_mode_parsed(
13496 : : void *parsed_result,
13497 : : __rte_unused struct cmdline *cl,
13498 : : __rte_unused void *data)
13499 : : {
13500 : : struct cmd_set_port_fec_mode *res = parsed_result;
13501 : 0 : uint16_t port_id = res->port_id;
13502 : : uint32_t fec_capa;
13503 : : int ret;
13504 : :
13505 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
13506 : 0 : if (ret < 0) {
13507 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
13508 : : res->fec_value, port_id);
13509 : 0 : return;
13510 : : }
13511 : :
13512 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
13513 : 0 : if (ret == -ENOTSUP) {
13514 : 0 : fprintf(stderr, "Function not implemented\n");
13515 : 0 : return;
13516 : 0 : } else if (ret < 0) {
13517 : 0 : fprintf(stderr, "Set FEC mode failed\n");
13518 : 0 : return;
13519 : : }
13520 : : }
13521 : :
13522 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
13523 : : .f = cmd_set_port_fec_mode_parsed,
13524 : : .data = NULL,
13525 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
13526 : : .tokens = {
13527 : : (void *)&cmd_set_port_fec_mode_set,
13528 : : (void *)&cmd_set_port_fec_mode_port,
13529 : : (void *)&cmd_set_port_fec_mode_port_id,
13530 : : (void *)&cmd_set_port_fec_mode_str,
13531 : : (void *)&cmd_set_port_fec_mode_value,
13532 : : NULL,
13533 : : },
13534 : : };
13535 : :
13536 : : /* *** set available descriptors threshold for an RxQ of a port *** */
13537 : : struct cmd_set_rxq_avail_thresh_result {
13538 : : cmdline_fixed_string_t set;
13539 : : cmdline_fixed_string_t port;
13540 : : uint16_t port_num;
13541 : : cmdline_fixed_string_t rxq;
13542 : : uint16_t rxq_num;
13543 : : cmdline_fixed_string_t avail_thresh;
13544 : : uint8_t avail_thresh_num;
13545 : : };
13546 : :
13547 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
13548 : : __rte_unused struct cmdline *cl,
13549 : : __rte_unused void *data)
13550 : : {
13551 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
13552 : : int ret = 0;
13553 : :
13554 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
13555 : 0 : && (strcmp(res->rxq, "rxq") == 0)
13556 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
13557 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
13558 : 0 : res->avail_thresh_num);
13559 : 0 : if (ret < 0)
13560 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
13561 : :
13562 : 0 : }
13563 : :
13564 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
13565 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13566 : : set, "set");
13567 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
13568 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13569 : : port, "port");
13570 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
13571 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13572 : : port_num, RTE_UINT16);
13573 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
13574 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13575 : : rxq, "rxq");
13576 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
13577 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13578 : : rxq_num, RTE_UINT16);
13579 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
13580 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13581 : : avail_thresh, "avail_thresh");
13582 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
13583 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13584 : : avail_thresh_num, RTE_UINT8);
13585 : :
13586 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
13587 : : .f = cmd_set_rxq_avail_thresh_parsed,
13588 : : .data = (void *)0,
13589 : : .help_str =
13590 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
13591 : : "Set available descriptors threshold for Rx queue",
13592 : : .tokens = {
13593 : : (void *)&cmd_set_rxq_avail_thresh_set,
13594 : : (void *)&cmd_set_rxq_avail_thresh_port,
13595 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
13596 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
13597 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
13598 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
13599 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
13600 : : NULL,
13601 : : },
13602 : : };
13603 : :
13604 : : /* show port supported ptypes */
13605 : :
13606 : : /* Common result structure for show port ptypes */
13607 : : struct cmd_show_port_supported_ptypes_result {
13608 : : cmdline_fixed_string_t show;
13609 : : cmdline_fixed_string_t port;
13610 : : portid_t port_id;
13611 : : cmdline_fixed_string_t ptypes;
13612 : : };
13613 : :
13614 : : /* Common CLI fields for show port ptypes */
13615 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
13616 : : TOKEN_STRING_INITIALIZER
13617 : : (struct cmd_show_port_supported_ptypes_result,
13618 : : show, "show");
13619 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
13620 : : TOKEN_STRING_INITIALIZER
13621 : : (struct cmd_show_port_supported_ptypes_result,
13622 : : port, "port");
13623 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
13624 : : TOKEN_NUM_INITIALIZER
13625 : : (struct cmd_show_port_supported_ptypes_result,
13626 : : port_id, RTE_UINT16);
13627 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
13628 : : TOKEN_STRING_INITIALIZER
13629 : : (struct cmd_show_port_supported_ptypes_result,
13630 : : ptypes, "ptypes");
13631 : :
13632 : : static void
13633 : 0 : cmd_show_port_supported_ptypes_parsed(
13634 : : void *parsed_result,
13635 : : __rte_unused struct cmdline *cl,
13636 : : __rte_unused void *data)
13637 : : {
13638 : : #define RSVD_PTYPE_MASK 0xf0000000
13639 : : #define MAX_PTYPES_PER_LAYER 16
13640 : : #define LTYPE_NAMESIZE 32
13641 : : #define PTYPE_NAMESIZE 256
13642 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
13643 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
13644 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
13645 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
13646 : 0 : uint16_t port_id = res->port_id;
13647 : : int ret, i;
13648 : :
13649 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
13650 : 0 : if (ret < 0)
13651 : 0 : return;
13652 : :
13653 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
13654 : :
13655 : 0 : switch (ptype_mask) {
13656 : : case RTE_PTYPE_L2_MASK:
13657 : : strlcpy(ltype, "L2", sizeof(ltype));
13658 : : break;
13659 : : case RTE_PTYPE_L3_MASK:
13660 : : strlcpy(ltype, "L3", sizeof(ltype));
13661 : : break;
13662 : : case RTE_PTYPE_L4_MASK:
13663 : : strlcpy(ltype, "L4", sizeof(ltype));
13664 : : break;
13665 : : case RTE_PTYPE_TUNNEL_MASK:
13666 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
13667 : : break;
13668 : : case RTE_PTYPE_INNER_L2_MASK:
13669 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
13670 : : break;
13671 : : case RTE_PTYPE_INNER_L3_MASK:
13672 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
13673 : : break;
13674 : : case RTE_PTYPE_INNER_L4_MASK:
13675 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
13676 : : break;
13677 : : default:
13678 : : return;
13679 : : }
13680 : :
13681 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
13682 : : ptype_mask, ptypes,
13683 : : MAX_PTYPES_PER_LAYER);
13684 : :
13685 : 0 : if (ret > 0)
13686 : : printf("Supported %s ptypes:\n", ltype);
13687 : : else
13688 : : printf("%s ptypes unsupported\n", ltype);
13689 : :
13690 : 0 : for (i = 0; i < ret; ++i) {
13691 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
13692 : : printf("%s\n", buf);
13693 : : }
13694 : :
13695 : 0 : ptype_mask <<= 4;
13696 : : }
13697 : : }
13698 : :
13699 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
13700 : : .f = cmd_show_port_supported_ptypes_parsed,
13701 : : .data = NULL,
13702 : : .help_str = "show port <port_id> ptypes",
13703 : : .tokens = {
13704 : : (void *)&cmd_show_port_supported_ptypes_show,
13705 : : (void *)&cmd_show_port_supported_ptypes_port,
13706 : : (void *)&cmd_show_port_supported_ptypes_port_id,
13707 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
13708 : : NULL,
13709 : : },
13710 : : };
13711 : :
13712 : : /* *** display rx/tx descriptor status *** */
13713 : : struct cmd_show_rx_tx_desc_status_result {
13714 : : cmdline_fixed_string_t cmd_show;
13715 : : cmdline_fixed_string_t cmd_port;
13716 : : cmdline_fixed_string_t cmd_keyword;
13717 : : cmdline_fixed_string_t cmd_desc;
13718 : : cmdline_fixed_string_t cmd_status;
13719 : : portid_t cmd_pid;
13720 : : portid_t cmd_qid;
13721 : : portid_t cmd_did;
13722 : : };
13723 : :
13724 : : static void
13725 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
13726 : : __rte_unused struct cmdline *cl,
13727 : : __rte_unused void *data)
13728 : : {
13729 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
13730 : : int rc;
13731 : :
13732 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
13733 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13734 : 0 : fprintf(stderr,
13735 : : "Invalid input: port id = %d, queue id = %d\n",
13736 : 0 : res->cmd_pid, res->cmd_qid);
13737 : 0 : return;
13738 : : }
13739 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
13740 : 0 : res->cmd_did);
13741 : 0 : if (rc < 0) {
13742 : 0 : fprintf(stderr,
13743 : : "Invalid input: queue id = %d, desc id = %d\n",
13744 : 0 : res->cmd_qid, res->cmd_did);
13745 : 0 : return;
13746 : : }
13747 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
13748 : : printf("Desc status = AVAILABLE\n");
13749 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
13750 : : printf("Desc status = DONE\n");
13751 : : else
13752 : : printf("Desc status = UNAVAILABLE\n");
13753 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
13754 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13755 : 0 : fprintf(stderr,
13756 : : "Invalid input: port id = %d, queue id = %d\n",
13757 : 0 : res->cmd_pid, res->cmd_qid);
13758 : 0 : return;
13759 : : }
13760 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
13761 : 0 : res->cmd_did);
13762 : 0 : if (rc < 0) {
13763 : 0 : fprintf(stderr,
13764 : : "Invalid input: queue id = %d, desc id = %d\n",
13765 : 0 : res->cmd_qid, res->cmd_did);
13766 : 0 : return;
13767 : : }
13768 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
13769 : : printf("Desc status = FULL\n");
13770 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
13771 : : printf("Desc status = DONE\n");
13772 : : else
13773 : : printf("Desc status = UNAVAILABLE\n");
13774 : : }
13775 : : }
13776 : :
13777 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
13778 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13779 : : cmd_show, "show");
13780 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
13781 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13782 : : cmd_port, "port");
13783 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
13784 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13785 : : cmd_pid, RTE_UINT16);
13786 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
13787 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13788 : : cmd_keyword, "rxq#txq");
13789 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
13790 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13791 : : cmd_qid, RTE_UINT16);
13792 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
13793 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13794 : : cmd_desc, "desc");
13795 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
13796 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13797 : : cmd_did, RTE_UINT16);
13798 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
13799 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13800 : : cmd_status, "status");
13801 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
13802 : : .f = cmd_show_rx_tx_desc_status_parsed,
13803 : : .data = NULL,
13804 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
13805 : : "status",
13806 : : .tokens = {
13807 : : (void *)&cmd_show_rx_tx_desc_status_show,
13808 : : (void *)&cmd_show_rx_tx_desc_status_port,
13809 : : (void *)&cmd_show_rx_tx_desc_status_pid,
13810 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
13811 : : (void *)&cmd_show_rx_tx_desc_status_qid,
13812 : : (void *)&cmd_show_rx_tx_desc_status_desc,
13813 : : (void *)&cmd_show_rx_tx_desc_status_did,
13814 : : (void *)&cmd_show_rx_tx_desc_status_status,
13815 : : NULL,
13816 : : },
13817 : : };
13818 : :
13819 : : /* *** display rx/tx queue descriptor used count *** */
13820 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
13821 : : cmdline_fixed_string_t cmd_show;
13822 : : cmdline_fixed_string_t cmd_port;
13823 : : cmdline_fixed_string_t cmd_dir;
13824 : : cmdline_fixed_string_t cmd_desc;
13825 : : cmdline_fixed_string_t cmd_used;
13826 : : cmdline_fixed_string_t cmd_count;
13827 : : portid_t cmd_pid;
13828 : : portid_t cmd_qid;
13829 : : };
13830 : :
13831 : : static void
13832 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
13833 : : __rte_unused void *data)
13834 : : {
13835 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
13836 : : int rc;
13837 : :
13838 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
13839 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13840 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13841 : 0 : res->cmd_pid, res->cmd_qid);
13842 : 0 : return;
13843 : : }
13844 : :
13845 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
13846 : 0 : if (rc < 0) {
13847 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
13848 : 0 : res->cmd_qid);
13849 : 0 : return;
13850 : : }
13851 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
13852 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
13853 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13854 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13855 : 0 : res->cmd_pid, res->cmd_qid);
13856 : 0 : return;
13857 : : }
13858 : :
13859 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
13860 : 0 : if (rc < 0) {
13861 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
13862 : 0 : res->cmd_qid);
13863 : 0 : return;
13864 : : }
13865 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
13866 : : }
13867 : : }
13868 : :
13869 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
13870 : : TOKEN_STRING_INITIALIZER
13871 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13872 : : cmd_show, "show");
13873 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
13874 : : TOKEN_STRING_INITIALIZER
13875 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13876 : : cmd_port, "port");
13877 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
13878 : : TOKEN_NUM_INITIALIZER
13879 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13880 : : cmd_pid, RTE_UINT16);
13881 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
13882 : : TOKEN_STRING_INITIALIZER
13883 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13884 : : cmd_dir, "rxq#txq");
13885 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
13886 : : TOKEN_NUM_INITIALIZER
13887 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13888 : : cmd_qid, RTE_UINT16);
13889 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
13890 : : TOKEN_STRING_INITIALIZER
13891 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13892 : : cmd_desc, "desc");
13893 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
13894 : : TOKEN_STRING_INITIALIZER
13895 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13896 : : cmd_count, "used");
13897 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
13898 : : TOKEN_STRING_INITIALIZER
13899 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13900 : : cmd_count, "count");
13901 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
13902 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
13903 : : .data = NULL,
13904 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
13905 : : .tokens = {
13906 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
13907 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
13908 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
13909 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
13910 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
13911 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
13912 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
13913 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
13914 : : NULL,
13915 : : },
13916 : : };
13917 : :
13918 : : /* Common result structure for set port ptypes */
13919 : : struct cmd_set_port_ptypes_result {
13920 : : cmdline_fixed_string_t set;
13921 : : cmdline_fixed_string_t port;
13922 : : portid_t port_id;
13923 : : cmdline_fixed_string_t ptype_mask;
13924 : : uint32_t mask;
13925 : : };
13926 : :
13927 : : /* Common CLI fields for set port ptypes */
13928 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
13929 : : TOKEN_STRING_INITIALIZER
13930 : : (struct cmd_set_port_ptypes_result,
13931 : : set, "set");
13932 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
13933 : : TOKEN_STRING_INITIALIZER
13934 : : (struct cmd_set_port_ptypes_result,
13935 : : port, "port");
13936 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
13937 : : TOKEN_NUM_INITIALIZER
13938 : : (struct cmd_set_port_ptypes_result,
13939 : : port_id, RTE_UINT16);
13940 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
13941 : : TOKEN_STRING_INITIALIZER
13942 : : (struct cmd_set_port_ptypes_result,
13943 : : ptype_mask, "ptype_mask");
13944 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
13945 : : TOKEN_NUM_INITIALIZER
13946 : : (struct cmd_set_port_ptypes_result,
13947 : : mask, RTE_UINT32);
13948 : :
13949 : : static void
13950 : 0 : cmd_set_port_ptypes_parsed(
13951 : : void *parsed_result,
13952 : : __rte_unused struct cmdline *cl,
13953 : : __rte_unused void *data)
13954 : : {
13955 : : struct cmd_set_port_ptypes_result *res = parsed_result;
13956 : : #define PTYPE_NAMESIZE 256
13957 : : char ptype_name[PTYPE_NAMESIZE];
13958 : 0 : uint16_t port_id = res->port_id;
13959 : 0 : uint32_t ptype_mask = res->mask;
13960 : : int ret, i;
13961 : :
13962 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
13963 : : NULL, 0);
13964 : 0 : if (ret <= 0) {
13965 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
13966 : : port_id);
13967 : 0 : return;
13968 : : }
13969 : :
13970 : 0 : uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
13971 : :
13972 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
13973 : 0 : if (ret < 0) {
13974 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
13975 : : port_id);
13976 : 0 : return;
13977 : : }
13978 : :
13979 : : printf("Successfully set following ptypes for Port %d\n", port_id);
13980 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
13981 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
13982 : : printf("%s\n", ptype_name);
13983 : : }
13984 : :
13985 : 0 : clear_ptypes = false;
13986 : : }
13987 : :
13988 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
13989 : : .f = cmd_set_port_ptypes_parsed,
13990 : : .data = NULL,
13991 : : .help_str = "set port <port_id> ptype_mask <mask>",
13992 : : .tokens = {
13993 : : (void *)&cmd_set_port_ptypes_set,
13994 : : (void *)&cmd_set_port_ptypes_port,
13995 : : (void *)&cmd_set_port_ptypes_port_id,
13996 : : (void *)&cmd_set_port_ptypes_mask_str,
13997 : : (void *)&cmd_set_port_ptypes_mask_u32,
13998 : : NULL,
13999 : : },
14000 : : };
14001 : :
14002 : : /* *** display mac addresses added to a port *** */
14003 : : struct cmd_showport_macs_result {
14004 : : cmdline_fixed_string_t cmd_show;
14005 : : cmdline_fixed_string_t cmd_port;
14006 : : cmdline_fixed_string_t cmd_keyword;
14007 : : portid_t cmd_pid;
14008 : : };
14009 : :
14010 : : static void
14011 : 0 : cmd_showport_macs_parsed(void *parsed_result,
14012 : : __rte_unused struct cmdline *cl,
14013 : : __rte_unused void *data)
14014 : : {
14015 : : struct cmd_showport_macs_result *res = parsed_result;
14016 : :
14017 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
14018 : : return;
14019 : :
14020 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
14021 : 0 : show_macs(res->cmd_pid);
14022 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
14023 : 0 : show_mcast_macs(res->cmd_pid);
14024 : : }
14025 : :
14026 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
14027 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
14028 : : cmd_show, "show");
14029 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
14030 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
14031 : : cmd_port, "port");
14032 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
14033 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
14034 : : cmd_pid, RTE_UINT16);
14035 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
14036 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
14037 : : cmd_keyword, "macs#mcast_macs");
14038 : :
14039 : : static cmdline_parse_inst_t cmd_showport_macs = {
14040 : : .f = cmd_showport_macs_parsed,
14041 : : .data = NULL,
14042 : : .help_str = "show port <port_id> macs|mcast_macs",
14043 : : .tokens = {
14044 : : (void *)&cmd_showport_macs_show,
14045 : : (void *)&cmd_showport_macs_port,
14046 : : (void *)&cmd_showport_macs_pid,
14047 : : (void *)&cmd_showport_macs_keyword,
14048 : : NULL,
14049 : : },
14050 : : };
14051 : :
14052 : : /* *** show flow transfer proxy port ID for the given port *** */
14053 : : struct cmd_show_port_flow_transfer_proxy_result {
14054 : : cmdline_fixed_string_t show;
14055 : : cmdline_fixed_string_t port;
14056 : : portid_t port_id;
14057 : : cmdline_fixed_string_t flow;
14058 : : cmdline_fixed_string_t transfer;
14059 : : cmdline_fixed_string_t proxy;
14060 : : };
14061 : :
14062 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
14063 : : TOKEN_STRING_INITIALIZER
14064 : : (struct cmd_show_port_flow_transfer_proxy_result,
14065 : : show, "show");
14066 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
14067 : : TOKEN_STRING_INITIALIZER
14068 : : (struct cmd_show_port_flow_transfer_proxy_result,
14069 : : port, "port");
14070 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
14071 : : TOKEN_NUM_INITIALIZER
14072 : : (struct cmd_show_port_flow_transfer_proxy_result,
14073 : : port_id, RTE_UINT16);
14074 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
14075 : : TOKEN_STRING_INITIALIZER
14076 : : (struct cmd_show_port_flow_transfer_proxy_result,
14077 : : flow, "flow");
14078 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
14079 : : TOKEN_STRING_INITIALIZER
14080 : : (struct cmd_show_port_flow_transfer_proxy_result,
14081 : : transfer, "transfer");
14082 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
14083 : : TOKEN_STRING_INITIALIZER
14084 : : (struct cmd_show_port_flow_transfer_proxy_result,
14085 : : proxy, "proxy");
14086 : :
14087 : : static void
14088 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
14089 : : __rte_unused struct cmdline *cl,
14090 : : __rte_unused void *data)
14091 : : {
14092 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
14093 : : portid_t proxy_port_id;
14094 : : int ret;
14095 : :
14096 : : printf("\n");
14097 : :
14098 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
14099 : 0 : if (ret != 0) {
14100 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
14101 : : rte_strerror(-ret));
14102 : 0 : return;
14103 : : }
14104 : :
14105 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
14106 : : }
14107 : :
14108 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
14109 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
14110 : : .data = NULL,
14111 : : .help_str = "show port <port_id> flow transfer proxy",
14112 : : .tokens = {
14113 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
14114 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
14115 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
14116 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
14117 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
14118 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
14119 : : NULL,
14120 : : }
14121 : : };
14122 : :
14123 : : /* *** configure port txq affinity value *** */
14124 : : struct cmd_config_tx_affinity_map {
14125 : : cmdline_fixed_string_t port;
14126 : : cmdline_fixed_string_t config;
14127 : : portid_t portid;
14128 : : cmdline_fixed_string_t txq;
14129 : : uint16_t qid;
14130 : : cmdline_fixed_string_t affinity;
14131 : : uint8_t value;
14132 : : };
14133 : :
14134 : : static void
14135 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
14136 : : __rte_unused struct cmdline *cl,
14137 : : __rte_unused void *data)
14138 : : {
14139 : : struct cmd_config_tx_affinity_map *res = parsed_result;
14140 : : int ret;
14141 : :
14142 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
14143 : : return;
14144 : :
14145 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
14146 : : printf("Invalid port id\n");
14147 : 0 : return;
14148 : : }
14149 : :
14150 : 0 : if (strcmp(res->txq, "txq")) {
14151 : : printf("Unknown parameter\n");
14152 : 0 : return;
14153 : : }
14154 : 0 : if (tx_queue_id_is_invalid(res->qid))
14155 : : return;
14156 : :
14157 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
14158 : 0 : if (ret < 0) {
14159 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
14160 : : strerror(-ret));
14161 : 0 : return;
14162 : : }
14163 : :
14164 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
14165 : 0 : if (ret != 0) {
14166 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
14167 : : rte_strerror(-ret));
14168 : 0 : return;
14169 : : }
14170 : : }
14171 : :
14172 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
14173 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14174 : : port, "port");
14175 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
14176 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14177 : : config, "config");
14178 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
14179 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14180 : : portid, RTE_UINT16);
14181 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
14182 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14183 : : txq, "txq");
14184 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
14185 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14186 : : qid, RTE_UINT16);
14187 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
14188 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14189 : : affinity, "affinity");
14190 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
14191 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14192 : : value, RTE_UINT8);
14193 : :
14194 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
14195 : : .f = cmd_config_tx_affinity_map_parsed,
14196 : : .data = (void *)0,
14197 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
14198 : : .tokens = {
14199 : : (void *)&cmd_config_tx_affinity_map_port,
14200 : : (void *)&cmd_config_tx_affinity_map_config,
14201 : : (void *)&cmd_config_tx_affinity_map_portid,
14202 : : (void *)&cmd_config_tx_affinity_map_txq,
14203 : : (void *)&cmd_config_tx_affinity_map_qid,
14204 : : (void *)&cmd_config_tx_affinity_map_affinity,
14205 : : (void *)&cmd_config_tx_affinity_map_value,
14206 : : NULL,
14207 : : },
14208 : : };
14209 : :
14210 : : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
14211 : : struct cmd_dev_led_result {
14212 : : cmdline_fixed_string_t set;
14213 : : cmdline_fixed_string_t port;
14214 : : portid_t port_id;
14215 : : cmdline_fixed_string_t led;
14216 : : cmdline_fixed_string_t state;
14217 : : };
14218 : :
14219 : : static void
14220 : 0 : cmd_set_dev_led_parsed(void *parsed_result,
14221 : : __rte_unused struct cmdline *cl,
14222 : : __rte_unused void *data)
14223 : : {
14224 : : struct cmd_dev_led_result *res = parsed_result;
14225 : :
14226 : 0 : if (strcmp(res->state, "on") == 0)
14227 : 0 : set_dev_led(res->port_id, true);
14228 : : else
14229 : 0 : set_dev_led(res->port_id, false);
14230 : 0 : }
14231 : :
14232 : : static cmdline_parse_token_string_t cmd_dev_led_set =
14233 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
14234 : : static cmdline_parse_token_string_t cmd_dev_led_port =
14235 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
14236 : : static cmdline_parse_token_num_t cmd_dev_led_port_id =
14237 : : TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
14238 : : static cmdline_parse_token_string_t cmd_dev_led =
14239 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
14240 : : static cmdline_parse_token_string_t cmd_dev_state =
14241 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
14242 : :
14243 : : static cmdline_parse_inst_t cmd_set_dev_led = {
14244 : : .f = cmd_set_dev_led_parsed,
14245 : : .data = NULL,
14246 : : .help_str = "set port <port_id> led <on/off>",
14247 : : .tokens = {
14248 : : (void *)&cmd_dev_led_set,
14249 : : (void *)&cmd_dev_led_port,
14250 : : (void *)&cmd_dev_led_port_id,
14251 : : (void *)&cmd_dev_led,
14252 : : (void *)&cmd_dev_state,
14253 : : NULL,
14254 : : },
14255 : : };
14256 : :
14257 : : /* ******************************************************************************** */
14258 : :
14259 : : /* list of instructions */
14260 : : static cmdline_parse_ctx_t builtin_ctx[] = {
14261 : : &cmd_help_brief,
14262 : : &cmd_help_long,
14263 : : &cmd_quit,
14264 : : &cmd_load_from_file,
14265 : : &cmd_load_echo_file,
14266 : : &cmd_showport,
14267 : : &cmd_showqueue,
14268 : : &cmd_showeeprom,
14269 : : &cmd_showeeprom_decode,
14270 : : &cmd_seteeprom,
14271 : : &cmd_showportall,
14272 : : &cmd_representor_info,
14273 : : &cmd_showdevice,
14274 : : &cmd_showcfg,
14275 : : &cmd_showfwdall,
14276 : : &cmd_start,
14277 : : &cmd_start_tx_first,
14278 : : &cmd_start_tx_first_n,
14279 : : &cmd_set_link_up,
14280 : : &cmd_set_link_down,
14281 : : &cmd_reset,
14282 : : &cmd_set_numbers,
14283 : : &cmd_set_log,
14284 : : &cmd_set_rxoffs,
14285 : : &cmd_set_rxpkts,
14286 : : &cmd_set_rxhdrs,
14287 : : &cmd_set_txflows,
14288 : : &cmd_set_txpkts,
14289 : : &cmd_set_txsplit,
14290 : : &cmd_set_txtimes,
14291 : : &cmd_set_fwd_list,
14292 : : &cmd_set_fwd_mask,
14293 : : &cmd_set_fwd_mode,
14294 : : &cmd_set_fwd_retry_mode,
14295 : : &cmd_set_dcb_fwd_tc,
14296 : : &cmd_set_dcb_fwd_tc_cores,
14297 : : &cmd_set_burst_tx_retry,
14298 : : &cmd_set_promisc_mode_one,
14299 : : &cmd_set_promisc_mode_all,
14300 : : &cmd_set_allmulti_mode_one,
14301 : : &cmd_set_allmulti_mode_all,
14302 : : &cmd_set_flush_rx,
14303 : : &cmd_set_link_check,
14304 : : &cmd_vlan_offload,
14305 : : &cmd_vlan_tpid,
14306 : : &cmd_rx_vlan_filter_all,
14307 : : &cmd_rx_vlan_filter,
14308 : : &cmd_tx_vlan_set,
14309 : : &cmd_tx_vlan_set_qinq,
14310 : : &cmd_tx_vlan_reset,
14311 : : &cmd_tx_vlan_set_pvid,
14312 : : &cmd_csum_set,
14313 : : &cmd_csum_show,
14314 : : &cmd_csum_tunnel,
14315 : : &cmd_csum_mac_swap,
14316 : : &cmd_tso_set,
14317 : : &cmd_tso_show,
14318 : : &cmd_tunnel_tso_set,
14319 : : &cmd_tunnel_tso_show,
14320 : : #ifdef RTE_LIB_GRO
14321 : : &cmd_gro_enable,
14322 : : &cmd_gro_flush,
14323 : : &cmd_gro_show,
14324 : : #endif
14325 : : #ifdef RTE_LIB_GSO
14326 : : &cmd_gso_enable,
14327 : : &cmd_gso_size,
14328 : : &cmd_gso_show,
14329 : : #endif
14330 : : &cmd_link_flow_control_set,
14331 : : &cmd_link_flow_control_set_rx,
14332 : : &cmd_link_flow_control_set_tx,
14333 : : &cmd_link_flow_control_set_hw,
14334 : : &cmd_link_flow_control_set_lw,
14335 : : &cmd_link_flow_control_set_pt,
14336 : : &cmd_link_flow_control_set_xon,
14337 : : &cmd_link_flow_control_set_macfwd,
14338 : : &cmd_link_flow_control_set_autoneg,
14339 : : &cmd_link_flow_control_show,
14340 : : &cmd_priority_flow_control_set,
14341 : : &cmd_queue_priority_flow_control_set,
14342 : : &cmd_config_dcb,
14343 : : &cmd_read_rxd_txd,
14344 : : &cmd_stop,
14345 : : &cmd_mac_addr,
14346 : : &cmd_set_fwd_eth_peer,
14347 : : &cmd_set_xstats_hide_zero,
14348 : : &cmd_set_xstats_show_state,
14349 : : &cmd_set_xstats_hide_disabled,
14350 : : &cmd_operate_set_counter,
14351 : : &cmd_set_record_core_cycles,
14352 : : &cmd_set_record_burst_stats,
14353 : : &cmd_operate_port,
14354 : : &cmd_operate_specific_port,
14355 : : &cmd_operate_attach_port,
14356 : : &cmd_operate_detach_port,
14357 : : &cmd_operate_detach_device,
14358 : : &cmd_set_port_setup_on,
14359 : : &cmd_config_speed_all,
14360 : : &cmd_config_speed_specific,
14361 : : &cmd_config_speed_lanes_all,
14362 : : &cmd_config_speed_lanes_specific,
14363 : : &cmd_show_speed_lanes,
14364 : : &cmd_config_loopback_all,
14365 : : &cmd_config_loopback_specific,
14366 : : &cmd_config_rx_tx,
14367 : : &cmd_config_mtu,
14368 : : &cmd_config_max_pkt_len,
14369 : : &cmd_config_max_lro_pkt_size,
14370 : : &cmd_config_rx_mode_flag,
14371 : : &cmd_config_rss,
14372 : : &cmd_config_rxtx_ring_size,
14373 : : &cmd_config_rxtx_queue,
14374 : : &cmd_config_deferred_start_rxtx_queue,
14375 : : &cmd_setup_rxtx_queue,
14376 : : &cmd_config_rss_reta,
14377 : : &cmd_showport_reta,
14378 : : &cmd_showport_macs,
14379 : : &cmd_show_port_flow_transfer_proxy,
14380 : : &cmd_config_burst,
14381 : : &cmd_config_thresh,
14382 : : &cmd_config_threshold,
14383 : : &cmd_set_uc_hash_filter,
14384 : : &cmd_set_uc_all_hash_filter,
14385 : : &cmd_vf_mac_addr_filter,
14386 : : &cmd_queue_rate_limit,
14387 : : &cmd_show_queue_rate_limit,
14388 : : &cmd_tunnel_udp_config,
14389 : : &cmd_showport_rss_hash,
14390 : : &cmd_showport_rss_hash_key,
14391 : : &cmd_showport_rss_hash_algo,
14392 : : &cmd_config_rss_hash_key,
14393 : : &cmd_config_rss_hash_algo,
14394 : : &cmd_cleanup_txq_mbufs,
14395 : : &cmd_dump_simple,
14396 : : &cmd_dump_named,
14397 : : &cmd_dump_mbuf_history_stdout,
14398 : : &cmd_dump_mbuf_history_to_file,
14399 : : &cmd_dump_mbuf_pool_history_stdout,
14400 : : &cmd_dump_mbuf_pool_history_to_file,
14401 : : &cmd_flow,
14402 : : &cmd_show_port_meter_cap,
14403 : : &cmd_add_port_meter_profile_srtcm,
14404 : : &cmd_add_port_meter_profile_trtcm,
14405 : : &cmd_add_port_meter_profile_trtcm_rfc4115,
14406 : : &cmd_del_port_meter_profile,
14407 : : &cmd_create_port_meter,
14408 : : &cmd_enable_port_meter,
14409 : : &cmd_disable_port_meter,
14410 : : &cmd_del_port_meter,
14411 : : &cmd_del_port_meter_policy,
14412 : : &cmd_set_port_meter_profile,
14413 : : &cmd_set_port_meter_dscp_table,
14414 : : &cmd_set_port_meter_vlan_table,
14415 : : &cmd_set_port_meter_in_proto,
14416 : : &cmd_get_port_meter_in_proto,
14417 : : &cmd_get_port_meter_in_proto_prio,
14418 : : &cmd_set_port_meter_stats_mask,
14419 : : &cmd_show_port_meter_stats,
14420 : : &cmd_mcast_addr,
14421 : : &cmd_mcast_addr_flush,
14422 : : &cmd_set_vf_vlan_anti_spoof,
14423 : : &cmd_set_vf_mac_anti_spoof,
14424 : : &cmd_set_vf_vlan_stripq,
14425 : : &cmd_set_vf_vlan_insert,
14426 : : &cmd_set_tx_loopback,
14427 : : &cmd_set_all_queues_drop_en,
14428 : : &cmd_set_vf_traffic,
14429 : : &cmd_set_vf_rxmode,
14430 : : &cmd_vf_rate_limit,
14431 : : &cmd_vf_rxvlan_filter,
14432 : : &cmd_set_vf_mac_addr,
14433 : : &cmd_set_vxlan,
14434 : : &cmd_set_vxlan_tos_ttl,
14435 : : &cmd_set_vxlan_with_vlan,
14436 : : &cmd_set_nvgre,
14437 : : &cmd_set_nvgre_with_vlan,
14438 : : &cmd_set_l2_encap,
14439 : : &cmd_set_l2_encap_with_vlan,
14440 : : &cmd_set_l2_decap,
14441 : : &cmd_set_l2_decap_with_vlan,
14442 : : &cmd_set_mplsogre_encap,
14443 : : &cmd_set_mplsogre_encap_with_vlan,
14444 : : &cmd_set_mplsogre_decap,
14445 : : &cmd_set_mplsogre_decap_with_vlan,
14446 : : &cmd_set_mplsoudp_encap,
14447 : : &cmd_set_mplsoudp_encap_with_vlan,
14448 : : &cmd_set_mplsoudp_decap,
14449 : : &cmd_set_mplsoudp_decap_with_vlan,
14450 : : &cmd_set_conntrack_common,
14451 : : &cmd_set_conntrack_dir,
14452 : : &cmd_show_vf_stats,
14453 : : &cmd_clear_vf_stats,
14454 : : &cmd_show_port_supported_ptypes,
14455 : : &cmd_set_port_ptypes,
14456 : : &cmd_show_port_tm_cap,
14457 : : &cmd_show_port_tm_level_cap,
14458 : : &cmd_show_port_tm_node,
14459 : : &cmd_show_port_tm_node_cap,
14460 : : &cmd_show_port_tm_node_type,
14461 : : &cmd_show_port_tm_node_stats,
14462 : : &cmd_add_port_tm_node_shaper_profile,
14463 : : &cmd_del_port_tm_node_shaper_profile,
14464 : : &cmd_add_port_tm_node_shared_shaper,
14465 : : &cmd_del_port_tm_node_shared_shaper,
14466 : : &cmd_add_port_tm_node_wred_profile,
14467 : : &cmd_del_port_tm_node_wred_profile,
14468 : : &cmd_set_port_tm_node_shaper_profile,
14469 : : &cmd_add_port_tm_nonleaf_node,
14470 : : &cmd_add_port_tm_nonleaf_node_pmode,
14471 : : &cmd_add_port_tm_leaf_node,
14472 : : &cmd_del_port_tm_node,
14473 : : &cmd_set_port_tm_node_parent,
14474 : : &cmd_suspend_port_tm_node,
14475 : : &cmd_resume_port_tm_node,
14476 : : &cmd_port_tm_hierarchy_commit,
14477 : : &cmd_port_tm_mark_ip_ecn,
14478 : : &cmd_port_tm_mark_ip_dscp,
14479 : : &cmd_port_tm_mark_vlan_dei,
14480 : : &cmd_cfg_tunnel_udp_port,
14481 : : &cmd_rx_offload_get_capa,
14482 : : &cmd_rx_offload_get_configuration,
14483 : : &cmd_config_per_port_rx_offload,
14484 : : &cmd_config_all_port_rx_offload,
14485 : : &cmd_config_per_queue_rx_offload,
14486 : : &cmd_tx_offload_get_capa,
14487 : : &cmd_tx_offload_get_configuration,
14488 : : &cmd_config_per_port_tx_offload,
14489 : : &cmd_config_all_port_tx_offload,
14490 : : &cmd_config_per_queue_tx_offload,
14491 : : #ifdef RTE_LIB_BPF
14492 : : &cmd_operate_bpf_ld_parse,
14493 : : &cmd_operate_bpf_unld_parse,
14494 : : #endif
14495 : : &cmd_config_tx_metadata_specific,
14496 : : &cmd_show_tx_metadata,
14497 : : &cmd_show_rx_tx_desc_status,
14498 : : &cmd_show_rx_tx_queue_desc_used_count,
14499 : : &cmd_set_raw,
14500 : : &cmd_show_set_raw,
14501 : : &cmd_show_set_raw_all,
14502 : : &cmd_config_tx_dynf_specific,
14503 : : &cmd_show_fec_mode,
14504 : : &cmd_set_fec_mode,
14505 : : &cmd_set_rxq_avail_thresh,
14506 : : &cmd_show_capability,
14507 : : &cmd_set_flex_is_pattern,
14508 : : &cmd_set_flex_spec_pattern,
14509 : : &cmd_show_port_cman_capa,
14510 : : &cmd_show_port_cman_config,
14511 : : &cmd_set_port_cman_config,
14512 : : &cmd_config_tx_affinity_map,
14513 : : &cmd_set_dev_led,
14514 : : NULL,
14515 : : };
14516 : :
14517 : : void
14518 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
14519 : : {
14520 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
14521 : 0 : }
14522 : :
14523 : : int
14524 : 0 : init_cmdline(void)
14525 : : {
14526 : : struct testpmd_driver_commands *c;
14527 : : unsigned int count;
14528 : : unsigned int i;
14529 : :
14530 : : /* initialize non-constant commands */
14531 : 0 : cmd_set_fwd_mode_init();
14532 : 0 : cmd_set_fwd_retry_mode_init();
14533 : :
14534 : : count = 0;
14535 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
14536 : 0 : count++;
14537 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14538 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
14539 : 0 : count++;
14540 : : }
14541 : :
14542 : : /* cmdline expects a NULL terminated array */
14543 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
14544 : 0 : if (main_ctx == NULL)
14545 : : return -1;
14546 : :
14547 : : count = 0;
14548 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
14549 : 0 : main_ctx[count] = builtin_ctx[i];
14550 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14551 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
14552 : 0 : main_ctx[count] = c->commands[i].ctx;
14553 : : }
14554 : :
14555 : : return 0;
14556 : : }
14557 : :
14558 : : /* read cmdline commands from file */
14559 : : int
14560 : 0 : cmdline_read_from_file(const char *filename, bool echo)
14561 : : {
14562 : : struct cmdline *cl;
14563 : : int fd = -1;
14564 : : int ret = 0;
14565 : :
14566 : : /* cmdline_file_new does not produce any output
14567 : : * so when echoing is requested we open filename directly
14568 : : * and then pass that to cmdline_new with stdout as the output path.
14569 : : */
14570 : 0 : if (!echo) {
14571 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14572 : : } else {
14573 : : /* use basename(filename) as prompt */
14574 : 0 : char prompt[32] = "[] ";
14575 : :
14576 : 0 : rte_basename(filename, &prompt[1], sizeof(prompt) - strlen(prompt));
14577 : 0 : strlcat(prompt, "] ", sizeof(prompt));
14578 : :
14579 : : fd = open(filename, O_RDONLY);
14580 : 0 : if (fd < 0) {
14581 : 0 : fprintf(stderr, "Failed to open file %s: %s\n",
14582 : 0 : filename, strerror(errno));
14583 : 0 : return -1;
14584 : : }
14585 : :
14586 : 0 : cl = cmdline_new(main_ctx, prompt, fd, STDOUT_FILENO);
14587 : : }
14588 : 0 : if (cl == NULL) {
14589 : 0 : fprintf(stderr,
14590 : : "Failed to create file based cmdline context: %s\n",
14591 : : filename);
14592 : : ret = -1;
14593 : 0 : goto end;
14594 : : }
14595 : :
14596 : 0 : cmdline_interact(cl);
14597 : : /* when done, if we have echo, we only need to print end of file,
14598 : : * but if no echo, we need to use printf and include the filename.
14599 : : */
14600 : 0 : if (echo)
14601 : 0 : cmdline_printf(cl, "<End-Of-File>\n");
14602 : : else
14603 : : printf("Finished reading CLI commands from %s\n", filename);
14604 : :
14605 : 0 : cmdline_quit(cl);
14606 : 0 : cmdline_free(cl);
14607 : :
14608 : :
14609 : 0 : end:
14610 : 0 : if (fd >= 0)
14611 : 0 : close(fd);
14612 : : return ret;
14613 : : }
14614 : :
14615 : : void
14616 : 0 : prompt_exit(void)
14617 : : {
14618 : 0 : cmdline_quit(testpmd_cl);
14619 : 0 : }
14620 : :
14621 : : /* prompt function, called from main on MAIN lcore */
14622 : : void
14623 : 0 : prompt(void)
14624 : : {
14625 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14626 : 0 : if (testpmd_cl == NULL) {
14627 : 0 : fprintf(stderr,
14628 : : "Failed to create stdin based cmdline context\n");
14629 : 0 : return;
14630 : : }
14631 : :
14632 : 0 : cmdline_interact(testpmd_cl);
14633 : 0 : cmdline_stdin_exit(testpmd_cl);
14634 : : }
14635 : :
14636 : : void
14637 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14638 : : {
14639 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
14640 : : portid_t pid;
14641 : :
14642 : 0 : RTE_ETH_FOREACH_DEV(pid) {
14643 : : /* check if need_reconfig has been set to 1 */
14644 : 0 : if (ports[pid].need_reconfig == 0)
14645 : 0 : ports[pid].need_reconfig = dev;
14646 : : /* check if need_reconfig_queues has been set to 1 */
14647 : 0 : if (ports[pid].need_reconfig_queues == 0)
14648 : 0 : ports[pid].need_reconfig_queues = queue;
14649 : : }
14650 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14651 : : /* check if need_reconfig has been set to 1 */
14652 : 0 : if (ports[id].need_reconfig == 0)
14653 : 0 : ports[id].need_reconfig = dev;
14654 : : /* check if need_reconfig_queues has been set to 1 */
14655 : 0 : if (ports[id].need_reconfig_queues == 0)
14656 : 0 : ports[id].need_reconfig_queues = queue;
14657 : : }
14658 : 0 : }
|