Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2016 Intel Corporation.
3 : : * Copyright(c) 2014 6WIND S.A.
4 : : */
5 : :
6 : : #include <ctype.h>
7 : : #include <stdarg.h>
8 : : #include <errno.h>
9 : : #include <fcntl.h>
10 : : #include <stdio.h>
11 : : #include <stdint.h>
12 : : #include <stdlib.h>
13 : : #include <string.h>
14 : : #include <unistd.h>
15 : : #include <inttypes.h>
16 : : #include <sys/queue.h>
17 : :
18 : : #include <rte_common.h>
19 : : #include <rte_byteorder.h>
20 : : #include <rte_log.h>
21 : : #include <rte_debug.h>
22 : : #include <rte_cycles.h>
23 : : #include <rte_memory.h>
24 : : #include <rte_memzone.h>
25 : : #include <rte_malloc.h>
26 : : #include <rte_launch.h>
27 : : #include <rte_eal.h>
28 : : #include <rte_per_lcore.h>
29 : : #include <rte_lcore.h>
30 : : #include <rte_branch_prediction.h>
31 : : #include <rte_ring.h>
32 : : #include <rte_mempool.h>
33 : : #include <rte_interrupts.h>
34 : : #include <rte_ether.h>
35 : : #include <rte_ethdev.h>
36 : : #include <rte_string_fns.h>
37 : : #include <rte_devargs.h>
38 : : #include <rte_flow.h>
39 : : #ifdef RTE_LIB_GRO
40 : : #include <rte_gro.h>
41 : : #endif
42 : : #include <rte_mbuf_dyn.h>
43 : : #include <rte_mbuf_history.h>
44 : : #include <rte_trace.h>
45 : :
46 : : #include <cmdline_rdline.h>
47 : : #include <cmdline_parse.h>
48 : : #include <cmdline_parse_num.h>
49 : : #include <cmdline_parse_bool.h>
50 : : #include <cmdline_parse_string.h>
51 : : #include <cmdline_parse_ipaddr.h>
52 : : #include <cmdline_parse_etheraddr.h>
53 : : #include <cmdline_socket.h>
54 : : #include <cmdline.h>
55 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
56 : : #include <rte_pmd_dpaa.h>
57 : : #endif
58 : : #ifdef RTE_NET_IXGBE
59 : : #include <rte_pmd_ixgbe.h>
60 : : #endif
61 : : #ifdef RTE_NET_I40E
62 : : #include <rte_pmd_i40e.h>
63 : : #endif
64 : : #ifdef RTE_NET_BNXT
65 : : #include <rte_pmd_bnxt.h>
66 : : #endif
67 : : #include "testpmd.h"
68 : : #include "cmdline_cman.h"
69 : : #include "cmdline_mtr.h"
70 : : #include "cmdline_tm.h"
71 : : #include "bpf_cmd.h"
72 : :
73 : : static struct cmdline *testpmd_cl;
74 : : static cmdline_parse_ctx_t *main_ctx;
75 : : static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
76 : : TAILQ_HEAD_INITIALIZER(driver_commands_head);
77 : :
78 : : /* *** Help command with introduction. *** */
79 : : struct cmd_help_brief_result {
80 : : cmdline_fixed_string_t help;
81 : : };
82 : :
83 : 0 : static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
84 : : struct cmdline *cl,
85 : : __rte_unused void *data)
86 : : {
87 : 0 : cmdline_printf(
88 : : cl,
89 : : "\n"
90 : : "Help is available for the following sections:\n\n"
91 : : " help control : Start and stop forwarding.\n"
92 : : " help display : Displaying port, stats and config "
93 : : "information.\n"
94 : : " help config : Configuration information.\n"
95 : : " help ports : Configuring ports.\n"
96 : : " help filters : Filters configuration help.\n"
97 : : " help traffic_management : Traffic Management commands.\n"
98 : : " help devices : Device related commands.\n"
99 : : " help drivers : Driver specific commands.\n"
100 : : " help all : All of the above sections.\n\n"
101 : : );
102 : :
103 : 0 : }
104 : :
105 : : static cmdline_parse_token_string_t cmd_help_brief_help =
106 : : TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
107 : :
108 : : static cmdline_parse_inst_t cmd_help_brief = {
109 : : .f = cmd_help_brief_parsed,
110 : : .data = NULL,
111 : : .help_str = "help: Show help",
112 : : .tokens = {
113 : : (void *)&cmd_help_brief_help,
114 : : NULL,
115 : : },
116 : : };
117 : :
118 : : /* *** Help command with help sections. *** */
119 : : struct cmd_help_long_result {
120 : : cmdline_fixed_string_t help;
121 : : cmdline_fixed_string_t section;
122 : : };
123 : :
124 : 0 : static void cmd_help_long_parsed(void *parsed_result,
125 : : struct cmdline *cl,
126 : : __rte_unused void *data)
127 : : {
128 : : int show_all = 0;
129 : : struct cmd_help_long_result *res = parsed_result;
130 : :
131 : 0 : if (!strcmp(res->section, "all"))
132 : : show_all = 1;
133 : :
134 : 0 : if (show_all || !strcmp(res->section, "control")) {
135 : :
136 : 0 : cmdline_printf(
137 : : cl,
138 : : "\n"
139 : : "Control forwarding:\n"
140 : : "-------------------\n\n"
141 : :
142 : : "start\n"
143 : : " Start packet forwarding with current configuration.\n\n"
144 : :
145 : : "start tx_first\n"
146 : : " Start packet forwarding with current config"
147 : : " after sending one burst of packets.\n\n"
148 : :
149 : : "stop\n"
150 : : " Stop packet forwarding, and display accumulated"
151 : : " statistics.\n\n"
152 : :
153 : : "quit\n"
154 : : " Quit to prompt.\n\n"
155 : : );
156 : : }
157 : :
158 : 0 : if (show_all || !strcmp(res->section, "display")) {
159 : :
160 : 0 : cmdline_printf(
161 : : cl,
162 : : "\n"
163 : : "Display:\n"
164 : : "--------\n\n"
165 : :
166 : : "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
167 : : " Display information for port_id, or all.\n\n"
168 : :
169 : : "show port info (port_id) representor\n"
170 : : " Show supported representors for a specific port\n\n"
171 : :
172 : : "show port port_id (module_eeprom|eeprom)\n"
173 : : " Display the module EEPROM or EEPROM information for port_id.\n\n"
174 : :
175 : : "set port (port_id) eeprom (accept_risk) magic (magic_num)"
176 : : " value (value) offset (offset)\n"
177 : : " Set the device eeprom for certain port.\nNote:\n"
178 : : " This is a high-risk command and its misuse may"
179 : : " result in unexpected behaviour from the NIC.\n"
180 : : " By inserting \"accept_risk\" into the command, the"
181 : : " user is acknowledging and taking responsibility for"
182 : : " this risk.\n\n"
183 : :
184 : : "show port X rss reta (size) (mask0,mask1,...)\n"
185 : : " Display the rss redirection table entry indicated"
186 : : " by masks on port X. size is used to indicate the"
187 : : " hardware supported reta size\n\n"
188 : :
189 : : "show port (port_id) rss-hash [key | algorithm]\n"
190 : : " Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
191 : :
192 : : "clear port (info|stats|xstats|fdir) (port_id|all)\n"
193 : : " Clear information for port_id, or all.\n\n"
194 : :
195 : : "show (rxq|txq) info (port_id) (queue_id)\n"
196 : : " Display information for configured RX/TX queue.\n\n"
197 : :
198 : : "show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
199 : : " Display the given configuration.\n\n"
200 : :
201 : : "read rxd (port_id) (queue_id) (rxd_id)\n"
202 : : " Display an RX descriptor of a port RX queue.\n\n"
203 : :
204 : : "read txd (port_id) (queue_id) (txd_id)\n"
205 : : " Display a TX descriptor of a port TX queue.\n\n"
206 : :
207 : : "show vf stats (port_id) (vf_id)\n"
208 : : " Display a VF's statistics.\n\n"
209 : :
210 : : "clear vf stats (port_id) (vf_id)\n"
211 : : " Reset a VF's statistics.\n\n"
212 : :
213 : : "show port meter stats (port_id) (meter_id) (clear)\n"
214 : : " Get meter stats on a port\n\n"
215 : :
216 : : "show fwd stats all\n"
217 : : " Display statistics for all fwd engines.\n\n"
218 : :
219 : : "clear fwd stats all\n"
220 : : " Clear statistics for all fwd engines.\n\n"
221 : :
222 : : "show port (port_id) rx_offload capabilities\n"
223 : : " List all per queue and per port Rx offloading"
224 : : " capabilities of a port\n\n"
225 : :
226 : : "show port (port_id) rx_offload configuration\n"
227 : : " List port level and all queue level"
228 : : " Rx offloading configuration\n\n"
229 : :
230 : : "show port (port_id) tx_offload capabilities\n"
231 : : " List all per queue and per port"
232 : : " Tx offloading capabilities of a port\n\n"
233 : :
234 : : "show port (port_id) tx_offload configuration\n"
235 : : " List port level and all queue level"
236 : : " Tx offloading configuration\n\n"
237 : :
238 : : "show port (port_id) tx_metadata\n"
239 : : " Show Tx metadata value set"
240 : : " for a specific port\n\n"
241 : :
242 : : "show port (port_id) ptypes\n"
243 : : " Show port supported ptypes"
244 : : " for a specific port\n\n"
245 : :
246 : : "show device info (<identifier>|all)"
247 : : " Show general information about devices probed.\n\n"
248 : :
249 : : "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
250 : : " Show status of rx|tx descriptor.\n\n"
251 : :
252 : : "show port (port_id) rxq|txq (queue_id) desc used count\n"
253 : : " Show current number of used descriptor count for rx|tx.\n\n"
254 : :
255 : : "show port (port_id) macs|mcast_macs"
256 : : " Display list of mac addresses added to port.\n\n"
257 : :
258 : : "show port (port_id) flow transfer proxy\n"
259 : : " Display proxy port to manage transfer flows\n\n"
260 : :
261 : : "show port (port_id) fec capabilities"
262 : : " Show fec capabilities of a port.\n\n"
263 : :
264 : : "show port (port_id) fec_mode"
265 : : " Show fec mode of a port.\n\n"
266 : :
267 : : "show port (port_id) flow_ctrl"
268 : : " Show flow control info of a port.\n\n"
269 : :
270 : : "dump physmem\n"
271 : : " Dumps all physical memory segment layouts\n\n"
272 : :
273 : : "dump socket_mem\n"
274 : : " Dumps the memory usage of all sockets\n\n"
275 : :
276 : : "dump memzone\n"
277 : : " Dumps the layout of all memory zones\n\n"
278 : :
279 : : "dump struct_sizes\n"
280 : : " Dumps the size of all memory structures\n\n"
281 : :
282 : : "dump ring [name]\n"
283 : : " Dumps the status of all or specific element in DPDK rings\n\n"
284 : :
285 : : "dump mempool [name]\n"
286 : : " Dumps the statistics of all or specific memory pool\n\n"
287 : :
288 : : "dump devargs\n"
289 : : " Dumps the user device list\n\n"
290 : :
291 : : "dump lcores\n"
292 : : " Dumps the logical cores list\n\n"
293 : :
294 : : "dump trace\n"
295 : : " Dumps the tracing data to the folder according to the current EAL settings\n\n"
296 : :
297 : : "dump log_types\n"
298 : : " Dumps the log level for all the dpdk modules\n\n"
299 : :
300 : : "dump mbuf history all [file_name]\n"
301 : : " Dumps the mbuf history for all mempools\n\n"
302 : :
303 : : "dump mbuf history <mbuf_addr> [file_name]\n"
304 : : " Dumps the history for a specific mbuf (use 0x<address> format)\n\n"
305 : :
306 : : "dump mbuf pool history <mempool_name> [file_name]\n"
307 : : " Dumps the history for a specific mempool\n\n"
308 : :
309 : : "show port (port_id) speed_lanes capabilities"
310 : : " Show speed lanes capabilities of a port.\n\n"
311 : : );
312 : : }
313 : :
314 : 0 : if (show_all || !strcmp(res->section, "config")) {
315 : 0 : cmdline_printf(
316 : : cl,
317 : : "\n"
318 : : "Configuration:\n"
319 : : "--------------\n"
320 : : "Configuration changes only become active when"
321 : : " forwarding is started/restarted.\n\n"
322 : :
323 : : "set default\n"
324 : : " Reset forwarding to the default configuration.\n\n"
325 : :
326 : : "set verbose (level)\n"
327 : : " Set the debug verbosity level X.\n\n"
328 : :
329 : : "set log global|(type) (level)\n"
330 : : " Set the log level.\n\n"
331 : :
332 : : "set nbport (num)\n"
333 : : " Set number of ports.\n\n"
334 : :
335 : : "set nbcore (num)\n"
336 : : " Set number of cores.\n\n"
337 : :
338 : : "set coremask (mask)\n"
339 : : " Set the forwarding cores hexadecimal mask.\n\n"
340 : :
341 : : "set portmask (mask)\n"
342 : : " Set the forwarding ports hexadecimal mask.\n\n"
343 : :
344 : : "set burst (num)\n"
345 : : " Set number of packets per burst.\n\n"
346 : :
347 : : "set burst tx delay (microseconds) retry (num)\n"
348 : : " Set the transmit delay time and number of retries,"
349 : : " effective when retry is enabled.\n\n"
350 : :
351 : : "set rxoffs (x[,y]*)\n"
352 : : " Set the offset of each packet segment on"
353 : : " receiving if split feature is engaged."
354 : : " Affects only the queues configured with split"
355 : : " offloads.\n\n"
356 : :
357 : : "set rxpkts (x[,y]*)\n"
358 : : " Set the length of each segment to scatter"
359 : : " packets on receiving if split feature is engaged."
360 : : " Affects only the queues configured with split"
361 : : " offloads.\n\n"
362 : :
363 : : "set rxhdrs (eth[,ipv4])*\n"
364 : : " Set the protocol hdr of each segment to scatter"
365 : : " packets on receiving if split feature is engaged."
366 : : " Affects only the queues configured with split"
367 : : " offloads.\n"
368 : : " Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
369 : : "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
370 : : "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
371 : : "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
372 : : "inner-ipv4-sctp|inner-ipv6-sctp\n\n"
373 : :
374 : : "set txpkts (x[,y]*)\n"
375 : : " Set the length of each segment of TXONLY"
376 : : " and optionally CSUM packets.\n\n"
377 : :
378 : : "set txsplit (off|on|rand)\n"
379 : : " Set the split policy for the TX packets."
380 : : " Right now only applicable for CSUM and TXONLY"
381 : : " modes\n\n"
382 : :
383 : : "set txtimes (x, y)\n"
384 : : " Set the scheduling on timestamps"
385 : : " timings for the TXONLY mode\n\n"
386 : :
387 : : "set corelist (x[,y]*)\n"
388 : : " Set the list of forwarding cores.\n\n"
389 : :
390 : : "set portlist (x[,y]*)\n"
391 : : " Set the list of forwarding ports.\n\n"
392 : :
393 : : "set port setup on (iterator|event)\n"
394 : : " Select how attached port is retrieved for setup.\n\n"
395 : :
396 : : "set tx loopback (port_id) (on|off)\n"
397 : : " Enable or disable tx loopback.\n\n"
398 : :
399 : : "set all queues drop (port_id) (on|off)\n"
400 : : " Set drop enable bit for all queues.\n\n"
401 : :
402 : : "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
403 : : " Set MAC antispoof for a VF from the PF.\n\n"
404 : :
405 : : "vlan set stripq (on|off) (port_id,queue_id)\n"
406 : : " Set the VLAN strip for a queue on a port.\n\n"
407 : :
408 : : "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
409 : : " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
410 : :
411 : : "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
412 : : " Set VLAN insert for a VF from the PF.\n\n"
413 : :
414 : : "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
415 : : " Set VLAN antispoof for a VF from the PF.\n\n"
416 : :
417 : : "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
418 : : " Set the VLAN strip or filter or qinq strip or extend\n\n"
419 : :
420 : : "vlan set (inner|outer) tpid (value) (port_id)\n"
421 : : " Set the VLAN TPID for Packet Filtering on"
422 : : " a port\n\n"
423 : :
424 : : "rx_vlan add (vlan_id|all) (port_id)\n"
425 : : " Add a vlan_id, or all identifiers, to the set"
426 : : " of VLAN identifiers filtered by port_id.\n\n"
427 : :
428 : : "rx_vlan rm (vlan_id|all) (port_id)\n"
429 : : " Remove a vlan_id, or all identifiers, from the set"
430 : : " of VLAN identifiers filtered by port_id.\n\n"
431 : :
432 : : "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
433 : : " Add a vlan_id, to the set of VLAN identifiers"
434 : : "filtered for VF(s) from port_id.\n\n"
435 : :
436 : : "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
437 : : " Remove a vlan_id, to the set of VLAN identifiers"
438 : : "filtered for VF(s) from port_id.\n\n"
439 : :
440 : : "rx_vxlan_port add (udp_port) (port_id)\n"
441 : : " Add an UDP port for VXLAN packet filter on a port\n\n"
442 : :
443 : : "rx_vxlan_port rm (udp_port) (port_id)\n"
444 : : " Remove an UDP port for VXLAN packet filter on a port\n\n"
445 : :
446 : : "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
447 : : " Set hardware insertion of VLAN IDs (single or double VLAN "
448 : : "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
449 : :
450 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
451 : : " Set port based TX VLAN insertion.\n\n"
452 : :
453 : : "tx_vlan reset (port_id)\n"
454 : : " Disable hardware insertion of a VLAN header in"
455 : : " packets sent on a port.\n\n"
456 : :
457 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
458 : : " Select hardware or software calculation of the"
459 : : " checksum when transmitting a packet using the"
460 : : " csum forward engine.\n"
461 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
462 : : " outer-ip concerns the outer IP layer in"
463 : : " outer-udp concerns the outer UDP layer in"
464 : : " case the packet is recognized as a tunnel packet by"
465 : : " the forward engine (vxlan, gre and ipip are supported)\n"
466 : : " Please check the NIC datasheet for HW limits.\n\n"
467 : :
468 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
469 : : " If disabled, treat tunnel packets as non-tunneled"
470 : : " packets (treat inner headers as payload). The port\n"
471 : : " argument is the port used for TX in csum forward"
472 : : " engine.\n\n"
473 : :
474 : : "csum show (port_id)\n"
475 : : " Display tx checksum offload configuration\n\n"
476 : :
477 : : "tso set (segsize) (portid)\n"
478 : : " Enable TCP Segmentation Offload in csum forward"
479 : : " engine.\n"
480 : : " Please check the NIC datasheet for HW limits.\n\n"
481 : :
482 : : "tso show (portid)"
483 : : " Display the status of TCP Segmentation Offload.\n\n"
484 : :
485 : : #ifdef RTE_LIB_GRO
486 : : "set port (port_id) gro on|off\n"
487 : : " Enable or disable Generic Receive Offload in"
488 : : " csum forwarding engine.\n\n"
489 : :
490 : : "show port (port_id) gro\n"
491 : : " Display GRO configuration.\n\n"
492 : :
493 : : "set gro flush (cycles)\n"
494 : : " Set the cycle to flush GROed packets from"
495 : : " reassembly tables.\n\n"
496 : : #endif
497 : :
498 : : #ifdef RTE_LIB_GSO
499 : : "set port (port_id) gso (on|off)"
500 : : " Enable or disable Generic Segmentation Offload in"
501 : : " csum forwarding engine.\n\n"
502 : :
503 : : "set gso segsz (length)\n"
504 : : " Set max packet length for output GSO segments,"
505 : : " including packet header and payload.\n\n"
506 : :
507 : : "show port (port_id) gso\n"
508 : : " Show GSO configuration.\n\n"
509 : : #endif
510 : :
511 : : "set fwd (%s)\n"
512 : : " Set packet forwarding mode.\n\n"
513 : :
514 : : "set dcb fwd_tc (tc_mask)\n"
515 : : " Set DCB forwarding on specify TCs, if bit-n in tc-mask is 1, then TC-n's forwarding is enabled\n\n"
516 : :
517 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
518 : : " Add a MAC address on port_id.\n\n"
519 : :
520 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
521 : : " Remove a MAC address from port_id.\n\n"
522 : :
523 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
524 : : " Set the default MAC address for port_id.\n\n"
525 : :
526 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
527 : : " Add a MAC address for a VF on the port.\n\n"
528 : :
529 : : "mcast_addr add (port_id) (mcast_addr)\n"
530 : : " Add a multicast MAC addresses on port_id.\n\n"
531 : :
532 : : "mcast_addr remove (port_id) (mcast_addr)\n"
533 : : " Remove a multicast MAC address from port_id.\n\n"
534 : :
535 : : "mcast_addr flush (port_id)\n"
536 : : " Flush all multicast MAC addresses on port_id.\n\n"
537 : :
538 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
539 : : " Set the MAC address for a VF from the PF.\n\n"
540 : :
541 : : "set eth-peer (port_id) (peer_addr)\n"
542 : : " set the peer address for certain port.\n\n"
543 : :
544 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
545 : : " Add/Remove a or all unicast hash filter(s)"
546 : : "from port X.\n\n"
547 : :
548 : : "set promisc (port_id|all) (on|off)\n"
549 : : " Set the promiscuous mode on port_id, or all.\n\n"
550 : :
551 : : "set allmulti (port_id|all) (on|off)\n"
552 : : " Set the allmulti mode on port_id, or all.\n\n"
553 : :
554 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
555 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
556 : : " (on|off) autoneg (on|off) (port_id)\n"
557 : : "set flow_ctrl rx (on|off) (portid)\n"
558 : : "set flow_ctrl tx (on|off) (portid)\n"
559 : : "set flow_ctrl high_water (high_water) (portid)\n"
560 : : "set flow_ctrl low_water (low_water) (portid)\n"
561 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
562 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
563 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
564 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
565 : : " Set the link flow control parameter on a port.\n\n"
566 : :
567 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
568 : : " (low_water) (pause_time) (priority) (port_id)\n"
569 : : " Set the priority flow control parameter on a"
570 : : " port.\n\n"
571 : :
572 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
573 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
574 : : " Set the queue priority flow control parameter on a"
575 : : " given Rx and Tx queues of a port.\n\n"
576 : :
577 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
578 : : " set available descriptors threshold for Rx queue\n\n"
579 : :
580 : : "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
581 : : " Set statistics mapping (qmapping 0..15) for RX/TX"
582 : : " queue on port.\n"
583 : : " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
584 : : " on port 0 to mapping 5.\n\n"
585 : :
586 : : "set xstats-hide-zero on|off\n"
587 : : " Set the option to hide the zero values"
588 : : " for xstats display.\n"
589 : :
590 : : "set record-core-cycles on|off\n"
591 : : " Set the option to enable measurement of CPU cycles.\n"
592 : :
593 : : "set record-burst-stats on|off\n"
594 : : " Set the option to enable display of RX and TX bursts.\n"
595 : :
596 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
597 : : " Enable/Disable a VF receive/transmit from a port\n\n"
598 : :
599 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
600 : : "|MPE) (on|off)\n"
601 : : " AUPE:accepts untagged VLAN;"
602 : : "ROPE:accept unicast hash\n\n"
603 : : " BAM:accepts broadcast packets;"
604 : : "MPE:accepts all multicast packets\n\n"
605 : : " Enable/Disable a VF receive mode of a port\n\n"
606 : :
607 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
608 : : " Set rate limit for a queue of a port\n\n"
609 : :
610 : : "set port (port_id) vf (vf_id) rate (rate_num) "
611 : : "queue_mask (queue_mask_value)\n"
612 : : " Set rate limit for queues in VF of a port\n\n"
613 : :
614 : : "set flush_rx (on|off)\n"
615 : : " Flush (default) or don't flush RX streams before"
616 : : " forwarding. Mainly used with PCAP drivers.\n\n"
617 : :
618 : : "set link-up port (port_id)\n"
619 : : " Set link up for a port.\n\n"
620 : :
621 : : "set link-down port (port_id)\n"
622 : : " Set link down for a port.\n\n"
623 : :
624 : : "set port (port_id) ptype_mask (ptype_mask)\n"
625 : : " set packet types classification for a specific port\n\n"
626 : :
627 : : "show port meter cap (port_id)\n"
628 : : " Show port meter capability information\n\n"
629 : :
630 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
631 : : " meter profile add - srtcm rfc 2697\n\n"
632 : :
633 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
634 : : " meter profile add - trtcm rfc 2698\n\n"
635 : :
636 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
637 : : " meter profile add - trtcm rfc 4115\n\n"
638 : :
639 : : "del port meter profile (port_id) (profile_id)\n"
640 : : " meter profile delete\n\n"
641 : :
642 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
643 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
644 : : "(dscp_tbl_entry63)]\n"
645 : : " meter create\n\n"
646 : :
647 : : "enable port meter (port_id) (mtr_id)\n"
648 : : " meter enable\n\n"
649 : :
650 : : "disable port meter (port_id) (mtr_id)\n"
651 : : " meter disable\n\n"
652 : :
653 : : "del port meter (port_id) (mtr_id)\n"
654 : : " meter delete\n\n"
655 : :
656 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
657 : : "y_actions (actions) r_actions (actions)\n"
658 : : " meter policy add\n\n"
659 : :
660 : : "del port meter policy (port_id) (policy_id)\n"
661 : : " meter policy delete\n\n"
662 : :
663 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
664 : : " meter update meter profile\n\n"
665 : :
666 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
667 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
668 : : " update meter dscp table entries\n\n"
669 : :
670 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
671 : : "(action0) [(action1) (action2)]\n"
672 : : " meter update policer action\n\n"
673 : :
674 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
675 : : " meter update stats\n\n"
676 : :
677 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
678 : : " set fec mode for a specific port\n\n"
679 : :
680 : : "show port cman capa (port_id)\n"
681 : : " Show congestion management capabilities\n\n"
682 : :
683 : : "show port cman config (port_id)\n"
684 : : " Show congestion management configuration\n\n"
685 : :
686 : : "set port cman config (port_id) (queue_id) default | "
687 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
688 : : "(max_thresh) (prob_inv)]\n"
689 : : " Set congestion management configuration\n\n"
690 : :
691 : : "set port (port_id) led (on|off)\n"
692 : : " Set a controllable LED associated with a certain"
693 : : " port on or off.\n\n"
694 : :
695 : : , list_pkt_forwarding_modes()
696 : : );
697 : : }
698 : :
699 : 0 : if (show_all || !strcmp(res->section, "ports")) {
700 : :
701 : 0 : cmdline_printf(
702 : : cl,
703 : : "\n"
704 : : "Port Operations:\n"
705 : : "----------------\n\n"
706 : :
707 : : "port start (port_id|all)\n"
708 : : " Start all ports or port_id.\n\n"
709 : :
710 : : "port stop (port_id|all)\n"
711 : : " Stop all ports or port_id.\n\n"
712 : :
713 : : "port close (port_id|all)\n"
714 : : " Close all ports or port_id.\n\n"
715 : :
716 : : "port reset (port_id|all)\n"
717 : : " Reset all ports or port_id.\n\n"
718 : :
719 : : "port attach (ident)\n"
720 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
721 : :
722 : : "port detach (port_id)\n"
723 : : " Detach physical or virtual dev by port_id\n\n"
724 : :
725 : : "port config (port_id|all)"
726 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|"
727 : : "100000|200000|400000|800000|auto)"
728 : : " duplex (half|full|auto)\n"
729 : : " Set speed and duplex for all ports or port_id\n\n"
730 : :
731 : : "port config (port_id|all) loopback (mode)\n"
732 : : " Set loopback mode for all ports or port_id\n\n"
733 : :
734 : : "port config all (rxq|txq|rxd|txd) (value)\n"
735 : : " Set number for rxq/txq/rxd/txd.\n\n"
736 : :
737 : : "port config all max-pkt-len (value)\n"
738 : : " Set the max packet length.\n\n"
739 : :
740 : : "port config all max-lro-pkt-size (value)\n"
741 : : " Set the max LRO aggregated packet size.\n\n"
742 : :
743 : : "port config all drop-en (on|off)\n"
744 : : " Enable or disable packet drop on all RX queues of all ports when no "
745 : : "receive buffers available.\n\n"
746 : :
747 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
748 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
749 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
750 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
751 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
752 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
753 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
754 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
755 : : " Set the RSS mode.\n\n"
756 : :
757 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
758 : : " Set the RSS redirection table.\n\n"
759 : :
760 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
761 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
762 : : " Set the RSS hash algorithm.\n\n"
763 : :
764 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
765 : : " pfc (on|off)\n"
766 : : " Set the DCB mode.\n\n"
767 : :
768 : : "port config all burst (value)\n"
769 : : " Set the number of packets per burst.\n\n"
770 : :
771 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
772 : : " (value)\n"
773 : : " Set the ring prefetch/host/writeback threshold"
774 : : " for tx/rx queue.\n\n"
775 : :
776 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
777 : : " Set free threshold for rx/tx, or set"
778 : : " tx rs bit threshold.\n\n"
779 : : "port config mtu X value\n"
780 : : " Set the MTU of port X to a given value\n\n"
781 : :
782 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
783 : : " Set a rx/tx queue's ring size configuration, the new"
784 : : " value will take effect after command that (re-)start the port"
785 : : " or command that setup the specific queue\n\n"
786 : :
787 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
788 : : " Start/stop a rx/tx queue of port X. Only take effect"
789 : : " when port X is started\n\n"
790 : :
791 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
792 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
793 : : " take effect when port X is stopped.\n\n"
794 : :
795 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
796 : : " Setup a rx/tx queue of port X.\n\n"
797 : :
798 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
799 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
800 : :
801 : : "port config (port_id|all) rx_offload all|vlan_strip|"
802 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
803 : : "outer_ipv4_cksum|macsec_strip|"
804 : : "vlan_filter|vlan_extend|scatter|"
805 : : "buffer_split|timestamp|security|keep_crc on|off\n"
806 : : " Enable or disable a per port Rx offloading"
807 : : " on all Rx queues of a port\n\n"
808 : :
809 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
810 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
811 : : "outer_ipv4_cksum|macsec_strip|"
812 : : "vlan_filter|vlan_extend|scatter|"
813 : : "buffer_split|timestamp|security|keep_crc on|off\n"
814 : : " Enable or disable a per queue Rx offloading"
815 : : " only on a specific Rx queue\n\n"
816 : :
817 : : "port config (port_id|all) tx_offload all|vlan_insert|"
818 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
819 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
820 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
821 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
822 : : "security on|off\n"
823 : : " Enable or disable a per port Tx offloading"
824 : : " on all Tx queues of a port\n\n"
825 : :
826 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
827 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
828 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
829 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
830 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
831 : : " on|off\n"
832 : : " Enable or disable a per queue Tx offloading"
833 : : " only on a specific Tx queue\n\n"
834 : :
835 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
836 : : " Load an eBPF program as a callback"
837 : : " for particular RX/TX queue\n\n"
838 : :
839 : : "bpf-unload rx|tx (port) (queue)\n"
840 : : " Unload previously loaded eBPF program"
841 : : " for particular RX/TX queue\n\n"
842 : :
843 : : "port config (port_id) tx_metadata (value)\n"
844 : : " Set Tx metadata value per port. Testpmd will add this value"
845 : : " to any Tx packet sent from this port\n\n"
846 : :
847 : : "port config (port_id) dynf (name) set|clear\n"
848 : : " Register a dynf and Set/clear this flag on Tx. "
849 : : "Testpmd will set this value to any Tx packet "
850 : : "sent from this port\n\n"
851 : :
852 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
853 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
854 : :
855 : : "port config (port_id) txq (queue_id) affinity (value)\n"
856 : : " Map a Tx queue with an aggregated port "
857 : : "of the DPDK port\n\n"
858 : :
859 : : "port config (port_id|all) speed_lanes (value)\n"
860 : : " Set number of lanes for all ports or port_id for a forced speed\n\n"
861 : : );
862 : : }
863 : :
864 : 0 : if (show_all || !strcmp(res->section, "filters")) {
865 : :
866 : 0 : cmdline_printf(
867 : : cl,
868 : : "\n"
869 : : "filters:\n"
870 : : "--------\n\n"
871 : :
872 : : "flow validate {port_id}"
873 : : " [group {group_id}] [priority {level}]"
874 : : " [ingress] [egress]"
875 : : " pattern {item} [/ {item} [...]] / end"
876 : : " actions {action} [/ {action} [...]] / end\n"
877 : : " Check whether a flow rule can be created.\n\n"
878 : :
879 : : "flow create {port_id}"
880 : : " [group {group_id}] [priority {level}]"
881 : : " [ingress] [egress]"
882 : : " pattern {item} [/ {item} [...]] / end"
883 : : " actions {action} [/ {action} [...]] / end\n"
884 : : " Create a flow rule.\n\n"
885 : :
886 : : "flow destroy {port_id} rule {rule_id} [...]\n"
887 : : " Destroy specific flow rules.\n\n"
888 : :
889 : : "flow update {port_id} {rule_id}"
890 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
891 : : " Update a flow rule with new actions.\n\n"
892 : :
893 : : "flow flush {port_id}\n"
894 : : " Destroy all flow rules.\n\n"
895 : :
896 : : "flow query {port_id} {rule_id} {action}\n"
897 : : " Query an existing flow rule.\n\n"
898 : :
899 : : "flow list {port_id} [group {group_id}] [...]\n"
900 : : " List existing flow rules sorted by priority,"
901 : : " filtered by group identifiers.\n\n"
902 : :
903 : : "flow isolate {port_id} {boolean}\n"
904 : : " Restrict ingress traffic to the defined"
905 : : " flow rules\n\n"
906 : :
907 : : "flow aged {port_id} [destroy]\n"
908 : : " List and destroy aged flows"
909 : : " flow rules\n\n"
910 : :
911 : : "flow indirect_action {port_id} create"
912 : : " [action_id {indirect_action_id}]"
913 : : " [ingress] [egress]"
914 : : " action {action} / end\n"
915 : : " Create indirect action.\n\n"
916 : :
917 : : "flow indirect_action {port_id} update"
918 : : " {indirect_action_id} action {action} / end\n"
919 : : " Update indirect action.\n\n"
920 : :
921 : : "flow indirect_action {port_id} destroy"
922 : : " action_id {indirect_action_id} [...]\n"
923 : : " Destroy specific indirect actions.\n\n"
924 : :
925 : : "flow indirect_action {port_id} query"
926 : : " {indirect_action_id}\n"
927 : : " Query an existing indirect action.\n\n"
928 : :
929 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
930 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
931 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
932 : : " Configure the VXLAN encapsulation for flows.\n\n"
933 : :
934 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
935 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
936 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
937 : : " eth-dst (eth-dst)\n"
938 : : " Configure the VXLAN encapsulation for flows.\n\n"
939 : :
940 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
941 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
942 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
943 : : " eth-dst (eth-dst)\n"
944 : : " Configure the VXLAN encapsulation for flows.\n\n"
945 : :
946 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
947 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
948 : : " (eth-dst)\n"
949 : : " Configure the NVGRE encapsulation for flows.\n\n"
950 : :
951 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
952 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
953 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
954 : : " Configure the NVGRE encapsulation for flows.\n\n"
955 : :
956 : : "set raw_encap {flow items}\n"
957 : : " Configure the encapsulation with raw data.\n\n"
958 : :
959 : : "set raw_decap {flow items}\n"
960 : : " Configure the decapsulation with raw data.\n\n"
961 : :
962 : : );
963 : : }
964 : :
965 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
966 : 0 : cmdline_printf(
967 : : cl,
968 : : "\n"
969 : : "Traffic Management:\n"
970 : : "--------------\n"
971 : : "show port tm cap (port_id)\n"
972 : : " Display the port TM capability.\n\n"
973 : :
974 : : "show port tm level cap (port_id) (level_id)\n"
975 : : " Display the port TM hierarchical level capability.\n\n"
976 : :
977 : : "show port tm node cap (port_id) (node_id)\n"
978 : : " Display the port TM node capability.\n\n"
979 : :
980 : : "show port tm node type (port_id) (node_id)\n"
981 : : " Display the port TM node type.\n\n"
982 : :
983 : : "show port tm node stats (port_id) (node_id) (clear)\n"
984 : : " Display the port TM node stats.\n\n"
985 : :
986 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
987 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
988 : : " (packet_length_adjust) (packet_mode)\n"
989 : : " Add port tm node private shaper profile.\n\n"
990 : :
991 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
992 : : " Delete port tm node private shaper profile.\n\n"
993 : :
994 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
995 : : " (shaper_profile_id)\n"
996 : : " Add/update port tm node shared shaper.\n\n"
997 : :
998 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
999 : : " Delete port tm node shared shaper.\n\n"
1000 : :
1001 : : "set port tm node shaper profile (port_id) (node_id)"
1002 : : " (shaper_profile_id)\n"
1003 : : " Set port tm node shaper profile.\n\n"
1004 : :
1005 : : "add port tm node wred profile (port_id) (wred_profile_id)"
1006 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
1007 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
1008 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
1009 : : " Add port tm node wred profile.\n\n"
1010 : :
1011 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
1012 : : " Delete port tm node wred profile.\n\n"
1013 : :
1014 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1015 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1016 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1017 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1018 : : " Add port tm nonleaf node.\n\n"
1019 : :
1020 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1021 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1022 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1023 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1024 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
1025 : :
1026 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1027 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1028 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1029 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1030 : : " Add port tm leaf node.\n\n"
1031 : :
1032 : : "del port tm node (port_id) (node_id)\n"
1033 : : " Delete port tm node.\n\n"
1034 : :
1035 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1036 : : " (priority) (weight)\n"
1037 : : " Set port tm node parent.\n\n"
1038 : :
1039 : : "suspend port tm node (port_id) (node_id)"
1040 : : " Suspend tm node.\n\n"
1041 : :
1042 : : "resume port tm node (port_id) (node_id)"
1043 : : " Resume tm node.\n\n"
1044 : :
1045 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1046 : : " Commit tm hierarchy.\n\n"
1047 : :
1048 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1049 : : " (red)\n"
1050 : : " Enables/Disables the traffic management marking"
1051 : : " for IP ECN (Explicit Congestion Notification)"
1052 : : " packets on a given port\n\n"
1053 : :
1054 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1055 : : " (red)\n"
1056 : : " Enables/Disables the traffic management marking"
1057 : : " on the port for IP dscp packets\n\n"
1058 : :
1059 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1060 : : " (red)\n"
1061 : : " Enables/Disables the traffic management marking"
1062 : : " on the port for VLAN packets with DEI enabled\n\n"
1063 : : );
1064 : : }
1065 : :
1066 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1067 : 0 : cmdline_printf(
1068 : : cl,
1069 : : "\n"
1070 : : "Device Operations:\n"
1071 : : "--------------\n"
1072 : : "device detach (identifier)\n"
1073 : : " Detach device by identifier.\n\n"
1074 : : );
1075 : : }
1076 : :
1077 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1078 : : struct testpmd_driver_commands *c;
1079 : : unsigned int i;
1080 : :
1081 : 0 : cmdline_printf(
1082 : : cl,
1083 : : "\n"
1084 : : "Driver specific:\n"
1085 : : "----------------\n"
1086 : : );
1087 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1088 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1089 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1090 : : }
1091 : : }
1092 : 0 : }
1093 : :
1094 : : static cmdline_parse_token_string_t cmd_help_long_help =
1095 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1096 : :
1097 : : static cmdline_parse_token_string_t cmd_help_long_section =
1098 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1099 : : "all#control#display#config#ports#"
1100 : : "filters#traffic_management#devices#drivers");
1101 : :
1102 : : static cmdline_parse_inst_t cmd_help_long = {
1103 : : .f = cmd_help_long_parsed,
1104 : : .data = NULL,
1105 : : .help_str = "help all|control|display|config|ports|"
1106 : : "filters|traffic_management|devices|drivers: "
1107 : : "Show help",
1108 : : .tokens = {
1109 : : (void *)&cmd_help_long_help,
1110 : : (void *)&cmd_help_long_section,
1111 : : NULL,
1112 : : },
1113 : : };
1114 : :
1115 : :
1116 : : /* *** start/stop/close all ports *** */
1117 : : struct cmd_operate_port_result {
1118 : : cmdline_fixed_string_t keyword;
1119 : : cmdline_fixed_string_t name;
1120 : : cmdline_fixed_string_t value;
1121 : : };
1122 : :
1123 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1124 : : __rte_unused struct cmdline *cl,
1125 : : __rte_unused void *data)
1126 : : {
1127 : : struct cmd_operate_port_result *res = parsed_result;
1128 : :
1129 : 0 : if (!strcmp(res->name, "start"))
1130 : 0 : start_port(RTE_PORT_ALL);
1131 : 0 : else if (!strcmp(res->name, "stop"))
1132 : 0 : stop_port(RTE_PORT_ALL);
1133 : 0 : else if (!strcmp(res->name, "close"))
1134 : 0 : close_port(RTE_PORT_ALL);
1135 : 0 : else if (!strcmp(res->name, "reset"))
1136 : 0 : reset_port(RTE_PORT_ALL);
1137 : : else
1138 : 0 : fprintf(stderr, "Unknown parameter\n");
1139 : 0 : }
1140 : :
1141 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1142 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1143 : : "port");
1144 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1145 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1146 : : "start#stop#close#reset");
1147 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1148 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1149 : :
1150 : : static cmdline_parse_inst_t cmd_operate_port = {
1151 : : .f = cmd_operate_port_parsed,
1152 : : .data = NULL,
1153 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1154 : : .tokens = {
1155 : : (void *)&cmd_operate_port_all_cmd,
1156 : : (void *)&cmd_operate_port_all_port,
1157 : : (void *)&cmd_operate_port_all_all,
1158 : : NULL,
1159 : : },
1160 : : };
1161 : :
1162 : : /* *** start/stop/close specific port *** */
1163 : : struct cmd_operate_specific_port_result {
1164 : : cmdline_fixed_string_t keyword;
1165 : : cmdline_fixed_string_t name;
1166 : : uint8_t value;
1167 : : };
1168 : :
1169 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1170 : : __rte_unused struct cmdline *cl,
1171 : : __rte_unused void *data)
1172 : : {
1173 : : struct cmd_operate_specific_port_result *res = parsed_result;
1174 : :
1175 : 0 : if (!strcmp(res->name, "start"))
1176 : 0 : start_port(res->value);
1177 : 0 : else if (!strcmp(res->name, "stop"))
1178 : 0 : stop_port(res->value);
1179 : 0 : else if (!strcmp(res->name, "close"))
1180 : 0 : close_port(res->value);
1181 : 0 : else if (!strcmp(res->name, "reset"))
1182 : 0 : reset_port(res->value);
1183 : : else
1184 : 0 : fprintf(stderr, "Unknown parameter\n");
1185 : 0 : }
1186 : :
1187 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1188 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1189 : : keyword, "port");
1190 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1191 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1192 : : name, "start#stop#close#reset");
1193 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1194 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1195 : : value, RTE_UINT8);
1196 : :
1197 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1198 : : .f = cmd_operate_specific_port_parsed,
1199 : : .data = NULL,
1200 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1201 : : .tokens = {
1202 : : (void *)&cmd_operate_specific_port_cmd,
1203 : : (void *)&cmd_operate_specific_port_port,
1204 : : (void *)&cmd_operate_specific_port_id,
1205 : : NULL,
1206 : : },
1207 : : };
1208 : :
1209 : : /* *** enable port setup (after attach) via iterator or event *** */
1210 : : struct cmd_set_port_setup_on_result {
1211 : : cmdline_fixed_string_t set;
1212 : : cmdline_fixed_string_t port;
1213 : : cmdline_fixed_string_t setup;
1214 : : cmdline_fixed_string_t on;
1215 : : cmdline_fixed_string_t mode;
1216 : : };
1217 : :
1218 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1219 : : __rte_unused struct cmdline *cl,
1220 : : __rte_unused void *data)
1221 : : {
1222 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1223 : :
1224 : 0 : if (strcmp(res->mode, "event") == 0)
1225 : 0 : setup_on_probe_event = true;
1226 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1227 : 0 : setup_on_probe_event = false;
1228 : : else
1229 : 0 : fprintf(stderr, "Unknown mode\n");
1230 : 0 : }
1231 : :
1232 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1233 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1234 : : set, "set");
1235 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1236 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1237 : : port, "port");
1238 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1239 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1240 : : setup, "setup");
1241 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1242 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1243 : : on, "on");
1244 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1245 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1246 : : mode, "iterator#event");
1247 : :
1248 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1249 : : .f = cmd_set_port_setup_on_parsed,
1250 : : .data = NULL,
1251 : : .help_str = "set port setup on iterator|event",
1252 : : .tokens = {
1253 : : (void *)&cmd_set_port_setup_on_set,
1254 : : (void *)&cmd_set_port_setup_on_port,
1255 : : (void *)&cmd_set_port_setup_on_setup,
1256 : : (void *)&cmd_set_port_setup_on_on,
1257 : : (void *)&cmd_set_port_setup_on_mode,
1258 : : NULL,
1259 : : },
1260 : : };
1261 : :
1262 : : /* *** attach a specified port *** */
1263 : : struct cmd_operate_attach_port_result {
1264 : : cmdline_fixed_string_t port;
1265 : : cmdline_fixed_string_t keyword;
1266 : : cmdline_multi_string_t identifier;
1267 : : };
1268 : :
1269 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1270 : : __rte_unused struct cmdline *cl,
1271 : : __rte_unused void *data)
1272 : : {
1273 : : struct cmd_operate_attach_port_result *res = parsed_result;
1274 : :
1275 : 0 : if (!strcmp(res->keyword, "attach"))
1276 : 0 : attach_port(res->identifier);
1277 : : else
1278 : 0 : fprintf(stderr, "Unknown parameter\n");
1279 : 0 : }
1280 : :
1281 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1282 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1283 : : port, "port");
1284 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1285 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1286 : : keyword, "attach");
1287 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1288 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1289 : : identifier, TOKEN_STRING_MULTI);
1290 : :
1291 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1292 : : .f = cmd_operate_attach_port_parsed,
1293 : : .data = NULL,
1294 : : .help_str = "port attach <identifier>: "
1295 : : "(identifier: pci address or virtual dev name)",
1296 : : .tokens = {
1297 : : (void *)&cmd_operate_attach_port_port,
1298 : : (void *)&cmd_operate_attach_port_keyword,
1299 : : (void *)&cmd_operate_attach_port_identifier,
1300 : : NULL,
1301 : : },
1302 : : };
1303 : :
1304 : : /* *** detach a specified port *** */
1305 : : struct cmd_operate_detach_port_result {
1306 : : cmdline_fixed_string_t port;
1307 : : cmdline_fixed_string_t keyword;
1308 : : portid_t port_id;
1309 : : };
1310 : :
1311 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1312 : : __rte_unused struct cmdline *cl,
1313 : : __rte_unused void *data)
1314 : : {
1315 : : struct cmd_operate_detach_port_result *res = parsed_result;
1316 : :
1317 : 0 : if (!strcmp(res->keyword, "detach")) {
1318 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1319 : 0 : detach_port_device(res->port_id);
1320 : : } else {
1321 : 0 : fprintf(stderr, "Unknown parameter\n");
1322 : : }
1323 : : }
1324 : :
1325 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1326 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1327 : : port, "port");
1328 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1329 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1330 : : keyword, "detach");
1331 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1332 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1333 : : port_id, RTE_UINT16);
1334 : :
1335 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1336 : : .f = cmd_operate_detach_port_parsed,
1337 : : .data = NULL,
1338 : : .help_str = "port detach <port_id>",
1339 : : .tokens = {
1340 : : (void *)&cmd_operate_detach_port_port,
1341 : : (void *)&cmd_operate_detach_port_keyword,
1342 : : (void *)&cmd_operate_detach_port_port_id,
1343 : : NULL,
1344 : : },
1345 : : };
1346 : :
1347 : : /* *** detach device by identifier *** */
1348 : : struct cmd_operate_detach_device_result {
1349 : : cmdline_fixed_string_t device;
1350 : : cmdline_fixed_string_t keyword;
1351 : : cmdline_fixed_string_t identifier;
1352 : : };
1353 : :
1354 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1355 : : __rte_unused struct cmdline *cl,
1356 : : __rte_unused void *data)
1357 : : {
1358 : : struct cmd_operate_detach_device_result *res = parsed_result;
1359 : :
1360 : 0 : if (!strcmp(res->keyword, "detach"))
1361 : 0 : detach_devargs(res->identifier);
1362 : : else
1363 : 0 : fprintf(stderr, "Unknown parameter\n");
1364 : 0 : }
1365 : :
1366 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1367 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1368 : : device, "device");
1369 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1370 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1371 : : keyword, "detach");
1372 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1373 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1374 : : identifier, NULL);
1375 : :
1376 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1377 : : .f = cmd_operate_detach_device_parsed,
1378 : : .data = NULL,
1379 : : .help_str = "device detach <identifier>:"
1380 : : "(identifier: pci address or virtual dev name)",
1381 : : .tokens = {
1382 : : (void *)&cmd_operate_detach_device_device,
1383 : : (void *)&cmd_operate_detach_device_keyword,
1384 : : (void *)&cmd_operate_detach_device_identifier,
1385 : : NULL,
1386 : : },
1387 : : };
1388 : : /* *** configure speed for all ports *** */
1389 : : struct cmd_config_speed_all {
1390 : : cmdline_fixed_string_t port;
1391 : : cmdline_fixed_string_t keyword;
1392 : : cmdline_fixed_string_t all;
1393 : : cmdline_fixed_string_t item1;
1394 : : cmdline_fixed_string_t item2;
1395 : : cmdline_fixed_string_t value1;
1396 : : cmdline_fixed_string_t value2;
1397 : : };
1398 : :
1399 : : static int
1400 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1401 : : {
1402 : :
1403 : : int duplex;
1404 : :
1405 : 0 : if (!strcmp(duplexstr, "half")) {
1406 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1407 : 0 : } else if (!strcmp(duplexstr, "full")) {
1408 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1409 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1410 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1411 : : } else {
1412 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1413 : 0 : return -1;
1414 : : }
1415 : :
1416 : 0 : if (!strcmp(speedstr, "10")) {
1417 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1418 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1419 : 0 : } else if (!strcmp(speedstr, "100")) {
1420 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1421 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1422 : : } else {
1423 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1424 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1425 : 0 : return -1;
1426 : : }
1427 : 0 : if (!strcmp(speedstr, "1000")) {
1428 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1429 : 0 : } else if (!strcmp(speedstr, "2500")) {
1430 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1431 : 0 : } else if (!strcmp(speedstr, "5000")) {
1432 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1433 : 0 : } else if (!strcmp(speedstr, "10000")) {
1434 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1435 : 0 : } else if (!strcmp(speedstr, "25000")) {
1436 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1437 : 0 : } else if (!strcmp(speedstr, "40000")) {
1438 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1439 : 0 : } else if (!strcmp(speedstr, "50000")) {
1440 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1441 : 0 : } else if (!strcmp(speedstr, "100000")) {
1442 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1443 : 0 : } else if (!strcmp(speedstr, "200000")) {
1444 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1445 : 0 : } else if (!strcmp(speedstr, "400000")) {
1446 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1447 : 0 : } else if (!strcmp(speedstr, "800000")) {
1448 : 0 : *speed = RTE_ETH_LINK_SPEED_800G;
1449 : 0 : } else if (!strcmp(speedstr, "auto")) {
1450 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1451 : : } else {
1452 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1453 : 0 : return -1;
1454 : : }
1455 : : }
1456 : :
1457 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1458 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1459 : :
1460 : : return 0;
1461 : : }
1462 : :
1463 : : static void
1464 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1465 : : __rte_unused struct cmdline *cl,
1466 : : __rte_unused void *data)
1467 : : {
1468 : : struct cmd_config_speed_all *res = parsed_result;
1469 : : uint32_t link_speed;
1470 : : portid_t pid;
1471 : :
1472 : 0 : if (!all_ports_stopped()) {
1473 : 0 : fprintf(stderr, "Please stop all ports first\n");
1474 : 0 : return;
1475 : : }
1476 : :
1477 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1478 : : &link_speed) < 0)
1479 : : return;
1480 : :
1481 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1482 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1483 : : }
1484 : :
1485 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1486 : : }
1487 : :
1488 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1489 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1490 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1491 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1492 : : "config");
1493 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1494 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1495 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1496 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1497 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1498 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1499 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1500 : : "100000#200000#400000#800000#auto");
1501 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1502 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1503 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1504 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1505 : : "half#full#auto");
1506 : :
1507 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1508 : : .f = cmd_config_speed_all_parsed,
1509 : : .data = NULL,
1510 : : .help_str = "port config all speed "
1511 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1512 : : "100000|200000|400000|800000|auto "
1513 : : "duplex half|full|auto",
1514 : : .tokens = {
1515 : : (void *)&cmd_config_speed_all_port,
1516 : : (void *)&cmd_config_speed_all_keyword,
1517 : : (void *)&cmd_config_speed_all_all,
1518 : : (void *)&cmd_config_speed_all_item1,
1519 : : (void *)&cmd_config_speed_all_value1,
1520 : : (void *)&cmd_config_speed_all_item2,
1521 : : (void *)&cmd_config_speed_all_value2,
1522 : : NULL,
1523 : : },
1524 : : };
1525 : :
1526 : : /* *** configure speed for specific port *** */
1527 : : struct cmd_config_speed_specific {
1528 : : cmdline_fixed_string_t port;
1529 : : cmdline_fixed_string_t keyword;
1530 : : portid_t id;
1531 : : cmdline_fixed_string_t item1;
1532 : : cmdline_fixed_string_t item2;
1533 : : cmdline_fixed_string_t value1;
1534 : : cmdline_fixed_string_t value2;
1535 : : };
1536 : :
1537 : : static void
1538 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1539 : : __rte_unused struct cmdline *cl,
1540 : : __rte_unused void *data)
1541 : : {
1542 : : struct cmd_config_speed_specific *res = parsed_result;
1543 : : uint32_t link_speed;
1544 : :
1545 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1546 : 0 : return;
1547 : :
1548 : 0 : if (!port_is_stopped(res->id)) {
1549 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1550 : 0 : return;
1551 : : }
1552 : :
1553 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1554 : : &link_speed) < 0)
1555 : : return;
1556 : :
1557 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1558 : :
1559 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1560 : : }
1561 : :
1562 : :
1563 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1564 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1565 : : "port");
1566 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1567 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1568 : : "config");
1569 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1570 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1571 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1572 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1573 : : "speed");
1574 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1575 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1576 : : "10#100#1000#2500#5000#10000#25000#40000#50000#"
1577 : : "100000#200000#400000#800000#auto");
1578 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1579 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1580 : : "duplex");
1581 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1582 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1583 : : "half#full#auto");
1584 : :
1585 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1586 : : .f = cmd_config_speed_specific_parsed,
1587 : : .data = NULL,
1588 : : .help_str = "port config <port_id> speed "
1589 : : "10|100|1000|2500|5000|10000|25000|40000|50000|"
1590 : : "100000|200000|400000|800000|auto "
1591 : : "duplex half|full|auto",
1592 : : .tokens = {
1593 : : (void *)&cmd_config_speed_specific_port,
1594 : : (void *)&cmd_config_speed_specific_keyword,
1595 : : (void *)&cmd_config_speed_specific_id,
1596 : : (void *)&cmd_config_speed_specific_item1,
1597 : : (void *)&cmd_config_speed_specific_value1,
1598 : : (void *)&cmd_config_speed_specific_item2,
1599 : : (void *)&cmd_config_speed_specific_value2,
1600 : : NULL,
1601 : : },
1602 : : };
1603 : :
1604 : : static int
1605 : 0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
1606 : : {
1607 : : int ret;
1608 : :
1609 : 0 : ret = rte_eth_speed_lanes_set(pid, lanes);
1610 : 0 : if (ret == -ENOTSUP) {
1611 : 0 : fprintf(stderr, "Function not implemented\n");
1612 : 0 : return -1;
1613 : 0 : } else if (ret < 0) {
1614 : 0 : fprintf(stderr, "Set speed lanes failed\n");
1615 : 0 : return -1;
1616 : : }
1617 : :
1618 : : return 0;
1619 : : }
1620 : :
1621 : : static void
1622 : 0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
1623 : : {
1624 : : unsigned int i;
1625 : : uint32_t capa;
1626 : :
1627 : : printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
1628 : : printf("\n-----------------------------------\n");
1629 : 0 : for (i = 0; i < num; i++) {
1630 : 0 : printf("%-17s ",
1631 : 0 : rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
1632 : 0 : capa = speed_lanes_capa[i].capa;
1633 : : int s = 0;
1634 : :
1635 : 0 : while (capa) {
1636 : 0 : if (capa & 0x1)
1637 : : printf("%-2d ", s);
1638 : 0 : s++;
1639 : 0 : capa = capa >> 1;
1640 : : }
1641 : : printf("\n");
1642 : : }
1643 : 0 : }
1644 : :
1645 : : /* *** display speed lanes per port capabilities *** */
1646 : : struct cmd_show_speed_lanes_result {
1647 : : cmdline_fixed_string_t cmd_show;
1648 : : cmdline_fixed_string_t cmd_port;
1649 : : cmdline_fixed_string_t cmd_keyword;
1650 : : portid_t cmd_pid;
1651 : : };
1652 : :
1653 : : static void
1654 : 0 : cmd_show_speed_lanes_parsed(void *parsed_result,
1655 : : __rte_unused struct cmdline *cl,
1656 : : __rte_unused void *data)
1657 : : {
1658 : : struct cmd_show_speed_lanes_result *res = parsed_result;
1659 : : struct rte_eth_speed_lanes_capa *speed_lanes_capa;
1660 : : unsigned int num;
1661 : : int ret;
1662 : :
1663 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
1664 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
1665 : 0 : return;
1666 : : }
1667 : :
1668 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
1669 : 0 : if (ret == -ENOTSUP) {
1670 : 0 : fprintf(stderr, "Function not implemented\n");
1671 : 0 : return;
1672 : 0 : } else if (ret < 0) {
1673 : 0 : fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
1674 : 0 : return;
1675 : : }
1676 : :
1677 : 0 : num = (unsigned int)ret;
1678 : 0 : speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
1679 : 0 : if (speed_lanes_capa == NULL) {
1680 : 0 : fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
1681 : 0 : return;
1682 : : }
1683 : :
1684 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
1685 : 0 : if (ret < 0) {
1686 : 0 : fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
1687 : 0 : goto out;
1688 : : }
1689 : :
1690 : 0 : show_speed_lanes_capability(num, speed_lanes_capa);
1691 : 0 : out:
1692 : 0 : free(speed_lanes_capa);
1693 : : }
1694 : :
1695 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
1696 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1697 : : cmd_show, "show");
1698 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
1699 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1700 : : cmd_port, "port");
1701 : : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
1702 : : TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
1703 : : cmd_pid, RTE_UINT16);
1704 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
1705 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1706 : : cmd_keyword, "speed_lanes");
1707 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
1708 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1709 : : cmd_keyword, "capabilities");
1710 : :
1711 : : static cmdline_parse_inst_t cmd_show_speed_lanes = {
1712 : : .f = cmd_show_speed_lanes_parsed,
1713 : : .data = NULL,
1714 : : .help_str = "show port <port_id> speed_lanes capabilities",
1715 : : .tokens = {
1716 : : (void *)&cmd_show_speed_lanes_show,
1717 : : (void *)&cmd_show_speed_lanes_port,
1718 : : (void *)&cmd_show_speed_lanes_pid,
1719 : : (void *)&cmd_show_speed_lanes_keyword,
1720 : : (void *)&cmd_show_speed_lanes_cap_keyword,
1721 : : NULL,
1722 : : },
1723 : : };
1724 : :
1725 : : /* *** configure speed_lanes for all ports *** */
1726 : : struct cmd_config_speed_lanes_all {
1727 : : cmdline_fixed_string_t port;
1728 : : cmdline_fixed_string_t keyword;
1729 : : cmdline_fixed_string_t all;
1730 : : cmdline_fixed_string_t item;
1731 : : uint32_t lanes;
1732 : : };
1733 : :
1734 : : static void
1735 : 0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
1736 : : __rte_unused struct cmdline *cl,
1737 : : __rte_unused void *data)
1738 : : {
1739 : : struct cmd_config_speed_lanes_all *res = parsed_result;
1740 : : portid_t pid;
1741 : :
1742 : 0 : if (!all_ports_stopped()) {
1743 : 0 : fprintf(stderr, "Please stop all ports first\n");
1744 : 0 : return;
1745 : : }
1746 : :
1747 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1748 : 0 : if (parse_speed_lanes_cfg(pid, res->lanes))
1749 : : return;
1750 : : }
1751 : :
1752 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1753 : : }
1754 : :
1755 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
1756 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
1757 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
1758 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
1759 : : "config");
1760 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
1761 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
1762 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
1763 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
1764 : : "speed_lanes");
1765 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
1766 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
1767 : :
1768 : : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
1769 : : .f = cmd_config_speed_lanes_all_parsed,
1770 : : .data = NULL,
1771 : : .help_str = "port config all speed_lanes <value>",
1772 : : .tokens = {
1773 : : (void *)&cmd_config_speed_lanes_all_port,
1774 : : (void *)&cmd_config_speed_lanes_all_keyword,
1775 : : (void *)&cmd_config_speed_lanes_all_all,
1776 : : (void *)&cmd_config_speed_lanes_all_item,
1777 : : (void *)&cmd_config_speed_lanes_all_lanes,
1778 : : NULL,
1779 : : },
1780 : : };
1781 : :
1782 : : /* *** configure speed_lanes for specific port *** */
1783 : : struct cmd_config_speed_lanes_specific {
1784 : : cmdline_fixed_string_t port;
1785 : : cmdline_fixed_string_t keyword;
1786 : : uint16_t port_id;
1787 : : cmdline_fixed_string_t item;
1788 : : uint32_t lanes;
1789 : : };
1790 : :
1791 : : static void
1792 : 0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
1793 : : __rte_unused struct cmdline *cl,
1794 : : __rte_unused void *data)
1795 : : {
1796 : : struct cmd_config_speed_lanes_specific *res = parsed_result;
1797 : :
1798 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1799 : : return;
1800 : :
1801 : 0 : if (!port_is_stopped(res->port_id)) {
1802 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1803 : 0 : return;
1804 : : }
1805 : :
1806 : 0 : if (parse_speed_lanes_cfg(res->port_id, res->lanes))
1807 : : return;
1808 : :
1809 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1810 : : }
1811 : :
1812 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
1813 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
1814 : : "port");
1815 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
1816 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
1817 : : "config");
1818 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
1819 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
1820 : : RTE_UINT16);
1821 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
1822 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
1823 : : "speed_lanes");
1824 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
1825 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
1826 : : RTE_UINT32);
1827 : :
1828 : : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
1829 : : .f = cmd_config_speed_lanes_specific_parsed,
1830 : : .data = NULL,
1831 : : .help_str = "port config <port_id> speed_lanes <value>",
1832 : : .tokens = {
1833 : : (void *)&cmd_config_speed_lanes_specific_port,
1834 : : (void *)&cmd_config_speed_lanes_specific_keyword,
1835 : : (void *)&cmd_config_speed_lanes_specific_id,
1836 : : (void *)&cmd_config_speed_lanes_specific_item,
1837 : : (void *)&cmd_config_speed_lanes_specific_lanes,
1838 : : NULL,
1839 : : },
1840 : : };
1841 : :
1842 : : /* *** configure loopback for all ports *** */
1843 : : struct cmd_config_loopback_all {
1844 : : cmdline_fixed_string_t port;
1845 : : cmdline_fixed_string_t keyword;
1846 : : cmdline_fixed_string_t all;
1847 : : cmdline_fixed_string_t item;
1848 : : uint32_t mode;
1849 : : };
1850 : :
1851 : : static void
1852 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1853 : : __rte_unused struct cmdline *cl,
1854 : : __rte_unused void *data)
1855 : : {
1856 : : struct cmd_config_loopback_all *res = parsed_result;
1857 : : portid_t pid;
1858 : :
1859 : 0 : if (!all_ports_stopped()) {
1860 : 0 : fprintf(stderr, "Please stop all ports first\n");
1861 : 0 : return;
1862 : : }
1863 : :
1864 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1865 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1866 : : }
1867 : :
1868 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1869 : : }
1870 : :
1871 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1872 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1873 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1874 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1875 : : "config");
1876 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1877 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1878 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1879 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1880 : : "loopback");
1881 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1882 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1883 : :
1884 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1885 : : .f = cmd_config_loopback_all_parsed,
1886 : : .data = NULL,
1887 : : .help_str = "port config all loopback <mode>",
1888 : : .tokens = {
1889 : : (void *)&cmd_config_loopback_all_port,
1890 : : (void *)&cmd_config_loopback_all_keyword,
1891 : : (void *)&cmd_config_loopback_all_all,
1892 : : (void *)&cmd_config_loopback_all_item,
1893 : : (void *)&cmd_config_loopback_all_mode,
1894 : : NULL,
1895 : : },
1896 : : };
1897 : :
1898 : : /* *** configure loopback for specific port *** */
1899 : : struct cmd_config_loopback_specific {
1900 : : cmdline_fixed_string_t port;
1901 : : cmdline_fixed_string_t keyword;
1902 : : uint16_t port_id;
1903 : : cmdline_fixed_string_t item;
1904 : : uint32_t mode;
1905 : : };
1906 : :
1907 : : static void
1908 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1909 : : __rte_unused struct cmdline *cl,
1910 : : __rte_unused void *data)
1911 : : {
1912 : : struct cmd_config_loopback_specific *res = parsed_result;
1913 : :
1914 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1915 : : return;
1916 : :
1917 : 0 : if (!port_is_stopped(res->port_id)) {
1918 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1919 : 0 : return;
1920 : : }
1921 : :
1922 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1923 : :
1924 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1925 : : }
1926 : :
1927 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1928 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1929 : : "port");
1930 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1931 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1932 : : "config");
1933 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1934 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1935 : : RTE_UINT16);
1936 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1937 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1938 : : "loopback");
1939 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1940 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1941 : : RTE_UINT32);
1942 : :
1943 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1944 : : .f = cmd_config_loopback_specific_parsed,
1945 : : .data = NULL,
1946 : : .help_str = "port config <port_id> loopback <mode>",
1947 : : .tokens = {
1948 : : (void *)&cmd_config_loopback_specific_port,
1949 : : (void *)&cmd_config_loopback_specific_keyword,
1950 : : (void *)&cmd_config_loopback_specific_id,
1951 : : (void *)&cmd_config_loopback_specific_item,
1952 : : (void *)&cmd_config_loopback_specific_mode,
1953 : : NULL,
1954 : : },
1955 : : };
1956 : :
1957 : : /* *** configure txq/rxq, txd/rxd *** */
1958 : : struct cmd_config_rx_tx {
1959 : : cmdline_fixed_string_t port;
1960 : : cmdline_fixed_string_t keyword;
1961 : : cmdline_fixed_string_t all;
1962 : : cmdline_fixed_string_t name;
1963 : : uint16_t value;
1964 : : };
1965 : :
1966 : : static void
1967 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1968 : : __rte_unused struct cmdline *cl,
1969 : : __rte_unused void *data)
1970 : : {
1971 : : struct cmd_config_rx_tx *res = parsed_result;
1972 : :
1973 : 0 : if (!all_ports_stopped()) {
1974 : 0 : fprintf(stderr, "Please stop all ports first\n");
1975 : 0 : return;
1976 : : }
1977 : 0 : if (!strcmp(res->name, "rxq")) {
1978 : 0 : if (!res->value && !nb_txq) {
1979 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1980 : 0 : return;
1981 : : }
1982 : 0 : if (check_nb_rxq(res->value) != 0)
1983 : : return;
1984 : 0 : nb_rxq = res->value;
1985 : : }
1986 : 0 : else if (!strcmp(res->name, "txq")) {
1987 : 0 : if (!res->value && !nb_rxq) {
1988 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1989 : 0 : return;
1990 : : }
1991 : 0 : if (check_nb_txq(res->value) != 0)
1992 : : return;
1993 : 0 : nb_txq = res->value;
1994 : : }
1995 : 0 : else if (!strcmp(res->name, "rxd")) {
1996 : 0 : if (check_nb_rxd(res->value) != 0)
1997 : : return;
1998 : 0 : nb_rxd = res->value;
1999 : 0 : } else if (!strcmp(res->name, "txd")) {
2000 : 0 : if (check_nb_txd(res->value) != 0)
2001 : : return;
2002 : :
2003 : 0 : nb_txd = res->value;
2004 : : } else {
2005 : 0 : fprintf(stderr, "Unknown parameter\n");
2006 : 0 : return;
2007 : : }
2008 : :
2009 : 0 : fwd_config_setup();
2010 : :
2011 : 0 : init_port_config();
2012 : :
2013 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2014 : : }
2015 : :
2016 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
2017 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
2018 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
2019 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2020 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
2021 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2022 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
2023 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2024 : : "rxq#txq#rxd#txd");
2025 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
2026 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
2027 : :
2028 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
2029 : : .f = cmd_config_rx_tx_parsed,
2030 : : .data = NULL,
2031 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
2032 : : .tokens = {
2033 : : (void *)&cmd_config_rx_tx_port,
2034 : : (void *)&cmd_config_rx_tx_keyword,
2035 : : (void *)&cmd_config_rx_tx_all,
2036 : : (void *)&cmd_config_rx_tx_name,
2037 : : (void *)&cmd_config_rx_tx_value,
2038 : : NULL,
2039 : : },
2040 : : };
2041 : :
2042 : : /* *** config max packet length *** */
2043 : : struct cmd_config_max_pkt_len_result {
2044 : : cmdline_fixed_string_t port;
2045 : : cmdline_fixed_string_t keyword;
2046 : : cmdline_fixed_string_t all;
2047 : : cmdline_fixed_string_t name;
2048 : : uint32_t value;
2049 : : };
2050 : :
2051 : : static void
2052 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
2053 : : __rte_unused struct cmdline *cl,
2054 : : __rte_unused void *data)
2055 : : {
2056 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
2057 : : portid_t port_id;
2058 : : int ret;
2059 : :
2060 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
2061 : : printf("Unknown parameter\n");
2062 : 0 : return;
2063 : : }
2064 : :
2065 : 0 : if (!all_ports_stopped()) {
2066 : 0 : fprintf(stderr, "Please stop all ports first\n");
2067 : 0 : return;
2068 : : }
2069 : :
2070 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
2071 : 0 : struct rte_port *port = &ports[port_id];
2072 : :
2073 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
2074 : 0 : fprintf(stderr,
2075 : : "max-pkt-len can not be less than %d\n",
2076 : : RTE_ETHER_MIN_LEN);
2077 : 0 : return;
2078 : : }
2079 : :
2080 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
2081 : 0 : if (ret != 0) {
2082 : 0 : fprintf(stderr,
2083 : : "rte_eth_dev_info_get() failed for port %u\n",
2084 : : port_id);
2085 : 0 : return;
2086 : : }
2087 : :
2088 : 0 : update_mtu_from_frame_size(port_id, res->value);
2089 : : }
2090 : :
2091 : 0 : init_port_config();
2092 : :
2093 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2094 : : }
2095 : :
2096 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2097 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2098 : : "port");
2099 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2100 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2101 : : "config");
2102 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2103 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2104 : : "all");
2105 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2106 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2107 : : "max-pkt-len");
2108 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2109 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2110 : : RTE_UINT32);
2111 : :
2112 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
2113 : : .f = cmd_config_max_pkt_len_parsed,
2114 : : .data = NULL,
2115 : : .help_str = "port config all max-pkt-len <value>",
2116 : : .tokens = {
2117 : : (void *)&cmd_config_max_pkt_len_port,
2118 : : (void *)&cmd_config_max_pkt_len_keyword,
2119 : : (void *)&cmd_config_max_pkt_len_all,
2120 : : (void *)&cmd_config_max_pkt_len_name,
2121 : : (void *)&cmd_config_max_pkt_len_value,
2122 : : NULL,
2123 : : },
2124 : : };
2125 : :
2126 : : /* *** config max LRO aggregated packet size *** */
2127 : : struct cmd_config_max_lro_pkt_size_result {
2128 : : cmdline_fixed_string_t port;
2129 : : cmdline_fixed_string_t keyword;
2130 : : cmdline_fixed_string_t all;
2131 : : cmdline_fixed_string_t name;
2132 : : uint32_t value;
2133 : : };
2134 : :
2135 : : static void
2136 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2137 : : __rte_unused struct cmdline *cl,
2138 : : __rte_unused void *data)
2139 : : {
2140 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2141 : : portid_t pid;
2142 : :
2143 : 0 : if (!all_ports_stopped()) {
2144 : 0 : fprintf(stderr, "Please stop all ports first\n");
2145 : 0 : return;
2146 : : }
2147 : :
2148 : 0 : RTE_ETH_FOREACH_DEV(pid) {
2149 : 0 : struct rte_port *port = &ports[pid];
2150 : :
2151 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
2152 : 0 : if (res->value ==
2153 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
2154 : : return;
2155 : :
2156 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2157 : : } else {
2158 : 0 : fprintf(stderr, "Unknown parameter\n");
2159 : 0 : return;
2160 : : }
2161 : : }
2162 : :
2163 : 0 : init_port_config();
2164 : :
2165 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2166 : : }
2167 : :
2168 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2169 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2170 : : port, "port");
2171 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2172 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2173 : : keyword, "config");
2174 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2175 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2176 : : all, "all");
2177 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2178 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2179 : : name, "max-lro-pkt-size");
2180 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2181 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2182 : : value, RTE_UINT32);
2183 : :
2184 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2185 : : .f = cmd_config_max_lro_pkt_size_parsed,
2186 : : .data = NULL,
2187 : : .help_str = "port config all max-lro-pkt-size <value>",
2188 : : .tokens = {
2189 : : (void *)&cmd_config_max_lro_pkt_size_port,
2190 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
2191 : : (void *)&cmd_config_max_lro_pkt_size_all,
2192 : : (void *)&cmd_config_max_lro_pkt_size_name,
2193 : : (void *)&cmd_config_max_lro_pkt_size_value,
2194 : : NULL,
2195 : : },
2196 : : };
2197 : :
2198 : : /* *** configure port MTU *** */
2199 : : struct cmd_config_mtu_result {
2200 : : cmdline_fixed_string_t port;
2201 : : cmdline_fixed_string_t keyword;
2202 : : cmdline_fixed_string_t mtu;
2203 : : portid_t port_id;
2204 : : uint16_t value;
2205 : : };
2206 : :
2207 : : static void
2208 : 0 : cmd_config_mtu_parsed(void *parsed_result,
2209 : : __rte_unused struct cmdline *cl,
2210 : : __rte_unused void *data)
2211 : : {
2212 : : struct cmd_config_mtu_result *res = parsed_result;
2213 : :
2214 : 0 : port_mtu_set(res->port_id, res->value);
2215 : 0 : }
2216 : :
2217 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
2218 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2219 : : "port");
2220 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2221 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2222 : : "config");
2223 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2224 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2225 : : "mtu");
2226 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2227 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2228 : : RTE_UINT16);
2229 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
2230 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2231 : : RTE_UINT16);
2232 : :
2233 : : static cmdline_parse_inst_t cmd_config_mtu = {
2234 : : .f = cmd_config_mtu_parsed,
2235 : : .data = NULL,
2236 : : .help_str = "port config mtu <port_id> <value>",
2237 : : .tokens = {
2238 : : (void *)&cmd_config_mtu_port,
2239 : : (void *)&cmd_config_mtu_keyword,
2240 : : (void *)&cmd_config_mtu_mtu,
2241 : : (void *)&cmd_config_mtu_port_id,
2242 : : (void *)&cmd_config_mtu_value,
2243 : : NULL,
2244 : : },
2245 : : };
2246 : :
2247 : : /* *** configure rx mode *** */
2248 : : struct cmd_config_rx_mode_flag {
2249 : : cmdline_fixed_string_t port;
2250 : : cmdline_fixed_string_t keyword;
2251 : : cmdline_fixed_string_t all;
2252 : : cmdline_fixed_string_t name;
2253 : : cmdline_fixed_string_t value;
2254 : : };
2255 : :
2256 : : static void
2257 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
2258 : : __rte_unused struct cmdline *cl,
2259 : : __rte_unused void *data)
2260 : : {
2261 : : struct cmd_config_rx_mode_flag *res = parsed_result;
2262 : :
2263 : 0 : if (!all_ports_stopped()) {
2264 : 0 : fprintf(stderr, "Please stop all ports first\n");
2265 : 0 : return;
2266 : : }
2267 : :
2268 : 0 : if (!strcmp(res->name, "drop-en")) {
2269 : 0 : if (!strcmp(res->value, "on"))
2270 : 0 : rx_drop_en = 1;
2271 : 0 : else if (!strcmp(res->value, "off"))
2272 : 0 : rx_drop_en = 0;
2273 : : else {
2274 : 0 : fprintf(stderr, "Unknown parameter\n");
2275 : 0 : return;
2276 : : }
2277 : : } else {
2278 : 0 : fprintf(stderr, "Unknown parameter\n");
2279 : 0 : return;
2280 : : }
2281 : :
2282 : 0 : init_port_config();
2283 : :
2284 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2285 : : }
2286 : :
2287 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2288 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2289 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2290 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2291 : : "config");
2292 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2293 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2294 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2295 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2296 : : "drop-en");
2297 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2298 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2299 : : "on#off");
2300 : :
2301 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2302 : : .f = cmd_config_rx_mode_flag_parsed,
2303 : : .data = NULL,
2304 : : .help_str = "port config all drop-en on|off",
2305 : : .tokens = {
2306 : : (void *)&cmd_config_rx_mode_flag_port,
2307 : : (void *)&cmd_config_rx_mode_flag_keyword,
2308 : : (void *)&cmd_config_rx_mode_flag_all,
2309 : : (void *)&cmd_config_rx_mode_flag_name,
2310 : : (void *)&cmd_config_rx_mode_flag_value,
2311 : : NULL,
2312 : : },
2313 : : };
2314 : :
2315 : : /* *** configure rss *** */
2316 : : struct cmd_config_rss {
2317 : : cmdline_fixed_string_t port;
2318 : : cmdline_fixed_string_t keyword;
2319 : : cmdline_fixed_string_t all;
2320 : : cmdline_fixed_string_t name;
2321 : : cmdline_fixed_string_t value;
2322 : : };
2323 : :
2324 : : static void
2325 : 0 : cmd_config_rss_parsed(void *parsed_result,
2326 : : __rte_unused struct cmdline *cl,
2327 : : __rte_unused void *data)
2328 : : {
2329 : : struct cmd_config_rss *res = parsed_result;
2330 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2331 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2332 : : int use_default = 0;
2333 : : int all_updated = 1;
2334 : : int diag;
2335 : : uint16_t i;
2336 : : int ret;
2337 : :
2338 : 0 : if (!strcmp(res->value, "level-default")) {
2339 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2340 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2341 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2342 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2343 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2344 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2345 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2346 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2347 : 0 : } else if (!strcmp(res->value, "default")) {
2348 : : use_default = 1;
2349 : 0 : } else if (isdigit(res->value[0])) {
2350 : : int value = atoi(res->value);
2351 : 0 : if (value > 0 && value < 64)
2352 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2353 : : else {
2354 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2355 : 0 : return;
2356 : : }
2357 : 0 : } else if (!strcmp(res->value, "none")) {
2358 : : rss_conf.rss_hf = 0;
2359 : : } else {
2360 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2361 : 0 : if (rss_conf.rss_hf == 0) {
2362 : 0 : fprintf(stderr, "Unknown parameter\n");
2363 : 0 : return;
2364 : : }
2365 : : }
2366 : : rss_conf.rss_key = NULL;
2367 : : /* Update global configuration for RSS types. */
2368 : 0 : RTE_ETH_FOREACH_DEV(i) {
2369 : : struct rte_eth_rss_conf local_rss_conf;
2370 : :
2371 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2372 : 0 : if (ret != 0)
2373 : 0 : return;
2374 : :
2375 : 0 : if (use_default)
2376 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2377 : :
2378 : 0 : local_rss_conf = rss_conf;
2379 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2380 : 0 : dev_info.flow_type_rss_offloads;
2381 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2382 : : printf("Port %u modified RSS hash function based on hardware support,"
2383 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2384 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2385 : : }
2386 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2387 : 0 : if (diag < 0) {
2388 : : all_updated = 0;
2389 : 0 : fprintf(stderr,
2390 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2391 : : i, -diag, strerror(-diag));
2392 : : }
2393 : : }
2394 : 0 : if (all_updated && !use_default) {
2395 : 0 : rss_hf = rss_conf.rss_hf;
2396 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2397 : : }
2398 : : }
2399 : :
2400 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2401 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2402 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2403 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2404 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2405 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2406 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2407 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2408 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2409 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2410 : :
2411 : : static cmdline_parse_inst_t cmd_config_rss = {
2412 : : .f = cmd_config_rss_parsed,
2413 : : .data = NULL,
2414 : : .help_str = "port config all rss "
2415 : : "all|default|level-default|level-outer|level-inner|"
2416 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2417 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2418 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2419 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2420 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2421 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2422 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2423 : : .tokens = {
2424 : : (void *)&cmd_config_rss_port,
2425 : : (void *)&cmd_config_rss_keyword,
2426 : : (void *)&cmd_config_rss_all,
2427 : : (void *)&cmd_config_rss_name,
2428 : : (void *)&cmd_config_rss_value,
2429 : : NULL,
2430 : : },
2431 : : };
2432 : :
2433 : : /* *** configure rss hash key *** */
2434 : : struct cmd_config_rss_hash_key {
2435 : : cmdline_fixed_string_t port;
2436 : : cmdline_fixed_string_t config;
2437 : : portid_t port_id;
2438 : : cmdline_fixed_string_t rss_hash_key;
2439 : : cmdline_fixed_string_t rss_type;
2440 : : cmdline_fixed_string_t key;
2441 : : };
2442 : :
2443 : : static uint8_t
2444 : : hexa_digit_to_value(char hexa_digit)
2445 : : {
2446 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2447 : : return (uint8_t) (hexa_digit - '0');
2448 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2449 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2450 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2451 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2452 : : /* Invalid hexa digit */
2453 : : return 0xFF;
2454 : : }
2455 : :
2456 : : static uint8_t
2457 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2458 : : {
2459 : : uint8_t hexa_v;
2460 : :
2461 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2462 : : if (hexa_v == 0xFF)
2463 : 0 : fprintf(stderr,
2464 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2465 : : key[idx], idx);
2466 : 0 : return hexa_v;
2467 : : }
2468 : :
2469 : : static void
2470 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2471 : : __rte_unused struct cmdline *cl,
2472 : : __rte_unused void *data)
2473 : : {
2474 : : struct cmd_config_rss_hash_key *res = parsed_result;
2475 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2476 : : uint8_t xdgt0;
2477 : : uint8_t xdgt1;
2478 : : int i;
2479 : : struct rte_eth_dev_info dev_info;
2480 : : uint8_t hash_key_size;
2481 : : uint32_t key_len;
2482 : : int ret;
2483 : :
2484 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2485 : 0 : if (ret != 0)
2486 : 0 : return;
2487 : :
2488 : 0 : if (dev_info.hash_key_size > 0 &&
2489 : : dev_info.hash_key_size <= sizeof(hash_key))
2490 : : hash_key_size = dev_info.hash_key_size;
2491 : : else {
2492 : 0 : fprintf(stderr,
2493 : : "dev_info did not provide a valid hash key size\n");
2494 : 0 : return;
2495 : : }
2496 : : /* Check the length of the RSS hash key */
2497 : 0 : key_len = strlen(res->key);
2498 : 0 : if (key_len != (hash_key_size * 2)) {
2499 : 0 : fprintf(stderr,
2500 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2501 : : (int)key_len, hash_key_size * 2);
2502 : 0 : return;
2503 : : }
2504 : : /* Translate RSS hash key into binary representation */
2505 : 0 : for (i = 0; i < hash_key_size; i++) {
2506 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2507 : 0 : if (xdgt0 == 0xFF)
2508 : : return;
2509 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2510 : 0 : if (xdgt1 == 0xFF)
2511 : : return;
2512 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2513 : : }
2514 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2515 : : hash_key_size);
2516 : : }
2517 : :
2518 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2519 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2520 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2521 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2522 : : "config");
2523 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2524 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2525 : : RTE_UINT16);
2526 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2527 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2528 : : rss_hash_key, "rss-hash-key");
2529 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2530 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2531 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2532 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2533 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2534 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2535 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2536 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2537 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2538 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2539 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2540 : :
2541 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2542 : : .f = cmd_config_rss_hash_key_parsed,
2543 : : .data = NULL,
2544 : : .help_str = "port config <port_id> rss-hash-key "
2545 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2546 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2547 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2548 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2549 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2550 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2551 : : "<string of hex digits (variable length, NIC dependent)>",
2552 : : .tokens = {
2553 : : (void *)&cmd_config_rss_hash_key_port,
2554 : : (void *)&cmd_config_rss_hash_key_config,
2555 : : (void *)&cmd_config_rss_hash_key_port_id,
2556 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2557 : : (void *)&cmd_config_rss_hash_key_rss_type,
2558 : : (void *)&cmd_config_rss_hash_key_value,
2559 : : NULL,
2560 : : },
2561 : : };
2562 : :
2563 : : /* *** configure rss hash algorithm *** */
2564 : : struct cmd_config_rss_hash_algo {
2565 : : cmdline_fixed_string_t port;
2566 : : cmdline_fixed_string_t config;
2567 : : portid_t port_id;
2568 : : cmdline_fixed_string_t rss_hash_algo;
2569 : : cmdline_fixed_string_t algo;
2570 : : };
2571 : :
2572 : : static void
2573 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2574 : : __rte_unused struct cmdline *cl,
2575 : : __rte_unused void *data)
2576 : : {
2577 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2578 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2579 : : struct rte_eth_rss_conf rss_conf;
2580 : : uint32_t algorithm;
2581 : : int ret;
2582 : :
2583 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2584 : 0 : rss_conf.rss_key = rss_key;
2585 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2586 : 0 : if (ret != 0) {
2587 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2588 : 0 : res->port_id);
2589 : 0 : return;
2590 : : }
2591 : :
2592 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2593 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2594 : 0 : if (ret != 0) {
2595 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2596 : 0 : res->port_id, res->algo);
2597 : 0 : return;
2598 : : }
2599 : :
2600 : 0 : rss_conf.algorithm = algorithm;
2601 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2602 : 0 : if (ret != 0) {
2603 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2604 : 0 : res->port_id);
2605 : 0 : return;
2606 : : }
2607 : : }
2608 : :
2609 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2610 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2611 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2612 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2613 : : "config");
2614 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2615 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2616 : : RTE_UINT16);
2617 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2618 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2619 : : rss_hash_algo, "rss-hash-algo");
2620 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2621 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2622 : : "default#simple_xor#toeplitz#"
2623 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2624 : :
2625 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2626 : : .f = cmd_config_rss_hash_algo_parsed,
2627 : : .data = NULL,
2628 : : .help_str = "port config <port_id> rss-hash-algo "
2629 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2630 : : .tokens = {
2631 : : (void *)&cmd_config_rss_hash_algo_port,
2632 : : (void *)&cmd_config_rss_hash_algo_config,
2633 : : (void *)&cmd_config_rss_hash_algo_port_id,
2634 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2635 : : (void *)&cmd_config_rss_hash_algo_algo,
2636 : : NULL,
2637 : : },
2638 : : };
2639 : :
2640 : : /* *** cleanup txq mbufs *** */
2641 : : struct cmd_cleanup_txq_mbufs_result {
2642 : : cmdline_fixed_string_t port;
2643 : : cmdline_fixed_string_t keyword;
2644 : : cmdline_fixed_string_t name;
2645 : : uint16_t port_id;
2646 : : uint16_t queue_id;
2647 : : uint32_t free_cnt;
2648 : : };
2649 : :
2650 : : static void
2651 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2652 : : __rte_unused struct cmdline *cl,
2653 : : __rte_unused void *data)
2654 : : {
2655 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2656 : 0 : uint16_t port_id = res->port_id;
2657 : 0 : uint16_t queue_id = res->queue_id;
2658 : 0 : uint32_t free_cnt = res->free_cnt;
2659 : : struct rte_eth_txq_info qinfo;
2660 : : int ret;
2661 : :
2662 : 0 : if (test_done == 0) {
2663 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2664 : 0 : return;
2665 : : }
2666 : :
2667 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2668 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2669 : : port_id, queue_id);
2670 : 0 : return;
2671 : : }
2672 : :
2673 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2674 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2675 : 0 : return;
2676 : : }
2677 : :
2678 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2679 : 0 : if (ret < 0) {
2680 : 0 : fprintf(stderr,
2681 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2682 : : port_id, queue_id, strerror(-ret), ret);
2683 : 0 : return;
2684 : : }
2685 : :
2686 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2687 : : port_id, queue_id, ret);
2688 : : }
2689 : :
2690 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2691 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2692 : : "port");
2693 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2694 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2695 : : "cleanup");
2696 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2697 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2698 : : RTE_UINT16);
2699 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2700 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2701 : : "txq");
2702 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2703 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2704 : : RTE_UINT16);
2705 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2706 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2707 : : RTE_UINT32);
2708 : :
2709 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2710 : : .f = cmd_cleanup_txq_mbufs_parsed,
2711 : : .data = NULL,
2712 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2713 : : .tokens = {
2714 : : (void *)&cmd_cleanup_txq_mbufs_port,
2715 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2716 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2717 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2718 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2719 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2720 : : NULL,
2721 : : },
2722 : : };
2723 : :
2724 : : /* *** configure port rxq/txq ring size *** */
2725 : : struct cmd_config_rxtx_ring_size {
2726 : : cmdline_fixed_string_t port;
2727 : : cmdline_fixed_string_t config;
2728 : : portid_t portid;
2729 : : cmdline_fixed_string_t rxtxq;
2730 : : uint16_t qid;
2731 : : cmdline_fixed_string_t rsize;
2732 : : uint16_t size;
2733 : : };
2734 : :
2735 : : static void
2736 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2737 : : __rte_unused struct cmdline *cl,
2738 : : __rte_unused void *data)
2739 : : {
2740 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2741 : : struct rte_port *port;
2742 : : uint8_t isrx;
2743 : :
2744 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2745 : : return;
2746 : :
2747 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2748 : 0 : fprintf(stderr, "Invalid port id\n");
2749 : 0 : return;
2750 : : }
2751 : :
2752 : 0 : port = &ports[res->portid];
2753 : :
2754 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2755 : : isrx = 1;
2756 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2757 : : isrx = 0;
2758 : : else {
2759 : 0 : fprintf(stderr, "Unknown parameter\n");
2760 : 0 : return;
2761 : : }
2762 : :
2763 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2764 : : return;
2765 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2766 : : return;
2767 : :
2768 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2769 : 0 : fprintf(stderr,
2770 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2771 : : rx_free_thresh);
2772 : 0 : return;
2773 : : }
2774 : :
2775 : 0 : if (isrx)
2776 : 0 : port->nb_rx_desc[res->qid] = res->size;
2777 : : else
2778 : 0 : port->nb_tx_desc[res->qid] = res->size;
2779 : :
2780 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2781 : : }
2782 : :
2783 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2784 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2785 : : port, "port");
2786 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2787 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2788 : : config, "config");
2789 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2790 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2791 : : portid, RTE_UINT16);
2792 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2793 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2794 : : rxtxq, "rxq#txq");
2795 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2796 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2797 : : qid, RTE_UINT16);
2798 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2799 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2800 : : rsize, "ring_size");
2801 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2802 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2803 : : size, RTE_UINT16);
2804 : :
2805 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2806 : : .f = cmd_config_rxtx_ring_size_parsed,
2807 : : .data = NULL,
2808 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2809 : : .tokens = {
2810 : : (void *)&cmd_config_rxtx_ring_size_port,
2811 : : (void *)&cmd_config_rxtx_ring_size_config,
2812 : : (void *)&cmd_config_rxtx_ring_size_portid,
2813 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2814 : : (void *)&cmd_config_rxtx_ring_size_qid,
2815 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2816 : : (void *)&cmd_config_rxtx_ring_size_size,
2817 : : NULL,
2818 : : },
2819 : : };
2820 : :
2821 : : /* *** configure port rxq/txq start/stop *** */
2822 : : struct cmd_config_rxtx_queue {
2823 : : cmdline_fixed_string_t port;
2824 : : portid_t portid;
2825 : : cmdline_fixed_string_t rxtxq;
2826 : : uint16_t qid;
2827 : : cmdline_fixed_string_t opname;
2828 : : };
2829 : :
2830 : : static void
2831 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2832 : : __rte_unused struct cmdline *cl,
2833 : : __rte_unused void *data)
2834 : : {
2835 : : struct cmd_config_rxtx_queue *res = parsed_result;
2836 : : struct rte_port *port;
2837 : : uint8_t isrx;
2838 : : uint8_t isstart;
2839 : : uint8_t *state;
2840 : : int ret = 0;
2841 : :
2842 : 0 : if (test_done == 0) {
2843 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2844 : 0 : return;
2845 : : }
2846 : :
2847 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2848 : : return;
2849 : :
2850 : 0 : if (port_is_started(res->portid) != 1) {
2851 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2852 : 0 : return;
2853 : : }
2854 : :
2855 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2856 : : isrx = 1;
2857 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2858 : : isrx = 0;
2859 : : else {
2860 : 0 : fprintf(stderr, "Unknown parameter\n");
2861 : 0 : return;
2862 : : }
2863 : :
2864 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2865 : : return;
2866 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2867 : : return;
2868 : :
2869 : 0 : if (!strcmp(res->opname, "start"))
2870 : : isstart = 1;
2871 : 0 : else if (!strcmp(res->opname, "stop"))
2872 : : isstart = 0;
2873 : : else {
2874 : 0 : fprintf(stderr, "Unknown parameter\n");
2875 : 0 : return;
2876 : : }
2877 : :
2878 : 0 : if (isstart && isrx)
2879 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2880 : 0 : else if (!isstart && isrx)
2881 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2882 : 0 : else if (isstart && !isrx)
2883 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2884 : : else
2885 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2886 : :
2887 : 0 : if (ret == -ENOTSUP) {
2888 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2889 : 0 : return;
2890 : : }
2891 : :
2892 : 0 : port = &ports[res->portid];
2893 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2894 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2895 : : RTE_ETH_QUEUE_STATE_STOPPED;
2896 : : }
2897 : :
2898 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2899 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2900 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2901 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2902 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2903 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2904 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2905 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2906 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2907 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2908 : : "start#stop");
2909 : :
2910 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2911 : : .f = cmd_config_rxtx_queue_parsed,
2912 : : .data = NULL,
2913 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2914 : : .tokens = {
2915 : : (void *)&cmd_config_rxtx_queue_port,
2916 : : (void *)&cmd_config_rxtx_queue_portid,
2917 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2918 : : (void *)&cmd_config_rxtx_queue_qid,
2919 : : (void *)&cmd_config_rxtx_queue_opname,
2920 : : NULL,
2921 : : },
2922 : : };
2923 : :
2924 : : /* *** configure port rxq/txq deferred start on/off *** */
2925 : : struct cmd_config_deferred_start_rxtx_queue {
2926 : : cmdline_fixed_string_t port;
2927 : : portid_t port_id;
2928 : : cmdline_fixed_string_t rxtxq;
2929 : : uint16_t qid;
2930 : : cmdline_fixed_string_t opname;
2931 : : cmdline_fixed_string_t state;
2932 : : };
2933 : :
2934 : : static void
2935 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2936 : : __rte_unused struct cmdline *cl,
2937 : : __rte_unused void *data)
2938 : : {
2939 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2940 : : struct rte_port *port;
2941 : : uint8_t isrx;
2942 : : uint8_t ison;
2943 : : uint8_t needreconfig = 0;
2944 : :
2945 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2946 : : return;
2947 : :
2948 : 0 : if (port_is_started(res->port_id) != 0) {
2949 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2950 : 0 : return;
2951 : : }
2952 : :
2953 : 0 : port = &ports[res->port_id];
2954 : :
2955 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2956 : :
2957 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2958 : : return;
2959 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2960 : : return;
2961 : :
2962 : 0 : ison = !strcmp(res->state, "on");
2963 : :
2964 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2965 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2966 : : needreconfig = 1;
2967 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2968 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2969 : : needreconfig = 1;
2970 : : }
2971 : :
2972 : : if (needreconfig)
2973 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2974 : : }
2975 : :
2976 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2977 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2978 : : port, "port");
2979 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2980 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2981 : : port_id, RTE_UINT16);
2982 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2983 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2984 : : rxtxq, "rxq#txq");
2985 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2986 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2987 : : qid, RTE_UINT16);
2988 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2989 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2990 : : opname, "deferred_start");
2991 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2992 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2993 : : state, "on#off");
2994 : :
2995 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2996 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
2997 : : .data = NULL,
2998 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2999 : : .tokens = {
3000 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
3001 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
3002 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
3003 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
3004 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
3005 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
3006 : : NULL,
3007 : : },
3008 : : };
3009 : :
3010 : : /* *** configure port rxq/txq setup *** */
3011 : : struct cmd_setup_rxtx_queue {
3012 : : cmdline_fixed_string_t port;
3013 : : portid_t portid;
3014 : : cmdline_fixed_string_t rxtxq;
3015 : : uint16_t qid;
3016 : : cmdline_fixed_string_t setup;
3017 : : };
3018 : :
3019 : : /* Common CLI fields for queue setup */
3020 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
3021 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
3022 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
3023 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
3024 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
3025 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
3026 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
3027 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
3028 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
3029 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
3030 : :
3031 : : static void
3032 : 0 : cmd_setup_rxtx_queue_parsed(
3033 : : void *parsed_result,
3034 : : __rte_unused struct cmdline *cl,
3035 : : __rte_unused void *data)
3036 : : {
3037 : : struct cmd_setup_rxtx_queue *res = parsed_result;
3038 : : struct rte_port *port;
3039 : : struct rte_mempool *mp;
3040 : : unsigned int socket_id;
3041 : : uint8_t isrx = 0;
3042 : : int ret;
3043 : :
3044 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
3045 : : return;
3046 : :
3047 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
3048 : 0 : fprintf(stderr, "Invalid port id\n");
3049 : 0 : return;
3050 : : }
3051 : :
3052 : 0 : if (!strcmp(res->rxtxq, "rxq"))
3053 : : isrx = 1;
3054 : 0 : else if (!strcmp(res->rxtxq, "txq"))
3055 : : isrx = 0;
3056 : : else {
3057 : 0 : fprintf(stderr, "Unknown parameter\n");
3058 : 0 : return;
3059 : : }
3060 : :
3061 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
3062 : 0 : fprintf(stderr, "Invalid rx queue\n");
3063 : 0 : return;
3064 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
3065 : 0 : fprintf(stderr, "Invalid tx queue\n");
3066 : 0 : return;
3067 : : }
3068 : :
3069 : 0 : port = &ports[res->portid];
3070 : 0 : if (isrx) {
3071 : 0 : socket_id = rxring_numa[res->portid];
3072 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3073 : 0 : socket_id = port->socket_id;
3074 : :
3075 : : mp = mbuf_pool_find(socket_id, 0);
3076 : 0 : if (mp == NULL) {
3077 : 0 : fprintf(stderr,
3078 : : "Failed to setup RX queue: No mempool allocation on the socket %d\n",
3079 : 0 : rxring_numa[res->portid]);
3080 : 0 : return;
3081 : : }
3082 : 0 : ret = rx_queue_setup(res->portid,
3083 : : res->qid,
3084 : 0 : port->nb_rx_desc[res->qid],
3085 : : socket_id,
3086 : 0 : &port->rxq[res->qid].conf,
3087 : : mp);
3088 : 0 : if (ret)
3089 : 0 : fprintf(stderr, "Failed to setup RX queue\n");
3090 : : } else {
3091 : 0 : socket_id = txring_numa[res->portid];
3092 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3093 : 0 : socket_id = port->socket_id;
3094 : :
3095 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
3096 : 0 : fprintf(stderr,
3097 : : "Failed to setup TX queue: not enough descriptors\n");
3098 : 0 : return;
3099 : : }
3100 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
3101 : : res->qid,
3102 : : port->nb_tx_desc[res->qid],
3103 : : socket_id,
3104 : 0 : &port->txq[res->qid].conf);
3105 : 0 : if (ret)
3106 : 0 : fprintf(stderr, "Failed to setup TX queue\n");
3107 : : }
3108 : : }
3109 : :
3110 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
3111 : : .f = cmd_setup_rxtx_queue_parsed,
3112 : : .data = NULL,
3113 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
3114 : : .tokens = {
3115 : : (void *)&cmd_setup_rxtx_queue_port,
3116 : : (void *)&cmd_setup_rxtx_queue_portid,
3117 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
3118 : : (void *)&cmd_setup_rxtx_queue_qid,
3119 : : (void *)&cmd_setup_rxtx_queue_setup,
3120 : : NULL,
3121 : : },
3122 : : };
3123 : :
3124 : :
3125 : : /* *** Configure RSS RETA *** */
3126 : : struct cmd_config_rss_reta {
3127 : : cmdline_fixed_string_t port;
3128 : : cmdline_fixed_string_t keyword;
3129 : : portid_t port_id;
3130 : : cmdline_fixed_string_t name;
3131 : : cmdline_fixed_string_t list_name;
3132 : : cmdline_fixed_string_t list_of_items;
3133 : : };
3134 : :
3135 : : static int
3136 : 0 : parse_reta_config(const char *str,
3137 : : struct rte_eth_rss_reta_entry64 *reta_conf,
3138 : : uint16_t nb_entries)
3139 : : {
3140 : : int i;
3141 : : unsigned size;
3142 : : uint16_t hash_index, idx, shift;
3143 : : uint16_t nb_queue;
3144 : : char s[256];
3145 : : const char *p, *p0 = str;
3146 : : char *end;
3147 : : enum fieldnames {
3148 : : FLD_HASH_INDEX = 0,
3149 : : FLD_QUEUE,
3150 : : _NUM_FLD
3151 : : };
3152 : : unsigned long int_fld[_NUM_FLD];
3153 : : char *str_fld[_NUM_FLD];
3154 : :
3155 : 0 : while ((p = strchr(p0,'(')) != NULL) {
3156 : 0 : ++p;
3157 : 0 : if((p0 = strchr(p,')')) == NULL)
3158 : : return -1;
3159 : :
3160 : 0 : size = p0 - p;
3161 : 0 : if(size >= sizeof(s))
3162 : : return -1;
3163 : :
3164 : : snprintf(s, sizeof(s), "%.*s", size, p);
3165 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3166 : : return -1;
3167 : 0 : for (i = 0; i < _NUM_FLD; i++) {
3168 : 0 : errno = 0;
3169 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
3170 : 0 : if (errno != 0 || end == str_fld[i] ||
3171 : : int_fld[i] > 65535)
3172 : : return -1;
3173 : : }
3174 : :
3175 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3176 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3177 : :
3178 : 0 : if (hash_index >= nb_entries) {
3179 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
3180 : : hash_index);
3181 : 0 : return -1;
3182 : : }
3183 : :
3184 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3185 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3186 : 0 : reta_conf[idx].mask |= (1ULL << shift);
3187 : 0 : reta_conf[idx].reta[shift] = nb_queue;
3188 : : }
3189 : :
3190 : : return 0;
3191 : : }
3192 : :
3193 : : static void
3194 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
3195 : : __rte_unused struct cmdline *cl,
3196 : : __rte_unused void *data)
3197 : : {
3198 : : int ret;
3199 : : struct rte_eth_dev_info dev_info;
3200 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3201 : : struct cmd_config_rss_reta *res = parsed_result;
3202 : :
3203 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3204 : 0 : if (ret != 0)
3205 : 0 : return;
3206 : :
3207 : 0 : if (dev_info.reta_size == 0) {
3208 : 0 : fprintf(stderr,
3209 : : "Redirection table size is 0 which is invalid for RSS\n");
3210 : 0 : return;
3211 : : } else
3212 : 0 : printf("The reta size of port %d is %u\n",
3213 : 0 : res->port_id, dev_info.reta_size);
3214 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3215 : 0 : fprintf(stderr,
3216 : : "Currently do not support more than %u entries of redirection table\n",
3217 : : RTE_ETH_RSS_RETA_SIZE_512);
3218 : 0 : return;
3219 : : }
3220 : :
3221 : : memset(reta_conf, 0, sizeof(reta_conf));
3222 : 0 : if (!strcmp(res->list_name, "reta")) {
3223 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
3224 : : dev_info.reta_size)) {
3225 : 0 : fprintf(stderr,
3226 : : "Invalid RSS Redirection Table config entered\n");
3227 : 0 : return;
3228 : : }
3229 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
3230 : 0 : reta_conf, dev_info.reta_size);
3231 : 0 : if (ret != 0)
3232 : 0 : fprintf(stderr,
3233 : : "Bad redirection table parameter, return code = %d\n",
3234 : : ret);
3235 : : }
3236 : : }
3237 : :
3238 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3239 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3240 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3241 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3242 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3243 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3244 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3245 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3246 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3247 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3248 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3249 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3250 : : NULL);
3251 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
3252 : : .f = cmd_set_rss_reta_parsed,
3253 : : .data = NULL,
3254 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3255 : : .tokens = {
3256 : : (void *)&cmd_config_rss_reta_port,
3257 : : (void *)&cmd_config_rss_reta_keyword,
3258 : : (void *)&cmd_config_rss_reta_port_id,
3259 : : (void *)&cmd_config_rss_reta_name,
3260 : : (void *)&cmd_config_rss_reta_list_name,
3261 : : (void *)&cmd_config_rss_reta_list_of_items,
3262 : : NULL,
3263 : : },
3264 : : };
3265 : :
3266 : : /* *** SHOW PORT RETA INFO *** */
3267 : : struct cmd_showport_reta {
3268 : : cmdline_fixed_string_t show;
3269 : : cmdline_fixed_string_t port;
3270 : : portid_t port_id;
3271 : : cmdline_fixed_string_t rss;
3272 : : cmdline_fixed_string_t reta;
3273 : : uint16_t size;
3274 : : cmdline_fixed_string_t list_of_items;
3275 : : };
3276 : :
3277 : : static int
3278 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3279 : : uint16_t nb_entries,
3280 : : char *str)
3281 : : {
3282 : : uint32_t size;
3283 : : const char *p, *p0 = str;
3284 : : char s[256];
3285 : : char *end;
3286 : : char *str_fld[8];
3287 : : uint16_t i;
3288 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3289 : : RTE_ETH_RETA_GROUP_SIZE;
3290 : : int ret;
3291 : :
3292 : 0 : p = strchr(p0, '(');
3293 : 0 : if (p == NULL)
3294 : : return -1;
3295 : 0 : p++;
3296 : 0 : p0 = strchr(p, ')');
3297 : 0 : if (p0 == NULL)
3298 : : return -1;
3299 : 0 : size = p0 - p;
3300 : 0 : if (size >= sizeof(s)) {
3301 : 0 : fprintf(stderr,
3302 : : "The string size exceeds the internal buffer size\n");
3303 : 0 : return -1;
3304 : : }
3305 : : snprintf(s, sizeof(s), "%.*s", size, p);
3306 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3307 : 0 : if (ret <= 0 || ret != num) {
3308 : 0 : fprintf(stderr,
3309 : : "The bits of masks do not match the number of reta entries: %u\n",
3310 : : num);
3311 : 0 : return -1;
3312 : : }
3313 : 0 : for (i = 0; i < ret; i++)
3314 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3315 : :
3316 : : return 0;
3317 : : }
3318 : :
3319 : : static void
3320 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3321 : : __rte_unused struct cmdline *cl,
3322 : : __rte_unused void *data)
3323 : : {
3324 : : struct cmd_showport_reta *res = parsed_result;
3325 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3326 : : struct rte_eth_dev_info dev_info;
3327 : : uint16_t max_reta_size;
3328 : : int ret;
3329 : :
3330 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3331 : 0 : if (ret != 0)
3332 : 0 : return;
3333 : :
3334 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3335 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3336 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3337 : : res->size, max_reta_size);
3338 : 0 : return;
3339 : : }
3340 : :
3341 : : memset(reta_conf, 0, sizeof(reta_conf));
3342 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3343 : 0 : res->list_of_items) < 0) {
3344 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3345 : : res->list_of_items);
3346 : 0 : return;
3347 : : }
3348 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3349 : : }
3350 : :
3351 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3352 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3353 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3354 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3355 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3356 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3357 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3358 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3359 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3360 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3361 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3362 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3363 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3364 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3365 : : list_of_items, NULL);
3366 : :
3367 : : static cmdline_parse_inst_t cmd_showport_reta = {
3368 : : .f = cmd_showport_reta_parsed,
3369 : : .data = NULL,
3370 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3371 : : .tokens = {
3372 : : (void *)&cmd_showport_reta_show,
3373 : : (void *)&cmd_showport_reta_port,
3374 : : (void *)&cmd_showport_reta_port_id,
3375 : : (void *)&cmd_showport_reta_rss,
3376 : : (void *)&cmd_showport_reta_reta,
3377 : : (void *)&cmd_showport_reta_size,
3378 : : (void *)&cmd_showport_reta_list_of_items,
3379 : : NULL,
3380 : : },
3381 : : };
3382 : :
3383 : : /* *** Show RSS hash configuration *** */
3384 : : struct cmd_showport_rss_hash {
3385 : : cmdline_fixed_string_t show;
3386 : : cmdline_fixed_string_t port;
3387 : : portid_t port_id;
3388 : : cmdline_fixed_string_t rss_hash;
3389 : : cmdline_fixed_string_t rss_type;
3390 : : cmdline_fixed_string_t key; /* optional argument */
3391 : : cmdline_fixed_string_t algorithm; /* optional argument */
3392 : : };
3393 : :
3394 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3395 : : __rte_unused struct cmdline *cl,
3396 : : __rte_unused void *data)
3397 : : {
3398 : : struct cmd_showport_rss_hash *res = parsed_result;
3399 : :
3400 : 0 : port_rss_hash_conf_show(res->port_id,
3401 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3402 : 0 : }
3403 : :
3404 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3405 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3406 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3407 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3408 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3409 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3410 : : RTE_UINT16);
3411 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3412 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3413 : : "rss-hash");
3414 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3415 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3416 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3417 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3418 : :
3419 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3420 : : .f = cmd_showport_rss_hash_parsed,
3421 : : .data = NULL,
3422 : : .help_str = "show port <port_id> rss-hash",
3423 : : .tokens = {
3424 : : (void *)&cmd_showport_rss_hash_show,
3425 : : (void *)&cmd_showport_rss_hash_port,
3426 : : (void *)&cmd_showport_rss_hash_port_id,
3427 : : (void *)&cmd_showport_rss_hash_rss_hash,
3428 : : NULL,
3429 : : },
3430 : : };
3431 : :
3432 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3433 : : .f = cmd_showport_rss_hash_parsed,
3434 : : .data = NULL,
3435 : : .help_str = "show port <port_id> rss-hash key",
3436 : : .tokens = {
3437 : : (void *)&cmd_showport_rss_hash_show,
3438 : : (void *)&cmd_showport_rss_hash_port,
3439 : : (void *)&cmd_showport_rss_hash_port_id,
3440 : : (void *)&cmd_showport_rss_hash_rss_hash,
3441 : : (void *)&cmd_showport_rss_hash_rss_key,
3442 : : NULL,
3443 : : },
3444 : : };
3445 : :
3446 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3447 : : .f = cmd_showport_rss_hash_parsed,
3448 : : .data = NULL,
3449 : : .help_str = "show port <port_id> rss-hash algorithm",
3450 : : .tokens = {
3451 : : (void *)&cmd_showport_rss_hash_show,
3452 : : (void *)&cmd_showport_rss_hash_port,
3453 : : (void *)&cmd_showport_rss_hash_port_id,
3454 : : (void *)&cmd_showport_rss_hash_rss_hash,
3455 : : (void *)&cmd_showport_rss_hash_rss_algo,
3456 : : NULL,
3457 : : },
3458 : : };
3459 : :
3460 : : /* *** Configure DCB *** */
3461 : : struct cmd_config_dcb {
3462 : : cmdline_fixed_string_t port;
3463 : : cmdline_fixed_string_t config;
3464 : : portid_t port_id;
3465 : : cmdline_fixed_string_t dcb;
3466 : : cmdline_fixed_string_t vt;
3467 : : cmdline_fixed_string_t vt_en;
3468 : : uint8_t num_tcs;
3469 : : cmdline_fixed_string_t pfc;
3470 : : cmdline_multi_string_t token_str;
3471 : : };
3472 : :
3473 : : static int
3474 : 0 : parse_dcb_token_prio_tc(char *param_str[], int param_num,
3475 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3476 : : uint8_t *prio_tc_en)
3477 : : {
3478 : : unsigned long prio, tc;
3479 : : int prio_tc_maps = 0;
3480 : : char *param, *end;
3481 : : int i;
3482 : :
3483 : 0 : for (i = 0; i < param_num; i++) {
3484 : 0 : param = param_str[i];
3485 : 0 : prio = strtoul(param, &end, 10);
3486 : 0 : if (prio >= RTE_ETH_DCB_NUM_USER_PRIORITIES) {
3487 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO %lu\n", prio);
3488 : 0 : return -1;
3489 : : }
3490 : 0 : if ((*end != ':') || (strlen(end + 1) == 0)) {
3491 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3492 : 0 : return -1;
3493 : : }
3494 : 0 : tc = strtoul(end + 1, &end, 10);
3495 : 0 : if (tc >= RTE_ETH_8_TCS) {
3496 : 0 : fprintf(stderr, "Bad Argument: invalid TC %lu\n", tc);
3497 : 0 : return -1;
3498 : : }
3499 : 0 : if (*end != '\0') {
3500 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3501 : 0 : return -1;
3502 : : }
3503 : 0 : prio_tc[prio] = tc;
3504 : 0 : prio_tc_maps++;
3505 : : } while (0);
3506 : :
3507 : 0 : if (prio_tc_maps == 0) {
3508 : 0 : fprintf(stderr, "Bad Argument: no PRIO:TC provided\n");
3509 : 0 : return -1;
3510 : : }
3511 : 0 : *prio_tc_en = 1;
3512 : :
3513 : 0 : return 0;
3514 : : }
3515 : :
3516 : : #define DCB_TOKEN_PRIO_TC "prio-tc"
3517 : : #define DCB_TOKEN_KEEP_QNUM "keep-qnum"
3518 : :
3519 : : static int
3520 : 0 : parse_dcb_token_find(char *split_str[], int split_num, int *param_num)
3521 : : {
3522 : : int i;
3523 : :
3524 : 0 : if (strcmp(split_str[0], DCB_TOKEN_KEEP_QNUM) == 0) {
3525 : 0 : *param_num = 0;
3526 : 0 : return 0;
3527 : : }
3528 : :
3529 : 0 : if (strcmp(split_str[0], DCB_TOKEN_PRIO_TC) != 0) {
3530 : 0 : fprintf(stderr, "Bad Argument: unknown token %s\n", split_str[0]);
3531 : 0 : return -EINVAL;
3532 : : }
3533 : :
3534 : 0 : for (i = 1; i < split_num; i++) {
3535 : 0 : if ((strcmp(split_str[i], DCB_TOKEN_PRIO_TC) != 0) &&
3536 : 0 : (strcmp(split_str[i], DCB_TOKEN_KEEP_QNUM) != 0))
3537 : : continue;
3538 : : /* find another optional parameter, then exit. */
3539 : : break;
3540 : : }
3541 : :
3542 : 0 : *param_num = i - 1;
3543 : :
3544 : 0 : return 0;
3545 : : }
3546 : :
3547 : : static int
3548 : 0 : parse_dcb_token_value(char *token_str,
3549 : : uint8_t *pfc_en,
3550 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3551 : : uint8_t *prio_tc_en,
3552 : : uint8_t *keep_qnum)
3553 : : {
3554 : : #define MAX_TOKEN_NUM 128
3555 : : char *split_str[MAX_TOKEN_NUM];
3556 : : int param_num, start, ret;
3557 : : int split_num = 0;
3558 : : char *token;
3559 : :
3560 : : /* split multiple token to split str. */
3561 : : do {
3562 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
3563 : 0 : if (token == NULL)
3564 : : break;
3565 : 0 : if (split_num >= MAX_TOKEN_NUM) {
3566 : 0 : fprintf(stderr, "Bad Argument: too much argument\n");
3567 : 0 : return -1;
3568 : : }
3569 : 0 : split_str[split_num++] = token;
3570 : : } while (1);
3571 : :
3572 : : /* parse fixed parameter "pfc-en" first. */
3573 : 0 : token = split_str[0];
3574 : 0 : if (strcmp(token, "on") == 0)
3575 : 0 : *pfc_en = 1;
3576 : 0 : else if (strcmp(token, "off") == 0)
3577 : 0 : *pfc_en = 0;
3578 : : else {
3579 : 0 : fprintf(stderr, "Bad Argument: pfc-en must be on or off\n");
3580 : 0 : return -EINVAL;
3581 : : }
3582 : :
3583 : 0 : if (split_num == 1)
3584 : : return 0;
3585 : :
3586 : : /* start parse optional parameter. */
3587 : : start = 1;
3588 : : do {
3589 : 0 : param_num = 0;
3590 : 0 : ret = parse_dcb_token_find(&split_str[start], split_num - start, ¶m_num);
3591 : 0 : if (ret != 0)
3592 : 0 : return ret;
3593 : :
3594 : 0 : token = split_str[start];
3595 : 0 : if (strcmp(token, DCB_TOKEN_PRIO_TC) == 0) {
3596 : 0 : if (*prio_tc_en == 1) {
3597 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3598 : : DCB_TOKEN_PRIO_TC);
3599 : 0 : return -1;
3600 : : }
3601 : 0 : ret = parse_dcb_token_prio_tc(&split_str[start + 1], param_num, prio_tc,
3602 : : prio_tc_en);
3603 : 0 : if (ret != 0)
3604 : 0 : return ret;
3605 : : } else {
3606 : : /* this must be keep-qnum. */
3607 : 0 : if (*keep_qnum == 1) {
3608 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3609 : : DCB_TOKEN_KEEP_QNUM);
3610 : 0 : return -1;
3611 : : }
3612 : 0 : *keep_qnum = 1;
3613 : : }
3614 : :
3615 : 0 : start += param_num + 1;
3616 : 0 : if (start >= split_num)
3617 : : break;
3618 : : } while (1);
3619 : :
3620 : : return 0;
3621 : : }
3622 : :
3623 : : static void
3624 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3625 : : __rte_unused struct cmdline *cl,
3626 : : __rte_unused void *data)
3627 : : {
3628 : 0 : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES] = {0};
3629 : : struct cmd_config_dcb *res = parsed_result;
3630 : : struct rte_eth_dcb_info dcb_info;
3631 : 0 : portid_t port_id = res->port_id;
3632 : 0 : uint8_t prio_tc_en = 0;
3633 : 0 : uint8_t keep_qnum = 0;
3634 : : struct rte_port *port;
3635 : 0 : uint8_t pfc_en = 0;
3636 : : int ret;
3637 : :
3638 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
3639 : 0 : return;
3640 : :
3641 : 0 : port = &ports[port_id];
3642 : : /** Check if the port is not started **/
3643 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3644 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3645 : 0 : return;
3646 : : }
3647 : :
3648 : 0 : if (res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS) {
3649 : 0 : fprintf(stderr,
3650 : : "The invalid number of traffic class, only 1~8 allowed.\n");
3651 : 0 : return;
3652 : : }
3653 : :
3654 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3655 : 0 : fprintf(stderr,
3656 : : "nb_cores shouldn't be less than number of TCs.\n");
3657 : 0 : return;
3658 : : }
3659 : :
3660 : : /* Check whether the port supports the report of DCB info. */
3661 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3662 : 0 : if (ret == -ENOTSUP) {
3663 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3664 : 0 : return;
3665 : : }
3666 : :
3667 : 0 : ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en, &keep_qnum);
3668 : 0 : if (ret != 0)
3669 : : return;
3670 : :
3671 : : /* DCB in VT mode */
3672 : 0 : if (!strncmp(res->vt_en, "on", 2))
3673 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3674 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3675 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3676 : : else
3677 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3678 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3679 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3680 : 0 : if (ret != 0) {
3681 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3682 : 0 : return;
3683 : : }
3684 : :
3685 : 0 : fwd_config_setup();
3686 : :
3687 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3688 : : }
3689 : :
3690 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3691 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3692 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3693 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3694 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3695 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3696 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3697 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3698 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3699 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3700 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3701 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3702 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3703 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3704 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3705 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3706 : : static cmdline_parse_token_string_t cmd_config_dcb_token_str =
3707 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, token_str, TOKEN_STRING_MULTI);
3708 : :
3709 : : static cmdline_parse_inst_t cmd_config_dcb = {
3710 : : .f = cmd_config_dcb_parsed,
3711 : : .data = NULL,
3712 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP keep-qnum\n"
3713 : : "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
3714 : : " PRIO-MAPPING := PRIO:TC\n"
3715 : : " PRIO: { 0 .. 7 }\n"
3716 : : " TC: { 0 .. 7 }",
3717 : : .tokens = {
3718 : : (void *)&cmd_config_dcb_port,
3719 : : (void *)&cmd_config_dcb_config,
3720 : : (void *)&cmd_config_dcb_port_id,
3721 : : (void *)&cmd_config_dcb_dcb,
3722 : : (void *)&cmd_config_dcb_vt,
3723 : : (void *)&cmd_config_dcb_vt_en,
3724 : : (void *)&cmd_config_dcb_num_tcs,
3725 : : (void *)&cmd_config_dcb_pfc,
3726 : : (void *)&cmd_config_dcb_token_str,
3727 : : NULL,
3728 : : },
3729 : : };
3730 : :
3731 : : /* *** configure number of packets per burst *** */
3732 : : struct cmd_config_burst {
3733 : : cmdline_fixed_string_t port;
3734 : : cmdline_fixed_string_t keyword;
3735 : : cmdline_fixed_string_t all;
3736 : : cmdline_fixed_string_t name;
3737 : : uint16_t value;
3738 : : };
3739 : :
3740 : : static void
3741 : 0 : cmd_config_burst_parsed(void *parsed_result,
3742 : : __rte_unused struct cmdline *cl,
3743 : : __rte_unused void *data)
3744 : : {
3745 : : struct cmd_config_burst *res = parsed_result;
3746 : : struct rte_eth_dev_info dev_info;
3747 : : uint16_t rec_nb_pkts;
3748 : : int ret;
3749 : :
3750 : 0 : if (!all_ports_stopped()) {
3751 : 0 : fprintf(stderr, "Please stop all ports first\n");
3752 : 0 : return;
3753 : : }
3754 : :
3755 : 0 : if (!strcmp(res->name, "burst")) {
3756 : 0 : if (res->value == 0) {
3757 : : /* If user gives a value of zero, query the PMD for
3758 : : * its recommended Rx burst size. Testpmd uses a single
3759 : : * size for all ports, so assume all ports are the same
3760 : : * NIC model and use the values from Port 0.
3761 : : */
3762 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3763 : 0 : if (ret != 0)
3764 : : return;
3765 : :
3766 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3767 : :
3768 : 0 : if (rec_nb_pkts == 0) {
3769 : : printf("PMD does not recommend a burst size.\n"
3770 : : "User provided value must be between"
3771 : : " 1 and %d\n", MAX_PKT_BURST);
3772 : 0 : return;
3773 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3774 : 0 : printf("PMD recommended burst size of %d"
3775 : : " exceeds maximum value of %d\n",
3776 : : rec_nb_pkts, MAX_PKT_BURST);
3777 : 0 : return;
3778 : : }
3779 : 0 : printf("Using PMD-provided burst value of %d\n",
3780 : : rec_nb_pkts);
3781 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3782 : 0 : } else if (res->value > MAX_PKT_BURST) {
3783 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3784 : : MAX_PKT_BURST);
3785 : 0 : return;
3786 : : } else
3787 : 0 : nb_pkt_per_burst = res->value;
3788 : : } else {
3789 : 0 : fprintf(stderr, "Unknown parameter\n");
3790 : 0 : return;
3791 : : }
3792 : :
3793 : 0 : init_port_config();
3794 : :
3795 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3796 : : }
3797 : :
3798 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3799 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3800 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3801 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3802 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3803 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3804 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3805 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3806 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3807 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3808 : :
3809 : : static cmdline_parse_inst_t cmd_config_burst = {
3810 : : .f = cmd_config_burst_parsed,
3811 : : .data = NULL,
3812 : : .help_str = "port config all burst <value>",
3813 : : .tokens = {
3814 : : (void *)&cmd_config_burst_port,
3815 : : (void *)&cmd_config_burst_keyword,
3816 : : (void *)&cmd_config_burst_all,
3817 : : (void *)&cmd_config_burst_name,
3818 : : (void *)&cmd_config_burst_value,
3819 : : NULL,
3820 : : },
3821 : : };
3822 : :
3823 : : /* *** configure rx/tx queues *** */
3824 : : struct cmd_config_thresh {
3825 : : cmdline_fixed_string_t port;
3826 : : cmdline_fixed_string_t keyword;
3827 : : cmdline_fixed_string_t all;
3828 : : cmdline_fixed_string_t name;
3829 : : uint8_t value;
3830 : : };
3831 : :
3832 : : static void
3833 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3834 : : __rte_unused struct cmdline *cl,
3835 : : __rte_unused void *data)
3836 : : {
3837 : : struct cmd_config_thresh *res = parsed_result;
3838 : :
3839 : 0 : if (!all_ports_stopped()) {
3840 : 0 : fprintf(stderr, "Please stop all ports first\n");
3841 : 0 : return;
3842 : : }
3843 : :
3844 : 0 : if (!strcmp(res->name, "txpt"))
3845 : 0 : tx_pthresh = res->value;
3846 : 0 : else if(!strcmp(res->name, "txht"))
3847 : 0 : tx_hthresh = res->value;
3848 : 0 : else if(!strcmp(res->name, "txwt"))
3849 : 0 : tx_wthresh = res->value;
3850 : 0 : else if(!strcmp(res->name, "rxpt"))
3851 : 0 : rx_pthresh = res->value;
3852 : 0 : else if(!strcmp(res->name, "rxht"))
3853 : 0 : rx_hthresh = res->value;
3854 : 0 : else if(!strcmp(res->name, "rxwt"))
3855 : 0 : rx_wthresh = res->value;
3856 : : else {
3857 : 0 : fprintf(stderr, "Unknown parameter\n");
3858 : 0 : return;
3859 : : }
3860 : :
3861 : 0 : init_port_config();
3862 : :
3863 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3864 : : }
3865 : :
3866 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3867 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3868 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3869 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3870 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3871 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3872 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3873 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3874 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3875 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3876 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3877 : :
3878 : : static cmdline_parse_inst_t cmd_config_thresh = {
3879 : : .f = cmd_config_thresh_parsed,
3880 : : .data = NULL,
3881 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3882 : : .tokens = {
3883 : : (void *)&cmd_config_thresh_port,
3884 : : (void *)&cmd_config_thresh_keyword,
3885 : : (void *)&cmd_config_thresh_all,
3886 : : (void *)&cmd_config_thresh_name,
3887 : : (void *)&cmd_config_thresh_value,
3888 : : NULL,
3889 : : },
3890 : : };
3891 : :
3892 : : /* *** configure free/rs threshold *** */
3893 : : struct cmd_config_threshold {
3894 : : cmdline_fixed_string_t port;
3895 : : cmdline_fixed_string_t keyword;
3896 : : cmdline_fixed_string_t all;
3897 : : cmdline_fixed_string_t name;
3898 : : uint16_t value;
3899 : : };
3900 : :
3901 : : static void
3902 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3903 : : __rte_unused struct cmdline *cl,
3904 : : __rte_unused void *data)
3905 : : {
3906 : : struct cmd_config_threshold *res = parsed_result;
3907 : :
3908 : 0 : if (!all_ports_stopped()) {
3909 : 0 : fprintf(stderr, "Please stop all ports first\n");
3910 : 0 : return;
3911 : : }
3912 : :
3913 : 0 : if (!strcmp(res->name, "txfreet"))
3914 : 0 : tx_free_thresh = res->value;
3915 : 0 : else if (!strcmp(res->name, "txrst"))
3916 : 0 : tx_rs_thresh = res->value;
3917 : 0 : else if (!strcmp(res->name, "rxfreet"))
3918 : 0 : rx_free_thresh = res->value;
3919 : : else {
3920 : 0 : fprintf(stderr, "Unknown parameter\n");
3921 : 0 : return;
3922 : : }
3923 : :
3924 : 0 : init_port_config();
3925 : :
3926 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3927 : : }
3928 : :
3929 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3930 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3931 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3932 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3933 : : "config");
3934 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3935 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3936 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3937 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3938 : : "txfreet#txrst#rxfreet");
3939 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3940 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3941 : :
3942 : : static cmdline_parse_inst_t cmd_config_threshold = {
3943 : : .f = cmd_config_threshold_parsed,
3944 : : .data = NULL,
3945 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3946 : : .tokens = {
3947 : : (void *)&cmd_config_threshold_port,
3948 : : (void *)&cmd_config_threshold_keyword,
3949 : : (void *)&cmd_config_threshold_all,
3950 : : (void *)&cmd_config_threshold_name,
3951 : : (void *)&cmd_config_threshold_value,
3952 : : NULL,
3953 : : },
3954 : : };
3955 : :
3956 : : /* *** stop *** */
3957 : : struct cmd_stop_result {
3958 : : cmdline_fixed_string_t stop;
3959 : : };
3960 : :
3961 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3962 : : __rte_unused struct cmdline *cl,
3963 : : __rte_unused void *data)
3964 : : {
3965 : 0 : stop_packet_forwarding();
3966 : 0 : }
3967 : :
3968 : : static cmdline_parse_token_string_t cmd_stop_stop =
3969 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3970 : :
3971 : : static cmdline_parse_inst_t cmd_stop = {
3972 : : .f = cmd_stop_parsed,
3973 : : .data = NULL,
3974 : : .help_str = "stop: Stop packet forwarding",
3975 : : .tokens = {
3976 : : (void *)&cmd_stop_stop,
3977 : : NULL,
3978 : : },
3979 : : };
3980 : :
3981 : : static unsigned int
3982 : 0 : get_ptype(char *value)
3983 : : {
3984 : : uint32_t protocol;
3985 : :
3986 : 0 : if (!strcmp(value, "eth"))
3987 : : protocol = RTE_PTYPE_L2_ETHER;
3988 : 0 : else if (!strcmp(value, "ipv4"))
3989 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3990 : 0 : else if (!strcmp(value, "ipv6"))
3991 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3992 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3993 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3994 : 0 : else if (!strcmp(value, "ipv4-udp"))
3995 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3996 : 0 : else if (!strcmp(value, "ipv4-sctp"))
3997 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3998 : 0 : else if (!strcmp(value, "ipv6-tcp"))
3999 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
4000 : 0 : else if (!strcmp(value, "ipv6-udp"))
4001 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
4002 : 0 : else if (!strcmp(value, "ipv6-sctp"))
4003 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
4004 : 0 : else if (!strcmp(value, "grenat"))
4005 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
4006 : 0 : else if (!strcmp(value, "inner-eth"))
4007 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
4008 : 0 : else if (!strcmp(value, "inner-ipv4"))
4009 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4010 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
4011 : 0 : else if (!strcmp(value, "inner-ipv6"))
4012 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4013 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
4014 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
4015 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4016 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4017 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
4018 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4019 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4020 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
4021 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4022 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4023 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
4024 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4025 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4026 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
4027 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4028 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4029 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
4030 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4031 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4032 : : else {
4033 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
4034 : : protocol = RTE_PTYPE_UNKNOWN;
4035 : : }
4036 : :
4037 : 0 : return protocol;
4038 : : }
4039 : :
4040 : : /* *** SET RXHDRSLIST *** */
4041 : :
4042 : : unsigned int
4043 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
4044 : : unsigned int *parsed_items)
4045 : : {
4046 : : unsigned int nb_item;
4047 : : char *cur;
4048 : : char *tmp;
4049 : :
4050 : : nb_item = 0;
4051 : 0 : char *str2 = strdup(str);
4052 : 0 : if (str2 == NULL)
4053 : : return nb_item;
4054 : 0 : cur = strtok_r(str2, ",", &tmp);
4055 : 0 : while (cur != NULL) {
4056 : 0 : parsed_items[nb_item] = get_ptype(cur);
4057 : 0 : cur = strtok_r(NULL, ",", &tmp);
4058 : 0 : nb_item++;
4059 : : }
4060 : 0 : if (nb_item > max_items)
4061 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4062 : : item_name, nb_item + 1, max_items);
4063 : 0 : free(str2);
4064 : 0 : return nb_item;
4065 : : }
4066 : :
4067 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
4068 : :
4069 : : unsigned int
4070 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
4071 : : unsigned int *parsed_items, int check_unique_values)
4072 : : {
4073 : : unsigned int nb_item;
4074 : : unsigned int value;
4075 : : unsigned int i;
4076 : : unsigned int j;
4077 : : int value_ok;
4078 : : char c;
4079 : :
4080 : : /*
4081 : : * First parse all items in the list and store their value.
4082 : : */
4083 : : value = 0;
4084 : : nb_item = 0;
4085 : : value_ok = 0;
4086 : 0 : for (i = 0; i < strnlen(str, STR_MULTI_TOKEN_SIZE); i++) {
4087 : 0 : c = str[i];
4088 : 0 : if ((c >= '0') && (c <= '9')) {
4089 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
4090 : : value_ok = 1;
4091 : 0 : continue;
4092 : : }
4093 : 0 : if (c != ',') {
4094 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
4095 : 0 : return 0;
4096 : : }
4097 : 0 : if (! value_ok) {
4098 : 0 : fprintf(stderr, "No valid value before comma\n");
4099 : 0 : return 0;
4100 : : }
4101 : 0 : if (nb_item < max_items) {
4102 : 0 : parsed_items[nb_item] = value;
4103 : : value_ok = 0;
4104 : : value = 0;
4105 : : }
4106 : 0 : nb_item++;
4107 : : }
4108 : 0 : if (nb_item >= max_items) {
4109 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4110 : : item_name, nb_item + 1, max_items);
4111 : 0 : return 0;
4112 : : }
4113 : 0 : parsed_items[nb_item++] = value;
4114 : 0 : if (! check_unique_values)
4115 : : return nb_item;
4116 : :
4117 : : /*
4118 : : * Then, check that all values in the list are different.
4119 : : * No optimization here...
4120 : : */
4121 : 0 : for (i = 0; i < nb_item; i++) {
4122 : 0 : for (j = i + 1; j < nb_item; j++) {
4123 : 0 : if (parsed_items[j] == parsed_items[i]) {
4124 : 0 : fprintf(stderr,
4125 : : "duplicated %s %u at index %u and %u\n",
4126 : : item_name, parsed_items[i], i, j);
4127 : 0 : return 0;
4128 : : }
4129 : : }
4130 : : }
4131 : : return nb_item;
4132 : : }
4133 : :
4134 : : struct cmd_set_list_result {
4135 : : cmdline_fixed_string_t cmd_keyword;
4136 : : cmdline_fixed_string_t list_name;
4137 : : cmdline_multi_string_t list_of_items;
4138 : : };
4139 : :
4140 : 0 : static void cmd_set_list_parsed(void *parsed_result,
4141 : : __rte_unused struct cmdline *cl,
4142 : : __rte_unused void *data)
4143 : : {
4144 : : struct cmd_set_list_result *res;
4145 : : union {
4146 : : unsigned int lcorelist[RTE_MAX_LCORE];
4147 : : unsigned int portlist[RTE_MAX_ETHPORTS];
4148 : : } parsed_items;
4149 : : unsigned int nb_item;
4150 : :
4151 : 0 : if (test_done == 0) {
4152 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4153 : 0 : return;
4154 : : }
4155 : :
4156 : : res = parsed_result;
4157 : 0 : if (!strcmp(res->list_name, "corelist")) {
4158 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
4159 : : RTE_MAX_LCORE,
4160 : : parsed_items.lcorelist, 1);
4161 : 0 : if (nb_item > 0) {
4162 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
4163 : 0 : fwd_config_setup();
4164 : : }
4165 : 0 : return;
4166 : : }
4167 : 0 : if (!strcmp(res->list_name, "portlist")) {
4168 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
4169 : : RTE_MAX_ETHPORTS,
4170 : : parsed_items.portlist, 1);
4171 : 0 : if (nb_item > 0) {
4172 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
4173 : 0 : fwd_config_setup();
4174 : : }
4175 : : }
4176 : : }
4177 : :
4178 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
4179 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
4180 : : "set");
4181 : : static cmdline_parse_token_string_t cmd_set_list_name =
4182 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
4183 : : "corelist#portlist");
4184 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
4185 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
4186 : : TOKEN_STRING_MULTI);
4187 : :
4188 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
4189 : : .f = cmd_set_list_parsed,
4190 : : .data = NULL,
4191 : : .help_str = "set corelist|portlist <list0[,list1]*>",
4192 : : .tokens = {
4193 : : (void *)&cmd_set_list_keyword,
4194 : : (void *)&cmd_set_list_name,
4195 : : (void *)&cmd_set_list_of_items,
4196 : : NULL,
4197 : : },
4198 : : };
4199 : :
4200 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
4201 : :
4202 : : struct cmd_setmask_result {
4203 : : cmdline_fixed_string_t set;
4204 : : cmdline_fixed_string_t mask;
4205 : : uint64_t hexavalue;
4206 : : };
4207 : :
4208 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
4209 : : __rte_unused struct cmdline *cl,
4210 : : __rte_unused void *data)
4211 : : {
4212 : : struct cmd_setmask_result *res = parsed_result;
4213 : :
4214 : 0 : if (test_done == 0) {
4215 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4216 : 0 : return;
4217 : : }
4218 : 0 : if (!strcmp(res->mask, "coremask")) {
4219 : 0 : set_fwd_lcores_mask(res->hexavalue);
4220 : 0 : fwd_config_setup();
4221 : 0 : } else if (!strcmp(res->mask, "portmask")) {
4222 : 0 : set_fwd_ports_mask(res->hexavalue);
4223 : 0 : fwd_config_setup();
4224 : : }
4225 : : }
4226 : :
4227 : : static cmdline_parse_token_string_t cmd_setmask_set =
4228 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
4229 : : static cmdline_parse_token_string_t cmd_setmask_mask =
4230 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
4231 : : "coremask#portmask");
4232 : : static cmdline_parse_token_num_t cmd_setmask_value =
4233 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
4234 : :
4235 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
4236 : : .f = cmd_set_mask_parsed,
4237 : : .data = NULL,
4238 : : .help_str = "set coremask|portmask <hexadecimal value>",
4239 : : .tokens = {
4240 : : (void *)&cmd_setmask_set,
4241 : : (void *)&cmd_setmask_mask,
4242 : : (void *)&cmd_setmask_value,
4243 : : NULL,
4244 : : },
4245 : : };
4246 : :
4247 : : /*
4248 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
4249 : : */
4250 : : struct cmd_set_result {
4251 : : cmdline_fixed_string_t set;
4252 : : cmdline_fixed_string_t what;
4253 : : uint16_t value;
4254 : : };
4255 : :
4256 : 0 : static void cmd_set_parsed(void *parsed_result,
4257 : : __rte_unused struct cmdline *cl,
4258 : : __rte_unused void *data)
4259 : : {
4260 : : struct cmd_set_result *res = parsed_result;
4261 : 0 : if (!strcmp(res->what, "nbport")) {
4262 : 0 : set_fwd_ports_number(res->value);
4263 : 0 : fwd_config_setup();
4264 : 0 : } else if (!strcmp(res->what, "nbcore")) {
4265 : 0 : set_fwd_lcores_number(res->value);
4266 : 0 : fwd_config_setup();
4267 : 0 : } else if (!strcmp(res->what, "burst"))
4268 : 0 : set_nb_pkt_per_burst(res->value);
4269 : 0 : else if (!strcmp(res->what, "verbose"))
4270 : 0 : set_verbose_level(res->value);
4271 : 0 : }
4272 : :
4273 : : static cmdline_parse_token_string_t cmd_set_set =
4274 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
4275 : : static cmdline_parse_token_string_t cmd_set_what =
4276 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
4277 : : "nbport#nbcore#burst#verbose");
4278 : : static cmdline_parse_token_num_t cmd_set_value =
4279 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
4280 : :
4281 : : static cmdline_parse_inst_t cmd_set_numbers = {
4282 : : .f = cmd_set_parsed,
4283 : : .data = NULL,
4284 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
4285 : : .tokens = {
4286 : : (void *)&cmd_set_set,
4287 : : (void *)&cmd_set_what,
4288 : : (void *)&cmd_set_value,
4289 : : NULL,
4290 : : },
4291 : : };
4292 : :
4293 : : /* *** SET LOG LEVEL CONFIGURATION *** */
4294 : :
4295 : : struct cmd_set_log_result {
4296 : : cmdline_fixed_string_t set;
4297 : : cmdline_fixed_string_t log;
4298 : : cmdline_fixed_string_t type;
4299 : : uint32_t level;
4300 : : };
4301 : :
4302 : : static void
4303 : 0 : cmd_set_log_parsed(void *parsed_result,
4304 : : __rte_unused struct cmdline *cl,
4305 : : __rte_unused void *data)
4306 : : {
4307 : : struct cmd_set_log_result *res;
4308 : : int ret;
4309 : :
4310 : : res = parsed_result;
4311 : 0 : if (!strcmp(res->type, "global"))
4312 : 0 : rte_log_set_global_level(res->level);
4313 : : else {
4314 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
4315 : 0 : if (ret < 0)
4316 : 0 : fprintf(stderr, "Unable to set log level\n");
4317 : : }
4318 : 0 : }
4319 : :
4320 : : static cmdline_parse_token_string_t cmd_set_log_set =
4321 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
4322 : : static cmdline_parse_token_string_t cmd_set_log_log =
4323 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
4324 : : static cmdline_parse_token_string_t cmd_set_log_type =
4325 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
4326 : : static cmdline_parse_token_num_t cmd_set_log_level =
4327 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
4328 : :
4329 : : static cmdline_parse_inst_t cmd_set_log = {
4330 : : .f = cmd_set_log_parsed,
4331 : : .data = NULL,
4332 : : .help_str = "set log global|<type> <level>",
4333 : : .tokens = {
4334 : : (void *)&cmd_set_log_set,
4335 : : (void *)&cmd_set_log_log,
4336 : : (void *)&cmd_set_log_type,
4337 : : (void *)&cmd_set_log_level,
4338 : : NULL,
4339 : : },
4340 : : };
4341 : :
4342 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
4343 : :
4344 : : struct cmd_set_rxoffs_result {
4345 : : cmdline_fixed_string_t cmd_keyword;
4346 : : cmdline_fixed_string_t rxoffs;
4347 : : cmdline_fixed_string_t seg_offsets;
4348 : : };
4349 : :
4350 : : static void
4351 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
4352 : : __rte_unused struct cmdline *cl,
4353 : : __rte_unused void *data)
4354 : : {
4355 : : struct cmd_set_rxoffs_result *res;
4356 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
4357 : : unsigned int nb_segs;
4358 : :
4359 : : res = parsed_result;
4360 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
4361 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
4362 : 0 : if (nb_segs > 0)
4363 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
4364 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4365 : 0 : }
4366 : :
4367 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
4368 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4369 : : cmd_keyword, "set");
4370 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
4371 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4372 : : rxoffs, "rxoffs");
4373 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
4374 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4375 : : seg_offsets, NULL);
4376 : :
4377 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
4378 : : .f = cmd_set_rxoffs_parsed,
4379 : : .data = NULL,
4380 : : .help_str = "set rxoffs <len0[,len1]*>",
4381 : : .tokens = {
4382 : : (void *)&cmd_set_rxoffs_keyword,
4383 : : (void *)&cmd_set_rxoffs_name,
4384 : : (void *)&cmd_set_rxoffs_offsets,
4385 : : NULL,
4386 : : },
4387 : : };
4388 : :
4389 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
4390 : :
4391 : : struct cmd_set_rxpkts_result {
4392 : : cmdline_fixed_string_t cmd_keyword;
4393 : : cmdline_fixed_string_t rxpkts;
4394 : : cmdline_fixed_string_t seg_lengths;
4395 : : };
4396 : :
4397 : : static void
4398 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
4399 : : __rte_unused struct cmdline *cl,
4400 : : __rte_unused void *data)
4401 : : {
4402 : : struct cmd_set_rxpkts_result *res;
4403 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
4404 : : unsigned int nb_segs;
4405 : :
4406 : : res = parsed_result;
4407 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4408 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
4409 : 0 : if (nb_segs > 0)
4410 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
4411 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4412 : 0 : }
4413 : :
4414 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
4415 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4416 : : cmd_keyword, "set");
4417 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
4418 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4419 : : rxpkts, "rxpkts");
4420 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4421 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4422 : : seg_lengths, NULL);
4423 : :
4424 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
4425 : : .f = cmd_set_rxpkts_parsed,
4426 : : .data = NULL,
4427 : : .help_str = "set rxpkts <len0[,len1]*>",
4428 : : .tokens = {
4429 : : (void *)&cmd_set_rxpkts_keyword,
4430 : : (void *)&cmd_set_rxpkts_name,
4431 : : (void *)&cmd_set_rxpkts_lengths,
4432 : : NULL,
4433 : : },
4434 : : };
4435 : :
4436 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4437 : : struct cmd_set_rxhdrs_result {
4438 : : cmdline_fixed_string_t set;
4439 : : cmdline_fixed_string_t rxhdrs;
4440 : : cmdline_fixed_string_t values;
4441 : : };
4442 : :
4443 : : static void
4444 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4445 : : __rte_unused struct cmdline *cl,
4446 : : __rte_unused void *data)
4447 : : {
4448 : : struct cmd_set_rxhdrs_result *res;
4449 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4450 : : unsigned int nb_segs;
4451 : :
4452 : : res = parsed_result;
4453 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4454 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4455 : 0 : if (nb_segs > 0)
4456 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4457 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4458 : 0 : }
4459 : :
4460 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4461 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4462 : : set, "set");
4463 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4464 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4465 : : rxhdrs, "rxhdrs");
4466 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4467 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4468 : : values, NULL);
4469 : :
4470 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4471 : : .f = cmd_set_rxhdrs_parsed,
4472 : : .data = NULL,
4473 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4474 : : .tokens = {
4475 : : (void *)&cmd_set_rxhdrs_set,
4476 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4477 : : (void *)&cmd_set_rxhdrs_values,
4478 : : NULL,
4479 : : },
4480 : : };
4481 : :
4482 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4483 : :
4484 : : struct cmd_set_txpkts_result {
4485 : : cmdline_fixed_string_t cmd_keyword;
4486 : : cmdline_fixed_string_t txpkts;
4487 : : cmdline_fixed_string_t seg_lengths;
4488 : : };
4489 : :
4490 : : static void
4491 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4492 : : __rte_unused struct cmdline *cl,
4493 : : __rte_unused void *data)
4494 : : {
4495 : : struct cmd_set_txpkts_result *res;
4496 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4497 : : unsigned int nb_segs;
4498 : :
4499 : : res = parsed_result;
4500 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4501 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4502 : 0 : if (nb_segs > 0)
4503 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4504 : 0 : }
4505 : :
4506 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4507 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4508 : : cmd_keyword, "set");
4509 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4510 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4511 : : txpkts, "txpkts");
4512 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4513 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4514 : : seg_lengths, NULL);
4515 : :
4516 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4517 : : .f = cmd_set_txpkts_parsed,
4518 : : .data = NULL,
4519 : : .help_str = "set txpkts <len0[,len1]*>",
4520 : : .tokens = {
4521 : : (void *)&cmd_set_txpkts_keyword,
4522 : : (void *)&cmd_set_txpkts_name,
4523 : : (void *)&cmd_set_txpkts_lengths,
4524 : : NULL,
4525 : : },
4526 : : };
4527 : :
4528 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4529 : :
4530 : : struct cmd_set_txsplit_result {
4531 : : cmdline_fixed_string_t cmd_keyword;
4532 : : cmdline_fixed_string_t txsplit;
4533 : : cmdline_fixed_string_t mode;
4534 : : };
4535 : :
4536 : : static void
4537 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4538 : : __rte_unused struct cmdline *cl,
4539 : : __rte_unused void *data)
4540 : : {
4541 : : struct cmd_set_txsplit_result *res;
4542 : :
4543 : : res = parsed_result;
4544 : 0 : set_tx_pkt_split(res->mode);
4545 : 0 : }
4546 : :
4547 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4548 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4549 : : cmd_keyword, "set");
4550 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4551 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4552 : : txsplit, "txsplit");
4553 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4554 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4555 : : mode, NULL);
4556 : :
4557 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4558 : : .f = cmd_set_txsplit_parsed,
4559 : : .data = NULL,
4560 : : .help_str = "set txsplit on|off|rand",
4561 : : .tokens = {
4562 : : (void *)&cmd_set_txsplit_keyword,
4563 : : (void *)&cmd_set_txsplit_name,
4564 : : (void *)&cmd_set_txsplit_mode,
4565 : : NULL,
4566 : : },
4567 : : };
4568 : :
4569 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4570 : :
4571 : : struct cmd_set_txtimes_result {
4572 : : cmdline_fixed_string_t cmd_keyword;
4573 : : cmdline_fixed_string_t txtimes;
4574 : : cmdline_fixed_string_t tx_times;
4575 : : };
4576 : :
4577 : : static void
4578 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4579 : : __rte_unused struct cmdline *cl,
4580 : : __rte_unused void *data)
4581 : : {
4582 : : struct cmd_set_txtimes_result *res;
4583 : 0 : unsigned int tx_times[2] = {0, 0};
4584 : : unsigned int n_times;
4585 : :
4586 : : res = parsed_result;
4587 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4588 : : 2, tx_times, 0);
4589 : 0 : if (n_times == 2)
4590 : 0 : set_tx_pkt_times(tx_times);
4591 : 0 : }
4592 : :
4593 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4594 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4595 : : cmd_keyword, "set");
4596 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4597 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4598 : : txtimes, "txtimes");
4599 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4600 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4601 : : tx_times, NULL);
4602 : :
4603 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4604 : : .f = cmd_set_txtimes_parsed,
4605 : : .data = NULL,
4606 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4607 : : .tokens = {
4608 : : (void *)&cmd_set_txtimes_keyword,
4609 : : (void *)&cmd_set_txtimes_name,
4610 : : (void *)&cmd_set_txtimes_value,
4611 : : NULL,
4612 : : },
4613 : : };
4614 : :
4615 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4616 : : struct cmd_rx_vlan_filter_all_result {
4617 : : cmdline_fixed_string_t rx_vlan;
4618 : : cmdline_fixed_string_t what;
4619 : : cmdline_fixed_string_t all;
4620 : : portid_t port_id;
4621 : : };
4622 : :
4623 : : static void
4624 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4625 : : __rte_unused struct cmdline *cl,
4626 : : __rte_unused void *data)
4627 : : {
4628 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4629 : :
4630 : 0 : if (!strcmp(res->what, "add"))
4631 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4632 : : else
4633 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4634 : 0 : }
4635 : :
4636 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4637 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4638 : : rx_vlan, "rx_vlan");
4639 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4640 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4641 : : what, "add#rm");
4642 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4643 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4644 : : all, "all");
4645 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4646 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4647 : : port_id, RTE_UINT16);
4648 : :
4649 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4650 : : .f = cmd_rx_vlan_filter_all_parsed,
4651 : : .data = NULL,
4652 : : .help_str = "rx_vlan add|rm all <port_id>: "
4653 : : "Add/Remove all identifiers to/from the set of VLAN "
4654 : : "identifiers filtered by a port",
4655 : : .tokens = {
4656 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4657 : : (void *)&cmd_rx_vlan_filter_all_what,
4658 : : (void *)&cmd_rx_vlan_filter_all_all,
4659 : : (void *)&cmd_rx_vlan_filter_all_portid,
4660 : : NULL,
4661 : : },
4662 : : };
4663 : :
4664 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4665 : : struct cmd_vlan_offload_result {
4666 : : cmdline_fixed_string_t vlan;
4667 : : cmdline_fixed_string_t set;
4668 : : cmdline_fixed_string_t vlan_type;
4669 : : cmdline_fixed_string_t what;
4670 : : cmdline_fixed_string_t on;
4671 : : cmdline_fixed_string_t port_id;
4672 : : };
4673 : :
4674 : : static void
4675 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4676 : : __rte_unused struct cmdline *cl,
4677 : : __rte_unused void *data)
4678 : : {
4679 : : int on;
4680 : : struct cmd_vlan_offload_result *res = parsed_result;
4681 : : char *str;
4682 : : int i, len = 0;
4683 : : portid_t port_id = 0;
4684 : : unsigned int tmp;
4685 : :
4686 : 0 : str = res->port_id;
4687 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4688 : : i = 0;
4689 : : /* Get port_id first */
4690 : 0 : while(i < len){
4691 : 0 : if(str[i] == ',')
4692 : : break;
4693 : :
4694 : 0 : i++;
4695 : : }
4696 : 0 : str[i]='\0';
4697 : 0 : tmp = strtoul(str, NULL, 0);
4698 : : /* If port_id greater that what portid_t can represent, return */
4699 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4700 : : return;
4701 : 0 : port_id = (portid_t)tmp;
4702 : :
4703 : 0 : if (!strcmp(res->on, "on"))
4704 : : on = 1;
4705 : : else
4706 : : on = 0;
4707 : :
4708 : 0 : if (!strcmp(res->what, "strip"))
4709 : 0 : rx_vlan_strip_set(port_id, on);
4710 : 0 : else if(!strcmp(res->what, "stripq")){
4711 : : uint16_t queue_id = 0;
4712 : :
4713 : : /* No queue_id, return */
4714 : 0 : if(i + 1 >= len) {
4715 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4716 : 0 : return;
4717 : : }
4718 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4719 : : /* If queue_id greater that what 16-bits can represent, return */
4720 : 0 : if(tmp > 0xffff)
4721 : : return;
4722 : :
4723 : 0 : queue_id = (uint16_t)tmp;
4724 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4725 : : }
4726 : 0 : else if (!strcmp(res->what, "filter"))
4727 : 0 : rx_vlan_filter_set(port_id, on);
4728 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4729 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4730 : : else
4731 : 0 : vlan_extend_set(port_id, on);
4732 : :
4733 : : return;
4734 : : }
4735 : :
4736 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4737 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4738 : : vlan, "vlan");
4739 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4740 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4741 : : set, "set");
4742 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4743 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4744 : : what, "strip#filter#qinq_strip#extend#stripq");
4745 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4746 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4747 : : on, "on#off");
4748 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4749 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4750 : : port_id, NULL);
4751 : :
4752 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4753 : : .f = cmd_vlan_offload_parsed,
4754 : : .data = NULL,
4755 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4756 : : "<port_id[,queue_id]>: "
4757 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4758 : : .tokens = {
4759 : : (void *)&cmd_vlan_offload_vlan,
4760 : : (void *)&cmd_vlan_offload_set,
4761 : : (void *)&cmd_vlan_offload_what,
4762 : : (void *)&cmd_vlan_offload_on,
4763 : : (void *)&cmd_vlan_offload_portid,
4764 : : NULL,
4765 : : },
4766 : : };
4767 : :
4768 : : /* *** VLAN TPID SET ON A PORT *** */
4769 : : struct cmd_vlan_tpid_result {
4770 : : cmdline_fixed_string_t vlan;
4771 : : cmdline_fixed_string_t set;
4772 : : cmdline_fixed_string_t vlan_type;
4773 : : cmdline_fixed_string_t what;
4774 : : uint16_t tp_id;
4775 : : portid_t port_id;
4776 : : };
4777 : :
4778 : : static void
4779 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4780 : : __rte_unused struct cmdline *cl,
4781 : : __rte_unused void *data)
4782 : : {
4783 : : struct cmd_vlan_tpid_result *res = parsed_result;
4784 : : enum rte_vlan_type vlan_type;
4785 : :
4786 : 0 : if (!strcmp(res->vlan_type, "inner"))
4787 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4788 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4789 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4790 : : else {
4791 : 0 : fprintf(stderr, "Unknown vlan type\n");
4792 : 0 : return;
4793 : : }
4794 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4795 : : }
4796 : :
4797 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4798 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4799 : : vlan, "vlan");
4800 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4801 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4802 : : set, "set");
4803 : : static cmdline_parse_token_string_t cmd_vlan_type =
4804 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4805 : : vlan_type, "inner#outer");
4806 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4807 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4808 : : what, "tpid");
4809 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4810 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4811 : : tp_id, RTE_UINT16);
4812 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4813 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4814 : : port_id, RTE_UINT16);
4815 : :
4816 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4817 : : .f = cmd_vlan_tpid_parsed,
4818 : : .data = NULL,
4819 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4820 : : "Set the VLAN Ether type",
4821 : : .tokens = {
4822 : : (void *)&cmd_vlan_tpid_vlan,
4823 : : (void *)&cmd_vlan_tpid_set,
4824 : : (void *)&cmd_vlan_type,
4825 : : (void *)&cmd_vlan_tpid_what,
4826 : : (void *)&cmd_vlan_tpid_tpid,
4827 : : (void *)&cmd_vlan_tpid_portid,
4828 : : NULL,
4829 : : },
4830 : : };
4831 : :
4832 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4833 : : struct cmd_rx_vlan_filter_result {
4834 : : cmdline_fixed_string_t rx_vlan;
4835 : : cmdline_fixed_string_t what;
4836 : : uint16_t vlan_id;
4837 : : portid_t port_id;
4838 : : };
4839 : :
4840 : : static void
4841 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4842 : : __rte_unused struct cmdline *cl,
4843 : : __rte_unused void *data)
4844 : : {
4845 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4846 : :
4847 : 0 : if (!strcmp(res->what, "add"))
4848 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4849 : : else
4850 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4851 : 0 : }
4852 : :
4853 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4854 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4855 : : rx_vlan, "rx_vlan");
4856 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4857 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4858 : : what, "add#rm");
4859 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4860 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4861 : : vlan_id, RTE_UINT16);
4862 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4863 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4864 : : port_id, RTE_UINT16);
4865 : :
4866 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4867 : : .f = cmd_rx_vlan_filter_parsed,
4868 : : .data = NULL,
4869 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4870 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4871 : : "identifiers filtered by a port",
4872 : : .tokens = {
4873 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4874 : : (void *)&cmd_rx_vlan_filter_what,
4875 : : (void *)&cmd_rx_vlan_filter_vlanid,
4876 : : (void *)&cmd_rx_vlan_filter_portid,
4877 : : NULL,
4878 : : },
4879 : : };
4880 : :
4881 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4882 : : struct cmd_tx_vlan_set_result {
4883 : : cmdline_fixed_string_t tx_vlan;
4884 : : cmdline_fixed_string_t set;
4885 : : portid_t port_id;
4886 : : uint16_t vlan_id;
4887 : : };
4888 : :
4889 : : static void
4890 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4891 : : __rte_unused struct cmdline *cl,
4892 : : __rte_unused void *data)
4893 : : {
4894 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4895 : :
4896 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4897 : : return;
4898 : :
4899 : 0 : if (!port_is_stopped(res->port_id)) {
4900 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4901 : 0 : return;
4902 : : }
4903 : :
4904 : 0 : tx_vlan_set(res->port_id, res->vlan_id);
4905 : :
4906 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4907 : : }
4908 : :
4909 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4910 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4911 : : tx_vlan, "tx_vlan");
4912 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4913 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4914 : : set, "set");
4915 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4916 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4917 : : port_id, RTE_UINT16);
4918 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4919 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4920 : : vlan_id, RTE_UINT16);
4921 : :
4922 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4923 : : .f = cmd_tx_vlan_set_parsed,
4924 : : .data = NULL,
4925 : : .help_str = "tx_vlan set <port_id> <vlan_id>: "
4926 : : "Enable hardware insertion of a single VLAN header "
4927 : : "with a given TAG Identifier in packets sent on a port",
4928 : : .tokens = {
4929 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4930 : : (void *)&cmd_tx_vlan_set_set,
4931 : : (void *)&cmd_tx_vlan_set_portid,
4932 : : (void *)&cmd_tx_vlan_set_vlanid,
4933 : : NULL,
4934 : : },
4935 : : };
4936 : :
4937 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4938 : : struct cmd_tx_vlan_set_qinq_result {
4939 : : cmdline_fixed_string_t tx_vlan;
4940 : : cmdline_fixed_string_t set;
4941 : : portid_t port_id;
4942 : : uint16_t vlan_id;
4943 : : uint16_t vlan_id_outer;
4944 : : };
4945 : :
4946 : : static void
4947 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4948 : : __rte_unused struct cmdline *cl,
4949 : : __rte_unused void *data)
4950 : : {
4951 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4952 : :
4953 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4954 : : return;
4955 : :
4956 : 0 : if (!port_is_stopped(res->port_id)) {
4957 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4958 : 0 : return;
4959 : : }
4960 : :
4961 : 0 : tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4962 : :
4963 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4964 : : }
4965 : :
4966 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4967 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4968 : : tx_vlan, "tx_vlan");
4969 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4970 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4971 : : set, "set");
4972 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4973 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4974 : : port_id, RTE_UINT16);
4975 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4976 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4977 : : vlan_id, RTE_UINT16);
4978 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4979 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4980 : : vlan_id_outer, RTE_UINT16);
4981 : :
4982 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4983 : : .f = cmd_tx_vlan_set_qinq_parsed,
4984 : : .data = NULL,
4985 : : .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4986 : : "Enable hardware insertion of double VLAN header "
4987 : : "with given TAG Identifiers in packets sent on a port",
4988 : : .tokens = {
4989 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4990 : : (void *)&cmd_tx_vlan_set_qinq_set,
4991 : : (void *)&cmd_tx_vlan_set_qinq_portid,
4992 : : (void *)&cmd_tx_vlan_set_qinq_vlanid,
4993 : : (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4994 : : NULL,
4995 : : },
4996 : : };
4997 : :
4998 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4999 : : struct cmd_tx_vlan_set_pvid_result {
5000 : : cmdline_fixed_string_t tx_vlan;
5001 : : cmdline_fixed_string_t set;
5002 : : cmdline_fixed_string_t pvid;
5003 : : portid_t port_id;
5004 : : uint16_t vlan_id;
5005 : : cmdline_fixed_string_t mode;
5006 : : };
5007 : :
5008 : : static void
5009 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
5010 : : __rte_unused struct cmdline *cl,
5011 : : __rte_unused void *data)
5012 : : {
5013 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
5014 : :
5015 : 0 : if (strcmp(res->mode, "on") == 0)
5016 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
5017 : : else
5018 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
5019 : 0 : }
5020 : :
5021 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
5022 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5023 : : tx_vlan, "tx_vlan");
5024 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
5025 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5026 : : set, "set");
5027 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
5028 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5029 : : pvid, "pvid");
5030 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
5031 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5032 : : port_id, RTE_UINT16);
5033 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
5034 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5035 : : vlan_id, RTE_UINT16);
5036 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
5037 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5038 : : mode, "on#off");
5039 : :
5040 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
5041 : : .f = cmd_tx_vlan_set_pvid_parsed,
5042 : : .data = NULL,
5043 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
5044 : : .tokens = {
5045 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
5046 : : (void *)&cmd_tx_vlan_set_pvid_set,
5047 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
5048 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
5049 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
5050 : : (void *)&cmd_tx_vlan_set_pvid_mode,
5051 : : NULL,
5052 : : },
5053 : : };
5054 : :
5055 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
5056 : : struct cmd_tx_vlan_reset_result {
5057 : : cmdline_fixed_string_t tx_vlan;
5058 : : cmdline_fixed_string_t reset;
5059 : : portid_t port_id;
5060 : : };
5061 : :
5062 : : static void
5063 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
5064 : : __rte_unused struct cmdline *cl,
5065 : : __rte_unused void *data)
5066 : : {
5067 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
5068 : :
5069 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5070 : : return;
5071 : :
5072 : 0 : if (!port_is_stopped(res->port_id)) {
5073 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5074 : 0 : return;
5075 : : }
5076 : :
5077 : 0 : tx_vlan_reset(res->port_id);
5078 : :
5079 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5080 : : }
5081 : :
5082 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
5083 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5084 : : tx_vlan, "tx_vlan");
5085 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
5086 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5087 : : reset, "reset");
5088 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
5089 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
5090 : : port_id, RTE_UINT16);
5091 : :
5092 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
5093 : : .f = cmd_tx_vlan_reset_parsed,
5094 : : .data = NULL,
5095 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
5096 : : "VLAN header in packets sent on a port",
5097 : : .tokens = {
5098 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
5099 : : (void *)&cmd_tx_vlan_reset_reset,
5100 : : (void *)&cmd_tx_vlan_reset_portid,
5101 : : NULL,
5102 : : },
5103 : : };
5104 : :
5105 : :
5106 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
5107 : : struct cmd_csum_result {
5108 : : cmdline_fixed_string_t csum;
5109 : : cmdline_fixed_string_t mode;
5110 : : cmdline_fixed_string_t proto;
5111 : : cmdline_fixed_string_t hwsw;
5112 : : portid_t port_id;
5113 : : };
5114 : :
5115 : : static void
5116 : 0 : csum_show(int port_id)
5117 : : {
5118 : : struct rte_eth_dev_info dev_info;
5119 : : uint64_t tx_offloads;
5120 : : int ret;
5121 : :
5122 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
5123 : 0 : printf("Parse tunnel is %s\n",
5124 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
5125 : 0 : printf("IP checksum offload is %s\n",
5126 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
5127 : 0 : printf("UDP checksum offload is %s\n",
5128 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
5129 : 0 : printf("TCP checksum offload is %s\n",
5130 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
5131 : 0 : printf("SCTP checksum offload is %s\n",
5132 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
5133 : 0 : printf("Outer-Ip checksum offload is %s\n",
5134 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
5135 : 0 : printf("Outer-Udp checksum offload is %s\n",
5136 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
5137 : :
5138 : : /* display warnings if configuration is not supported by the NIC */
5139 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
5140 : 0 : if (ret != 0)
5141 : 0 : return;
5142 : :
5143 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
5144 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
5145 : 0 : fprintf(stderr,
5146 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
5147 : : port_id);
5148 : : }
5149 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
5150 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
5151 : 0 : fprintf(stderr,
5152 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
5153 : : port_id);
5154 : : }
5155 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
5156 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
5157 : 0 : fprintf(stderr,
5158 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
5159 : : port_id);
5160 : : }
5161 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
5162 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
5163 : 0 : fprintf(stderr,
5164 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
5165 : : port_id);
5166 : : }
5167 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
5168 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
5169 : 0 : fprintf(stderr,
5170 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
5171 : : port_id);
5172 : : }
5173 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
5174 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
5175 : : == 0) {
5176 : 0 : fprintf(stderr,
5177 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
5178 : : port_id);
5179 : : }
5180 : : }
5181 : :
5182 : : static void
5183 : : cmd_config_queue_tx_offloads(struct rte_port *port)
5184 : : {
5185 : : int k;
5186 : :
5187 : : /* Apply queue tx offloads configuration */
5188 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
5189 : 0 : port->txq[k].conf.offloads =
5190 : 0 : port->dev_conf.txmode.offloads;
5191 : : }
5192 : :
5193 : : static void
5194 : 0 : cmd_csum_parsed(void *parsed_result,
5195 : : __rte_unused struct cmdline *cl,
5196 : : __rte_unused void *data)
5197 : : {
5198 : : struct cmd_csum_result *res = parsed_result;
5199 : : int hw = 0;
5200 : : uint64_t csum_offloads = 0;
5201 : : struct rte_eth_dev_info dev_info;
5202 : : int ret;
5203 : :
5204 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
5205 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
5206 : 0 : return;
5207 : : }
5208 : 0 : if (!port_is_stopped(res->port_id)) {
5209 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5210 : 0 : return;
5211 : : }
5212 : :
5213 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5214 : 0 : if (ret != 0)
5215 : : return;
5216 : :
5217 : 0 : if (!strcmp(res->mode, "set")) {
5218 : :
5219 : 0 : if (!strcmp(res->hwsw, "hw"))
5220 : : hw = 1;
5221 : :
5222 : 0 : if (!strcmp(res->proto, "ip")) {
5223 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5224 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
5225 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
5226 : : } else {
5227 : 0 : fprintf(stderr,
5228 : : "IP checksum offload is not supported by port %u\n",
5229 : 0 : res->port_id);
5230 : : }
5231 : 0 : } else if (!strcmp(res->proto, "udp")) {
5232 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5233 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
5234 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
5235 : : } else {
5236 : 0 : fprintf(stderr,
5237 : : "UDP checksum offload is not supported by port %u\n",
5238 : 0 : res->port_id);
5239 : : }
5240 : 0 : } else if (!strcmp(res->proto, "tcp")) {
5241 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5242 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
5243 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
5244 : : } else {
5245 : 0 : fprintf(stderr,
5246 : : "TCP checksum offload is not supported by port %u\n",
5247 : 0 : res->port_id);
5248 : : }
5249 : 0 : } else if (!strcmp(res->proto, "sctp")) {
5250 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5251 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
5252 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
5253 : : } else {
5254 : 0 : fprintf(stderr,
5255 : : "SCTP checksum offload is not supported by port %u\n",
5256 : 0 : res->port_id);
5257 : : }
5258 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
5259 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5260 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5261 : : csum_offloads |=
5262 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
5263 : : } else {
5264 : 0 : fprintf(stderr,
5265 : : "Outer IP checksum offload is not supported by port %u\n",
5266 : 0 : res->port_id);
5267 : : }
5268 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
5269 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5270 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
5271 : : csum_offloads |=
5272 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
5273 : : } else {
5274 : 0 : fprintf(stderr,
5275 : : "Outer UDP checksum offload is not supported by port %u\n",
5276 : 0 : res->port_id);
5277 : : }
5278 : : }
5279 : :
5280 : 0 : if (hw) {
5281 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5282 : : csum_offloads;
5283 : : } else {
5284 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5285 : 0 : (~csum_offloads);
5286 : : }
5287 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5288 : : }
5289 : 0 : csum_show(res->port_id);
5290 : :
5291 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5292 : : }
5293 : :
5294 : : static cmdline_parse_token_string_t cmd_csum_csum =
5295 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5296 : : csum, "csum");
5297 : : static cmdline_parse_token_string_t cmd_csum_mode =
5298 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5299 : : mode, "set");
5300 : : static cmdline_parse_token_string_t cmd_csum_proto =
5301 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5302 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
5303 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
5304 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5305 : : hwsw, "hw#sw");
5306 : : static cmdline_parse_token_num_t cmd_csum_portid =
5307 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
5308 : : port_id, RTE_UINT16);
5309 : :
5310 : : static cmdline_parse_inst_t cmd_csum_set = {
5311 : : .f = cmd_csum_parsed,
5312 : : .data = NULL,
5313 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
5314 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
5315 : : "using csum forward engine",
5316 : : .tokens = {
5317 : : (void *)&cmd_csum_csum,
5318 : : (void *)&cmd_csum_mode,
5319 : : (void *)&cmd_csum_proto,
5320 : : (void *)&cmd_csum_hwsw,
5321 : : (void *)&cmd_csum_portid,
5322 : : NULL,
5323 : : },
5324 : : };
5325 : :
5326 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
5327 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5328 : : mode, "show");
5329 : :
5330 : : static cmdline_parse_inst_t cmd_csum_show = {
5331 : : .f = cmd_csum_parsed,
5332 : : .data = NULL,
5333 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
5334 : : .tokens = {
5335 : : (void *)&cmd_csum_csum,
5336 : : (void *)&cmd_csum_mode_show,
5337 : : (void *)&cmd_csum_portid,
5338 : : NULL,
5339 : : },
5340 : : };
5341 : :
5342 : : /* Enable/disable tunnel parsing */
5343 : : struct cmd_csum_tunnel_result {
5344 : : cmdline_fixed_string_t csum;
5345 : : cmdline_fixed_string_t parse;
5346 : : cmdline_fixed_string_t onoff;
5347 : : portid_t port_id;
5348 : : };
5349 : :
5350 : : static void
5351 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
5352 : : __rte_unused struct cmdline *cl,
5353 : : __rte_unused void *data)
5354 : : {
5355 : : struct cmd_csum_tunnel_result *res = parsed_result;
5356 : :
5357 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5358 : : return;
5359 : :
5360 : 0 : if (!strcmp(res->onoff, "on"))
5361 : 0 : ports[res->port_id].parse_tunnel = 1;
5362 : : else
5363 : 0 : ports[res->port_id].parse_tunnel = 0;
5364 : :
5365 : 0 : csum_show(res->port_id);
5366 : : }
5367 : :
5368 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
5369 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5370 : : csum, "csum");
5371 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
5372 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5373 : : parse, "parse-tunnel");
5374 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
5375 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5376 : : onoff, "on#off");
5377 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
5378 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
5379 : : port_id, RTE_UINT16);
5380 : :
5381 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
5382 : : .f = cmd_csum_tunnel_parsed,
5383 : : .data = NULL,
5384 : : .help_str = "csum parse-tunnel on|off <port_id>: "
5385 : : "Enable/Disable parsing of tunnels for csum engine",
5386 : : .tokens = {
5387 : : (void *)&cmd_csum_tunnel_csum,
5388 : : (void *)&cmd_csum_tunnel_parse,
5389 : : (void *)&cmd_csum_tunnel_onoff,
5390 : : (void *)&cmd_csum_tunnel_portid,
5391 : : NULL,
5392 : : },
5393 : : };
5394 : :
5395 : : struct cmd_csum_mac_swap_result {
5396 : : cmdline_fixed_string_t csum;
5397 : : cmdline_fixed_string_t parse;
5398 : : cmdline_fixed_string_t onoff;
5399 : : portid_t port_id;
5400 : : };
5401 : :
5402 : : static void
5403 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
5404 : : __rte_unused struct cmdline *cl,
5405 : : __rte_unused void *data)
5406 : : {
5407 : : struct cmd_csum_mac_swap_result *res = parsed_result;
5408 : :
5409 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5410 : : return;
5411 : 0 : if (strcmp(res->onoff, "on") == 0)
5412 : 0 : ports[res->port_id].fwd_mac_swap = 1;
5413 : : else
5414 : 0 : ports[res->port_id].fwd_mac_swap = 0;
5415 : : }
5416 : :
5417 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
5418 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5419 : : csum, "csum");
5420 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
5421 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5422 : : parse, "mac-swap");
5423 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
5424 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5425 : : onoff, "on#off");
5426 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
5427 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
5428 : : port_id, RTE_UINT16);
5429 : :
5430 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
5431 : : .f = cmd_csum_mac_swap_parsed,
5432 : : .data = NULL,
5433 : : .help_str = "csum mac-swap on|off <port_id>: "
5434 : : "Enable/Disable forward mac address swap",
5435 : : .tokens = {
5436 : : (void *)&cmd_csum_mac_swap_csum,
5437 : : (void *)&cmd_csum_mac_swap_parse,
5438 : : (void *)&cmd_csum_mac_swap_onoff,
5439 : : (void *)&cmd_csum_mac_swap_portid,
5440 : : NULL,
5441 : : },
5442 : : };
5443 : :
5444 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5445 : : struct cmd_tso_set_result {
5446 : : cmdline_fixed_string_t tso;
5447 : : cmdline_fixed_string_t mode;
5448 : : uint16_t tso_segsz;
5449 : : portid_t port_id;
5450 : : };
5451 : :
5452 : : static void
5453 : 0 : cmd_tso_set_parsed(void *parsed_result,
5454 : : __rte_unused struct cmdline *cl,
5455 : : __rte_unused void *data)
5456 : : {
5457 : : struct cmd_tso_set_result *res = parsed_result;
5458 : : struct rte_eth_dev_info dev_info;
5459 : : uint64_t offloads;
5460 : : int ret;
5461 : :
5462 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5463 : 0 : return;
5464 : 0 : if (!port_is_stopped(res->port_id)) {
5465 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5466 : 0 : return;
5467 : : }
5468 : :
5469 : 0 : if (!strcmp(res->mode, "set"))
5470 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5471 : :
5472 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5473 : 0 : if (ret != 0)
5474 : : return;
5475 : :
5476 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5477 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5478 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5479 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5480 : : res->port_id);
5481 : 0 : return;
5482 : : }
5483 : : /* display warnings if configuration is not supported by the NIC */
5484 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5485 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5486 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5487 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5488 : : }
5489 : :
5490 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5491 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5492 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5493 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5494 : : } else {
5495 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5496 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5497 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5498 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5499 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5500 : 0 : printf("segment size for non-tunneled packets is %d\n",
5501 : : ports[res->port_id].tso_segsz);
5502 : : }
5503 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5504 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5505 : : }
5506 : :
5507 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5508 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5509 : : tso, "tso");
5510 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5511 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5512 : : mode, "set");
5513 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5514 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5515 : : tso_segsz, RTE_UINT16);
5516 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5517 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5518 : : port_id, RTE_UINT16);
5519 : :
5520 : : static cmdline_parse_inst_t cmd_tso_set = {
5521 : : .f = cmd_tso_set_parsed,
5522 : : .data = NULL,
5523 : : .help_str = "tso set <tso_segsz> <port_id>: "
5524 : : "Set TSO segment size of non-tunneled packets for csum engine "
5525 : : "(0 to disable)",
5526 : : .tokens = {
5527 : : (void *)&cmd_tso_set_tso,
5528 : : (void *)&cmd_tso_set_mode,
5529 : : (void *)&cmd_tso_set_tso_segsz,
5530 : : (void *)&cmd_tso_set_portid,
5531 : : NULL,
5532 : : },
5533 : : };
5534 : :
5535 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5536 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5537 : : mode, "show");
5538 : :
5539 : :
5540 : : static cmdline_parse_inst_t cmd_tso_show = {
5541 : : .f = cmd_tso_set_parsed,
5542 : : .data = NULL,
5543 : : .help_str = "tso show <port_id>: "
5544 : : "Show TSO segment size of non-tunneled packets for csum engine",
5545 : : .tokens = {
5546 : : (void *)&cmd_tso_set_tso,
5547 : : (void *)&cmd_tso_show_mode,
5548 : : (void *)&cmd_tso_set_portid,
5549 : : NULL,
5550 : : },
5551 : : };
5552 : :
5553 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5554 : : struct cmd_tunnel_tso_set_result {
5555 : : cmdline_fixed_string_t tso;
5556 : : cmdline_fixed_string_t mode;
5557 : : uint16_t tso_segsz;
5558 : : portid_t port_id;
5559 : : };
5560 : :
5561 : : static void
5562 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5563 : : {
5564 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5565 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5566 : : port_id);
5567 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5568 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5569 : : port_id);
5570 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5571 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5572 : : port_id);
5573 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5574 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5575 : : port_id);
5576 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5577 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5578 : : port_id);
5579 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5580 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5581 : : port_id);
5582 : 0 : }
5583 : :
5584 : : static void
5585 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5586 : : __rte_unused struct cmdline *cl,
5587 : : __rte_unused void *data)
5588 : : {
5589 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5590 : : struct rte_eth_dev_info dev_info;
5591 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5592 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5593 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5594 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5595 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5596 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5597 : : int ret;
5598 : :
5599 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5600 : 0 : return;
5601 : 0 : if (!port_is_stopped(res->port_id)) {
5602 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5603 : 0 : return;
5604 : : }
5605 : :
5606 : 0 : if (!strcmp(res->mode, "set"))
5607 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5608 : :
5609 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5610 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5611 : : printf("TSO for tunneled packets is disabled\n");
5612 : : } else {
5613 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5614 : 0 : if (ret != 0)
5615 : : return;
5616 : :
5617 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5618 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5619 : 0 : res->port_id);
5620 : 0 : return;
5621 : : }
5622 : :
5623 : : /* Below conditions are needed to make it work:
5624 : : * (1) tunnel TSO is supported by the NIC;
5625 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5626 : : * are recognized;
5627 : : * (3) for tunneled pkts with outer L3 of IPv4,
5628 : : * "csum set outer-ip" must be set to hw, because after tso,
5629 : : * total_len of outer IP header is changed, and the checksum
5630 : : * of outer IP header calculated by sw should be wrong; that
5631 : : * is not necessary for IPv6 tunneled pkts because there's no
5632 : : * checksum in IP header anymore.
5633 : : */
5634 : 0 : if (!ports[res->port_id].parse_tunnel) {
5635 : 0 : fprintf(stderr,
5636 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5637 : 0 : return;
5638 : : }
5639 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5640 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5641 : 0 : fprintf(stderr,
5642 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5643 : 0 : return;
5644 : : }
5645 : :
5646 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5647 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5648 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5649 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5650 : 0 : ports[res->port_id].tunnel_tso_segsz);
5651 : : }
5652 : :
5653 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5654 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5655 : : }
5656 : :
5657 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5658 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5659 : : tso, "tunnel_tso");
5660 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5661 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5662 : : mode, "set");
5663 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5664 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5665 : : tso_segsz, RTE_UINT16);
5666 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5667 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5668 : : port_id, RTE_UINT16);
5669 : :
5670 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5671 : : .f = cmd_tunnel_tso_set_parsed,
5672 : : .data = NULL,
5673 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5674 : : "Set TSO segment size of tunneled packets for csum engine "
5675 : : "(0 to disable)",
5676 : : .tokens = {
5677 : : (void *)&cmd_tunnel_tso_set_tso,
5678 : : (void *)&cmd_tunnel_tso_set_mode,
5679 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5680 : : (void *)&cmd_tunnel_tso_set_portid,
5681 : : NULL,
5682 : : },
5683 : : };
5684 : :
5685 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5686 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5687 : : mode, "show");
5688 : :
5689 : :
5690 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5691 : : .f = cmd_tunnel_tso_set_parsed,
5692 : : .data = NULL,
5693 : : .help_str = "tunnel_tso show <port_id> "
5694 : : "Show TSO segment size of tunneled packets for csum engine",
5695 : : .tokens = {
5696 : : (void *)&cmd_tunnel_tso_set_tso,
5697 : : (void *)&cmd_tunnel_tso_show_mode,
5698 : : (void *)&cmd_tunnel_tso_set_portid,
5699 : : NULL,
5700 : : },
5701 : : };
5702 : :
5703 : : #ifdef RTE_LIB_GRO
5704 : : /* *** SET GRO FOR A PORT *** */
5705 : : struct cmd_gro_enable_result {
5706 : : cmdline_fixed_string_t cmd_set;
5707 : : cmdline_fixed_string_t cmd_port;
5708 : : cmdline_fixed_string_t cmd_keyword;
5709 : : cmdline_fixed_string_t cmd_onoff;
5710 : : portid_t cmd_pid;
5711 : : };
5712 : :
5713 : : static void
5714 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5715 : : __rte_unused struct cmdline *cl,
5716 : : __rte_unused void *data)
5717 : : {
5718 : : struct cmd_gro_enable_result *res;
5719 : :
5720 : : res = parsed_result;
5721 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5722 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5723 : 0 : }
5724 : :
5725 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5726 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5727 : : cmd_set, "set");
5728 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5729 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5730 : : cmd_keyword, "port");
5731 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5732 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5733 : : cmd_pid, RTE_UINT16);
5734 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5735 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5736 : : cmd_keyword, "gro");
5737 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5738 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5739 : : cmd_onoff, "on#off");
5740 : :
5741 : : static cmdline_parse_inst_t cmd_gro_enable = {
5742 : : .f = cmd_gro_enable_parsed,
5743 : : .data = NULL,
5744 : : .help_str = "set port <port_id> gro on|off",
5745 : : .tokens = {
5746 : : (void *)&cmd_gro_enable_set,
5747 : : (void *)&cmd_gro_enable_port,
5748 : : (void *)&cmd_gro_enable_pid,
5749 : : (void *)&cmd_gro_enable_keyword,
5750 : : (void *)&cmd_gro_enable_onoff,
5751 : : NULL,
5752 : : },
5753 : : };
5754 : :
5755 : : /* *** DISPLAY GRO CONFIGURATION *** */
5756 : : struct cmd_gro_show_result {
5757 : : cmdline_fixed_string_t cmd_show;
5758 : : cmdline_fixed_string_t cmd_port;
5759 : : cmdline_fixed_string_t cmd_keyword;
5760 : : portid_t cmd_pid;
5761 : : };
5762 : :
5763 : : static void
5764 : 0 : cmd_gro_show_parsed(void *parsed_result,
5765 : : __rte_unused struct cmdline *cl,
5766 : : __rte_unused void *data)
5767 : : {
5768 : : struct cmd_gro_show_result *res;
5769 : :
5770 : : res = parsed_result;
5771 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5772 : 0 : show_gro(res->cmd_pid);
5773 : 0 : }
5774 : :
5775 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5776 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5777 : : cmd_show, "show");
5778 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5779 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5780 : : cmd_port, "port");
5781 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5782 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5783 : : cmd_pid, RTE_UINT16);
5784 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5785 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5786 : : cmd_keyword, "gro");
5787 : :
5788 : : static cmdline_parse_inst_t cmd_gro_show = {
5789 : : .f = cmd_gro_show_parsed,
5790 : : .data = NULL,
5791 : : .help_str = "show port <port_id> gro",
5792 : : .tokens = {
5793 : : (void *)&cmd_gro_show_show,
5794 : : (void *)&cmd_gro_show_port,
5795 : : (void *)&cmd_gro_show_pid,
5796 : : (void *)&cmd_gro_show_keyword,
5797 : : NULL,
5798 : : },
5799 : : };
5800 : :
5801 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5802 : : struct cmd_gro_flush_result {
5803 : : cmdline_fixed_string_t cmd_set;
5804 : : cmdline_fixed_string_t cmd_keyword;
5805 : : cmdline_fixed_string_t cmd_flush;
5806 : : uint8_t cmd_cycles;
5807 : : };
5808 : :
5809 : : static void
5810 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5811 : : __rte_unused struct cmdline *cl,
5812 : : __rte_unused void *data)
5813 : : {
5814 : : struct cmd_gro_flush_result *res;
5815 : :
5816 : : res = parsed_result;
5817 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5818 : 0 : (!strcmp(res->cmd_flush, "flush")))
5819 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5820 : 0 : }
5821 : :
5822 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5823 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5824 : : cmd_set, "set");
5825 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5826 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5827 : : cmd_keyword, "gro");
5828 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5829 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5830 : : cmd_flush, "flush");
5831 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5832 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5833 : : cmd_cycles, RTE_UINT8);
5834 : :
5835 : : static cmdline_parse_inst_t cmd_gro_flush = {
5836 : : .f = cmd_gro_flush_parsed,
5837 : : .data = NULL,
5838 : : .help_str = "set gro flush <cycles>",
5839 : : .tokens = {
5840 : : (void *)&cmd_gro_flush_set,
5841 : : (void *)&cmd_gro_flush_keyword,
5842 : : (void *)&cmd_gro_flush_flush,
5843 : : (void *)&cmd_gro_flush_cycles,
5844 : : NULL,
5845 : : },
5846 : : };
5847 : : #endif /* RTE_LIB_GRO */
5848 : :
5849 : : #ifdef RTE_LIB_GSO
5850 : : /* *** ENABLE/DISABLE GSO *** */
5851 : : struct cmd_gso_enable_result {
5852 : : cmdline_fixed_string_t cmd_set;
5853 : : cmdline_fixed_string_t cmd_port;
5854 : : cmdline_fixed_string_t cmd_keyword;
5855 : : cmdline_fixed_string_t cmd_mode;
5856 : : portid_t cmd_pid;
5857 : : };
5858 : :
5859 : : static void
5860 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5861 : : __rte_unused struct cmdline *cl,
5862 : : __rte_unused void *data)
5863 : : {
5864 : : struct cmd_gso_enable_result *res;
5865 : :
5866 : : res = parsed_result;
5867 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5868 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5869 : 0 : }
5870 : :
5871 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5872 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5873 : : cmd_set, "set");
5874 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5875 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5876 : : cmd_port, "port");
5877 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5878 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5879 : : cmd_keyword, "gso");
5880 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5881 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5882 : : cmd_mode, "on#off");
5883 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5884 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5885 : : cmd_pid, RTE_UINT16);
5886 : :
5887 : : static cmdline_parse_inst_t cmd_gso_enable = {
5888 : : .f = cmd_gso_enable_parsed,
5889 : : .data = NULL,
5890 : : .help_str = "set port <port_id> gso on|off",
5891 : : .tokens = {
5892 : : (void *)&cmd_gso_enable_set,
5893 : : (void *)&cmd_gso_enable_port,
5894 : : (void *)&cmd_gso_enable_pid,
5895 : : (void *)&cmd_gso_enable_keyword,
5896 : : (void *)&cmd_gso_enable_mode,
5897 : : NULL,
5898 : : },
5899 : : };
5900 : :
5901 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5902 : : struct cmd_gso_size_result {
5903 : : cmdline_fixed_string_t cmd_set;
5904 : : cmdline_fixed_string_t cmd_keyword;
5905 : : cmdline_fixed_string_t cmd_segsz;
5906 : : uint16_t cmd_size;
5907 : : };
5908 : :
5909 : : static void
5910 : 0 : cmd_gso_size_parsed(void *parsed_result,
5911 : : __rte_unused struct cmdline *cl,
5912 : : __rte_unused void *data)
5913 : : {
5914 : : struct cmd_gso_size_result *res = parsed_result;
5915 : :
5916 : 0 : if (test_done == 0) {
5917 : 0 : fprintf(stderr,
5918 : : "Before setting GSO segsz, please first stop forwarding\n");
5919 : 0 : return;
5920 : : }
5921 : :
5922 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5923 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5924 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5925 : 0 : fprintf(stderr,
5926 : : "gso_size should be larger than %zu. Please input a legal value\n",
5927 : : RTE_GSO_SEG_SIZE_MIN);
5928 : : else
5929 : 0 : gso_max_segment_size = res->cmd_size;
5930 : : }
5931 : : }
5932 : :
5933 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5934 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5935 : : cmd_set, "set");
5936 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5937 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5938 : : cmd_keyword, "gso");
5939 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5940 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5941 : : cmd_segsz, "segsz");
5942 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5943 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5944 : : cmd_size, RTE_UINT16);
5945 : :
5946 : : static cmdline_parse_inst_t cmd_gso_size = {
5947 : : .f = cmd_gso_size_parsed,
5948 : : .data = NULL,
5949 : : .help_str = "set gso segsz <length>",
5950 : : .tokens = {
5951 : : (void *)&cmd_gso_size_set,
5952 : : (void *)&cmd_gso_size_keyword,
5953 : : (void *)&cmd_gso_size_segsz,
5954 : : (void *)&cmd_gso_size_size,
5955 : : NULL,
5956 : : },
5957 : : };
5958 : :
5959 : : /* *** SHOW GSO CONFIGURATION *** */
5960 : : struct cmd_gso_show_result {
5961 : : cmdline_fixed_string_t cmd_show;
5962 : : cmdline_fixed_string_t cmd_port;
5963 : : cmdline_fixed_string_t cmd_keyword;
5964 : : portid_t cmd_pid;
5965 : : };
5966 : :
5967 : : static void
5968 : 0 : cmd_gso_show_parsed(void *parsed_result,
5969 : : __rte_unused struct cmdline *cl,
5970 : : __rte_unused void *data)
5971 : : {
5972 : : struct cmd_gso_show_result *res = parsed_result;
5973 : :
5974 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5975 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5976 : 0 : return;
5977 : : }
5978 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
5979 : 0 : if (gso_ports[res->cmd_pid].enable) {
5980 : 0 : printf("Max GSO'd packet size: %uB\n"
5981 : : "Supported GSO types: TCP/IPv4, "
5982 : : "UDP/IPv4, VxLAN with inner "
5983 : : "TCP/IPv4 packet, GRE with inner "
5984 : : "TCP/IPv4 packet\n",
5985 : : gso_max_segment_size);
5986 : : } else
5987 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5988 : : }
5989 : : }
5990 : :
5991 : : static cmdline_parse_token_string_t cmd_gso_show_show =
5992 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5993 : : cmd_show, "show");
5994 : : static cmdline_parse_token_string_t cmd_gso_show_port =
5995 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5996 : : cmd_port, "port");
5997 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
5998 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5999 : : cmd_keyword, "gso");
6000 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
6001 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
6002 : : cmd_pid, RTE_UINT16);
6003 : :
6004 : : static cmdline_parse_inst_t cmd_gso_show = {
6005 : : .f = cmd_gso_show_parsed,
6006 : : .data = NULL,
6007 : : .help_str = "show port <port_id> gso",
6008 : : .tokens = {
6009 : : (void *)&cmd_gso_show_show,
6010 : : (void *)&cmd_gso_show_port,
6011 : : (void *)&cmd_gso_show_pid,
6012 : : (void *)&cmd_gso_show_keyword,
6013 : : NULL,
6014 : : },
6015 : : };
6016 : : #endif /* RTE_LIB_GSO */
6017 : :
6018 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
6019 : : struct cmd_set_flush_rx {
6020 : : cmdline_fixed_string_t set;
6021 : : cmdline_fixed_string_t flush_rx;
6022 : : cmdline_fixed_string_t mode;
6023 : : };
6024 : :
6025 : : static void
6026 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
6027 : : __rte_unused struct cmdline *cl,
6028 : : __rte_unused void *data)
6029 : : {
6030 : : struct cmd_set_flush_rx *res = parsed_result;
6031 : :
6032 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
6033 : : printf("multi-process doesn't support to flush Rx queues.\n");
6034 : 0 : return;
6035 : : }
6036 : :
6037 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6038 : : }
6039 : :
6040 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
6041 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6042 : : set, "set");
6043 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
6044 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6045 : : flush_rx, "flush_rx");
6046 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
6047 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6048 : : mode, "on#off");
6049 : :
6050 : :
6051 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
6052 : : .f = cmd_set_flush_rx_parsed,
6053 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
6054 : : .data = NULL,
6055 : : .tokens = {
6056 : : (void *)&cmd_setflushrx_set,
6057 : : (void *)&cmd_setflushrx_flush_rx,
6058 : : (void *)&cmd_setflushrx_mode,
6059 : : NULL,
6060 : : },
6061 : : };
6062 : :
6063 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
6064 : : struct cmd_set_link_check {
6065 : : cmdline_fixed_string_t set;
6066 : : cmdline_fixed_string_t link_check;
6067 : : cmdline_fixed_string_t mode;
6068 : : };
6069 : :
6070 : : static void
6071 : 0 : cmd_set_link_check_parsed(void *parsed_result,
6072 : : __rte_unused struct cmdline *cl,
6073 : : __rte_unused void *data)
6074 : : {
6075 : : struct cmd_set_link_check *res = parsed_result;
6076 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6077 : 0 : }
6078 : :
6079 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
6080 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6081 : : set, "set");
6082 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
6083 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6084 : : link_check, "link_check");
6085 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
6086 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6087 : : mode, "on#off");
6088 : :
6089 : :
6090 : : static cmdline_parse_inst_t cmd_set_link_check = {
6091 : : .f = cmd_set_link_check_parsed,
6092 : : .help_str = "set link_check on|off: Enable/Disable link status check "
6093 : : "when starting/stopping a port",
6094 : : .data = NULL,
6095 : : .tokens = {
6096 : : (void *)&cmd_setlinkcheck_set,
6097 : : (void *)&cmd_setlinkcheck_link_check,
6098 : : (void *)&cmd_setlinkcheck_mode,
6099 : : NULL,
6100 : : },
6101 : : };
6102 : :
6103 : : /* *** SET FORWARDING MODE *** */
6104 : : struct cmd_set_fwd_mode_result {
6105 : : cmdline_fixed_string_t set;
6106 : : cmdline_fixed_string_t fwd;
6107 : : cmdline_fixed_string_t mode;
6108 : : };
6109 : :
6110 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
6111 : : __rte_unused struct cmdline *cl,
6112 : : __rte_unused void *data)
6113 : : {
6114 : : struct cmd_set_fwd_mode_result *res = parsed_result;
6115 : :
6116 : 0 : retry_enabled = 0;
6117 : 0 : set_pkt_forwarding_mode(res->mode);
6118 : 0 : }
6119 : :
6120 : : static cmdline_parse_token_string_t cmd_setfwd_set =
6121 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6122 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
6123 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6124 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
6125 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6126 : : "" /* defined at init */);
6127 : :
6128 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
6129 : : .f = cmd_set_fwd_mode_parsed,
6130 : : .data = NULL,
6131 : : .help_str = NULL, /* defined at init */
6132 : : .tokens = {
6133 : : (void *)&cmd_setfwd_set,
6134 : : (void *)&cmd_setfwd_fwd,
6135 : : (void *)&cmd_setfwd_mode,
6136 : : NULL,
6137 : : },
6138 : : };
6139 : :
6140 : 0 : static void cmd_set_fwd_mode_init(void)
6141 : : {
6142 : : char *modes, *c;
6143 : : static char token[128];
6144 : : static char help[256];
6145 : : cmdline_parse_token_string_t *token_struct;
6146 : :
6147 : 0 : modes = list_pkt_forwarding_modes();
6148 : : snprintf(help, sizeof(help), "set fwd %s: "
6149 : : "Set packet forwarding mode", modes);
6150 : 0 : cmd_set_fwd_mode.help_str = help;
6151 : :
6152 : : /* string token separator is # */
6153 : 0 : for (c = token; *modes != '\0'; modes++)
6154 : 0 : if (*modes == '|')
6155 : 0 : *c++ = '#';
6156 : : else
6157 : 0 : *c++ = *modes;
6158 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6159 : 0 : token_struct->string_data.str = token;
6160 : 0 : }
6161 : :
6162 : : /* *** SET RETRY FORWARDING MODE *** */
6163 : : struct cmd_set_fwd_retry_mode_result {
6164 : : cmdline_fixed_string_t set;
6165 : : cmdline_fixed_string_t fwd;
6166 : : cmdline_fixed_string_t mode;
6167 : : cmdline_fixed_string_t retry;
6168 : : };
6169 : :
6170 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6171 : : __rte_unused struct cmdline *cl,
6172 : : __rte_unused void *data)
6173 : : {
6174 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6175 : :
6176 : 0 : retry_enabled = 1;
6177 : 0 : set_pkt_forwarding_mode(res->mode);
6178 : 0 : }
6179 : :
6180 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6181 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6182 : : set, "set");
6183 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6184 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6185 : : fwd, "fwd");
6186 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6187 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6188 : : mode,
6189 : : "" /* defined at init */);
6190 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6191 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6192 : : retry, "retry");
6193 : :
6194 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6195 : : .f = cmd_set_fwd_retry_mode_parsed,
6196 : : .data = NULL,
6197 : : .help_str = NULL, /* defined at init */
6198 : : .tokens = {
6199 : : (void *)&cmd_setfwd_retry_set,
6200 : : (void *)&cmd_setfwd_retry_fwd,
6201 : : (void *)&cmd_setfwd_retry_mode,
6202 : : (void *)&cmd_setfwd_retry_retry,
6203 : : NULL,
6204 : : },
6205 : : };
6206 : :
6207 : 0 : static void cmd_set_fwd_retry_mode_init(void)
6208 : : {
6209 : : char *modes, *c;
6210 : : static char token[128];
6211 : : static char help[256];
6212 : : cmdline_parse_token_string_t *token_struct;
6213 : :
6214 : 0 : modes = list_pkt_forwarding_retry_modes();
6215 : : snprintf(help, sizeof(help), "set fwd %s retry: "
6216 : : "Set packet forwarding mode with retry", modes);
6217 : 0 : cmd_set_fwd_retry_mode.help_str = help;
6218 : :
6219 : : /* string token separator is # */
6220 : 0 : for (c = token; *modes != '\0'; modes++)
6221 : 0 : if (*modes == '|')
6222 : 0 : *c++ = '#';
6223 : : else
6224 : 0 : *c++ = *modes;
6225 : 0 : token_struct = (cmdline_parse_token_string_t *)
6226 : : cmd_set_fwd_retry_mode.tokens[2];
6227 : 0 : token_struct->string_data.str = token;
6228 : 0 : }
6229 : :
6230 : : /* *** set DCB forward TCs *** */
6231 : : struct cmd_set_dcb_fwd_tc_result {
6232 : : cmdline_fixed_string_t set;
6233 : : cmdline_fixed_string_t dcb;
6234 : : cmdline_fixed_string_t fwd_tc;
6235 : : uint8_t tc_mask;
6236 : : };
6237 : :
6238 : 0 : static void cmd_set_dcb_fwd_tc_parsed(void *parsed_result,
6239 : : __rte_unused struct cmdline *cl,
6240 : : __rte_unused void *data)
6241 : : {
6242 : : struct cmd_set_dcb_fwd_tc_result *res = parsed_result;
6243 : : int i;
6244 : 0 : if (res->tc_mask == 0) {
6245 : 0 : fprintf(stderr, "TC mask should not be zero!\n");
6246 : 0 : return;
6247 : : }
6248 : : printf("Enabled DCB forwarding TC list:");
6249 : 0 : dcb_fwd_tc_mask = res->tc_mask;
6250 : 0 : for (i = 0; i < RTE_ETH_8_TCS; i++) {
6251 : 0 : if (dcb_fwd_tc_mask & (1u << i))
6252 : : printf(" %d", i);
6253 : : }
6254 : : printf("\n");
6255 : : }
6256 : :
6257 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_set =
6258 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6259 : : set, "set");
6260 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_dcb =
6261 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6262 : : dcb, "dcb");
6263 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_fwdtc =
6264 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6265 : : fwd_tc, "fwd_tc");
6266 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_tcmask =
6267 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_result,
6268 : : tc_mask, RTE_UINT8);
6269 : :
6270 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc = {
6271 : : .f = cmd_set_dcb_fwd_tc_parsed,
6272 : : .data = NULL,
6273 : : .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.",
6274 : : .tokens = {
6275 : : (void *)&cmd_set_dcb_fwd_tc_set,
6276 : : (void *)&cmd_set_dcb_fwd_tc_dcb,
6277 : : (void *)&cmd_set_dcb_fwd_tc_fwdtc,
6278 : : (void *)&cmd_set_dcb_fwd_tc_tcmask,
6279 : : NULL,
6280 : : },
6281 : : };
6282 : :
6283 : : /* *** set DCB forward cores per TC *** */
6284 : : struct cmd_set_dcb_fwd_tc_cores_result {
6285 : : cmdline_fixed_string_t set;
6286 : : cmdline_fixed_string_t dcb;
6287 : : cmdline_fixed_string_t fwd_tc_cores;
6288 : : uint8_t tc_cores;
6289 : : };
6290 : :
6291 : 0 : static void cmd_set_dcb_fwd_tc_cores_parsed(void *parsed_result,
6292 : : __rte_unused struct cmdline *cl,
6293 : : __rte_unused void *data)
6294 : : {
6295 : : struct cmd_set_dcb_fwd_tc_cores_result *res = parsed_result;
6296 : 0 : if (res->tc_cores == 0) {
6297 : 0 : fprintf(stderr, "Cores per-TC should not be zero!\n");
6298 : 0 : return;
6299 : : }
6300 : 0 : dcb_fwd_tc_cores = res->tc_cores;
6301 : 0 : printf("Set cores-per-TC: %u\n", dcb_fwd_tc_cores);
6302 : : }
6303 : :
6304 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_set =
6305 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6306 : : set, "set");
6307 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_dcb =
6308 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6309 : : dcb, "dcb");
6310 : : static cmdline_parse_token_string_t cmd_set_dcb_fwd_tc_cores_fwdtccores =
6311 : : TOKEN_STRING_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6312 : : fwd_tc_cores, "fwd_tc_cores");
6313 : : static cmdline_parse_token_num_t cmd_set_dcb_fwd_tc_cores_tccores =
6314 : : TOKEN_NUM_INITIALIZER(struct cmd_set_dcb_fwd_tc_cores_result,
6315 : : tc_cores, RTE_UINT8);
6316 : :
6317 : : static cmdline_parse_inst_t cmd_set_dcb_fwd_tc_cores = {
6318 : : .f = cmd_set_dcb_fwd_tc_cores_parsed,
6319 : : .data = NULL,
6320 : : .help_str = "config DCB forwarding cores per-TC, 1-means one core process all queues of a TC.",
6321 : : .tokens = {
6322 : : (void *)&cmd_set_dcb_fwd_tc_cores_set,
6323 : : (void *)&cmd_set_dcb_fwd_tc_cores_dcb,
6324 : : (void *)&cmd_set_dcb_fwd_tc_cores_fwdtccores,
6325 : : (void *)&cmd_set_dcb_fwd_tc_cores_tccores,
6326 : : NULL,
6327 : : },
6328 : : };
6329 : :
6330 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6331 : : struct cmd_set_burst_tx_retry_result {
6332 : : cmdline_fixed_string_t set;
6333 : : cmdline_fixed_string_t burst;
6334 : : cmdline_fixed_string_t tx;
6335 : : cmdline_fixed_string_t delay;
6336 : : uint32_t time;
6337 : : cmdline_fixed_string_t retry;
6338 : : uint32_t retry_num;
6339 : : };
6340 : :
6341 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6342 : : __rte_unused struct cmdline *cl,
6343 : : __rte_unused void *data)
6344 : : {
6345 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
6346 : :
6347 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6348 : 0 : && !strcmp(res->tx, "tx")) {
6349 : 0 : if (!strcmp(res->delay, "delay"))
6350 : 0 : burst_tx_delay_time = res->time;
6351 : 0 : if (!strcmp(res->retry, "retry"))
6352 : 0 : burst_tx_retry_num = res->retry_num;
6353 : : }
6354 : :
6355 : 0 : }
6356 : :
6357 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6358 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6359 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6360 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6361 : : "burst");
6362 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6363 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6364 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6365 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6366 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6367 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6368 : : RTE_UINT32);
6369 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6370 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6371 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6372 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6373 : : RTE_UINT32);
6374 : :
6375 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6376 : : .f = cmd_set_burst_tx_retry_parsed,
6377 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6378 : : .tokens = {
6379 : : (void *)&cmd_set_burst_tx_retry_set,
6380 : : (void *)&cmd_set_burst_tx_retry_burst,
6381 : : (void *)&cmd_set_burst_tx_retry_tx,
6382 : : (void *)&cmd_set_burst_tx_retry_delay,
6383 : : (void *)&cmd_set_burst_tx_retry_time,
6384 : : (void *)&cmd_set_burst_tx_retry_retry,
6385 : : (void *)&cmd_set_burst_tx_retry_retry_num,
6386 : : NULL,
6387 : : },
6388 : : };
6389 : :
6390 : : /* *** SET PROMISC MODE *** */
6391 : : struct cmd_set_promisc_mode_result {
6392 : : cmdline_fixed_string_t set;
6393 : : cmdline_fixed_string_t promisc;
6394 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6395 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6396 : : cmdline_fixed_string_t mode;
6397 : : };
6398 : :
6399 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
6400 : : __rte_unused struct cmdline *cl,
6401 : : void *allports)
6402 : : {
6403 : : struct cmd_set_promisc_mode_result *res = parsed_result;
6404 : : int enable;
6405 : : portid_t i;
6406 : :
6407 : 0 : if (!strcmp(res->mode, "on"))
6408 : : enable = 1;
6409 : : else
6410 : : enable = 0;
6411 : :
6412 : : /* all ports */
6413 : 0 : if (allports) {
6414 : 0 : RTE_ETH_FOREACH_DEV(i)
6415 : 0 : eth_set_promisc_mode(i, enable);
6416 : : } else {
6417 : 0 : eth_set_promisc_mode(res->port_num, enable);
6418 : : }
6419 : 0 : }
6420 : :
6421 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
6422 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6423 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
6424 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6425 : : "promisc");
6426 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
6427 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6428 : : "all");
6429 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
6430 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6431 : : RTE_UINT16);
6432 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
6433 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6434 : : "on#off");
6435 : :
6436 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6437 : : .f = cmd_set_promisc_mode_parsed,
6438 : : .data = (void *)1,
6439 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
6440 : : .tokens = {
6441 : : (void *)&cmd_setpromisc_set,
6442 : : (void *)&cmd_setpromisc_promisc,
6443 : : (void *)&cmd_setpromisc_portall,
6444 : : (void *)&cmd_setpromisc_mode,
6445 : : NULL,
6446 : : },
6447 : : };
6448 : :
6449 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6450 : : .f = cmd_set_promisc_mode_parsed,
6451 : : .data = (void *)0,
6452 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6453 : : .tokens = {
6454 : : (void *)&cmd_setpromisc_set,
6455 : : (void *)&cmd_setpromisc_promisc,
6456 : : (void *)&cmd_setpromisc_portnum,
6457 : : (void *)&cmd_setpromisc_mode,
6458 : : NULL,
6459 : : },
6460 : : };
6461 : :
6462 : : /* *** SET ALLMULTI MODE *** */
6463 : : struct cmd_set_allmulti_mode_result {
6464 : : cmdline_fixed_string_t set;
6465 : : cmdline_fixed_string_t allmulti;
6466 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6467 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6468 : : cmdline_fixed_string_t mode;
6469 : : };
6470 : :
6471 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6472 : : __rte_unused struct cmdline *cl,
6473 : : void *allports)
6474 : : {
6475 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
6476 : : int enable;
6477 : : portid_t i;
6478 : :
6479 : 0 : if (!strcmp(res->mode, "on"))
6480 : : enable = 1;
6481 : : else
6482 : : enable = 0;
6483 : :
6484 : : /* all ports */
6485 : 0 : if (allports) {
6486 : 0 : RTE_ETH_FOREACH_DEV(i) {
6487 : 0 : eth_set_allmulticast_mode(i, enable);
6488 : : }
6489 : : }
6490 : : else {
6491 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
6492 : : }
6493 : 0 : }
6494 : :
6495 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
6496 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6497 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6498 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6499 : : "allmulti");
6500 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
6501 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6502 : : "all");
6503 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
6504 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6505 : : RTE_UINT16);
6506 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
6507 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6508 : : "on#off");
6509 : :
6510 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6511 : : .f = cmd_set_allmulti_mode_parsed,
6512 : : .data = (void *)1,
6513 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6514 : : .tokens = {
6515 : : (void *)&cmd_setallmulti_set,
6516 : : (void *)&cmd_setallmulti_allmulti,
6517 : : (void *)&cmd_setallmulti_portall,
6518 : : (void *)&cmd_setallmulti_mode,
6519 : : NULL,
6520 : : },
6521 : : };
6522 : :
6523 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6524 : : .f = cmd_set_allmulti_mode_parsed,
6525 : : .data = (void *)0,
6526 : : .help_str = "set allmulti <port_id> on|off: "
6527 : : "Set allmulti mode on port_id",
6528 : : .tokens = {
6529 : : (void *)&cmd_setallmulti_set,
6530 : : (void *)&cmd_setallmulti_allmulti,
6531 : : (void *)&cmd_setallmulti_portnum,
6532 : : (void *)&cmd_setallmulti_mode,
6533 : : NULL,
6534 : : },
6535 : : };
6536 : :
6537 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6538 : : struct cmd_link_flow_ctrl_show {
6539 : : cmdline_fixed_string_t show;
6540 : : cmdline_fixed_string_t port;
6541 : : portid_t port_id;
6542 : : cmdline_fixed_string_t flow_ctrl;
6543 : : };
6544 : :
6545 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6546 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6547 : : show, "show");
6548 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6549 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6550 : : port, "port");
6551 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6552 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6553 : : port_id, RTE_UINT16);
6554 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6555 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6556 : : flow_ctrl, "flow_ctrl");
6557 : :
6558 : : static void
6559 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6560 : : __rte_unused struct cmdline *cl,
6561 : : __rte_unused void *data)
6562 : : {
6563 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6564 : : static const char *info_border = "*********************";
6565 : : struct rte_eth_fc_conf fc_conf;
6566 : : bool rx_fc_en = false;
6567 : : bool tx_fc_en = false;
6568 : : int ret;
6569 : :
6570 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6571 : 0 : if (ret != 0) {
6572 : 0 : fprintf(stderr,
6573 : : "Failed to get current flow ctrl information: err = %d\n",
6574 : : ret);
6575 : 0 : return;
6576 : : }
6577 : :
6578 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6579 : : rx_fc_en = true;
6580 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6581 : : tx_fc_en = true;
6582 : :
6583 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6584 : 0 : info_border, res->port_id, info_border);
6585 : : printf("FC mode:\n");
6586 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6587 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6588 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6589 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6590 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6591 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6592 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6593 : 0 : printf("Forward MAC control frames: %s\n",
6594 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6595 : 0 : printf("\n%s************** End ***********%s\n",
6596 : : info_border, info_border);
6597 : : }
6598 : :
6599 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6600 : : .f = cmd_link_flow_ctrl_show_parsed,
6601 : : .data = NULL,
6602 : : .help_str = "show port <port_id> flow_ctrl",
6603 : : .tokens = {
6604 : : (void *)&cmd_lfc_show_show,
6605 : : (void *)&cmd_lfc_show_port,
6606 : : (void *)&cmd_lfc_show_portid,
6607 : : (void *)&cmd_lfc_show_flow_ctrl,
6608 : : NULL,
6609 : : },
6610 : : };
6611 : :
6612 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6613 : : struct cmd_link_flow_ctrl_set_result {
6614 : : cmdline_fixed_string_t set;
6615 : : cmdline_fixed_string_t flow_ctrl;
6616 : : cmdline_fixed_string_t rx;
6617 : : cmdline_fixed_string_t rx_lfc_mode;
6618 : : cmdline_fixed_string_t tx;
6619 : : cmdline_fixed_string_t tx_lfc_mode;
6620 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6621 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6622 : : cmdline_fixed_string_t autoneg_str;
6623 : : cmdline_fixed_string_t autoneg;
6624 : : cmdline_fixed_string_t hw_str;
6625 : : uint32_t high_water;
6626 : : cmdline_fixed_string_t lw_str;
6627 : : uint32_t low_water;
6628 : : cmdline_fixed_string_t pt_str;
6629 : : uint16_t pause_time;
6630 : : cmdline_fixed_string_t xon_str;
6631 : : uint16_t send_xon;
6632 : : portid_t port_id;
6633 : : };
6634 : :
6635 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6636 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6637 : : set, "set");
6638 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6639 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6640 : : flow_ctrl, "flow_ctrl");
6641 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6642 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6643 : : rx, "rx");
6644 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6645 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6646 : : rx_lfc_mode, "on#off");
6647 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6648 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6649 : : tx, "tx");
6650 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6651 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6652 : : tx_lfc_mode, "on#off");
6653 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6654 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6655 : : hw_str, "high_water");
6656 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6657 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6658 : : high_water, RTE_UINT32);
6659 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6660 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6661 : : lw_str, "low_water");
6662 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6663 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6664 : : low_water, RTE_UINT32);
6665 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6666 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6667 : : pt_str, "pause_time");
6668 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6669 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6670 : : pause_time, RTE_UINT16);
6671 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6672 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6673 : : xon_str, "send_xon");
6674 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6675 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6676 : : send_xon, RTE_UINT16);
6677 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6678 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6679 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6680 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6681 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6682 : : mac_ctrl_frame_fwd_mode, "on#off");
6683 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6684 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6685 : : autoneg_str, "autoneg");
6686 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6687 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6688 : : autoneg, "on#off");
6689 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6690 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6691 : : port_id, RTE_UINT16);
6692 : :
6693 : : /* forward declaration */
6694 : : static void
6695 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6696 : : void *data);
6697 : :
6698 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6699 : : .f = cmd_link_flow_ctrl_set_parsed,
6700 : : .data = NULL,
6701 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6702 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6703 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6704 : : .tokens = {
6705 : : (void *)&cmd_lfc_set_set,
6706 : : (void *)&cmd_lfc_set_flow_ctrl,
6707 : : (void *)&cmd_lfc_set_rx,
6708 : : (void *)&cmd_lfc_set_rx_mode,
6709 : : (void *)&cmd_lfc_set_tx,
6710 : : (void *)&cmd_lfc_set_tx_mode,
6711 : : (void *)&cmd_lfc_set_high_water,
6712 : : (void *)&cmd_lfc_set_low_water,
6713 : : (void *)&cmd_lfc_set_pause_time,
6714 : : (void *)&cmd_lfc_set_send_xon,
6715 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6716 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6717 : : (void *)&cmd_lfc_set_autoneg_str,
6718 : : (void *)&cmd_lfc_set_autoneg,
6719 : : (void *)&cmd_lfc_set_portid,
6720 : : NULL,
6721 : : },
6722 : : };
6723 : :
6724 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6725 : : .f = cmd_link_flow_ctrl_set_parsed,
6726 : : .data = (void *)&cmd_link_flow_control_set_rx,
6727 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6728 : : "Change rx flow control parameter",
6729 : : .tokens = {
6730 : : (void *)&cmd_lfc_set_set,
6731 : : (void *)&cmd_lfc_set_flow_ctrl,
6732 : : (void *)&cmd_lfc_set_rx,
6733 : : (void *)&cmd_lfc_set_rx_mode,
6734 : : (void *)&cmd_lfc_set_portid,
6735 : : NULL,
6736 : : },
6737 : : };
6738 : :
6739 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6740 : : .f = cmd_link_flow_ctrl_set_parsed,
6741 : : .data = (void *)&cmd_link_flow_control_set_tx,
6742 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6743 : : "Change tx flow control parameter",
6744 : : .tokens = {
6745 : : (void *)&cmd_lfc_set_set,
6746 : : (void *)&cmd_lfc_set_flow_ctrl,
6747 : : (void *)&cmd_lfc_set_tx,
6748 : : (void *)&cmd_lfc_set_tx_mode,
6749 : : (void *)&cmd_lfc_set_portid,
6750 : : NULL,
6751 : : },
6752 : : };
6753 : :
6754 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6755 : : .f = cmd_link_flow_ctrl_set_parsed,
6756 : : .data = (void *)&cmd_link_flow_control_set_hw,
6757 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6758 : : "Change high water flow control parameter",
6759 : : .tokens = {
6760 : : (void *)&cmd_lfc_set_set,
6761 : : (void *)&cmd_lfc_set_flow_ctrl,
6762 : : (void *)&cmd_lfc_set_high_water_str,
6763 : : (void *)&cmd_lfc_set_high_water,
6764 : : (void *)&cmd_lfc_set_portid,
6765 : : NULL,
6766 : : },
6767 : : };
6768 : :
6769 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6770 : : .f = cmd_link_flow_ctrl_set_parsed,
6771 : : .data = (void *)&cmd_link_flow_control_set_lw,
6772 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6773 : : "Change low water flow control parameter",
6774 : : .tokens = {
6775 : : (void *)&cmd_lfc_set_set,
6776 : : (void *)&cmd_lfc_set_flow_ctrl,
6777 : : (void *)&cmd_lfc_set_low_water_str,
6778 : : (void *)&cmd_lfc_set_low_water,
6779 : : (void *)&cmd_lfc_set_portid,
6780 : : NULL,
6781 : : },
6782 : : };
6783 : :
6784 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6785 : : .f = cmd_link_flow_ctrl_set_parsed,
6786 : : .data = (void *)&cmd_link_flow_control_set_pt,
6787 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6788 : : "Change pause time flow control parameter",
6789 : : .tokens = {
6790 : : (void *)&cmd_lfc_set_set,
6791 : : (void *)&cmd_lfc_set_flow_ctrl,
6792 : : (void *)&cmd_lfc_set_pause_time_str,
6793 : : (void *)&cmd_lfc_set_pause_time,
6794 : : (void *)&cmd_lfc_set_portid,
6795 : : NULL,
6796 : : },
6797 : : };
6798 : :
6799 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6800 : : .f = cmd_link_flow_ctrl_set_parsed,
6801 : : .data = (void *)&cmd_link_flow_control_set_xon,
6802 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6803 : : "Change send_xon flow control parameter",
6804 : : .tokens = {
6805 : : (void *)&cmd_lfc_set_set,
6806 : : (void *)&cmd_lfc_set_flow_ctrl,
6807 : : (void *)&cmd_lfc_set_send_xon_str,
6808 : : (void *)&cmd_lfc_set_send_xon,
6809 : : (void *)&cmd_lfc_set_portid,
6810 : : NULL,
6811 : : },
6812 : : };
6813 : :
6814 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6815 : : .f = cmd_link_flow_ctrl_set_parsed,
6816 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6817 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6818 : : "Change mac ctrl fwd flow control parameter",
6819 : : .tokens = {
6820 : : (void *)&cmd_lfc_set_set,
6821 : : (void *)&cmd_lfc_set_flow_ctrl,
6822 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6823 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6824 : : (void *)&cmd_lfc_set_portid,
6825 : : NULL,
6826 : : },
6827 : : };
6828 : :
6829 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6830 : : .f = cmd_link_flow_ctrl_set_parsed,
6831 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6832 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6833 : : "Change autoneg flow control parameter",
6834 : : .tokens = {
6835 : : (void *)&cmd_lfc_set_set,
6836 : : (void *)&cmd_lfc_set_flow_ctrl,
6837 : : (void *)&cmd_lfc_set_autoneg_str,
6838 : : (void *)&cmd_lfc_set_autoneg,
6839 : : (void *)&cmd_lfc_set_portid,
6840 : : NULL,
6841 : : },
6842 : : };
6843 : :
6844 : : static void
6845 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6846 : : __rte_unused struct cmdline *cl,
6847 : : void *data)
6848 : : {
6849 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6850 : : cmdline_parse_inst_t *cmd = data;
6851 : : struct rte_eth_fc_conf fc_conf;
6852 : : int rx_fc_en = 0;
6853 : : int tx_fc_en = 0;
6854 : : int ret;
6855 : :
6856 : : /*
6857 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6858 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6859 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6860 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6861 : : */
6862 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6863 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6864 : : };
6865 : :
6866 : : /* Partial command line, retrieve current configuration */
6867 : 0 : if (cmd) {
6868 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6869 : 0 : if (ret != 0) {
6870 : 0 : fprintf(stderr,
6871 : : "cannot get current flow ctrl parameters, return code = %d\n",
6872 : : ret);
6873 : 0 : return;
6874 : : }
6875 : :
6876 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6877 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6878 : : rx_fc_en = 1;
6879 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6880 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6881 : : tx_fc_en = 1;
6882 : : }
6883 : :
6884 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6885 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6886 : :
6887 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6888 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6889 : :
6890 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6891 : :
6892 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6893 : 0 : fc_conf.high_water = res->high_water;
6894 : :
6895 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6896 : 0 : fc_conf.low_water = res->low_water;
6897 : :
6898 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6899 : 0 : fc_conf.pause_time = res->pause_time;
6900 : :
6901 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6902 : 0 : fc_conf.send_xon = res->send_xon;
6903 : :
6904 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6905 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6906 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6907 : : else
6908 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6909 : : }
6910 : :
6911 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6912 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6913 : :
6914 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6915 : 0 : if (ret != 0)
6916 : 0 : fprintf(stderr,
6917 : : "bad flow control parameter, return code = %d\n",
6918 : : ret);
6919 : : }
6920 : :
6921 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6922 : : struct cmd_priority_flow_ctrl_set_result {
6923 : : cmdline_fixed_string_t set;
6924 : : cmdline_fixed_string_t pfc_ctrl;
6925 : : cmdline_fixed_string_t rx;
6926 : : cmdline_fixed_string_t rx_pfc_mode;
6927 : : cmdline_fixed_string_t tx;
6928 : : cmdline_fixed_string_t tx_pfc_mode;
6929 : : uint32_t high_water;
6930 : : uint32_t low_water;
6931 : : uint16_t pause_time;
6932 : : uint8_t priority;
6933 : : portid_t port_id;
6934 : : };
6935 : :
6936 : : static void
6937 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6938 : : __rte_unused struct cmdline *cl,
6939 : : __rte_unused void *data)
6940 : : {
6941 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6942 : : struct rte_eth_pfc_conf pfc_conf;
6943 : : int rx_fc_enable, tx_fc_enable;
6944 : : int ret;
6945 : :
6946 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
6947 : 0 : return;
6948 : :
6949 : : /*
6950 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6951 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6952 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6953 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6954 : : */
6955 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6956 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6957 : : };
6958 : :
6959 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
6960 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6961 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6962 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6963 : 0 : pfc_conf.fc.high_water = res->high_water;
6964 : 0 : pfc_conf.fc.low_water = res->low_water;
6965 : 0 : pfc_conf.fc.pause_time = res->pause_time;
6966 : 0 : pfc_conf.priority = res->priority;
6967 : :
6968 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6969 : 0 : if (ret != 0)
6970 : 0 : fprintf(stderr,
6971 : : "bad priority flow control parameter, return code = %d\n",
6972 : : ret);
6973 : : }
6974 : :
6975 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
6976 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6977 : : set, "set");
6978 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6979 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6980 : : pfc_ctrl, "pfc_ctrl");
6981 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
6982 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6983 : : rx, "rx");
6984 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6985 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6986 : : rx_pfc_mode, "on#off");
6987 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
6988 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6989 : : tx, "tx");
6990 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6991 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6992 : : tx_pfc_mode, "on#off");
6993 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
6994 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6995 : : high_water, RTE_UINT32);
6996 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
6997 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6998 : : low_water, RTE_UINT32);
6999 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
7000 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7001 : : pause_time, RTE_UINT16);
7002 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
7003 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7004 : : priority, RTE_UINT8);
7005 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
7006 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
7007 : : port_id, RTE_UINT16);
7008 : :
7009 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
7010 : : .f = cmd_priority_flow_ctrl_set_parsed,
7011 : : .data = NULL,
7012 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
7013 : : "<pause_time> <priority> <port_id>: "
7014 : : "Configure the Ethernet priority flow control",
7015 : : .tokens = {
7016 : : (void *)&cmd_pfc_set_set,
7017 : : (void *)&cmd_pfc_set_flow_ctrl,
7018 : : (void *)&cmd_pfc_set_rx,
7019 : : (void *)&cmd_pfc_set_rx_mode,
7020 : : (void *)&cmd_pfc_set_tx,
7021 : : (void *)&cmd_pfc_set_tx_mode,
7022 : : (void *)&cmd_pfc_set_high_water,
7023 : : (void *)&cmd_pfc_set_low_water,
7024 : : (void *)&cmd_pfc_set_pause_time,
7025 : : (void *)&cmd_pfc_set_priority,
7026 : : (void *)&cmd_pfc_set_portid,
7027 : : NULL,
7028 : : },
7029 : : };
7030 : :
7031 : : struct cmd_queue_priority_flow_ctrl_set_result {
7032 : : cmdline_fixed_string_t set;
7033 : : cmdline_fixed_string_t pfc_queue_ctrl;
7034 : : portid_t port_id;
7035 : : cmdline_fixed_string_t rx;
7036 : : cmdline_fixed_string_t rx_pfc_mode;
7037 : : uint16_t tx_qid;
7038 : : uint8_t tx_tc;
7039 : : cmdline_fixed_string_t tx;
7040 : : cmdline_fixed_string_t tx_pfc_mode;
7041 : : uint16_t rx_qid;
7042 : : uint8_t rx_tc;
7043 : : uint16_t pause_time;
7044 : : };
7045 : :
7046 : : static void
7047 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
7048 : : __rte_unused struct cmdline *cl,
7049 : : __rte_unused void *data)
7050 : : {
7051 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
7052 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
7053 : : int rx_fc_enable, tx_fc_enable;
7054 : : int ret;
7055 : :
7056 : : /*
7057 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
7058 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
7059 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
7060 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
7061 : : * the Tx side.
7062 : : */
7063 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
7064 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
7065 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
7066 : : };
7067 : :
7068 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
7069 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
7070 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
7071 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
7072 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
7073 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
7074 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
7075 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
7076 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
7077 : :
7078 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
7079 : : &pfc_queue_conf);
7080 : 0 : if (ret != 0) {
7081 : 0 : fprintf(stderr,
7082 : : "bad queue priority flow control parameter, rc = %d\n",
7083 : : ret);
7084 : : }
7085 : 0 : }
7086 : :
7087 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
7088 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7089 : : set, "set");
7090 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
7091 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7092 : : pfc_queue_ctrl, "pfc_queue_ctrl");
7093 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
7094 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7095 : : port_id, RTE_UINT16);
7096 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
7097 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7098 : : rx, "rx");
7099 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
7100 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7101 : : rx_pfc_mode, "on#off");
7102 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
7103 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7104 : : tx_qid, RTE_UINT16);
7105 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
7106 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7107 : : tx_tc, RTE_UINT8);
7108 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
7109 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7110 : : tx, "tx");
7111 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
7112 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7113 : : tx_pfc_mode, "on#off");
7114 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
7115 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7116 : : rx_qid, RTE_UINT16);
7117 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
7118 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7119 : : rx_tc, RTE_UINT8);
7120 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7121 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7122 : : pause_time, RTE_UINT16);
7123 : :
7124 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7125 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
7126 : : .data = NULL,
7127 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7128 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7129 : : "Configure the Ethernet queue priority flow control",
7130 : : .tokens = {
7131 : : (void *)&cmd_q_pfc_set_set,
7132 : : (void *)&cmd_q_pfc_set_flow_ctrl,
7133 : : (void *)&cmd_q_pfc_set_portid,
7134 : : (void *)&cmd_q_pfc_set_rx,
7135 : : (void *)&cmd_q_pfc_set_rx_mode,
7136 : : (void *)&cmd_q_pfc_set_tx_qid,
7137 : : (void *)&cmd_q_pfc_set_tx_tc,
7138 : : (void *)&cmd_q_pfc_set_tx,
7139 : : (void *)&cmd_q_pfc_set_tx_mode,
7140 : : (void *)&cmd_q_pfc_set_rx_qid,
7141 : : (void *)&cmd_q_pfc_set_rx_tc,
7142 : : (void *)&cmd_q_pfc_set_pause_time,
7143 : : NULL,
7144 : : },
7145 : : };
7146 : :
7147 : : /* *** RESET CONFIGURATION *** */
7148 : : struct cmd_reset_result {
7149 : : cmdline_fixed_string_t reset;
7150 : : cmdline_fixed_string_t def;
7151 : : };
7152 : :
7153 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
7154 : : struct cmdline *cl,
7155 : : __rte_unused void *data)
7156 : : {
7157 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7158 : 0 : set_def_fwd_config();
7159 : 0 : }
7160 : :
7161 : : static cmdline_parse_token_string_t cmd_reset_set =
7162 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7163 : : static cmdline_parse_token_string_t cmd_reset_def =
7164 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7165 : : "default");
7166 : :
7167 : : static cmdline_parse_inst_t cmd_reset = {
7168 : : .f = cmd_reset_parsed,
7169 : : .data = NULL,
7170 : : .help_str = "set default: Reset default forwarding configuration",
7171 : : .tokens = {
7172 : : (void *)&cmd_reset_set,
7173 : : (void *)&cmd_reset_def,
7174 : : NULL,
7175 : : },
7176 : : };
7177 : :
7178 : : /* *** START FORWARDING *** */
7179 : : struct cmd_start_result {
7180 : : cmdline_fixed_string_t start;
7181 : : };
7182 : :
7183 : : static cmdline_parse_token_string_t cmd_start_start =
7184 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7185 : :
7186 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
7187 : : __rte_unused struct cmdline *cl,
7188 : : __rte_unused void *data)
7189 : : {
7190 : 0 : start_packet_forwarding(0);
7191 : 0 : }
7192 : :
7193 : : static cmdline_parse_inst_t cmd_start = {
7194 : : .f = cmd_start_parsed,
7195 : : .data = NULL,
7196 : : .help_str = "start: Start packet forwarding",
7197 : : .tokens = {
7198 : : (void *)&cmd_start_start,
7199 : : NULL,
7200 : : },
7201 : : };
7202 : :
7203 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7204 : : struct cmd_start_tx_first_result {
7205 : : cmdline_fixed_string_t start;
7206 : : cmdline_fixed_string_t tx_first;
7207 : : };
7208 : :
7209 : : static void
7210 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7211 : : __rte_unused struct cmdline *cl,
7212 : : __rte_unused void *data)
7213 : : {
7214 : 0 : start_packet_forwarding(1);
7215 : 0 : }
7216 : :
7217 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
7218 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7219 : : "start");
7220 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7221 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7222 : : tx_first, "tx_first");
7223 : :
7224 : : static cmdline_parse_inst_t cmd_start_tx_first = {
7225 : : .f = cmd_start_tx_first_parsed,
7226 : : .data = NULL,
7227 : : .help_str = "start tx_first: Start packet forwarding, "
7228 : : "after sending 1 burst of packets",
7229 : : .tokens = {
7230 : : (void *)&cmd_start_tx_first_start,
7231 : : (void *)&cmd_start_tx_first_tx_first,
7232 : : NULL,
7233 : : },
7234 : : };
7235 : :
7236 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
7237 : : struct cmd_start_tx_first_n_result {
7238 : : cmdline_fixed_string_t start;
7239 : : cmdline_fixed_string_t tx_first;
7240 : : uint32_t tx_num;
7241 : : };
7242 : :
7243 : : static void
7244 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
7245 : : __rte_unused struct cmdline *cl,
7246 : : __rte_unused void *data)
7247 : : {
7248 : : struct cmd_start_tx_first_n_result *res = parsed_result;
7249 : :
7250 : 0 : start_packet_forwarding(res->tx_num);
7251 : 0 : }
7252 : :
7253 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7254 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7255 : : start, "start");
7256 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7257 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7258 : : tx_first, "tx_first");
7259 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7260 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7261 : : tx_num, RTE_UINT32);
7262 : :
7263 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
7264 : : .f = cmd_start_tx_first_n_parsed,
7265 : : .data = NULL,
7266 : : .help_str = "start tx_first <num>: "
7267 : : "packet forwarding, after sending <num> bursts of packets",
7268 : : .tokens = {
7269 : : (void *)&cmd_start_tx_first_n_start,
7270 : : (void *)&cmd_start_tx_first_n_tx_first,
7271 : : (void *)&cmd_start_tx_first_n_tx_num,
7272 : : NULL,
7273 : : },
7274 : : };
7275 : :
7276 : : /* *** SET LINK UP *** */
7277 : : struct cmd_set_link_up_result {
7278 : : cmdline_fixed_string_t set;
7279 : : cmdline_fixed_string_t link_up;
7280 : : cmdline_fixed_string_t port;
7281 : : portid_t port_id;
7282 : : };
7283 : :
7284 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
7285 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7286 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7287 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7288 : : "link-up");
7289 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
7290 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7291 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7292 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7293 : : RTE_UINT16);
7294 : :
7295 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7296 : : __rte_unused struct cmdline *cl,
7297 : : __rte_unused void *data)
7298 : : {
7299 : : struct cmd_set_link_up_result *res = parsed_result;
7300 : 0 : dev_set_link_up(res->port_id);
7301 : 0 : }
7302 : :
7303 : : static cmdline_parse_inst_t cmd_set_link_up = {
7304 : : .f = cmd_set_link_up_parsed,
7305 : : .data = NULL,
7306 : : .help_str = "set link-up port <port id>",
7307 : : .tokens = {
7308 : : (void *)&cmd_set_link_up_set,
7309 : : (void *)&cmd_set_link_up_link_up,
7310 : : (void *)&cmd_set_link_up_port,
7311 : : (void *)&cmd_set_link_up_port_id,
7312 : : NULL,
7313 : : },
7314 : : };
7315 : :
7316 : : /* *** SET LINK DOWN *** */
7317 : : struct cmd_set_link_down_result {
7318 : : cmdline_fixed_string_t set;
7319 : : cmdline_fixed_string_t link_down;
7320 : : cmdline_fixed_string_t port;
7321 : : portid_t port_id;
7322 : : };
7323 : :
7324 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
7325 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7326 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
7327 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7328 : : "link-down");
7329 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
7330 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7331 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
7332 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7333 : : RTE_UINT16);
7334 : :
7335 : 0 : static void cmd_set_link_down_parsed(
7336 : : __rte_unused void *parsed_result,
7337 : : __rte_unused struct cmdline *cl,
7338 : : __rte_unused void *data)
7339 : : {
7340 : : struct cmd_set_link_down_result *res = parsed_result;
7341 : 0 : dev_set_link_down(res->port_id);
7342 : 0 : }
7343 : :
7344 : : static cmdline_parse_inst_t cmd_set_link_down = {
7345 : : .f = cmd_set_link_down_parsed,
7346 : : .data = NULL,
7347 : : .help_str = "set link-down port <port id>",
7348 : : .tokens = {
7349 : : (void *)&cmd_set_link_down_set,
7350 : : (void *)&cmd_set_link_down_link_down,
7351 : : (void *)&cmd_set_link_down_port,
7352 : : (void *)&cmd_set_link_down_port_id,
7353 : : NULL,
7354 : : },
7355 : : };
7356 : :
7357 : : /* *** SHOW CFG *** */
7358 : : struct cmd_showcfg_result {
7359 : : cmdline_fixed_string_t show;
7360 : : cmdline_fixed_string_t cfg;
7361 : : cmdline_fixed_string_t what;
7362 : : };
7363 : :
7364 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
7365 : : __rte_unused struct cmdline *cl,
7366 : : __rte_unused void *data)
7367 : : {
7368 : : struct cmd_showcfg_result *res = parsed_result;
7369 : 0 : if (!strcmp(res->what, "rxtx"))
7370 : 0 : rxtx_config_display();
7371 : 0 : else if (!strcmp(res->what, "cores"))
7372 : 0 : fwd_lcores_config_display();
7373 : 0 : else if (!strcmp(res->what, "fwd"))
7374 : 0 : pkt_fwd_config_display(&cur_fwd_config);
7375 : 0 : else if (!strcmp(res->what, "rxoffs"))
7376 : 0 : show_rx_pkt_offsets();
7377 : 0 : else if (!strcmp(res->what, "rxpkts"))
7378 : 0 : show_rx_pkt_segments();
7379 : 0 : else if (!strcmp(res->what, "rxhdrs"))
7380 : 0 : show_rx_pkt_hdrs();
7381 : 0 : else if (!strcmp(res->what, "txpkts"))
7382 : 0 : show_tx_pkt_segments();
7383 : 0 : else if (!strcmp(res->what, "txtimes"))
7384 : 0 : show_tx_pkt_times();
7385 : 0 : }
7386 : :
7387 : : static cmdline_parse_token_string_t cmd_showcfg_show =
7388 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7389 : : static cmdline_parse_token_string_t cmd_showcfg_port =
7390 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7391 : : static cmdline_parse_token_string_t cmd_showcfg_what =
7392 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7393 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
7394 : :
7395 : : static cmdline_parse_inst_t cmd_showcfg = {
7396 : : .f = cmd_showcfg_parsed,
7397 : : .data = NULL,
7398 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
7399 : : .tokens = {
7400 : : (void *)&cmd_showcfg_show,
7401 : : (void *)&cmd_showcfg_port,
7402 : : (void *)&cmd_showcfg_what,
7403 : : NULL,
7404 : : },
7405 : : };
7406 : :
7407 : : /* *** SHOW ALL PORT INFO *** */
7408 : : struct cmd_showportall_result {
7409 : : cmdline_fixed_string_t show;
7410 : : cmdline_fixed_string_t port;
7411 : : cmdline_fixed_string_t what;
7412 : : cmdline_fixed_string_t all;
7413 : : };
7414 : :
7415 : 0 : static void cmd_showportall_parsed(void *parsed_result,
7416 : : __rte_unused struct cmdline *cl,
7417 : : __rte_unused void *data)
7418 : : {
7419 : : portid_t i;
7420 : :
7421 : : struct cmd_showportall_result *res = parsed_result;
7422 : 0 : if (!strcmp(res->show, "clear")) {
7423 : 0 : if (!strcmp(res->what, "stats"))
7424 : 0 : RTE_ETH_FOREACH_DEV(i)
7425 : 0 : nic_stats_clear(i);
7426 : 0 : else if (!strcmp(res->what, "xstats"))
7427 : 0 : RTE_ETH_FOREACH_DEV(i)
7428 : 0 : nic_xstats_clear(i);
7429 : 0 : } else if (!strcmp(res->what, "info"))
7430 : 0 : RTE_ETH_FOREACH_DEV(i)
7431 : 0 : port_infos_display(i);
7432 : 0 : else if (!strcmp(res->what, "summary")) {
7433 : 0 : port_summary_header_display();
7434 : 0 : RTE_ETH_FOREACH_DEV(i)
7435 : 0 : port_summary_display(i);
7436 : : }
7437 : 0 : else if (!strcmp(res->what, "stats"))
7438 : 0 : RTE_ETH_FOREACH_DEV(i)
7439 : 0 : nic_stats_display(i);
7440 : 0 : else if (!strcmp(res->what, "xstats"))
7441 : 0 : RTE_ETH_FOREACH_DEV(i)
7442 : 0 : nic_xstats_display(i);
7443 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7444 : 0 : else if (!strcmp(res->what, "fdir"))
7445 : 0 : RTE_ETH_FOREACH_DEV(i)
7446 : 0 : fdir_get_infos(i);
7447 : : #endif
7448 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7449 : 0 : RTE_ETH_FOREACH_DEV(i)
7450 : 0 : port_dcb_info_display(i);
7451 : 0 : }
7452 : :
7453 : : static cmdline_parse_token_string_t cmd_showportall_show =
7454 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7455 : : "show#clear");
7456 : : static cmdline_parse_token_string_t cmd_showportall_port =
7457 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7458 : : static cmdline_parse_token_string_t cmd_showportall_what =
7459 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7460 : : "info#summary#stats#xstats#fdir#dcb_tc");
7461 : : static cmdline_parse_token_string_t cmd_showportall_all =
7462 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7463 : : static cmdline_parse_inst_t cmd_showportall = {
7464 : : .f = cmd_showportall_parsed,
7465 : : .data = NULL,
7466 : : .help_str = "show|clear port "
7467 : : "info|summary|stats|xstats|fdir|dcb_tc all",
7468 : : .tokens = {
7469 : : (void *)&cmd_showportall_show,
7470 : : (void *)&cmd_showportall_port,
7471 : : (void *)&cmd_showportall_what,
7472 : : (void *)&cmd_showportall_all,
7473 : : NULL,
7474 : : },
7475 : : };
7476 : :
7477 : : /* *** SHOW PORT INFO *** */
7478 : : struct cmd_showport_result {
7479 : : cmdline_fixed_string_t show;
7480 : : cmdline_fixed_string_t port;
7481 : : cmdline_fixed_string_t what;
7482 : : uint16_t portnum;
7483 : : };
7484 : :
7485 : 0 : static void cmd_showport_parsed(void *parsed_result,
7486 : : __rte_unused struct cmdline *cl,
7487 : : __rte_unused void *data)
7488 : : {
7489 : : struct cmd_showport_result *res = parsed_result;
7490 : 0 : if (!strcmp(res->show, "clear")) {
7491 : 0 : if (!strcmp(res->what, "stats"))
7492 : 0 : nic_stats_clear(res->portnum);
7493 : 0 : else if (!strcmp(res->what, "xstats"))
7494 : 0 : nic_xstats_clear(res->portnum);
7495 : 0 : } else if (!strcmp(res->what, "info"))
7496 : 0 : port_infos_display(res->portnum);
7497 : 0 : else if (!strcmp(res->what, "summary")) {
7498 : 0 : port_summary_header_display();
7499 : 0 : port_summary_display(res->portnum);
7500 : : }
7501 : 0 : else if (!strcmp(res->what, "stats"))
7502 : 0 : nic_stats_display(res->portnum);
7503 : 0 : else if (!strcmp(res->what, "xstats"))
7504 : 0 : nic_xstats_display(res->portnum);
7505 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7506 : 0 : else if (!strcmp(res->what, "fdir"))
7507 : 0 : fdir_get_infos(res->portnum);
7508 : : #endif
7509 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7510 : 0 : port_dcb_info_display(res->portnum);
7511 : 0 : }
7512 : :
7513 : : static cmdline_parse_token_string_t cmd_showport_show =
7514 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7515 : : "show#clear");
7516 : : static cmdline_parse_token_string_t cmd_showport_port =
7517 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7518 : : static cmdline_parse_token_string_t cmd_showport_what =
7519 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7520 : : "info#summary#stats#xstats#fdir#dcb_tc");
7521 : : static cmdline_parse_token_num_t cmd_showport_portnum =
7522 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7523 : :
7524 : : static cmdline_parse_inst_t cmd_showport = {
7525 : : .f = cmd_showport_parsed,
7526 : : .data = NULL,
7527 : : .help_str = "show|clear port "
7528 : : "info|summary|stats|xstats|fdir|dcb_tc "
7529 : : "<port_id>",
7530 : : .tokens = {
7531 : : (void *)&cmd_showport_show,
7532 : : (void *)&cmd_showport_port,
7533 : : (void *)&cmd_showport_what,
7534 : : (void *)&cmd_showport_portnum,
7535 : : NULL,
7536 : : },
7537 : : };
7538 : :
7539 : : /* *** show port representors information *** */
7540 : : struct cmd_representor_info_result {
7541 : : cmdline_fixed_string_t cmd_show;
7542 : : cmdline_fixed_string_t cmd_port;
7543 : : cmdline_fixed_string_t cmd_info;
7544 : : cmdline_fixed_string_t cmd_keyword;
7545 : : portid_t cmd_pid;
7546 : : };
7547 : :
7548 : : static void
7549 : 0 : cmd_representor_info_parsed(void *parsed_result,
7550 : : __rte_unused struct cmdline *cl,
7551 : : __rte_unused void *data)
7552 : : {
7553 : : struct cmd_representor_info_result *res = parsed_result;
7554 : : struct rte_eth_representor_info *info;
7555 : : struct rte_eth_representor_range *range;
7556 : : uint32_t range_diff;
7557 : : uint32_t i;
7558 : : int ret;
7559 : : int num;
7560 : :
7561 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7562 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7563 : 0 : return;
7564 : : }
7565 : :
7566 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7567 : 0 : if (ret < 0) {
7568 : 0 : fprintf(stderr,
7569 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7570 : 0 : res->cmd_pid, rte_strerror(-ret));
7571 : 0 : return;
7572 : : }
7573 : : num = ret;
7574 : :
7575 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7576 : 0 : if (info == NULL) {
7577 : 0 : fprintf(stderr,
7578 : : "Failed to allocate memory for representor info for port %hu\n",
7579 : 0 : res->cmd_pid);
7580 : 0 : return;
7581 : : }
7582 : 0 : info->nb_ranges_alloc = num;
7583 : :
7584 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7585 : 0 : if (ret < 0) {
7586 : 0 : fprintf(stderr,
7587 : : "Failed to get the representor info for port %hu: %s\n",
7588 : 0 : res->cmd_pid, rte_strerror(-ret));
7589 : 0 : free(info);
7590 : 0 : return;
7591 : : }
7592 : :
7593 : 0 : printf("Port controller: %hu\n", info->controller);
7594 : 0 : printf("Port PF: %hu\n", info->pf);
7595 : :
7596 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7597 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7598 : : range = &info->ranges[i];
7599 : 0 : range_diff = range->id_end - range->id_base;
7600 : :
7601 : 0 : printf("%u. ", i + 1);
7602 : 0 : printf("'%s' ", range->name);
7603 : 0 : if (range_diff > 0)
7604 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7605 : : else
7606 : 0 : printf("[%u]: ", range->id_base);
7607 : :
7608 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7609 : :
7610 : 0 : switch (range->type) {
7611 : : case RTE_ETH_REPRESENTOR_NONE:
7612 : : printf(", NONE\n");
7613 : : break;
7614 : 0 : case RTE_ETH_REPRESENTOR_VF:
7615 : 0 : if (range_diff > 0)
7616 : 0 : printf(", VF %d..%d\n", range->vf,
7617 : 0 : range->vf + range_diff);
7618 : : else
7619 : 0 : printf(", VF %d\n", range->vf);
7620 : : break;
7621 : 0 : case RTE_ETH_REPRESENTOR_SF:
7622 : 0 : printf(", SF %d\n", range->sf);
7623 : : break;
7624 : 0 : case RTE_ETH_REPRESENTOR_PF:
7625 : 0 : if (range_diff > 0)
7626 : 0 : printf("..%d\n", range->pf + range_diff);
7627 : : else
7628 : : printf("\n");
7629 : : break;
7630 : 0 : default:
7631 : : printf(", UNKNOWN TYPE %d\n", range->type);
7632 : : break;
7633 : : }
7634 : : }
7635 : :
7636 : 0 : free(info);
7637 : : }
7638 : :
7639 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7640 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7641 : : cmd_show, "show");
7642 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7643 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7644 : : cmd_port, "port");
7645 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7646 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7647 : : cmd_info, "info");
7648 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7649 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7650 : : cmd_pid, RTE_UINT16);
7651 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7652 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7653 : : cmd_keyword, "representor");
7654 : :
7655 : : static cmdline_parse_inst_t cmd_representor_info = {
7656 : : .f = cmd_representor_info_parsed,
7657 : : .data = NULL,
7658 : : .help_str = "show port info <port_id> representor",
7659 : : .tokens = {
7660 : : (void *)&cmd_representor_info_show,
7661 : : (void *)&cmd_representor_info_port,
7662 : : (void *)&cmd_representor_info_info,
7663 : : (void *)&cmd_representor_info_pid,
7664 : : (void *)&cmd_representor_info_keyword,
7665 : : NULL,
7666 : : },
7667 : : };
7668 : :
7669 : :
7670 : : /* *** SHOW DEVICE INFO *** */
7671 : : struct cmd_showdevice_result {
7672 : : cmdline_fixed_string_t show;
7673 : : cmdline_fixed_string_t device;
7674 : : cmdline_fixed_string_t what;
7675 : : cmdline_fixed_string_t identifier;
7676 : : };
7677 : :
7678 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7679 : : __rte_unused struct cmdline *cl,
7680 : : __rte_unused void *data)
7681 : : {
7682 : : struct cmd_showdevice_result *res = parsed_result;
7683 : 0 : if (!strcmp(res->what, "info")) {
7684 : 0 : if (!strcmp(res->identifier, "all"))
7685 : 0 : device_infos_display(NULL);
7686 : : else
7687 : 0 : device_infos_display(res->identifier);
7688 : : }
7689 : 0 : }
7690 : :
7691 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7692 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7693 : : "show");
7694 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7695 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7696 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7697 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7698 : : "info");
7699 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7700 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7701 : : identifier, NULL);
7702 : :
7703 : : static cmdline_parse_inst_t cmd_showdevice = {
7704 : : .f = cmd_showdevice_parsed,
7705 : : .data = NULL,
7706 : : .help_str = "show device info <identifier>|all",
7707 : : .tokens = {
7708 : : (void *)&cmd_showdevice_show,
7709 : : (void *)&cmd_showdevice_device,
7710 : : (void *)&cmd_showdevice_what,
7711 : : (void *)&cmd_showdevice_identifier,
7712 : : NULL,
7713 : : },
7714 : : };
7715 : :
7716 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7717 : : struct cmd_showeeprom_result {
7718 : : cmdline_fixed_string_t show;
7719 : : cmdline_fixed_string_t port;
7720 : : uint16_t portnum;
7721 : : cmdline_fixed_string_t type;
7722 : : };
7723 : :
7724 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7725 : : __rte_unused struct cmdline *cl,
7726 : : __rte_unused void *data)
7727 : : {
7728 : : struct cmd_showeeprom_result *res = parsed_result;
7729 : :
7730 : 0 : if (!strcmp(res->type, "eeprom"))
7731 : 0 : port_eeprom_display(res->portnum);
7732 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7733 : 0 : port_module_eeprom_display(res->portnum);
7734 : : else
7735 : 0 : fprintf(stderr, "Unknown argument\n");
7736 : 0 : }
7737 : :
7738 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7739 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7740 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7741 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7742 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7743 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7744 : : RTE_UINT16);
7745 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7746 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7747 : :
7748 : : static cmdline_parse_inst_t cmd_showeeprom = {
7749 : : .f = cmd_showeeprom_parsed,
7750 : : .data = NULL,
7751 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7752 : : .tokens = {
7753 : : (void *)&cmd_showeeprom_show,
7754 : : (void *)&cmd_showeeprom_port,
7755 : : (void *)&cmd_showeeprom_portnum,
7756 : : (void *)&cmd_showeeprom_type,
7757 : : NULL,
7758 : : },
7759 : : };
7760 : :
7761 : : /* *** SET PORT EEPROM *** */
7762 : : struct cmd_seteeprom_result {
7763 : : cmdline_fixed_string_t set;
7764 : : cmdline_fixed_string_t port;
7765 : : uint16_t portnum;
7766 : : cmdline_fixed_string_t eeprom;
7767 : : cmdline_fixed_string_t confirm_str;
7768 : : cmdline_fixed_string_t magic_str;
7769 : : uint32_t magic;
7770 : : cmdline_fixed_string_t value;
7771 : : cmdline_multi_string_t token_str;
7772 : : };
7773 : :
7774 : 0 : static void cmd_seteeprom_parsed(void *parsed_result,
7775 : : __rte_unused struct cmdline *cl,
7776 : : __rte_unused void *data)
7777 : : {
7778 : : struct cmd_seteeprom_result *res = parsed_result;
7779 : : uint32_t offset = 0;
7780 : : uint32_t length;
7781 : : uint8_t *value;
7782 : : char *token_str;
7783 : : char *token;
7784 : :
7785 : 0 : token_str = res->token_str;
7786 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7787 : :
7788 : : /* Parse Hex string to Byte data */
7789 : 0 : if (strlen(token) % 2 != 0) {
7790 : 0 : fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
7791 : : token);
7792 : 0 : return;
7793 : : }
7794 : :
7795 : 0 : length = strlen(token) / 2;
7796 : 0 : value = calloc(length, sizeof(uint8_t));
7797 : 0 : for (int count = 0; count < (int)(length); count++) {
7798 : 0 : if (sscanf(token, "%2hhx", &value[count]) != 1) {
7799 : 0 : fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
7800 : 0 : token - (count + 1));
7801 : 0 : goto out;
7802 : : }
7803 : 0 : token += 2;
7804 : : }
7805 : :
7806 : : /* Second token: offset string */
7807 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7808 : 0 : if (token != NULL) {
7809 : 0 : if (strcmp(token, "offset") == 0) {
7810 : : /* Third token: offset */
7811 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7812 : 0 : if (token == NULL) {
7813 : 0 : fprintf(stderr, "No offset specified\n");
7814 : 0 : goto out;
7815 : : }
7816 : :
7817 : : char *end;
7818 : 0 : offset = strtoul(token, &end, 10);
7819 : 0 : if (offset == 0 && strcmp(end, "") != 0) {
7820 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7821 : 0 : goto out;
7822 : : }
7823 : : } else {
7824 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7825 : 0 : goto out;
7826 : : }
7827 : : }
7828 : :
7829 : 0 : port_eeprom_set(res->portnum, res->magic, offset, length, value);
7830 : :
7831 : 0 : out:
7832 : 0 : free(value);
7833 : : }
7834 : :
7835 : : static cmdline_parse_token_string_t cmd_seteeprom_set =
7836 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
7837 : : static cmdline_parse_token_string_t cmd_seteeprom_port =
7838 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
7839 : : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
7840 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
7841 : : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
7842 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
7843 : : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
7844 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
7845 : : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
7846 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
7847 : : static cmdline_parse_token_num_t cmd_seteeprom_magic =
7848 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
7849 : : static cmdline_parse_token_string_t cmd_seteeprom_value =
7850 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
7851 : : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
7852 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
7853 : :
7854 : : static cmdline_parse_inst_t cmd_seteeprom = {
7855 : : .f = cmd_seteeprom_parsed,
7856 : : .data = NULL,
7857 : : .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
7858 : : "value <value> offset <offset>: Set eeprom value for port_id.\n"
7859 : : "Note:\n"
7860 : : "This is a high-risk command and its misuse may result in "
7861 : : "unexpected behaviour from the NIC.\n"
7862 : : "By inserting \"accept_risk\" into the command, the user is "
7863 : : "acknowledging and taking responsibility for this risk.",
7864 : : .tokens = {
7865 : : (void *)&cmd_seteeprom_set,
7866 : : (void *)&cmd_seteeprom_port,
7867 : : (void *)&cmd_seteeprom_portnum,
7868 : : (void *)&cmd_seteeprom_eeprom,
7869 : : (void *)&cmd_seteeprom_confirm_str,
7870 : : (void *)&cmd_seteeprom_magic_str,
7871 : : (void *)&cmd_seteeprom_magic,
7872 : : (void *)&cmd_seteeprom_value,
7873 : : (void *)&cmd_seteeprom_token_str,
7874 : : NULL,
7875 : : },
7876 : : };
7877 : :
7878 : : /* *** SHOW QUEUE INFO *** */
7879 : : struct cmd_showqueue_result {
7880 : : cmdline_fixed_string_t show;
7881 : : cmdline_fixed_string_t type;
7882 : : cmdline_fixed_string_t what;
7883 : : uint16_t portnum;
7884 : : uint16_t queuenum;
7885 : : };
7886 : :
7887 : : static void
7888 : 0 : cmd_showqueue_parsed(void *parsed_result,
7889 : : __rte_unused struct cmdline *cl,
7890 : : __rte_unused void *data)
7891 : : {
7892 : : struct cmd_showqueue_result *res = parsed_result;
7893 : :
7894 : 0 : if (!strcmp(res->type, "rxq"))
7895 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7896 : 0 : else if (!strcmp(res->type, "txq"))
7897 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7898 : 0 : }
7899 : :
7900 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7901 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7902 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7903 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7904 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7905 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7906 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7907 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7908 : : RTE_UINT16);
7909 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7910 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7911 : : RTE_UINT16);
7912 : :
7913 : : static cmdline_parse_inst_t cmd_showqueue = {
7914 : : .f = cmd_showqueue_parsed,
7915 : : .data = NULL,
7916 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7917 : : .tokens = {
7918 : : (void *)&cmd_showqueue_show,
7919 : : (void *)&cmd_showqueue_type,
7920 : : (void *)&cmd_showqueue_what,
7921 : : (void *)&cmd_showqueue_portnum,
7922 : : (void *)&cmd_showqueue_queuenum,
7923 : : NULL,
7924 : : },
7925 : : };
7926 : :
7927 : : /* show/clear fwd engine statistics */
7928 : : struct fwd_result {
7929 : : cmdline_fixed_string_t action;
7930 : : cmdline_fixed_string_t fwd;
7931 : : cmdline_fixed_string_t stats;
7932 : : cmdline_fixed_string_t all;
7933 : : };
7934 : :
7935 : : static cmdline_parse_token_string_t cmd_fwd_action =
7936 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7937 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
7938 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7939 : : static cmdline_parse_token_string_t cmd_fwd_stats =
7940 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7941 : : static cmdline_parse_token_string_t cmd_fwd_all =
7942 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7943 : :
7944 : : static void
7945 : 0 : cmd_showfwdall_parsed(void *parsed_result,
7946 : : __rte_unused struct cmdline *cl,
7947 : : __rte_unused void *data)
7948 : : {
7949 : : struct fwd_result *res = parsed_result;
7950 : :
7951 : 0 : if (!strcmp(res->action, "show"))
7952 : 0 : fwd_stats_display();
7953 : : else
7954 : 0 : fwd_stats_reset();
7955 : 0 : }
7956 : :
7957 : : static cmdline_parse_inst_t cmd_showfwdall = {
7958 : : .f = cmd_showfwdall_parsed,
7959 : : .data = NULL,
7960 : : .help_str = "show|clear fwd stats all",
7961 : : .tokens = {
7962 : : (void *)&cmd_fwd_action,
7963 : : (void *)&cmd_fwd_fwd,
7964 : : (void *)&cmd_fwd_stats,
7965 : : (void *)&cmd_fwd_all,
7966 : : NULL,
7967 : : },
7968 : : };
7969 : :
7970 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7971 : : struct cmd_read_rxd_txd_result {
7972 : : cmdline_fixed_string_t read;
7973 : : cmdline_fixed_string_t rxd_txd;
7974 : : portid_t port_id;
7975 : : uint16_t queue_id;
7976 : : uint16_t desc_id;
7977 : : };
7978 : :
7979 : : static void
7980 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
7981 : : __rte_unused struct cmdline *cl,
7982 : : __rte_unused void *data)
7983 : : {
7984 : : struct cmd_read_rxd_txd_result *res = parsed_result;
7985 : :
7986 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
7987 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7988 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
7989 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7990 : 0 : }
7991 : :
7992 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7993 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7994 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7995 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7996 : : "rxd#txd");
7997 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7998 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
7999 : : RTE_UINT16);
8000 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
8001 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
8002 : : RTE_UINT16);
8003 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
8004 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
8005 : : RTE_UINT16);
8006 : :
8007 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
8008 : : .f = cmd_read_rxd_txd_parsed,
8009 : : .data = NULL,
8010 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
8011 : : .tokens = {
8012 : : (void *)&cmd_read_rxd_txd_read,
8013 : : (void *)&cmd_read_rxd_txd_rxd_txd,
8014 : : (void *)&cmd_read_rxd_txd_port_id,
8015 : : (void *)&cmd_read_rxd_txd_queue_id,
8016 : : (void *)&cmd_read_rxd_txd_desc_id,
8017 : : NULL,
8018 : : },
8019 : : };
8020 : :
8021 : : /* *** QUIT *** */
8022 : : struct cmd_quit_result {
8023 : : cmdline_fixed_string_t quit;
8024 : : };
8025 : :
8026 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
8027 : : struct cmdline *cl,
8028 : : __rte_unused void *data)
8029 : : {
8030 : 0 : cmdline_quit(cl);
8031 : 0 : cl_quit = 1;
8032 : 0 : }
8033 : :
8034 : : static cmdline_parse_token_string_t cmd_quit_quit =
8035 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
8036 : :
8037 : : static cmdline_parse_inst_t cmd_quit = {
8038 : : .f = cmd_quit_parsed,
8039 : : .data = NULL,
8040 : : .help_str = "quit: Exit application",
8041 : : .tokens = {
8042 : : (void *)&cmd_quit_quit,
8043 : : NULL,
8044 : : },
8045 : : };
8046 : :
8047 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
8048 : : struct cmd_mac_addr_result {
8049 : : cmdline_fixed_string_t mac_addr_cmd;
8050 : : cmdline_fixed_string_t what;
8051 : : uint16_t port_num;
8052 : : struct rte_ether_addr address;
8053 : : };
8054 : :
8055 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
8056 : : __rte_unused struct cmdline *cl,
8057 : : __rte_unused void *data)
8058 : : {
8059 : : struct cmd_mac_addr_result *res = parsed_result;
8060 : : int ret;
8061 : :
8062 : 0 : if (strcmp(res->what, "add") == 0)
8063 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
8064 : 0 : else if (strcmp(res->what, "set") == 0)
8065 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
8066 : : &res->address);
8067 : : else
8068 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
8069 : :
8070 : : /* check the return value and print it if is < 0 */
8071 : 0 : if(ret < 0)
8072 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
8073 : :
8074 : 0 : }
8075 : :
8076 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
8077 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
8078 : : "mac_addr");
8079 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
8080 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
8081 : : "add#remove#set");
8082 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
8083 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
8084 : : RTE_UINT16);
8085 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
8086 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8087 : :
8088 : : static cmdline_parse_inst_t cmd_mac_addr = {
8089 : : .f = cmd_mac_addr_parsed,
8090 : : .data = (void *)0,
8091 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
8092 : : "Add/Remove/Set MAC address on port_id",
8093 : : .tokens = {
8094 : : (void *)&cmd_mac_addr_cmd,
8095 : : (void *)&cmd_mac_addr_what,
8096 : : (void *)&cmd_mac_addr_portnum,
8097 : : (void *)&cmd_mac_addr_addr,
8098 : : NULL,
8099 : : },
8100 : : };
8101 : :
8102 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
8103 : : struct cmd_eth_peer_result {
8104 : : cmdline_fixed_string_t set;
8105 : : cmdline_fixed_string_t eth_peer;
8106 : : portid_t port_id;
8107 : : cmdline_fixed_string_t peer_addr;
8108 : : };
8109 : :
8110 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
8111 : : __rte_unused struct cmdline *cl,
8112 : : __rte_unused void *data)
8113 : : {
8114 : : struct cmd_eth_peer_result *res = parsed_result;
8115 : :
8116 : 0 : if (test_done == 0) {
8117 : 0 : fprintf(stderr, "Please stop forwarding first\n");
8118 : 0 : return;
8119 : : }
8120 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
8121 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
8122 : 0 : fwd_config_setup();
8123 : : }
8124 : : }
8125 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
8126 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8127 : : static cmdline_parse_token_string_t cmd_eth_peer =
8128 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8129 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
8130 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8131 : : RTE_UINT16);
8132 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
8133 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8134 : :
8135 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8136 : : .f = cmd_set_eth_peer_parsed,
8137 : : .data = NULL,
8138 : : .help_str = "set eth-peer <port_id> <peer_mac>",
8139 : : .tokens = {
8140 : : (void *)&cmd_eth_peer_set,
8141 : : (void *)&cmd_eth_peer,
8142 : : (void *)&cmd_eth_peer_port_id,
8143 : : (void *)&cmd_eth_peer_addr,
8144 : : NULL,
8145 : : },
8146 : : };
8147 : :
8148 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8149 : : struct cmd_set_xstats_hide_zero_result {
8150 : : cmdline_fixed_string_t keyword;
8151 : : cmdline_fixed_string_t name;
8152 : : cmdline_fixed_string_t on_off;
8153 : : };
8154 : :
8155 : : static void
8156 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8157 : : __rte_unused struct cmdline *cl,
8158 : : __rte_unused void *data)
8159 : : {
8160 : : struct cmd_set_xstats_hide_zero_result *res;
8161 : : uint16_t on_off = 0;
8162 : :
8163 : : res = parsed_result;
8164 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8165 : 0 : set_xstats_hide_zero(on_off);
8166 : 0 : }
8167 : :
8168 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8169 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8170 : : keyword, "set");
8171 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8172 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8173 : : name, "xstats-hide-zero");
8174 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8175 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8176 : : on_off, "on#off");
8177 : :
8178 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8179 : : .f = cmd_set_xstats_hide_zero_parsed,
8180 : : .data = NULL,
8181 : : .help_str = "set xstats-hide-zero on|off",
8182 : : .tokens = {
8183 : : (void *)&cmd_set_xstats_hide_zero_keyword,
8184 : : (void *)&cmd_set_xstats_hide_zero_name,
8185 : : (void *)&cmd_set_xstats_hide_zero_on_off,
8186 : : NULL,
8187 : : },
8188 : : };
8189 : :
8190 : : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
8191 : : struct cmd_set_xstats_show_state_result {
8192 : : cmdline_fixed_string_t keyword;
8193 : : cmdline_fixed_string_t name;
8194 : : uint8_t on_off;
8195 : : };
8196 : : static void
8197 : 0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
8198 : : __rte_unused struct cmdline *cl,
8199 : : __rte_unused void *data)
8200 : : {
8201 : : struct cmd_set_xstats_show_state_result *res = parsed_result;
8202 : 0 : set_xstats_show_state(res->on_off);
8203 : 0 : }
8204 : :
8205 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
8206 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8207 : : keyword, "set");
8208 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
8209 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8210 : : name, "xstats-show-state");
8211 : : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
8212 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
8213 : : on_off);
8214 : :
8215 : : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
8216 : : .f = cmd_set_xstats_show_state_parsed,
8217 : : .data = NULL,
8218 : : .help_str = "set xstats-show-state on|off",
8219 : : .tokens = {
8220 : : (void *)&cmd_set_xstats_show_state_keyword,
8221 : : (void *)&cmd_set_xstats_show_state_name,
8222 : : (void *)&cmd_set_xstats_show_state_on_off,
8223 : : NULL,
8224 : : },
8225 : : };
8226 : :
8227 : : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
8228 : : struct cmd_set_xstats_hide_disabled_result {
8229 : : cmdline_fixed_string_t keyword;
8230 : : cmdline_fixed_string_t name;
8231 : : uint8_t on_off;
8232 : : };
8233 : :
8234 : : static void
8235 : 0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
8236 : : __rte_unused struct cmdline *cl,
8237 : : __rte_unused void *data)
8238 : : {
8239 : : struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
8240 : 0 : set_xstats_hide_disabled(res->on_off);
8241 : 0 : }
8242 : :
8243 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
8244 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8245 : : keyword, "set");
8246 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
8247 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8248 : : name, "xstats-hide-disabled");
8249 : : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
8250 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8251 : : on_off);
8252 : :
8253 : : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
8254 : : .f = cmd_set_xstats_hide_disabled_parsed,
8255 : : .data = NULL,
8256 : : .help_str = "set xstats-hide-disabled on|off",
8257 : : .tokens = {
8258 : : (void *)&cmd_set_xstats_hide_disabled_keyword,
8259 : : (void *)&cmd_set_xstats_hide_disabled_name,
8260 : : (void *)&cmd_set_xstats_hide_disabled_on_off,
8261 : : NULL,
8262 : : },
8263 : : };
8264 : :
8265 : : /* *** enable/disable counter by name *** */
8266 : : struct cmd_operate_set_counter_result {
8267 : : cmdline_fixed_string_t port;
8268 : : portid_t port_id;
8269 : : cmdline_fixed_string_t what;
8270 : : cmdline_multi_string_t counter_name;
8271 : : };
8272 : :
8273 : : static void
8274 : 0 : cmd_operate_set_counter_parsed(void *parsed_result,
8275 : : __rte_unused struct cmdline *cl,
8276 : : __rte_unused void *data)
8277 : : {
8278 : : struct cmd_operate_set_counter_result *res = parsed_result;
8279 : 0 : uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
8280 : :
8281 : 0 : if ((strcmp(res->port, "port") == 0))
8282 : 0 : nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
8283 : 0 : }
8284 : :
8285 : : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
8286 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8287 : : port, "port");
8288 : : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
8289 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
8290 : : port_id, RTE_UINT16);
8291 : : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
8292 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8293 : : what, "enable#disable");
8294 : : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
8295 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8296 : : counter_name, TOKEN_STRING_MULTI);
8297 : :
8298 : : static cmdline_parse_inst_t cmd_operate_set_counter = {
8299 : : .f = cmd_operate_set_counter_parsed,
8300 : : .data = NULL,
8301 : : .help_str = "port (port_id) enable|disable <counter_name>",
8302 : : .tokens = {
8303 : : (void *)&cmd_operate_set_counter_port,
8304 : : (void *)&cmd_operate_set_counter_port_id,
8305 : : (void *)&cmd_operate_set_counter_what,
8306 : : (void *)&cmd_operate_set_counter_name,
8307 : : NULL,
8308 : : },
8309 : : };
8310 : :
8311 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8312 : : struct cmd_set_record_core_cycles_result {
8313 : : cmdline_fixed_string_t keyword;
8314 : : cmdline_fixed_string_t name;
8315 : : cmdline_fixed_string_t on_off;
8316 : : };
8317 : :
8318 : : static void
8319 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
8320 : : __rte_unused struct cmdline *cl,
8321 : : __rte_unused void *data)
8322 : : {
8323 : : struct cmd_set_record_core_cycles_result *res;
8324 : : uint16_t on_off = 0;
8325 : :
8326 : : res = parsed_result;
8327 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8328 : 0 : set_record_core_cycles(on_off);
8329 : 0 : }
8330 : :
8331 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8332 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8333 : : keyword, "set");
8334 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8335 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8336 : : name, "record-core-cycles");
8337 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8338 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8339 : : on_off, "on#off");
8340 : :
8341 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
8342 : : .f = cmd_set_record_core_cycles_parsed,
8343 : : .data = NULL,
8344 : : .help_str = "set record-core-cycles on|off",
8345 : : .tokens = {
8346 : : (void *)&cmd_set_record_core_cycles_keyword,
8347 : : (void *)&cmd_set_record_core_cycles_name,
8348 : : (void *)&cmd_set_record_core_cycles_on_off,
8349 : : NULL,
8350 : : },
8351 : : };
8352 : :
8353 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8354 : : struct cmd_set_record_burst_stats_result {
8355 : : cmdline_fixed_string_t keyword;
8356 : : cmdline_fixed_string_t name;
8357 : : cmdline_fixed_string_t on_off;
8358 : : };
8359 : :
8360 : : static void
8361 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
8362 : : __rte_unused struct cmdline *cl,
8363 : : __rte_unused void *data)
8364 : : {
8365 : : struct cmd_set_record_burst_stats_result *res;
8366 : : uint16_t on_off = 0;
8367 : :
8368 : : res = parsed_result;
8369 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8370 : 0 : set_record_burst_stats(on_off);
8371 : 0 : }
8372 : :
8373 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8374 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8375 : : keyword, "set");
8376 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8377 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8378 : : name, "record-burst-stats");
8379 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8380 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8381 : : on_off, "on#off");
8382 : :
8383 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
8384 : : .f = cmd_set_record_burst_stats_parsed,
8385 : : .data = NULL,
8386 : : .help_str = "set record-burst-stats on|off",
8387 : : .tokens = {
8388 : : (void *)&cmd_set_record_burst_stats_keyword,
8389 : : (void *)&cmd_set_record_burst_stats_name,
8390 : : (void *)&cmd_set_record_burst_stats_on_off,
8391 : : NULL,
8392 : : },
8393 : : };
8394 : :
8395 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
8396 : : struct cmd_set_uc_hash_table {
8397 : : cmdline_fixed_string_t set;
8398 : : cmdline_fixed_string_t port;
8399 : : portid_t port_id;
8400 : : cmdline_fixed_string_t what;
8401 : : struct rte_ether_addr address;
8402 : : cmdline_fixed_string_t mode;
8403 : : };
8404 : :
8405 : : static void
8406 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
8407 : : __rte_unused struct cmdline *cl,
8408 : : __rte_unused void *data)
8409 : : {
8410 : : int ret=0;
8411 : : struct cmd_set_uc_hash_table *res = parsed_result;
8412 : :
8413 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8414 : :
8415 : 0 : if (strcmp(res->what, "uta") == 0)
8416 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8417 : : &res->address,(uint8_t)is_on);
8418 : 0 : if (ret < 0)
8419 : 0 : fprintf(stderr,
8420 : : "bad unicast hash table parameter, return code = %d\n",
8421 : : ret);
8422 : :
8423 : 0 : }
8424 : :
8425 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
8426 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8427 : : set, "set");
8428 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
8429 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8430 : : port, "port");
8431 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8432 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8433 : : port_id, RTE_UINT16);
8434 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
8435 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8436 : : what, "uta");
8437 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8438 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8439 : : address);
8440 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8441 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8442 : : mode, "on#off");
8443 : :
8444 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8445 : : .f = cmd_set_uc_hash_parsed,
8446 : : .data = NULL,
8447 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
8448 : : .tokens = {
8449 : : (void *)&cmd_set_uc_hash_set,
8450 : : (void *)&cmd_set_uc_hash_port,
8451 : : (void *)&cmd_set_uc_hash_portid,
8452 : : (void *)&cmd_set_uc_hash_what,
8453 : : (void *)&cmd_set_uc_hash_mac,
8454 : : (void *)&cmd_set_uc_hash_mode,
8455 : : NULL,
8456 : : },
8457 : : };
8458 : :
8459 : : struct cmd_set_uc_all_hash_table {
8460 : : cmdline_fixed_string_t set;
8461 : : cmdline_fixed_string_t port;
8462 : : portid_t port_id;
8463 : : cmdline_fixed_string_t what;
8464 : : cmdline_fixed_string_t value;
8465 : : cmdline_fixed_string_t mode;
8466 : : };
8467 : :
8468 : : static void
8469 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
8470 : : __rte_unused struct cmdline *cl,
8471 : : __rte_unused void *data)
8472 : : {
8473 : : int ret=0;
8474 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
8475 : :
8476 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8477 : :
8478 : 0 : if ((strcmp(res->what, "uta") == 0) &&
8479 : 0 : (strcmp(res->value, "all") == 0))
8480 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8481 : 0 : if (ret < 0)
8482 : 0 : fprintf(stderr,
8483 : : "bad unicast hash table parameter, return code = %d\n",
8484 : : ret);
8485 : 0 : }
8486 : :
8487 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8488 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8489 : : set, "set");
8490 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8491 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8492 : : port, "port");
8493 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8494 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8495 : : port_id, RTE_UINT16);
8496 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8497 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8498 : : what, "uta");
8499 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8500 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8501 : : value,"all");
8502 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8503 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8504 : : mode, "on#off");
8505 : :
8506 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8507 : : .f = cmd_set_uc_all_hash_parsed,
8508 : : .data = NULL,
8509 : : .help_str = "set port <port_id> uta all on|off",
8510 : : .tokens = {
8511 : : (void *)&cmd_set_uc_all_hash_set,
8512 : : (void *)&cmd_set_uc_all_hash_port,
8513 : : (void *)&cmd_set_uc_all_hash_portid,
8514 : : (void *)&cmd_set_uc_all_hash_what,
8515 : : (void *)&cmd_set_uc_all_hash_value,
8516 : : (void *)&cmd_set_uc_all_hash_mode,
8517 : : NULL,
8518 : : },
8519 : : };
8520 : :
8521 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8522 : : struct cmd_set_vf_traffic {
8523 : : cmdline_fixed_string_t set;
8524 : : cmdline_fixed_string_t port;
8525 : : portid_t port_id;
8526 : : cmdline_fixed_string_t vf;
8527 : : uint8_t vf_id;
8528 : : cmdline_fixed_string_t what;
8529 : : cmdline_fixed_string_t mode;
8530 : : };
8531 : :
8532 : : static void
8533 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
8534 : : __rte_unused struct cmdline *cl,
8535 : : __rte_unused void *data)
8536 : : {
8537 : : struct cmd_set_vf_traffic *res = parsed_result;
8538 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8539 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8540 : :
8541 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8542 : 0 : }
8543 : :
8544 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
8545 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8546 : : set, "set");
8547 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
8548 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8549 : : port, "port");
8550 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8551 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8552 : : port_id, RTE_UINT16);
8553 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8554 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8555 : : vf, "vf");
8556 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8557 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8558 : : vf_id, RTE_UINT8);
8559 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
8560 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8561 : : what, "tx#rx");
8562 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8563 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8564 : : mode, "on#off");
8565 : :
8566 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
8567 : : .f = cmd_set_vf_traffic_parsed,
8568 : : .data = NULL,
8569 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8570 : : .tokens = {
8571 : : (void *)&cmd_setvf_traffic_set,
8572 : : (void *)&cmd_setvf_traffic_port,
8573 : : (void *)&cmd_setvf_traffic_portid,
8574 : : (void *)&cmd_setvf_traffic_vf,
8575 : : (void *)&cmd_setvf_traffic_vfid,
8576 : : (void *)&cmd_setvf_traffic_what,
8577 : : (void *)&cmd_setvf_traffic_mode,
8578 : : NULL,
8579 : : },
8580 : : };
8581 : :
8582 : : /* *** CONFIGURE VF RECEIVE MODE *** */
8583 : : struct cmd_set_vf_rxmode {
8584 : : cmdline_fixed_string_t set;
8585 : : cmdline_fixed_string_t port;
8586 : : portid_t port_id;
8587 : : cmdline_fixed_string_t vf;
8588 : : uint8_t vf_id;
8589 : : cmdline_fixed_string_t what;
8590 : : cmdline_fixed_string_t mode;
8591 : : cmdline_fixed_string_t on;
8592 : : };
8593 : :
8594 : : static void
8595 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
8596 : : __rte_unused struct cmdline *cl,
8597 : : __rte_unused void *data)
8598 : : {
8599 : : int ret = -ENOTSUP;
8600 : : uint16_t vf_rxmode = 0;
8601 : : struct cmd_set_vf_rxmode *res = parsed_result;
8602 : :
8603 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8604 : 0 : if (!strcmp(res->what,"rxmode")) {
8605 : 0 : if (!strcmp(res->mode, "AUPE"))
8606 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
8607 : 0 : else if (!strcmp(res->mode, "ROPE"))
8608 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
8609 : 0 : else if (!strcmp(res->mode, "BAM"))
8610 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
8611 : 0 : else if (!strncmp(res->mode, "MPE",3))
8612 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
8613 : : }
8614 : :
8615 : : RTE_SET_USED(is_on);
8616 : : RTE_SET_USED(vf_rxmode);
8617 : :
8618 : : #ifdef RTE_NET_IXGBE
8619 : : if (ret == -ENOTSUP)
8620 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8621 : : vf_rxmode, (uint8_t)is_on);
8622 : : #endif
8623 : : #ifdef RTE_NET_BNXT
8624 : 0 : if (ret == -ENOTSUP)
8625 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8626 : : vf_rxmode, (uint8_t)is_on);
8627 : : #endif
8628 : 0 : if (ret < 0)
8629 : 0 : fprintf(stderr,
8630 : : "bad VF receive mode parameter, return code = %d\n",
8631 : : ret);
8632 : 0 : }
8633 : :
8634 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8635 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8636 : : set, "set");
8637 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8638 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8639 : : port, "port");
8640 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8641 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8642 : : port_id, RTE_UINT16);
8643 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8644 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8645 : : vf, "vf");
8646 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8647 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8648 : : vf_id, RTE_UINT8);
8649 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8650 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8651 : : what, "rxmode");
8652 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8653 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8654 : : mode, "AUPE#ROPE#BAM#MPE");
8655 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8656 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8657 : : on, "on#off");
8658 : :
8659 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
8660 : : .f = cmd_set_vf_rxmode_parsed,
8661 : : .data = NULL,
8662 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
8663 : : "AUPE|ROPE|BAM|MPE on|off",
8664 : : .tokens = {
8665 : : (void *)&cmd_set_vf_rxmode_set,
8666 : : (void *)&cmd_set_vf_rxmode_port,
8667 : : (void *)&cmd_set_vf_rxmode_portid,
8668 : : (void *)&cmd_set_vf_rxmode_vf,
8669 : : (void *)&cmd_set_vf_rxmode_vfid,
8670 : : (void *)&cmd_set_vf_rxmode_what,
8671 : : (void *)&cmd_set_vf_rxmode_mode,
8672 : : (void *)&cmd_set_vf_rxmode_on,
8673 : : NULL,
8674 : : },
8675 : : };
8676 : :
8677 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8678 : : struct cmd_vf_mac_addr_result {
8679 : : cmdline_fixed_string_t mac_addr_cmd;
8680 : : cmdline_fixed_string_t what;
8681 : : cmdline_fixed_string_t port;
8682 : : uint16_t port_num;
8683 : : cmdline_fixed_string_t vf;
8684 : : uint8_t vf_num;
8685 : : struct rte_ether_addr address;
8686 : : };
8687 : :
8688 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
8689 : : __rte_unused struct cmdline *cl,
8690 : : __rte_unused void *data)
8691 : : {
8692 : : struct cmd_vf_mac_addr_result *res = parsed_result;
8693 : : int ret = -ENOTSUP;
8694 : :
8695 : 0 : if (strcmp(res->what, "add") != 0)
8696 : : return;
8697 : :
8698 : : #ifdef RTE_NET_I40E
8699 : : if (ret == -ENOTSUP)
8700 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8701 : : &res->address);
8702 : : #endif
8703 : : #ifdef RTE_NET_BNXT
8704 : 0 : if (ret == -ENOTSUP)
8705 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8706 : 0 : res->vf_num);
8707 : : #endif
8708 : :
8709 : 0 : if(ret < 0)
8710 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8711 : :
8712 : : }
8713 : :
8714 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8715 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8716 : : mac_addr_cmd,"mac_addr");
8717 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8718 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8719 : : what,"add");
8720 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8721 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8722 : : port,"port");
8723 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8724 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8725 : : port_num, RTE_UINT16);
8726 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8727 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8728 : : vf,"vf");
8729 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8730 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8731 : : vf_num, RTE_UINT8);
8732 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8733 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8734 : : address);
8735 : :
8736 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8737 : : .f = cmd_vf_mac_addr_parsed,
8738 : : .data = (void *)0,
8739 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8740 : : "Add MAC address filtering for a VF on port_id",
8741 : : .tokens = {
8742 : : (void *)&cmd_vf_mac_addr_cmd,
8743 : : (void *)&cmd_vf_mac_addr_what,
8744 : : (void *)&cmd_vf_mac_addr_port,
8745 : : (void *)&cmd_vf_mac_addr_portnum,
8746 : : (void *)&cmd_vf_mac_addr_vf,
8747 : : (void *)&cmd_vf_mac_addr_vfnum,
8748 : : (void *)&cmd_vf_mac_addr_addr,
8749 : : NULL,
8750 : : },
8751 : : };
8752 : :
8753 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8754 : : struct cmd_vf_rx_vlan_filter {
8755 : : cmdline_fixed_string_t rx_vlan;
8756 : : cmdline_fixed_string_t what;
8757 : : uint16_t vlan_id;
8758 : : cmdline_fixed_string_t port;
8759 : : portid_t port_id;
8760 : : cmdline_fixed_string_t vf;
8761 : : uint64_t vf_mask;
8762 : : };
8763 : :
8764 : : static void
8765 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8766 : : __rte_unused struct cmdline *cl,
8767 : : __rte_unused void *data)
8768 : : {
8769 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8770 : : int ret = -ENOTSUP;
8771 : :
8772 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8773 : :
8774 : : #ifdef RTE_NET_IXGBE
8775 : : if (ret == -ENOTSUP)
8776 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8777 : 0 : res->vlan_id, res->vf_mask, is_add);
8778 : : #endif
8779 : : #ifdef RTE_NET_I40E
8780 : 0 : if (ret == -ENOTSUP)
8781 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8782 : 0 : res->vlan_id, res->vf_mask, is_add);
8783 : : #endif
8784 : : #ifdef RTE_NET_BNXT
8785 : 0 : if (ret == -ENOTSUP)
8786 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8787 : 0 : res->vlan_id, res->vf_mask, is_add);
8788 : : #endif
8789 : :
8790 : 0 : switch (ret) {
8791 : : case 0:
8792 : : break;
8793 : 0 : case -EINVAL:
8794 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8795 : 0 : res->vlan_id, res->vf_mask);
8796 : : break;
8797 : 0 : case -ENODEV:
8798 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8799 : : break;
8800 : 0 : case -ENOTSUP:
8801 : 0 : fprintf(stderr, "function not implemented or supported\n");
8802 : : break;
8803 : 0 : default:
8804 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8805 : : }
8806 : 0 : }
8807 : :
8808 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8809 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8810 : : rx_vlan, "rx_vlan");
8811 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8812 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8813 : : what, "add#rm");
8814 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8815 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8816 : : vlan_id, RTE_UINT16);
8817 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8818 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8819 : : port, "port");
8820 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8821 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8822 : : port_id, RTE_UINT16);
8823 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8824 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8825 : : vf, "vf");
8826 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8827 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8828 : : vf_mask, RTE_UINT64);
8829 : :
8830 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8831 : : .f = cmd_vf_rx_vlan_filter_parsed,
8832 : : .data = NULL,
8833 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8834 : : "(vf_mask = hexadecimal VF mask)",
8835 : : .tokens = {
8836 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8837 : : (void *)&cmd_vf_rx_vlan_filter_what,
8838 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8839 : : (void *)&cmd_vf_rx_vlan_filter_port,
8840 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8841 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8842 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8843 : : NULL,
8844 : : },
8845 : : };
8846 : :
8847 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8848 : : struct cmd_queue_rate_limit_result {
8849 : : cmdline_fixed_string_t set;
8850 : : cmdline_fixed_string_t port;
8851 : : uint16_t port_num;
8852 : : cmdline_fixed_string_t queue;
8853 : : uint8_t queue_num;
8854 : : cmdline_fixed_string_t rate;
8855 : : uint32_t rate_num;
8856 : : };
8857 : :
8858 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8859 : : __rte_unused struct cmdline *cl,
8860 : : __rte_unused void *data)
8861 : : {
8862 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8863 : : int ret = 0;
8864 : :
8865 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8866 : 0 : && (strcmp(res->queue, "queue") == 0)
8867 : 0 : && (strcmp(res->rate, "rate") == 0))
8868 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8869 : : res->rate_num);
8870 : 0 : if (ret < 0)
8871 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8872 : : strerror(-ret));
8873 : :
8874 : 0 : }
8875 : :
8876 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8877 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8878 : : set, "set");
8879 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8880 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8881 : : port, "port");
8882 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8883 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8884 : : port_num, RTE_UINT16);
8885 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8886 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8887 : : queue, "queue");
8888 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8889 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8890 : : queue_num, RTE_UINT8);
8891 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8892 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8893 : : rate, "rate");
8894 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8895 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8896 : : rate_num, RTE_UINT32);
8897 : :
8898 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8899 : : .f = cmd_queue_rate_limit_parsed,
8900 : : .data = (void *)0,
8901 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8902 : : "Set rate limit for a queue on port_id",
8903 : : .tokens = {
8904 : : (void *)&cmd_queue_rate_limit_set,
8905 : : (void *)&cmd_queue_rate_limit_port,
8906 : : (void *)&cmd_queue_rate_limit_portnum,
8907 : : (void *)&cmd_queue_rate_limit_queue,
8908 : : (void *)&cmd_queue_rate_limit_queuenum,
8909 : : (void *)&cmd_queue_rate_limit_rate,
8910 : : (void *)&cmd_queue_rate_limit_ratenum,
8911 : : NULL,
8912 : : },
8913 : : };
8914 : :
8915 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8916 : : struct cmd_vf_rate_limit_result {
8917 : : cmdline_fixed_string_t set;
8918 : : cmdline_fixed_string_t port;
8919 : : uint16_t port_num;
8920 : : cmdline_fixed_string_t vf;
8921 : : uint8_t vf_num;
8922 : : cmdline_fixed_string_t rate;
8923 : : uint32_t rate_num;
8924 : : cmdline_fixed_string_t q_msk;
8925 : : uint64_t q_msk_val;
8926 : : };
8927 : :
8928 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
8929 : : __rte_unused struct cmdline *cl,
8930 : : __rte_unused void *data)
8931 : : {
8932 : : struct cmd_vf_rate_limit_result *res = parsed_result;
8933 : : int ret = 0;
8934 : :
8935 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8936 : 0 : && (strcmp(res->vf, "vf") == 0)
8937 : 0 : && (strcmp(res->rate, "rate") == 0)
8938 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
8939 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
8940 : : res->rate_num, res->q_msk_val);
8941 : 0 : if (ret < 0)
8942 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
8943 : : strerror(-ret));
8944 : :
8945 : 0 : }
8946 : :
8947 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8948 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8949 : : set, "set");
8950 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8951 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8952 : : port, "port");
8953 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8954 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8955 : : port_num, RTE_UINT16);
8956 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8957 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8958 : : vf, "vf");
8959 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8960 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8961 : : vf_num, RTE_UINT8);
8962 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8963 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8964 : : rate, "rate");
8965 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8966 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8967 : : rate_num, RTE_UINT32);
8968 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8969 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8970 : : q_msk, "queue_mask");
8971 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8972 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8973 : : q_msk_val, RTE_UINT64);
8974 : :
8975 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
8976 : : .f = cmd_vf_rate_limit_parsed,
8977 : : .data = (void *)0,
8978 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8979 : : "queue_mask <queue_mask_value>: "
8980 : : "Set rate limit for queues of VF on port_id",
8981 : : .tokens = {
8982 : : (void *)&cmd_vf_rate_limit_set,
8983 : : (void *)&cmd_vf_rate_limit_port,
8984 : : (void *)&cmd_vf_rate_limit_portnum,
8985 : : (void *)&cmd_vf_rate_limit_vf,
8986 : : (void *)&cmd_vf_rate_limit_vfnum,
8987 : : (void *)&cmd_vf_rate_limit_rate,
8988 : : (void *)&cmd_vf_rate_limit_ratenum,
8989 : : (void *)&cmd_vf_rate_limit_q_msk,
8990 : : (void *)&cmd_vf_rate_limit_q_msk_val,
8991 : : NULL,
8992 : : },
8993 : : };
8994 : :
8995 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
8996 : : struct cmd_tunnel_udp_config {
8997 : : cmdline_fixed_string_t rx_vxlan_port;
8998 : : cmdline_fixed_string_t what;
8999 : : uint16_t udp_port;
9000 : : portid_t port_id;
9001 : : };
9002 : :
9003 : : static void
9004 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
9005 : : __rte_unused struct cmdline *cl,
9006 : : __rte_unused void *data)
9007 : : {
9008 : : struct cmd_tunnel_udp_config *res = parsed_result;
9009 : : struct rte_eth_udp_tunnel tunnel_udp;
9010 : : int ret;
9011 : :
9012 : 0 : tunnel_udp.udp_port = res->udp_port;
9013 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9014 : :
9015 : 0 : if (!strcmp(res->what, "add"))
9016 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9017 : : &tunnel_udp);
9018 : : else
9019 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9020 : : &tunnel_udp);
9021 : :
9022 : 0 : if (ret < 0)
9023 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
9024 : : strerror(-ret));
9025 : 0 : }
9026 : :
9027 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
9028 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9029 : : rx_vxlan_port, "rx_vxlan_port");
9030 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
9031 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
9032 : : what, "add#rm");
9033 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
9034 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9035 : : udp_port, RTE_UINT16);
9036 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
9037 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
9038 : : port_id, RTE_UINT16);
9039 : :
9040 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
9041 : : .f = cmd_tunnel_udp_config_parsed,
9042 : : .data = (void *)0,
9043 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
9044 : : "Add/Remove a tunneling UDP port filter",
9045 : : .tokens = {
9046 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
9047 : : (void *)&cmd_tunnel_udp_config_what,
9048 : : (void *)&cmd_tunnel_udp_config_udp_port,
9049 : : (void *)&cmd_tunnel_udp_config_port_id,
9050 : : NULL,
9051 : : },
9052 : : };
9053 : :
9054 : : struct cmd_config_tunnel_udp_port {
9055 : : cmdline_fixed_string_t port;
9056 : : cmdline_fixed_string_t config;
9057 : : portid_t port_id;
9058 : : cmdline_fixed_string_t udp_tunnel_port;
9059 : : cmdline_fixed_string_t action;
9060 : : cmdline_fixed_string_t tunnel_type;
9061 : : uint16_t udp_port;
9062 : : };
9063 : :
9064 : : static void
9065 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9066 : : __rte_unused struct cmdline *cl,
9067 : : __rte_unused void *data)
9068 : : {
9069 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
9070 : : struct rte_eth_udp_tunnel tunnel_udp;
9071 : : int ret = 0;
9072 : :
9073 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9074 : 0 : return;
9075 : :
9076 : 0 : tunnel_udp.udp_port = res->udp_port;
9077 : :
9078 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
9079 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9080 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
9081 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9082 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9083 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9084 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
9085 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9086 : : } else {
9087 : 0 : fprintf(stderr, "Invalid tunnel type\n");
9088 : 0 : return;
9089 : : }
9090 : :
9091 : 0 : if (!strcmp(res->action, "add"))
9092 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9093 : : &tunnel_udp);
9094 : : else
9095 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9096 : : &tunnel_udp);
9097 : :
9098 : 0 : if (ret < 0)
9099 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
9100 : : strerror(-ret));
9101 : : }
9102 : :
9103 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9104 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9105 : : "port");
9106 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9107 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9108 : : "config");
9109 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9110 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9111 : : RTE_UINT16);
9112 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9113 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9114 : : udp_tunnel_port,
9115 : : "udp_tunnel_port");
9116 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9117 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9118 : : "add#rm");
9119 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9120 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9121 : : "vxlan#geneve#vxlan-gpe#ecpri");
9122 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9123 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9124 : : RTE_UINT16);
9125 : :
9126 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9127 : : .f = cmd_cfg_tunnel_udp_port_parsed,
9128 : : .data = NULL,
9129 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9130 : : "geneve|vxlan-gpe|ecpri <udp_port>",
9131 : : .tokens = {
9132 : : (void *)&cmd_config_tunnel_udp_port_port,
9133 : : (void *)&cmd_config_tunnel_udp_port_config,
9134 : : (void *)&cmd_config_tunnel_udp_port_port_id,
9135 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9136 : : (void *)&cmd_config_tunnel_udp_port_action,
9137 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9138 : : (void *)&cmd_config_tunnel_udp_port_value,
9139 : : NULL,
9140 : : },
9141 : : };
9142 : :
9143 : : /* ******************************************************************************** */
9144 : :
9145 : : struct cmd_dump_simple_result {
9146 : : cmdline_fixed_string_t dump;
9147 : : cmdline_fixed_string_t obj;
9148 : : cmdline_fixed_string_t name;
9149 : : };
9150 : : static cmdline_parse_token_string_t cmd_dump_simple_dump =
9151 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, dump, "dump");
9152 : : static cmdline_parse_token_string_t cmd_dump_simple_obj =
9153 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9154 : : "physmem#"
9155 : : "socket_mem#"
9156 : : "memzone#"
9157 : : "struct_sizes#"
9158 : : "ring#"
9159 : : "mempool#"
9160 : : "devargs#"
9161 : : "lcores#"
9162 : : "trace#"
9163 : : "log_types"
9164 : : );
9165 : : static cmdline_parse_token_string_t cmd_dump_named_obj =
9166 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, obj,
9167 : : "ring#"
9168 : : "mempool#"
9169 : : );
9170 : : static cmdline_parse_token_string_t cmd_dump_named_name =
9171 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_simple_result, name, NULL);
9172 : :
9173 : : static void
9174 : 0 : dump_struct_sizes(void)
9175 : : {
9176 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9177 : : DUMP_SIZE(struct rte_mbuf);
9178 : : DUMP_SIZE(struct rte_mempool);
9179 : : DUMP_SIZE(struct rte_ring);
9180 : : #undef DUMP_SIZE
9181 : 0 : }
9182 : :
9183 : : /* Dump the socket memory statistics on console */
9184 : : static void
9185 : 0 : dump_socket_mem(FILE *f)
9186 : : {
9187 : : struct rte_malloc_socket_stats socket_stats;
9188 : : unsigned int i;
9189 : : size_t total = 0;
9190 : : size_t alloc = 0;
9191 : : size_t free = 0;
9192 : : unsigned int n_alloc = 0;
9193 : : unsigned int n_free = 0;
9194 : : static size_t last_allocs;
9195 : : static size_t last_total;
9196 : :
9197 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9198 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9199 : 0 : !socket_stats.heap_totalsz_bytes)
9200 : 0 : continue;
9201 : 0 : total += socket_stats.heap_totalsz_bytes;
9202 : 0 : alloc += socket_stats.heap_allocsz_bytes;
9203 : 0 : free += socket_stats.heap_freesz_bytes;
9204 : 0 : n_alloc += socket_stats.alloc_count;
9205 : 0 : n_free += socket_stats.free_count;
9206 : 0 : fprintf(f,
9207 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9208 : : i,
9209 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9210 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9211 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
9212 : 0 : (double)socket_stats.heap_totalsz_bytes,
9213 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9214 : : socket_stats.alloc_count,
9215 : : socket_stats.free_count);
9216 : : }
9217 : 0 : fprintf(f,
9218 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9219 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9220 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
9221 : 0 : (double)free / (1024 * 1024),
9222 : : n_alloc, n_free);
9223 : 0 : if (last_allocs)
9224 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9225 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
9226 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
9227 : 0 : last_allocs = alloc;
9228 : 0 : last_total = total;
9229 : 0 : }
9230 : :
9231 : 0 : static void cmd_dump_simple_parsed(void *parsed_result,
9232 : : struct cmdline *cl,
9233 : : __rte_unused void *data)
9234 : : {
9235 : : struct cmd_dump_simple_result *res = parsed_result;
9236 : :
9237 : 0 : if (strcmp(res->obj, "physmem") == 0)
9238 : 0 : rte_dump_physmem_layout(stdout);
9239 : 0 : else if (strcmp(res->obj, "socket_mem") == 0)
9240 : 0 : dump_socket_mem(stdout);
9241 : 0 : else if (strcmp(res->obj, "memzone") == 0)
9242 : 0 : rte_memzone_dump(stdout);
9243 : 0 : else if (strcmp(res->obj, "struct_sizes") == 0)
9244 : 0 : dump_struct_sizes();
9245 : 0 : else if (strcmp(res->obj, "ring") == 0) {
9246 : 0 : if (strcmp(res->name, "") == 0) {
9247 : 0 : rte_ring_list_dump(stdout);
9248 : : } else {
9249 : : struct rte_ring *r;
9250 : 0 : r = rte_ring_lookup(res->name);
9251 : 0 : if (r == NULL) {
9252 : 0 : cmdline_printf(cl, "Cannot find ring\n");
9253 : 0 : return;
9254 : : }
9255 : 0 : rte_ring_dump(stdout, r);
9256 : : }
9257 : 0 : } else if (strcmp(res->obj, "mempool") == 0) {
9258 : 0 : if (strcmp(res->name, "") == 0) {
9259 : 0 : rte_mempool_list_dump(stdout);
9260 : : } else {
9261 : : struct rte_mempool *mp;
9262 : 0 : mp = rte_mempool_lookup(res->name);
9263 : 0 : if (mp == NULL) {
9264 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
9265 : 0 : return;
9266 : : }
9267 : 0 : rte_mempool_dump(stdout, mp);
9268 : : }
9269 : 0 : } else if (strcmp(res->obj, "devargs") == 0)
9270 : 0 : rte_devargs_dump(stdout);
9271 : 0 : else if (strcmp(res->obj, "lcores") == 0)
9272 : 0 : rte_lcore_dump(stdout);
9273 : 0 : else if (strcmp(res->obj, "trace") == 0)
9274 : : #ifdef RTE_EXEC_ENV_WINDOWS
9275 : : cmdline_printf(cl, "trace is not supported on Windows\n");
9276 : : #else
9277 : 0 : rte_trace_save();
9278 : : #endif
9279 : 0 : else if (strcmp(res->obj, "log_types") == 0)
9280 : 0 : rte_log_dump(stdout);
9281 : : }
9282 : :
9283 : : static cmdline_parse_inst_t cmd_dump_simple = {
9284 : : .f = cmd_dump_simple_parsed,
9285 : : .help_str = "Dump objects",
9286 : : .tokens = {
9287 : : (void *)&cmd_dump_simple_dump,
9288 : : (void *)&cmd_dump_simple_obj,
9289 : : NULL,
9290 : : },
9291 : : };
9292 : : static cmdline_parse_inst_t cmd_dump_named = {
9293 : : .f = cmd_dump_simple_parsed,
9294 : : .help_str = "dump ring|mempool <name>: Dump one ring/mempool",
9295 : : .tokens = {
9296 : : (void *)&cmd_dump_simple_dump,
9297 : : (void *)&cmd_dump_named_obj,
9298 : : (void *)&cmd_dump_named_name,
9299 : : NULL,
9300 : : },
9301 : : };
9302 : :
9303 : : struct cmd_dump_mbuf_history_result {
9304 : : cmdline_fixed_string_t dump;
9305 : : cmdline_fixed_string_t mbuf;
9306 : : cmdline_fixed_string_t history;
9307 : : cmdline_fixed_string_t obj;
9308 : : cmdline_fixed_string_t name;
9309 : : cmdline_fixed_string_t addr;
9310 : : cmdline_fixed_string_t file;
9311 : : };
9312 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_dump =
9313 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, dump, "dump");
9314 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_mbuf =
9315 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, mbuf, "mbuf");
9316 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_history =
9317 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, history, "history");
9318 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_obj =
9319 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, NULL);
9320 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_pool =
9321 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, obj, "pool");
9322 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_name =
9323 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, name, NULL);
9324 : : static cmdline_parse_token_string_t cmd_dump_mbuf_history_file =
9325 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_mbuf_history_result, file, NULL);
9326 : :
9327 : 0 : static void cmd_dump_mbuf_history_parsed(void *parsed_result,
9328 : : struct cmdline *cl,
9329 : : __rte_unused void *data)
9330 : : {
9331 : : struct cmd_dump_mbuf_history_result *res = parsed_result;
9332 : 0 : FILE *out = stdout;
9333 : :
9334 : 0 : if (strcmp(res->file, "") != 0) {
9335 : 0 : out = fopen(res->file, "w");
9336 : 0 : if (out == NULL) {
9337 : 0 : cmdline_printf(cl,
9338 : : "Failed to open file '%s'\n",
9339 : : res->file);
9340 : 0 : return;
9341 : : }
9342 : : }
9343 : :
9344 : 0 : if (strcmp(res->obj, "all") == 0) {
9345 : 0 : rte_mbuf_history_dump_all(out);
9346 : 0 : if (out != stdout)
9347 : 0 : cmdline_printf(cl,
9348 : : "Dump written in '%s'\n",
9349 : 0 : res->file);
9350 : 0 : } else if (strcmp(res->obj, "pool") == 0) {
9351 : 0 : struct rte_mempool *mp = rte_mempool_lookup(res->name);
9352 : 0 : if (mp == NULL) {
9353 : 0 : cmdline_printf(cl,
9354 : : "Failed to find mempool '%s'\n",
9355 : : res->name);
9356 : 0 : return;
9357 : : }
9358 : 0 : rte_mbuf_history_dump_mempool(out, mp);
9359 : 0 : if (out != stdout)
9360 : 0 : cmdline_printf(cl,
9361 : : "Dump for mempool '%s' written in '%s'\n",
9362 : 0 : res->name, res->file);
9363 : : } else {
9364 : : struct rte_mbuf *mbuf;
9365 : : uintptr_t mbuf_addr;
9366 : 0 : if (sscanf(res->obj, "0x%" SCNxPTR, &mbuf_addr) != 1) {
9367 : 0 : cmdline_printf(cl,
9368 : : "Invalid mbuf pointer format. Use 0x<address>\n");
9369 : 0 : return;
9370 : : }
9371 : 0 : mbuf = (struct rte_mbuf *)mbuf_addr;
9372 : 0 : rte_mbuf_history_dump(out, mbuf);
9373 : 0 : if (out != stdout)
9374 : 0 : cmdline_printf(cl,
9375 : : "Dump for mbuf '%p' written in '%s'\n",
9376 : 0 : mbuf, res->file);
9377 : : }
9378 : :
9379 : 0 : if (out != stdout)
9380 : 0 : fclose(out);
9381 : : }
9382 : :
9383 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_stdout = {
9384 : : .f = cmd_dump_mbuf_history_parsed,
9385 : : .help_str = "dump mbuf history all|<address>",
9386 : : .tokens = {
9387 : : (void *)&cmd_dump_mbuf_history_dump,
9388 : : (void *)&cmd_dump_mbuf_history_mbuf,
9389 : : (void *)&cmd_dump_mbuf_history_history,
9390 : : (void *)&cmd_dump_mbuf_history_obj,
9391 : : NULL,
9392 : : },
9393 : : };
9394 : : static cmdline_parse_inst_t cmd_dump_mbuf_history_to_file = {
9395 : : .f = cmd_dump_mbuf_history_parsed,
9396 : : .help_str = "dump mbuf history all|<address> [file]",
9397 : : .tokens = {
9398 : : (void *)&cmd_dump_mbuf_history_dump,
9399 : : (void *)&cmd_dump_mbuf_history_mbuf,
9400 : : (void *)&cmd_dump_mbuf_history_history,
9401 : : (void *)&cmd_dump_mbuf_history_obj,
9402 : : (void *)&cmd_dump_mbuf_history_file,
9403 : : NULL,
9404 : : },
9405 : : };
9406 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_stdout = {
9407 : : .f = cmd_dump_mbuf_history_parsed,
9408 : : .help_str = "dump mbuf pool history <name>",
9409 : : .tokens = {
9410 : : (void *)&cmd_dump_mbuf_history_dump,
9411 : : (void *)&cmd_dump_mbuf_history_mbuf,
9412 : : (void *)&cmd_dump_mbuf_history_pool,
9413 : : (void *)&cmd_dump_mbuf_history_history,
9414 : : (void *)&cmd_dump_mbuf_history_name,
9415 : : NULL,
9416 : : },
9417 : : };
9418 : : static cmdline_parse_inst_t cmd_dump_mbuf_pool_history_to_file = {
9419 : : .f = cmd_dump_mbuf_history_parsed,
9420 : : .help_str = "dump mbuf pool history <name> [file]",
9421 : : .tokens = {
9422 : : (void *)&cmd_dump_mbuf_history_dump,
9423 : : (void *)&cmd_dump_mbuf_history_mbuf,
9424 : : (void *)&cmd_dump_mbuf_history_pool,
9425 : : (void *)&cmd_dump_mbuf_history_history,
9426 : : (void *)&cmd_dump_mbuf_history_name,
9427 : : (void *)&cmd_dump_mbuf_history_file,
9428 : : NULL,
9429 : : },
9430 : : };
9431 : :
9432 : : /* *** Filters Control *** */
9433 : :
9434 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9435 : : do { \
9436 : : if ((ip_addr).family == AF_INET) \
9437 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
9438 : : else { \
9439 : : fprintf(stderr, "invalid parameter.\n"); \
9440 : : return; \
9441 : : } \
9442 : : } while (0)
9443 : :
9444 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9445 : : do { \
9446 : : if ((ip_addr).family == AF_INET6) \
9447 : : ip = ip_addr.addr.ipv6; \
9448 : : else { \
9449 : : fprintf(stderr, "invalid parameter.\n"); \
9450 : : return; \
9451 : : } \
9452 : : } while (0)
9453 : :
9454 : : /* Generic flow interface command. */
9455 : : extern cmdline_parse_inst_t cmd_flow;
9456 : :
9457 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9458 : : struct cmd_mcast_addr_result {
9459 : : cmdline_fixed_string_t mcast_addr_cmd;
9460 : : cmdline_fixed_string_t what;
9461 : : uint16_t port_num;
9462 : : struct rte_ether_addr mc_addr;
9463 : : };
9464 : :
9465 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
9466 : : __rte_unused struct cmdline *cl,
9467 : : __rte_unused void *data)
9468 : : {
9469 : : struct cmd_mcast_addr_result *res = parsed_result;
9470 : :
9471 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
9472 : 0 : fprintf(stderr,
9473 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
9474 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
9475 : 0 : return;
9476 : : }
9477 : 0 : if (strcmp(res->what, "add") == 0)
9478 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
9479 : : else
9480 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
9481 : : }
9482 : :
9483 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9484 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9485 : : mcast_addr_cmd, "mcast_addr");
9486 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
9487 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9488 : : "add#remove");
9489 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9490 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9491 : : RTE_UINT16);
9492 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9493 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9494 : :
9495 : : static cmdline_parse_inst_t cmd_mcast_addr = {
9496 : : .f = cmd_mcast_addr_parsed,
9497 : : .data = (void *)0,
9498 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
9499 : : "Add/Remove multicast MAC address on port_id",
9500 : : .tokens = {
9501 : : (void *)&cmd_mcast_addr_cmd,
9502 : : (void *)&cmd_mcast_addr_what,
9503 : : (void *)&cmd_mcast_addr_portnum,
9504 : : (void *)&cmd_mcast_addr_addr,
9505 : : NULL,
9506 : : },
9507 : : };
9508 : :
9509 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
9510 : : struct cmd_mcast_addr_flush_result {
9511 : : cmdline_fixed_string_t mcast_addr_cmd;
9512 : : cmdline_fixed_string_t what;
9513 : : uint16_t port_num;
9514 : : };
9515 : :
9516 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
9517 : : __rte_unused struct cmdline *cl,
9518 : : __rte_unused void *data)
9519 : : {
9520 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
9521 : :
9522 : 0 : mcast_addr_flush(res->port_num);
9523 : 0 : }
9524 : :
9525 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
9526 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9527 : : mcast_addr_cmd, "mcast_addr");
9528 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
9529 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9530 : : "flush");
9531 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
9532 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9533 : : RTE_UINT16);
9534 : :
9535 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
9536 : : .f = cmd_mcast_addr_flush_parsed,
9537 : : .data = (void *)0,
9538 : : .help_str = "mcast_addr flush <port_id> : "
9539 : : "flush all multicast MAC addresses on port_id",
9540 : : .tokens = {
9541 : : (void *)&cmd_mcast_addr_flush_cmd,
9542 : : (void *)&cmd_mcast_addr_flush_what,
9543 : : (void *)&cmd_mcast_addr_flush_portnum,
9544 : : NULL,
9545 : : },
9546 : : };
9547 : :
9548 : : /* vf vlan anti spoof configuration */
9549 : :
9550 : : /* Common result structure for vf vlan anti spoof */
9551 : : struct cmd_vf_vlan_anti_spoof_result {
9552 : : cmdline_fixed_string_t set;
9553 : : cmdline_fixed_string_t vf;
9554 : : cmdline_fixed_string_t vlan;
9555 : : cmdline_fixed_string_t antispoof;
9556 : : portid_t port_id;
9557 : : uint32_t vf_id;
9558 : : cmdline_fixed_string_t on_off;
9559 : : };
9560 : :
9561 : : /* Common CLI fields for vf vlan anti spoof enable disable */
9562 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
9563 : : TOKEN_STRING_INITIALIZER
9564 : : (struct cmd_vf_vlan_anti_spoof_result,
9565 : : set, "set");
9566 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
9567 : : TOKEN_STRING_INITIALIZER
9568 : : (struct cmd_vf_vlan_anti_spoof_result,
9569 : : vf, "vf");
9570 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
9571 : : TOKEN_STRING_INITIALIZER
9572 : : (struct cmd_vf_vlan_anti_spoof_result,
9573 : : vlan, "vlan");
9574 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
9575 : : TOKEN_STRING_INITIALIZER
9576 : : (struct cmd_vf_vlan_anti_spoof_result,
9577 : : antispoof, "antispoof");
9578 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
9579 : : TOKEN_NUM_INITIALIZER
9580 : : (struct cmd_vf_vlan_anti_spoof_result,
9581 : : port_id, RTE_UINT16);
9582 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
9583 : : TOKEN_NUM_INITIALIZER
9584 : : (struct cmd_vf_vlan_anti_spoof_result,
9585 : : vf_id, RTE_UINT32);
9586 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
9587 : : TOKEN_STRING_INITIALIZER
9588 : : (struct cmd_vf_vlan_anti_spoof_result,
9589 : : on_off, "on#off");
9590 : :
9591 : : static void
9592 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
9593 : : void *parsed_result,
9594 : : __rte_unused struct cmdline *cl,
9595 : : __rte_unused void *data)
9596 : : {
9597 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
9598 : : int ret = -ENOTSUP;
9599 : :
9600 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9601 : :
9602 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9603 : : return;
9604 : :
9605 : : #ifdef RTE_NET_IXGBE
9606 : : if (ret == -ENOTSUP)
9607 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
9608 : 0 : res->vf_id, is_on);
9609 : : #endif
9610 : : #ifdef RTE_NET_I40E
9611 : 0 : if (ret == -ENOTSUP)
9612 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
9613 : 0 : res->vf_id, is_on);
9614 : : #endif
9615 : : #ifdef RTE_NET_BNXT
9616 : 0 : if (ret == -ENOTSUP)
9617 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
9618 : 0 : res->vf_id, is_on);
9619 : : #endif
9620 : :
9621 : 0 : switch (ret) {
9622 : : case 0:
9623 : : break;
9624 : 0 : case -EINVAL:
9625 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
9626 : : break;
9627 : 0 : case -ENODEV:
9628 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9629 : : break;
9630 : 0 : case -ENOTSUP:
9631 : 0 : fprintf(stderr, "function not implemented\n");
9632 : : break;
9633 : 0 : default:
9634 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9635 : : }
9636 : : }
9637 : :
9638 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
9639 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
9640 : : .data = NULL,
9641 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
9642 : : .tokens = {
9643 : : (void *)&cmd_vf_vlan_anti_spoof_set,
9644 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
9645 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
9646 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
9647 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
9648 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
9649 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
9650 : : NULL,
9651 : : },
9652 : : };
9653 : :
9654 : : /* vf mac anti spoof configuration */
9655 : :
9656 : : /* Common result structure for vf mac anti spoof */
9657 : : struct cmd_vf_mac_anti_spoof_result {
9658 : : cmdline_fixed_string_t set;
9659 : : cmdline_fixed_string_t vf;
9660 : : cmdline_fixed_string_t mac;
9661 : : cmdline_fixed_string_t antispoof;
9662 : : portid_t port_id;
9663 : : uint32_t vf_id;
9664 : : cmdline_fixed_string_t on_off;
9665 : : };
9666 : :
9667 : : /* Common CLI fields for vf mac anti spoof enable disable */
9668 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
9669 : : TOKEN_STRING_INITIALIZER
9670 : : (struct cmd_vf_mac_anti_spoof_result,
9671 : : set, "set");
9672 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
9673 : : TOKEN_STRING_INITIALIZER
9674 : : (struct cmd_vf_mac_anti_spoof_result,
9675 : : vf, "vf");
9676 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
9677 : : TOKEN_STRING_INITIALIZER
9678 : : (struct cmd_vf_mac_anti_spoof_result,
9679 : : mac, "mac");
9680 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
9681 : : TOKEN_STRING_INITIALIZER
9682 : : (struct cmd_vf_mac_anti_spoof_result,
9683 : : antispoof, "antispoof");
9684 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
9685 : : TOKEN_NUM_INITIALIZER
9686 : : (struct cmd_vf_mac_anti_spoof_result,
9687 : : port_id, RTE_UINT16);
9688 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
9689 : : TOKEN_NUM_INITIALIZER
9690 : : (struct cmd_vf_mac_anti_spoof_result,
9691 : : vf_id, RTE_UINT32);
9692 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
9693 : : TOKEN_STRING_INITIALIZER
9694 : : (struct cmd_vf_mac_anti_spoof_result,
9695 : : on_off, "on#off");
9696 : :
9697 : : static void
9698 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
9699 : : void *parsed_result,
9700 : : __rte_unused struct cmdline *cl,
9701 : : __rte_unused void *data)
9702 : : {
9703 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
9704 : : int ret = -ENOTSUP;
9705 : :
9706 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9707 : :
9708 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9709 : : return;
9710 : :
9711 : : #ifdef RTE_NET_IXGBE
9712 : : if (ret == -ENOTSUP)
9713 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
9714 : 0 : res->vf_id, is_on);
9715 : : #endif
9716 : : #ifdef RTE_NET_I40E
9717 : 0 : if (ret == -ENOTSUP)
9718 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
9719 : 0 : res->vf_id, is_on);
9720 : : #endif
9721 : : #ifdef RTE_NET_BNXT
9722 : 0 : if (ret == -ENOTSUP)
9723 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
9724 : 0 : res->vf_id, is_on);
9725 : : #endif
9726 : :
9727 : 0 : switch (ret) {
9728 : : case 0:
9729 : : break;
9730 : 0 : case -EINVAL:
9731 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9732 : : res->vf_id, is_on);
9733 : : break;
9734 : 0 : case -ENODEV:
9735 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9736 : : break;
9737 : 0 : case -ENOTSUP:
9738 : 0 : fprintf(stderr, "function not implemented\n");
9739 : : break;
9740 : 0 : default:
9741 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9742 : : }
9743 : : }
9744 : :
9745 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
9746 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
9747 : : .data = NULL,
9748 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
9749 : : .tokens = {
9750 : : (void *)&cmd_vf_mac_anti_spoof_set,
9751 : : (void *)&cmd_vf_mac_anti_spoof_vf,
9752 : : (void *)&cmd_vf_mac_anti_spoof_mac,
9753 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
9754 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
9755 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
9756 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
9757 : : NULL,
9758 : : },
9759 : : };
9760 : :
9761 : : /* vf vlan strip queue configuration */
9762 : :
9763 : : /* Common result structure for vf mac anti spoof */
9764 : : struct cmd_vf_vlan_stripq_result {
9765 : : cmdline_fixed_string_t set;
9766 : : cmdline_fixed_string_t vf;
9767 : : cmdline_fixed_string_t vlan;
9768 : : cmdline_fixed_string_t stripq;
9769 : : portid_t port_id;
9770 : : uint16_t vf_id;
9771 : : cmdline_fixed_string_t on_off;
9772 : : };
9773 : :
9774 : : /* Common CLI fields for vf vlan strip enable disable */
9775 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
9776 : : TOKEN_STRING_INITIALIZER
9777 : : (struct cmd_vf_vlan_stripq_result,
9778 : : set, "set");
9779 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
9780 : : TOKEN_STRING_INITIALIZER
9781 : : (struct cmd_vf_vlan_stripq_result,
9782 : : vf, "vf");
9783 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
9784 : : TOKEN_STRING_INITIALIZER
9785 : : (struct cmd_vf_vlan_stripq_result,
9786 : : vlan, "vlan");
9787 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
9788 : : TOKEN_STRING_INITIALIZER
9789 : : (struct cmd_vf_vlan_stripq_result,
9790 : : stripq, "stripq");
9791 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
9792 : : TOKEN_NUM_INITIALIZER
9793 : : (struct cmd_vf_vlan_stripq_result,
9794 : : port_id, RTE_UINT16);
9795 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
9796 : : TOKEN_NUM_INITIALIZER
9797 : : (struct cmd_vf_vlan_stripq_result,
9798 : : vf_id, RTE_UINT16);
9799 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
9800 : : TOKEN_STRING_INITIALIZER
9801 : : (struct cmd_vf_vlan_stripq_result,
9802 : : on_off, "on#off");
9803 : :
9804 : : static void
9805 : 0 : cmd_set_vf_vlan_stripq_parsed(
9806 : : void *parsed_result,
9807 : : __rte_unused struct cmdline *cl,
9808 : : __rte_unused void *data)
9809 : : {
9810 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
9811 : : int ret = -ENOTSUP;
9812 : :
9813 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9814 : :
9815 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9816 : : return;
9817 : :
9818 : : #ifdef RTE_NET_IXGBE
9819 : : if (ret == -ENOTSUP)
9820 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
9821 : 0 : res->vf_id, is_on);
9822 : : #endif
9823 : : #ifdef RTE_NET_I40E
9824 : 0 : if (ret == -ENOTSUP)
9825 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
9826 : 0 : res->vf_id, is_on);
9827 : : #endif
9828 : : #ifdef RTE_NET_BNXT
9829 : 0 : if (ret == -ENOTSUP)
9830 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
9831 : 0 : res->vf_id, is_on);
9832 : : #endif
9833 : :
9834 : 0 : switch (ret) {
9835 : : case 0:
9836 : : break;
9837 : 0 : case -EINVAL:
9838 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9839 : 0 : res->vf_id, is_on);
9840 : : break;
9841 : 0 : case -ENODEV:
9842 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9843 : : break;
9844 : 0 : case -ENOTSUP:
9845 : 0 : fprintf(stderr, "function not implemented\n");
9846 : : break;
9847 : 0 : default:
9848 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9849 : : }
9850 : : }
9851 : :
9852 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
9853 : : .f = cmd_set_vf_vlan_stripq_parsed,
9854 : : .data = NULL,
9855 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
9856 : : .tokens = {
9857 : : (void *)&cmd_vf_vlan_stripq_set,
9858 : : (void *)&cmd_vf_vlan_stripq_vf,
9859 : : (void *)&cmd_vf_vlan_stripq_vlan,
9860 : : (void *)&cmd_vf_vlan_stripq_stripq,
9861 : : (void *)&cmd_vf_vlan_stripq_port_id,
9862 : : (void *)&cmd_vf_vlan_stripq_vf_id,
9863 : : (void *)&cmd_vf_vlan_stripq_on_off,
9864 : : NULL,
9865 : : },
9866 : : };
9867 : :
9868 : : /* vf vlan insert configuration */
9869 : :
9870 : : /* Common result structure for vf vlan insert */
9871 : : struct cmd_vf_vlan_insert_result {
9872 : : cmdline_fixed_string_t set;
9873 : : cmdline_fixed_string_t vf;
9874 : : cmdline_fixed_string_t vlan;
9875 : : cmdline_fixed_string_t insert;
9876 : : portid_t port_id;
9877 : : uint16_t vf_id;
9878 : : uint16_t vlan_id;
9879 : : };
9880 : :
9881 : : /* Common CLI fields for vf vlan insert enable disable */
9882 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
9883 : : TOKEN_STRING_INITIALIZER
9884 : : (struct cmd_vf_vlan_insert_result,
9885 : : set, "set");
9886 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
9887 : : TOKEN_STRING_INITIALIZER
9888 : : (struct cmd_vf_vlan_insert_result,
9889 : : vf, "vf");
9890 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
9891 : : TOKEN_STRING_INITIALIZER
9892 : : (struct cmd_vf_vlan_insert_result,
9893 : : vlan, "vlan");
9894 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
9895 : : TOKEN_STRING_INITIALIZER
9896 : : (struct cmd_vf_vlan_insert_result,
9897 : : insert, "insert");
9898 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
9899 : : TOKEN_NUM_INITIALIZER
9900 : : (struct cmd_vf_vlan_insert_result,
9901 : : port_id, RTE_UINT16);
9902 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
9903 : : TOKEN_NUM_INITIALIZER
9904 : : (struct cmd_vf_vlan_insert_result,
9905 : : vf_id, RTE_UINT16);
9906 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
9907 : : TOKEN_NUM_INITIALIZER
9908 : : (struct cmd_vf_vlan_insert_result,
9909 : : vlan_id, RTE_UINT16);
9910 : :
9911 : : static void
9912 : 0 : cmd_set_vf_vlan_insert_parsed(
9913 : : void *parsed_result,
9914 : : __rte_unused struct cmdline *cl,
9915 : : __rte_unused void *data)
9916 : : {
9917 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
9918 : : int ret = -ENOTSUP;
9919 : :
9920 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9921 : : return;
9922 : :
9923 : : #ifdef RTE_NET_IXGBE
9924 : : if (ret == -ENOTSUP)
9925 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
9926 : 0 : res->vlan_id);
9927 : : #endif
9928 : : #ifdef RTE_NET_I40E
9929 : 0 : if (ret == -ENOTSUP)
9930 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
9931 : 0 : res->vlan_id);
9932 : : #endif
9933 : : #ifdef RTE_NET_BNXT
9934 : 0 : if (ret == -ENOTSUP)
9935 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
9936 : 0 : res->vlan_id);
9937 : : #endif
9938 : :
9939 : 0 : switch (ret) {
9940 : : case 0:
9941 : : break;
9942 : 0 : case -EINVAL:
9943 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
9944 : 0 : res->vf_id, res->vlan_id);
9945 : : break;
9946 : 0 : case -ENODEV:
9947 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9948 : : break;
9949 : 0 : case -ENOTSUP:
9950 : 0 : fprintf(stderr, "function not implemented\n");
9951 : : break;
9952 : 0 : default:
9953 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9954 : : }
9955 : : }
9956 : :
9957 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
9958 : : .f = cmd_set_vf_vlan_insert_parsed,
9959 : : .data = NULL,
9960 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
9961 : : .tokens = {
9962 : : (void *)&cmd_vf_vlan_insert_set,
9963 : : (void *)&cmd_vf_vlan_insert_vf,
9964 : : (void *)&cmd_vf_vlan_insert_vlan,
9965 : : (void *)&cmd_vf_vlan_insert_insert,
9966 : : (void *)&cmd_vf_vlan_insert_port_id,
9967 : : (void *)&cmd_vf_vlan_insert_vf_id,
9968 : : (void *)&cmd_vf_vlan_insert_vlan_id,
9969 : : NULL,
9970 : : },
9971 : : };
9972 : :
9973 : : /* tx loopback configuration */
9974 : :
9975 : : /* Common result structure for tx loopback */
9976 : : struct cmd_tx_loopback_result {
9977 : : cmdline_fixed_string_t set;
9978 : : cmdline_fixed_string_t tx;
9979 : : cmdline_fixed_string_t loopback;
9980 : : portid_t port_id;
9981 : : cmdline_fixed_string_t on_off;
9982 : : };
9983 : :
9984 : : /* Common CLI fields for tx loopback enable disable */
9985 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
9986 : : TOKEN_STRING_INITIALIZER
9987 : : (struct cmd_tx_loopback_result,
9988 : : set, "set");
9989 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
9990 : : TOKEN_STRING_INITIALIZER
9991 : : (struct cmd_tx_loopback_result,
9992 : : tx, "tx");
9993 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
9994 : : TOKEN_STRING_INITIALIZER
9995 : : (struct cmd_tx_loopback_result,
9996 : : loopback, "loopback");
9997 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
9998 : : TOKEN_NUM_INITIALIZER
9999 : : (struct cmd_tx_loopback_result,
10000 : : port_id, RTE_UINT16);
10001 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
10002 : : TOKEN_STRING_INITIALIZER
10003 : : (struct cmd_tx_loopback_result,
10004 : : on_off, "on#off");
10005 : :
10006 : : static void
10007 : 0 : cmd_set_tx_loopback_parsed(
10008 : : void *parsed_result,
10009 : : __rte_unused struct cmdline *cl,
10010 : : __rte_unused void *data)
10011 : : {
10012 : : struct cmd_tx_loopback_result *res = parsed_result;
10013 : : int ret = -ENOTSUP;
10014 : :
10015 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10016 : :
10017 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10018 : : return;
10019 : :
10020 : : #ifdef RTE_NET_IXGBE
10021 : : if (ret == -ENOTSUP)
10022 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
10023 : : #endif
10024 : : #ifdef RTE_NET_I40E
10025 : 0 : if (ret == -ENOTSUP)
10026 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
10027 : : #endif
10028 : : #ifdef RTE_NET_BNXT
10029 : 0 : if (ret == -ENOTSUP)
10030 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
10031 : : #endif
10032 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
10033 : 0 : if (ret == -ENOTSUP)
10034 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
10035 : : #endif
10036 : :
10037 : 0 : switch (ret) {
10038 : : case 0:
10039 : : break;
10040 : 0 : case -EINVAL:
10041 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10042 : : break;
10043 : 0 : case -ENODEV:
10044 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10045 : : break;
10046 : 0 : case -ENOTSUP:
10047 : 0 : fprintf(stderr, "function not implemented\n");
10048 : : break;
10049 : 0 : default:
10050 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10051 : : }
10052 : : }
10053 : :
10054 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
10055 : : .f = cmd_set_tx_loopback_parsed,
10056 : : .data = NULL,
10057 : : .help_str = "set tx loopback <port_id> on|off",
10058 : : .tokens = {
10059 : : (void *)&cmd_tx_loopback_set,
10060 : : (void *)&cmd_tx_loopback_tx,
10061 : : (void *)&cmd_tx_loopback_loopback,
10062 : : (void *)&cmd_tx_loopback_port_id,
10063 : : (void *)&cmd_tx_loopback_on_off,
10064 : : NULL,
10065 : : },
10066 : : };
10067 : :
10068 : : /* all queues drop enable configuration */
10069 : :
10070 : : /* Common result structure for all queues drop enable */
10071 : : struct cmd_all_queues_drop_en_result {
10072 : : cmdline_fixed_string_t set;
10073 : : cmdline_fixed_string_t all;
10074 : : cmdline_fixed_string_t queues;
10075 : : cmdline_fixed_string_t drop;
10076 : : portid_t port_id;
10077 : : cmdline_fixed_string_t on_off;
10078 : : };
10079 : :
10080 : : /* Common CLI fields for tx loopback enable disable */
10081 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
10082 : : TOKEN_STRING_INITIALIZER
10083 : : (struct cmd_all_queues_drop_en_result,
10084 : : set, "set");
10085 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
10086 : : TOKEN_STRING_INITIALIZER
10087 : : (struct cmd_all_queues_drop_en_result,
10088 : : all, "all");
10089 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
10090 : : TOKEN_STRING_INITIALIZER
10091 : : (struct cmd_all_queues_drop_en_result,
10092 : : queues, "queues");
10093 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
10094 : : TOKEN_STRING_INITIALIZER
10095 : : (struct cmd_all_queues_drop_en_result,
10096 : : drop, "drop");
10097 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
10098 : : TOKEN_NUM_INITIALIZER
10099 : : (struct cmd_all_queues_drop_en_result,
10100 : : port_id, RTE_UINT16);
10101 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
10102 : : TOKEN_STRING_INITIALIZER
10103 : : (struct cmd_all_queues_drop_en_result,
10104 : : on_off, "on#off");
10105 : :
10106 : : static void
10107 : 0 : cmd_set_all_queues_drop_en_parsed(
10108 : : void *parsed_result,
10109 : : __rte_unused struct cmdline *cl,
10110 : : __rte_unused void *data)
10111 : : {
10112 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
10113 : : int ret = -ENOTSUP;
10114 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
10115 : :
10116 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10117 : : return;
10118 : :
10119 : : #ifdef RTE_NET_IXGBE
10120 : : if (ret == -ENOTSUP)
10121 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
10122 : : #endif
10123 : : #ifdef RTE_NET_BNXT
10124 : 0 : if (ret == -ENOTSUP)
10125 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
10126 : : #endif
10127 : 0 : switch (ret) {
10128 : : case 0:
10129 : : break;
10130 : 0 : case -EINVAL:
10131 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
10132 : : break;
10133 : 0 : case -ENODEV:
10134 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10135 : : break;
10136 : 0 : case -ENOTSUP:
10137 : 0 : fprintf(stderr, "function not implemented\n");
10138 : : break;
10139 : 0 : default:
10140 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10141 : : }
10142 : : }
10143 : :
10144 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
10145 : : .f = cmd_set_all_queues_drop_en_parsed,
10146 : : .data = NULL,
10147 : : .help_str = "set all queues drop <port_id> on|off",
10148 : : .tokens = {
10149 : : (void *)&cmd_all_queues_drop_en_set,
10150 : : (void *)&cmd_all_queues_drop_en_all,
10151 : : (void *)&cmd_all_queues_drop_en_queues,
10152 : : (void *)&cmd_all_queues_drop_en_drop,
10153 : : (void *)&cmd_all_queues_drop_en_port_id,
10154 : : (void *)&cmd_all_queues_drop_en_on_off,
10155 : : NULL,
10156 : : },
10157 : : };
10158 : :
10159 : : /* vf mac address configuration */
10160 : :
10161 : : /* Common result structure for vf mac address */
10162 : : struct cmd_set_vf_mac_addr_result {
10163 : : cmdline_fixed_string_t set;
10164 : : cmdline_fixed_string_t vf;
10165 : : cmdline_fixed_string_t mac;
10166 : : cmdline_fixed_string_t addr;
10167 : : portid_t port_id;
10168 : : uint16_t vf_id;
10169 : : struct rte_ether_addr mac_addr;
10170 : :
10171 : : };
10172 : :
10173 : : /* Common CLI fields for vf split drop enable disable */
10174 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
10175 : : TOKEN_STRING_INITIALIZER
10176 : : (struct cmd_set_vf_mac_addr_result,
10177 : : set, "set");
10178 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
10179 : : TOKEN_STRING_INITIALIZER
10180 : : (struct cmd_set_vf_mac_addr_result,
10181 : : vf, "vf");
10182 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
10183 : : TOKEN_STRING_INITIALIZER
10184 : : (struct cmd_set_vf_mac_addr_result,
10185 : : mac, "mac");
10186 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
10187 : : TOKEN_STRING_INITIALIZER
10188 : : (struct cmd_set_vf_mac_addr_result,
10189 : : addr, "addr");
10190 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
10191 : : TOKEN_NUM_INITIALIZER
10192 : : (struct cmd_set_vf_mac_addr_result,
10193 : : port_id, RTE_UINT16);
10194 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
10195 : : TOKEN_NUM_INITIALIZER
10196 : : (struct cmd_set_vf_mac_addr_result,
10197 : : vf_id, RTE_UINT16);
10198 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
10199 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
10200 : : mac_addr);
10201 : :
10202 : : static void
10203 : 0 : cmd_set_vf_mac_addr_parsed(
10204 : : void *parsed_result,
10205 : : __rte_unused struct cmdline *cl,
10206 : : __rte_unused void *data)
10207 : : {
10208 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
10209 : : int ret = -ENOTSUP;
10210 : :
10211 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10212 : : return;
10213 : :
10214 : : #ifdef RTE_NET_IXGBE
10215 : : if (ret == -ENOTSUP)
10216 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
10217 : : &res->mac_addr);
10218 : : #endif
10219 : : #ifdef RTE_NET_I40E
10220 : 0 : if (ret == -ENOTSUP)
10221 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
10222 : : &res->mac_addr);
10223 : : #endif
10224 : : #ifdef RTE_NET_BNXT
10225 : 0 : if (ret == -ENOTSUP)
10226 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
10227 : : &res->mac_addr);
10228 : : #endif
10229 : :
10230 : 0 : switch (ret) {
10231 : : case 0:
10232 : : break;
10233 : 0 : case -EINVAL:
10234 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
10235 : : break;
10236 : 0 : case -ENODEV:
10237 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10238 : : break;
10239 : 0 : case -ENOTSUP:
10240 : 0 : fprintf(stderr, "function not implemented\n");
10241 : : break;
10242 : 0 : default:
10243 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10244 : : }
10245 : : }
10246 : :
10247 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
10248 : : .f = cmd_set_vf_mac_addr_parsed,
10249 : : .data = NULL,
10250 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
10251 : : .tokens = {
10252 : : (void *)&cmd_set_vf_mac_addr_set,
10253 : : (void *)&cmd_set_vf_mac_addr_vf,
10254 : : (void *)&cmd_set_vf_mac_addr_mac,
10255 : : (void *)&cmd_set_vf_mac_addr_addr,
10256 : : (void *)&cmd_set_vf_mac_addr_port_id,
10257 : : (void *)&cmd_set_vf_mac_addr_vf_id,
10258 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
10259 : : NULL,
10260 : : },
10261 : : };
10262 : :
10263 : : /** Set VXLAN encapsulation details */
10264 : : struct cmd_set_vxlan_result {
10265 : : cmdline_fixed_string_t set;
10266 : : cmdline_fixed_string_t vxlan;
10267 : : cmdline_fixed_string_t pos_token;
10268 : : cmdline_fixed_string_t ip_version;
10269 : : uint32_t vlan_present:1;
10270 : : uint32_t vni;
10271 : : uint16_t udp_src;
10272 : : uint16_t udp_dst;
10273 : : cmdline_ipaddr_t ip_src;
10274 : : cmdline_ipaddr_t ip_dst;
10275 : : uint16_t tci;
10276 : : uint8_t tos;
10277 : : uint8_t ttl;
10278 : : struct rte_ether_addr eth_src;
10279 : : struct rte_ether_addr eth_dst;
10280 : : };
10281 : :
10282 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
10283 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
10284 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
10285 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
10286 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
10287 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10288 : : "vxlan-tos-ttl");
10289 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
10290 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10291 : : "vxlan-with-vlan");
10292 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
10293 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10294 : : "ip-version");
10295 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
10296 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
10297 : : "ipv4#ipv6");
10298 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
10299 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10300 : : "vni");
10301 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
10302 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
10303 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
10304 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10305 : : "udp-src");
10306 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
10307 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
10308 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
10309 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10310 : : "udp-dst");
10311 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
10312 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
10313 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
10314 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10315 : : "ip-tos");
10316 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
10317 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
10318 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
10319 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10320 : : "ip-ttl");
10321 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
10322 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
10323 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
10324 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10325 : : "ip-src");
10326 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
10327 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
10328 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
10329 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10330 : : "ip-dst");
10331 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
10332 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
10333 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
10334 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10335 : : "vlan-tci");
10336 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
10337 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
10338 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
10339 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10340 : : "eth-src");
10341 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
10342 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
10343 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
10344 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10345 : : "eth-dst");
10346 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
10347 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
10348 : :
10349 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
10350 : : __rte_unused struct cmdline *cl,
10351 : : __rte_unused void *data)
10352 : : {
10353 : : struct cmd_set_vxlan_result *res = parsed_result;
10354 : : union {
10355 : : uint32_t vxlan_id;
10356 : : uint8_t vni[4];
10357 : 0 : } id = {
10358 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
10359 : : };
10360 : :
10361 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
10362 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
10363 : 0 : vxlan_encap_conf.select_vlan = 0;
10364 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
10365 : 0 : vxlan_encap_conf.select_vlan = 1;
10366 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
10367 : 0 : vxlan_encap_conf.select_vlan = 0;
10368 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
10369 : : }
10370 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10371 : 0 : vxlan_encap_conf.select_ipv4 = 1;
10372 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10373 : 0 : vxlan_encap_conf.select_ipv4 = 0;
10374 : : else
10375 : 0 : return;
10376 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
10377 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10378 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10379 : 0 : vxlan_encap_conf.ip_tos = res->tos;
10380 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
10381 : 0 : if (vxlan_encap_conf.select_ipv4) {
10382 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
10383 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
10384 : : } else {
10385 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
10386 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
10387 : : }
10388 : 0 : if (vxlan_encap_conf.select_vlan)
10389 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10390 : 0 : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
10391 : : RTE_ETHER_ADDR_LEN);
10392 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10393 : : RTE_ETHER_ADDR_LEN);
10394 : : }
10395 : :
10396 : : static cmdline_parse_inst_t cmd_set_vxlan = {
10397 : : .f = cmd_set_vxlan_parsed,
10398 : : .data = NULL,
10399 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
10400 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
10401 : : " eth-src <eth-src> eth-dst <eth-dst>",
10402 : : .tokens = {
10403 : : (void *)&cmd_set_vxlan_set,
10404 : : (void *)&cmd_set_vxlan_vxlan,
10405 : : (void *)&cmd_set_vxlan_ip_version,
10406 : : (void *)&cmd_set_vxlan_ip_version_value,
10407 : : (void *)&cmd_set_vxlan_vni,
10408 : : (void *)&cmd_set_vxlan_vni_value,
10409 : : (void *)&cmd_set_vxlan_udp_src,
10410 : : (void *)&cmd_set_vxlan_udp_src_value,
10411 : : (void *)&cmd_set_vxlan_udp_dst,
10412 : : (void *)&cmd_set_vxlan_udp_dst_value,
10413 : : (void *)&cmd_set_vxlan_ip_src,
10414 : : (void *)&cmd_set_vxlan_ip_src_value,
10415 : : (void *)&cmd_set_vxlan_ip_dst,
10416 : : (void *)&cmd_set_vxlan_ip_dst_value,
10417 : : (void *)&cmd_set_vxlan_eth_src,
10418 : : (void *)&cmd_set_vxlan_eth_src_value,
10419 : : (void *)&cmd_set_vxlan_eth_dst,
10420 : : (void *)&cmd_set_vxlan_eth_dst_value,
10421 : : NULL,
10422 : : },
10423 : : };
10424 : :
10425 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
10426 : : .f = cmd_set_vxlan_parsed,
10427 : : .data = NULL,
10428 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
10429 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
10430 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10431 : : " eth-dst <eth-dst>",
10432 : : .tokens = {
10433 : : (void *)&cmd_set_vxlan_set,
10434 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
10435 : : (void *)&cmd_set_vxlan_ip_version,
10436 : : (void *)&cmd_set_vxlan_ip_version_value,
10437 : : (void *)&cmd_set_vxlan_vni,
10438 : : (void *)&cmd_set_vxlan_vni_value,
10439 : : (void *)&cmd_set_vxlan_udp_src,
10440 : : (void *)&cmd_set_vxlan_udp_src_value,
10441 : : (void *)&cmd_set_vxlan_udp_dst,
10442 : : (void *)&cmd_set_vxlan_udp_dst_value,
10443 : : (void *)&cmd_set_vxlan_ip_tos,
10444 : : (void *)&cmd_set_vxlan_ip_tos_value,
10445 : : (void *)&cmd_set_vxlan_ip_ttl,
10446 : : (void *)&cmd_set_vxlan_ip_ttl_value,
10447 : : (void *)&cmd_set_vxlan_ip_src,
10448 : : (void *)&cmd_set_vxlan_ip_src_value,
10449 : : (void *)&cmd_set_vxlan_ip_dst,
10450 : : (void *)&cmd_set_vxlan_ip_dst_value,
10451 : : (void *)&cmd_set_vxlan_eth_src,
10452 : : (void *)&cmd_set_vxlan_eth_src_value,
10453 : : (void *)&cmd_set_vxlan_eth_dst,
10454 : : (void *)&cmd_set_vxlan_eth_dst_value,
10455 : : NULL,
10456 : : },
10457 : : };
10458 : :
10459 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
10460 : : .f = cmd_set_vxlan_parsed,
10461 : : .data = NULL,
10462 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
10463 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
10464 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
10465 : : " <eth-dst>",
10466 : : .tokens = {
10467 : : (void *)&cmd_set_vxlan_set,
10468 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
10469 : : (void *)&cmd_set_vxlan_ip_version,
10470 : : (void *)&cmd_set_vxlan_ip_version_value,
10471 : : (void *)&cmd_set_vxlan_vni,
10472 : : (void *)&cmd_set_vxlan_vni_value,
10473 : : (void *)&cmd_set_vxlan_udp_src,
10474 : : (void *)&cmd_set_vxlan_udp_src_value,
10475 : : (void *)&cmd_set_vxlan_udp_dst,
10476 : : (void *)&cmd_set_vxlan_udp_dst_value,
10477 : : (void *)&cmd_set_vxlan_ip_src,
10478 : : (void *)&cmd_set_vxlan_ip_src_value,
10479 : : (void *)&cmd_set_vxlan_ip_dst,
10480 : : (void *)&cmd_set_vxlan_ip_dst_value,
10481 : : (void *)&cmd_set_vxlan_vlan,
10482 : : (void *)&cmd_set_vxlan_vlan_value,
10483 : : (void *)&cmd_set_vxlan_eth_src,
10484 : : (void *)&cmd_set_vxlan_eth_src_value,
10485 : : (void *)&cmd_set_vxlan_eth_dst,
10486 : : (void *)&cmd_set_vxlan_eth_dst_value,
10487 : : NULL,
10488 : : },
10489 : : };
10490 : :
10491 : : /** Set NVGRE encapsulation details */
10492 : : struct cmd_set_nvgre_result {
10493 : : cmdline_fixed_string_t set;
10494 : : cmdline_fixed_string_t nvgre;
10495 : : cmdline_fixed_string_t pos_token;
10496 : : cmdline_fixed_string_t ip_version;
10497 : : uint32_t tni;
10498 : : cmdline_ipaddr_t ip_src;
10499 : : cmdline_ipaddr_t ip_dst;
10500 : : uint16_t tci;
10501 : : struct rte_ether_addr eth_src;
10502 : : struct rte_ether_addr eth_dst;
10503 : : };
10504 : :
10505 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
10506 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
10507 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
10508 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
10509 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
10510 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
10511 : : "nvgre-with-vlan");
10512 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
10513 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10514 : : "ip-version");
10515 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
10516 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
10517 : : "ipv4#ipv6");
10518 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
10519 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10520 : : "tni");
10521 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
10522 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
10523 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
10524 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10525 : : "ip-src");
10526 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
10527 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
10528 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
10529 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10530 : : "ip-dst");
10531 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
10532 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
10533 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
10534 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10535 : : "vlan-tci");
10536 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
10537 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
10538 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
10539 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10540 : : "eth-src");
10541 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
10542 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
10543 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
10544 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10545 : : "eth-dst");
10546 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
10547 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
10548 : :
10549 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
10550 : : __rte_unused struct cmdline *cl,
10551 : : __rte_unused void *data)
10552 : : {
10553 : : struct cmd_set_nvgre_result *res = parsed_result;
10554 : : union {
10555 : : uint32_t nvgre_tni;
10556 : : uint8_t tni[4];
10557 : 0 : } id = {
10558 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
10559 : : };
10560 : :
10561 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
10562 : 0 : nvgre_encap_conf.select_vlan = 0;
10563 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
10564 : 0 : nvgre_encap_conf.select_vlan = 1;
10565 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10566 : 0 : nvgre_encap_conf.select_ipv4 = 1;
10567 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10568 : 0 : nvgre_encap_conf.select_ipv4 = 0;
10569 : : else
10570 : 0 : return;
10571 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
10572 : 0 : if (nvgre_encap_conf.select_ipv4) {
10573 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
10574 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
10575 : : } else {
10576 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
10577 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
10578 : : }
10579 : 0 : if (nvgre_encap_conf.select_vlan)
10580 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10581 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
10582 : : RTE_ETHER_ADDR_LEN);
10583 : 0 : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10584 : : RTE_ETHER_ADDR_LEN);
10585 : : }
10586 : :
10587 : : static cmdline_parse_inst_t cmd_set_nvgre = {
10588 : : .f = cmd_set_nvgre_parsed,
10589 : : .data = NULL,
10590 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
10591 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10592 : : " eth-dst <eth-dst>",
10593 : : .tokens = {
10594 : : (void *)&cmd_set_nvgre_set,
10595 : : (void *)&cmd_set_nvgre_nvgre,
10596 : : (void *)&cmd_set_nvgre_ip_version,
10597 : : (void *)&cmd_set_nvgre_ip_version_value,
10598 : : (void *)&cmd_set_nvgre_tni,
10599 : : (void *)&cmd_set_nvgre_tni_value,
10600 : : (void *)&cmd_set_nvgre_ip_src,
10601 : : (void *)&cmd_set_nvgre_ip_src_value,
10602 : : (void *)&cmd_set_nvgre_ip_dst,
10603 : : (void *)&cmd_set_nvgre_ip_dst_value,
10604 : : (void *)&cmd_set_nvgre_eth_src,
10605 : : (void *)&cmd_set_nvgre_eth_src_value,
10606 : : (void *)&cmd_set_nvgre_eth_dst,
10607 : : (void *)&cmd_set_nvgre_eth_dst_value,
10608 : : NULL,
10609 : : },
10610 : : };
10611 : :
10612 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
10613 : : .f = cmd_set_nvgre_parsed,
10614 : : .data = NULL,
10615 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
10616 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10617 : : " eth-src <eth-src> eth-dst <eth-dst>",
10618 : : .tokens = {
10619 : : (void *)&cmd_set_nvgre_set,
10620 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
10621 : : (void *)&cmd_set_nvgre_ip_version,
10622 : : (void *)&cmd_set_nvgre_ip_version_value,
10623 : : (void *)&cmd_set_nvgre_tni,
10624 : : (void *)&cmd_set_nvgre_tni_value,
10625 : : (void *)&cmd_set_nvgre_ip_src,
10626 : : (void *)&cmd_set_nvgre_ip_src_value,
10627 : : (void *)&cmd_set_nvgre_ip_dst,
10628 : : (void *)&cmd_set_nvgre_ip_dst_value,
10629 : : (void *)&cmd_set_nvgre_vlan,
10630 : : (void *)&cmd_set_nvgre_vlan_value,
10631 : : (void *)&cmd_set_nvgre_eth_src,
10632 : : (void *)&cmd_set_nvgre_eth_src_value,
10633 : : (void *)&cmd_set_nvgre_eth_dst,
10634 : : (void *)&cmd_set_nvgre_eth_dst_value,
10635 : : NULL,
10636 : : },
10637 : : };
10638 : :
10639 : : /** Set L2 encapsulation details */
10640 : : struct cmd_set_l2_encap_result {
10641 : : cmdline_fixed_string_t set;
10642 : : cmdline_fixed_string_t l2_encap;
10643 : : cmdline_fixed_string_t pos_token;
10644 : : cmdline_fixed_string_t ip_version;
10645 : : uint32_t vlan_present:1;
10646 : : uint16_t tci;
10647 : : struct rte_ether_addr eth_src;
10648 : : struct rte_ether_addr eth_dst;
10649 : : };
10650 : :
10651 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
10652 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
10653 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
10654 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
10655 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
10656 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
10657 : : "l2_encap-with-vlan");
10658 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
10659 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10660 : : "ip-version");
10661 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
10662 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
10663 : : "ipv4#ipv6");
10664 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
10665 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10666 : : "vlan-tci");
10667 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
10668 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
10669 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
10670 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10671 : : "eth-src");
10672 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
10673 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
10674 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
10675 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10676 : : "eth-dst");
10677 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
10678 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
10679 : :
10680 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
10681 : : __rte_unused struct cmdline *cl,
10682 : : __rte_unused void *data)
10683 : : {
10684 : : struct cmd_set_l2_encap_result *res = parsed_result;
10685 : :
10686 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
10687 : 0 : l2_encap_conf.select_vlan = 0;
10688 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
10689 : 0 : l2_encap_conf.select_vlan = 1;
10690 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10691 : 0 : l2_encap_conf.select_ipv4 = 1;
10692 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10693 : 0 : l2_encap_conf.select_ipv4 = 0;
10694 : : else
10695 : : return;
10696 : 0 : if (l2_encap_conf.select_vlan)
10697 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10698 : 0 : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
10699 : : RTE_ETHER_ADDR_LEN);
10700 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10701 : : RTE_ETHER_ADDR_LEN);
10702 : : }
10703 : :
10704 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
10705 : : .f = cmd_set_l2_encap_parsed,
10706 : : .data = NULL,
10707 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
10708 : : " eth-src <eth-src> eth-dst <eth-dst>",
10709 : : .tokens = {
10710 : : (void *)&cmd_set_l2_encap_set,
10711 : : (void *)&cmd_set_l2_encap_l2_encap,
10712 : : (void *)&cmd_set_l2_encap_ip_version,
10713 : : (void *)&cmd_set_l2_encap_ip_version_value,
10714 : : (void *)&cmd_set_l2_encap_eth_src,
10715 : : (void *)&cmd_set_l2_encap_eth_src_value,
10716 : : (void *)&cmd_set_l2_encap_eth_dst,
10717 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10718 : : NULL,
10719 : : },
10720 : : };
10721 : :
10722 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
10723 : : .f = cmd_set_l2_encap_parsed,
10724 : : .data = NULL,
10725 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
10726 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10727 : : .tokens = {
10728 : : (void *)&cmd_set_l2_encap_set,
10729 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
10730 : : (void *)&cmd_set_l2_encap_ip_version,
10731 : : (void *)&cmd_set_l2_encap_ip_version_value,
10732 : : (void *)&cmd_set_l2_encap_vlan,
10733 : : (void *)&cmd_set_l2_encap_vlan_value,
10734 : : (void *)&cmd_set_l2_encap_eth_src,
10735 : : (void *)&cmd_set_l2_encap_eth_src_value,
10736 : : (void *)&cmd_set_l2_encap_eth_dst,
10737 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10738 : : NULL,
10739 : : },
10740 : : };
10741 : :
10742 : : /** Set L2 decapsulation details */
10743 : : struct cmd_set_l2_decap_result {
10744 : : cmdline_fixed_string_t set;
10745 : : cmdline_fixed_string_t l2_decap;
10746 : : cmdline_fixed_string_t pos_token;
10747 : : uint32_t vlan_present:1;
10748 : : };
10749 : :
10750 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
10751 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
10752 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
10753 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10754 : : "l2_decap");
10755 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
10756 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10757 : : "l2_decap-with-vlan");
10758 : :
10759 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
10760 : : __rte_unused struct cmdline *cl,
10761 : : __rte_unused void *data)
10762 : : {
10763 : : struct cmd_set_l2_decap_result *res = parsed_result;
10764 : :
10765 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
10766 : 0 : l2_decap_conf.select_vlan = 0;
10767 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
10768 : 0 : l2_decap_conf.select_vlan = 1;
10769 : 0 : }
10770 : :
10771 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
10772 : : .f = cmd_set_l2_decap_parsed,
10773 : : .data = NULL,
10774 : : .help_str = "set l2_decap",
10775 : : .tokens = {
10776 : : (void *)&cmd_set_l2_decap_set,
10777 : : (void *)&cmd_set_l2_decap_l2_decap,
10778 : : NULL,
10779 : : },
10780 : : };
10781 : :
10782 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
10783 : : .f = cmd_set_l2_decap_parsed,
10784 : : .data = NULL,
10785 : : .help_str = "set l2_decap-with-vlan",
10786 : : .tokens = {
10787 : : (void *)&cmd_set_l2_decap_set,
10788 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
10789 : : NULL,
10790 : : },
10791 : : };
10792 : :
10793 : : /** Set MPLSoGRE encapsulation details */
10794 : : struct cmd_set_mplsogre_encap_result {
10795 : : cmdline_fixed_string_t set;
10796 : : cmdline_fixed_string_t mplsogre;
10797 : : cmdline_fixed_string_t pos_token;
10798 : : cmdline_fixed_string_t ip_version;
10799 : : uint32_t vlan_present:1;
10800 : : uint32_t label;
10801 : : cmdline_ipaddr_t ip_src;
10802 : : cmdline_ipaddr_t ip_dst;
10803 : : uint16_t tci;
10804 : : struct rte_ether_addr eth_src;
10805 : : struct rte_ether_addr eth_dst;
10806 : : };
10807 : :
10808 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
10809 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
10810 : : "set");
10811 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
10812 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
10813 : : "mplsogre_encap");
10814 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
10815 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10816 : : mplsogre, "mplsogre_encap-with-vlan");
10817 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
10818 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10819 : : pos_token, "ip-version");
10820 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
10821 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10822 : : ip_version, "ipv4#ipv6");
10823 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
10824 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10825 : : pos_token, "label");
10826 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
10827 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
10828 : : RTE_UINT32);
10829 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
10830 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10831 : : pos_token, "ip-src");
10832 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
10833 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
10834 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
10835 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10836 : : pos_token, "ip-dst");
10837 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
10838 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
10839 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
10840 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10841 : : pos_token, "vlan-tci");
10842 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
10843 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
10844 : : RTE_UINT16);
10845 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
10846 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10847 : : pos_token, "eth-src");
10848 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
10849 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10850 : : eth_src);
10851 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
10852 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10853 : : pos_token, "eth-dst");
10854 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
10855 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10856 : : eth_dst);
10857 : :
10858 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
10859 : : __rte_unused struct cmdline *cl,
10860 : : __rte_unused void *data)
10861 : : {
10862 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
10863 : : union {
10864 : : uint32_t mplsogre_label;
10865 : : uint8_t label[4];
10866 : 0 : } id = {
10867 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
10868 : : };
10869 : :
10870 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
10871 : 0 : mplsogre_encap_conf.select_vlan = 0;
10872 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
10873 : 0 : mplsogre_encap_conf.select_vlan = 1;
10874 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10875 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
10876 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10877 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
10878 : : else
10879 : 0 : return;
10880 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
10881 : 0 : if (mplsogre_encap_conf.select_ipv4) {
10882 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
10883 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
10884 : : } else {
10885 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
10886 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
10887 : : }
10888 : 0 : if (mplsogre_encap_conf.select_vlan)
10889 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10890 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
10891 : : RTE_ETHER_ADDR_LEN);
10892 : 0 : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10893 : : RTE_ETHER_ADDR_LEN);
10894 : : }
10895 : :
10896 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
10897 : : .f = cmd_set_mplsogre_encap_parsed,
10898 : : .data = NULL,
10899 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
10900 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10901 : : " eth-dst <eth-dst>",
10902 : : .tokens = {
10903 : : (void *)&cmd_set_mplsogre_encap_set,
10904 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
10905 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10906 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10907 : : (void *)&cmd_set_mplsogre_encap_label,
10908 : : (void *)&cmd_set_mplsogre_encap_label_value,
10909 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10910 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10911 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10912 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10913 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10914 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10915 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10916 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10917 : : NULL,
10918 : : },
10919 : : };
10920 : :
10921 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
10922 : : .f = cmd_set_mplsogre_encap_parsed,
10923 : : .data = NULL,
10924 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
10925 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
10926 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10927 : : .tokens = {
10928 : : (void *)&cmd_set_mplsogre_encap_set,
10929 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
10930 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10931 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10932 : : (void *)&cmd_set_mplsogre_encap_label,
10933 : : (void *)&cmd_set_mplsogre_encap_label_value,
10934 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10935 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10936 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10937 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10938 : : (void *)&cmd_set_mplsogre_encap_vlan,
10939 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
10940 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10941 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10942 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10943 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10944 : : NULL,
10945 : : },
10946 : : };
10947 : :
10948 : : /** Set MPLSoGRE decapsulation details */
10949 : : struct cmd_set_mplsogre_decap_result {
10950 : : cmdline_fixed_string_t set;
10951 : : cmdline_fixed_string_t mplsogre;
10952 : : cmdline_fixed_string_t pos_token;
10953 : : cmdline_fixed_string_t ip_version;
10954 : : uint32_t vlan_present:1;
10955 : : };
10956 : :
10957 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
10958 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
10959 : : "set");
10960 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
10961 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
10962 : : "mplsogre_decap");
10963 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
10964 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10965 : : mplsogre, "mplsogre_decap-with-vlan");
10966 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
10967 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10968 : : pos_token, "ip-version");
10969 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
10970 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10971 : : ip_version, "ipv4#ipv6");
10972 : :
10973 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
10974 : : __rte_unused struct cmdline *cl,
10975 : : __rte_unused void *data)
10976 : : {
10977 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
10978 : :
10979 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
10980 : 0 : mplsogre_decap_conf.select_vlan = 0;
10981 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
10982 : 0 : mplsogre_decap_conf.select_vlan = 1;
10983 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10984 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
10985 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10986 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
10987 : 0 : }
10988 : :
10989 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
10990 : : .f = cmd_set_mplsogre_decap_parsed,
10991 : : .data = NULL,
10992 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
10993 : : .tokens = {
10994 : : (void *)&cmd_set_mplsogre_decap_set,
10995 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
10996 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10997 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10998 : : NULL,
10999 : : },
11000 : : };
11001 : :
11002 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
11003 : : .f = cmd_set_mplsogre_decap_parsed,
11004 : : .data = NULL,
11005 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
11006 : : .tokens = {
11007 : : (void *)&cmd_set_mplsogre_decap_set,
11008 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
11009 : : (void *)&cmd_set_mplsogre_decap_ip_version,
11010 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
11011 : : NULL,
11012 : : },
11013 : : };
11014 : :
11015 : : /** Set MPLSoUDP encapsulation details */
11016 : : struct cmd_set_mplsoudp_encap_result {
11017 : : cmdline_fixed_string_t set;
11018 : : cmdline_fixed_string_t mplsoudp;
11019 : : cmdline_fixed_string_t pos_token;
11020 : : cmdline_fixed_string_t ip_version;
11021 : : uint32_t vlan_present:1;
11022 : : uint32_t label;
11023 : : uint16_t udp_src;
11024 : : uint16_t udp_dst;
11025 : : cmdline_ipaddr_t ip_src;
11026 : : cmdline_ipaddr_t ip_dst;
11027 : : uint16_t tci;
11028 : : struct rte_ether_addr eth_src;
11029 : : struct rte_ether_addr eth_dst;
11030 : : };
11031 : :
11032 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
11033 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
11034 : : "set");
11035 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
11036 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
11037 : : "mplsoudp_encap");
11038 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
11039 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11040 : : mplsoudp, "mplsoudp_encap-with-vlan");
11041 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
11042 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11043 : : pos_token, "ip-version");
11044 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
11045 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11046 : : ip_version, "ipv4#ipv6");
11047 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
11048 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11049 : : pos_token, "label");
11050 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
11051 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
11052 : : RTE_UINT32);
11053 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
11054 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11055 : : pos_token, "udp-src");
11056 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
11057 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
11058 : : RTE_UINT16);
11059 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
11060 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11061 : : pos_token, "udp-dst");
11062 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
11063 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
11064 : : RTE_UINT16);
11065 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
11066 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11067 : : pos_token, "ip-src");
11068 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
11069 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
11070 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
11071 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11072 : : pos_token, "ip-dst");
11073 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
11074 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
11075 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
11076 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11077 : : pos_token, "vlan-tci");
11078 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
11079 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
11080 : : RTE_UINT16);
11081 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
11082 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11083 : : pos_token, "eth-src");
11084 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
11085 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11086 : : eth_src);
11087 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
11088 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11089 : : pos_token, "eth-dst");
11090 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
11091 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
11092 : : eth_dst);
11093 : :
11094 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
11095 : : __rte_unused struct cmdline *cl,
11096 : : __rte_unused void *data)
11097 : : {
11098 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
11099 : : union {
11100 : : uint32_t mplsoudp_label;
11101 : : uint8_t label[4];
11102 : 0 : } id = {
11103 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
11104 : : };
11105 : :
11106 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
11107 : 0 : mplsoudp_encap_conf.select_vlan = 0;
11108 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
11109 : 0 : mplsoudp_encap_conf.select_vlan = 1;
11110 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11111 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
11112 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11113 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
11114 : : else
11115 : 0 : return;
11116 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
11117 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
11118 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
11119 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
11120 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
11121 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
11122 : : } else {
11123 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
11124 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
11125 : : }
11126 : 0 : if (mplsoudp_encap_conf.select_vlan)
11127 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
11128 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
11129 : : RTE_ETHER_ADDR_LEN);
11130 : 0 : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
11131 : : RTE_ETHER_ADDR_LEN);
11132 : : }
11133 : :
11134 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
11135 : : .f = cmd_set_mplsoudp_encap_parsed,
11136 : : .data = NULL,
11137 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
11138 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
11139 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
11140 : : .tokens = {
11141 : : (void *)&cmd_set_mplsoudp_encap_set,
11142 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
11143 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11144 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11145 : : (void *)&cmd_set_mplsoudp_encap_label,
11146 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11147 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11148 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11149 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11150 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11151 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11152 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11153 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11154 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11155 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11156 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11157 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11158 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11159 : : NULL,
11160 : : },
11161 : : };
11162 : :
11163 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
11164 : : .f = cmd_set_mplsoudp_encap_parsed,
11165 : : .data = NULL,
11166 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
11167 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
11168 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
11169 : : " eth-src <eth-src> eth-dst <eth-dst>",
11170 : : .tokens = {
11171 : : (void *)&cmd_set_mplsoudp_encap_set,
11172 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
11173 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
11174 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
11175 : : (void *)&cmd_set_mplsoudp_encap_label,
11176 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11177 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11178 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11179 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11180 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11181 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11182 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11183 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11184 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11185 : : (void *)&cmd_set_mplsoudp_encap_vlan,
11186 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
11187 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11188 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11189 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11190 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11191 : : NULL,
11192 : : },
11193 : : };
11194 : :
11195 : : /** Set MPLSoUDP decapsulation details */
11196 : : struct cmd_set_mplsoudp_decap_result {
11197 : : cmdline_fixed_string_t set;
11198 : : cmdline_fixed_string_t mplsoudp;
11199 : : cmdline_fixed_string_t pos_token;
11200 : : cmdline_fixed_string_t ip_version;
11201 : : uint32_t vlan_present:1;
11202 : : };
11203 : :
11204 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
11205 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
11206 : : "set");
11207 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
11208 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
11209 : : "mplsoudp_decap");
11210 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
11211 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11212 : : mplsoudp, "mplsoudp_decap-with-vlan");
11213 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
11214 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11215 : : pos_token, "ip-version");
11216 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
11217 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11218 : : ip_version, "ipv4#ipv6");
11219 : :
11220 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
11221 : : __rte_unused struct cmdline *cl,
11222 : : __rte_unused void *data)
11223 : : {
11224 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
11225 : :
11226 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
11227 : 0 : mplsoudp_decap_conf.select_vlan = 0;
11228 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
11229 : 0 : mplsoudp_decap_conf.select_vlan = 1;
11230 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11231 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
11232 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11233 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
11234 : 0 : }
11235 : :
11236 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
11237 : : .f = cmd_set_mplsoudp_decap_parsed,
11238 : : .data = NULL,
11239 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
11240 : : .tokens = {
11241 : : (void *)&cmd_set_mplsoudp_decap_set,
11242 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
11243 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11244 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11245 : : NULL,
11246 : : },
11247 : : };
11248 : :
11249 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
11250 : : .f = cmd_set_mplsoudp_decap_parsed,
11251 : : .data = NULL,
11252 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
11253 : : .tokens = {
11254 : : (void *)&cmd_set_mplsoudp_decap_set,
11255 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
11256 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11257 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11258 : : NULL,
11259 : : },
11260 : : };
11261 : :
11262 : : /** Set connection tracking object common details */
11263 : : struct cmd_set_conntrack_common_result {
11264 : : cmdline_fixed_string_t set;
11265 : : cmdline_fixed_string_t conntrack;
11266 : : cmdline_fixed_string_t common;
11267 : : cmdline_fixed_string_t peer;
11268 : : cmdline_fixed_string_t is_orig;
11269 : : cmdline_fixed_string_t enable;
11270 : : cmdline_fixed_string_t live;
11271 : : cmdline_fixed_string_t sack;
11272 : : cmdline_fixed_string_t cack;
11273 : : cmdline_fixed_string_t last_dir;
11274 : : cmdline_fixed_string_t liberal;
11275 : : cmdline_fixed_string_t state;
11276 : : cmdline_fixed_string_t max_ack_win;
11277 : : cmdline_fixed_string_t retrans;
11278 : : cmdline_fixed_string_t last_win;
11279 : : cmdline_fixed_string_t last_seq;
11280 : : cmdline_fixed_string_t last_ack;
11281 : : cmdline_fixed_string_t last_end;
11282 : : cmdline_fixed_string_t last_index;
11283 : : uint8_t stat;
11284 : : uint8_t factor;
11285 : : uint16_t peer_port;
11286 : : uint32_t is_original;
11287 : : uint32_t en;
11288 : : uint32_t is_live;
11289 : : uint32_t s_ack;
11290 : : uint32_t c_ack;
11291 : : uint32_t ld;
11292 : : uint32_t lb;
11293 : : uint8_t re_num;
11294 : : uint8_t li;
11295 : : uint16_t lw;
11296 : : uint32_t ls;
11297 : : uint32_t la;
11298 : : uint32_t le;
11299 : : };
11300 : :
11301 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
11302 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11303 : : set, "set");
11304 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
11305 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11306 : : conntrack, "conntrack");
11307 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
11308 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11309 : : common, "com");
11310 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
11311 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11312 : : peer, "peer");
11313 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
11314 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11315 : : peer_port, RTE_UINT16);
11316 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
11317 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11318 : : is_orig, "is_orig");
11319 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
11320 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11321 : : is_original, RTE_UINT32);
11322 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
11323 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11324 : : enable, "enable");
11325 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
11326 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11327 : : en, RTE_UINT32);
11328 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
11329 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11330 : : live, "live");
11331 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
11332 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11333 : : is_live, RTE_UINT32);
11334 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
11335 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11336 : : sack, "sack");
11337 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
11338 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11339 : : s_ack, RTE_UINT32);
11340 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
11341 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11342 : : cack, "cack");
11343 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
11344 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11345 : : c_ack, RTE_UINT32);
11346 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
11347 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11348 : : last_dir, "last_dir");
11349 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
11350 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11351 : : ld, RTE_UINT32);
11352 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
11353 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11354 : : liberal, "liberal");
11355 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
11356 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11357 : : lb, RTE_UINT32);
11358 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
11359 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11360 : : state, "state");
11361 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
11362 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11363 : : stat, RTE_UINT8);
11364 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
11365 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11366 : : max_ack_win, "max_ack_win");
11367 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
11368 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11369 : : factor, RTE_UINT8);
11370 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
11371 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11372 : : retrans, "r_lim");
11373 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
11374 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11375 : : re_num, RTE_UINT8);
11376 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
11377 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11378 : : last_win, "last_win");
11379 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
11380 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11381 : : lw, RTE_UINT16);
11382 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
11383 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11384 : : last_seq, "last_seq");
11385 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
11386 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11387 : : ls, RTE_UINT32);
11388 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
11389 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11390 : : last_ack, "last_ack");
11391 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
11392 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11393 : : la, RTE_UINT32);
11394 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
11395 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11396 : : last_end, "last_end");
11397 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
11398 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11399 : : le, RTE_UINT32);
11400 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
11401 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11402 : : last_index, "last_index");
11403 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
11404 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11405 : : li, RTE_UINT8);
11406 : :
11407 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
11408 : : __rte_unused struct cmdline *cl,
11409 : : __rte_unused void *data)
11410 : : {
11411 : : struct cmd_set_conntrack_common_result *res = parsed_result;
11412 : :
11413 : : /* No need to swap to big endian. */
11414 : 0 : conntrack_context.peer_port = res->peer_port;
11415 : 0 : conntrack_context.is_original_dir = res->is_original;
11416 : 0 : conntrack_context.enable = res->en;
11417 : 0 : conntrack_context.live_connection = res->is_live;
11418 : 0 : conntrack_context.selective_ack = res->s_ack;
11419 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
11420 : 0 : conntrack_context.last_direction = res->ld;
11421 : 0 : conntrack_context.liberal_mode = res->lb;
11422 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
11423 : 0 : conntrack_context.max_ack_window = res->factor;
11424 : 0 : conntrack_context.retransmission_limit = res->re_num;
11425 : 0 : conntrack_context.last_window = res->lw;
11426 : 0 : conntrack_context.last_index =
11427 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
11428 : 0 : conntrack_context.last_seq = res->ls;
11429 : 0 : conntrack_context.last_ack = res->la;
11430 : 0 : conntrack_context.last_end = res->le;
11431 : 0 : }
11432 : :
11433 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
11434 : : .f = cmd_set_conntrack_common_parsed,
11435 : : .data = NULL,
11436 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
11437 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
11438 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
11439 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
11440 : : " last_index <flag>",
11441 : : .tokens = {
11442 : : (void *)&cmd_set_conntrack_set,
11443 : : (void *)&cmd_set_conntrack_conntrack,
11444 : : (void *)&cmd_set_conntrack_common_com,
11445 : : (void *)&cmd_set_conntrack_common_peer,
11446 : : (void *)&cmd_set_conntrack_common_peer_value,
11447 : : (void *)&cmd_set_conntrack_common_is_orig,
11448 : : (void *)&cmd_set_conntrack_common_is_orig_value,
11449 : : (void *)&cmd_set_conntrack_common_enable,
11450 : : (void *)&cmd_set_conntrack_common_enable_value,
11451 : : (void *)&cmd_set_conntrack_common_live,
11452 : : (void *)&cmd_set_conntrack_common_live_value,
11453 : : (void *)&cmd_set_conntrack_common_sack,
11454 : : (void *)&cmd_set_conntrack_common_sack_value,
11455 : : (void *)&cmd_set_conntrack_common_cack,
11456 : : (void *)&cmd_set_conntrack_common_cack_value,
11457 : : (void *)&cmd_set_conntrack_common_last_dir,
11458 : : (void *)&cmd_set_conntrack_common_last_dir_value,
11459 : : (void *)&cmd_set_conntrack_common_liberal,
11460 : : (void *)&cmd_set_conntrack_common_liberal_value,
11461 : : (void *)&cmd_set_conntrack_common_state,
11462 : : (void *)&cmd_set_conntrack_common_state_value,
11463 : : (void *)&cmd_set_conntrack_common_max_ackwin,
11464 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
11465 : : (void *)&cmd_set_conntrack_common_retrans,
11466 : : (void *)&cmd_set_conntrack_common_retrans_value,
11467 : : (void *)&cmd_set_conntrack_common_last_win,
11468 : : (void *)&cmd_set_conntrack_common_last_win_value,
11469 : : (void *)&cmd_set_conntrack_common_last_seq,
11470 : : (void *)&cmd_set_conntrack_common_last_seq_value,
11471 : : (void *)&cmd_set_conntrack_common_last_ack,
11472 : : (void *)&cmd_set_conntrack_common_last_ack_value,
11473 : : (void *)&cmd_set_conntrack_common_last_end,
11474 : : (void *)&cmd_set_conntrack_common_last_end_value,
11475 : : (void *)&cmd_set_conntrack_common_last_index,
11476 : : (void *)&cmd_set_conntrack_common_last_index_value,
11477 : : NULL,
11478 : : },
11479 : : };
11480 : :
11481 : : /** Set connection tracking object both directions' details */
11482 : : struct cmd_set_conntrack_dir_result {
11483 : : cmdline_fixed_string_t set;
11484 : : cmdline_fixed_string_t conntrack;
11485 : : cmdline_fixed_string_t dir;
11486 : : cmdline_fixed_string_t scale;
11487 : : cmdline_fixed_string_t fin;
11488 : : cmdline_fixed_string_t ack_seen;
11489 : : cmdline_fixed_string_t unack;
11490 : : cmdline_fixed_string_t sent_end;
11491 : : cmdline_fixed_string_t reply_end;
11492 : : cmdline_fixed_string_t max_win;
11493 : : cmdline_fixed_string_t max_ack;
11494 : : uint32_t factor;
11495 : : uint32_t f;
11496 : : uint32_t as;
11497 : : uint32_t un;
11498 : : uint32_t se;
11499 : : uint32_t re;
11500 : : uint32_t mw;
11501 : : uint32_t ma;
11502 : : };
11503 : :
11504 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
11505 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11506 : : dir, "orig#rply");
11507 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
11508 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11509 : : scale, "scale");
11510 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
11511 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11512 : : factor, RTE_UINT32);
11513 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
11514 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11515 : : fin, "fin");
11516 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
11517 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11518 : : f, RTE_UINT32);
11519 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
11520 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11521 : : ack_seen, "acked");
11522 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
11523 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11524 : : as, RTE_UINT32);
11525 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
11526 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11527 : : unack, "unack_data");
11528 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
11529 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11530 : : un, RTE_UINT32);
11531 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
11532 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11533 : : sent_end, "sent_end");
11534 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
11535 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11536 : : se, RTE_UINT32);
11537 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
11538 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11539 : : reply_end, "reply_end");
11540 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
11541 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11542 : : re, RTE_UINT32);
11543 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
11544 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11545 : : max_win, "max_win");
11546 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
11547 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11548 : : mw, RTE_UINT32);
11549 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
11550 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11551 : : max_ack, "max_ack");
11552 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
11553 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11554 : : ma, RTE_UINT32);
11555 : :
11556 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
11557 : : __rte_unused struct cmdline *cl,
11558 : : __rte_unused void *data)
11559 : : {
11560 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
11561 : : struct rte_flow_tcp_dir_param *dir = NULL;
11562 : :
11563 : 0 : if (strcmp(res->dir, "orig") == 0)
11564 : : dir = &conntrack_context.original_dir;
11565 : 0 : else if (strcmp(res->dir, "rply") == 0)
11566 : : dir = &conntrack_context.reply_dir;
11567 : : else
11568 : : return;
11569 : 0 : dir->scale = res->factor;
11570 : 0 : dir->close_initiated = res->f;
11571 : 0 : dir->last_ack_seen = res->as;
11572 : 0 : dir->data_unacked = res->un;
11573 : 0 : dir->sent_end = res->se;
11574 : 0 : dir->reply_end = res->re;
11575 : 0 : dir->max_ack = res->ma;
11576 : 0 : dir->max_win = res->mw;
11577 : : }
11578 : :
11579 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
11580 : : .f = cmd_set_conntrack_dir_parsed,
11581 : : .data = NULL,
11582 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
11583 : : " acked <seen> unack_data <unack> sent_end <sent>"
11584 : : " reply_end <reply> max_win <win> max_ack <ack>",
11585 : : .tokens = {
11586 : : (void *)&cmd_set_conntrack_set,
11587 : : (void *)&cmd_set_conntrack_conntrack,
11588 : : (void *)&cmd_set_conntrack_dir_dir,
11589 : : (void *)&cmd_set_conntrack_dir_scale,
11590 : : (void *)&cmd_set_conntrack_dir_scale_value,
11591 : : (void *)&cmd_set_conntrack_dir_fin,
11592 : : (void *)&cmd_set_conntrack_dir_fin_value,
11593 : : (void *)&cmd_set_conntrack_dir_ack,
11594 : : (void *)&cmd_set_conntrack_dir_ack_value,
11595 : : (void *)&cmd_set_conntrack_dir_unack_data,
11596 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
11597 : : (void *)&cmd_set_conntrack_dir_sent_end,
11598 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
11599 : : (void *)&cmd_set_conntrack_dir_reply_end,
11600 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
11601 : : (void *)&cmd_set_conntrack_dir_max_win,
11602 : : (void *)&cmd_set_conntrack_dir_max_win_value,
11603 : : (void *)&cmd_set_conntrack_dir_max_ack,
11604 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
11605 : : NULL,
11606 : : },
11607 : : };
11608 : :
11609 : : /* show vf stats */
11610 : :
11611 : : /* Common result structure for show vf stats */
11612 : : struct cmd_show_vf_stats_result {
11613 : : cmdline_fixed_string_t show;
11614 : : cmdline_fixed_string_t vf;
11615 : : cmdline_fixed_string_t stats;
11616 : : portid_t port_id;
11617 : : uint16_t vf_id;
11618 : : };
11619 : :
11620 : : /* Common CLI fields show vf stats*/
11621 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
11622 : : TOKEN_STRING_INITIALIZER
11623 : : (struct cmd_show_vf_stats_result,
11624 : : show, "show");
11625 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
11626 : : TOKEN_STRING_INITIALIZER
11627 : : (struct cmd_show_vf_stats_result,
11628 : : vf, "vf");
11629 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
11630 : : TOKEN_STRING_INITIALIZER
11631 : : (struct cmd_show_vf_stats_result,
11632 : : stats, "stats");
11633 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
11634 : : TOKEN_NUM_INITIALIZER
11635 : : (struct cmd_show_vf_stats_result,
11636 : : port_id, RTE_UINT16);
11637 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
11638 : : TOKEN_NUM_INITIALIZER
11639 : : (struct cmd_show_vf_stats_result,
11640 : : vf_id, RTE_UINT16);
11641 : :
11642 : : static void
11643 : 0 : cmd_show_vf_stats_parsed(
11644 : : void *parsed_result,
11645 : : __rte_unused struct cmdline *cl,
11646 : : __rte_unused void *data)
11647 : : {
11648 : : struct cmd_show_vf_stats_result *res = parsed_result;
11649 : : struct rte_eth_stats stats;
11650 : : int ret = -ENOTSUP;
11651 : : static const char *nic_stats_border = "########################";
11652 : :
11653 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11654 : 0 : return;
11655 : :
11656 : : memset(&stats, 0, sizeof(stats));
11657 : :
11658 : : #ifdef RTE_NET_I40E
11659 : : if (ret == -ENOTSUP)
11660 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
11661 : 0 : res->vf_id,
11662 : : &stats);
11663 : : #endif
11664 : : #ifdef RTE_NET_BNXT
11665 : 0 : if (ret == -ENOTSUP)
11666 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
11667 : 0 : res->vf_id,
11668 : : &stats);
11669 : : #endif
11670 : :
11671 : 0 : switch (ret) {
11672 : : case 0:
11673 : : break;
11674 : 0 : case -EINVAL:
11675 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11676 : : break;
11677 : 0 : case -ENODEV:
11678 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11679 : : break;
11680 : 0 : case -ENOTSUP:
11681 : 0 : fprintf(stderr, "function not implemented\n");
11682 : : break;
11683 : 0 : default:
11684 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11685 : : }
11686 : :
11687 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
11688 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
11689 : :
11690 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
11691 : : "%-"PRIu64"\n",
11692 : : stats.ipackets, stats.imissed, stats.ibytes);
11693 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
11694 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
11695 : : stats.rx_nombuf);
11696 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
11697 : : "%-"PRIu64"\n",
11698 : : stats.opackets, stats.oerrors, stats.obytes);
11699 : :
11700 : 0 : printf(" %s############################%s\n",
11701 : : nic_stats_border, nic_stats_border);
11702 : : }
11703 : :
11704 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
11705 : : .f = cmd_show_vf_stats_parsed,
11706 : : .data = NULL,
11707 : : .help_str = "show vf stats <port_id> <vf_id>",
11708 : : .tokens = {
11709 : : (void *)&cmd_show_vf_stats_show,
11710 : : (void *)&cmd_show_vf_stats_vf,
11711 : : (void *)&cmd_show_vf_stats_stats,
11712 : : (void *)&cmd_show_vf_stats_port_id,
11713 : : (void *)&cmd_show_vf_stats_vf_id,
11714 : : NULL,
11715 : : },
11716 : : };
11717 : :
11718 : : /* clear vf stats */
11719 : :
11720 : : /* Common result structure for clear vf stats */
11721 : : struct cmd_clear_vf_stats_result {
11722 : : cmdline_fixed_string_t clear;
11723 : : cmdline_fixed_string_t vf;
11724 : : cmdline_fixed_string_t stats;
11725 : : portid_t port_id;
11726 : : uint16_t vf_id;
11727 : : };
11728 : :
11729 : : /* Common CLI fields clear vf stats*/
11730 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
11731 : : TOKEN_STRING_INITIALIZER
11732 : : (struct cmd_clear_vf_stats_result,
11733 : : clear, "clear");
11734 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
11735 : : TOKEN_STRING_INITIALIZER
11736 : : (struct cmd_clear_vf_stats_result,
11737 : : vf, "vf");
11738 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
11739 : : TOKEN_STRING_INITIALIZER
11740 : : (struct cmd_clear_vf_stats_result,
11741 : : stats, "stats");
11742 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
11743 : : TOKEN_NUM_INITIALIZER
11744 : : (struct cmd_clear_vf_stats_result,
11745 : : port_id, RTE_UINT16);
11746 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
11747 : : TOKEN_NUM_INITIALIZER
11748 : : (struct cmd_clear_vf_stats_result,
11749 : : vf_id, RTE_UINT16);
11750 : :
11751 : : static void
11752 : 0 : cmd_clear_vf_stats_parsed(
11753 : : void *parsed_result,
11754 : : __rte_unused struct cmdline *cl,
11755 : : __rte_unused void *data)
11756 : : {
11757 : : struct cmd_clear_vf_stats_result *res = parsed_result;
11758 : : int ret = -ENOTSUP;
11759 : :
11760 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11761 : : return;
11762 : :
11763 : : #ifdef RTE_NET_I40E
11764 : : if (ret == -ENOTSUP)
11765 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
11766 : 0 : res->vf_id);
11767 : : #endif
11768 : : #ifdef RTE_NET_BNXT
11769 : 0 : if (ret == -ENOTSUP)
11770 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
11771 : 0 : res->vf_id);
11772 : : #endif
11773 : :
11774 : 0 : switch (ret) {
11775 : : case 0:
11776 : : break;
11777 : 0 : case -EINVAL:
11778 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11779 : : break;
11780 : 0 : case -ENODEV:
11781 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11782 : : break;
11783 : 0 : case -ENOTSUP:
11784 : 0 : fprintf(stderr, "function not implemented\n");
11785 : : break;
11786 : 0 : default:
11787 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11788 : : }
11789 : : }
11790 : :
11791 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
11792 : : .f = cmd_clear_vf_stats_parsed,
11793 : : .data = NULL,
11794 : : .help_str = "clear vf stats <port_id> <vf_id>",
11795 : : .tokens = {
11796 : : (void *)&cmd_clear_vf_stats_clear,
11797 : : (void *)&cmd_clear_vf_stats_vf,
11798 : : (void *)&cmd_clear_vf_stats_stats,
11799 : : (void *)&cmd_clear_vf_stats_port_id,
11800 : : (void *)&cmd_clear_vf_stats_vf_id,
11801 : : NULL,
11802 : : },
11803 : : };
11804 : :
11805 : : /* Common result structure for file commands */
11806 : : struct cmd_cmdfile_result {
11807 : : cmdline_fixed_string_t load;
11808 : : cmdline_fixed_string_t filename;
11809 : : };
11810 : :
11811 : : /* Common CLI fields for file commands */
11812 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
11813 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
11814 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
11815 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
11816 : :
11817 : : static void
11818 : 0 : cmd_load_from_file_parsed(
11819 : : void *parsed_result,
11820 : : __rte_unused struct cmdline *cl,
11821 : : __rte_unused void *data)
11822 : : {
11823 : : struct cmd_cmdfile_result *res = parsed_result;
11824 : :
11825 : 0 : if (cmdline_read_from_file(res->filename, false) != 0) {
11826 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
11827 : : }
11828 : 0 : }
11829 : :
11830 : : static cmdline_parse_inst_t cmd_load_from_file = {
11831 : : .f = cmd_load_from_file_parsed,
11832 : : .data = NULL,
11833 : : .help_str = "load <filename>",
11834 : : .tokens = {
11835 : : (void *)&cmd_load_cmdfile,
11836 : : (void *)&cmd_load_cmdfile_filename,
11837 : : NULL,
11838 : : },
11839 : : };
11840 : :
11841 : : /* command to load a file with echoing commands */
11842 : : struct cmd_load_echo_result {
11843 : : cmdline_fixed_string_t load_echo;
11844 : : cmdline_fixed_string_t filename;
11845 : : };
11846 : :
11847 : : /* CLI fields for file load with echo command */
11848 : : static cmdline_parse_token_string_t cmd_load_echo =
11849 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, load_echo, "load_echo");
11850 : : static cmdline_parse_token_string_t cmd_load_echo_filename =
11851 : : TOKEN_STRING_INITIALIZER(struct cmd_load_echo_result, filename, NULL);
11852 : :
11853 : : static void
11854 : 0 : cmd_load_echo_file_parsed(
11855 : : void *parsed_result,
11856 : : __rte_unused struct cmdline *cl,
11857 : : __rte_unused void *data)
11858 : : {
11859 : : struct cmd_load_echo_result *res = parsed_result;
11860 : :
11861 : 0 : if (cmdline_read_from_file(res->filename, true) != 0)
11862 : 0 : fprintf(stderr, "Failed to load commands from file: %s\n", res->filename);
11863 : 0 : }
11864 : :
11865 : : static cmdline_parse_inst_t cmd_load_echo_file = {
11866 : : .f = cmd_load_echo_file_parsed,
11867 : : .data = NULL,
11868 : : .help_str = "load_echo <filename>",
11869 : : .tokens = {
11870 : : (void *)&cmd_load_echo,
11871 : : (void *)&cmd_load_echo_filename,
11872 : : NULL,
11873 : : },
11874 : : };
11875 : :
11876 : : /* Get Rx offloads capabilities */
11877 : : struct cmd_rx_offload_get_capa_result {
11878 : : cmdline_fixed_string_t show;
11879 : : cmdline_fixed_string_t port;
11880 : : portid_t port_id;
11881 : : cmdline_fixed_string_t rx_offload;
11882 : : cmdline_fixed_string_t capabilities;
11883 : : };
11884 : :
11885 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
11886 : : TOKEN_STRING_INITIALIZER
11887 : : (struct cmd_rx_offload_get_capa_result,
11888 : : show, "show");
11889 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
11890 : : TOKEN_STRING_INITIALIZER
11891 : : (struct cmd_rx_offload_get_capa_result,
11892 : : port, "port");
11893 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
11894 : : TOKEN_NUM_INITIALIZER
11895 : : (struct cmd_rx_offload_get_capa_result,
11896 : : port_id, RTE_UINT16);
11897 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
11898 : : TOKEN_STRING_INITIALIZER
11899 : : (struct cmd_rx_offload_get_capa_result,
11900 : : rx_offload, "rx_offload");
11901 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
11902 : : TOKEN_STRING_INITIALIZER
11903 : : (struct cmd_rx_offload_get_capa_result,
11904 : : capabilities, "capabilities");
11905 : :
11906 : : static void
11907 : 0 : print_rx_offloads(uint64_t offloads)
11908 : : {
11909 : : uint64_t single_offload;
11910 : : int begin;
11911 : : int end;
11912 : : int bit;
11913 : :
11914 : 0 : if (offloads == 0)
11915 : : return;
11916 : :
11917 : : begin = rte_ctz64(offloads);
11918 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11919 : :
11920 : 0 : single_offload = 1ULL << begin;
11921 : 0 : for (bit = begin; bit < end; bit++) {
11922 : 0 : if (offloads & single_offload)
11923 : 0 : printf(" %s",
11924 : : rte_eth_dev_rx_offload_name(single_offload));
11925 : 0 : single_offload <<= 1;
11926 : : }
11927 : : }
11928 : :
11929 : : static void
11930 : 0 : cmd_rx_offload_get_capa_parsed(
11931 : : void *parsed_result,
11932 : : __rte_unused struct cmdline *cl,
11933 : : __rte_unused void *data)
11934 : : {
11935 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
11936 : : struct rte_eth_dev_info dev_info;
11937 : 0 : portid_t port_id = res->port_id;
11938 : : uint64_t queue_offloads;
11939 : : uint64_t port_offloads;
11940 : : int ret;
11941 : :
11942 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11943 : 0 : if (ret != 0)
11944 : 0 : return;
11945 : :
11946 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
11947 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
11948 : :
11949 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
11950 : : printf(" Per Queue :");
11951 : 0 : print_rx_offloads(queue_offloads);
11952 : :
11953 : : printf("\n");
11954 : : printf(" Per Port :");
11955 : 0 : print_rx_offloads(port_offloads);
11956 : : printf("\n\n");
11957 : : }
11958 : :
11959 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
11960 : : .f = cmd_rx_offload_get_capa_parsed,
11961 : : .data = NULL,
11962 : : .help_str = "show port <port_id> rx_offload capabilities",
11963 : : .tokens = {
11964 : : (void *)&cmd_rx_offload_get_capa_show,
11965 : : (void *)&cmd_rx_offload_get_capa_port,
11966 : : (void *)&cmd_rx_offload_get_capa_port_id,
11967 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
11968 : : (void *)&cmd_rx_offload_get_capa_capabilities,
11969 : : NULL,
11970 : : }
11971 : : };
11972 : :
11973 : : /* Get Rx offloads configuration */
11974 : : struct cmd_rx_offload_get_configuration_result {
11975 : : cmdline_fixed_string_t show;
11976 : : cmdline_fixed_string_t port;
11977 : : portid_t port_id;
11978 : : cmdline_fixed_string_t rx_offload;
11979 : : cmdline_fixed_string_t configuration;
11980 : : };
11981 : :
11982 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
11983 : : TOKEN_STRING_INITIALIZER
11984 : : (struct cmd_rx_offload_get_configuration_result,
11985 : : show, "show");
11986 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
11987 : : TOKEN_STRING_INITIALIZER
11988 : : (struct cmd_rx_offload_get_configuration_result,
11989 : : port, "port");
11990 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
11991 : : TOKEN_NUM_INITIALIZER
11992 : : (struct cmd_rx_offload_get_configuration_result,
11993 : : port_id, RTE_UINT16);
11994 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
11995 : : TOKEN_STRING_INITIALIZER
11996 : : (struct cmd_rx_offload_get_configuration_result,
11997 : : rx_offload, "rx_offload");
11998 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
11999 : : TOKEN_STRING_INITIALIZER
12000 : : (struct cmd_rx_offload_get_configuration_result,
12001 : : configuration, "configuration");
12002 : :
12003 : : static void
12004 : 0 : cmd_rx_offload_get_configuration_parsed(
12005 : : void *parsed_result,
12006 : : __rte_unused struct cmdline *cl,
12007 : : __rte_unused void *data)
12008 : : {
12009 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
12010 : : struct rte_eth_dev_info dev_info;
12011 : 0 : portid_t port_id = res->port_id;
12012 : : struct rte_port *port;
12013 : : struct rte_eth_conf dev_conf;
12014 : : uint64_t port_offloads;
12015 : : uint64_t queue_offloads;
12016 : : uint16_t nb_rx_queues;
12017 : : int q;
12018 : : int ret;
12019 : :
12020 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12021 : 0 : if (ret != 0)
12022 : 0 : return;
12023 : :
12024 : 0 : port = &ports[port_id];
12025 : : printf("Rx Offloading Configuration of port %d :\n", port_id);
12026 : :
12027 : 0 : port_offloads = dev_conf.rxmode.offloads;
12028 : : printf(" Port :");
12029 : 0 : print_rx_offloads(port_offloads);
12030 : : printf("\n");
12031 : :
12032 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12033 : 0 : if (ret != 0)
12034 : : return;
12035 : :
12036 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12037 : 0 : for (q = 0; q < nb_rx_queues; q++) {
12038 : 0 : queue_offloads = port->rxq[q].conf.offloads;
12039 : : printf(" Queue[%2d] :", q);
12040 : 0 : print_rx_offloads(queue_offloads);
12041 : : printf("\n");
12042 : : }
12043 : : printf("\n");
12044 : : }
12045 : :
12046 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
12047 : : .f = cmd_rx_offload_get_configuration_parsed,
12048 : : .data = NULL,
12049 : : .help_str = "show port <port_id> rx_offload configuration",
12050 : : .tokens = {
12051 : : (void *)&cmd_rx_offload_get_configuration_show,
12052 : : (void *)&cmd_rx_offload_get_configuration_port,
12053 : : (void *)&cmd_rx_offload_get_configuration_port_id,
12054 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
12055 : : (void *)&cmd_rx_offload_get_configuration_configuration,
12056 : : NULL,
12057 : : }
12058 : : };
12059 : :
12060 : : /* Enable/Disable a per port offloading */
12061 : : struct cmd_config_per_port_rx_offload_result {
12062 : : cmdline_fixed_string_t port;
12063 : : cmdline_fixed_string_t config;
12064 : : portid_t port_id;
12065 : : cmdline_fixed_string_t rx_offload;
12066 : : cmdline_fixed_string_t offload;
12067 : : cmdline_fixed_string_t on_off;
12068 : : };
12069 : :
12070 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
12071 : : TOKEN_STRING_INITIALIZER
12072 : : (struct cmd_config_per_port_rx_offload_result,
12073 : : port, "port");
12074 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
12075 : : TOKEN_STRING_INITIALIZER
12076 : : (struct cmd_config_per_port_rx_offload_result,
12077 : : config, "config");
12078 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
12079 : : TOKEN_NUM_INITIALIZER
12080 : : (struct cmd_config_per_port_rx_offload_result,
12081 : : port_id, RTE_UINT16);
12082 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
12083 : : TOKEN_STRING_INITIALIZER
12084 : : (struct cmd_config_per_port_rx_offload_result,
12085 : : rx_offload, "rx_offload");
12086 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
12087 : : TOKEN_STRING_INITIALIZER
12088 : : (struct cmd_config_per_port_rx_offload_result,
12089 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12090 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12091 : : "vlan_filter#vlan_extend#"
12092 : : "scatter#buffer_split#timestamp#security#"
12093 : : "keep_crc#rss_hash");
12094 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
12095 : : TOKEN_STRING_INITIALIZER
12096 : : (struct cmd_config_per_port_rx_offload_result,
12097 : : on_off, "on#off");
12098 : :
12099 : : static uint64_t
12100 : 0 : search_rx_offload(const char *name)
12101 : : {
12102 : : uint64_t single_offload;
12103 : : const char *single_name;
12104 : : int found = 0;
12105 : : unsigned int bit;
12106 : :
12107 : : single_offload = 1;
12108 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12109 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
12110 : 0 : if (!strcasecmp(single_name, name)) {
12111 : : found = 1;
12112 : : break;
12113 : : }
12114 : 0 : single_offload <<= 1;
12115 : : }
12116 : :
12117 : 0 : if (found)
12118 : 0 : return single_offload;
12119 : :
12120 : : return 0;
12121 : : }
12122 : :
12123 : : static void
12124 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
12125 : : {
12126 : : struct rte_eth_dev_info dev_info;
12127 : : struct rte_port *port;
12128 : : uint16_t nb_rx_queues;
12129 : : uint64_t offload;
12130 : : int q;
12131 : : int ret;
12132 : :
12133 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12134 : 0 : if (ret != 0)
12135 : 0 : return;
12136 : :
12137 : 0 : port = &ports[port_id];
12138 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12139 : 0 : fprintf(stderr,
12140 : : "Error: Can't config offload when Port %d is not stopped\n",
12141 : : port_id);
12142 : 0 : return;
12143 : : }
12144 : :
12145 : 0 : if (!strcmp(name, "all")) {
12146 : 0 : offload = dev_info.rx_offload_capa;
12147 : : } else {
12148 : 0 : offload = search_rx_offload(name);
12149 : 0 : if (offload == 0) {
12150 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12151 : 0 : return;
12152 : : }
12153 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
12154 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12155 : : port_id, name);
12156 : 0 : return;
12157 : : }
12158 : : }
12159 : :
12160 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
12161 : 0 : if (on) {
12162 : 0 : port->dev_conf.rxmode.offloads |= offload;
12163 : 0 : for (q = 0; q < nb_rx_queues; q++)
12164 : 0 : port->rxq[q].conf.offloads |= offload;
12165 : : } else {
12166 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
12167 : 0 : for (q = 0; q < nb_rx_queues; q++)
12168 : 0 : port->rxq[q].conf.offloads &= ~offload;
12169 : : }
12170 : :
12171 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12172 : : }
12173 : :
12174 : : static void
12175 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
12176 : : __rte_unused struct cmdline *cl,
12177 : : __rte_unused void *data)
12178 : : {
12179 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
12180 : : bool on;
12181 : :
12182 : 0 : on = strcmp(res->on_off, "on") == 0;
12183 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
12184 : 0 : }
12185 : :
12186 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
12187 : : .f = cmd_config_per_port_rx_offload_parsed,
12188 : : .data = NULL,
12189 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
12190 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12191 : : "macsec_strip|vlan_filter|vlan_extend|"
12192 : : "scatter|buffer_split|timestamp|security|"
12193 : : "keep_crc|rss_hash on|off",
12194 : : .tokens = {
12195 : : (void *)&cmd_config_per_port_rx_offload_result_port,
12196 : : (void *)&cmd_config_per_port_rx_offload_result_config,
12197 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
12198 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
12199 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
12200 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
12201 : : NULL,
12202 : : }
12203 : : };
12204 : :
12205 : : /* Enable/Disable all port Rx offloading */
12206 : : struct cmd_config_all_port_rx_offload_result {
12207 : : cmdline_fixed_string_t port;
12208 : : cmdline_fixed_string_t config;
12209 : : cmdline_fixed_string_t port_all;
12210 : : cmdline_fixed_string_t rx_offload;
12211 : : cmdline_fixed_string_t offload;
12212 : : cmdline_fixed_string_t on_off;
12213 : : };
12214 : :
12215 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
12216 : : TOKEN_STRING_INITIALIZER
12217 : : (struct cmd_config_all_port_rx_offload_result,
12218 : : port, "port");
12219 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
12220 : : TOKEN_STRING_INITIALIZER
12221 : : (struct cmd_config_all_port_rx_offload_result,
12222 : : config, "config");
12223 : :
12224 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
12225 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
12226 : : port_all, "all");
12227 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
12228 : : TOKEN_STRING_INITIALIZER
12229 : : (struct cmd_config_all_port_rx_offload_result,
12230 : : rx_offload, "rx_offload");
12231 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
12232 : : TOKEN_STRING_INITIALIZER
12233 : : (struct cmd_config_all_port_rx_offload_result,
12234 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12235 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12236 : : "vlan_filter#vlan_extend#"
12237 : : "scatter#buffer_split#timestamp#security#"
12238 : : "keep_crc#rss_hash");
12239 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
12240 : : TOKEN_STRING_INITIALIZER
12241 : : (struct cmd_config_all_port_rx_offload_result,
12242 : : on_off, "on#off");
12243 : :
12244 : : static void
12245 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
12246 : : __rte_unused struct cmdline *cl,
12247 : : __rte_unused void *data)
12248 : : {
12249 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
12250 : : bool on_off;
12251 : : portid_t i;
12252 : :
12253 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12254 : 0 : RTE_ETH_FOREACH_DEV(i)
12255 : 0 : config_port_rx_offload(i, res->offload, on_off);
12256 : :
12257 : 0 : }
12258 : :
12259 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
12260 : : .f = cmd_config_all_port_rx_offload_parsed,
12261 : : .data = NULL,
12262 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
12263 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12264 : : "macsec_strip|vlan_filter|vlan_extend|"
12265 : : "scatter|buffer_split|timestamp|security|"
12266 : : "keep_crc|rss_hash on|off",
12267 : : .tokens = {
12268 : : (void *)&cmd_config_all_port_rx_offload_result_port,
12269 : : (void *)&cmd_config_all_port_rx_offload_result_config,
12270 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
12271 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
12272 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
12273 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
12274 : : NULL,
12275 : : }
12276 : : };
12277 : :
12278 : : /* Enable/Disable a per queue offloading */
12279 : : struct cmd_config_per_queue_rx_offload_result {
12280 : : cmdline_fixed_string_t port;
12281 : : portid_t port_id;
12282 : : cmdline_fixed_string_t rxq;
12283 : : uint16_t queue_id;
12284 : : cmdline_fixed_string_t rx_offload;
12285 : : cmdline_fixed_string_t offload;
12286 : : cmdline_fixed_string_t on_off;
12287 : : };
12288 : :
12289 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
12290 : : TOKEN_STRING_INITIALIZER
12291 : : (struct cmd_config_per_queue_rx_offload_result,
12292 : : port, "port");
12293 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
12294 : : TOKEN_NUM_INITIALIZER
12295 : : (struct cmd_config_per_queue_rx_offload_result,
12296 : : port_id, RTE_UINT16);
12297 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
12298 : : TOKEN_STRING_INITIALIZER
12299 : : (struct cmd_config_per_queue_rx_offload_result,
12300 : : rxq, "rxq");
12301 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
12302 : : TOKEN_NUM_INITIALIZER
12303 : : (struct cmd_config_per_queue_rx_offload_result,
12304 : : queue_id, RTE_UINT16);
12305 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
12306 : : TOKEN_STRING_INITIALIZER
12307 : : (struct cmd_config_per_queue_rx_offload_result,
12308 : : rx_offload, "rx_offload");
12309 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
12310 : : TOKEN_STRING_INITIALIZER
12311 : : (struct cmd_config_per_queue_rx_offload_result,
12312 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12313 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12314 : : "vlan_filter#vlan_extend#"
12315 : : "scatter#buffer_split#timestamp#security#keep_crc");
12316 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
12317 : : TOKEN_STRING_INITIALIZER
12318 : : (struct cmd_config_per_queue_rx_offload_result,
12319 : : on_off, "on#off");
12320 : :
12321 : : static void
12322 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
12323 : : __rte_unused struct cmdline *cl,
12324 : : __rte_unused void *data)
12325 : : {
12326 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
12327 : : struct rte_eth_dev_info dev_info;
12328 : 0 : portid_t port_id = res->port_id;
12329 : 0 : uint16_t queue_id = res->queue_id;
12330 : : struct rte_port *port;
12331 : : uint64_t offload;
12332 : : int ret;
12333 : :
12334 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12335 : 0 : if (ret != 0)
12336 : 0 : return;
12337 : :
12338 : 0 : port = &ports[port_id];
12339 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12340 : 0 : fprintf(stderr,
12341 : : "Error: Can't config offload when Port %d is not stopped\n",
12342 : : port_id);
12343 : 0 : return;
12344 : : }
12345 : :
12346 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
12347 : 0 : fprintf(stderr,
12348 : : "Error: input queue_id should be 0 ... %d\n",
12349 : 0 : dev_info.nb_rx_queues - 1);
12350 : 0 : return;
12351 : : }
12352 : :
12353 : 0 : if (!strcmp(res->offload, "all")) {
12354 : 0 : offload = dev_info.rx_queue_offload_capa;
12355 : : } else {
12356 : 0 : offload = search_rx_offload(res->offload);
12357 : 0 : if (offload == 0) {
12358 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12359 : 0 : return;
12360 : : }
12361 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
12362 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12363 : : port_id, res->offload);
12364 : 0 : return;
12365 : : }
12366 : : }
12367 : :
12368 : 0 : if (!strcmp(res->on_off, "on"))
12369 : 0 : port->rxq[queue_id].conf.offloads |= offload;
12370 : : else
12371 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
12372 : :
12373 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12374 : : }
12375 : :
12376 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
12377 : : .f = cmd_config_per_queue_rx_offload_parsed,
12378 : : .data = NULL,
12379 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
12380 : : "all|vlan_strip|ipv4_cksum|"
12381 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12382 : : "macsec_strip|vlan_filter|vlan_extend|"
12383 : : "scatter|buffer_split|timestamp|security|"
12384 : : "keep_crc on|off",
12385 : : .tokens = {
12386 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
12387 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
12388 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
12389 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
12390 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
12391 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
12392 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
12393 : : NULL,
12394 : : }
12395 : : };
12396 : :
12397 : : /* Get Tx offloads capabilities */
12398 : : struct cmd_tx_offload_get_capa_result {
12399 : : cmdline_fixed_string_t show;
12400 : : cmdline_fixed_string_t port;
12401 : : portid_t port_id;
12402 : : cmdline_fixed_string_t tx_offload;
12403 : : cmdline_fixed_string_t capabilities;
12404 : : };
12405 : :
12406 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
12407 : : TOKEN_STRING_INITIALIZER
12408 : : (struct cmd_tx_offload_get_capa_result,
12409 : : show, "show");
12410 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
12411 : : TOKEN_STRING_INITIALIZER
12412 : : (struct cmd_tx_offload_get_capa_result,
12413 : : port, "port");
12414 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
12415 : : TOKEN_NUM_INITIALIZER
12416 : : (struct cmd_tx_offload_get_capa_result,
12417 : : port_id, RTE_UINT16);
12418 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
12419 : : TOKEN_STRING_INITIALIZER
12420 : : (struct cmd_tx_offload_get_capa_result,
12421 : : tx_offload, "tx_offload");
12422 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
12423 : : TOKEN_STRING_INITIALIZER
12424 : : (struct cmd_tx_offload_get_capa_result,
12425 : : capabilities, "capabilities");
12426 : :
12427 : : static void
12428 : 0 : print_tx_offloads(uint64_t offloads)
12429 : : {
12430 : : uint64_t single_offload;
12431 : : int begin;
12432 : : int end;
12433 : : int bit;
12434 : :
12435 : 0 : if (offloads == 0)
12436 : : return;
12437 : :
12438 : : begin = rte_ctz64(offloads);
12439 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12440 : :
12441 : 0 : single_offload = 1ULL << begin;
12442 : 0 : for (bit = begin; bit < end; bit++) {
12443 : 0 : if (offloads & single_offload)
12444 : 0 : printf(" %s",
12445 : : rte_eth_dev_tx_offload_name(single_offload));
12446 : 0 : single_offload <<= 1;
12447 : : }
12448 : : }
12449 : :
12450 : : static void
12451 : 0 : cmd_tx_offload_get_capa_parsed(
12452 : : void *parsed_result,
12453 : : __rte_unused struct cmdline *cl,
12454 : : __rte_unused void *data)
12455 : : {
12456 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
12457 : : struct rte_eth_dev_info dev_info;
12458 : 0 : portid_t port_id = res->port_id;
12459 : : uint64_t queue_offloads;
12460 : : uint64_t port_offloads;
12461 : : int ret;
12462 : :
12463 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12464 : 0 : if (ret != 0)
12465 : 0 : return;
12466 : :
12467 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
12468 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
12469 : :
12470 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
12471 : : printf(" Per Queue :");
12472 : 0 : print_tx_offloads(queue_offloads);
12473 : :
12474 : : printf("\n");
12475 : : printf(" Per Port :");
12476 : 0 : print_tx_offloads(port_offloads);
12477 : : printf("\n\n");
12478 : : }
12479 : :
12480 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
12481 : : .f = cmd_tx_offload_get_capa_parsed,
12482 : : .data = NULL,
12483 : : .help_str = "show port <port_id> tx_offload capabilities",
12484 : : .tokens = {
12485 : : (void *)&cmd_tx_offload_get_capa_show,
12486 : : (void *)&cmd_tx_offload_get_capa_port,
12487 : : (void *)&cmd_tx_offload_get_capa_port_id,
12488 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
12489 : : (void *)&cmd_tx_offload_get_capa_capabilities,
12490 : : NULL,
12491 : : }
12492 : : };
12493 : :
12494 : : /* Get Tx offloads configuration */
12495 : : struct cmd_tx_offload_get_configuration_result {
12496 : : cmdline_fixed_string_t show;
12497 : : cmdline_fixed_string_t port;
12498 : : portid_t port_id;
12499 : : cmdline_fixed_string_t tx_offload;
12500 : : cmdline_fixed_string_t configuration;
12501 : : };
12502 : :
12503 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
12504 : : TOKEN_STRING_INITIALIZER
12505 : : (struct cmd_tx_offload_get_configuration_result,
12506 : : show, "show");
12507 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
12508 : : TOKEN_STRING_INITIALIZER
12509 : : (struct cmd_tx_offload_get_configuration_result,
12510 : : port, "port");
12511 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
12512 : : TOKEN_NUM_INITIALIZER
12513 : : (struct cmd_tx_offload_get_configuration_result,
12514 : : port_id, RTE_UINT16);
12515 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
12516 : : TOKEN_STRING_INITIALIZER
12517 : : (struct cmd_tx_offload_get_configuration_result,
12518 : : tx_offload, "tx_offload");
12519 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
12520 : : TOKEN_STRING_INITIALIZER
12521 : : (struct cmd_tx_offload_get_configuration_result,
12522 : : configuration, "configuration");
12523 : :
12524 : : static void
12525 : 0 : cmd_tx_offload_get_configuration_parsed(
12526 : : void *parsed_result,
12527 : : __rte_unused struct cmdline *cl,
12528 : : __rte_unused void *data)
12529 : : {
12530 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
12531 : : struct rte_eth_dev_info dev_info;
12532 : 0 : portid_t port_id = res->port_id;
12533 : : struct rte_port *port;
12534 : : struct rte_eth_conf dev_conf;
12535 : : uint64_t port_offloads;
12536 : : uint64_t queue_offloads;
12537 : : uint16_t nb_tx_queues;
12538 : : int q;
12539 : : int ret;
12540 : :
12541 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12542 : 0 : if (ret != 0)
12543 : 0 : return;
12544 : :
12545 : : printf("Tx Offloading Configuration of port %d :\n", port_id);
12546 : 0 : port = &ports[port_id];
12547 : 0 : port_offloads = dev_conf.txmode.offloads;
12548 : : printf(" Port :");
12549 : 0 : print_tx_offloads(port_offloads);
12550 : : printf("\n");
12551 : :
12552 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12553 : 0 : if (ret != 0)
12554 : : return;
12555 : :
12556 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12557 : 0 : for (q = 0; q < nb_tx_queues; q++) {
12558 : 0 : queue_offloads = port->txq[q].conf.offloads;
12559 : : printf(" Queue[%2d] :", q);
12560 : 0 : print_tx_offloads(queue_offloads);
12561 : : printf("\n");
12562 : : }
12563 : : printf("\n");
12564 : : }
12565 : :
12566 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
12567 : : .f = cmd_tx_offload_get_configuration_parsed,
12568 : : .data = NULL,
12569 : : .help_str = "show port <port_id> tx_offload configuration",
12570 : : .tokens = {
12571 : : (void *)&cmd_tx_offload_get_configuration_show,
12572 : : (void *)&cmd_tx_offload_get_configuration_port,
12573 : : (void *)&cmd_tx_offload_get_configuration_port_id,
12574 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
12575 : : (void *)&cmd_tx_offload_get_configuration_configuration,
12576 : : NULL,
12577 : : }
12578 : : };
12579 : :
12580 : : /* Enable/Disable a per port offloading */
12581 : : struct cmd_config_per_port_tx_offload_result {
12582 : : cmdline_fixed_string_t port;
12583 : : cmdline_fixed_string_t config;
12584 : : portid_t port_id;
12585 : : cmdline_fixed_string_t tx_offload;
12586 : : cmdline_fixed_string_t offload;
12587 : : cmdline_fixed_string_t on_off;
12588 : : };
12589 : :
12590 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
12591 : : TOKEN_STRING_INITIALIZER
12592 : : (struct cmd_config_per_port_tx_offload_result,
12593 : : port, "port");
12594 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
12595 : : TOKEN_STRING_INITIALIZER
12596 : : (struct cmd_config_per_port_tx_offload_result,
12597 : : config, "config");
12598 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
12599 : : TOKEN_NUM_INITIALIZER
12600 : : (struct cmd_config_per_port_tx_offload_result,
12601 : : port_id, RTE_UINT16);
12602 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
12603 : : TOKEN_STRING_INITIALIZER
12604 : : (struct cmd_config_per_port_tx_offload_result,
12605 : : tx_offload, "tx_offload");
12606 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
12607 : : TOKEN_STRING_INITIALIZER
12608 : : (struct cmd_config_per_port_tx_offload_result,
12609 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12610 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12611 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12612 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12613 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12614 : : "send_on_timestamp");
12615 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
12616 : : TOKEN_STRING_INITIALIZER
12617 : : (struct cmd_config_per_port_tx_offload_result,
12618 : : on_off, "on#off");
12619 : :
12620 : : static uint64_t
12621 : 0 : search_tx_offload(const char *name)
12622 : : {
12623 : : uint64_t single_offload;
12624 : : const char *single_name;
12625 : : int found = 0;
12626 : : unsigned int bit;
12627 : :
12628 : : single_offload = 1;
12629 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12630 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
12631 : 0 : if (single_name == NULL)
12632 : : break;
12633 : 0 : if (!strcasecmp(single_name, name)) {
12634 : : found = 1;
12635 : : break;
12636 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
12637 : : break;
12638 : 0 : single_offload <<= 1;
12639 : : }
12640 : :
12641 : 0 : if (found)
12642 : 0 : return single_offload;
12643 : :
12644 : : return 0;
12645 : : }
12646 : :
12647 : : static void
12648 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
12649 : : {
12650 : : struct rte_eth_dev_info dev_info;
12651 : : struct rte_port *port;
12652 : : uint16_t nb_tx_queues;
12653 : : uint64_t offload;
12654 : : int q;
12655 : : int ret;
12656 : :
12657 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12658 : 0 : if (ret != 0)
12659 : 0 : return;
12660 : :
12661 : 0 : port = &ports[port_id];
12662 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12663 : 0 : fprintf(stderr,
12664 : : "Error: Can't config offload when Port %d is not stopped\n",
12665 : : port_id);
12666 : 0 : return;
12667 : : }
12668 : :
12669 : 0 : if (!strcmp(name, "all")) {
12670 : 0 : offload = dev_info.tx_offload_capa;
12671 : : } else {
12672 : 0 : offload = search_tx_offload(name);
12673 : 0 : if (offload == 0) {
12674 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12675 : 0 : return;
12676 : : }
12677 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
12678 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12679 : : port_id, name);
12680 : 0 : return;
12681 : : }
12682 : : }
12683 : :
12684 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12685 : 0 : if (on) {
12686 : 0 : port->dev_conf.txmode.offloads |= offload;
12687 : 0 : for (q = 0; q < nb_tx_queues; q++)
12688 : 0 : port->txq[q].conf.offloads |= offload;
12689 : : } else {
12690 : 0 : port->dev_conf.txmode.offloads &= ~offload;
12691 : 0 : for (q = 0; q < nb_tx_queues; q++)
12692 : 0 : port->txq[q].conf.offloads &= ~offload;
12693 : : }
12694 : :
12695 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12696 : : }
12697 : :
12698 : : static void
12699 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
12700 : : __rte_unused struct cmdline *cl,
12701 : : __rte_unused void *data)
12702 : : {
12703 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
12704 : : bool on;
12705 : :
12706 : 0 : on = strcmp(res->on_off, "on") == 0;
12707 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
12708 : 0 : }
12709 : :
12710 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
12711 : : .f = cmd_config_per_port_tx_offload_parsed,
12712 : : .data = NULL,
12713 : : .help_str = "port config <port_id> tx_offload "
12714 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12715 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12716 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12717 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12718 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12719 : : "send_on_timestamp on|off",
12720 : : .tokens = {
12721 : : (void *)&cmd_config_per_port_tx_offload_result_port,
12722 : : (void *)&cmd_config_per_port_tx_offload_result_config,
12723 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
12724 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
12725 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
12726 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
12727 : : NULL,
12728 : : }
12729 : : };
12730 : :
12731 : : /* Enable/Disable all port Tx offloading */
12732 : : struct cmd_config_all_port_tx_offload_result {
12733 : : cmdline_fixed_string_t port;
12734 : : cmdline_fixed_string_t config;
12735 : : cmdline_fixed_string_t port_all;
12736 : : cmdline_fixed_string_t tx_offload;
12737 : : cmdline_fixed_string_t offload;
12738 : : cmdline_fixed_string_t on_off;
12739 : : };
12740 : :
12741 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
12742 : : TOKEN_STRING_INITIALIZER
12743 : : (struct cmd_config_all_port_tx_offload_result,
12744 : : port, "port");
12745 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
12746 : : TOKEN_STRING_INITIALIZER
12747 : : (struct cmd_config_all_port_tx_offload_result,
12748 : : config, "config");
12749 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
12750 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
12751 : : port_all, "all");
12752 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
12753 : : TOKEN_STRING_INITIALIZER
12754 : : (struct cmd_config_all_port_tx_offload_result,
12755 : : tx_offload, "tx_offload");
12756 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
12757 : : TOKEN_STRING_INITIALIZER
12758 : : (struct cmd_config_all_port_tx_offload_result,
12759 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12760 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12761 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12762 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12763 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12764 : : "send_on_timestamp");
12765 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
12766 : : TOKEN_STRING_INITIALIZER
12767 : : (struct cmd_config_all_port_tx_offload_result,
12768 : : on_off, "on#off");
12769 : :
12770 : : static void
12771 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
12772 : : __rte_unused struct cmdline *cl,
12773 : : __rte_unused void *data)
12774 : : {
12775 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
12776 : : portid_t i;
12777 : : bool on_off;
12778 : :
12779 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12780 : 0 : RTE_ETH_FOREACH_DEV(i)
12781 : 0 : config_port_tx_offload(i, res->offload, on_off);
12782 : 0 : }
12783 : :
12784 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
12785 : : .f = cmd_config_all_port_tx_offload_parsed,
12786 : : .data = NULL,
12787 : : .help_str = "port config all tx_offload "
12788 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12789 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12790 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12791 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12792 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12793 : : "send_on_timestamp on|off",
12794 : : .tokens = {
12795 : : (void *)&cmd_config_all_port_tx_offload_result_port,
12796 : : (void *)&cmd_config_all_port_tx_offload_result_config,
12797 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
12798 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
12799 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
12800 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
12801 : : NULL,
12802 : : }
12803 : : };
12804 : :
12805 : : /* Enable/Disable a per queue offloading */
12806 : : struct cmd_config_per_queue_tx_offload_result {
12807 : : cmdline_fixed_string_t port;
12808 : : portid_t port_id;
12809 : : cmdline_fixed_string_t txq;
12810 : : uint16_t queue_id;
12811 : : cmdline_fixed_string_t tx_offload;
12812 : : cmdline_fixed_string_t offload;
12813 : : cmdline_fixed_string_t on_off;
12814 : : };
12815 : :
12816 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
12817 : : TOKEN_STRING_INITIALIZER
12818 : : (struct cmd_config_per_queue_tx_offload_result,
12819 : : port, "port");
12820 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
12821 : : TOKEN_NUM_INITIALIZER
12822 : : (struct cmd_config_per_queue_tx_offload_result,
12823 : : port_id, RTE_UINT16);
12824 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
12825 : : TOKEN_STRING_INITIALIZER
12826 : : (struct cmd_config_per_queue_tx_offload_result,
12827 : : txq, "txq");
12828 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
12829 : : TOKEN_NUM_INITIALIZER
12830 : : (struct cmd_config_per_queue_tx_offload_result,
12831 : : queue_id, RTE_UINT16);
12832 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
12833 : : TOKEN_STRING_INITIALIZER
12834 : : (struct cmd_config_per_queue_tx_offload_result,
12835 : : tx_offload, "tx_offload");
12836 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
12837 : : TOKEN_STRING_INITIALIZER
12838 : : (struct cmd_config_per_queue_tx_offload_result,
12839 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12840 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12841 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12842 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12843 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
12844 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
12845 : : TOKEN_STRING_INITIALIZER
12846 : : (struct cmd_config_per_queue_tx_offload_result,
12847 : : on_off, "on#off");
12848 : :
12849 : : static void
12850 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
12851 : : __rte_unused struct cmdline *cl,
12852 : : __rte_unused void *data)
12853 : : {
12854 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
12855 : : struct rte_eth_dev_info dev_info;
12856 : 0 : portid_t port_id = res->port_id;
12857 : 0 : uint16_t queue_id = res->queue_id;
12858 : : struct rte_port *port;
12859 : : uint64_t offload;
12860 : : int ret;
12861 : :
12862 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12863 : 0 : if (ret != 0)
12864 : 0 : return;
12865 : :
12866 : 0 : port = &ports[port_id];
12867 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12868 : 0 : fprintf(stderr,
12869 : : "Error: Can't config offload when Port %d is not stopped\n",
12870 : : port_id);
12871 : 0 : return;
12872 : : }
12873 : :
12874 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
12875 : 0 : fprintf(stderr,
12876 : : "Error: input queue_id should be 0 ... %d\n",
12877 : 0 : dev_info.nb_tx_queues - 1);
12878 : 0 : return;
12879 : : }
12880 : :
12881 : 0 : if (!strcmp(res->offload, "all")) {
12882 : 0 : offload = dev_info.tx_queue_offload_capa;
12883 : : } else {
12884 : 0 : offload = search_tx_offload(res->offload);
12885 : 0 : if (offload == 0) {
12886 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12887 : 0 : return;
12888 : : }
12889 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
12890 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12891 : : port_id, res->offload);
12892 : 0 : return;
12893 : : }
12894 : : }
12895 : :
12896 : 0 : if (!strcmp(res->on_off, "on"))
12897 : 0 : port->txq[queue_id].conf.offloads |= offload;
12898 : : else
12899 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
12900 : :
12901 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12902 : : }
12903 : :
12904 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
12905 : : .f = cmd_config_per_queue_tx_offload_parsed,
12906 : : .data = NULL,
12907 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
12908 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12909 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12910 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12911 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12912 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
12913 : : "on|off",
12914 : : .tokens = {
12915 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
12916 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
12917 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
12918 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
12919 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
12920 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
12921 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
12922 : : NULL,
12923 : : }
12924 : : };
12925 : :
12926 : : /* *** configure tx_metadata for specific port *** */
12927 : : struct cmd_config_tx_metadata_specific_result {
12928 : : cmdline_fixed_string_t port;
12929 : : cmdline_fixed_string_t keyword;
12930 : : uint16_t port_id;
12931 : : cmdline_fixed_string_t item;
12932 : : uint32_t value;
12933 : : };
12934 : :
12935 : : static void
12936 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
12937 : : __rte_unused struct cmdline *cl,
12938 : : __rte_unused void *data)
12939 : : {
12940 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
12941 : :
12942 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12943 : : return;
12944 : 0 : ports[res->port_id].tx_metadata = res->value;
12945 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
12946 : 0 : if (ports[res->port_id].tx_metadata)
12947 : 0 : add_tx_md_callback(res->port_id);
12948 : : else
12949 : 0 : remove_tx_md_callback(res->port_id);
12950 : 0 : rte_flow_dynf_metadata_register();
12951 : : }
12952 : :
12953 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
12954 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12955 : : port, "port");
12956 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
12957 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12958 : : keyword, "config");
12959 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
12960 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12961 : : port_id, RTE_UINT16);
12962 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
12963 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12964 : : item, "tx_metadata");
12965 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
12966 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12967 : : value, RTE_UINT32);
12968 : :
12969 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
12970 : : .f = cmd_config_tx_metadata_specific_parsed,
12971 : : .data = NULL,
12972 : : .help_str = "port config <port_id> tx_metadata <value>",
12973 : : .tokens = {
12974 : : (void *)&cmd_config_tx_metadata_specific_port,
12975 : : (void *)&cmd_config_tx_metadata_specific_keyword,
12976 : : (void *)&cmd_config_tx_metadata_specific_id,
12977 : : (void *)&cmd_config_tx_metadata_specific_item,
12978 : : (void *)&cmd_config_tx_metadata_specific_value,
12979 : : NULL,
12980 : : },
12981 : : };
12982 : :
12983 : : /* *** set dynf *** */
12984 : : struct cmd_config_tx_dynf_specific_result {
12985 : : cmdline_fixed_string_t port;
12986 : : cmdline_fixed_string_t keyword;
12987 : : uint16_t port_id;
12988 : : cmdline_fixed_string_t item;
12989 : : cmdline_fixed_string_t name;
12990 : : cmdline_fixed_string_t value;
12991 : : };
12992 : :
12993 : : static void
12994 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
12995 : : __rte_unused struct cmdline *cl,
12996 : : __rte_unused void *data)
12997 : : {
12998 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
12999 : : struct rte_mbuf_dynflag desc_flag;
13000 : : int flag;
13001 : : uint64_t old_port_flags;
13002 : :
13003 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
13004 : 0 : return;
13005 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
13006 : 0 : if (flag <= 0) {
13007 : 0 : if (strlcpy(desc_flag.name, res->name,
13008 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
13009 : 0 : fprintf(stderr, "Flag name too long\n");
13010 : 0 : return;
13011 : : }
13012 : 0 : desc_flag.flags = 0;
13013 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
13014 : 0 : if (flag < 0) {
13015 : 0 : fprintf(stderr, "Can't register flag\n");
13016 : 0 : return;
13017 : : }
13018 : 0 : strcpy(dynf_names[flag], desc_flag.name);
13019 : : }
13020 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
13021 : 0 : if (!strcmp(res->value, "set")) {
13022 : 0 : ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
13023 : 0 : if (old_port_flags == 0)
13024 : 0 : add_tx_dynf_callback(res->port_id);
13025 : : } else {
13026 : 0 : ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
13027 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
13028 : 0 : remove_tx_dynf_callback(res->port_id);
13029 : : }
13030 : : }
13031 : :
13032 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
13033 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13034 : : keyword, "port");
13035 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
13036 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13037 : : keyword, "config");
13038 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
13039 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13040 : : port_id, RTE_UINT16);
13041 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
13042 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13043 : : item, "dynf");
13044 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
13045 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13046 : : name, NULL);
13047 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
13048 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
13049 : : value, "set#clear");
13050 : :
13051 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
13052 : : .f = cmd_config_dynf_specific_parsed,
13053 : : .data = NULL,
13054 : : .help_str = "port config <port id> dynf <name> set|clear",
13055 : : .tokens = {
13056 : : (void *)&cmd_config_tx_dynf_specific_port,
13057 : : (void *)&cmd_config_tx_dynf_specific_keyword,
13058 : : (void *)&cmd_config_tx_dynf_specific_port_id,
13059 : : (void *)&cmd_config_tx_dynf_specific_item,
13060 : : (void *)&cmd_config_tx_dynf_specific_name,
13061 : : (void *)&cmd_config_tx_dynf_specific_value,
13062 : : NULL,
13063 : : },
13064 : : };
13065 : :
13066 : : /* *** display tx_metadata per port configuration *** */
13067 : : struct cmd_show_tx_metadata_result {
13068 : : cmdline_fixed_string_t cmd_show;
13069 : : cmdline_fixed_string_t cmd_port;
13070 : : cmdline_fixed_string_t cmd_keyword;
13071 : : portid_t cmd_pid;
13072 : : };
13073 : :
13074 : : static void
13075 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
13076 : : __rte_unused struct cmdline *cl,
13077 : : __rte_unused void *data)
13078 : : {
13079 : : struct cmd_show_tx_metadata_result *res = parsed_result;
13080 : :
13081 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13082 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
13083 : 0 : return;
13084 : : }
13085 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
13086 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
13087 : 0 : ports[res->cmd_pid].tx_metadata);
13088 : : }
13089 : : }
13090 : :
13091 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
13092 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13093 : : cmd_show, "show");
13094 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
13095 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13096 : : cmd_port, "port");
13097 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
13098 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
13099 : : cmd_pid, RTE_UINT16);
13100 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
13101 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
13102 : : cmd_keyword, "tx_metadata");
13103 : :
13104 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
13105 : : .f = cmd_show_tx_metadata_parsed,
13106 : : .data = NULL,
13107 : : .help_str = "show port <port_id> tx_metadata",
13108 : : .tokens = {
13109 : : (void *)&cmd_show_tx_metadata_show,
13110 : : (void *)&cmd_show_tx_metadata_port,
13111 : : (void *)&cmd_show_tx_metadata_pid,
13112 : : (void *)&cmd_show_tx_metadata_keyword,
13113 : : NULL,
13114 : : },
13115 : : };
13116 : :
13117 : : /* *** show fec capability per port configuration *** */
13118 : : struct cmd_show_fec_capability_result {
13119 : : cmdline_fixed_string_t cmd_show;
13120 : : cmdline_fixed_string_t cmd_port;
13121 : : cmdline_fixed_string_t cmd_fec;
13122 : : cmdline_fixed_string_t cmd_keyword;
13123 : : portid_t cmd_pid;
13124 : : };
13125 : :
13126 : : static void
13127 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
13128 : : __rte_unused struct cmdline *cl,
13129 : : __rte_unused void *data)
13130 : : {
13131 : : struct cmd_show_fec_capability_result *res = parsed_result;
13132 : : struct rte_eth_fec_capa *speed_fec_capa;
13133 : : unsigned int num;
13134 : : int ret;
13135 : :
13136 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13137 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13138 : 0 : return;
13139 : : }
13140 : :
13141 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
13142 : 0 : if (ret == -ENOTSUP) {
13143 : 0 : fprintf(stderr, "Function not implemented\n");
13144 : 0 : return;
13145 : 0 : } else if (ret < 0) {
13146 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
13147 : 0 : return;
13148 : : }
13149 : :
13150 : 0 : num = (unsigned int)ret;
13151 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
13152 : 0 : if (speed_fec_capa == NULL) {
13153 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
13154 : 0 : return;
13155 : : }
13156 : :
13157 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
13158 : 0 : if (ret < 0) {
13159 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
13160 : 0 : goto out;
13161 : : }
13162 : :
13163 : 0 : show_fec_capability(num, speed_fec_capa);
13164 : 0 : out:
13165 : 0 : free(speed_fec_capa);
13166 : : }
13167 : :
13168 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
13169 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13170 : : cmd_show, "show");
13171 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
13172 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13173 : : cmd_port, "port");
13174 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
13175 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
13176 : : cmd_pid, RTE_UINT16);
13177 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
13178 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13179 : : cmd_fec, "fec");
13180 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
13181 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
13182 : : cmd_keyword, "capabilities");
13183 : :
13184 : : static cmdline_parse_inst_t cmd_show_capability = {
13185 : : .f = cmd_show_fec_capability_parsed,
13186 : : .data = NULL,
13187 : : .help_str = "show port <port_id> fec capabilities",
13188 : : .tokens = {
13189 : : (void *)&cmd_show_fec_capability_show,
13190 : : (void *)&cmd_show_fec_capability_port,
13191 : : (void *)&cmd_show_fec_capability_pid,
13192 : : (void *)&cmd_show_fec_capability_fec,
13193 : : (void *)&cmd_show_fec_capability_keyword,
13194 : : NULL,
13195 : : },
13196 : : };
13197 : :
13198 : : /* *** show fec mode per port configuration *** */
13199 : : struct cmd_show_fec_metadata_result {
13200 : : cmdline_fixed_string_t cmd_show;
13201 : : cmdline_fixed_string_t cmd_port;
13202 : : cmdline_fixed_string_t cmd_keyword;
13203 : : portid_t cmd_pid;
13204 : : };
13205 : :
13206 : : static void
13207 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
13208 : : __rte_unused struct cmdline *cl,
13209 : : __rte_unused void *data)
13210 : : {
13211 : : #define FEC_NAME_SIZE 16
13212 : : struct cmd_show_fec_metadata_result *res = parsed_result;
13213 : : uint32_t mode;
13214 : : char buf[FEC_NAME_SIZE];
13215 : : int ret;
13216 : :
13217 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13218 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13219 : 0 : return;
13220 : : }
13221 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
13222 : 0 : if (ret == -ENOTSUP) {
13223 : 0 : fprintf(stderr, "Function not implemented\n");
13224 : 0 : return;
13225 : 0 : } else if (ret < 0) {
13226 : 0 : fprintf(stderr, "Get FEC mode failed\n");
13227 : 0 : return;
13228 : : }
13229 : :
13230 : 0 : switch (mode) {
13231 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
13232 : : strlcpy(buf, "off", sizeof(buf));
13233 : : break;
13234 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
13235 : : strlcpy(buf, "auto", sizeof(buf));
13236 : : break;
13237 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
13238 : : strlcpy(buf, "baser", sizeof(buf));
13239 : : break;
13240 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
13241 : : strlcpy(buf, "rs", sizeof(buf));
13242 : : break;
13243 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
13244 : : strlcpy(buf, "llrs", sizeof(buf));
13245 : : break;
13246 : : default:
13247 : : return;
13248 : : }
13249 : :
13250 : : printf("%s\n", buf);
13251 : : }
13252 : :
13253 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
13254 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13255 : : cmd_show, "show");
13256 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
13257 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13258 : : cmd_port, "port");
13259 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
13260 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
13261 : : cmd_pid, RTE_UINT16);
13262 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
13263 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13264 : : cmd_keyword, "fec_mode");
13265 : :
13266 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
13267 : : .f = cmd_show_fec_mode_parsed,
13268 : : .data = NULL,
13269 : : .help_str = "show port <port_id> fec_mode",
13270 : : .tokens = {
13271 : : (void *)&cmd_show_fec_mode_show,
13272 : : (void *)&cmd_show_fec_mode_port,
13273 : : (void *)&cmd_show_fec_mode_pid,
13274 : : (void *)&cmd_show_fec_mode_keyword,
13275 : : NULL,
13276 : : },
13277 : : };
13278 : :
13279 : : /* *** set fec mode per port configuration *** */
13280 : : struct cmd_set_port_fec_mode {
13281 : : cmdline_fixed_string_t set;
13282 : : cmdline_fixed_string_t port;
13283 : : portid_t port_id;
13284 : : cmdline_fixed_string_t fec_mode;
13285 : : cmdline_fixed_string_t fec_value;
13286 : : };
13287 : :
13288 : : /* Common CLI fields for set fec mode */
13289 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
13290 : : TOKEN_STRING_INITIALIZER
13291 : : (struct cmd_set_port_fec_mode,
13292 : : set, "set");
13293 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
13294 : : TOKEN_STRING_INITIALIZER
13295 : : (struct cmd_set_port_fec_mode,
13296 : : port, "port");
13297 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
13298 : : TOKEN_NUM_INITIALIZER
13299 : : (struct cmd_set_port_fec_mode,
13300 : : port_id, RTE_UINT16);
13301 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
13302 : : TOKEN_STRING_INITIALIZER
13303 : : (struct cmd_set_port_fec_mode,
13304 : : fec_mode, "fec_mode");
13305 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
13306 : : TOKEN_STRING_INITIALIZER
13307 : : (struct cmd_set_port_fec_mode,
13308 : : fec_value, NULL);
13309 : :
13310 : : static void
13311 : 0 : cmd_set_port_fec_mode_parsed(
13312 : : void *parsed_result,
13313 : : __rte_unused struct cmdline *cl,
13314 : : __rte_unused void *data)
13315 : : {
13316 : : struct cmd_set_port_fec_mode *res = parsed_result;
13317 : 0 : uint16_t port_id = res->port_id;
13318 : : uint32_t fec_capa;
13319 : : int ret;
13320 : :
13321 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
13322 : 0 : if (ret < 0) {
13323 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
13324 : : res->fec_value, port_id);
13325 : 0 : return;
13326 : : }
13327 : :
13328 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
13329 : 0 : if (ret == -ENOTSUP) {
13330 : 0 : fprintf(stderr, "Function not implemented\n");
13331 : 0 : return;
13332 : 0 : } else if (ret < 0) {
13333 : 0 : fprintf(stderr, "Set FEC mode failed\n");
13334 : 0 : return;
13335 : : }
13336 : : }
13337 : :
13338 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
13339 : : .f = cmd_set_port_fec_mode_parsed,
13340 : : .data = NULL,
13341 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
13342 : : .tokens = {
13343 : : (void *)&cmd_set_port_fec_mode_set,
13344 : : (void *)&cmd_set_port_fec_mode_port,
13345 : : (void *)&cmd_set_port_fec_mode_port_id,
13346 : : (void *)&cmd_set_port_fec_mode_str,
13347 : : (void *)&cmd_set_port_fec_mode_value,
13348 : : NULL,
13349 : : },
13350 : : };
13351 : :
13352 : : /* *** set available descriptors threshold for an RxQ of a port *** */
13353 : : struct cmd_set_rxq_avail_thresh_result {
13354 : : cmdline_fixed_string_t set;
13355 : : cmdline_fixed_string_t port;
13356 : : uint16_t port_num;
13357 : : cmdline_fixed_string_t rxq;
13358 : : uint16_t rxq_num;
13359 : : cmdline_fixed_string_t avail_thresh;
13360 : : uint8_t avail_thresh_num;
13361 : : };
13362 : :
13363 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
13364 : : __rte_unused struct cmdline *cl,
13365 : : __rte_unused void *data)
13366 : : {
13367 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
13368 : : int ret = 0;
13369 : :
13370 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
13371 : 0 : && (strcmp(res->rxq, "rxq") == 0)
13372 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
13373 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
13374 : 0 : res->avail_thresh_num);
13375 : 0 : if (ret < 0)
13376 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
13377 : :
13378 : 0 : }
13379 : :
13380 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
13381 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13382 : : set, "set");
13383 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
13384 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13385 : : port, "port");
13386 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
13387 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13388 : : port_num, RTE_UINT16);
13389 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
13390 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13391 : : rxq, "rxq");
13392 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
13393 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13394 : : rxq_num, RTE_UINT16);
13395 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
13396 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13397 : : avail_thresh, "avail_thresh");
13398 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
13399 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13400 : : avail_thresh_num, RTE_UINT8);
13401 : :
13402 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
13403 : : .f = cmd_set_rxq_avail_thresh_parsed,
13404 : : .data = (void *)0,
13405 : : .help_str =
13406 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
13407 : : "Set available descriptors threshold for Rx queue",
13408 : : .tokens = {
13409 : : (void *)&cmd_set_rxq_avail_thresh_set,
13410 : : (void *)&cmd_set_rxq_avail_thresh_port,
13411 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
13412 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
13413 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
13414 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
13415 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
13416 : : NULL,
13417 : : },
13418 : : };
13419 : :
13420 : : /* show port supported ptypes */
13421 : :
13422 : : /* Common result structure for show port ptypes */
13423 : : struct cmd_show_port_supported_ptypes_result {
13424 : : cmdline_fixed_string_t show;
13425 : : cmdline_fixed_string_t port;
13426 : : portid_t port_id;
13427 : : cmdline_fixed_string_t ptypes;
13428 : : };
13429 : :
13430 : : /* Common CLI fields for show port ptypes */
13431 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
13432 : : TOKEN_STRING_INITIALIZER
13433 : : (struct cmd_show_port_supported_ptypes_result,
13434 : : show, "show");
13435 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
13436 : : TOKEN_STRING_INITIALIZER
13437 : : (struct cmd_show_port_supported_ptypes_result,
13438 : : port, "port");
13439 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
13440 : : TOKEN_NUM_INITIALIZER
13441 : : (struct cmd_show_port_supported_ptypes_result,
13442 : : port_id, RTE_UINT16);
13443 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
13444 : : TOKEN_STRING_INITIALIZER
13445 : : (struct cmd_show_port_supported_ptypes_result,
13446 : : ptypes, "ptypes");
13447 : :
13448 : : static void
13449 : 0 : cmd_show_port_supported_ptypes_parsed(
13450 : : void *parsed_result,
13451 : : __rte_unused struct cmdline *cl,
13452 : : __rte_unused void *data)
13453 : : {
13454 : : #define RSVD_PTYPE_MASK 0xf0000000
13455 : : #define MAX_PTYPES_PER_LAYER 16
13456 : : #define LTYPE_NAMESIZE 32
13457 : : #define PTYPE_NAMESIZE 256
13458 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
13459 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
13460 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
13461 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
13462 : 0 : uint16_t port_id = res->port_id;
13463 : : int ret, i;
13464 : :
13465 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
13466 : 0 : if (ret < 0)
13467 : 0 : return;
13468 : :
13469 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
13470 : :
13471 : 0 : switch (ptype_mask) {
13472 : : case RTE_PTYPE_L2_MASK:
13473 : : strlcpy(ltype, "L2", sizeof(ltype));
13474 : : break;
13475 : : case RTE_PTYPE_L3_MASK:
13476 : : strlcpy(ltype, "L3", sizeof(ltype));
13477 : : break;
13478 : : case RTE_PTYPE_L4_MASK:
13479 : : strlcpy(ltype, "L4", sizeof(ltype));
13480 : : break;
13481 : : case RTE_PTYPE_TUNNEL_MASK:
13482 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
13483 : : break;
13484 : : case RTE_PTYPE_INNER_L2_MASK:
13485 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
13486 : : break;
13487 : : case RTE_PTYPE_INNER_L3_MASK:
13488 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
13489 : : break;
13490 : : case RTE_PTYPE_INNER_L4_MASK:
13491 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
13492 : : break;
13493 : : default:
13494 : : return;
13495 : : }
13496 : :
13497 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
13498 : : ptype_mask, ptypes,
13499 : : MAX_PTYPES_PER_LAYER);
13500 : :
13501 : 0 : if (ret > 0)
13502 : : printf("Supported %s ptypes:\n", ltype);
13503 : : else
13504 : : printf("%s ptypes unsupported\n", ltype);
13505 : :
13506 : 0 : for (i = 0; i < ret; ++i) {
13507 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
13508 : : printf("%s\n", buf);
13509 : : }
13510 : :
13511 : 0 : ptype_mask <<= 4;
13512 : : }
13513 : : }
13514 : :
13515 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
13516 : : .f = cmd_show_port_supported_ptypes_parsed,
13517 : : .data = NULL,
13518 : : .help_str = "show port <port_id> ptypes",
13519 : : .tokens = {
13520 : : (void *)&cmd_show_port_supported_ptypes_show,
13521 : : (void *)&cmd_show_port_supported_ptypes_port,
13522 : : (void *)&cmd_show_port_supported_ptypes_port_id,
13523 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
13524 : : NULL,
13525 : : },
13526 : : };
13527 : :
13528 : : /* *** display rx/tx descriptor status *** */
13529 : : struct cmd_show_rx_tx_desc_status_result {
13530 : : cmdline_fixed_string_t cmd_show;
13531 : : cmdline_fixed_string_t cmd_port;
13532 : : cmdline_fixed_string_t cmd_keyword;
13533 : : cmdline_fixed_string_t cmd_desc;
13534 : : cmdline_fixed_string_t cmd_status;
13535 : : portid_t cmd_pid;
13536 : : portid_t cmd_qid;
13537 : : portid_t cmd_did;
13538 : : };
13539 : :
13540 : : static void
13541 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
13542 : : __rte_unused struct cmdline *cl,
13543 : : __rte_unused void *data)
13544 : : {
13545 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
13546 : : int rc;
13547 : :
13548 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
13549 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13550 : 0 : fprintf(stderr,
13551 : : "Invalid input: port id = %d, queue id = %d\n",
13552 : 0 : res->cmd_pid, res->cmd_qid);
13553 : 0 : return;
13554 : : }
13555 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
13556 : 0 : res->cmd_did);
13557 : 0 : if (rc < 0) {
13558 : 0 : fprintf(stderr,
13559 : : "Invalid input: queue id = %d, desc id = %d\n",
13560 : 0 : res->cmd_qid, res->cmd_did);
13561 : 0 : return;
13562 : : }
13563 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
13564 : : printf("Desc status = AVAILABLE\n");
13565 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
13566 : : printf("Desc status = DONE\n");
13567 : : else
13568 : : printf("Desc status = UNAVAILABLE\n");
13569 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
13570 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13571 : 0 : fprintf(stderr,
13572 : : "Invalid input: port id = %d, queue id = %d\n",
13573 : 0 : res->cmd_pid, res->cmd_qid);
13574 : 0 : return;
13575 : : }
13576 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
13577 : 0 : res->cmd_did);
13578 : 0 : if (rc < 0) {
13579 : 0 : fprintf(stderr,
13580 : : "Invalid input: queue id = %d, desc id = %d\n",
13581 : 0 : res->cmd_qid, res->cmd_did);
13582 : 0 : return;
13583 : : }
13584 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
13585 : : printf("Desc status = FULL\n");
13586 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
13587 : : printf("Desc status = DONE\n");
13588 : : else
13589 : : printf("Desc status = UNAVAILABLE\n");
13590 : : }
13591 : : }
13592 : :
13593 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
13594 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13595 : : cmd_show, "show");
13596 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
13597 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13598 : : cmd_port, "port");
13599 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
13600 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13601 : : cmd_pid, RTE_UINT16);
13602 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
13603 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13604 : : cmd_keyword, "rxq#txq");
13605 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
13606 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13607 : : cmd_qid, RTE_UINT16);
13608 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
13609 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13610 : : cmd_desc, "desc");
13611 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
13612 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13613 : : cmd_did, RTE_UINT16);
13614 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
13615 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13616 : : cmd_status, "status");
13617 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
13618 : : .f = cmd_show_rx_tx_desc_status_parsed,
13619 : : .data = NULL,
13620 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
13621 : : "status",
13622 : : .tokens = {
13623 : : (void *)&cmd_show_rx_tx_desc_status_show,
13624 : : (void *)&cmd_show_rx_tx_desc_status_port,
13625 : : (void *)&cmd_show_rx_tx_desc_status_pid,
13626 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
13627 : : (void *)&cmd_show_rx_tx_desc_status_qid,
13628 : : (void *)&cmd_show_rx_tx_desc_status_desc,
13629 : : (void *)&cmd_show_rx_tx_desc_status_did,
13630 : : (void *)&cmd_show_rx_tx_desc_status_status,
13631 : : NULL,
13632 : : },
13633 : : };
13634 : :
13635 : : /* *** display rx/tx queue descriptor used count *** */
13636 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
13637 : : cmdline_fixed_string_t cmd_show;
13638 : : cmdline_fixed_string_t cmd_port;
13639 : : cmdline_fixed_string_t cmd_dir;
13640 : : cmdline_fixed_string_t cmd_desc;
13641 : : cmdline_fixed_string_t cmd_used;
13642 : : cmdline_fixed_string_t cmd_count;
13643 : : portid_t cmd_pid;
13644 : : portid_t cmd_qid;
13645 : : };
13646 : :
13647 : : static void
13648 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
13649 : : __rte_unused void *data)
13650 : : {
13651 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
13652 : : int rc;
13653 : :
13654 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
13655 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13656 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13657 : 0 : res->cmd_pid, res->cmd_qid);
13658 : 0 : return;
13659 : : }
13660 : :
13661 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
13662 : 0 : if (rc < 0) {
13663 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
13664 : 0 : res->cmd_qid);
13665 : 0 : return;
13666 : : }
13667 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
13668 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
13669 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13670 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13671 : 0 : res->cmd_pid, res->cmd_qid);
13672 : 0 : return;
13673 : : }
13674 : :
13675 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
13676 : 0 : if (rc < 0) {
13677 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
13678 : 0 : res->cmd_qid);
13679 : 0 : return;
13680 : : }
13681 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
13682 : : }
13683 : : }
13684 : :
13685 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
13686 : : TOKEN_STRING_INITIALIZER
13687 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13688 : : cmd_show, "show");
13689 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
13690 : : TOKEN_STRING_INITIALIZER
13691 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13692 : : cmd_port, "port");
13693 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
13694 : : TOKEN_NUM_INITIALIZER
13695 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13696 : : cmd_pid, RTE_UINT16);
13697 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
13698 : : TOKEN_STRING_INITIALIZER
13699 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13700 : : cmd_dir, "rxq#txq");
13701 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
13702 : : TOKEN_NUM_INITIALIZER
13703 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13704 : : cmd_qid, RTE_UINT16);
13705 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
13706 : : TOKEN_STRING_INITIALIZER
13707 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13708 : : cmd_desc, "desc");
13709 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
13710 : : TOKEN_STRING_INITIALIZER
13711 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13712 : : cmd_count, "used");
13713 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
13714 : : TOKEN_STRING_INITIALIZER
13715 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13716 : : cmd_count, "count");
13717 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
13718 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
13719 : : .data = NULL,
13720 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
13721 : : .tokens = {
13722 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
13723 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
13724 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
13725 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
13726 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
13727 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
13728 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
13729 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
13730 : : NULL,
13731 : : },
13732 : : };
13733 : :
13734 : : /* Common result structure for set port ptypes */
13735 : : struct cmd_set_port_ptypes_result {
13736 : : cmdline_fixed_string_t set;
13737 : : cmdline_fixed_string_t port;
13738 : : portid_t port_id;
13739 : : cmdline_fixed_string_t ptype_mask;
13740 : : uint32_t mask;
13741 : : };
13742 : :
13743 : : /* Common CLI fields for set port ptypes */
13744 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
13745 : : TOKEN_STRING_INITIALIZER
13746 : : (struct cmd_set_port_ptypes_result,
13747 : : set, "set");
13748 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
13749 : : TOKEN_STRING_INITIALIZER
13750 : : (struct cmd_set_port_ptypes_result,
13751 : : port, "port");
13752 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
13753 : : TOKEN_NUM_INITIALIZER
13754 : : (struct cmd_set_port_ptypes_result,
13755 : : port_id, RTE_UINT16);
13756 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
13757 : : TOKEN_STRING_INITIALIZER
13758 : : (struct cmd_set_port_ptypes_result,
13759 : : ptype_mask, "ptype_mask");
13760 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
13761 : : TOKEN_NUM_INITIALIZER
13762 : : (struct cmd_set_port_ptypes_result,
13763 : : mask, RTE_UINT32);
13764 : :
13765 : : static void
13766 : 0 : cmd_set_port_ptypes_parsed(
13767 : : void *parsed_result,
13768 : : __rte_unused struct cmdline *cl,
13769 : : __rte_unused void *data)
13770 : : {
13771 : : struct cmd_set_port_ptypes_result *res = parsed_result;
13772 : : #define PTYPE_NAMESIZE 256
13773 : : char ptype_name[PTYPE_NAMESIZE];
13774 : 0 : uint16_t port_id = res->port_id;
13775 : 0 : uint32_t ptype_mask = res->mask;
13776 : : int ret, i;
13777 : :
13778 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
13779 : : NULL, 0);
13780 : 0 : if (ret <= 0) {
13781 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
13782 : : port_id);
13783 : 0 : return;
13784 : : }
13785 : :
13786 : 0 : uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
13787 : :
13788 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
13789 : 0 : if (ret < 0) {
13790 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
13791 : : port_id);
13792 : 0 : return;
13793 : : }
13794 : :
13795 : : printf("Successfully set following ptypes for Port %d\n", port_id);
13796 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
13797 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
13798 : : printf("%s\n", ptype_name);
13799 : : }
13800 : :
13801 : 0 : clear_ptypes = false;
13802 : : }
13803 : :
13804 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
13805 : : .f = cmd_set_port_ptypes_parsed,
13806 : : .data = NULL,
13807 : : .help_str = "set port <port_id> ptype_mask <mask>",
13808 : : .tokens = {
13809 : : (void *)&cmd_set_port_ptypes_set,
13810 : : (void *)&cmd_set_port_ptypes_port,
13811 : : (void *)&cmd_set_port_ptypes_port_id,
13812 : : (void *)&cmd_set_port_ptypes_mask_str,
13813 : : (void *)&cmd_set_port_ptypes_mask_u32,
13814 : : NULL,
13815 : : },
13816 : : };
13817 : :
13818 : : /* *** display mac addresses added to a port *** */
13819 : : struct cmd_showport_macs_result {
13820 : : cmdline_fixed_string_t cmd_show;
13821 : : cmdline_fixed_string_t cmd_port;
13822 : : cmdline_fixed_string_t cmd_keyword;
13823 : : portid_t cmd_pid;
13824 : : };
13825 : :
13826 : : static void
13827 : 0 : cmd_showport_macs_parsed(void *parsed_result,
13828 : : __rte_unused struct cmdline *cl,
13829 : : __rte_unused void *data)
13830 : : {
13831 : : struct cmd_showport_macs_result *res = parsed_result;
13832 : :
13833 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
13834 : : return;
13835 : :
13836 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
13837 : 0 : show_macs(res->cmd_pid);
13838 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
13839 : 0 : show_mcast_macs(res->cmd_pid);
13840 : : }
13841 : :
13842 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
13843 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13844 : : cmd_show, "show");
13845 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
13846 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13847 : : cmd_port, "port");
13848 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
13849 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
13850 : : cmd_pid, RTE_UINT16);
13851 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
13852 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13853 : : cmd_keyword, "macs#mcast_macs");
13854 : :
13855 : : static cmdline_parse_inst_t cmd_showport_macs = {
13856 : : .f = cmd_showport_macs_parsed,
13857 : : .data = NULL,
13858 : : .help_str = "show port <port_id> macs|mcast_macs",
13859 : : .tokens = {
13860 : : (void *)&cmd_showport_macs_show,
13861 : : (void *)&cmd_showport_macs_port,
13862 : : (void *)&cmd_showport_macs_pid,
13863 : : (void *)&cmd_showport_macs_keyword,
13864 : : NULL,
13865 : : },
13866 : : };
13867 : :
13868 : : /* *** show flow transfer proxy port ID for the given port *** */
13869 : : struct cmd_show_port_flow_transfer_proxy_result {
13870 : : cmdline_fixed_string_t show;
13871 : : cmdline_fixed_string_t port;
13872 : : portid_t port_id;
13873 : : cmdline_fixed_string_t flow;
13874 : : cmdline_fixed_string_t transfer;
13875 : : cmdline_fixed_string_t proxy;
13876 : : };
13877 : :
13878 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
13879 : : TOKEN_STRING_INITIALIZER
13880 : : (struct cmd_show_port_flow_transfer_proxy_result,
13881 : : show, "show");
13882 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
13883 : : TOKEN_STRING_INITIALIZER
13884 : : (struct cmd_show_port_flow_transfer_proxy_result,
13885 : : port, "port");
13886 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
13887 : : TOKEN_NUM_INITIALIZER
13888 : : (struct cmd_show_port_flow_transfer_proxy_result,
13889 : : port_id, RTE_UINT16);
13890 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
13891 : : TOKEN_STRING_INITIALIZER
13892 : : (struct cmd_show_port_flow_transfer_proxy_result,
13893 : : flow, "flow");
13894 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
13895 : : TOKEN_STRING_INITIALIZER
13896 : : (struct cmd_show_port_flow_transfer_proxy_result,
13897 : : transfer, "transfer");
13898 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
13899 : : TOKEN_STRING_INITIALIZER
13900 : : (struct cmd_show_port_flow_transfer_proxy_result,
13901 : : proxy, "proxy");
13902 : :
13903 : : static void
13904 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
13905 : : __rte_unused struct cmdline *cl,
13906 : : __rte_unused void *data)
13907 : : {
13908 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
13909 : : portid_t proxy_port_id;
13910 : : int ret;
13911 : :
13912 : : printf("\n");
13913 : :
13914 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
13915 : 0 : if (ret != 0) {
13916 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
13917 : : rte_strerror(-ret));
13918 : 0 : return;
13919 : : }
13920 : :
13921 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
13922 : : }
13923 : :
13924 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
13925 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
13926 : : .data = NULL,
13927 : : .help_str = "show port <port_id> flow transfer proxy",
13928 : : .tokens = {
13929 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
13930 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
13931 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
13932 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
13933 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
13934 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
13935 : : NULL,
13936 : : }
13937 : : };
13938 : :
13939 : : /* *** configure port txq affinity value *** */
13940 : : struct cmd_config_tx_affinity_map {
13941 : : cmdline_fixed_string_t port;
13942 : : cmdline_fixed_string_t config;
13943 : : portid_t portid;
13944 : : cmdline_fixed_string_t txq;
13945 : : uint16_t qid;
13946 : : cmdline_fixed_string_t affinity;
13947 : : uint8_t value;
13948 : : };
13949 : :
13950 : : static void
13951 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
13952 : : __rte_unused struct cmdline *cl,
13953 : : __rte_unused void *data)
13954 : : {
13955 : : struct cmd_config_tx_affinity_map *res = parsed_result;
13956 : : int ret;
13957 : :
13958 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
13959 : : return;
13960 : :
13961 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
13962 : : printf("Invalid port id\n");
13963 : 0 : return;
13964 : : }
13965 : :
13966 : 0 : if (strcmp(res->txq, "txq")) {
13967 : : printf("Unknown parameter\n");
13968 : 0 : return;
13969 : : }
13970 : 0 : if (tx_queue_id_is_invalid(res->qid))
13971 : : return;
13972 : :
13973 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
13974 : 0 : if (ret < 0) {
13975 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
13976 : : strerror(-ret));
13977 : 0 : return;
13978 : : }
13979 : :
13980 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
13981 : 0 : if (ret != 0) {
13982 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
13983 : : rte_strerror(-ret));
13984 : 0 : return;
13985 : : }
13986 : : }
13987 : :
13988 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
13989 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13990 : : port, "port");
13991 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
13992 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13993 : : config, "config");
13994 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
13995 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13996 : : portid, RTE_UINT16);
13997 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
13998 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13999 : : txq, "txq");
14000 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
14001 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14002 : : qid, RTE_UINT16);
14003 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
14004 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
14005 : : affinity, "affinity");
14006 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
14007 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
14008 : : value, RTE_UINT8);
14009 : :
14010 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
14011 : : .f = cmd_config_tx_affinity_map_parsed,
14012 : : .data = (void *)0,
14013 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
14014 : : .tokens = {
14015 : : (void *)&cmd_config_tx_affinity_map_port,
14016 : : (void *)&cmd_config_tx_affinity_map_config,
14017 : : (void *)&cmd_config_tx_affinity_map_portid,
14018 : : (void *)&cmd_config_tx_affinity_map_txq,
14019 : : (void *)&cmd_config_tx_affinity_map_qid,
14020 : : (void *)&cmd_config_tx_affinity_map_affinity,
14021 : : (void *)&cmd_config_tx_affinity_map_value,
14022 : : NULL,
14023 : : },
14024 : : };
14025 : :
14026 : : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
14027 : : struct cmd_dev_led_result {
14028 : : cmdline_fixed_string_t set;
14029 : : cmdline_fixed_string_t port;
14030 : : portid_t port_id;
14031 : : cmdline_fixed_string_t led;
14032 : : cmdline_fixed_string_t state;
14033 : : };
14034 : :
14035 : : static void
14036 : 0 : cmd_set_dev_led_parsed(void *parsed_result,
14037 : : __rte_unused struct cmdline *cl,
14038 : : __rte_unused void *data)
14039 : : {
14040 : : struct cmd_dev_led_result *res = parsed_result;
14041 : :
14042 : 0 : if (strcmp(res->state, "on") == 0)
14043 : 0 : set_dev_led(res->port_id, true);
14044 : : else
14045 : 0 : set_dev_led(res->port_id, false);
14046 : 0 : }
14047 : :
14048 : : static cmdline_parse_token_string_t cmd_dev_led_set =
14049 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
14050 : : static cmdline_parse_token_string_t cmd_dev_led_port =
14051 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
14052 : : static cmdline_parse_token_num_t cmd_dev_led_port_id =
14053 : : TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
14054 : : static cmdline_parse_token_string_t cmd_dev_led =
14055 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
14056 : : static cmdline_parse_token_string_t cmd_dev_state =
14057 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
14058 : :
14059 : : static cmdline_parse_inst_t cmd_set_dev_led = {
14060 : : .f = cmd_set_dev_led_parsed,
14061 : : .data = NULL,
14062 : : .help_str = "set port <port_id> led <on/off>",
14063 : : .tokens = {
14064 : : (void *)&cmd_dev_led_set,
14065 : : (void *)&cmd_dev_led_port,
14066 : : (void *)&cmd_dev_led_port_id,
14067 : : (void *)&cmd_dev_led,
14068 : : (void *)&cmd_dev_state,
14069 : : NULL,
14070 : : },
14071 : : };
14072 : :
14073 : : /* ******************************************************************************** */
14074 : :
14075 : : /* list of instructions */
14076 : : static cmdline_parse_ctx_t builtin_ctx[] = {
14077 : : &cmd_help_brief,
14078 : : &cmd_help_long,
14079 : : &cmd_quit,
14080 : : &cmd_load_from_file,
14081 : : &cmd_load_echo_file,
14082 : : &cmd_showport,
14083 : : &cmd_showqueue,
14084 : : &cmd_showeeprom,
14085 : : &cmd_seteeprom,
14086 : : &cmd_showportall,
14087 : : &cmd_representor_info,
14088 : : &cmd_showdevice,
14089 : : &cmd_showcfg,
14090 : : &cmd_showfwdall,
14091 : : &cmd_start,
14092 : : &cmd_start_tx_first,
14093 : : &cmd_start_tx_first_n,
14094 : : &cmd_set_link_up,
14095 : : &cmd_set_link_down,
14096 : : &cmd_reset,
14097 : : &cmd_set_numbers,
14098 : : &cmd_set_log,
14099 : : &cmd_set_rxoffs,
14100 : : &cmd_set_rxpkts,
14101 : : &cmd_set_rxhdrs,
14102 : : &cmd_set_txpkts,
14103 : : &cmd_set_txsplit,
14104 : : &cmd_set_txtimes,
14105 : : &cmd_set_fwd_list,
14106 : : &cmd_set_fwd_mask,
14107 : : &cmd_set_fwd_mode,
14108 : : &cmd_set_fwd_retry_mode,
14109 : : &cmd_set_dcb_fwd_tc,
14110 : : &cmd_set_dcb_fwd_tc_cores,
14111 : : &cmd_set_burst_tx_retry,
14112 : : &cmd_set_promisc_mode_one,
14113 : : &cmd_set_promisc_mode_all,
14114 : : &cmd_set_allmulti_mode_one,
14115 : : &cmd_set_allmulti_mode_all,
14116 : : &cmd_set_flush_rx,
14117 : : &cmd_set_link_check,
14118 : : &cmd_vlan_offload,
14119 : : &cmd_vlan_tpid,
14120 : : &cmd_rx_vlan_filter_all,
14121 : : &cmd_rx_vlan_filter,
14122 : : &cmd_tx_vlan_set,
14123 : : &cmd_tx_vlan_set_qinq,
14124 : : &cmd_tx_vlan_reset,
14125 : : &cmd_tx_vlan_set_pvid,
14126 : : &cmd_csum_set,
14127 : : &cmd_csum_show,
14128 : : &cmd_csum_tunnel,
14129 : : &cmd_csum_mac_swap,
14130 : : &cmd_tso_set,
14131 : : &cmd_tso_show,
14132 : : &cmd_tunnel_tso_set,
14133 : : &cmd_tunnel_tso_show,
14134 : : #ifdef RTE_LIB_GRO
14135 : : &cmd_gro_enable,
14136 : : &cmd_gro_flush,
14137 : : &cmd_gro_show,
14138 : : #endif
14139 : : #ifdef RTE_LIB_GSO
14140 : : &cmd_gso_enable,
14141 : : &cmd_gso_size,
14142 : : &cmd_gso_show,
14143 : : #endif
14144 : : &cmd_link_flow_control_set,
14145 : : &cmd_link_flow_control_set_rx,
14146 : : &cmd_link_flow_control_set_tx,
14147 : : &cmd_link_flow_control_set_hw,
14148 : : &cmd_link_flow_control_set_lw,
14149 : : &cmd_link_flow_control_set_pt,
14150 : : &cmd_link_flow_control_set_xon,
14151 : : &cmd_link_flow_control_set_macfwd,
14152 : : &cmd_link_flow_control_set_autoneg,
14153 : : &cmd_link_flow_control_show,
14154 : : &cmd_priority_flow_control_set,
14155 : : &cmd_queue_priority_flow_control_set,
14156 : : &cmd_config_dcb,
14157 : : &cmd_read_rxd_txd,
14158 : : &cmd_stop,
14159 : : &cmd_mac_addr,
14160 : : &cmd_set_fwd_eth_peer,
14161 : : &cmd_set_xstats_hide_zero,
14162 : : &cmd_set_xstats_show_state,
14163 : : &cmd_set_xstats_hide_disabled,
14164 : : &cmd_operate_set_counter,
14165 : : &cmd_set_record_core_cycles,
14166 : : &cmd_set_record_burst_stats,
14167 : : &cmd_operate_port,
14168 : : &cmd_operate_specific_port,
14169 : : &cmd_operate_attach_port,
14170 : : &cmd_operate_detach_port,
14171 : : &cmd_operate_detach_device,
14172 : : &cmd_set_port_setup_on,
14173 : : &cmd_config_speed_all,
14174 : : &cmd_config_speed_specific,
14175 : : &cmd_config_speed_lanes_all,
14176 : : &cmd_config_speed_lanes_specific,
14177 : : &cmd_show_speed_lanes,
14178 : : &cmd_config_loopback_all,
14179 : : &cmd_config_loopback_specific,
14180 : : &cmd_config_rx_tx,
14181 : : &cmd_config_mtu,
14182 : : &cmd_config_max_pkt_len,
14183 : : &cmd_config_max_lro_pkt_size,
14184 : : &cmd_config_rx_mode_flag,
14185 : : &cmd_config_rss,
14186 : : &cmd_config_rxtx_ring_size,
14187 : : &cmd_config_rxtx_queue,
14188 : : &cmd_config_deferred_start_rxtx_queue,
14189 : : &cmd_setup_rxtx_queue,
14190 : : &cmd_config_rss_reta,
14191 : : &cmd_showport_reta,
14192 : : &cmd_showport_macs,
14193 : : &cmd_show_port_flow_transfer_proxy,
14194 : : &cmd_config_burst,
14195 : : &cmd_config_thresh,
14196 : : &cmd_config_threshold,
14197 : : &cmd_set_uc_hash_filter,
14198 : : &cmd_set_uc_all_hash_filter,
14199 : : &cmd_vf_mac_addr_filter,
14200 : : &cmd_queue_rate_limit,
14201 : : &cmd_tunnel_udp_config,
14202 : : &cmd_showport_rss_hash,
14203 : : &cmd_showport_rss_hash_key,
14204 : : &cmd_showport_rss_hash_algo,
14205 : : &cmd_config_rss_hash_key,
14206 : : &cmd_config_rss_hash_algo,
14207 : : &cmd_cleanup_txq_mbufs,
14208 : : &cmd_dump_simple,
14209 : : &cmd_dump_named,
14210 : : &cmd_dump_mbuf_history_stdout,
14211 : : &cmd_dump_mbuf_history_to_file,
14212 : : &cmd_dump_mbuf_pool_history_stdout,
14213 : : &cmd_dump_mbuf_pool_history_to_file,
14214 : : &cmd_flow,
14215 : : &cmd_show_port_meter_cap,
14216 : : &cmd_add_port_meter_profile_srtcm,
14217 : : &cmd_add_port_meter_profile_trtcm,
14218 : : &cmd_add_port_meter_profile_trtcm_rfc4115,
14219 : : &cmd_del_port_meter_profile,
14220 : : &cmd_create_port_meter,
14221 : : &cmd_enable_port_meter,
14222 : : &cmd_disable_port_meter,
14223 : : &cmd_del_port_meter,
14224 : : &cmd_del_port_meter_policy,
14225 : : &cmd_set_port_meter_profile,
14226 : : &cmd_set_port_meter_dscp_table,
14227 : : &cmd_set_port_meter_vlan_table,
14228 : : &cmd_set_port_meter_in_proto,
14229 : : &cmd_get_port_meter_in_proto,
14230 : : &cmd_get_port_meter_in_proto_prio,
14231 : : &cmd_set_port_meter_stats_mask,
14232 : : &cmd_show_port_meter_stats,
14233 : : &cmd_mcast_addr,
14234 : : &cmd_mcast_addr_flush,
14235 : : &cmd_set_vf_vlan_anti_spoof,
14236 : : &cmd_set_vf_mac_anti_spoof,
14237 : : &cmd_set_vf_vlan_stripq,
14238 : : &cmd_set_vf_vlan_insert,
14239 : : &cmd_set_tx_loopback,
14240 : : &cmd_set_all_queues_drop_en,
14241 : : &cmd_set_vf_traffic,
14242 : : &cmd_set_vf_rxmode,
14243 : : &cmd_vf_rate_limit,
14244 : : &cmd_vf_rxvlan_filter,
14245 : : &cmd_set_vf_mac_addr,
14246 : : &cmd_set_vxlan,
14247 : : &cmd_set_vxlan_tos_ttl,
14248 : : &cmd_set_vxlan_with_vlan,
14249 : : &cmd_set_nvgre,
14250 : : &cmd_set_nvgre_with_vlan,
14251 : : &cmd_set_l2_encap,
14252 : : &cmd_set_l2_encap_with_vlan,
14253 : : &cmd_set_l2_decap,
14254 : : &cmd_set_l2_decap_with_vlan,
14255 : : &cmd_set_mplsogre_encap,
14256 : : &cmd_set_mplsogre_encap_with_vlan,
14257 : : &cmd_set_mplsogre_decap,
14258 : : &cmd_set_mplsogre_decap_with_vlan,
14259 : : &cmd_set_mplsoudp_encap,
14260 : : &cmd_set_mplsoudp_encap_with_vlan,
14261 : : &cmd_set_mplsoudp_decap,
14262 : : &cmd_set_mplsoudp_decap_with_vlan,
14263 : : &cmd_set_conntrack_common,
14264 : : &cmd_set_conntrack_dir,
14265 : : &cmd_show_vf_stats,
14266 : : &cmd_clear_vf_stats,
14267 : : &cmd_show_port_supported_ptypes,
14268 : : &cmd_set_port_ptypes,
14269 : : &cmd_show_port_tm_cap,
14270 : : &cmd_show_port_tm_level_cap,
14271 : : &cmd_show_port_tm_node,
14272 : : &cmd_show_port_tm_node_cap,
14273 : : &cmd_show_port_tm_node_type,
14274 : : &cmd_show_port_tm_node_stats,
14275 : : &cmd_add_port_tm_node_shaper_profile,
14276 : : &cmd_del_port_tm_node_shaper_profile,
14277 : : &cmd_add_port_tm_node_shared_shaper,
14278 : : &cmd_del_port_tm_node_shared_shaper,
14279 : : &cmd_add_port_tm_node_wred_profile,
14280 : : &cmd_del_port_tm_node_wred_profile,
14281 : : &cmd_set_port_tm_node_shaper_profile,
14282 : : &cmd_add_port_tm_nonleaf_node,
14283 : : &cmd_add_port_tm_nonleaf_node_pmode,
14284 : : &cmd_add_port_tm_leaf_node,
14285 : : &cmd_del_port_tm_node,
14286 : : &cmd_set_port_tm_node_parent,
14287 : : &cmd_suspend_port_tm_node,
14288 : : &cmd_resume_port_tm_node,
14289 : : &cmd_port_tm_hierarchy_commit,
14290 : : &cmd_port_tm_mark_ip_ecn,
14291 : : &cmd_port_tm_mark_ip_dscp,
14292 : : &cmd_port_tm_mark_vlan_dei,
14293 : : &cmd_cfg_tunnel_udp_port,
14294 : : &cmd_rx_offload_get_capa,
14295 : : &cmd_rx_offload_get_configuration,
14296 : : &cmd_config_per_port_rx_offload,
14297 : : &cmd_config_all_port_rx_offload,
14298 : : &cmd_config_per_queue_rx_offload,
14299 : : &cmd_tx_offload_get_capa,
14300 : : &cmd_tx_offload_get_configuration,
14301 : : &cmd_config_per_port_tx_offload,
14302 : : &cmd_config_all_port_tx_offload,
14303 : : &cmd_config_per_queue_tx_offload,
14304 : : #ifdef RTE_LIB_BPF
14305 : : &cmd_operate_bpf_ld_parse,
14306 : : &cmd_operate_bpf_unld_parse,
14307 : : #endif
14308 : : &cmd_config_tx_metadata_specific,
14309 : : &cmd_show_tx_metadata,
14310 : : &cmd_show_rx_tx_desc_status,
14311 : : &cmd_show_rx_tx_queue_desc_used_count,
14312 : : &cmd_set_raw,
14313 : : &cmd_show_set_raw,
14314 : : &cmd_show_set_raw_all,
14315 : : &cmd_config_tx_dynf_specific,
14316 : : &cmd_show_fec_mode,
14317 : : &cmd_set_fec_mode,
14318 : : &cmd_set_rxq_avail_thresh,
14319 : : &cmd_show_capability,
14320 : : &cmd_set_flex_is_pattern,
14321 : : &cmd_set_flex_spec_pattern,
14322 : : &cmd_show_port_cman_capa,
14323 : : &cmd_show_port_cman_config,
14324 : : &cmd_set_port_cman_config,
14325 : : &cmd_config_tx_affinity_map,
14326 : : &cmd_set_dev_led,
14327 : : NULL,
14328 : : };
14329 : :
14330 : : void
14331 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
14332 : : {
14333 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
14334 : 0 : }
14335 : :
14336 : : int
14337 : 0 : init_cmdline(void)
14338 : : {
14339 : : struct testpmd_driver_commands *c;
14340 : : unsigned int count;
14341 : : unsigned int i;
14342 : :
14343 : : /* initialize non-constant commands */
14344 : 0 : cmd_set_fwd_mode_init();
14345 : 0 : cmd_set_fwd_retry_mode_init();
14346 : :
14347 : : count = 0;
14348 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
14349 : 0 : count++;
14350 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14351 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
14352 : 0 : count++;
14353 : : }
14354 : :
14355 : : /* cmdline expects a NULL terminated array */
14356 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
14357 : 0 : if (main_ctx == NULL)
14358 : : return -1;
14359 : :
14360 : : count = 0;
14361 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
14362 : 0 : main_ctx[count] = builtin_ctx[i];
14363 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14364 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
14365 : 0 : main_ctx[count] = c->commands[i].ctx;
14366 : : }
14367 : :
14368 : : return 0;
14369 : : }
14370 : :
14371 : : /* read cmdline commands from file */
14372 : : int
14373 : 0 : cmdline_read_from_file(const char *filename, bool echo)
14374 : : {
14375 : : struct cmdline *cl;
14376 : : int fd = -1;
14377 : : int ret = 0;
14378 : :
14379 : : /* cmdline_file_new does not produce any output
14380 : : * so when echoing is requested we open filename directly
14381 : : * and then pass that to cmdline_new with stdout as the output path.
14382 : : */
14383 : 0 : if (!echo) {
14384 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14385 : : } else {
14386 : : /* use basename(filename) as prompt */
14387 : 0 : char prompt[32] = "[] ";
14388 : :
14389 : 0 : rte_basename(filename, &prompt[1], sizeof(prompt) - strlen(prompt));
14390 : 0 : strlcat(prompt, "] ", sizeof(prompt));
14391 : :
14392 : : fd = open(filename, O_RDONLY);
14393 : 0 : if (fd < 0) {
14394 : 0 : fprintf(stderr, "Failed to open file %s: %s\n",
14395 : 0 : filename, strerror(errno));
14396 : 0 : return -1;
14397 : : }
14398 : :
14399 : 0 : cl = cmdline_new(main_ctx, prompt, fd, STDOUT_FILENO);
14400 : : }
14401 : 0 : if (cl == NULL) {
14402 : 0 : fprintf(stderr,
14403 : : "Failed to create file based cmdline context: %s\n",
14404 : : filename);
14405 : : ret = -1;
14406 : 0 : goto end;
14407 : : }
14408 : :
14409 : 0 : cmdline_interact(cl);
14410 : : /* when done, if we have echo, we only need to print end of file,
14411 : : * but if no echo, we need to use printf and include the filename.
14412 : : */
14413 : 0 : if (echo)
14414 : 0 : cmdline_printf(cl, "<End-Of-File>\n");
14415 : : else
14416 : : printf("Finished reading CLI commands from %s\n", filename);
14417 : :
14418 : 0 : cmdline_quit(cl);
14419 : 0 : cmdline_free(cl);
14420 : :
14421 : :
14422 : 0 : end:
14423 : 0 : if (fd >= 0)
14424 : 0 : close(fd);
14425 : : return ret;
14426 : : }
14427 : :
14428 : : void
14429 : 0 : prompt_exit(void)
14430 : : {
14431 : 0 : cmdline_quit(testpmd_cl);
14432 : 0 : }
14433 : :
14434 : : /* prompt function, called from main on MAIN lcore */
14435 : : void
14436 : 0 : prompt(void)
14437 : : {
14438 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14439 : 0 : if (testpmd_cl == NULL) {
14440 : 0 : fprintf(stderr,
14441 : : "Failed to create stdin based cmdline context\n");
14442 : 0 : return;
14443 : : }
14444 : :
14445 : 0 : cmdline_interact(testpmd_cl);
14446 : 0 : cmdline_stdin_exit(testpmd_cl);
14447 : : }
14448 : :
14449 : : void
14450 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14451 : : {
14452 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
14453 : : portid_t pid;
14454 : :
14455 : 0 : RTE_ETH_FOREACH_DEV(pid) {
14456 : : /* check if need_reconfig has been set to 1 */
14457 : 0 : if (ports[pid].need_reconfig == 0)
14458 : 0 : ports[pid].need_reconfig = dev;
14459 : : /* check if need_reconfig_queues has been set to 1 */
14460 : 0 : if (ports[pid].need_reconfig_queues == 0)
14461 : 0 : ports[pid].need_reconfig_queues = queue;
14462 : : }
14463 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14464 : : /* check if need_reconfig has been set to 1 */
14465 : 0 : if (ports[id].need_reconfig == 0)
14466 : 0 : ports[id].need_reconfig = dev;
14467 : : /* check if need_reconfig_queues has been set to 1 */
14468 : 0 : if (ports[id].need_reconfig_queues == 0)
14469 : 0 : ports[id].need_reconfig_queues = queue;
14470 : : }
14471 : 0 : }
|