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_trace.h>
44 : :
45 : : #include <cmdline_rdline.h>
46 : : #include <cmdline_parse.h>
47 : : #include <cmdline_parse_num.h>
48 : : #include <cmdline_parse_bool.h>
49 : : #include <cmdline_parse_string.h>
50 : : #include <cmdline_parse_ipaddr.h>
51 : : #include <cmdline_parse_etheraddr.h>
52 : : #include <cmdline_socket.h>
53 : : #include <cmdline.h>
54 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
55 : : #include <rte_pmd_dpaa.h>
56 : : #endif
57 : : #ifdef RTE_NET_IXGBE
58 : : #include <rte_pmd_ixgbe.h>
59 : : #endif
60 : : #ifdef RTE_NET_I40E
61 : : #include <rte_pmd_i40e.h>
62 : : #endif
63 : : #ifdef RTE_NET_BNXT
64 : : #include <rte_pmd_bnxt.h>
65 : : #endif
66 : : #include "testpmd.h"
67 : : #include "cmdline_cman.h"
68 : : #include "cmdline_mtr.h"
69 : : #include "cmdline_tm.h"
70 : : #include "bpf_cmd.h"
71 : :
72 : : static struct cmdline *testpmd_cl;
73 : : static cmdline_parse_ctx_t *main_ctx;
74 : : static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
75 : : TAILQ_HEAD_INITIALIZER(driver_commands_head);
76 : :
77 : : /* *** Help command with introduction. *** */
78 : : struct cmd_help_brief_result {
79 : : cmdline_fixed_string_t help;
80 : : };
81 : :
82 : 0 : static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
83 : : struct cmdline *cl,
84 : : __rte_unused void *data)
85 : : {
86 : 0 : cmdline_printf(
87 : : cl,
88 : : "\n"
89 : : "Help is available for the following sections:\n\n"
90 : : " help control : Start and stop forwarding.\n"
91 : : " help display : Displaying port, stats and config "
92 : : "information.\n"
93 : : " help config : Configuration information.\n"
94 : : " help ports : Configuring ports.\n"
95 : : " help filters : Filters configuration help.\n"
96 : : " help traffic_management : Traffic Management commands.\n"
97 : : " help devices : Device related commands.\n"
98 : : " help drivers : Driver specific commands.\n"
99 : : " help all : All of the above sections.\n\n"
100 : : );
101 : :
102 : 0 : }
103 : :
104 : : static cmdline_parse_token_string_t cmd_help_brief_help =
105 : : TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
106 : :
107 : : static cmdline_parse_inst_t cmd_help_brief = {
108 : : .f = cmd_help_brief_parsed,
109 : : .data = NULL,
110 : : .help_str = "help: Show help",
111 : : .tokens = {
112 : : (void *)&cmd_help_brief_help,
113 : : NULL,
114 : : },
115 : : };
116 : :
117 : : /* *** Help command with help sections. *** */
118 : : struct cmd_help_long_result {
119 : : cmdline_fixed_string_t help;
120 : : cmdline_fixed_string_t section;
121 : : };
122 : :
123 : 0 : static void cmd_help_long_parsed(void *parsed_result,
124 : : struct cmdline *cl,
125 : : __rte_unused void *data)
126 : : {
127 : : int show_all = 0;
128 : : struct cmd_help_long_result *res = parsed_result;
129 : :
130 : 0 : if (!strcmp(res->section, "all"))
131 : : show_all = 1;
132 : :
133 : 0 : if (show_all || !strcmp(res->section, "control")) {
134 : :
135 : 0 : cmdline_printf(
136 : : cl,
137 : : "\n"
138 : : "Control forwarding:\n"
139 : : "-------------------\n\n"
140 : :
141 : : "start\n"
142 : : " Start packet forwarding with current configuration.\n\n"
143 : :
144 : : "start tx_first\n"
145 : : " Start packet forwarding with current config"
146 : : " after sending one burst of packets.\n\n"
147 : :
148 : : "stop\n"
149 : : " Stop packet forwarding, and display accumulated"
150 : : " statistics.\n\n"
151 : :
152 : : "quit\n"
153 : : " Quit to prompt.\n\n"
154 : : );
155 : : }
156 : :
157 : 0 : if (show_all || !strcmp(res->section, "display")) {
158 : :
159 : 0 : cmdline_printf(
160 : : cl,
161 : : "\n"
162 : : "Display:\n"
163 : : "--------\n\n"
164 : :
165 : : "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
166 : : " Display information for port_id, or all.\n\n"
167 : :
168 : : "show port info (port_id) representor\n"
169 : : " Show supported representors for a specific port\n\n"
170 : :
171 : : "show port port_id (module_eeprom|eeprom)\n"
172 : : " Display the module EEPROM or EEPROM information for port_id.\n\n"
173 : :
174 : : "set port (port_id) eeprom (accept_risk) magic (magic_num)"
175 : : " value (value) offset (offset)\n"
176 : : " Set the device eeprom for certain port.\nNote:\n"
177 : : " This is a high-risk command and its misuse may"
178 : : " result in unexpected behaviour from the NIC.\n"
179 : : " By inserting \"accept_risk\" into the command, the"
180 : : " user is acknowledging and taking responsibility for"
181 : : " this risk.\n\n"
182 : :
183 : : "show port X rss reta (size) (mask0,mask1,...)\n"
184 : : " Display the rss redirection table entry indicated"
185 : : " by masks on port X. size is used to indicate the"
186 : : " hardware supported reta size\n\n"
187 : :
188 : : "show port (port_id) rss-hash [key | algorithm]\n"
189 : : " Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
190 : :
191 : : "clear port (info|stats|xstats|fdir) (port_id|all)\n"
192 : : " Clear information for port_id, or all.\n\n"
193 : :
194 : : "show (rxq|txq) info (port_id) (queue_id)\n"
195 : : " Display information for configured RX/TX queue.\n\n"
196 : :
197 : : "show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
198 : : " Display the given configuration.\n\n"
199 : :
200 : : "read rxd (port_id) (queue_id) (rxd_id)\n"
201 : : " Display an RX descriptor of a port RX queue.\n\n"
202 : :
203 : : "read txd (port_id) (queue_id) (txd_id)\n"
204 : : " Display a TX descriptor of a port TX queue.\n\n"
205 : :
206 : : "show vf stats (port_id) (vf_id)\n"
207 : : " Display a VF's statistics.\n\n"
208 : :
209 : : "clear vf stats (port_id) (vf_id)\n"
210 : : " Reset a VF's statistics.\n\n"
211 : :
212 : : "show port meter stats (port_id) (meter_id) (clear)\n"
213 : : " Get meter stats on a port\n\n"
214 : :
215 : : "show fwd stats all\n"
216 : : " Display statistics for all fwd engines.\n\n"
217 : :
218 : : "clear fwd stats all\n"
219 : : " Clear statistics for all fwd engines.\n\n"
220 : :
221 : : "show port (port_id) rx_offload capabilities\n"
222 : : " List all per queue and per port Rx offloading"
223 : : " capabilities of a port\n\n"
224 : :
225 : : "show port (port_id) rx_offload configuration\n"
226 : : " List port level and all queue level"
227 : : " Rx offloading configuration\n\n"
228 : :
229 : : "show port (port_id) tx_offload capabilities\n"
230 : : " List all per queue and per port"
231 : : " Tx offloading capabilities of a port\n\n"
232 : :
233 : : "show port (port_id) tx_offload configuration\n"
234 : : " List port level and all queue level"
235 : : " Tx offloading configuration\n\n"
236 : :
237 : : "show port (port_id) tx_metadata\n"
238 : : " Show Tx metadata value set"
239 : : " for a specific port\n\n"
240 : :
241 : : "show port (port_id) ptypes\n"
242 : : " Show port supported ptypes"
243 : : " for a specific port\n\n"
244 : :
245 : : "show device info (<identifier>|all)"
246 : : " Show general information about devices probed.\n\n"
247 : :
248 : : "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
249 : : " Show status of rx|tx descriptor.\n\n"
250 : :
251 : : "show port (port_id) rxq|txq (queue_id) desc used count\n"
252 : : " Show current number of used descriptor count for rx|tx.\n\n"
253 : :
254 : : "show port (port_id) macs|mcast_macs"
255 : : " Display list of mac addresses added to port.\n\n"
256 : :
257 : : "show port (port_id) flow transfer proxy\n"
258 : : " Display proxy port to manage transfer flows\n\n"
259 : :
260 : : "show port (port_id) fec capabilities"
261 : : " Show fec capabilities of a port.\n\n"
262 : :
263 : : "show port (port_id) fec_mode"
264 : : " Show fec mode of a port.\n\n"
265 : :
266 : : "show port (port_id) flow_ctrl"
267 : : " Show flow control info of a port.\n\n"
268 : :
269 : : "dump_physmem\n"
270 : : " Dumps all physical memory segment layouts\n\n"
271 : :
272 : : "dump_socket_mem\n"
273 : : " Dumps the memory usage of all sockets\n\n"
274 : :
275 : : "dump_memzone\n"
276 : : " Dumps the layout of all memory zones\n\n"
277 : :
278 : : "dump_struct_sizes\n"
279 : : " Dumps the size of all memory structures\n\n"
280 : :
281 : : "dump_ring\n"
282 : : " Dumps the status of all or specific element in DPDK rings\n\n"
283 : :
284 : : "dump_mempool\n"
285 : : " Dumps the statistics of all or specific memory pool\n\n"
286 : :
287 : : "dump_devargs\n"
288 : : " Dumps the user device list\n\n"
289 : :
290 : : "dump_lcores\n"
291 : : " Dumps the logical cores list\n\n"
292 : :
293 : : "dump_trace\n"
294 : : " Dumps the tracing data to the folder according to the current EAL settings\n\n"
295 : :
296 : : "dump_log_types\n"
297 : : " Dumps the log level for all the dpdk modules\n\n"
298 : :
299 : : "show port (port_id) speed_lanes capabilities"
300 : : " Show speed lanes capabilities of a port.\n\n"
301 : : );
302 : : }
303 : :
304 : 0 : if (show_all || !strcmp(res->section, "config")) {
305 : 0 : cmdline_printf(
306 : : cl,
307 : : "\n"
308 : : "Configuration:\n"
309 : : "--------------\n"
310 : : "Configuration changes only become active when"
311 : : " forwarding is started/restarted.\n\n"
312 : :
313 : : "set default\n"
314 : : " Reset forwarding to the default configuration.\n\n"
315 : :
316 : : "set verbose (level)\n"
317 : : " Set the debug verbosity level X.\n\n"
318 : :
319 : : "set log global|(type) (level)\n"
320 : : " Set the log level.\n\n"
321 : :
322 : : "set nbport (num)\n"
323 : : " Set number of ports.\n\n"
324 : :
325 : : "set nbcore (num)\n"
326 : : " Set number of cores.\n\n"
327 : :
328 : : "set coremask (mask)\n"
329 : : " Set the forwarding cores hexadecimal mask.\n\n"
330 : :
331 : : "set portmask (mask)\n"
332 : : " Set the forwarding ports hexadecimal mask.\n\n"
333 : :
334 : : "set burst (num)\n"
335 : : " Set number of packets per burst.\n\n"
336 : :
337 : : "set burst tx delay (microseconds) retry (num)\n"
338 : : " Set the transmit delay time and number of retries,"
339 : : " effective when retry is enabled.\n\n"
340 : :
341 : : "set rxoffs (x[,y]*)\n"
342 : : " Set the offset of each packet segment on"
343 : : " receiving if split feature is engaged."
344 : : " Affects only the queues configured with split"
345 : : " offloads.\n\n"
346 : :
347 : : "set rxpkts (x[,y]*)\n"
348 : : " Set the length of each segment to scatter"
349 : : " packets on receiving if split feature is engaged."
350 : : " Affects only the queues configured with split"
351 : : " offloads.\n\n"
352 : :
353 : : "set rxhdrs (eth[,ipv4])*\n"
354 : : " Set the protocol hdr of each segment to scatter"
355 : : " packets on receiving if split feature is engaged."
356 : : " Affects only the queues configured with split"
357 : : " offloads.\n"
358 : : " Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
359 : : "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
360 : : "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
361 : : "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
362 : : "inner-ipv4-sctp|inner-ipv6-sctp\n\n"
363 : :
364 : : "set txpkts (x[,y]*)\n"
365 : : " Set the length of each segment of TXONLY"
366 : : " and optionally CSUM packets.\n\n"
367 : :
368 : : "set txsplit (off|on|rand)\n"
369 : : " Set the split policy for the TX packets."
370 : : " Right now only applicable for CSUM and TXONLY"
371 : : " modes\n\n"
372 : :
373 : : "set txtimes (x, y)\n"
374 : : " Set the scheduling on timestamps"
375 : : " timings for the TXONLY mode\n\n"
376 : :
377 : : "set corelist (x[,y]*)\n"
378 : : " Set the list of forwarding cores.\n\n"
379 : :
380 : : "set portlist (x[,y]*)\n"
381 : : " Set the list of forwarding ports.\n\n"
382 : :
383 : : "set port setup on (iterator|event)\n"
384 : : " Select how attached port is retrieved for setup.\n\n"
385 : :
386 : : "set tx loopback (port_id) (on|off)\n"
387 : : " Enable or disable tx loopback.\n\n"
388 : :
389 : : "set all queues drop (port_id) (on|off)\n"
390 : : " Set drop enable bit for all queues.\n\n"
391 : :
392 : : "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
393 : : " Set MAC antispoof for a VF from the PF.\n\n"
394 : :
395 : : "vlan set stripq (on|off) (port_id,queue_id)\n"
396 : : " Set the VLAN strip for a queue on a port.\n\n"
397 : :
398 : : "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
399 : : " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
400 : :
401 : : "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
402 : : " Set VLAN insert for a VF from the PF.\n\n"
403 : :
404 : : "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
405 : : " Set VLAN antispoof for a VF from the PF.\n\n"
406 : :
407 : : "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
408 : : " Set the VLAN strip or filter or qinq strip or extend\n\n"
409 : :
410 : : "vlan set (inner|outer) tpid (value) (port_id)\n"
411 : : " Set the VLAN TPID for Packet Filtering on"
412 : : " a port\n\n"
413 : :
414 : : "rx_vlan add (vlan_id|all) (port_id)\n"
415 : : " Add a vlan_id, or all identifiers, to the set"
416 : : " of VLAN identifiers filtered by port_id.\n\n"
417 : :
418 : : "rx_vlan rm (vlan_id|all) (port_id)\n"
419 : : " Remove a vlan_id, or all identifiers, from the set"
420 : : " of VLAN identifiers filtered by port_id.\n\n"
421 : :
422 : : "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
423 : : " Add a vlan_id, to the set of VLAN identifiers"
424 : : "filtered for VF(s) from port_id.\n\n"
425 : :
426 : : "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
427 : : " Remove a vlan_id, to the set of VLAN identifiers"
428 : : "filtered for VF(s) from port_id.\n\n"
429 : :
430 : : "rx_vxlan_port add (udp_port) (port_id)\n"
431 : : " Add an UDP port for VXLAN packet filter on a port\n\n"
432 : :
433 : : "rx_vxlan_port rm (udp_port) (port_id)\n"
434 : : " Remove an UDP port for VXLAN packet filter on a port\n\n"
435 : :
436 : : "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
437 : : " Set hardware insertion of VLAN IDs (single or double VLAN "
438 : : "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
439 : :
440 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
441 : : " Set port based TX VLAN insertion.\n\n"
442 : :
443 : : "tx_vlan reset (port_id)\n"
444 : : " Disable hardware insertion of a VLAN header in"
445 : : " packets sent on a port.\n\n"
446 : :
447 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
448 : : " Select hardware or software calculation of the"
449 : : " checksum when transmitting a packet using the"
450 : : " csum forward engine.\n"
451 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
452 : : " outer-ip concerns the outer IP layer in"
453 : : " outer-udp concerns the outer UDP layer in"
454 : : " case the packet is recognized as a tunnel packet by"
455 : : " the forward engine (vxlan, gre and ipip are supported)\n"
456 : : " Please check the NIC datasheet for HW limits.\n\n"
457 : :
458 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
459 : : " If disabled, treat tunnel packets as non-tunneled"
460 : : " packets (treat inner headers as payload). The port\n"
461 : : " argument is the port used for TX in csum forward"
462 : : " engine.\n\n"
463 : :
464 : : "csum show (port_id)\n"
465 : : " Display tx checksum offload configuration\n\n"
466 : :
467 : : "tso set (segsize) (portid)\n"
468 : : " Enable TCP Segmentation Offload in csum forward"
469 : : " engine.\n"
470 : : " Please check the NIC datasheet for HW limits.\n\n"
471 : :
472 : : "tso show (portid)"
473 : : " Display the status of TCP Segmentation Offload.\n\n"
474 : :
475 : : #ifdef RTE_LIB_GRO
476 : : "set port (port_id) gro on|off\n"
477 : : " Enable or disable Generic Receive Offload in"
478 : : " csum forwarding engine.\n\n"
479 : :
480 : : "show port (port_id) gro\n"
481 : : " Display GRO configuration.\n\n"
482 : :
483 : : "set gro flush (cycles)\n"
484 : : " Set the cycle to flush GROed packets from"
485 : : " reassembly tables.\n\n"
486 : : #endif
487 : :
488 : : #ifdef RTE_LIB_GSO
489 : : "set port (port_id) gso (on|off)"
490 : : " Enable or disable Generic Segmentation Offload in"
491 : : " csum forwarding engine.\n\n"
492 : :
493 : : "set gso segsz (length)\n"
494 : : " Set max packet length for output GSO segments,"
495 : : " including packet header and payload.\n\n"
496 : :
497 : : "show port (port_id) gso\n"
498 : : " Show GSO configuration.\n\n"
499 : : #endif
500 : :
501 : : "set fwd (%s)\n"
502 : : " Set packet forwarding mode.\n\n"
503 : :
504 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
505 : : " Add a MAC address on port_id.\n\n"
506 : :
507 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
508 : : " Remove a MAC address from port_id.\n\n"
509 : :
510 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
511 : : " Set the default MAC address for port_id.\n\n"
512 : :
513 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
514 : : " Add a MAC address for a VF on the port.\n\n"
515 : :
516 : : "mcast_addr add (port_id) (mcast_addr)\n"
517 : : " Add a multicast MAC addresses on port_id.\n\n"
518 : :
519 : : "mcast_addr remove (port_id) (mcast_addr)\n"
520 : : " Remove a multicast MAC address from port_id.\n\n"
521 : :
522 : : "mcast_addr flush (port_id)\n"
523 : : " Flush all multicast MAC addresses on port_id.\n\n"
524 : :
525 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
526 : : " Set the MAC address for a VF from the PF.\n\n"
527 : :
528 : : "set eth-peer (port_id) (peer_addr)\n"
529 : : " set the peer address for certain port.\n\n"
530 : :
531 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
532 : : " Add/Remove a or all unicast hash filter(s)"
533 : : "from port X.\n\n"
534 : :
535 : : "set promisc (port_id|all) (on|off)\n"
536 : : " Set the promiscuous mode on port_id, or all.\n\n"
537 : :
538 : : "set allmulti (port_id|all) (on|off)\n"
539 : : " Set the allmulti mode on port_id, or all.\n\n"
540 : :
541 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
542 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
543 : : " (on|off) autoneg (on|off) (port_id)\n"
544 : : "set flow_ctrl rx (on|off) (portid)\n"
545 : : "set flow_ctrl tx (on|off) (portid)\n"
546 : : "set flow_ctrl high_water (high_water) (portid)\n"
547 : : "set flow_ctrl low_water (low_water) (portid)\n"
548 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
549 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
550 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
551 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
552 : : " Set the link flow control parameter on a port.\n\n"
553 : :
554 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
555 : : " (low_water) (pause_time) (priority) (port_id)\n"
556 : : " Set the priority flow control parameter on a"
557 : : " port.\n\n"
558 : :
559 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
560 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
561 : : " Set the queue priority flow control parameter on a"
562 : : " given Rx and Tx queues of a port.\n\n"
563 : :
564 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
565 : : " set available descriptors threshold for Rx queue\n\n"
566 : :
567 : : "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
568 : : " Set statistics mapping (qmapping 0..15) for RX/TX"
569 : : " queue on port.\n"
570 : : " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
571 : : " on port 0 to mapping 5.\n\n"
572 : :
573 : : "set xstats-hide-zero on|off\n"
574 : : " Set the option to hide the zero values"
575 : : " for xstats display.\n"
576 : :
577 : : "set record-core-cycles on|off\n"
578 : : " Set the option to enable measurement of CPU cycles.\n"
579 : :
580 : : "set record-burst-stats on|off\n"
581 : : " Set the option to enable display of RX and TX bursts.\n"
582 : :
583 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
584 : : " Enable/Disable a VF receive/transmit from a port\n\n"
585 : :
586 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
587 : : "|MPE) (on|off)\n"
588 : : " AUPE:accepts untagged VLAN;"
589 : : "ROPE:accept unicast hash\n\n"
590 : : " BAM:accepts broadcast packets;"
591 : : "MPE:accepts all multicast packets\n\n"
592 : : " Enable/Disable a VF receive mode of a port\n\n"
593 : :
594 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
595 : : " Set rate limit for a queue of a port\n\n"
596 : :
597 : : "set port (port_id) vf (vf_id) rate (rate_num) "
598 : : "queue_mask (queue_mask_value)\n"
599 : : " Set rate limit for queues in VF of a port\n\n"
600 : :
601 : : "set flush_rx (on|off)\n"
602 : : " Flush (default) or don't flush RX streams before"
603 : : " forwarding. Mainly used with PCAP drivers.\n\n"
604 : :
605 : : "set link-up port (port_id)\n"
606 : : " Set link up for a port.\n\n"
607 : :
608 : : "set link-down port (port_id)\n"
609 : : " Set link down for a port.\n\n"
610 : :
611 : : "set port (port_id) ptype_mask (ptype_mask)\n"
612 : : " set packet types classification for a specific port\n\n"
613 : :
614 : : "show port meter cap (port_id)\n"
615 : : " Show port meter capability information\n\n"
616 : :
617 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
618 : : " meter profile add - srtcm rfc 2697\n\n"
619 : :
620 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
621 : : " meter profile add - trtcm rfc 2698\n\n"
622 : :
623 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
624 : : " meter profile add - trtcm rfc 4115\n\n"
625 : :
626 : : "del port meter profile (port_id) (profile_id)\n"
627 : : " meter profile delete\n\n"
628 : :
629 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
630 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
631 : : "(dscp_tbl_entry63)]\n"
632 : : " meter create\n\n"
633 : :
634 : : "enable port meter (port_id) (mtr_id)\n"
635 : : " meter enable\n\n"
636 : :
637 : : "disable port meter (port_id) (mtr_id)\n"
638 : : " meter disable\n\n"
639 : :
640 : : "del port meter (port_id) (mtr_id)\n"
641 : : " meter delete\n\n"
642 : :
643 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
644 : : "y_actions (actions) r_actions (actions)\n"
645 : : " meter policy add\n\n"
646 : :
647 : : "del port meter policy (port_id) (policy_id)\n"
648 : : " meter policy delete\n\n"
649 : :
650 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
651 : : " meter update meter profile\n\n"
652 : :
653 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
654 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
655 : : " update meter dscp table entries\n\n"
656 : :
657 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
658 : : "(action0) [(action1) (action2)]\n"
659 : : " meter update policer action\n\n"
660 : :
661 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
662 : : " meter update stats\n\n"
663 : :
664 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
665 : : " set fec mode for a specific port\n\n"
666 : :
667 : : "show port cman capa (port_id)\n"
668 : : " Show congestion management capabilities\n\n"
669 : :
670 : : "show port cman config (port_id)\n"
671 : : " Show congestion management configuration\n\n"
672 : :
673 : : "set port cman config (port_id) (queue_id) default | "
674 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
675 : : "(max_thresh) (prob_inv)]\n"
676 : : " Set congestion management configuration\n\n"
677 : :
678 : : "set port (port_id) led (on|off)\n"
679 : : " Set a controllable LED associated with a certain"
680 : : " port on or off.\n\n"
681 : :
682 : : , list_pkt_forwarding_modes()
683 : : );
684 : : }
685 : :
686 : 0 : if (show_all || !strcmp(res->section, "ports")) {
687 : :
688 : 0 : cmdline_printf(
689 : : cl,
690 : : "\n"
691 : : "Port Operations:\n"
692 : : "----------------\n\n"
693 : :
694 : : "port start (port_id|all)\n"
695 : : " Start all ports or port_id.\n\n"
696 : :
697 : : "port stop (port_id|all)\n"
698 : : " Stop all ports or port_id.\n\n"
699 : :
700 : : "port close (port_id|all)\n"
701 : : " Close all ports or port_id.\n\n"
702 : :
703 : : "port reset (port_id|all)\n"
704 : : " Reset all ports or port_id.\n\n"
705 : :
706 : : "port attach (ident)\n"
707 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
708 : :
709 : : "port detach (port_id)\n"
710 : : " Detach physical or virtual dev by port_id\n\n"
711 : :
712 : : "port config (port_id|all)"
713 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto)"
714 : : " duplex (half|full|auto)\n"
715 : : " Set speed and duplex for all ports or port_id\n\n"
716 : :
717 : : "port config (port_id|all) loopback (mode)\n"
718 : : " Set loopback mode for all ports or port_id\n\n"
719 : :
720 : : "port config all (rxq|txq|rxd|txd) (value)\n"
721 : : " Set number for rxq/txq/rxd/txd.\n\n"
722 : :
723 : : "port config all max-pkt-len (value)\n"
724 : : " Set the max packet length.\n\n"
725 : :
726 : : "port config all max-lro-pkt-size (value)\n"
727 : : " Set the max LRO aggregated packet size.\n\n"
728 : :
729 : : "port config all drop-en (on|off)\n"
730 : : " Enable or disable packet drop on all RX queues of all ports when no "
731 : : "receive buffers available.\n\n"
732 : :
733 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
734 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
735 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
736 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
737 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
738 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
739 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
740 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
741 : : " Set the RSS mode.\n\n"
742 : :
743 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
744 : : " Set the RSS redirection table.\n\n"
745 : :
746 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
747 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
748 : : " Set the RSS hash algorithm.\n\n"
749 : :
750 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
751 : : " pfc (on|off)\n"
752 : : " Set the DCB mode.\n\n"
753 : :
754 : : "port config all burst (value)\n"
755 : : " Set the number of packets per burst.\n\n"
756 : :
757 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
758 : : " (value)\n"
759 : : " Set the ring prefetch/host/writeback threshold"
760 : : " for tx/rx queue.\n\n"
761 : :
762 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
763 : : " Set free threshold for rx/tx, or set"
764 : : " tx rs bit threshold.\n\n"
765 : : "port config mtu X value\n"
766 : : " Set the MTU of port X to a given value\n\n"
767 : :
768 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
769 : : " Set a rx/tx queue's ring size configuration, the new"
770 : : " value will take effect after command that (re-)start the port"
771 : : " or command that setup the specific queue\n\n"
772 : :
773 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
774 : : " Start/stop a rx/tx queue of port X. Only take effect"
775 : : " when port X is started\n\n"
776 : :
777 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
778 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
779 : : " take effect when port X is stopped.\n\n"
780 : :
781 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
782 : : " Setup a rx/tx queue of port X.\n\n"
783 : :
784 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
785 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
786 : :
787 : : "port config (port_id|all) rx_offload all|vlan_strip|"
788 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
789 : : "outer_ipv4_cksum|macsec_strip|"
790 : : "vlan_filter|vlan_extend|scatter|"
791 : : "buffer_split|timestamp|security|keep_crc on|off\n"
792 : : " Enable or disable a per port Rx offloading"
793 : : " on all Rx queues of a port\n\n"
794 : :
795 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
796 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
797 : : "outer_ipv4_cksum|macsec_strip|"
798 : : "vlan_filter|vlan_extend|scatter|"
799 : : "buffer_split|timestamp|security|keep_crc on|off\n"
800 : : " Enable or disable a per queue Rx offloading"
801 : : " only on a specific Rx queue\n\n"
802 : :
803 : : "port config (port_id|all) tx_offload all|vlan_insert|"
804 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
805 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
806 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
807 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
808 : : "security on|off\n"
809 : : " Enable or disable a per port Tx offloading"
810 : : " on all Tx queues of a port\n\n"
811 : :
812 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
813 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
814 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
815 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
816 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
817 : : " on|off\n"
818 : : " Enable or disable a per queue Tx offloading"
819 : : " only on a specific Tx queue\n\n"
820 : :
821 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
822 : : " Load an eBPF program as a callback"
823 : : " for particular RX/TX queue\n\n"
824 : :
825 : : "bpf-unload rx|tx (port) (queue)\n"
826 : : " Unload previously loaded eBPF program"
827 : : " for particular RX/TX queue\n\n"
828 : :
829 : : "port config (port_id) tx_metadata (value)\n"
830 : : " Set Tx metadata value per port. Testpmd will add this value"
831 : : " to any Tx packet sent from this port\n\n"
832 : :
833 : : "port config (port_id) dynf (name) set|clear\n"
834 : : " Register a dynf and Set/clear this flag on Tx. "
835 : : "Testpmd will set this value to any Tx packet "
836 : : "sent from this port\n\n"
837 : :
838 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
839 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
840 : :
841 : : "port config (port_id) txq (queue_id) affinity (value)\n"
842 : : " Map a Tx queue with an aggregated port "
843 : : "of the DPDK port\n\n"
844 : :
845 : : "port config (port_id|all) speed_lanes (value)\n"
846 : : " Set number of lanes for all ports or port_id for a forced speed\n\n"
847 : : );
848 : : }
849 : :
850 : 0 : if (show_all || !strcmp(res->section, "filters")) {
851 : :
852 : 0 : cmdline_printf(
853 : : cl,
854 : : "\n"
855 : : "filters:\n"
856 : : "--------\n\n"
857 : :
858 : : "flow validate {port_id}"
859 : : " [group {group_id}] [priority {level}]"
860 : : " [ingress] [egress]"
861 : : " pattern {item} [/ {item} [...]] / end"
862 : : " actions {action} [/ {action} [...]] / end\n"
863 : : " Check whether a flow rule can be created.\n\n"
864 : :
865 : : "flow create {port_id}"
866 : : " [group {group_id}] [priority {level}]"
867 : : " [ingress] [egress]"
868 : : " pattern {item} [/ {item} [...]] / end"
869 : : " actions {action} [/ {action} [...]] / end\n"
870 : : " Create a flow rule.\n\n"
871 : :
872 : : "flow destroy {port_id} rule {rule_id} [...]\n"
873 : : " Destroy specific flow rules.\n\n"
874 : :
875 : : "flow update {port_id} {rule_id}"
876 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
877 : : " Update a flow rule with new actions.\n\n"
878 : :
879 : : "flow flush {port_id}\n"
880 : : " Destroy all flow rules.\n\n"
881 : :
882 : : "flow query {port_id} {rule_id} {action}\n"
883 : : " Query an existing flow rule.\n\n"
884 : :
885 : : "flow list {port_id} [group {group_id}] [...]\n"
886 : : " List existing flow rules sorted by priority,"
887 : : " filtered by group identifiers.\n\n"
888 : :
889 : : "flow isolate {port_id} {boolean}\n"
890 : : " Restrict ingress traffic to the defined"
891 : : " flow rules\n\n"
892 : :
893 : : "flow aged {port_id} [destroy]\n"
894 : : " List and destroy aged flows"
895 : : " flow rules\n\n"
896 : :
897 : : "flow indirect_action {port_id} create"
898 : : " [action_id {indirect_action_id}]"
899 : : " [ingress] [egress]"
900 : : " action {action} / end\n"
901 : : " Create indirect action.\n\n"
902 : :
903 : : "flow indirect_action {port_id} update"
904 : : " {indirect_action_id} action {action} / end\n"
905 : : " Update indirect action.\n\n"
906 : :
907 : : "flow indirect_action {port_id} destroy"
908 : : " action_id {indirect_action_id} [...]\n"
909 : : " Destroy specific indirect actions.\n\n"
910 : :
911 : : "flow indirect_action {port_id} query"
912 : : " {indirect_action_id}\n"
913 : : " Query an existing indirect action.\n\n"
914 : :
915 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
916 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
917 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
918 : : " Configure the VXLAN encapsulation for flows.\n\n"
919 : :
920 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
921 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
922 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
923 : : " eth-dst (eth-dst)\n"
924 : : " Configure the VXLAN encapsulation for flows.\n\n"
925 : :
926 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
927 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
928 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
929 : : " eth-dst (eth-dst)\n"
930 : : " Configure the VXLAN encapsulation for flows.\n\n"
931 : :
932 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
933 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
934 : : " (eth-dst)\n"
935 : : " Configure the NVGRE encapsulation for flows.\n\n"
936 : :
937 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
938 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
939 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
940 : : " Configure the NVGRE encapsulation for flows.\n\n"
941 : :
942 : : "set raw_encap {flow items}\n"
943 : : " Configure the encapsulation with raw data.\n\n"
944 : :
945 : : "set raw_decap {flow items}\n"
946 : : " Configure the decapsulation with raw data.\n\n"
947 : :
948 : : );
949 : : }
950 : :
951 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
952 : 0 : cmdline_printf(
953 : : cl,
954 : : "\n"
955 : : "Traffic Management:\n"
956 : : "--------------\n"
957 : : "show port tm cap (port_id)\n"
958 : : " Display the port TM capability.\n\n"
959 : :
960 : : "show port tm level cap (port_id) (level_id)\n"
961 : : " Display the port TM hierarchical level capability.\n\n"
962 : :
963 : : "show port tm node cap (port_id) (node_id)\n"
964 : : " Display the port TM node capability.\n\n"
965 : :
966 : : "show port tm node type (port_id) (node_id)\n"
967 : : " Display the port TM node type.\n\n"
968 : :
969 : : "show port tm node stats (port_id) (node_id) (clear)\n"
970 : : " Display the port TM node stats.\n\n"
971 : :
972 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
973 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
974 : : " (packet_length_adjust) (packet_mode)\n"
975 : : " Add port tm node private shaper profile.\n\n"
976 : :
977 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
978 : : " Delete port tm node private shaper profile.\n\n"
979 : :
980 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
981 : : " (shaper_profile_id)\n"
982 : : " Add/update port tm node shared shaper.\n\n"
983 : :
984 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
985 : : " Delete port tm node shared shaper.\n\n"
986 : :
987 : : "set port tm node shaper profile (port_id) (node_id)"
988 : : " (shaper_profile_id)\n"
989 : : " Set port tm node shaper profile.\n\n"
990 : :
991 : : "add port tm node wred profile (port_id) (wred_profile_id)"
992 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
993 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
994 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
995 : : " Add port tm node wred profile.\n\n"
996 : :
997 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
998 : : " Delete port tm node wred profile.\n\n"
999 : :
1000 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
1001 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1002 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1003 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1004 : : " Add port tm nonleaf node.\n\n"
1005 : :
1006 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
1007 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1008 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
1009 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1010 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
1011 : :
1012 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
1013 : : " (priority) (weight) (level_id) (shaper_profile_id)"
1014 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
1015 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
1016 : : " Add port tm leaf node.\n\n"
1017 : :
1018 : : "del port tm node (port_id) (node_id)\n"
1019 : : " Delete port tm node.\n\n"
1020 : :
1021 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1022 : : " (priority) (weight)\n"
1023 : : " Set port tm node parent.\n\n"
1024 : :
1025 : : "suspend port tm node (port_id) (node_id)"
1026 : : " Suspend tm node.\n\n"
1027 : :
1028 : : "resume port tm node (port_id) (node_id)"
1029 : : " Resume tm node.\n\n"
1030 : :
1031 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1032 : : " Commit tm hierarchy.\n\n"
1033 : :
1034 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1035 : : " (red)\n"
1036 : : " Enables/Disables the traffic management marking"
1037 : : " for IP ECN (Explicit Congestion Notification)"
1038 : : " packets on a given port\n\n"
1039 : :
1040 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1041 : : " (red)\n"
1042 : : " Enables/Disables the traffic management marking"
1043 : : " on the port for IP dscp packets\n\n"
1044 : :
1045 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1046 : : " (red)\n"
1047 : : " Enables/Disables the traffic management marking"
1048 : : " on the port for VLAN packets with DEI enabled\n\n"
1049 : : );
1050 : : }
1051 : :
1052 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1053 : 0 : cmdline_printf(
1054 : : cl,
1055 : : "\n"
1056 : : "Device Operations:\n"
1057 : : "--------------\n"
1058 : : "device detach (identifier)\n"
1059 : : " Detach device by identifier.\n\n"
1060 : : );
1061 : : }
1062 : :
1063 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1064 : : struct testpmd_driver_commands *c;
1065 : : unsigned int i;
1066 : :
1067 : 0 : cmdline_printf(
1068 : : cl,
1069 : : "\n"
1070 : : "Driver specific:\n"
1071 : : "----------------\n"
1072 : : );
1073 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1074 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1075 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1076 : : }
1077 : : }
1078 : 0 : }
1079 : :
1080 : : static cmdline_parse_token_string_t cmd_help_long_help =
1081 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1082 : :
1083 : : static cmdline_parse_token_string_t cmd_help_long_section =
1084 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1085 : : "all#control#display#config#ports#"
1086 : : "filters#traffic_management#devices#drivers");
1087 : :
1088 : : static cmdline_parse_inst_t cmd_help_long = {
1089 : : .f = cmd_help_long_parsed,
1090 : : .data = NULL,
1091 : : .help_str = "help all|control|display|config|ports|"
1092 : : "filters|traffic_management|devices|drivers: "
1093 : : "Show help",
1094 : : .tokens = {
1095 : : (void *)&cmd_help_long_help,
1096 : : (void *)&cmd_help_long_section,
1097 : : NULL,
1098 : : },
1099 : : };
1100 : :
1101 : :
1102 : : /* *** start/stop/close all ports *** */
1103 : : struct cmd_operate_port_result {
1104 : : cmdline_fixed_string_t keyword;
1105 : : cmdline_fixed_string_t name;
1106 : : cmdline_fixed_string_t value;
1107 : : };
1108 : :
1109 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1110 : : __rte_unused struct cmdline *cl,
1111 : : __rte_unused void *data)
1112 : : {
1113 : : struct cmd_operate_port_result *res = parsed_result;
1114 : :
1115 : 0 : if (!strcmp(res->name, "start"))
1116 : 0 : start_port(RTE_PORT_ALL);
1117 : 0 : else if (!strcmp(res->name, "stop"))
1118 : 0 : stop_port(RTE_PORT_ALL);
1119 : 0 : else if (!strcmp(res->name, "close"))
1120 : 0 : close_port(RTE_PORT_ALL);
1121 : 0 : else if (!strcmp(res->name, "reset"))
1122 : 0 : reset_port(RTE_PORT_ALL);
1123 : : else
1124 : 0 : fprintf(stderr, "Unknown parameter\n");
1125 : 0 : }
1126 : :
1127 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1128 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1129 : : "port");
1130 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1131 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1132 : : "start#stop#close#reset");
1133 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1134 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1135 : :
1136 : : static cmdline_parse_inst_t cmd_operate_port = {
1137 : : .f = cmd_operate_port_parsed,
1138 : : .data = NULL,
1139 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1140 : : .tokens = {
1141 : : (void *)&cmd_operate_port_all_cmd,
1142 : : (void *)&cmd_operate_port_all_port,
1143 : : (void *)&cmd_operate_port_all_all,
1144 : : NULL,
1145 : : },
1146 : : };
1147 : :
1148 : : /* *** start/stop/close specific port *** */
1149 : : struct cmd_operate_specific_port_result {
1150 : : cmdline_fixed_string_t keyword;
1151 : : cmdline_fixed_string_t name;
1152 : : uint8_t value;
1153 : : };
1154 : :
1155 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1156 : : __rte_unused struct cmdline *cl,
1157 : : __rte_unused void *data)
1158 : : {
1159 : : struct cmd_operate_specific_port_result *res = parsed_result;
1160 : :
1161 : 0 : if (!strcmp(res->name, "start"))
1162 : 0 : start_port(res->value);
1163 : 0 : else if (!strcmp(res->name, "stop"))
1164 : 0 : stop_port(res->value);
1165 : 0 : else if (!strcmp(res->name, "close"))
1166 : 0 : close_port(res->value);
1167 : 0 : else if (!strcmp(res->name, "reset"))
1168 : 0 : reset_port(res->value);
1169 : : else
1170 : 0 : fprintf(stderr, "Unknown parameter\n");
1171 : 0 : }
1172 : :
1173 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1174 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1175 : : keyword, "port");
1176 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1177 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1178 : : name, "start#stop#close#reset");
1179 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1180 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1181 : : value, RTE_UINT8);
1182 : :
1183 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1184 : : .f = cmd_operate_specific_port_parsed,
1185 : : .data = NULL,
1186 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1187 : : .tokens = {
1188 : : (void *)&cmd_operate_specific_port_cmd,
1189 : : (void *)&cmd_operate_specific_port_port,
1190 : : (void *)&cmd_operate_specific_port_id,
1191 : : NULL,
1192 : : },
1193 : : };
1194 : :
1195 : : /* *** enable port setup (after attach) via iterator or event *** */
1196 : : struct cmd_set_port_setup_on_result {
1197 : : cmdline_fixed_string_t set;
1198 : : cmdline_fixed_string_t port;
1199 : : cmdline_fixed_string_t setup;
1200 : : cmdline_fixed_string_t on;
1201 : : cmdline_fixed_string_t mode;
1202 : : };
1203 : :
1204 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1205 : : __rte_unused struct cmdline *cl,
1206 : : __rte_unused void *data)
1207 : : {
1208 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1209 : :
1210 : 0 : if (strcmp(res->mode, "event") == 0)
1211 : 0 : setup_on_probe_event = true;
1212 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1213 : 0 : setup_on_probe_event = false;
1214 : : else
1215 : 0 : fprintf(stderr, "Unknown mode\n");
1216 : 0 : }
1217 : :
1218 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1219 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1220 : : set, "set");
1221 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1222 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1223 : : port, "port");
1224 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1225 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1226 : : setup, "setup");
1227 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1228 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1229 : : on, "on");
1230 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1231 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1232 : : mode, "iterator#event");
1233 : :
1234 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1235 : : .f = cmd_set_port_setup_on_parsed,
1236 : : .data = NULL,
1237 : : .help_str = "set port setup on iterator|event",
1238 : : .tokens = {
1239 : : (void *)&cmd_set_port_setup_on_set,
1240 : : (void *)&cmd_set_port_setup_on_port,
1241 : : (void *)&cmd_set_port_setup_on_setup,
1242 : : (void *)&cmd_set_port_setup_on_on,
1243 : : (void *)&cmd_set_port_setup_on_mode,
1244 : : NULL,
1245 : : },
1246 : : };
1247 : :
1248 : : /* *** attach a specified port *** */
1249 : : struct cmd_operate_attach_port_result {
1250 : : cmdline_fixed_string_t port;
1251 : : cmdline_fixed_string_t keyword;
1252 : : cmdline_multi_string_t identifier;
1253 : : };
1254 : :
1255 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1256 : : __rte_unused struct cmdline *cl,
1257 : : __rte_unused void *data)
1258 : : {
1259 : : struct cmd_operate_attach_port_result *res = parsed_result;
1260 : :
1261 : 0 : if (!strcmp(res->keyword, "attach"))
1262 : 0 : attach_port(res->identifier);
1263 : : else
1264 : 0 : fprintf(stderr, "Unknown parameter\n");
1265 : 0 : }
1266 : :
1267 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1268 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1269 : : port, "port");
1270 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1271 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1272 : : keyword, "attach");
1273 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1274 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1275 : : identifier, TOKEN_STRING_MULTI);
1276 : :
1277 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1278 : : .f = cmd_operate_attach_port_parsed,
1279 : : .data = NULL,
1280 : : .help_str = "port attach <identifier>: "
1281 : : "(identifier: pci address or virtual dev name)",
1282 : : .tokens = {
1283 : : (void *)&cmd_operate_attach_port_port,
1284 : : (void *)&cmd_operate_attach_port_keyword,
1285 : : (void *)&cmd_operate_attach_port_identifier,
1286 : : NULL,
1287 : : },
1288 : : };
1289 : :
1290 : : /* *** detach a specified port *** */
1291 : : struct cmd_operate_detach_port_result {
1292 : : cmdline_fixed_string_t port;
1293 : : cmdline_fixed_string_t keyword;
1294 : : portid_t port_id;
1295 : : };
1296 : :
1297 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1298 : : __rte_unused struct cmdline *cl,
1299 : : __rte_unused void *data)
1300 : : {
1301 : : struct cmd_operate_detach_port_result *res = parsed_result;
1302 : :
1303 : 0 : if (!strcmp(res->keyword, "detach")) {
1304 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1305 : 0 : detach_port_device(res->port_id);
1306 : : } else {
1307 : 0 : fprintf(stderr, "Unknown parameter\n");
1308 : : }
1309 : : }
1310 : :
1311 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1312 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1313 : : port, "port");
1314 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1315 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1316 : : keyword, "detach");
1317 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1318 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1319 : : port_id, RTE_UINT16);
1320 : :
1321 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1322 : : .f = cmd_operate_detach_port_parsed,
1323 : : .data = NULL,
1324 : : .help_str = "port detach <port_id>",
1325 : : .tokens = {
1326 : : (void *)&cmd_operate_detach_port_port,
1327 : : (void *)&cmd_operate_detach_port_keyword,
1328 : : (void *)&cmd_operate_detach_port_port_id,
1329 : : NULL,
1330 : : },
1331 : : };
1332 : :
1333 : : /* *** detach device by identifier *** */
1334 : : struct cmd_operate_detach_device_result {
1335 : : cmdline_fixed_string_t device;
1336 : : cmdline_fixed_string_t keyword;
1337 : : cmdline_fixed_string_t identifier;
1338 : : };
1339 : :
1340 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1341 : : __rte_unused struct cmdline *cl,
1342 : : __rte_unused void *data)
1343 : : {
1344 : : struct cmd_operate_detach_device_result *res = parsed_result;
1345 : :
1346 : 0 : if (!strcmp(res->keyword, "detach"))
1347 : 0 : detach_devargs(res->identifier);
1348 : : else
1349 : 0 : fprintf(stderr, "Unknown parameter\n");
1350 : 0 : }
1351 : :
1352 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1353 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1354 : : device, "device");
1355 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1356 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1357 : : keyword, "detach");
1358 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1359 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1360 : : identifier, NULL);
1361 : :
1362 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1363 : : .f = cmd_operate_detach_device_parsed,
1364 : : .data = NULL,
1365 : : .help_str = "device detach <identifier>:"
1366 : : "(identifier: pci address or virtual dev name)",
1367 : : .tokens = {
1368 : : (void *)&cmd_operate_detach_device_device,
1369 : : (void *)&cmd_operate_detach_device_keyword,
1370 : : (void *)&cmd_operate_detach_device_identifier,
1371 : : NULL,
1372 : : },
1373 : : };
1374 : : /* *** configure speed for all ports *** */
1375 : : struct cmd_config_speed_all {
1376 : : cmdline_fixed_string_t port;
1377 : : cmdline_fixed_string_t keyword;
1378 : : cmdline_fixed_string_t all;
1379 : : cmdline_fixed_string_t item1;
1380 : : cmdline_fixed_string_t item2;
1381 : : cmdline_fixed_string_t value1;
1382 : : cmdline_fixed_string_t value2;
1383 : : };
1384 : :
1385 : : static int
1386 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1387 : : {
1388 : :
1389 : : int duplex;
1390 : :
1391 : 0 : if (!strcmp(duplexstr, "half")) {
1392 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1393 : 0 : } else if (!strcmp(duplexstr, "full")) {
1394 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1395 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1396 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1397 : : } else {
1398 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1399 : 0 : return -1;
1400 : : }
1401 : :
1402 : 0 : if (!strcmp(speedstr, "10")) {
1403 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1404 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1405 : 0 : } else if (!strcmp(speedstr, "100")) {
1406 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1407 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1408 : : } else {
1409 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1410 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1411 : 0 : return -1;
1412 : : }
1413 : 0 : if (!strcmp(speedstr, "1000")) {
1414 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1415 : 0 : } else if (!strcmp(speedstr, "2500")) {
1416 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1417 : 0 : } else if (!strcmp(speedstr, "5000")) {
1418 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1419 : 0 : } else if (!strcmp(speedstr, "10000")) {
1420 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1421 : 0 : } else if (!strcmp(speedstr, "25000")) {
1422 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1423 : 0 : } else if (!strcmp(speedstr, "40000")) {
1424 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1425 : 0 : } else if (!strcmp(speedstr, "50000")) {
1426 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1427 : 0 : } else if (!strcmp(speedstr, "100000")) {
1428 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1429 : 0 : } else if (!strcmp(speedstr, "200000")) {
1430 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1431 : 0 : } else if (!strcmp(speedstr, "400000")) {
1432 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1433 : 0 : } else if (!strcmp(speedstr, "auto")) {
1434 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1435 : : } else {
1436 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1437 : 0 : return -1;
1438 : : }
1439 : : }
1440 : :
1441 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1442 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1443 : :
1444 : : return 0;
1445 : : }
1446 : :
1447 : : static void
1448 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1449 : : __rte_unused struct cmdline *cl,
1450 : : __rte_unused void *data)
1451 : : {
1452 : : struct cmd_config_speed_all *res = parsed_result;
1453 : : uint32_t link_speed;
1454 : : portid_t pid;
1455 : :
1456 : 0 : if (!all_ports_stopped()) {
1457 : 0 : fprintf(stderr, "Please stop all ports first\n");
1458 : 0 : return;
1459 : : }
1460 : :
1461 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1462 : : &link_speed) < 0)
1463 : : return;
1464 : :
1465 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1466 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1467 : : }
1468 : :
1469 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1470 : : }
1471 : :
1472 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1473 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1474 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1475 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1476 : : "config");
1477 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1478 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1479 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1480 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1481 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1482 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1483 : : "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1484 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1485 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1486 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1487 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1488 : : "half#full#auto");
1489 : :
1490 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1491 : : .f = cmd_config_speed_all_parsed,
1492 : : .data = NULL,
1493 : : .help_str = "port config all speed "
1494 : : "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1495 : : "half|full|auto",
1496 : : .tokens = {
1497 : : (void *)&cmd_config_speed_all_port,
1498 : : (void *)&cmd_config_speed_all_keyword,
1499 : : (void *)&cmd_config_speed_all_all,
1500 : : (void *)&cmd_config_speed_all_item1,
1501 : : (void *)&cmd_config_speed_all_value1,
1502 : : (void *)&cmd_config_speed_all_item2,
1503 : : (void *)&cmd_config_speed_all_value2,
1504 : : NULL,
1505 : : },
1506 : : };
1507 : :
1508 : : /* *** configure speed for specific port *** */
1509 : : struct cmd_config_speed_specific {
1510 : : cmdline_fixed_string_t port;
1511 : : cmdline_fixed_string_t keyword;
1512 : : portid_t id;
1513 : : cmdline_fixed_string_t item1;
1514 : : cmdline_fixed_string_t item2;
1515 : : cmdline_fixed_string_t value1;
1516 : : cmdline_fixed_string_t value2;
1517 : : };
1518 : :
1519 : : static void
1520 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1521 : : __rte_unused struct cmdline *cl,
1522 : : __rte_unused void *data)
1523 : : {
1524 : : struct cmd_config_speed_specific *res = parsed_result;
1525 : : uint32_t link_speed;
1526 : :
1527 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1528 : 0 : return;
1529 : :
1530 : 0 : if (!port_is_stopped(res->id)) {
1531 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1532 : 0 : return;
1533 : : }
1534 : :
1535 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1536 : : &link_speed) < 0)
1537 : : return;
1538 : :
1539 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1540 : :
1541 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1542 : : }
1543 : :
1544 : :
1545 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1546 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1547 : : "port");
1548 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1549 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1550 : : "config");
1551 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1552 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1553 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1554 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1555 : : "speed");
1556 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1557 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1558 : : "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1559 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1560 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1561 : : "duplex");
1562 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1563 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1564 : : "half#full#auto");
1565 : :
1566 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1567 : : .f = cmd_config_speed_specific_parsed,
1568 : : .data = NULL,
1569 : : .help_str = "port config <port_id> speed "
1570 : : "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1571 : : "half|full|auto",
1572 : : .tokens = {
1573 : : (void *)&cmd_config_speed_specific_port,
1574 : : (void *)&cmd_config_speed_specific_keyword,
1575 : : (void *)&cmd_config_speed_specific_id,
1576 : : (void *)&cmd_config_speed_specific_item1,
1577 : : (void *)&cmd_config_speed_specific_value1,
1578 : : (void *)&cmd_config_speed_specific_item2,
1579 : : (void *)&cmd_config_speed_specific_value2,
1580 : : NULL,
1581 : : },
1582 : : };
1583 : :
1584 : : static int
1585 : 0 : parse_speed_lanes_cfg(portid_t pid, uint32_t lanes)
1586 : : {
1587 : : int ret;
1588 : :
1589 : 0 : ret = rte_eth_speed_lanes_set(pid, lanes);
1590 : 0 : if (ret == -ENOTSUP) {
1591 : 0 : fprintf(stderr, "Function not implemented\n");
1592 : 0 : return -1;
1593 : 0 : } else if (ret < 0) {
1594 : 0 : fprintf(stderr, "Set speed lanes failed\n");
1595 : 0 : return -1;
1596 : : }
1597 : :
1598 : : return 0;
1599 : : }
1600 : :
1601 : : static void
1602 : 0 : show_speed_lanes_capability(unsigned int num, struct rte_eth_speed_lanes_capa *speed_lanes_capa)
1603 : : {
1604 : : unsigned int i;
1605 : : uint32_t capa;
1606 : :
1607 : : printf("\n%-15s %-10s", "Supported-speeds", "Valid-lanes");
1608 : : printf("\n-----------------------------------\n");
1609 : 0 : for (i = 0; i < num; i++) {
1610 : 0 : printf("%-17s ",
1611 : 0 : rte_eth_link_speed_to_str(speed_lanes_capa[i].speed));
1612 : 0 : capa = speed_lanes_capa[i].capa;
1613 : : int s = 0;
1614 : :
1615 : 0 : while (capa) {
1616 : 0 : if (capa & 0x1)
1617 : : printf("%-2d ", s);
1618 : 0 : s++;
1619 : 0 : capa = capa >> 1;
1620 : : }
1621 : : printf("\n");
1622 : : }
1623 : 0 : }
1624 : :
1625 : : /* *** display speed lanes per port capabilities *** */
1626 : : struct cmd_show_speed_lanes_result {
1627 : : cmdline_fixed_string_t cmd_show;
1628 : : cmdline_fixed_string_t cmd_port;
1629 : : cmdline_fixed_string_t cmd_keyword;
1630 : : portid_t cmd_pid;
1631 : : };
1632 : :
1633 : : static void
1634 : 0 : cmd_show_speed_lanes_parsed(void *parsed_result,
1635 : : __rte_unused struct cmdline *cl,
1636 : : __rte_unused void *data)
1637 : : {
1638 : : struct cmd_show_speed_lanes_result *res = parsed_result;
1639 : : struct rte_eth_speed_lanes_capa *speed_lanes_capa;
1640 : : unsigned int num;
1641 : : int ret;
1642 : :
1643 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
1644 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
1645 : 0 : return;
1646 : : }
1647 : :
1648 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, NULL, 0);
1649 : 0 : if (ret == -ENOTSUP) {
1650 : 0 : fprintf(stderr, "Function not implemented\n");
1651 : 0 : return;
1652 : 0 : } else if (ret < 0) {
1653 : 0 : fprintf(stderr, "Get speed lanes capability failed: %d\n", ret);
1654 : 0 : return;
1655 : : }
1656 : :
1657 : 0 : num = (unsigned int)ret;
1658 : 0 : speed_lanes_capa = calloc(num, sizeof(*speed_lanes_capa));
1659 : 0 : if (speed_lanes_capa == NULL) {
1660 : 0 : fprintf(stderr, "Failed to alloc speed lanes capability buffer\n");
1661 : 0 : return;
1662 : : }
1663 : :
1664 : 0 : ret = rte_eth_speed_lanes_get_capability(res->cmd_pid, speed_lanes_capa, num);
1665 : 0 : if (ret < 0) {
1666 : 0 : fprintf(stderr, "Error getting speed lanes capability: %d\n", ret);
1667 : 0 : goto out;
1668 : : }
1669 : :
1670 : 0 : show_speed_lanes_capability(num, speed_lanes_capa);
1671 : 0 : out:
1672 : 0 : free(speed_lanes_capa);
1673 : : }
1674 : :
1675 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_show =
1676 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1677 : : cmd_show, "show");
1678 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_port =
1679 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1680 : : cmd_port, "port");
1681 : : static cmdline_parse_token_num_t cmd_show_speed_lanes_pid =
1682 : : TOKEN_NUM_INITIALIZER(struct cmd_show_speed_lanes_result,
1683 : : cmd_pid, RTE_UINT16);
1684 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_keyword =
1685 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1686 : : cmd_keyword, "speed_lanes");
1687 : : static cmdline_parse_token_string_t cmd_show_speed_lanes_cap_keyword =
1688 : : TOKEN_STRING_INITIALIZER(struct cmd_show_speed_lanes_result,
1689 : : cmd_keyword, "capabilities");
1690 : :
1691 : : static cmdline_parse_inst_t cmd_show_speed_lanes = {
1692 : : .f = cmd_show_speed_lanes_parsed,
1693 : : .data = NULL,
1694 : : .help_str = "show port <port_id> speed_lanes capabilities",
1695 : : .tokens = {
1696 : : (void *)&cmd_show_speed_lanes_show,
1697 : : (void *)&cmd_show_speed_lanes_port,
1698 : : (void *)&cmd_show_speed_lanes_pid,
1699 : : (void *)&cmd_show_speed_lanes_keyword,
1700 : : (void *)&cmd_show_speed_lanes_cap_keyword,
1701 : : NULL,
1702 : : },
1703 : : };
1704 : :
1705 : : /* *** configure speed_lanes for all ports *** */
1706 : : struct cmd_config_speed_lanes_all {
1707 : : cmdline_fixed_string_t port;
1708 : : cmdline_fixed_string_t keyword;
1709 : : cmdline_fixed_string_t all;
1710 : : cmdline_fixed_string_t item;
1711 : : uint32_t lanes;
1712 : : };
1713 : :
1714 : : static void
1715 : 0 : cmd_config_speed_lanes_all_parsed(void *parsed_result,
1716 : : __rte_unused struct cmdline *cl,
1717 : : __rte_unused void *data)
1718 : : {
1719 : : struct cmd_config_speed_lanes_all *res = parsed_result;
1720 : : portid_t pid;
1721 : :
1722 : 0 : if (!all_ports_stopped()) {
1723 : 0 : fprintf(stderr, "Please stop all ports first\n");
1724 : 0 : return;
1725 : : }
1726 : :
1727 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1728 : 0 : if (parse_speed_lanes_cfg(pid, res->lanes))
1729 : : return;
1730 : : }
1731 : :
1732 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1733 : : }
1734 : :
1735 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_port =
1736 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, port, "port");
1737 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_keyword =
1738 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, keyword,
1739 : : "config");
1740 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_all =
1741 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, all, "all");
1742 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_all_item =
1743 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_all, item,
1744 : : "speed_lanes");
1745 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_all_lanes =
1746 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_all, lanes, RTE_UINT32);
1747 : :
1748 : : static cmdline_parse_inst_t cmd_config_speed_lanes_all = {
1749 : : .f = cmd_config_speed_lanes_all_parsed,
1750 : : .data = NULL,
1751 : : .help_str = "port config all speed_lanes <value>",
1752 : : .tokens = {
1753 : : (void *)&cmd_config_speed_lanes_all_port,
1754 : : (void *)&cmd_config_speed_lanes_all_keyword,
1755 : : (void *)&cmd_config_speed_lanes_all_all,
1756 : : (void *)&cmd_config_speed_lanes_all_item,
1757 : : (void *)&cmd_config_speed_lanes_all_lanes,
1758 : : NULL,
1759 : : },
1760 : : };
1761 : :
1762 : : /* *** configure speed_lanes for specific port *** */
1763 : : struct cmd_config_speed_lanes_specific {
1764 : : cmdline_fixed_string_t port;
1765 : : cmdline_fixed_string_t keyword;
1766 : : uint16_t port_id;
1767 : : cmdline_fixed_string_t item;
1768 : : uint32_t lanes;
1769 : : };
1770 : :
1771 : : static void
1772 : 0 : cmd_config_speed_lanes_specific_parsed(void *parsed_result,
1773 : : __rte_unused struct cmdline *cl,
1774 : : __rte_unused void *data)
1775 : : {
1776 : : struct cmd_config_speed_lanes_specific *res = parsed_result;
1777 : :
1778 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1779 : : return;
1780 : :
1781 : 0 : if (!port_is_stopped(res->port_id)) {
1782 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1783 : 0 : return;
1784 : : }
1785 : :
1786 : 0 : if (parse_speed_lanes_cfg(res->port_id, res->lanes))
1787 : : return;
1788 : :
1789 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1790 : : }
1791 : :
1792 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_port =
1793 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, port,
1794 : : "port");
1795 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_keyword =
1796 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, keyword,
1797 : : "config");
1798 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_id =
1799 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, port_id,
1800 : : RTE_UINT16);
1801 : : static cmdline_parse_token_string_t cmd_config_speed_lanes_specific_item =
1802 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_lanes_specific, item,
1803 : : "speed_lanes");
1804 : : static cmdline_parse_token_num_t cmd_config_speed_lanes_specific_lanes =
1805 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_lanes_specific, lanes,
1806 : : RTE_UINT32);
1807 : :
1808 : : static cmdline_parse_inst_t cmd_config_speed_lanes_specific = {
1809 : : .f = cmd_config_speed_lanes_specific_parsed,
1810 : : .data = NULL,
1811 : : .help_str = "port config <port_id> speed_lanes <value>",
1812 : : .tokens = {
1813 : : (void *)&cmd_config_speed_lanes_specific_port,
1814 : : (void *)&cmd_config_speed_lanes_specific_keyword,
1815 : : (void *)&cmd_config_speed_lanes_specific_id,
1816 : : (void *)&cmd_config_speed_lanes_specific_item,
1817 : : (void *)&cmd_config_speed_lanes_specific_lanes,
1818 : : NULL,
1819 : : },
1820 : : };
1821 : :
1822 : : /* *** configure loopback for all ports *** */
1823 : : struct cmd_config_loopback_all {
1824 : : cmdline_fixed_string_t port;
1825 : : cmdline_fixed_string_t keyword;
1826 : : cmdline_fixed_string_t all;
1827 : : cmdline_fixed_string_t item;
1828 : : uint32_t mode;
1829 : : };
1830 : :
1831 : : static void
1832 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1833 : : __rte_unused struct cmdline *cl,
1834 : : __rte_unused void *data)
1835 : : {
1836 : : struct cmd_config_loopback_all *res = parsed_result;
1837 : : portid_t pid;
1838 : :
1839 : 0 : if (!all_ports_stopped()) {
1840 : 0 : fprintf(stderr, "Please stop all ports first\n");
1841 : 0 : return;
1842 : : }
1843 : :
1844 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1845 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1846 : : }
1847 : :
1848 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1849 : : }
1850 : :
1851 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1852 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1853 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1854 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1855 : : "config");
1856 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1857 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1858 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1859 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1860 : : "loopback");
1861 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1862 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1863 : :
1864 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1865 : : .f = cmd_config_loopback_all_parsed,
1866 : : .data = NULL,
1867 : : .help_str = "port config all loopback <mode>",
1868 : : .tokens = {
1869 : : (void *)&cmd_config_loopback_all_port,
1870 : : (void *)&cmd_config_loopback_all_keyword,
1871 : : (void *)&cmd_config_loopback_all_all,
1872 : : (void *)&cmd_config_loopback_all_item,
1873 : : (void *)&cmd_config_loopback_all_mode,
1874 : : NULL,
1875 : : },
1876 : : };
1877 : :
1878 : : /* *** configure loopback for specific port *** */
1879 : : struct cmd_config_loopback_specific {
1880 : : cmdline_fixed_string_t port;
1881 : : cmdline_fixed_string_t keyword;
1882 : : uint16_t port_id;
1883 : : cmdline_fixed_string_t item;
1884 : : uint32_t mode;
1885 : : };
1886 : :
1887 : : static void
1888 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1889 : : __rte_unused struct cmdline *cl,
1890 : : __rte_unused void *data)
1891 : : {
1892 : : struct cmd_config_loopback_specific *res = parsed_result;
1893 : :
1894 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1895 : : return;
1896 : :
1897 : 0 : if (!port_is_stopped(res->port_id)) {
1898 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1899 : 0 : return;
1900 : : }
1901 : :
1902 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1903 : :
1904 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1905 : : }
1906 : :
1907 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1908 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1909 : : "port");
1910 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1911 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1912 : : "config");
1913 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1914 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1915 : : RTE_UINT16);
1916 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1917 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1918 : : "loopback");
1919 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1920 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1921 : : RTE_UINT32);
1922 : :
1923 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1924 : : .f = cmd_config_loopback_specific_parsed,
1925 : : .data = NULL,
1926 : : .help_str = "port config <port_id> loopback <mode>",
1927 : : .tokens = {
1928 : : (void *)&cmd_config_loopback_specific_port,
1929 : : (void *)&cmd_config_loopback_specific_keyword,
1930 : : (void *)&cmd_config_loopback_specific_id,
1931 : : (void *)&cmd_config_loopback_specific_item,
1932 : : (void *)&cmd_config_loopback_specific_mode,
1933 : : NULL,
1934 : : },
1935 : : };
1936 : :
1937 : : /* *** configure txq/rxq, txd/rxd *** */
1938 : : struct cmd_config_rx_tx {
1939 : : cmdline_fixed_string_t port;
1940 : : cmdline_fixed_string_t keyword;
1941 : : cmdline_fixed_string_t all;
1942 : : cmdline_fixed_string_t name;
1943 : : uint16_t value;
1944 : : };
1945 : :
1946 : : static void
1947 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1948 : : __rte_unused struct cmdline *cl,
1949 : : __rte_unused void *data)
1950 : : {
1951 : : struct cmd_config_rx_tx *res = parsed_result;
1952 : :
1953 : 0 : if (!all_ports_stopped()) {
1954 : 0 : fprintf(stderr, "Please stop all ports first\n");
1955 : 0 : return;
1956 : : }
1957 : 0 : if (!strcmp(res->name, "rxq")) {
1958 : 0 : if (!res->value && !nb_txq) {
1959 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1960 : 0 : return;
1961 : : }
1962 : 0 : if (check_nb_rxq(res->value) != 0)
1963 : : return;
1964 : 0 : nb_rxq = res->value;
1965 : : }
1966 : 0 : else if (!strcmp(res->name, "txq")) {
1967 : 0 : if (!res->value && !nb_rxq) {
1968 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1969 : 0 : return;
1970 : : }
1971 : 0 : if (check_nb_txq(res->value) != 0)
1972 : : return;
1973 : 0 : nb_txq = res->value;
1974 : : }
1975 : 0 : else if (!strcmp(res->name, "rxd")) {
1976 : 0 : if (check_nb_rxd(res->value) != 0)
1977 : : return;
1978 : 0 : nb_rxd = res->value;
1979 : 0 : } else if (!strcmp(res->name, "txd")) {
1980 : 0 : if (check_nb_txd(res->value) != 0)
1981 : : return;
1982 : :
1983 : 0 : nb_txd = res->value;
1984 : : } else {
1985 : 0 : fprintf(stderr, "Unknown parameter\n");
1986 : 0 : return;
1987 : : }
1988 : :
1989 : 0 : fwd_config_setup();
1990 : :
1991 : 0 : init_port_config();
1992 : :
1993 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1994 : : }
1995 : :
1996 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
1997 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1998 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1999 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
2000 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
2001 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
2002 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
2003 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
2004 : : "rxq#txq#rxd#txd");
2005 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
2006 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
2007 : :
2008 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
2009 : : .f = cmd_config_rx_tx_parsed,
2010 : : .data = NULL,
2011 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
2012 : : .tokens = {
2013 : : (void *)&cmd_config_rx_tx_port,
2014 : : (void *)&cmd_config_rx_tx_keyword,
2015 : : (void *)&cmd_config_rx_tx_all,
2016 : : (void *)&cmd_config_rx_tx_name,
2017 : : (void *)&cmd_config_rx_tx_value,
2018 : : NULL,
2019 : : },
2020 : : };
2021 : :
2022 : : /* *** config max packet length *** */
2023 : : struct cmd_config_max_pkt_len_result {
2024 : : cmdline_fixed_string_t port;
2025 : : cmdline_fixed_string_t keyword;
2026 : : cmdline_fixed_string_t all;
2027 : : cmdline_fixed_string_t name;
2028 : : uint32_t value;
2029 : : };
2030 : :
2031 : : static void
2032 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
2033 : : __rte_unused struct cmdline *cl,
2034 : : __rte_unused void *data)
2035 : : {
2036 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
2037 : : portid_t port_id;
2038 : : int ret;
2039 : :
2040 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
2041 : : printf("Unknown parameter\n");
2042 : 0 : return;
2043 : : }
2044 : :
2045 : 0 : if (!all_ports_stopped()) {
2046 : 0 : fprintf(stderr, "Please stop all ports first\n");
2047 : 0 : return;
2048 : : }
2049 : :
2050 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
2051 : 0 : struct rte_port *port = &ports[port_id];
2052 : :
2053 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
2054 : 0 : fprintf(stderr,
2055 : : "max-pkt-len can not be less than %d\n",
2056 : : RTE_ETHER_MIN_LEN);
2057 : 0 : return;
2058 : : }
2059 : :
2060 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
2061 : 0 : if (ret != 0) {
2062 : 0 : fprintf(stderr,
2063 : : "rte_eth_dev_info_get() failed for port %u\n",
2064 : : port_id);
2065 : 0 : return;
2066 : : }
2067 : :
2068 : 0 : update_mtu_from_frame_size(port_id, res->value);
2069 : : }
2070 : :
2071 : 0 : init_port_config();
2072 : :
2073 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2074 : : }
2075 : :
2076 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
2077 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
2078 : : "port");
2079 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
2080 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
2081 : : "config");
2082 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
2083 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
2084 : : "all");
2085 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
2086 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
2087 : : "max-pkt-len");
2088 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
2089 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
2090 : : RTE_UINT32);
2091 : :
2092 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
2093 : : .f = cmd_config_max_pkt_len_parsed,
2094 : : .data = NULL,
2095 : : .help_str = "port config all max-pkt-len <value>",
2096 : : .tokens = {
2097 : : (void *)&cmd_config_max_pkt_len_port,
2098 : : (void *)&cmd_config_max_pkt_len_keyword,
2099 : : (void *)&cmd_config_max_pkt_len_all,
2100 : : (void *)&cmd_config_max_pkt_len_name,
2101 : : (void *)&cmd_config_max_pkt_len_value,
2102 : : NULL,
2103 : : },
2104 : : };
2105 : :
2106 : : /* *** config max LRO aggregated packet size *** */
2107 : : struct cmd_config_max_lro_pkt_size_result {
2108 : : cmdline_fixed_string_t port;
2109 : : cmdline_fixed_string_t keyword;
2110 : : cmdline_fixed_string_t all;
2111 : : cmdline_fixed_string_t name;
2112 : : uint32_t value;
2113 : : };
2114 : :
2115 : : static void
2116 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
2117 : : __rte_unused struct cmdline *cl,
2118 : : __rte_unused void *data)
2119 : : {
2120 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
2121 : : portid_t pid;
2122 : :
2123 : 0 : if (!all_ports_stopped()) {
2124 : 0 : fprintf(stderr, "Please stop all ports first\n");
2125 : 0 : return;
2126 : : }
2127 : :
2128 : 0 : RTE_ETH_FOREACH_DEV(pid) {
2129 : 0 : struct rte_port *port = &ports[pid];
2130 : :
2131 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
2132 : 0 : if (res->value ==
2133 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
2134 : : return;
2135 : :
2136 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
2137 : : } else {
2138 : 0 : fprintf(stderr, "Unknown parameter\n");
2139 : 0 : return;
2140 : : }
2141 : : }
2142 : :
2143 : 0 : init_port_config();
2144 : :
2145 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2146 : : }
2147 : :
2148 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
2149 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2150 : : port, "port");
2151 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
2152 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2153 : : keyword, "config");
2154 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
2155 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2156 : : all, "all");
2157 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
2158 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2159 : : name, "max-lro-pkt-size");
2160 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
2161 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
2162 : : value, RTE_UINT32);
2163 : :
2164 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
2165 : : .f = cmd_config_max_lro_pkt_size_parsed,
2166 : : .data = NULL,
2167 : : .help_str = "port config all max-lro-pkt-size <value>",
2168 : : .tokens = {
2169 : : (void *)&cmd_config_max_lro_pkt_size_port,
2170 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
2171 : : (void *)&cmd_config_max_lro_pkt_size_all,
2172 : : (void *)&cmd_config_max_lro_pkt_size_name,
2173 : : (void *)&cmd_config_max_lro_pkt_size_value,
2174 : : NULL,
2175 : : },
2176 : : };
2177 : :
2178 : : /* *** configure port MTU *** */
2179 : : struct cmd_config_mtu_result {
2180 : : cmdline_fixed_string_t port;
2181 : : cmdline_fixed_string_t keyword;
2182 : : cmdline_fixed_string_t mtu;
2183 : : portid_t port_id;
2184 : : uint16_t value;
2185 : : };
2186 : :
2187 : : static void
2188 : 0 : cmd_config_mtu_parsed(void *parsed_result,
2189 : : __rte_unused struct cmdline *cl,
2190 : : __rte_unused void *data)
2191 : : {
2192 : : struct cmd_config_mtu_result *res = parsed_result;
2193 : :
2194 : 0 : port_mtu_set(res->port_id, res->value);
2195 : 0 : }
2196 : :
2197 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
2198 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
2199 : : "port");
2200 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
2201 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2202 : : "config");
2203 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
2204 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
2205 : : "mtu");
2206 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
2207 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
2208 : : RTE_UINT16);
2209 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
2210 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
2211 : : RTE_UINT16);
2212 : :
2213 : : static cmdline_parse_inst_t cmd_config_mtu = {
2214 : : .f = cmd_config_mtu_parsed,
2215 : : .data = NULL,
2216 : : .help_str = "port config mtu <port_id> <value>",
2217 : : .tokens = {
2218 : : (void *)&cmd_config_mtu_port,
2219 : : (void *)&cmd_config_mtu_keyword,
2220 : : (void *)&cmd_config_mtu_mtu,
2221 : : (void *)&cmd_config_mtu_port_id,
2222 : : (void *)&cmd_config_mtu_value,
2223 : : NULL,
2224 : : },
2225 : : };
2226 : :
2227 : : /* *** configure rx mode *** */
2228 : : struct cmd_config_rx_mode_flag {
2229 : : cmdline_fixed_string_t port;
2230 : : cmdline_fixed_string_t keyword;
2231 : : cmdline_fixed_string_t all;
2232 : : cmdline_fixed_string_t name;
2233 : : cmdline_fixed_string_t value;
2234 : : };
2235 : :
2236 : : static void
2237 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
2238 : : __rte_unused struct cmdline *cl,
2239 : : __rte_unused void *data)
2240 : : {
2241 : : struct cmd_config_rx_mode_flag *res = parsed_result;
2242 : :
2243 : 0 : if (!all_ports_stopped()) {
2244 : 0 : fprintf(stderr, "Please stop all ports first\n");
2245 : 0 : return;
2246 : : }
2247 : :
2248 : 0 : if (!strcmp(res->name, "drop-en")) {
2249 : 0 : if (!strcmp(res->value, "on"))
2250 : 0 : rx_drop_en = 1;
2251 : 0 : else if (!strcmp(res->value, "off"))
2252 : 0 : rx_drop_en = 0;
2253 : : else {
2254 : 0 : fprintf(stderr, "Unknown parameter\n");
2255 : 0 : return;
2256 : : }
2257 : : } else {
2258 : 0 : fprintf(stderr, "Unknown parameter\n");
2259 : 0 : return;
2260 : : }
2261 : :
2262 : 0 : init_port_config();
2263 : :
2264 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2265 : : }
2266 : :
2267 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2268 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2269 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2270 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2271 : : "config");
2272 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2273 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2274 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2275 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2276 : : "drop-en");
2277 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2278 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2279 : : "on#off");
2280 : :
2281 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2282 : : .f = cmd_config_rx_mode_flag_parsed,
2283 : : .data = NULL,
2284 : : .help_str = "port config all drop-en on|off",
2285 : : .tokens = {
2286 : : (void *)&cmd_config_rx_mode_flag_port,
2287 : : (void *)&cmd_config_rx_mode_flag_keyword,
2288 : : (void *)&cmd_config_rx_mode_flag_all,
2289 : : (void *)&cmd_config_rx_mode_flag_name,
2290 : : (void *)&cmd_config_rx_mode_flag_value,
2291 : : NULL,
2292 : : },
2293 : : };
2294 : :
2295 : : /* *** configure rss *** */
2296 : : struct cmd_config_rss {
2297 : : cmdline_fixed_string_t port;
2298 : : cmdline_fixed_string_t keyword;
2299 : : cmdline_fixed_string_t all;
2300 : : cmdline_fixed_string_t name;
2301 : : cmdline_fixed_string_t value;
2302 : : };
2303 : :
2304 : : static void
2305 : 0 : cmd_config_rss_parsed(void *parsed_result,
2306 : : __rte_unused struct cmdline *cl,
2307 : : __rte_unused void *data)
2308 : : {
2309 : : struct cmd_config_rss *res = parsed_result;
2310 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2311 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2312 : : int use_default = 0;
2313 : : int all_updated = 1;
2314 : : int diag;
2315 : : uint16_t i;
2316 : : int ret;
2317 : :
2318 : 0 : if (!strcmp(res->value, "level-default")) {
2319 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2320 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2321 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2322 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2323 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2324 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2325 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2326 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2327 : 0 : } else if (!strcmp(res->value, "default")) {
2328 : : use_default = 1;
2329 : 0 : } else if (isdigit(res->value[0])) {
2330 : : int value = atoi(res->value);
2331 : 0 : if (value > 0 && value < 64)
2332 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2333 : : else {
2334 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2335 : 0 : return;
2336 : : }
2337 : 0 : } else if (!strcmp(res->value, "none")) {
2338 : : rss_conf.rss_hf = 0;
2339 : : } else {
2340 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2341 : 0 : if (rss_conf.rss_hf == 0) {
2342 : 0 : fprintf(stderr, "Unknown parameter\n");
2343 : 0 : return;
2344 : : }
2345 : : }
2346 : : rss_conf.rss_key = NULL;
2347 : : /* Update global configuration for RSS types. */
2348 : 0 : RTE_ETH_FOREACH_DEV(i) {
2349 : : struct rte_eth_rss_conf local_rss_conf;
2350 : :
2351 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2352 : 0 : if (ret != 0)
2353 : 0 : return;
2354 : :
2355 : 0 : if (use_default)
2356 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2357 : :
2358 : 0 : local_rss_conf = rss_conf;
2359 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2360 : 0 : dev_info.flow_type_rss_offloads;
2361 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2362 : : printf("Port %u modified RSS hash function based on hardware support,"
2363 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2364 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2365 : : }
2366 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2367 : 0 : if (diag < 0) {
2368 : : all_updated = 0;
2369 : 0 : fprintf(stderr,
2370 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2371 : : i, -diag, strerror(-diag));
2372 : : }
2373 : : }
2374 : 0 : if (all_updated && !use_default) {
2375 : 0 : rss_hf = rss_conf.rss_hf;
2376 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2377 : : }
2378 : : }
2379 : :
2380 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2381 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2382 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2383 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2384 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2385 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2386 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2387 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2388 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2389 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2390 : :
2391 : : static cmdline_parse_inst_t cmd_config_rss = {
2392 : : .f = cmd_config_rss_parsed,
2393 : : .data = NULL,
2394 : : .help_str = "port config all rss "
2395 : : "all|default|level-default|level-outer|level-inner|"
2396 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2397 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2398 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2399 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2400 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2401 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2402 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2403 : : .tokens = {
2404 : : (void *)&cmd_config_rss_port,
2405 : : (void *)&cmd_config_rss_keyword,
2406 : : (void *)&cmd_config_rss_all,
2407 : : (void *)&cmd_config_rss_name,
2408 : : (void *)&cmd_config_rss_value,
2409 : : NULL,
2410 : : },
2411 : : };
2412 : :
2413 : : /* *** configure rss hash key *** */
2414 : : struct cmd_config_rss_hash_key {
2415 : : cmdline_fixed_string_t port;
2416 : : cmdline_fixed_string_t config;
2417 : : portid_t port_id;
2418 : : cmdline_fixed_string_t rss_hash_key;
2419 : : cmdline_fixed_string_t rss_type;
2420 : : cmdline_fixed_string_t key;
2421 : : };
2422 : :
2423 : : static uint8_t
2424 : : hexa_digit_to_value(char hexa_digit)
2425 : : {
2426 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2427 : : return (uint8_t) (hexa_digit - '0');
2428 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2429 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2430 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2431 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2432 : : /* Invalid hexa digit */
2433 : : return 0xFF;
2434 : : }
2435 : :
2436 : : static uint8_t
2437 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2438 : : {
2439 : : uint8_t hexa_v;
2440 : :
2441 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2442 : : if (hexa_v == 0xFF)
2443 : 0 : fprintf(stderr,
2444 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2445 : : key[idx], idx);
2446 : 0 : return hexa_v;
2447 : : }
2448 : :
2449 : : static void
2450 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2451 : : __rte_unused struct cmdline *cl,
2452 : : __rte_unused void *data)
2453 : : {
2454 : : struct cmd_config_rss_hash_key *res = parsed_result;
2455 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2456 : : uint8_t xdgt0;
2457 : : uint8_t xdgt1;
2458 : : int i;
2459 : : struct rte_eth_dev_info dev_info;
2460 : : uint8_t hash_key_size;
2461 : : uint32_t key_len;
2462 : : int ret;
2463 : :
2464 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2465 : 0 : if (ret != 0)
2466 : 0 : return;
2467 : :
2468 : 0 : if (dev_info.hash_key_size > 0 &&
2469 : : dev_info.hash_key_size <= sizeof(hash_key))
2470 : : hash_key_size = dev_info.hash_key_size;
2471 : : else {
2472 : 0 : fprintf(stderr,
2473 : : "dev_info did not provide a valid hash key size\n");
2474 : 0 : return;
2475 : : }
2476 : : /* Check the length of the RSS hash key */
2477 : 0 : key_len = strlen(res->key);
2478 : 0 : if (key_len != (hash_key_size * 2)) {
2479 : 0 : fprintf(stderr,
2480 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2481 : : (int)key_len, hash_key_size * 2);
2482 : 0 : return;
2483 : : }
2484 : : /* Translate RSS hash key into binary representation */
2485 : 0 : for (i = 0; i < hash_key_size; i++) {
2486 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2487 : 0 : if (xdgt0 == 0xFF)
2488 : : return;
2489 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2490 : 0 : if (xdgt1 == 0xFF)
2491 : : return;
2492 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2493 : : }
2494 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2495 : : hash_key_size);
2496 : : }
2497 : :
2498 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2499 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2500 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2501 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2502 : : "config");
2503 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2504 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2505 : : RTE_UINT16);
2506 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2507 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2508 : : rss_hash_key, "rss-hash-key");
2509 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2510 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2511 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2512 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2513 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2514 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2515 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2516 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2517 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2518 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2519 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2520 : :
2521 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2522 : : .f = cmd_config_rss_hash_key_parsed,
2523 : : .data = NULL,
2524 : : .help_str = "port config <port_id> rss-hash-key "
2525 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2526 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2527 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2528 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2529 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2530 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2531 : : "<string of hex digits (variable length, NIC dependent)>",
2532 : : .tokens = {
2533 : : (void *)&cmd_config_rss_hash_key_port,
2534 : : (void *)&cmd_config_rss_hash_key_config,
2535 : : (void *)&cmd_config_rss_hash_key_port_id,
2536 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2537 : : (void *)&cmd_config_rss_hash_key_rss_type,
2538 : : (void *)&cmd_config_rss_hash_key_value,
2539 : : NULL,
2540 : : },
2541 : : };
2542 : :
2543 : : /* *** configure rss hash algorithm *** */
2544 : : struct cmd_config_rss_hash_algo {
2545 : : cmdline_fixed_string_t port;
2546 : : cmdline_fixed_string_t config;
2547 : : portid_t port_id;
2548 : : cmdline_fixed_string_t rss_hash_algo;
2549 : : cmdline_fixed_string_t algo;
2550 : : };
2551 : :
2552 : : static void
2553 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2554 : : __rte_unused struct cmdline *cl,
2555 : : __rte_unused void *data)
2556 : : {
2557 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2558 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2559 : : struct rte_eth_rss_conf rss_conf;
2560 : : uint32_t algorithm;
2561 : : int ret;
2562 : :
2563 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2564 : 0 : rss_conf.rss_key = rss_key;
2565 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2566 : 0 : if (ret != 0) {
2567 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2568 : 0 : res->port_id);
2569 : 0 : return;
2570 : : }
2571 : :
2572 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2573 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2574 : 0 : if (ret != 0) {
2575 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2576 : 0 : res->port_id, res->algo);
2577 : 0 : return;
2578 : : }
2579 : :
2580 : 0 : rss_conf.algorithm = algorithm;
2581 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2582 : 0 : if (ret != 0) {
2583 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2584 : 0 : res->port_id);
2585 : 0 : return;
2586 : : }
2587 : : }
2588 : :
2589 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2590 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2591 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2592 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2593 : : "config");
2594 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2595 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2596 : : RTE_UINT16);
2597 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2598 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2599 : : rss_hash_algo, "rss-hash-algo");
2600 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2601 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2602 : : "default#simple_xor#toeplitz#"
2603 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2604 : :
2605 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2606 : : .f = cmd_config_rss_hash_algo_parsed,
2607 : : .data = NULL,
2608 : : .help_str = "port config <port_id> rss-hash-algo "
2609 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2610 : : .tokens = {
2611 : : (void *)&cmd_config_rss_hash_algo_port,
2612 : : (void *)&cmd_config_rss_hash_algo_config,
2613 : : (void *)&cmd_config_rss_hash_algo_port_id,
2614 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2615 : : (void *)&cmd_config_rss_hash_algo_algo,
2616 : : NULL,
2617 : : },
2618 : : };
2619 : :
2620 : : /* *** cleanup txq mbufs *** */
2621 : : struct cmd_cleanup_txq_mbufs_result {
2622 : : cmdline_fixed_string_t port;
2623 : : cmdline_fixed_string_t keyword;
2624 : : cmdline_fixed_string_t name;
2625 : : uint16_t port_id;
2626 : : uint16_t queue_id;
2627 : : uint32_t free_cnt;
2628 : : };
2629 : :
2630 : : static void
2631 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2632 : : __rte_unused struct cmdline *cl,
2633 : : __rte_unused void *data)
2634 : : {
2635 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2636 : 0 : uint16_t port_id = res->port_id;
2637 : 0 : uint16_t queue_id = res->queue_id;
2638 : 0 : uint32_t free_cnt = res->free_cnt;
2639 : : struct rte_eth_txq_info qinfo;
2640 : : int ret;
2641 : :
2642 : 0 : if (test_done == 0) {
2643 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2644 : 0 : return;
2645 : : }
2646 : :
2647 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2648 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2649 : : port_id, queue_id);
2650 : 0 : return;
2651 : : }
2652 : :
2653 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2654 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2655 : 0 : return;
2656 : : }
2657 : :
2658 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2659 : 0 : if (ret < 0) {
2660 : 0 : fprintf(stderr,
2661 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2662 : : port_id, queue_id, strerror(-ret), ret);
2663 : 0 : return;
2664 : : }
2665 : :
2666 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2667 : : port_id, queue_id, ret);
2668 : : }
2669 : :
2670 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2671 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2672 : : "port");
2673 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2674 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2675 : : "cleanup");
2676 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2677 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2678 : : RTE_UINT16);
2679 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2680 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2681 : : "txq");
2682 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2683 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2684 : : RTE_UINT16);
2685 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2686 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2687 : : RTE_UINT32);
2688 : :
2689 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2690 : : .f = cmd_cleanup_txq_mbufs_parsed,
2691 : : .data = NULL,
2692 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2693 : : .tokens = {
2694 : : (void *)&cmd_cleanup_txq_mbufs_port,
2695 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2696 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2697 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2698 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2699 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2700 : : NULL,
2701 : : },
2702 : : };
2703 : :
2704 : : /* *** configure port rxq/txq ring size *** */
2705 : : struct cmd_config_rxtx_ring_size {
2706 : : cmdline_fixed_string_t port;
2707 : : cmdline_fixed_string_t config;
2708 : : portid_t portid;
2709 : : cmdline_fixed_string_t rxtxq;
2710 : : uint16_t qid;
2711 : : cmdline_fixed_string_t rsize;
2712 : : uint16_t size;
2713 : : };
2714 : :
2715 : : static void
2716 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2717 : : __rte_unused struct cmdline *cl,
2718 : : __rte_unused void *data)
2719 : : {
2720 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2721 : : struct rte_port *port;
2722 : : uint8_t isrx;
2723 : :
2724 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2725 : : return;
2726 : :
2727 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2728 : 0 : fprintf(stderr, "Invalid port id\n");
2729 : 0 : return;
2730 : : }
2731 : :
2732 : 0 : port = &ports[res->portid];
2733 : :
2734 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2735 : : isrx = 1;
2736 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2737 : : isrx = 0;
2738 : : else {
2739 : 0 : fprintf(stderr, "Unknown parameter\n");
2740 : 0 : return;
2741 : : }
2742 : :
2743 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2744 : : return;
2745 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2746 : : return;
2747 : :
2748 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2749 : 0 : fprintf(stderr,
2750 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2751 : : rx_free_thresh);
2752 : 0 : return;
2753 : : }
2754 : :
2755 : 0 : if (isrx)
2756 : 0 : port->nb_rx_desc[res->qid] = res->size;
2757 : : else
2758 : 0 : port->nb_tx_desc[res->qid] = res->size;
2759 : :
2760 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2761 : : }
2762 : :
2763 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2764 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2765 : : port, "port");
2766 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2767 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2768 : : config, "config");
2769 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2770 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2771 : : portid, RTE_UINT16);
2772 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2773 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2774 : : rxtxq, "rxq#txq");
2775 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2776 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2777 : : qid, RTE_UINT16);
2778 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2779 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2780 : : rsize, "ring_size");
2781 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2782 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2783 : : size, RTE_UINT16);
2784 : :
2785 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2786 : : .f = cmd_config_rxtx_ring_size_parsed,
2787 : : .data = NULL,
2788 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2789 : : .tokens = {
2790 : : (void *)&cmd_config_rxtx_ring_size_port,
2791 : : (void *)&cmd_config_rxtx_ring_size_config,
2792 : : (void *)&cmd_config_rxtx_ring_size_portid,
2793 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2794 : : (void *)&cmd_config_rxtx_ring_size_qid,
2795 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2796 : : (void *)&cmd_config_rxtx_ring_size_size,
2797 : : NULL,
2798 : : },
2799 : : };
2800 : :
2801 : : /* *** configure port rxq/txq start/stop *** */
2802 : : struct cmd_config_rxtx_queue {
2803 : : cmdline_fixed_string_t port;
2804 : : portid_t portid;
2805 : : cmdline_fixed_string_t rxtxq;
2806 : : uint16_t qid;
2807 : : cmdline_fixed_string_t opname;
2808 : : };
2809 : :
2810 : : static void
2811 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2812 : : __rte_unused struct cmdline *cl,
2813 : : __rte_unused void *data)
2814 : : {
2815 : : struct cmd_config_rxtx_queue *res = parsed_result;
2816 : : struct rte_port *port;
2817 : : uint8_t isrx;
2818 : : uint8_t isstart;
2819 : : uint8_t *state;
2820 : : int ret = 0;
2821 : :
2822 : 0 : if (test_done == 0) {
2823 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2824 : 0 : return;
2825 : : }
2826 : :
2827 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2828 : : return;
2829 : :
2830 : 0 : if (port_is_started(res->portid) != 1) {
2831 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2832 : 0 : return;
2833 : : }
2834 : :
2835 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2836 : : isrx = 1;
2837 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2838 : : isrx = 0;
2839 : : else {
2840 : 0 : fprintf(stderr, "Unknown parameter\n");
2841 : 0 : return;
2842 : : }
2843 : :
2844 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2845 : : return;
2846 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2847 : : return;
2848 : :
2849 : 0 : if (!strcmp(res->opname, "start"))
2850 : : isstart = 1;
2851 : 0 : else if (!strcmp(res->opname, "stop"))
2852 : : isstart = 0;
2853 : : else {
2854 : 0 : fprintf(stderr, "Unknown parameter\n");
2855 : 0 : return;
2856 : : }
2857 : :
2858 : 0 : if (isstart && isrx)
2859 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2860 : 0 : else if (!isstart && isrx)
2861 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2862 : 0 : else if (isstart && !isrx)
2863 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2864 : : else
2865 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2866 : :
2867 : 0 : if (ret == -ENOTSUP) {
2868 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2869 : 0 : return;
2870 : : }
2871 : :
2872 : 0 : port = &ports[res->portid];
2873 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2874 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2875 : : RTE_ETH_QUEUE_STATE_STOPPED;
2876 : : }
2877 : :
2878 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2879 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2880 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2881 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2882 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2883 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2884 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2885 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2886 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2887 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2888 : : "start#stop");
2889 : :
2890 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2891 : : .f = cmd_config_rxtx_queue_parsed,
2892 : : .data = NULL,
2893 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2894 : : .tokens = {
2895 : : (void *)&cmd_config_rxtx_queue_port,
2896 : : (void *)&cmd_config_rxtx_queue_portid,
2897 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2898 : : (void *)&cmd_config_rxtx_queue_qid,
2899 : : (void *)&cmd_config_rxtx_queue_opname,
2900 : : NULL,
2901 : : },
2902 : : };
2903 : :
2904 : : /* *** configure port rxq/txq deferred start on/off *** */
2905 : : struct cmd_config_deferred_start_rxtx_queue {
2906 : : cmdline_fixed_string_t port;
2907 : : portid_t port_id;
2908 : : cmdline_fixed_string_t rxtxq;
2909 : : uint16_t qid;
2910 : : cmdline_fixed_string_t opname;
2911 : : cmdline_fixed_string_t state;
2912 : : };
2913 : :
2914 : : static void
2915 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2916 : : __rte_unused struct cmdline *cl,
2917 : : __rte_unused void *data)
2918 : : {
2919 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2920 : : struct rte_port *port;
2921 : : uint8_t isrx;
2922 : : uint8_t ison;
2923 : : uint8_t needreconfig = 0;
2924 : :
2925 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2926 : : return;
2927 : :
2928 : 0 : if (port_is_started(res->port_id) != 0) {
2929 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2930 : 0 : return;
2931 : : }
2932 : :
2933 : 0 : port = &ports[res->port_id];
2934 : :
2935 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2936 : :
2937 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2938 : : return;
2939 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2940 : : return;
2941 : :
2942 : 0 : ison = !strcmp(res->state, "on");
2943 : :
2944 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2945 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2946 : : needreconfig = 1;
2947 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2948 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2949 : : needreconfig = 1;
2950 : : }
2951 : :
2952 : : if (needreconfig)
2953 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2954 : : }
2955 : :
2956 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2957 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2958 : : port, "port");
2959 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2960 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2961 : : port_id, RTE_UINT16);
2962 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2963 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2964 : : rxtxq, "rxq#txq");
2965 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2966 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2967 : : qid, RTE_UINT16);
2968 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2969 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2970 : : opname, "deferred_start");
2971 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2972 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2973 : : state, "on#off");
2974 : :
2975 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2976 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
2977 : : .data = NULL,
2978 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2979 : : .tokens = {
2980 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
2981 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2982 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2983 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2984 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2985 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
2986 : : NULL,
2987 : : },
2988 : : };
2989 : :
2990 : : /* *** configure port rxq/txq setup *** */
2991 : : struct cmd_setup_rxtx_queue {
2992 : : cmdline_fixed_string_t port;
2993 : : portid_t portid;
2994 : : cmdline_fixed_string_t rxtxq;
2995 : : uint16_t qid;
2996 : : cmdline_fixed_string_t setup;
2997 : : };
2998 : :
2999 : : /* Common CLI fields for queue setup */
3000 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
3001 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
3002 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
3003 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
3004 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
3005 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
3006 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
3007 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
3008 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
3009 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
3010 : :
3011 : : static void
3012 : 0 : cmd_setup_rxtx_queue_parsed(
3013 : : void *parsed_result,
3014 : : __rte_unused struct cmdline *cl,
3015 : : __rte_unused void *data)
3016 : : {
3017 : : struct cmd_setup_rxtx_queue *res = parsed_result;
3018 : : struct rte_port *port;
3019 : : struct rte_mempool *mp;
3020 : : unsigned int socket_id;
3021 : : uint8_t isrx = 0;
3022 : : int ret;
3023 : :
3024 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
3025 : : return;
3026 : :
3027 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
3028 : 0 : fprintf(stderr, "Invalid port id\n");
3029 : 0 : return;
3030 : : }
3031 : :
3032 : 0 : if (!strcmp(res->rxtxq, "rxq"))
3033 : : isrx = 1;
3034 : 0 : else if (!strcmp(res->rxtxq, "txq"))
3035 : : isrx = 0;
3036 : : else {
3037 : 0 : fprintf(stderr, "Unknown parameter\n");
3038 : 0 : return;
3039 : : }
3040 : :
3041 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
3042 : 0 : fprintf(stderr, "Invalid rx queue\n");
3043 : 0 : return;
3044 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
3045 : 0 : fprintf(stderr, "Invalid tx queue\n");
3046 : 0 : return;
3047 : : }
3048 : :
3049 : 0 : port = &ports[res->portid];
3050 : 0 : if (isrx) {
3051 : 0 : socket_id = rxring_numa[res->portid];
3052 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3053 : 0 : socket_id = port->socket_id;
3054 : :
3055 : : mp = mbuf_pool_find(socket_id, 0);
3056 : 0 : if (mp == NULL) {
3057 : 0 : fprintf(stderr,
3058 : : "Failed to setup RX queue: No mempool allocation on the socket %d\n",
3059 : 0 : rxring_numa[res->portid]);
3060 : 0 : return;
3061 : : }
3062 : 0 : ret = rx_queue_setup(res->portid,
3063 : : res->qid,
3064 : 0 : port->nb_rx_desc[res->qid],
3065 : : socket_id,
3066 : 0 : &port->rxq[res->qid].conf,
3067 : : mp);
3068 : 0 : if (ret)
3069 : 0 : fprintf(stderr, "Failed to setup RX queue\n");
3070 : : } else {
3071 : 0 : socket_id = txring_numa[res->portid];
3072 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
3073 : 0 : socket_id = port->socket_id;
3074 : :
3075 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
3076 : 0 : fprintf(stderr,
3077 : : "Failed to setup TX queue: not enough descriptors\n");
3078 : 0 : return;
3079 : : }
3080 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
3081 : : res->qid,
3082 : : port->nb_tx_desc[res->qid],
3083 : : socket_id,
3084 : 0 : &port->txq[res->qid].conf);
3085 : 0 : if (ret)
3086 : 0 : fprintf(stderr, "Failed to setup TX queue\n");
3087 : : }
3088 : : }
3089 : :
3090 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
3091 : : .f = cmd_setup_rxtx_queue_parsed,
3092 : : .data = NULL,
3093 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
3094 : : .tokens = {
3095 : : (void *)&cmd_setup_rxtx_queue_port,
3096 : : (void *)&cmd_setup_rxtx_queue_portid,
3097 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
3098 : : (void *)&cmd_setup_rxtx_queue_qid,
3099 : : (void *)&cmd_setup_rxtx_queue_setup,
3100 : : NULL,
3101 : : },
3102 : : };
3103 : :
3104 : :
3105 : : /* *** Configure RSS RETA *** */
3106 : : struct cmd_config_rss_reta {
3107 : : cmdline_fixed_string_t port;
3108 : : cmdline_fixed_string_t keyword;
3109 : : portid_t port_id;
3110 : : cmdline_fixed_string_t name;
3111 : : cmdline_fixed_string_t list_name;
3112 : : cmdline_fixed_string_t list_of_items;
3113 : : };
3114 : :
3115 : : static int
3116 : 0 : parse_reta_config(const char *str,
3117 : : struct rte_eth_rss_reta_entry64 *reta_conf,
3118 : : uint16_t nb_entries)
3119 : : {
3120 : : int i;
3121 : : unsigned size;
3122 : : uint16_t hash_index, idx, shift;
3123 : : uint16_t nb_queue;
3124 : : char s[256];
3125 : : const char *p, *p0 = str;
3126 : : char *end;
3127 : : enum fieldnames {
3128 : : FLD_HASH_INDEX = 0,
3129 : : FLD_QUEUE,
3130 : : _NUM_FLD
3131 : : };
3132 : : unsigned long int_fld[_NUM_FLD];
3133 : : char *str_fld[_NUM_FLD];
3134 : :
3135 : 0 : while ((p = strchr(p0,'(')) != NULL) {
3136 : 0 : ++p;
3137 : 0 : if((p0 = strchr(p,')')) == NULL)
3138 : : return -1;
3139 : :
3140 : 0 : size = p0 - p;
3141 : 0 : if(size >= sizeof(s))
3142 : : return -1;
3143 : :
3144 : : snprintf(s, sizeof(s), "%.*s", size, p);
3145 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
3146 : : return -1;
3147 : 0 : for (i = 0; i < _NUM_FLD; i++) {
3148 : 0 : errno = 0;
3149 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
3150 : 0 : if (errno != 0 || end == str_fld[i] ||
3151 : : int_fld[i] > 65535)
3152 : : return -1;
3153 : : }
3154 : :
3155 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
3156 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
3157 : :
3158 : 0 : if (hash_index >= nb_entries) {
3159 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
3160 : : hash_index);
3161 : 0 : return -1;
3162 : : }
3163 : :
3164 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
3165 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
3166 : 0 : reta_conf[idx].mask |= (1ULL << shift);
3167 : 0 : reta_conf[idx].reta[shift] = nb_queue;
3168 : : }
3169 : :
3170 : : return 0;
3171 : : }
3172 : :
3173 : : static void
3174 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
3175 : : __rte_unused struct cmdline *cl,
3176 : : __rte_unused void *data)
3177 : : {
3178 : : int ret;
3179 : : struct rte_eth_dev_info dev_info;
3180 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3181 : : struct cmd_config_rss_reta *res = parsed_result;
3182 : :
3183 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3184 : 0 : if (ret != 0)
3185 : 0 : return;
3186 : :
3187 : 0 : if (dev_info.reta_size == 0) {
3188 : 0 : fprintf(stderr,
3189 : : "Redirection table size is 0 which is invalid for RSS\n");
3190 : 0 : return;
3191 : : } else
3192 : 0 : printf("The reta size of port %d is %u\n",
3193 : 0 : res->port_id, dev_info.reta_size);
3194 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
3195 : 0 : fprintf(stderr,
3196 : : "Currently do not support more than %u entries of redirection table\n",
3197 : : RTE_ETH_RSS_RETA_SIZE_512);
3198 : 0 : return;
3199 : : }
3200 : :
3201 : : memset(reta_conf, 0, sizeof(reta_conf));
3202 : 0 : if (!strcmp(res->list_name, "reta")) {
3203 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
3204 : : dev_info.reta_size)) {
3205 : 0 : fprintf(stderr,
3206 : : "Invalid RSS Redirection Table config entered\n");
3207 : 0 : return;
3208 : : }
3209 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
3210 : 0 : reta_conf, dev_info.reta_size);
3211 : 0 : if (ret != 0)
3212 : 0 : fprintf(stderr,
3213 : : "Bad redirection table parameter, return code = %d\n",
3214 : : ret);
3215 : : }
3216 : : }
3217 : :
3218 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
3219 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
3220 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
3221 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
3222 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
3223 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
3224 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
3225 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
3226 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
3227 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
3228 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
3229 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
3230 : : NULL);
3231 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
3232 : : .f = cmd_set_rss_reta_parsed,
3233 : : .data = NULL,
3234 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
3235 : : .tokens = {
3236 : : (void *)&cmd_config_rss_reta_port,
3237 : : (void *)&cmd_config_rss_reta_keyword,
3238 : : (void *)&cmd_config_rss_reta_port_id,
3239 : : (void *)&cmd_config_rss_reta_name,
3240 : : (void *)&cmd_config_rss_reta_list_name,
3241 : : (void *)&cmd_config_rss_reta_list_of_items,
3242 : : NULL,
3243 : : },
3244 : : };
3245 : :
3246 : : /* *** SHOW PORT RETA INFO *** */
3247 : : struct cmd_showport_reta {
3248 : : cmdline_fixed_string_t show;
3249 : : cmdline_fixed_string_t port;
3250 : : portid_t port_id;
3251 : : cmdline_fixed_string_t rss;
3252 : : cmdline_fixed_string_t reta;
3253 : : uint16_t size;
3254 : : cmdline_fixed_string_t list_of_items;
3255 : : };
3256 : :
3257 : : static int
3258 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3259 : : uint16_t nb_entries,
3260 : : char *str)
3261 : : {
3262 : : uint32_t size;
3263 : : const char *p, *p0 = str;
3264 : : char s[256];
3265 : : char *end;
3266 : : char *str_fld[8];
3267 : : uint16_t i;
3268 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3269 : : RTE_ETH_RETA_GROUP_SIZE;
3270 : : int ret;
3271 : :
3272 : 0 : p = strchr(p0, '(');
3273 : 0 : if (p == NULL)
3274 : : return -1;
3275 : 0 : p++;
3276 : 0 : p0 = strchr(p, ')');
3277 : 0 : if (p0 == NULL)
3278 : : return -1;
3279 : 0 : size = p0 - p;
3280 : 0 : if (size >= sizeof(s)) {
3281 : 0 : fprintf(stderr,
3282 : : "The string size exceeds the internal buffer size\n");
3283 : 0 : return -1;
3284 : : }
3285 : : snprintf(s, sizeof(s), "%.*s", size, p);
3286 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3287 : 0 : if (ret <= 0 || ret != num) {
3288 : 0 : fprintf(stderr,
3289 : : "The bits of masks do not match the number of reta entries: %u\n",
3290 : : num);
3291 : 0 : return -1;
3292 : : }
3293 : 0 : for (i = 0; i < ret; i++)
3294 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3295 : :
3296 : : return 0;
3297 : : }
3298 : :
3299 : : static void
3300 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3301 : : __rte_unused struct cmdline *cl,
3302 : : __rte_unused void *data)
3303 : : {
3304 : : struct cmd_showport_reta *res = parsed_result;
3305 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3306 : : struct rte_eth_dev_info dev_info;
3307 : : uint16_t max_reta_size;
3308 : : int ret;
3309 : :
3310 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3311 : 0 : if (ret != 0)
3312 : 0 : return;
3313 : :
3314 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3315 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3316 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3317 : : res->size, max_reta_size);
3318 : 0 : return;
3319 : : }
3320 : :
3321 : : memset(reta_conf, 0, sizeof(reta_conf));
3322 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3323 : 0 : res->list_of_items) < 0) {
3324 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3325 : : res->list_of_items);
3326 : 0 : return;
3327 : : }
3328 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3329 : : }
3330 : :
3331 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3332 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3333 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3334 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3335 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3336 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3337 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3338 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3339 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3340 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3341 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3342 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3343 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3344 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3345 : : list_of_items, NULL);
3346 : :
3347 : : static cmdline_parse_inst_t cmd_showport_reta = {
3348 : : .f = cmd_showport_reta_parsed,
3349 : : .data = NULL,
3350 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3351 : : .tokens = {
3352 : : (void *)&cmd_showport_reta_show,
3353 : : (void *)&cmd_showport_reta_port,
3354 : : (void *)&cmd_showport_reta_port_id,
3355 : : (void *)&cmd_showport_reta_rss,
3356 : : (void *)&cmd_showport_reta_reta,
3357 : : (void *)&cmd_showport_reta_size,
3358 : : (void *)&cmd_showport_reta_list_of_items,
3359 : : NULL,
3360 : : },
3361 : : };
3362 : :
3363 : : /* *** Show RSS hash configuration *** */
3364 : : struct cmd_showport_rss_hash {
3365 : : cmdline_fixed_string_t show;
3366 : : cmdline_fixed_string_t port;
3367 : : portid_t port_id;
3368 : : cmdline_fixed_string_t rss_hash;
3369 : : cmdline_fixed_string_t rss_type;
3370 : : cmdline_fixed_string_t key; /* optional argument */
3371 : : cmdline_fixed_string_t algorithm; /* optional argument */
3372 : : };
3373 : :
3374 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3375 : : __rte_unused struct cmdline *cl,
3376 : : __rte_unused void *data)
3377 : : {
3378 : : struct cmd_showport_rss_hash *res = parsed_result;
3379 : :
3380 : 0 : port_rss_hash_conf_show(res->port_id,
3381 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3382 : 0 : }
3383 : :
3384 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3385 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3386 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3387 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3388 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3389 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3390 : : RTE_UINT16);
3391 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3392 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3393 : : "rss-hash");
3394 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3395 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3396 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3397 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3398 : :
3399 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3400 : : .f = cmd_showport_rss_hash_parsed,
3401 : : .data = NULL,
3402 : : .help_str = "show port <port_id> rss-hash",
3403 : : .tokens = {
3404 : : (void *)&cmd_showport_rss_hash_show,
3405 : : (void *)&cmd_showport_rss_hash_port,
3406 : : (void *)&cmd_showport_rss_hash_port_id,
3407 : : (void *)&cmd_showport_rss_hash_rss_hash,
3408 : : NULL,
3409 : : },
3410 : : };
3411 : :
3412 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3413 : : .f = cmd_showport_rss_hash_parsed,
3414 : : .data = NULL,
3415 : : .help_str = "show port <port_id> rss-hash key",
3416 : : .tokens = {
3417 : : (void *)&cmd_showport_rss_hash_show,
3418 : : (void *)&cmd_showport_rss_hash_port,
3419 : : (void *)&cmd_showport_rss_hash_port_id,
3420 : : (void *)&cmd_showport_rss_hash_rss_hash,
3421 : : (void *)&cmd_showport_rss_hash_rss_key,
3422 : : NULL,
3423 : : },
3424 : : };
3425 : :
3426 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3427 : : .f = cmd_showport_rss_hash_parsed,
3428 : : .data = NULL,
3429 : : .help_str = "show port <port_id> rss-hash algorithm",
3430 : : .tokens = {
3431 : : (void *)&cmd_showport_rss_hash_show,
3432 : : (void *)&cmd_showport_rss_hash_port,
3433 : : (void *)&cmd_showport_rss_hash_port_id,
3434 : : (void *)&cmd_showport_rss_hash_rss_hash,
3435 : : (void *)&cmd_showport_rss_hash_rss_algo,
3436 : : NULL,
3437 : : },
3438 : : };
3439 : :
3440 : : /* *** Configure DCB *** */
3441 : : struct cmd_config_dcb {
3442 : : cmdline_fixed_string_t port;
3443 : : cmdline_fixed_string_t config;
3444 : : portid_t port_id;
3445 : : cmdline_fixed_string_t dcb;
3446 : : cmdline_fixed_string_t vt;
3447 : : cmdline_fixed_string_t vt_en;
3448 : : uint8_t num_tcs;
3449 : : cmdline_fixed_string_t pfc;
3450 : : cmdline_multi_string_t token_str;
3451 : : };
3452 : :
3453 : : static int
3454 : 0 : parse_dcb_token_prio_tc(char *param_str[], int param_num,
3455 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3456 : : uint8_t *prio_tc_en)
3457 : : {
3458 : : unsigned long prio, tc;
3459 : : int prio_tc_maps = 0;
3460 : : char *param, *end;
3461 : : int i;
3462 : :
3463 : 0 : for (i = 0; i < param_num; i++) {
3464 : 0 : param = param_str[i];
3465 : 0 : prio = strtoul(param, &end, 10);
3466 : 0 : if (prio >= RTE_ETH_DCB_NUM_USER_PRIORITIES) {
3467 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO %lu\n", prio);
3468 : 0 : return -1;
3469 : : }
3470 : 0 : if ((*end != ':') || (strlen(end + 1) == 0)) {
3471 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3472 : 0 : return -1;
3473 : : }
3474 : 0 : tc = strtoul(end + 1, &end, 10);
3475 : 0 : if (tc >= RTE_ETH_8_TCS) {
3476 : 0 : fprintf(stderr, "Bad Argument: invalid TC %lu\n", tc);
3477 : 0 : return -1;
3478 : : }
3479 : 0 : if (*end != '\0') {
3480 : 0 : fprintf(stderr, "Bad Argument: invalid PRIO:TC format %s\n", param);
3481 : 0 : return -1;
3482 : : }
3483 : 0 : prio_tc[prio] = tc;
3484 : 0 : prio_tc_maps++;
3485 : : } while (0);
3486 : :
3487 : 0 : if (prio_tc_maps == 0) {
3488 : 0 : fprintf(stderr, "Bad Argument: no PRIO:TC provided\n");
3489 : 0 : return -1;
3490 : : }
3491 : 0 : *prio_tc_en = 1;
3492 : :
3493 : 0 : return 0;
3494 : : }
3495 : :
3496 : : #define DCB_TOKEN_PRIO_TC "prio-tc"
3497 : : #define DCB_TOKEN_KEEP_QNUM "keep-qnum"
3498 : :
3499 : : static int
3500 : 0 : parse_dcb_token_find(char *split_str[], int split_num, int *param_num)
3501 : : {
3502 : : int i;
3503 : :
3504 : 0 : if (strcmp(split_str[0], DCB_TOKEN_KEEP_QNUM) == 0) {
3505 : 0 : *param_num = 0;
3506 : 0 : return 0;
3507 : : }
3508 : :
3509 : 0 : if (strcmp(split_str[0], DCB_TOKEN_PRIO_TC) != 0) {
3510 : 0 : fprintf(stderr, "Bad Argument: unknown token %s\n", split_str[0]);
3511 : 0 : return -EINVAL;
3512 : : }
3513 : :
3514 : 0 : for (i = 1; i < split_num; i++) {
3515 : 0 : if ((strcmp(split_str[i], DCB_TOKEN_PRIO_TC) != 0) &&
3516 : 0 : (strcmp(split_str[i], DCB_TOKEN_KEEP_QNUM) != 0))
3517 : : continue;
3518 : : /* find another optional parameter, then exit. */
3519 : : break;
3520 : : }
3521 : :
3522 : 0 : *param_num = i - 1;
3523 : :
3524 : 0 : return 0;
3525 : : }
3526 : :
3527 : : static int
3528 : 0 : parse_dcb_token_value(char *token_str,
3529 : : uint8_t *pfc_en,
3530 : : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES],
3531 : : uint8_t *prio_tc_en,
3532 : : uint8_t *keep_qnum)
3533 : : {
3534 : : #define MAX_TOKEN_NUM 128
3535 : : char *split_str[MAX_TOKEN_NUM];
3536 : : int param_num, start, ret;
3537 : : int split_num = 0;
3538 : : char *token;
3539 : :
3540 : : /* split multiple token to split str. */
3541 : : do {
3542 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
3543 : 0 : if (token == NULL)
3544 : : break;
3545 : 0 : if (split_num >= MAX_TOKEN_NUM) {
3546 : 0 : fprintf(stderr, "Bad Argument: too much argument\n");
3547 : 0 : return -1;
3548 : : }
3549 : 0 : split_str[split_num++] = token;
3550 : : } while (1);
3551 : :
3552 : : /* parse fixed parameter "pfc-en" first. */
3553 : 0 : token = split_str[0];
3554 : 0 : if (strcmp(token, "on") == 0)
3555 : 0 : *pfc_en = 1;
3556 : 0 : else if (strcmp(token, "off") == 0)
3557 : 0 : *pfc_en = 0;
3558 : : else {
3559 : 0 : fprintf(stderr, "Bad Argument: pfc-en must be on or off\n");
3560 : 0 : return -EINVAL;
3561 : : }
3562 : :
3563 : 0 : if (split_num == 1)
3564 : : return 0;
3565 : :
3566 : : /* start parse optional parameter. */
3567 : : start = 1;
3568 : : do {
3569 : 0 : param_num = 0;
3570 : 0 : ret = parse_dcb_token_find(&split_str[start], split_num - start, ¶m_num);
3571 : 0 : if (ret != 0)
3572 : 0 : return ret;
3573 : :
3574 : 0 : token = split_str[start];
3575 : 0 : if (strcmp(token, DCB_TOKEN_PRIO_TC) == 0) {
3576 : 0 : if (*prio_tc_en == 1) {
3577 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3578 : : DCB_TOKEN_PRIO_TC);
3579 : 0 : return -1;
3580 : : }
3581 : 0 : ret = parse_dcb_token_prio_tc(&split_str[start + 1], param_num, prio_tc,
3582 : : prio_tc_en);
3583 : 0 : if (ret != 0)
3584 : 0 : return ret;
3585 : : } else {
3586 : : /* this must be keep-qnum. */
3587 : 0 : if (*keep_qnum == 1) {
3588 : 0 : fprintf(stderr, "Bad Argument: detect multiple %s token\n",
3589 : : DCB_TOKEN_KEEP_QNUM);
3590 : 0 : return -1;
3591 : : }
3592 : 0 : *keep_qnum = 1;
3593 : : }
3594 : :
3595 : 0 : start += param_num + 1;
3596 : 0 : if (start >= split_num)
3597 : : break;
3598 : : } while (1);
3599 : :
3600 : : return 0;
3601 : : }
3602 : :
3603 : : static void
3604 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3605 : : __rte_unused struct cmdline *cl,
3606 : : __rte_unused void *data)
3607 : : {
3608 : 0 : uint8_t prio_tc[RTE_ETH_DCB_NUM_USER_PRIORITIES] = {0};
3609 : : struct cmd_config_dcb *res = parsed_result;
3610 : : struct rte_eth_dcb_info dcb_info;
3611 : 0 : portid_t port_id = res->port_id;
3612 : 0 : uint8_t prio_tc_en = 0;
3613 : 0 : uint8_t keep_qnum = 0;
3614 : : struct rte_port *port;
3615 : 0 : uint8_t pfc_en = 0;
3616 : : int ret;
3617 : :
3618 : 0 : if (port_id_is_invalid(port_id, ENABLED_WARN))
3619 : 0 : return;
3620 : :
3621 : 0 : port = &ports[port_id];
3622 : : /** Check if the port is not started **/
3623 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3624 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3625 : 0 : return;
3626 : : }
3627 : :
3628 : 0 : if (res->num_tcs < 1 || res->num_tcs > RTE_ETH_8_TCS) {
3629 : 0 : fprintf(stderr,
3630 : : "The invalid number of traffic class, only 1~8 allowed.\n");
3631 : 0 : return;
3632 : : }
3633 : :
3634 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3635 : 0 : fprintf(stderr,
3636 : : "nb_cores shouldn't be less than number of TCs.\n");
3637 : 0 : return;
3638 : : }
3639 : :
3640 : : /* Check whether the port supports the report of DCB info. */
3641 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3642 : 0 : if (ret == -ENOTSUP) {
3643 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3644 : 0 : return;
3645 : : }
3646 : :
3647 : 0 : ret = parse_dcb_token_value(res->token_str, &pfc_en, prio_tc, &prio_tc_en, &keep_qnum);
3648 : 0 : if (ret != 0)
3649 : : return;
3650 : :
3651 : : /* DCB in VT mode */
3652 : 0 : if (!strncmp(res->vt_en, "on", 2))
3653 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3654 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3655 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3656 : : else
3657 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3658 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3659 : : pfc_en, prio_tc, prio_tc_en, keep_qnum);
3660 : 0 : if (ret != 0) {
3661 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3662 : 0 : return;
3663 : : }
3664 : :
3665 : 0 : fwd_config_setup();
3666 : :
3667 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3668 : : }
3669 : :
3670 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3671 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3672 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3673 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3674 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3675 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3676 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3677 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3678 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3679 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3680 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3681 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3682 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3683 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3684 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3685 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3686 : : static cmdline_parse_token_string_t cmd_config_dcb_token_str =
3687 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, token_str, TOKEN_STRING_MULTI);
3688 : :
3689 : : static cmdline_parse_inst_t cmd_config_dcb = {
3690 : : .f = cmd_config_dcb_parsed,
3691 : : .data = NULL,
3692 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off prio-tc PRIO-MAP keep-qnum\n"
3693 : : "where PRIO-MAP: [ PRIO-MAP ] PRIO-MAPPING\n"
3694 : : " PRIO-MAPPING := PRIO:TC\n"
3695 : : " PRIO: { 0 .. 7 }\n"
3696 : : " TC: { 0 .. 7 }",
3697 : : .tokens = {
3698 : : (void *)&cmd_config_dcb_port,
3699 : : (void *)&cmd_config_dcb_config,
3700 : : (void *)&cmd_config_dcb_port_id,
3701 : : (void *)&cmd_config_dcb_dcb,
3702 : : (void *)&cmd_config_dcb_vt,
3703 : : (void *)&cmd_config_dcb_vt_en,
3704 : : (void *)&cmd_config_dcb_num_tcs,
3705 : : (void *)&cmd_config_dcb_pfc,
3706 : : (void *)&cmd_config_dcb_token_str,
3707 : : NULL,
3708 : : },
3709 : : };
3710 : :
3711 : : /* *** configure number of packets per burst *** */
3712 : : struct cmd_config_burst {
3713 : : cmdline_fixed_string_t port;
3714 : : cmdline_fixed_string_t keyword;
3715 : : cmdline_fixed_string_t all;
3716 : : cmdline_fixed_string_t name;
3717 : : uint16_t value;
3718 : : };
3719 : :
3720 : : static void
3721 : 0 : cmd_config_burst_parsed(void *parsed_result,
3722 : : __rte_unused struct cmdline *cl,
3723 : : __rte_unused void *data)
3724 : : {
3725 : : struct cmd_config_burst *res = parsed_result;
3726 : : struct rte_eth_dev_info dev_info;
3727 : : uint16_t rec_nb_pkts;
3728 : : int ret;
3729 : :
3730 : 0 : if (!all_ports_stopped()) {
3731 : 0 : fprintf(stderr, "Please stop all ports first\n");
3732 : 0 : return;
3733 : : }
3734 : :
3735 : 0 : if (!strcmp(res->name, "burst")) {
3736 : 0 : if (res->value == 0) {
3737 : : /* If user gives a value of zero, query the PMD for
3738 : : * its recommended Rx burst size. Testpmd uses a single
3739 : : * size for all ports, so assume all ports are the same
3740 : : * NIC model and use the values from Port 0.
3741 : : */
3742 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3743 : 0 : if (ret != 0)
3744 : : return;
3745 : :
3746 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3747 : :
3748 : 0 : if (rec_nb_pkts == 0) {
3749 : : printf("PMD does not recommend a burst size.\n"
3750 : : "User provided value must be between"
3751 : : " 1 and %d\n", MAX_PKT_BURST);
3752 : 0 : return;
3753 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3754 : 0 : printf("PMD recommended burst size of %d"
3755 : : " exceeds maximum value of %d\n",
3756 : : rec_nb_pkts, MAX_PKT_BURST);
3757 : 0 : return;
3758 : : }
3759 : 0 : printf("Using PMD-provided burst value of %d\n",
3760 : : rec_nb_pkts);
3761 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3762 : 0 : } else if (res->value > MAX_PKT_BURST) {
3763 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3764 : : MAX_PKT_BURST);
3765 : 0 : return;
3766 : : } else
3767 : 0 : nb_pkt_per_burst = res->value;
3768 : : } else {
3769 : 0 : fprintf(stderr, "Unknown parameter\n");
3770 : 0 : return;
3771 : : }
3772 : :
3773 : 0 : init_port_config();
3774 : :
3775 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3776 : : }
3777 : :
3778 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3779 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3780 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3781 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3782 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3783 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3784 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3785 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3786 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3787 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3788 : :
3789 : : static cmdline_parse_inst_t cmd_config_burst = {
3790 : : .f = cmd_config_burst_parsed,
3791 : : .data = NULL,
3792 : : .help_str = "port config all burst <value>",
3793 : : .tokens = {
3794 : : (void *)&cmd_config_burst_port,
3795 : : (void *)&cmd_config_burst_keyword,
3796 : : (void *)&cmd_config_burst_all,
3797 : : (void *)&cmd_config_burst_name,
3798 : : (void *)&cmd_config_burst_value,
3799 : : NULL,
3800 : : },
3801 : : };
3802 : :
3803 : : /* *** configure rx/tx queues *** */
3804 : : struct cmd_config_thresh {
3805 : : cmdline_fixed_string_t port;
3806 : : cmdline_fixed_string_t keyword;
3807 : : cmdline_fixed_string_t all;
3808 : : cmdline_fixed_string_t name;
3809 : : uint8_t value;
3810 : : };
3811 : :
3812 : : static void
3813 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3814 : : __rte_unused struct cmdline *cl,
3815 : : __rte_unused void *data)
3816 : : {
3817 : : struct cmd_config_thresh *res = parsed_result;
3818 : :
3819 : 0 : if (!all_ports_stopped()) {
3820 : 0 : fprintf(stderr, "Please stop all ports first\n");
3821 : 0 : return;
3822 : : }
3823 : :
3824 : 0 : if (!strcmp(res->name, "txpt"))
3825 : 0 : tx_pthresh = res->value;
3826 : 0 : else if(!strcmp(res->name, "txht"))
3827 : 0 : tx_hthresh = res->value;
3828 : 0 : else if(!strcmp(res->name, "txwt"))
3829 : 0 : tx_wthresh = res->value;
3830 : 0 : else if(!strcmp(res->name, "rxpt"))
3831 : 0 : rx_pthresh = res->value;
3832 : 0 : else if(!strcmp(res->name, "rxht"))
3833 : 0 : rx_hthresh = res->value;
3834 : 0 : else if(!strcmp(res->name, "rxwt"))
3835 : 0 : rx_wthresh = res->value;
3836 : : else {
3837 : 0 : fprintf(stderr, "Unknown parameter\n");
3838 : 0 : return;
3839 : : }
3840 : :
3841 : 0 : init_port_config();
3842 : :
3843 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3844 : : }
3845 : :
3846 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3847 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3848 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3849 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3850 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3851 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3852 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3853 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3854 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3855 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3856 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3857 : :
3858 : : static cmdline_parse_inst_t cmd_config_thresh = {
3859 : : .f = cmd_config_thresh_parsed,
3860 : : .data = NULL,
3861 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3862 : : .tokens = {
3863 : : (void *)&cmd_config_thresh_port,
3864 : : (void *)&cmd_config_thresh_keyword,
3865 : : (void *)&cmd_config_thresh_all,
3866 : : (void *)&cmd_config_thresh_name,
3867 : : (void *)&cmd_config_thresh_value,
3868 : : NULL,
3869 : : },
3870 : : };
3871 : :
3872 : : /* *** configure free/rs threshold *** */
3873 : : struct cmd_config_threshold {
3874 : : cmdline_fixed_string_t port;
3875 : : cmdline_fixed_string_t keyword;
3876 : : cmdline_fixed_string_t all;
3877 : : cmdline_fixed_string_t name;
3878 : : uint16_t value;
3879 : : };
3880 : :
3881 : : static void
3882 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3883 : : __rte_unused struct cmdline *cl,
3884 : : __rte_unused void *data)
3885 : : {
3886 : : struct cmd_config_threshold *res = parsed_result;
3887 : :
3888 : 0 : if (!all_ports_stopped()) {
3889 : 0 : fprintf(stderr, "Please stop all ports first\n");
3890 : 0 : return;
3891 : : }
3892 : :
3893 : 0 : if (!strcmp(res->name, "txfreet"))
3894 : 0 : tx_free_thresh = res->value;
3895 : 0 : else if (!strcmp(res->name, "txrst"))
3896 : 0 : tx_rs_thresh = res->value;
3897 : 0 : else if (!strcmp(res->name, "rxfreet"))
3898 : 0 : rx_free_thresh = res->value;
3899 : : else {
3900 : 0 : fprintf(stderr, "Unknown parameter\n");
3901 : 0 : return;
3902 : : }
3903 : :
3904 : 0 : init_port_config();
3905 : :
3906 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3907 : : }
3908 : :
3909 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3910 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3911 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3912 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3913 : : "config");
3914 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3915 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3916 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3917 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3918 : : "txfreet#txrst#rxfreet");
3919 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3920 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3921 : :
3922 : : static cmdline_parse_inst_t cmd_config_threshold = {
3923 : : .f = cmd_config_threshold_parsed,
3924 : : .data = NULL,
3925 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3926 : : .tokens = {
3927 : : (void *)&cmd_config_threshold_port,
3928 : : (void *)&cmd_config_threshold_keyword,
3929 : : (void *)&cmd_config_threshold_all,
3930 : : (void *)&cmd_config_threshold_name,
3931 : : (void *)&cmd_config_threshold_value,
3932 : : NULL,
3933 : : },
3934 : : };
3935 : :
3936 : : /* *** stop *** */
3937 : : struct cmd_stop_result {
3938 : : cmdline_fixed_string_t stop;
3939 : : };
3940 : :
3941 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3942 : : __rte_unused struct cmdline *cl,
3943 : : __rte_unused void *data)
3944 : : {
3945 : 0 : stop_packet_forwarding();
3946 : 0 : }
3947 : :
3948 : : static cmdline_parse_token_string_t cmd_stop_stop =
3949 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3950 : :
3951 : : static cmdline_parse_inst_t cmd_stop = {
3952 : : .f = cmd_stop_parsed,
3953 : : .data = NULL,
3954 : : .help_str = "stop: Stop packet forwarding",
3955 : : .tokens = {
3956 : : (void *)&cmd_stop_stop,
3957 : : NULL,
3958 : : },
3959 : : };
3960 : :
3961 : : static unsigned int
3962 : 0 : get_ptype(char *value)
3963 : : {
3964 : : uint32_t protocol;
3965 : :
3966 : 0 : if (!strcmp(value, "eth"))
3967 : : protocol = RTE_PTYPE_L2_ETHER;
3968 : 0 : else if (!strcmp(value, "ipv4"))
3969 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3970 : 0 : else if (!strcmp(value, "ipv6"))
3971 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3972 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3973 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3974 : 0 : else if (!strcmp(value, "ipv4-udp"))
3975 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3976 : 0 : else if (!strcmp(value, "ipv4-sctp"))
3977 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3978 : 0 : else if (!strcmp(value, "ipv6-tcp"))
3979 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3980 : 0 : else if (!strcmp(value, "ipv6-udp"))
3981 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3982 : 0 : else if (!strcmp(value, "ipv6-sctp"))
3983 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3984 : 0 : else if (!strcmp(value, "grenat"))
3985 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
3986 : 0 : else if (!strcmp(value, "inner-eth"))
3987 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
3988 : 0 : else if (!strcmp(value, "inner-ipv4"))
3989 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3990 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
3991 : 0 : else if (!strcmp(value, "inner-ipv6"))
3992 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3993 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
3994 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
3995 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3996 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3997 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
3998 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3999 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4000 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
4001 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4002 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4003 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
4004 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4005 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
4006 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
4007 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4008 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
4009 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
4010 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
4011 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
4012 : : else {
4013 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
4014 : : protocol = RTE_PTYPE_UNKNOWN;
4015 : : }
4016 : :
4017 : 0 : return protocol;
4018 : : }
4019 : :
4020 : : /* *** SET RXHDRSLIST *** */
4021 : :
4022 : : unsigned int
4023 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
4024 : : unsigned int *parsed_items)
4025 : : {
4026 : : unsigned int nb_item;
4027 : : char *cur;
4028 : : char *tmp;
4029 : :
4030 : : nb_item = 0;
4031 : 0 : char *str2 = strdup(str);
4032 : 0 : if (str2 == NULL)
4033 : : return nb_item;
4034 : 0 : cur = strtok_r(str2, ",", &tmp);
4035 : 0 : while (cur != NULL) {
4036 : 0 : parsed_items[nb_item] = get_ptype(cur);
4037 : 0 : cur = strtok_r(NULL, ",", &tmp);
4038 : 0 : nb_item++;
4039 : : }
4040 : 0 : if (nb_item > max_items)
4041 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4042 : : item_name, nb_item + 1, max_items);
4043 : 0 : free(str2);
4044 : 0 : return nb_item;
4045 : : }
4046 : :
4047 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
4048 : :
4049 : : unsigned int
4050 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
4051 : : unsigned int *parsed_items, int check_unique_values)
4052 : : {
4053 : : unsigned int nb_item;
4054 : : unsigned int value;
4055 : : unsigned int i;
4056 : : unsigned int j;
4057 : : int value_ok;
4058 : : char c;
4059 : :
4060 : : /*
4061 : : * First parse all items in the list and store their value.
4062 : : */
4063 : : value = 0;
4064 : : nb_item = 0;
4065 : : value_ok = 0;
4066 : 0 : for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
4067 : 0 : c = str[i];
4068 : 0 : if ((c >= '0') && (c <= '9')) {
4069 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
4070 : : value_ok = 1;
4071 : 0 : continue;
4072 : : }
4073 : 0 : if (c != ',') {
4074 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
4075 : 0 : return 0;
4076 : : }
4077 : 0 : if (! value_ok) {
4078 : 0 : fprintf(stderr, "No valid value before comma\n");
4079 : 0 : return 0;
4080 : : }
4081 : 0 : if (nb_item < max_items) {
4082 : 0 : parsed_items[nb_item] = value;
4083 : : value_ok = 0;
4084 : : value = 0;
4085 : : }
4086 : 0 : nb_item++;
4087 : : }
4088 : 0 : if (nb_item >= max_items) {
4089 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
4090 : : item_name, nb_item + 1, max_items);
4091 : 0 : return 0;
4092 : : }
4093 : 0 : parsed_items[nb_item++] = value;
4094 : 0 : if (! check_unique_values)
4095 : : return nb_item;
4096 : :
4097 : : /*
4098 : : * Then, check that all values in the list are different.
4099 : : * No optimization here...
4100 : : */
4101 : 0 : for (i = 0; i < nb_item; i++) {
4102 : 0 : for (j = i + 1; j < nb_item; j++) {
4103 : 0 : if (parsed_items[j] == parsed_items[i]) {
4104 : 0 : fprintf(stderr,
4105 : : "duplicated %s %u at index %u and %u\n",
4106 : : item_name, parsed_items[i], i, j);
4107 : 0 : return 0;
4108 : : }
4109 : : }
4110 : : }
4111 : : return nb_item;
4112 : : }
4113 : :
4114 : : struct cmd_set_list_result {
4115 : : cmdline_fixed_string_t cmd_keyword;
4116 : : cmdline_fixed_string_t list_name;
4117 : : cmdline_fixed_string_t list_of_items;
4118 : : };
4119 : :
4120 : 0 : static void cmd_set_list_parsed(void *parsed_result,
4121 : : __rte_unused struct cmdline *cl,
4122 : : __rte_unused void *data)
4123 : : {
4124 : : struct cmd_set_list_result *res;
4125 : : union {
4126 : : unsigned int lcorelist[RTE_MAX_LCORE];
4127 : : unsigned int portlist[RTE_MAX_ETHPORTS];
4128 : : } parsed_items;
4129 : : unsigned int nb_item;
4130 : :
4131 : 0 : if (test_done == 0) {
4132 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4133 : 0 : return;
4134 : : }
4135 : :
4136 : : res = parsed_result;
4137 : 0 : if (!strcmp(res->list_name, "corelist")) {
4138 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
4139 : : RTE_MAX_LCORE,
4140 : : parsed_items.lcorelist, 1);
4141 : 0 : if (nb_item > 0) {
4142 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
4143 : 0 : fwd_config_setup();
4144 : : }
4145 : 0 : return;
4146 : : }
4147 : 0 : if (!strcmp(res->list_name, "portlist")) {
4148 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
4149 : : RTE_MAX_ETHPORTS,
4150 : : parsed_items.portlist, 1);
4151 : 0 : if (nb_item > 0) {
4152 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
4153 : 0 : fwd_config_setup();
4154 : : }
4155 : : }
4156 : : }
4157 : :
4158 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
4159 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
4160 : : "set");
4161 : : static cmdline_parse_token_string_t cmd_set_list_name =
4162 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
4163 : : "corelist#portlist");
4164 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
4165 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
4166 : : NULL);
4167 : :
4168 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
4169 : : .f = cmd_set_list_parsed,
4170 : : .data = NULL,
4171 : : .help_str = "set corelist|portlist <list0[,list1]*>",
4172 : : .tokens = {
4173 : : (void *)&cmd_set_list_keyword,
4174 : : (void *)&cmd_set_list_name,
4175 : : (void *)&cmd_set_list_of_items,
4176 : : NULL,
4177 : : },
4178 : : };
4179 : :
4180 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
4181 : :
4182 : : struct cmd_setmask_result {
4183 : : cmdline_fixed_string_t set;
4184 : : cmdline_fixed_string_t mask;
4185 : : uint64_t hexavalue;
4186 : : };
4187 : :
4188 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
4189 : : __rte_unused struct cmdline *cl,
4190 : : __rte_unused void *data)
4191 : : {
4192 : : struct cmd_setmask_result *res = parsed_result;
4193 : :
4194 : 0 : if (test_done == 0) {
4195 : 0 : fprintf(stderr, "Please stop forwarding first\n");
4196 : 0 : return;
4197 : : }
4198 : 0 : if (!strcmp(res->mask, "coremask")) {
4199 : 0 : set_fwd_lcores_mask(res->hexavalue);
4200 : 0 : fwd_config_setup();
4201 : 0 : } else if (!strcmp(res->mask, "portmask")) {
4202 : 0 : set_fwd_ports_mask(res->hexavalue);
4203 : 0 : fwd_config_setup();
4204 : : }
4205 : : }
4206 : :
4207 : : static cmdline_parse_token_string_t cmd_setmask_set =
4208 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
4209 : : static cmdline_parse_token_string_t cmd_setmask_mask =
4210 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
4211 : : "coremask#portmask");
4212 : : static cmdline_parse_token_num_t cmd_setmask_value =
4213 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
4214 : :
4215 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
4216 : : .f = cmd_set_mask_parsed,
4217 : : .data = NULL,
4218 : : .help_str = "set coremask|portmask <hexadecimal value>",
4219 : : .tokens = {
4220 : : (void *)&cmd_setmask_set,
4221 : : (void *)&cmd_setmask_mask,
4222 : : (void *)&cmd_setmask_value,
4223 : : NULL,
4224 : : },
4225 : : };
4226 : :
4227 : : /*
4228 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
4229 : : */
4230 : : struct cmd_set_result {
4231 : : cmdline_fixed_string_t set;
4232 : : cmdline_fixed_string_t what;
4233 : : uint16_t value;
4234 : : };
4235 : :
4236 : 0 : static void cmd_set_parsed(void *parsed_result,
4237 : : __rte_unused struct cmdline *cl,
4238 : : __rte_unused void *data)
4239 : : {
4240 : : struct cmd_set_result *res = parsed_result;
4241 : 0 : if (!strcmp(res->what, "nbport")) {
4242 : 0 : set_fwd_ports_number(res->value);
4243 : 0 : fwd_config_setup();
4244 : 0 : } else if (!strcmp(res->what, "nbcore")) {
4245 : 0 : set_fwd_lcores_number(res->value);
4246 : 0 : fwd_config_setup();
4247 : 0 : } else if (!strcmp(res->what, "burst"))
4248 : 0 : set_nb_pkt_per_burst(res->value);
4249 : 0 : else if (!strcmp(res->what, "verbose"))
4250 : 0 : set_verbose_level(res->value);
4251 : 0 : }
4252 : :
4253 : : static cmdline_parse_token_string_t cmd_set_set =
4254 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
4255 : : static cmdline_parse_token_string_t cmd_set_what =
4256 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
4257 : : "nbport#nbcore#burst#verbose");
4258 : : static cmdline_parse_token_num_t cmd_set_value =
4259 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
4260 : :
4261 : : static cmdline_parse_inst_t cmd_set_numbers = {
4262 : : .f = cmd_set_parsed,
4263 : : .data = NULL,
4264 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
4265 : : .tokens = {
4266 : : (void *)&cmd_set_set,
4267 : : (void *)&cmd_set_what,
4268 : : (void *)&cmd_set_value,
4269 : : NULL,
4270 : : },
4271 : : };
4272 : :
4273 : : /* *** SET LOG LEVEL CONFIGURATION *** */
4274 : :
4275 : : struct cmd_set_log_result {
4276 : : cmdline_fixed_string_t set;
4277 : : cmdline_fixed_string_t log;
4278 : : cmdline_fixed_string_t type;
4279 : : uint32_t level;
4280 : : };
4281 : :
4282 : : static void
4283 : 0 : cmd_set_log_parsed(void *parsed_result,
4284 : : __rte_unused struct cmdline *cl,
4285 : : __rte_unused void *data)
4286 : : {
4287 : : struct cmd_set_log_result *res;
4288 : : int ret;
4289 : :
4290 : : res = parsed_result;
4291 : 0 : if (!strcmp(res->type, "global"))
4292 : 0 : rte_log_set_global_level(res->level);
4293 : : else {
4294 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
4295 : 0 : if (ret < 0)
4296 : 0 : fprintf(stderr, "Unable to set log level\n");
4297 : : }
4298 : 0 : }
4299 : :
4300 : : static cmdline_parse_token_string_t cmd_set_log_set =
4301 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
4302 : : static cmdline_parse_token_string_t cmd_set_log_log =
4303 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
4304 : : static cmdline_parse_token_string_t cmd_set_log_type =
4305 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
4306 : : static cmdline_parse_token_num_t cmd_set_log_level =
4307 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
4308 : :
4309 : : static cmdline_parse_inst_t cmd_set_log = {
4310 : : .f = cmd_set_log_parsed,
4311 : : .data = NULL,
4312 : : .help_str = "set log global|<type> <level>",
4313 : : .tokens = {
4314 : : (void *)&cmd_set_log_set,
4315 : : (void *)&cmd_set_log_log,
4316 : : (void *)&cmd_set_log_type,
4317 : : (void *)&cmd_set_log_level,
4318 : : NULL,
4319 : : },
4320 : : };
4321 : :
4322 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
4323 : :
4324 : : struct cmd_set_rxoffs_result {
4325 : : cmdline_fixed_string_t cmd_keyword;
4326 : : cmdline_fixed_string_t rxoffs;
4327 : : cmdline_fixed_string_t seg_offsets;
4328 : : };
4329 : :
4330 : : static void
4331 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
4332 : : __rte_unused struct cmdline *cl,
4333 : : __rte_unused void *data)
4334 : : {
4335 : : struct cmd_set_rxoffs_result *res;
4336 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
4337 : : unsigned int nb_segs;
4338 : :
4339 : : res = parsed_result;
4340 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
4341 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
4342 : 0 : if (nb_segs > 0)
4343 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
4344 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4345 : 0 : }
4346 : :
4347 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
4348 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4349 : : cmd_keyword, "set");
4350 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
4351 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4352 : : rxoffs, "rxoffs");
4353 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
4354 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
4355 : : seg_offsets, NULL);
4356 : :
4357 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
4358 : : .f = cmd_set_rxoffs_parsed,
4359 : : .data = NULL,
4360 : : .help_str = "set rxoffs <len0[,len1]*>",
4361 : : .tokens = {
4362 : : (void *)&cmd_set_rxoffs_keyword,
4363 : : (void *)&cmd_set_rxoffs_name,
4364 : : (void *)&cmd_set_rxoffs_offsets,
4365 : : NULL,
4366 : : },
4367 : : };
4368 : :
4369 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
4370 : :
4371 : : struct cmd_set_rxpkts_result {
4372 : : cmdline_fixed_string_t cmd_keyword;
4373 : : cmdline_fixed_string_t rxpkts;
4374 : : cmdline_fixed_string_t seg_lengths;
4375 : : };
4376 : :
4377 : : static void
4378 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
4379 : : __rte_unused struct cmdline *cl,
4380 : : __rte_unused void *data)
4381 : : {
4382 : : struct cmd_set_rxpkts_result *res;
4383 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
4384 : : unsigned int nb_segs;
4385 : :
4386 : : res = parsed_result;
4387 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4388 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
4389 : 0 : if (nb_segs > 0)
4390 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
4391 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4392 : 0 : }
4393 : :
4394 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
4395 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4396 : : cmd_keyword, "set");
4397 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
4398 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4399 : : rxpkts, "rxpkts");
4400 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
4401 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
4402 : : seg_lengths, NULL);
4403 : :
4404 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
4405 : : .f = cmd_set_rxpkts_parsed,
4406 : : .data = NULL,
4407 : : .help_str = "set rxpkts <len0[,len1]*>",
4408 : : .tokens = {
4409 : : (void *)&cmd_set_rxpkts_keyword,
4410 : : (void *)&cmd_set_rxpkts_name,
4411 : : (void *)&cmd_set_rxpkts_lengths,
4412 : : NULL,
4413 : : },
4414 : : };
4415 : :
4416 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4417 : : struct cmd_set_rxhdrs_result {
4418 : : cmdline_fixed_string_t set;
4419 : : cmdline_fixed_string_t rxhdrs;
4420 : : cmdline_fixed_string_t values;
4421 : : };
4422 : :
4423 : : static void
4424 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4425 : : __rte_unused struct cmdline *cl,
4426 : : __rte_unused void *data)
4427 : : {
4428 : : struct cmd_set_rxhdrs_result *res;
4429 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4430 : : unsigned int nb_segs;
4431 : :
4432 : : res = parsed_result;
4433 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4434 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4435 : 0 : if (nb_segs > 0)
4436 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4437 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4438 : 0 : }
4439 : :
4440 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4441 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4442 : : set, "set");
4443 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4444 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4445 : : rxhdrs, "rxhdrs");
4446 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4447 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4448 : : values, NULL);
4449 : :
4450 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4451 : : .f = cmd_set_rxhdrs_parsed,
4452 : : .data = NULL,
4453 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4454 : : .tokens = {
4455 : : (void *)&cmd_set_rxhdrs_set,
4456 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4457 : : (void *)&cmd_set_rxhdrs_values,
4458 : : NULL,
4459 : : },
4460 : : };
4461 : :
4462 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4463 : :
4464 : : struct cmd_set_txpkts_result {
4465 : : cmdline_fixed_string_t cmd_keyword;
4466 : : cmdline_fixed_string_t txpkts;
4467 : : cmdline_fixed_string_t seg_lengths;
4468 : : };
4469 : :
4470 : : static void
4471 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4472 : : __rte_unused struct cmdline *cl,
4473 : : __rte_unused void *data)
4474 : : {
4475 : : struct cmd_set_txpkts_result *res;
4476 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4477 : : unsigned int nb_segs;
4478 : :
4479 : : res = parsed_result;
4480 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4481 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4482 : 0 : if (nb_segs > 0)
4483 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4484 : 0 : }
4485 : :
4486 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4487 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4488 : : cmd_keyword, "set");
4489 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4490 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4491 : : txpkts, "txpkts");
4492 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4493 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4494 : : seg_lengths, NULL);
4495 : :
4496 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4497 : : .f = cmd_set_txpkts_parsed,
4498 : : .data = NULL,
4499 : : .help_str = "set txpkts <len0[,len1]*>",
4500 : : .tokens = {
4501 : : (void *)&cmd_set_txpkts_keyword,
4502 : : (void *)&cmd_set_txpkts_name,
4503 : : (void *)&cmd_set_txpkts_lengths,
4504 : : NULL,
4505 : : },
4506 : : };
4507 : :
4508 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4509 : :
4510 : : struct cmd_set_txsplit_result {
4511 : : cmdline_fixed_string_t cmd_keyword;
4512 : : cmdline_fixed_string_t txsplit;
4513 : : cmdline_fixed_string_t mode;
4514 : : };
4515 : :
4516 : : static void
4517 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4518 : : __rte_unused struct cmdline *cl,
4519 : : __rte_unused void *data)
4520 : : {
4521 : : struct cmd_set_txsplit_result *res;
4522 : :
4523 : : res = parsed_result;
4524 : 0 : set_tx_pkt_split(res->mode);
4525 : 0 : }
4526 : :
4527 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4528 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4529 : : cmd_keyword, "set");
4530 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4531 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4532 : : txsplit, "txsplit");
4533 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4534 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4535 : : mode, NULL);
4536 : :
4537 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4538 : : .f = cmd_set_txsplit_parsed,
4539 : : .data = NULL,
4540 : : .help_str = "set txsplit on|off|rand",
4541 : : .tokens = {
4542 : : (void *)&cmd_set_txsplit_keyword,
4543 : : (void *)&cmd_set_txsplit_name,
4544 : : (void *)&cmd_set_txsplit_mode,
4545 : : NULL,
4546 : : },
4547 : : };
4548 : :
4549 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4550 : :
4551 : : struct cmd_set_txtimes_result {
4552 : : cmdline_fixed_string_t cmd_keyword;
4553 : : cmdline_fixed_string_t txtimes;
4554 : : cmdline_fixed_string_t tx_times;
4555 : : };
4556 : :
4557 : : static void
4558 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4559 : : __rte_unused struct cmdline *cl,
4560 : : __rte_unused void *data)
4561 : : {
4562 : : struct cmd_set_txtimes_result *res;
4563 : 0 : unsigned int tx_times[2] = {0, 0};
4564 : : unsigned int n_times;
4565 : :
4566 : : res = parsed_result;
4567 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4568 : : 2, tx_times, 0);
4569 : 0 : if (n_times == 2)
4570 : 0 : set_tx_pkt_times(tx_times);
4571 : 0 : }
4572 : :
4573 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4574 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4575 : : cmd_keyword, "set");
4576 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4577 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4578 : : txtimes, "txtimes");
4579 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4580 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4581 : : tx_times, NULL);
4582 : :
4583 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4584 : : .f = cmd_set_txtimes_parsed,
4585 : : .data = NULL,
4586 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4587 : : .tokens = {
4588 : : (void *)&cmd_set_txtimes_keyword,
4589 : : (void *)&cmd_set_txtimes_name,
4590 : : (void *)&cmd_set_txtimes_value,
4591 : : NULL,
4592 : : },
4593 : : };
4594 : :
4595 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4596 : : struct cmd_rx_vlan_filter_all_result {
4597 : : cmdline_fixed_string_t rx_vlan;
4598 : : cmdline_fixed_string_t what;
4599 : : cmdline_fixed_string_t all;
4600 : : portid_t port_id;
4601 : : };
4602 : :
4603 : : static void
4604 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4605 : : __rte_unused struct cmdline *cl,
4606 : : __rte_unused void *data)
4607 : : {
4608 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4609 : :
4610 : 0 : if (!strcmp(res->what, "add"))
4611 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4612 : : else
4613 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4614 : 0 : }
4615 : :
4616 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4617 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4618 : : rx_vlan, "rx_vlan");
4619 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4620 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4621 : : what, "add#rm");
4622 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4623 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4624 : : all, "all");
4625 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4626 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4627 : : port_id, RTE_UINT16);
4628 : :
4629 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4630 : : .f = cmd_rx_vlan_filter_all_parsed,
4631 : : .data = NULL,
4632 : : .help_str = "rx_vlan add|rm all <port_id>: "
4633 : : "Add/Remove all identifiers to/from the set of VLAN "
4634 : : "identifiers filtered by a port",
4635 : : .tokens = {
4636 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4637 : : (void *)&cmd_rx_vlan_filter_all_what,
4638 : : (void *)&cmd_rx_vlan_filter_all_all,
4639 : : (void *)&cmd_rx_vlan_filter_all_portid,
4640 : : NULL,
4641 : : },
4642 : : };
4643 : :
4644 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4645 : : struct cmd_vlan_offload_result {
4646 : : cmdline_fixed_string_t vlan;
4647 : : cmdline_fixed_string_t set;
4648 : : cmdline_fixed_string_t vlan_type;
4649 : : cmdline_fixed_string_t what;
4650 : : cmdline_fixed_string_t on;
4651 : : cmdline_fixed_string_t port_id;
4652 : : };
4653 : :
4654 : : static void
4655 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4656 : : __rte_unused struct cmdline *cl,
4657 : : __rte_unused void *data)
4658 : : {
4659 : : int on;
4660 : : struct cmd_vlan_offload_result *res = parsed_result;
4661 : : char *str;
4662 : : int i, len = 0;
4663 : : portid_t port_id = 0;
4664 : : unsigned int tmp;
4665 : :
4666 : 0 : str = res->port_id;
4667 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4668 : : i = 0;
4669 : : /* Get port_id first */
4670 : 0 : while(i < len){
4671 : 0 : if(str[i] == ',')
4672 : : break;
4673 : :
4674 : 0 : i++;
4675 : : }
4676 : 0 : str[i]='\0';
4677 : 0 : tmp = strtoul(str, NULL, 0);
4678 : : /* If port_id greater that what portid_t can represent, return */
4679 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4680 : : return;
4681 : 0 : port_id = (portid_t)tmp;
4682 : :
4683 : 0 : if (!strcmp(res->on, "on"))
4684 : : on = 1;
4685 : : else
4686 : : on = 0;
4687 : :
4688 : 0 : if (!strcmp(res->what, "strip"))
4689 : 0 : rx_vlan_strip_set(port_id, on);
4690 : 0 : else if(!strcmp(res->what, "stripq")){
4691 : : uint16_t queue_id = 0;
4692 : :
4693 : : /* No queue_id, return */
4694 : 0 : if(i + 1 >= len) {
4695 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4696 : 0 : return;
4697 : : }
4698 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4699 : : /* If queue_id greater that what 16-bits can represent, return */
4700 : 0 : if(tmp > 0xffff)
4701 : : return;
4702 : :
4703 : 0 : queue_id = (uint16_t)tmp;
4704 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4705 : : }
4706 : 0 : else if (!strcmp(res->what, "filter"))
4707 : 0 : rx_vlan_filter_set(port_id, on);
4708 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4709 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4710 : : else
4711 : 0 : vlan_extend_set(port_id, on);
4712 : :
4713 : : return;
4714 : : }
4715 : :
4716 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4717 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4718 : : vlan, "vlan");
4719 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4720 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4721 : : set, "set");
4722 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4723 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4724 : : what, "strip#filter#qinq_strip#extend#stripq");
4725 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4726 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4727 : : on, "on#off");
4728 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4729 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4730 : : port_id, NULL);
4731 : :
4732 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4733 : : .f = cmd_vlan_offload_parsed,
4734 : : .data = NULL,
4735 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4736 : : "<port_id[,queue_id]>: "
4737 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4738 : : .tokens = {
4739 : : (void *)&cmd_vlan_offload_vlan,
4740 : : (void *)&cmd_vlan_offload_set,
4741 : : (void *)&cmd_vlan_offload_what,
4742 : : (void *)&cmd_vlan_offload_on,
4743 : : (void *)&cmd_vlan_offload_portid,
4744 : : NULL,
4745 : : },
4746 : : };
4747 : :
4748 : : /* *** VLAN TPID SET ON A PORT *** */
4749 : : struct cmd_vlan_tpid_result {
4750 : : cmdline_fixed_string_t vlan;
4751 : : cmdline_fixed_string_t set;
4752 : : cmdline_fixed_string_t vlan_type;
4753 : : cmdline_fixed_string_t what;
4754 : : uint16_t tp_id;
4755 : : portid_t port_id;
4756 : : };
4757 : :
4758 : : static void
4759 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4760 : : __rte_unused struct cmdline *cl,
4761 : : __rte_unused void *data)
4762 : : {
4763 : : struct cmd_vlan_tpid_result *res = parsed_result;
4764 : : enum rte_vlan_type vlan_type;
4765 : :
4766 : 0 : if (!strcmp(res->vlan_type, "inner"))
4767 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4768 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4769 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4770 : : else {
4771 : 0 : fprintf(stderr, "Unknown vlan type\n");
4772 : 0 : return;
4773 : : }
4774 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4775 : : }
4776 : :
4777 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4778 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4779 : : vlan, "vlan");
4780 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4781 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4782 : : set, "set");
4783 : : static cmdline_parse_token_string_t cmd_vlan_type =
4784 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4785 : : vlan_type, "inner#outer");
4786 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4787 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4788 : : what, "tpid");
4789 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4790 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4791 : : tp_id, RTE_UINT16);
4792 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4793 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4794 : : port_id, RTE_UINT16);
4795 : :
4796 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4797 : : .f = cmd_vlan_tpid_parsed,
4798 : : .data = NULL,
4799 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4800 : : "Set the VLAN Ether type",
4801 : : .tokens = {
4802 : : (void *)&cmd_vlan_tpid_vlan,
4803 : : (void *)&cmd_vlan_tpid_set,
4804 : : (void *)&cmd_vlan_type,
4805 : : (void *)&cmd_vlan_tpid_what,
4806 : : (void *)&cmd_vlan_tpid_tpid,
4807 : : (void *)&cmd_vlan_tpid_portid,
4808 : : NULL,
4809 : : },
4810 : : };
4811 : :
4812 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4813 : : struct cmd_rx_vlan_filter_result {
4814 : : cmdline_fixed_string_t rx_vlan;
4815 : : cmdline_fixed_string_t what;
4816 : : uint16_t vlan_id;
4817 : : portid_t port_id;
4818 : : };
4819 : :
4820 : : static void
4821 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4822 : : __rte_unused struct cmdline *cl,
4823 : : __rte_unused void *data)
4824 : : {
4825 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4826 : :
4827 : 0 : if (!strcmp(res->what, "add"))
4828 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4829 : : else
4830 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4831 : 0 : }
4832 : :
4833 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4834 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4835 : : rx_vlan, "rx_vlan");
4836 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4837 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4838 : : what, "add#rm");
4839 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4840 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4841 : : vlan_id, RTE_UINT16);
4842 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4843 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4844 : : port_id, RTE_UINT16);
4845 : :
4846 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4847 : : .f = cmd_rx_vlan_filter_parsed,
4848 : : .data = NULL,
4849 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4850 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4851 : : "identifiers filtered by a port",
4852 : : .tokens = {
4853 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4854 : : (void *)&cmd_rx_vlan_filter_what,
4855 : : (void *)&cmd_rx_vlan_filter_vlanid,
4856 : : (void *)&cmd_rx_vlan_filter_portid,
4857 : : NULL,
4858 : : },
4859 : : };
4860 : :
4861 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4862 : : struct cmd_tx_vlan_set_result {
4863 : : cmdline_fixed_string_t tx_vlan;
4864 : : cmdline_fixed_string_t set;
4865 : : portid_t port_id;
4866 : : uint16_t vlan_id;
4867 : : };
4868 : :
4869 : : static void
4870 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4871 : : __rte_unused struct cmdline *cl,
4872 : : __rte_unused void *data)
4873 : : {
4874 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4875 : :
4876 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4877 : : return;
4878 : :
4879 : 0 : if (!port_is_stopped(res->port_id)) {
4880 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4881 : 0 : return;
4882 : : }
4883 : :
4884 : 0 : tx_vlan_set(res->port_id, res->vlan_id);
4885 : :
4886 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4887 : : }
4888 : :
4889 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4890 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4891 : : tx_vlan, "tx_vlan");
4892 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4893 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4894 : : set, "set");
4895 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4896 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4897 : : port_id, RTE_UINT16);
4898 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4899 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4900 : : vlan_id, RTE_UINT16);
4901 : :
4902 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4903 : : .f = cmd_tx_vlan_set_parsed,
4904 : : .data = NULL,
4905 : : .help_str = "tx_vlan set <port_id> <vlan_id>: "
4906 : : "Enable hardware insertion of a single VLAN header "
4907 : : "with a given TAG Identifier in packets sent on a port",
4908 : : .tokens = {
4909 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4910 : : (void *)&cmd_tx_vlan_set_set,
4911 : : (void *)&cmd_tx_vlan_set_portid,
4912 : : (void *)&cmd_tx_vlan_set_vlanid,
4913 : : NULL,
4914 : : },
4915 : : };
4916 : :
4917 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4918 : : struct cmd_tx_vlan_set_qinq_result {
4919 : : cmdline_fixed_string_t tx_vlan;
4920 : : cmdline_fixed_string_t set;
4921 : : portid_t port_id;
4922 : : uint16_t vlan_id;
4923 : : uint16_t vlan_id_outer;
4924 : : };
4925 : :
4926 : : static void
4927 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4928 : : __rte_unused struct cmdline *cl,
4929 : : __rte_unused void *data)
4930 : : {
4931 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4932 : :
4933 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4934 : : return;
4935 : :
4936 : 0 : if (!port_is_stopped(res->port_id)) {
4937 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4938 : 0 : return;
4939 : : }
4940 : :
4941 : 0 : tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4942 : :
4943 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4944 : : }
4945 : :
4946 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4947 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4948 : : tx_vlan, "tx_vlan");
4949 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4950 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4951 : : set, "set");
4952 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4953 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4954 : : port_id, RTE_UINT16);
4955 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4956 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4957 : : vlan_id, RTE_UINT16);
4958 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4959 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4960 : : vlan_id_outer, RTE_UINT16);
4961 : :
4962 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4963 : : .f = cmd_tx_vlan_set_qinq_parsed,
4964 : : .data = NULL,
4965 : : .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4966 : : "Enable hardware insertion of double VLAN header "
4967 : : "with given TAG Identifiers in packets sent on a port",
4968 : : .tokens = {
4969 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4970 : : (void *)&cmd_tx_vlan_set_qinq_set,
4971 : : (void *)&cmd_tx_vlan_set_qinq_portid,
4972 : : (void *)&cmd_tx_vlan_set_qinq_vlanid,
4973 : : (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4974 : : NULL,
4975 : : },
4976 : : };
4977 : :
4978 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4979 : : struct cmd_tx_vlan_set_pvid_result {
4980 : : cmdline_fixed_string_t tx_vlan;
4981 : : cmdline_fixed_string_t set;
4982 : : cmdline_fixed_string_t pvid;
4983 : : portid_t port_id;
4984 : : uint16_t vlan_id;
4985 : : cmdline_fixed_string_t mode;
4986 : : };
4987 : :
4988 : : static void
4989 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4990 : : __rte_unused struct cmdline *cl,
4991 : : __rte_unused void *data)
4992 : : {
4993 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4994 : :
4995 : 0 : if (strcmp(res->mode, "on") == 0)
4996 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4997 : : else
4998 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4999 : 0 : }
5000 : :
5001 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
5002 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5003 : : tx_vlan, "tx_vlan");
5004 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
5005 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5006 : : set, "set");
5007 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
5008 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5009 : : pvid, "pvid");
5010 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
5011 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5012 : : port_id, RTE_UINT16);
5013 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
5014 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5015 : : vlan_id, RTE_UINT16);
5016 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
5017 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
5018 : : mode, "on#off");
5019 : :
5020 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
5021 : : .f = cmd_tx_vlan_set_pvid_parsed,
5022 : : .data = NULL,
5023 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
5024 : : .tokens = {
5025 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
5026 : : (void *)&cmd_tx_vlan_set_pvid_set,
5027 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
5028 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
5029 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
5030 : : (void *)&cmd_tx_vlan_set_pvid_mode,
5031 : : NULL,
5032 : : },
5033 : : };
5034 : :
5035 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
5036 : : struct cmd_tx_vlan_reset_result {
5037 : : cmdline_fixed_string_t tx_vlan;
5038 : : cmdline_fixed_string_t reset;
5039 : : portid_t port_id;
5040 : : };
5041 : :
5042 : : static void
5043 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
5044 : : __rte_unused struct cmdline *cl,
5045 : : __rte_unused void *data)
5046 : : {
5047 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
5048 : :
5049 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5050 : : return;
5051 : :
5052 : 0 : if (!port_is_stopped(res->port_id)) {
5053 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5054 : 0 : return;
5055 : : }
5056 : :
5057 : 0 : tx_vlan_reset(res->port_id);
5058 : :
5059 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5060 : : }
5061 : :
5062 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
5063 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5064 : : tx_vlan, "tx_vlan");
5065 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
5066 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
5067 : : reset, "reset");
5068 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
5069 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
5070 : : port_id, RTE_UINT16);
5071 : :
5072 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
5073 : : .f = cmd_tx_vlan_reset_parsed,
5074 : : .data = NULL,
5075 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
5076 : : "VLAN header in packets sent on a port",
5077 : : .tokens = {
5078 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
5079 : : (void *)&cmd_tx_vlan_reset_reset,
5080 : : (void *)&cmd_tx_vlan_reset_portid,
5081 : : NULL,
5082 : : },
5083 : : };
5084 : :
5085 : :
5086 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
5087 : : struct cmd_csum_result {
5088 : : cmdline_fixed_string_t csum;
5089 : : cmdline_fixed_string_t mode;
5090 : : cmdline_fixed_string_t proto;
5091 : : cmdline_fixed_string_t hwsw;
5092 : : portid_t port_id;
5093 : : };
5094 : :
5095 : : static void
5096 : 0 : csum_show(int port_id)
5097 : : {
5098 : : struct rte_eth_dev_info dev_info;
5099 : : uint64_t tx_offloads;
5100 : : int ret;
5101 : :
5102 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
5103 : 0 : printf("Parse tunnel is %s\n",
5104 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
5105 : 0 : printf("IP checksum offload is %s\n",
5106 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
5107 : 0 : printf("UDP checksum offload is %s\n",
5108 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
5109 : 0 : printf("TCP checksum offload is %s\n",
5110 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
5111 : 0 : printf("SCTP checksum offload is %s\n",
5112 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
5113 : 0 : printf("Outer-Ip checksum offload is %s\n",
5114 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
5115 : 0 : printf("Outer-Udp checksum offload is %s\n",
5116 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
5117 : :
5118 : : /* display warnings if configuration is not supported by the NIC */
5119 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
5120 : 0 : if (ret != 0)
5121 : 0 : return;
5122 : :
5123 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
5124 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
5125 : 0 : fprintf(stderr,
5126 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
5127 : : port_id);
5128 : : }
5129 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
5130 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
5131 : 0 : fprintf(stderr,
5132 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
5133 : : port_id);
5134 : : }
5135 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
5136 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
5137 : 0 : fprintf(stderr,
5138 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
5139 : : port_id);
5140 : : }
5141 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
5142 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
5143 : 0 : fprintf(stderr,
5144 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
5145 : : port_id);
5146 : : }
5147 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
5148 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
5149 : 0 : fprintf(stderr,
5150 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
5151 : : port_id);
5152 : : }
5153 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
5154 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
5155 : : == 0) {
5156 : 0 : fprintf(stderr,
5157 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
5158 : : port_id);
5159 : : }
5160 : : }
5161 : :
5162 : : static void
5163 : : cmd_config_queue_tx_offloads(struct rte_port *port)
5164 : : {
5165 : : int k;
5166 : :
5167 : : /* Apply queue tx offloads configuration */
5168 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
5169 : 0 : port->txq[k].conf.offloads =
5170 : 0 : port->dev_conf.txmode.offloads;
5171 : : }
5172 : :
5173 : : static void
5174 : 0 : cmd_csum_parsed(void *parsed_result,
5175 : : __rte_unused struct cmdline *cl,
5176 : : __rte_unused void *data)
5177 : : {
5178 : : struct cmd_csum_result *res = parsed_result;
5179 : : int hw = 0;
5180 : : uint64_t csum_offloads = 0;
5181 : : struct rte_eth_dev_info dev_info;
5182 : : int ret;
5183 : :
5184 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
5185 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
5186 : 0 : return;
5187 : : }
5188 : 0 : if (!port_is_stopped(res->port_id)) {
5189 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5190 : 0 : return;
5191 : : }
5192 : :
5193 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5194 : 0 : if (ret != 0)
5195 : : return;
5196 : :
5197 : 0 : if (!strcmp(res->mode, "set")) {
5198 : :
5199 : 0 : if (!strcmp(res->hwsw, "hw"))
5200 : : hw = 1;
5201 : :
5202 : 0 : if (!strcmp(res->proto, "ip")) {
5203 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5204 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
5205 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
5206 : : } else {
5207 : 0 : fprintf(stderr,
5208 : : "IP checksum offload is not supported by port %u\n",
5209 : 0 : res->port_id);
5210 : : }
5211 : 0 : } else if (!strcmp(res->proto, "udp")) {
5212 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5213 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
5214 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
5215 : : } else {
5216 : 0 : fprintf(stderr,
5217 : : "UDP checksum offload is not supported by port %u\n",
5218 : 0 : res->port_id);
5219 : : }
5220 : 0 : } else if (!strcmp(res->proto, "tcp")) {
5221 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5222 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
5223 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
5224 : : } else {
5225 : 0 : fprintf(stderr,
5226 : : "TCP checksum offload is not supported by port %u\n",
5227 : 0 : res->port_id);
5228 : : }
5229 : 0 : } else if (!strcmp(res->proto, "sctp")) {
5230 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5231 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
5232 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
5233 : : } else {
5234 : 0 : fprintf(stderr,
5235 : : "SCTP checksum offload is not supported by port %u\n",
5236 : 0 : res->port_id);
5237 : : }
5238 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
5239 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5240 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5241 : : csum_offloads |=
5242 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
5243 : : } else {
5244 : 0 : fprintf(stderr,
5245 : : "Outer IP checksum offload is not supported by port %u\n",
5246 : 0 : res->port_id);
5247 : : }
5248 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
5249 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
5250 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
5251 : : csum_offloads |=
5252 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
5253 : : } else {
5254 : 0 : fprintf(stderr,
5255 : : "Outer UDP checksum offload is not supported by port %u\n",
5256 : 0 : res->port_id);
5257 : : }
5258 : : }
5259 : :
5260 : 0 : if (hw) {
5261 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5262 : : csum_offloads;
5263 : : } else {
5264 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5265 : 0 : (~csum_offloads);
5266 : : }
5267 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5268 : : }
5269 : 0 : csum_show(res->port_id);
5270 : :
5271 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5272 : : }
5273 : :
5274 : : static cmdline_parse_token_string_t cmd_csum_csum =
5275 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5276 : : csum, "csum");
5277 : : static cmdline_parse_token_string_t cmd_csum_mode =
5278 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5279 : : mode, "set");
5280 : : static cmdline_parse_token_string_t cmd_csum_proto =
5281 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5282 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
5283 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
5284 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5285 : : hwsw, "hw#sw");
5286 : : static cmdline_parse_token_num_t cmd_csum_portid =
5287 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
5288 : : port_id, RTE_UINT16);
5289 : :
5290 : : static cmdline_parse_inst_t cmd_csum_set = {
5291 : : .f = cmd_csum_parsed,
5292 : : .data = NULL,
5293 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
5294 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
5295 : : "using csum forward engine",
5296 : : .tokens = {
5297 : : (void *)&cmd_csum_csum,
5298 : : (void *)&cmd_csum_mode,
5299 : : (void *)&cmd_csum_proto,
5300 : : (void *)&cmd_csum_hwsw,
5301 : : (void *)&cmd_csum_portid,
5302 : : NULL,
5303 : : },
5304 : : };
5305 : :
5306 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
5307 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
5308 : : mode, "show");
5309 : :
5310 : : static cmdline_parse_inst_t cmd_csum_show = {
5311 : : .f = cmd_csum_parsed,
5312 : : .data = NULL,
5313 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
5314 : : .tokens = {
5315 : : (void *)&cmd_csum_csum,
5316 : : (void *)&cmd_csum_mode_show,
5317 : : (void *)&cmd_csum_portid,
5318 : : NULL,
5319 : : },
5320 : : };
5321 : :
5322 : : /* Enable/disable tunnel parsing */
5323 : : struct cmd_csum_tunnel_result {
5324 : : cmdline_fixed_string_t csum;
5325 : : cmdline_fixed_string_t parse;
5326 : : cmdline_fixed_string_t onoff;
5327 : : portid_t port_id;
5328 : : };
5329 : :
5330 : : static void
5331 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
5332 : : __rte_unused struct cmdline *cl,
5333 : : __rte_unused void *data)
5334 : : {
5335 : : struct cmd_csum_tunnel_result *res = parsed_result;
5336 : :
5337 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5338 : : return;
5339 : :
5340 : 0 : if (!strcmp(res->onoff, "on"))
5341 : 0 : ports[res->port_id].parse_tunnel = 1;
5342 : : else
5343 : 0 : ports[res->port_id].parse_tunnel = 0;
5344 : :
5345 : 0 : csum_show(res->port_id);
5346 : : }
5347 : :
5348 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
5349 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5350 : : csum, "csum");
5351 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
5352 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5353 : : parse, "parse-tunnel");
5354 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
5355 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
5356 : : onoff, "on#off");
5357 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
5358 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
5359 : : port_id, RTE_UINT16);
5360 : :
5361 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
5362 : : .f = cmd_csum_tunnel_parsed,
5363 : : .data = NULL,
5364 : : .help_str = "csum parse-tunnel on|off <port_id>: "
5365 : : "Enable/Disable parsing of tunnels for csum engine",
5366 : : .tokens = {
5367 : : (void *)&cmd_csum_tunnel_csum,
5368 : : (void *)&cmd_csum_tunnel_parse,
5369 : : (void *)&cmd_csum_tunnel_onoff,
5370 : : (void *)&cmd_csum_tunnel_portid,
5371 : : NULL,
5372 : : },
5373 : : };
5374 : :
5375 : : struct cmd_csum_mac_swap_result {
5376 : : cmdline_fixed_string_t csum;
5377 : : cmdline_fixed_string_t parse;
5378 : : cmdline_fixed_string_t onoff;
5379 : : portid_t port_id;
5380 : : };
5381 : :
5382 : : static void
5383 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
5384 : : __rte_unused struct cmdline *cl,
5385 : : __rte_unused void *data)
5386 : : {
5387 : : struct cmd_csum_mac_swap_result *res = parsed_result;
5388 : :
5389 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5390 : : return;
5391 : 0 : if (strcmp(res->onoff, "on") == 0)
5392 : 0 : ports[res->port_id].fwd_mac_swap = 1;
5393 : : else
5394 : 0 : ports[res->port_id].fwd_mac_swap = 0;
5395 : : }
5396 : :
5397 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
5398 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5399 : : csum, "csum");
5400 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
5401 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5402 : : parse, "mac-swap");
5403 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
5404 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
5405 : : onoff, "on#off");
5406 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
5407 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
5408 : : port_id, RTE_UINT16);
5409 : :
5410 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
5411 : : .f = cmd_csum_mac_swap_parsed,
5412 : : .data = NULL,
5413 : : .help_str = "csum mac-swap on|off <port_id>: "
5414 : : "Enable/Disable forward mac address swap",
5415 : : .tokens = {
5416 : : (void *)&cmd_csum_mac_swap_csum,
5417 : : (void *)&cmd_csum_mac_swap_parse,
5418 : : (void *)&cmd_csum_mac_swap_onoff,
5419 : : (void *)&cmd_csum_mac_swap_portid,
5420 : : NULL,
5421 : : },
5422 : : };
5423 : :
5424 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5425 : : struct cmd_tso_set_result {
5426 : : cmdline_fixed_string_t tso;
5427 : : cmdline_fixed_string_t mode;
5428 : : uint16_t tso_segsz;
5429 : : portid_t port_id;
5430 : : };
5431 : :
5432 : : static void
5433 : 0 : cmd_tso_set_parsed(void *parsed_result,
5434 : : __rte_unused struct cmdline *cl,
5435 : : __rte_unused void *data)
5436 : : {
5437 : : struct cmd_tso_set_result *res = parsed_result;
5438 : : struct rte_eth_dev_info dev_info;
5439 : : uint64_t offloads;
5440 : : int ret;
5441 : :
5442 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5443 : 0 : return;
5444 : 0 : if (!port_is_stopped(res->port_id)) {
5445 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5446 : 0 : return;
5447 : : }
5448 : :
5449 : 0 : if (!strcmp(res->mode, "set"))
5450 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5451 : :
5452 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5453 : 0 : if (ret != 0)
5454 : : return;
5455 : :
5456 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5457 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5458 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5459 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5460 : : res->port_id);
5461 : 0 : return;
5462 : : }
5463 : : /* display warnings if configuration is not supported by the NIC */
5464 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5465 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5466 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5467 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5468 : : }
5469 : :
5470 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5471 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5472 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5473 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5474 : : } else {
5475 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5476 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5477 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5478 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5479 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5480 : 0 : printf("segment size for non-tunneled packets is %d\n",
5481 : : ports[res->port_id].tso_segsz);
5482 : : }
5483 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5484 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5485 : : }
5486 : :
5487 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5488 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5489 : : tso, "tso");
5490 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5491 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5492 : : mode, "set");
5493 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5494 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5495 : : tso_segsz, RTE_UINT16);
5496 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5497 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5498 : : port_id, RTE_UINT16);
5499 : :
5500 : : static cmdline_parse_inst_t cmd_tso_set = {
5501 : : .f = cmd_tso_set_parsed,
5502 : : .data = NULL,
5503 : : .help_str = "tso set <tso_segsz> <port_id>: "
5504 : : "Set TSO segment size of non-tunneled packets for csum engine "
5505 : : "(0 to disable)",
5506 : : .tokens = {
5507 : : (void *)&cmd_tso_set_tso,
5508 : : (void *)&cmd_tso_set_mode,
5509 : : (void *)&cmd_tso_set_tso_segsz,
5510 : : (void *)&cmd_tso_set_portid,
5511 : : NULL,
5512 : : },
5513 : : };
5514 : :
5515 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5516 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5517 : : mode, "show");
5518 : :
5519 : :
5520 : : static cmdline_parse_inst_t cmd_tso_show = {
5521 : : .f = cmd_tso_set_parsed,
5522 : : .data = NULL,
5523 : : .help_str = "tso show <port_id>: "
5524 : : "Show TSO segment size of non-tunneled packets for csum engine",
5525 : : .tokens = {
5526 : : (void *)&cmd_tso_set_tso,
5527 : : (void *)&cmd_tso_show_mode,
5528 : : (void *)&cmd_tso_set_portid,
5529 : : NULL,
5530 : : },
5531 : : };
5532 : :
5533 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5534 : : struct cmd_tunnel_tso_set_result {
5535 : : cmdline_fixed_string_t tso;
5536 : : cmdline_fixed_string_t mode;
5537 : : uint16_t tso_segsz;
5538 : : portid_t port_id;
5539 : : };
5540 : :
5541 : : static void
5542 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5543 : : {
5544 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5545 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5546 : : port_id);
5547 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5548 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5549 : : port_id);
5550 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5551 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5552 : : port_id);
5553 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5554 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5555 : : port_id);
5556 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5557 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5558 : : port_id);
5559 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5560 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5561 : : port_id);
5562 : 0 : }
5563 : :
5564 : : static void
5565 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5566 : : __rte_unused struct cmdline *cl,
5567 : : __rte_unused void *data)
5568 : : {
5569 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5570 : : struct rte_eth_dev_info dev_info;
5571 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5572 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5573 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5574 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5575 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5576 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5577 : : int ret;
5578 : :
5579 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5580 : 0 : return;
5581 : 0 : if (!port_is_stopped(res->port_id)) {
5582 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5583 : 0 : return;
5584 : : }
5585 : :
5586 : 0 : if (!strcmp(res->mode, "set"))
5587 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5588 : :
5589 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5590 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5591 : : printf("TSO for tunneled packets is disabled\n");
5592 : : } else {
5593 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5594 : 0 : if (ret != 0)
5595 : : return;
5596 : :
5597 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5598 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5599 : 0 : res->port_id);
5600 : 0 : return;
5601 : : }
5602 : :
5603 : : /* Below conditions are needed to make it work:
5604 : : * (1) tunnel TSO is supported by the NIC;
5605 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5606 : : * are recognized;
5607 : : * (3) for tunneled pkts with outer L3 of IPv4,
5608 : : * "csum set outer-ip" must be set to hw, because after tso,
5609 : : * total_len of outer IP header is changed, and the checksum
5610 : : * of outer IP header calculated by sw should be wrong; that
5611 : : * is not necessary for IPv6 tunneled pkts because there's no
5612 : : * checksum in IP header anymore.
5613 : : */
5614 : 0 : if (!ports[res->port_id].parse_tunnel) {
5615 : 0 : fprintf(stderr,
5616 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5617 : 0 : return;
5618 : : }
5619 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5620 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5621 : 0 : fprintf(stderr,
5622 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5623 : 0 : return;
5624 : : }
5625 : :
5626 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5627 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5628 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5629 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5630 : 0 : ports[res->port_id].tunnel_tso_segsz);
5631 : : }
5632 : :
5633 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5634 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5635 : : }
5636 : :
5637 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5638 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5639 : : tso, "tunnel_tso");
5640 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5641 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5642 : : mode, "set");
5643 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5644 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5645 : : tso_segsz, RTE_UINT16);
5646 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5647 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5648 : : port_id, RTE_UINT16);
5649 : :
5650 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5651 : : .f = cmd_tunnel_tso_set_parsed,
5652 : : .data = NULL,
5653 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5654 : : "Set TSO segment size of tunneled packets for csum engine "
5655 : : "(0 to disable)",
5656 : : .tokens = {
5657 : : (void *)&cmd_tunnel_tso_set_tso,
5658 : : (void *)&cmd_tunnel_tso_set_mode,
5659 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5660 : : (void *)&cmd_tunnel_tso_set_portid,
5661 : : NULL,
5662 : : },
5663 : : };
5664 : :
5665 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5666 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5667 : : mode, "show");
5668 : :
5669 : :
5670 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5671 : : .f = cmd_tunnel_tso_set_parsed,
5672 : : .data = NULL,
5673 : : .help_str = "tunnel_tso show <port_id> "
5674 : : "Show TSO segment size of tunneled packets for csum engine",
5675 : : .tokens = {
5676 : : (void *)&cmd_tunnel_tso_set_tso,
5677 : : (void *)&cmd_tunnel_tso_show_mode,
5678 : : (void *)&cmd_tunnel_tso_set_portid,
5679 : : NULL,
5680 : : },
5681 : : };
5682 : :
5683 : : #ifdef RTE_LIB_GRO
5684 : : /* *** SET GRO FOR A PORT *** */
5685 : : struct cmd_gro_enable_result {
5686 : : cmdline_fixed_string_t cmd_set;
5687 : : cmdline_fixed_string_t cmd_port;
5688 : : cmdline_fixed_string_t cmd_keyword;
5689 : : cmdline_fixed_string_t cmd_onoff;
5690 : : portid_t cmd_pid;
5691 : : };
5692 : :
5693 : : static void
5694 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5695 : : __rte_unused struct cmdline *cl,
5696 : : __rte_unused void *data)
5697 : : {
5698 : : struct cmd_gro_enable_result *res;
5699 : :
5700 : : res = parsed_result;
5701 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5702 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5703 : 0 : }
5704 : :
5705 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5706 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5707 : : cmd_set, "set");
5708 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5709 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5710 : : cmd_keyword, "port");
5711 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5712 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5713 : : cmd_pid, RTE_UINT16);
5714 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5715 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5716 : : cmd_keyword, "gro");
5717 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5718 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5719 : : cmd_onoff, "on#off");
5720 : :
5721 : : static cmdline_parse_inst_t cmd_gro_enable = {
5722 : : .f = cmd_gro_enable_parsed,
5723 : : .data = NULL,
5724 : : .help_str = "set port <port_id> gro on|off",
5725 : : .tokens = {
5726 : : (void *)&cmd_gro_enable_set,
5727 : : (void *)&cmd_gro_enable_port,
5728 : : (void *)&cmd_gro_enable_pid,
5729 : : (void *)&cmd_gro_enable_keyword,
5730 : : (void *)&cmd_gro_enable_onoff,
5731 : : NULL,
5732 : : },
5733 : : };
5734 : :
5735 : : /* *** DISPLAY GRO CONFIGURATION *** */
5736 : : struct cmd_gro_show_result {
5737 : : cmdline_fixed_string_t cmd_show;
5738 : : cmdline_fixed_string_t cmd_port;
5739 : : cmdline_fixed_string_t cmd_keyword;
5740 : : portid_t cmd_pid;
5741 : : };
5742 : :
5743 : : static void
5744 : 0 : cmd_gro_show_parsed(void *parsed_result,
5745 : : __rte_unused struct cmdline *cl,
5746 : : __rte_unused void *data)
5747 : : {
5748 : : struct cmd_gro_show_result *res;
5749 : :
5750 : : res = parsed_result;
5751 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5752 : 0 : show_gro(res->cmd_pid);
5753 : 0 : }
5754 : :
5755 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5756 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5757 : : cmd_show, "show");
5758 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5759 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5760 : : cmd_port, "port");
5761 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5762 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5763 : : cmd_pid, RTE_UINT16);
5764 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5765 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5766 : : cmd_keyword, "gro");
5767 : :
5768 : : static cmdline_parse_inst_t cmd_gro_show = {
5769 : : .f = cmd_gro_show_parsed,
5770 : : .data = NULL,
5771 : : .help_str = "show port <port_id> gro",
5772 : : .tokens = {
5773 : : (void *)&cmd_gro_show_show,
5774 : : (void *)&cmd_gro_show_port,
5775 : : (void *)&cmd_gro_show_pid,
5776 : : (void *)&cmd_gro_show_keyword,
5777 : : NULL,
5778 : : },
5779 : : };
5780 : :
5781 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5782 : : struct cmd_gro_flush_result {
5783 : : cmdline_fixed_string_t cmd_set;
5784 : : cmdline_fixed_string_t cmd_keyword;
5785 : : cmdline_fixed_string_t cmd_flush;
5786 : : uint8_t cmd_cycles;
5787 : : };
5788 : :
5789 : : static void
5790 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5791 : : __rte_unused struct cmdline *cl,
5792 : : __rte_unused void *data)
5793 : : {
5794 : : struct cmd_gro_flush_result *res;
5795 : :
5796 : : res = parsed_result;
5797 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5798 : 0 : (!strcmp(res->cmd_flush, "flush")))
5799 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5800 : 0 : }
5801 : :
5802 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5803 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5804 : : cmd_set, "set");
5805 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5806 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5807 : : cmd_keyword, "gro");
5808 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5809 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5810 : : cmd_flush, "flush");
5811 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5812 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5813 : : cmd_cycles, RTE_UINT8);
5814 : :
5815 : : static cmdline_parse_inst_t cmd_gro_flush = {
5816 : : .f = cmd_gro_flush_parsed,
5817 : : .data = NULL,
5818 : : .help_str = "set gro flush <cycles>",
5819 : : .tokens = {
5820 : : (void *)&cmd_gro_flush_set,
5821 : : (void *)&cmd_gro_flush_keyword,
5822 : : (void *)&cmd_gro_flush_flush,
5823 : : (void *)&cmd_gro_flush_cycles,
5824 : : NULL,
5825 : : },
5826 : : };
5827 : : #endif /* RTE_LIB_GRO */
5828 : :
5829 : : #ifdef RTE_LIB_GSO
5830 : : /* *** ENABLE/DISABLE GSO *** */
5831 : : struct cmd_gso_enable_result {
5832 : : cmdline_fixed_string_t cmd_set;
5833 : : cmdline_fixed_string_t cmd_port;
5834 : : cmdline_fixed_string_t cmd_keyword;
5835 : : cmdline_fixed_string_t cmd_mode;
5836 : : portid_t cmd_pid;
5837 : : };
5838 : :
5839 : : static void
5840 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5841 : : __rte_unused struct cmdline *cl,
5842 : : __rte_unused void *data)
5843 : : {
5844 : : struct cmd_gso_enable_result *res;
5845 : :
5846 : : res = parsed_result;
5847 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5848 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5849 : 0 : }
5850 : :
5851 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5852 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5853 : : cmd_set, "set");
5854 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5855 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5856 : : cmd_port, "port");
5857 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5858 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5859 : : cmd_keyword, "gso");
5860 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5861 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5862 : : cmd_mode, "on#off");
5863 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5864 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5865 : : cmd_pid, RTE_UINT16);
5866 : :
5867 : : static cmdline_parse_inst_t cmd_gso_enable = {
5868 : : .f = cmd_gso_enable_parsed,
5869 : : .data = NULL,
5870 : : .help_str = "set port <port_id> gso on|off",
5871 : : .tokens = {
5872 : : (void *)&cmd_gso_enable_set,
5873 : : (void *)&cmd_gso_enable_port,
5874 : : (void *)&cmd_gso_enable_pid,
5875 : : (void *)&cmd_gso_enable_keyword,
5876 : : (void *)&cmd_gso_enable_mode,
5877 : : NULL,
5878 : : },
5879 : : };
5880 : :
5881 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5882 : : struct cmd_gso_size_result {
5883 : : cmdline_fixed_string_t cmd_set;
5884 : : cmdline_fixed_string_t cmd_keyword;
5885 : : cmdline_fixed_string_t cmd_segsz;
5886 : : uint16_t cmd_size;
5887 : : };
5888 : :
5889 : : static void
5890 : 0 : cmd_gso_size_parsed(void *parsed_result,
5891 : : __rte_unused struct cmdline *cl,
5892 : : __rte_unused void *data)
5893 : : {
5894 : : struct cmd_gso_size_result *res = parsed_result;
5895 : :
5896 : 0 : if (test_done == 0) {
5897 : 0 : fprintf(stderr,
5898 : : "Before setting GSO segsz, please first stop forwarding\n");
5899 : 0 : return;
5900 : : }
5901 : :
5902 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5903 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5904 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5905 : 0 : fprintf(stderr,
5906 : : "gso_size should be larger than %zu. Please input a legal value\n",
5907 : : RTE_GSO_SEG_SIZE_MIN);
5908 : : else
5909 : 0 : gso_max_segment_size = res->cmd_size;
5910 : : }
5911 : : }
5912 : :
5913 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5914 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5915 : : cmd_set, "set");
5916 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5917 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5918 : : cmd_keyword, "gso");
5919 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5920 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5921 : : cmd_segsz, "segsz");
5922 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5923 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5924 : : cmd_size, RTE_UINT16);
5925 : :
5926 : : static cmdline_parse_inst_t cmd_gso_size = {
5927 : : .f = cmd_gso_size_parsed,
5928 : : .data = NULL,
5929 : : .help_str = "set gso segsz <length>",
5930 : : .tokens = {
5931 : : (void *)&cmd_gso_size_set,
5932 : : (void *)&cmd_gso_size_keyword,
5933 : : (void *)&cmd_gso_size_segsz,
5934 : : (void *)&cmd_gso_size_size,
5935 : : NULL,
5936 : : },
5937 : : };
5938 : :
5939 : : /* *** SHOW GSO CONFIGURATION *** */
5940 : : struct cmd_gso_show_result {
5941 : : cmdline_fixed_string_t cmd_show;
5942 : : cmdline_fixed_string_t cmd_port;
5943 : : cmdline_fixed_string_t cmd_keyword;
5944 : : portid_t cmd_pid;
5945 : : };
5946 : :
5947 : : static void
5948 : 0 : cmd_gso_show_parsed(void *parsed_result,
5949 : : __rte_unused struct cmdline *cl,
5950 : : __rte_unused void *data)
5951 : : {
5952 : : struct cmd_gso_show_result *res = parsed_result;
5953 : :
5954 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5955 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5956 : 0 : return;
5957 : : }
5958 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
5959 : 0 : if (gso_ports[res->cmd_pid].enable) {
5960 : 0 : printf("Max GSO'd packet size: %uB\n"
5961 : : "Supported GSO types: TCP/IPv4, "
5962 : : "UDP/IPv4, VxLAN with inner "
5963 : : "TCP/IPv4 packet, GRE with inner "
5964 : : "TCP/IPv4 packet\n",
5965 : : gso_max_segment_size);
5966 : : } else
5967 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5968 : : }
5969 : : }
5970 : :
5971 : : static cmdline_parse_token_string_t cmd_gso_show_show =
5972 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5973 : : cmd_show, "show");
5974 : : static cmdline_parse_token_string_t cmd_gso_show_port =
5975 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5976 : : cmd_port, "port");
5977 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
5978 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5979 : : cmd_keyword, "gso");
5980 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
5981 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5982 : : cmd_pid, RTE_UINT16);
5983 : :
5984 : : static cmdline_parse_inst_t cmd_gso_show = {
5985 : : .f = cmd_gso_show_parsed,
5986 : : .data = NULL,
5987 : : .help_str = "show port <port_id> gso",
5988 : : .tokens = {
5989 : : (void *)&cmd_gso_show_show,
5990 : : (void *)&cmd_gso_show_port,
5991 : : (void *)&cmd_gso_show_pid,
5992 : : (void *)&cmd_gso_show_keyword,
5993 : : NULL,
5994 : : },
5995 : : };
5996 : : #endif /* RTE_LIB_GSO */
5997 : :
5998 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5999 : : struct cmd_set_flush_rx {
6000 : : cmdline_fixed_string_t set;
6001 : : cmdline_fixed_string_t flush_rx;
6002 : : cmdline_fixed_string_t mode;
6003 : : };
6004 : :
6005 : : static void
6006 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
6007 : : __rte_unused struct cmdline *cl,
6008 : : __rte_unused void *data)
6009 : : {
6010 : : struct cmd_set_flush_rx *res = parsed_result;
6011 : :
6012 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
6013 : : printf("multi-process doesn't support to flush Rx queues.\n");
6014 : 0 : return;
6015 : : }
6016 : :
6017 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6018 : : }
6019 : :
6020 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
6021 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6022 : : set, "set");
6023 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
6024 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6025 : : flush_rx, "flush_rx");
6026 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
6027 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
6028 : : mode, "on#off");
6029 : :
6030 : :
6031 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
6032 : : .f = cmd_set_flush_rx_parsed,
6033 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
6034 : : .data = NULL,
6035 : : .tokens = {
6036 : : (void *)&cmd_setflushrx_set,
6037 : : (void *)&cmd_setflushrx_flush_rx,
6038 : : (void *)&cmd_setflushrx_mode,
6039 : : NULL,
6040 : : },
6041 : : };
6042 : :
6043 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
6044 : : struct cmd_set_link_check {
6045 : : cmdline_fixed_string_t set;
6046 : : cmdline_fixed_string_t link_check;
6047 : : cmdline_fixed_string_t mode;
6048 : : };
6049 : :
6050 : : static void
6051 : 0 : cmd_set_link_check_parsed(void *parsed_result,
6052 : : __rte_unused struct cmdline *cl,
6053 : : __rte_unused void *data)
6054 : : {
6055 : : struct cmd_set_link_check *res = parsed_result;
6056 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
6057 : 0 : }
6058 : :
6059 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
6060 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6061 : : set, "set");
6062 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
6063 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6064 : : link_check, "link_check");
6065 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
6066 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
6067 : : mode, "on#off");
6068 : :
6069 : :
6070 : : static cmdline_parse_inst_t cmd_set_link_check = {
6071 : : .f = cmd_set_link_check_parsed,
6072 : : .help_str = "set link_check on|off: Enable/Disable link status check "
6073 : : "when starting/stopping a port",
6074 : : .data = NULL,
6075 : : .tokens = {
6076 : : (void *)&cmd_setlinkcheck_set,
6077 : : (void *)&cmd_setlinkcheck_link_check,
6078 : : (void *)&cmd_setlinkcheck_mode,
6079 : : NULL,
6080 : : },
6081 : : };
6082 : :
6083 : : /* *** SET FORWARDING MODE *** */
6084 : : struct cmd_set_fwd_mode_result {
6085 : : cmdline_fixed_string_t set;
6086 : : cmdline_fixed_string_t fwd;
6087 : : cmdline_fixed_string_t mode;
6088 : : };
6089 : :
6090 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
6091 : : __rte_unused struct cmdline *cl,
6092 : : __rte_unused void *data)
6093 : : {
6094 : : struct cmd_set_fwd_mode_result *res = parsed_result;
6095 : :
6096 : 0 : retry_enabled = 0;
6097 : 0 : set_pkt_forwarding_mode(res->mode);
6098 : 0 : }
6099 : :
6100 : : static cmdline_parse_token_string_t cmd_setfwd_set =
6101 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
6102 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
6103 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
6104 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
6105 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
6106 : : "" /* defined at init */);
6107 : :
6108 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
6109 : : .f = cmd_set_fwd_mode_parsed,
6110 : : .data = NULL,
6111 : : .help_str = NULL, /* defined at init */
6112 : : .tokens = {
6113 : : (void *)&cmd_setfwd_set,
6114 : : (void *)&cmd_setfwd_fwd,
6115 : : (void *)&cmd_setfwd_mode,
6116 : : NULL,
6117 : : },
6118 : : };
6119 : :
6120 : 0 : static void cmd_set_fwd_mode_init(void)
6121 : : {
6122 : : char *modes, *c;
6123 : : static char token[128];
6124 : : static char help[256];
6125 : : cmdline_parse_token_string_t *token_struct;
6126 : :
6127 : 0 : modes = list_pkt_forwarding_modes();
6128 : : snprintf(help, sizeof(help), "set fwd %s: "
6129 : : "Set packet forwarding mode", modes);
6130 : 0 : cmd_set_fwd_mode.help_str = help;
6131 : :
6132 : : /* string token separator is # */
6133 : 0 : for (c = token; *modes != '\0'; modes++)
6134 : 0 : if (*modes == '|')
6135 : 0 : *c++ = '#';
6136 : : else
6137 : 0 : *c++ = *modes;
6138 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
6139 : 0 : token_struct->string_data.str = token;
6140 : 0 : }
6141 : :
6142 : : /* *** SET RETRY FORWARDING MODE *** */
6143 : : struct cmd_set_fwd_retry_mode_result {
6144 : : cmdline_fixed_string_t set;
6145 : : cmdline_fixed_string_t fwd;
6146 : : cmdline_fixed_string_t mode;
6147 : : cmdline_fixed_string_t retry;
6148 : : };
6149 : :
6150 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
6151 : : __rte_unused struct cmdline *cl,
6152 : : __rte_unused void *data)
6153 : : {
6154 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
6155 : :
6156 : 0 : retry_enabled = 1;
6157 : 0 : set_pkt_forwarding_mode(res->mode);
6158 : 0 : }
6159 : :
6160 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
6161 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6162 : : set, "set");
6163 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
6164 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6165 : : fwd, "fwd");
6166 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
6167 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6168 : : mode,
6169 : : "" /* defined at init */);
6170 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
6171 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
6172 : : retry, "retry");
6173 : :
6174 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
6175 : : .f = cmd_set_fwd_retry_mode_parsed,
6176 : : .data = NULL,
6177 : : .help_str = NULL, /* defined at init */
6178 : : .tokens = {
6179 : : (void *)&cmd_setfwd_retry_set,
6180 : : (void *)&cmd_setfwd_retry_fwd,
6181 : : (void *)&cmd_setfwd_retry_mode,
6182 : : (void *)&cmd_setfwd_retry_retry,
6183 : : NULL,
6184 : : },
6185 : : };
6186 : :
6187 : 0 : static void cmd_set_fwd_retry_mode_init(void)
6188 : : {
6189 : : char *modes, *c;
6190 : : static char token[128];
6191 : : static char help[256];
6192 : : cmdline_parse_token_string_t *token_struct;
6193 : :
6194 : 0 : modes = list_pkt_forwarding_retry_modes();
6195 : : snprintf(help, sizeof(help), "set fwd %s retry: "
6196 : : "Set packet forwarding mode with retry", modes);
6197 : 0 : cmd_set_fwd_retry_mode.help_str = help;
6198 : :
6199 : : /* string token separator is # */
6200 : 0 : for (c = token; *modes != '\0'; modes++)
6201 : 0 : if (*modes == '|')
6202 : 0 : *c++ = '#';
6203 : : else
6204 : 0 : *c++ = *modes;
6205 : 0 : token_struct = (cmdline_parse_token_string_t *)
6206 : : cmd_set_fwd_retry_mode.tokens[2];
6207 : 0 : token_struct->string_data.str = token;
6208 : 0 : }
6209 : :
6210 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
6211 : : struct cmd_set_burst_tx_retry_result {
6212 : : cmdline_fixed_string_t set;
6213 : : cmdline_fixed_string_t burst;
6214 : : cmdline_fixed_string_t tx;
6215 : : cmdline_fixed_string_t delay;
6216 : : uint32_t time;
6217 : : cmdline_fixed_string_t retry;
6218 : : uint32_t retry_num;
6219 : : };
6220 : :
6221 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
6222 : : __rte_unused struct cmdline *cl,
6223 : : __rte_unused void *data)
6224 : : {
6225 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
6226 : :
6227 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
6228 : 0 : && !strcmp(res->tx, "tx")) {
6229 : 0 : if (!strcmp(res->delay, "delay"))
6230 : 0 : burst_tx_delay_time = res->time;
6231 : 0 : if (!strcmp(res->retry, "retry"))
6232 : 0 : burst_tx_retry_num = res->retry_num;
6233 : : }
6234 : :
6235 : 0 : }
6236 : :
6237 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
6238 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
6239 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
6240 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
6241 : : "burst");
6242 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
6243 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
6244 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
6245 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
6246 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
6247 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
6248 : : RTE_UINT32);
6249 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
6250 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
6251 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
6252 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
6253 : : RTE_UINT32);
6254 : :
6255 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
6256 : : .f = cmd_set_burst_tx_retry_parsed,
6257 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
6258 : : .tokens = {
6259 : : (void *)&cmd_set_burst_tx_retry_set,
6260 : : (void *)&cmd_set_burst_tx_retry_burst,
6261 : : (void *)&cmd_set_burst_tx_retry_tx,
6262 : : (void *)&cmd_set_burst_tx_retry_delay,
6263 : : (void *)&cmd_set_burst_tx_retry_time,
6264 : : (void *)&cmd_set_burst_tx_retry_retry,
6265 : : (void *)&cmd_set_burst_tx_retry_retry_num,
6266 : : NULL,
6267 : : },
6268 : : };
6269 : :
6270 : : /* *** SET PROMISC MODE *** */
6271 : : struct cmd_set_promisc_mode_result {
6272 : : cmdline_fixed_string_t set;
6273 : : cmdline_fixed_string_t promisc;
6274 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6275 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6276 : : cmdline_fixed_string_t mode;
6277 : : };
6278 : :
6279 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
6280 : : __rte_unused struct cmdline *cl,
6281 : : void *allports)
6282 : : {
6283 : : struct cmd_set_promisc_mode_result *res = parsed_result;
6284 : : int enable;
6285 : : portid_t i;
6286 : :
6287 : 0 : if (!strcmp(res->mode, "on"))
6288 : : enable = 1;
6289 : : else
6290 : : enable = 0;
6291 : :
6292 : : /* all ports */
6293 : 0 : if (allports) {
6294 : 0 : RTE_ETH_FOREACH_DEV(i)
6295 : 0 : eth_set_promisc_mode(i, enable);
6296 : : } else {
6297 : 0 : eth_set_promisc_mode(res->port_num, enable);
6298 : : }
6299 : 0 : }
6300 : :
6301 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
6302 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
6303 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
6304 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
6305 : : "promisc");
6306 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
6307 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
6308 : : "all");
6309 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
6310 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
6311 : : RTE_UINT16);
6312 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
6313 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
6314 : : "on#off");
6315 : :
6316 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
6317 : : .f = cmd_set_promisc_mode_parsed,
6318 : : .data = (void *)1,
6319 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
6320 : : .tokens = {
6321 : : (void *)&cmd_setpromisc_set,
6322 : : (void *)&cmd_setpromisc_promisc,
6323 : : (void *)&cmd_setpromisc_portall,
6324 : : (void *)&cmd_setpromisc_mode,
6325 : : NULL,
6326 : : },
6327 : : };
6328 : :
6329 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
6330 : : .f = cmd_set_promisc_mode_parsed,
6331 : : .data = (void *)0,
6332 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
6333 : : .tokens = {
6334 : : (void *)&cmd_setpromisc_set,
6335 : : (void *)&cmd_setpromisc_promisc,
6336 : : (void *)&cmd_setpromisc_portnum,
6337 : : (void *)&cmd_setpromisc_mode,
6338 : : NULL,
6339 : : },
6340 : : };
6341 : :
6342 : : /* *** SET ALLMULTI MODE *** */
6343 : : struct cmd_set_allmulti_mode_result {
6344 : : cmdline_fixed_string_t set;
6345 : : cmdline_fixed_string_t allmulti;
6346 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
6347 : : uint16_t port_num; /* valid if "allports" argument == 0 */
6348 : : cmdline_fixed_string_t mode;
6349 : : };
6350 : :
6351 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
6352 : : __rte_unused struct cmdline *cl,
6353 : : void *allports)
6354 : : {
6355 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
6356 : : int enable;
6357 : : portid_t i;
6358 : :
6359 : 0 : if (!strcmp(res->mode, "on"))
6360 : : enable = 1;
6361 : : else
6362 : : enable = 0;
6363 : :
6364 : : /* all ports */
6365 : 0 : if (allports) {
6366 : 0 : RTE_ETH_FOREACH_DEV(i) {
6367 : 0 : eth_set_allmulticast_mode(i, enable);
6368 : : }
6369 : : }
6370 : : else {
6371 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
6372 : : }
6373 : 0 : }
6374 : :
6375 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
6376 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
6377 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
6378 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
6379 : : "allmulti");
6380 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
6381 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
6382 : : "all");
6383 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
6384 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
6385 : : RTE_UINT16);
6386 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
6387 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
6388 : : "on#off");
6389 : :
6390 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
6391 : : .f = cmd_set_allmulti_mode_parsed,
6392 : : .data = (void *)1,
6393 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
6394 : : .tokens = {
6395 : : (void *)&cmd_setallmulti_set,
6396 : : (void *)&cmd_setallmulti_allmulti,
6397 : : (void *)&cmd_setallmulti_portall,
6398 : : (void *)&cmd_setallmulti_mode,
6399 : : NULL,
6400 : : },
6401 : : };
6402 : :
6403 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
6404 : : .f = cmd_set_allmulti_mode_parsed,
6405 : : .data = (void *)0,
6406 : : .help_str = "set allmulti <port_id> on|off: "
6407 : : "Set allmulti mode on port_id",
6408 : : .tokens = {
6409 : : (void *)&cmd_setallmulti_set,
6410 : : (void *)&cmd_setallmulti_allmulti,
6411 : : (void *)&cmd_setallmulti_portnum,
6412 : : (void *)&cmd_setallmulti_mode,
6413 : : NULL,
6414 : : },
6415 : : };
6416 : :
6417 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6418 : : struct cmd_link_flow_ctrl_show {
6419 : : cmdline_fixed_string_t show;
6420 : : cmdline_fixed_string_t port;
6421 : : portid_t port_id;
6422 : : cmdline_fixed_string_t flow_ctrl;
6423 : : };
6424 : :
6425 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6426 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6427 : : show, "show");
6428 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6429 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6430 : : port, "port");
6431 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6432 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6433 : : port_id, RTE_UINT16);
6434 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6435 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6436 : : flow_ctrl, "flow_ctrl");
6437 : :
6438 : : static void
6439 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6440 : : __rte_unused struct cmdline *cl,
6441 : : __rte_unused void *data)
6442 : : {
6443 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6444 : : static const char *info_border = "*********************";
6445 : : struct rte_eth_fc_conf fc_conf;
6446 : : bool rx_fc_en = false;
6447 : : bool tx_fc_en = false;
6448 : : int ret;
6449 : :
6450 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6451 : 0 : if (ret != 0) {
6452 : 0 : fprintf(stderr,
6453 : : "Failed to get current flow ctrl information: err = %d\n",
6454 : : ret);
6455 : 0 : return;
6456 : : }
6457 : :
6458 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6459 : : rx_fc_en = true;
6460 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6461 : : tx_fc_en = true;
6462 : :
6463 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6464 : 0 : info_border, res->port_id, info_border);
6465 : : printf("FC mode:\n");
6466 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6467 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6468 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6469 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6470 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6471 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6472 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6473 : 0 : printf("Forward MAC control frames: %s\n",
6474 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6475 : 0 : printf("\n%s************** End ***********%s\n",
6476 : : info_border, info_border);
6477 : : }
6478 : :
6479 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6480 : : .f = cmd_link_flow_ctrl_show_parsed,
6481 : : .data = NULL,
6482 : : .help_str = "show port <port_id> flow_ctrl",
6483 : : .tokens = {
6484 : : (void *)&cmd_lfc_show_show,
6485 : : (void *)&cmd_lfc_show_port,
6486 : : (void *)&cmd_lfc_show_portid,
6487 : : (void *)&cmd_lfc_show_flow_ctrl,
6488 : : NULL,
6489 : : },
6490 : : };
6491 : :
6492 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6493 : : struct cmd_link_flow_ctrl_set_result {
6494 : : cmdline_fixed_string_t set;
6495 : : cmdline_fixed_string_t flow_ctrl;
6496 : : cmdline_fixed_string_t rx;
6497 : : cmdline_fixed_string_t rx_lfc_mode;
6498 : : cmdline_fixed_string_t tx;
6499 : : cmdline_fixed_string_t tx_lfc_mode;
6500 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6501 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6502 : : cmdline_fixed_string_t autoneg_str;
6503 : : cmdline_fixed_string_t autoneg;
6504 : : cmdline_fixed_string_t hw_str;
6505 : : uint32_t high_water;
6506 : : cmdline_fixed_string_t lw_str;
6507 : : uint32_t low_water;
6508 : : cmdline_fixed_string_t pt_str;
6509 : : uint16_t pause_time;
6510 : : cmdline_fixed_string_t xon_str;
6511 : : uint16_t send_xon;
6512 : : portid_t port_id;
6513 : : };
6514 : :
6515 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6516 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6517 : : set, "set");
6518 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6519 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6520 : : flow_ctrl, "flow_ctrl");
6521 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6522 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6523 : : rx, "rx");
6524 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6525 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6526 : : rx_lfc_mode, "on#off");
6527 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6528 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6529 : : tx, "tx");
6530 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6531 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6532 : : tx_lfc_mode, "on#off");
6533 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6534 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6535 : : hw_str, "high_water");
6536 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6537 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6538 : : high_water, RTE_UINT32);
6539 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6540 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6541 : : lw_str, "low_water");
6542 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6543 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6544 : : low_water, RTE_UINT32);
6545 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6546 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6547 : : pt_str, "pause_time");
6548 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6549 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6550 : : pause_time, RTE_UINT16);
6551 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6552 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6553 : : xon_str, "send_xon");
6554 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6555 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6556 : : send_xon, RTE_UINT16);
6557 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6558 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6559 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6560 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6561 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6562 : : mac_ctrl_frame_fwd_mode, "on#off");
6563 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6564 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6565 : : autoneg_str, "autoneg");
6566 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6567 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6568 : : autoneg, "on#off");
6569 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6570 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6571 : : port_id, RTE_UINT16);
6572 : :
6573 : : /* forward declaration */
6574 : : static void
6575 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6576 : : void *data);
6577 : :
6578 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6579 : : .f = cmd_link_flow_ctrl_set_parsed,
6580 : : .data = NULL,
6581 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6582 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6583 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6584 : : .tokens = {
6585 : : (void *)&cmd_lfc_set_set,
6586 : : (void *)&cmd_lfc_set_flow_ctrl,
6587 : : (void *)&cmd_lfc_set_rx,
6588 : : (void *)&cmd_lfc_set_rx_mode,
6589 : : (void *)&cmd_lfc_set_tx,
6590 : : (void *)&cmd_lfc_set_tx_mode,
6591 : : (void *)&cmd_lfc_set_high_water,
6592 : : (void *)&cmd_lfc_set_low_water,
6593 : : (void *)&cmd_lfc_set_pause_time,
6594 : : (void *)&cmd_lfc_set_send_xon,
6595 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6596 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6597 : : (void *)&cmd_lfc_set_autoneg_str,
6598 : : (void *)&cmd_lfc_set_autoneg,
6599 : : (void *)&cmd_lfc_set_portid,
6600 : : NULL,
6601 : : },
6602 : : };
6603 : :
6604 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6605 : : .f = cmd_link_flow_ctrl_set_parsed,
6606 : : .data = (void *)&cmd_link_flow_control_set_rx,
6607 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6608 : : "Change rx flow control parameter",
6609 : : .tokens = {
6610 : : (void *)&cmd_lfc_set_set,
6611 : : (void *)&cmd_lfc_set_flow_ctrl,
6612 : : (void *)&cmd_lfc_set_rx,
6613 : : (void *)&cmd_lfc_set_rx_mode,
6614 : : (void *)&cmd_lfc_set_portid,
6615 : : NULL,
6616 : : },
6617 : : };
6618 : :
6619 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6620 : : .f = cmd_link_flow_ctrl_set_parsed,
6621 : : .data = (void *)&cmd_link_flow_control_set_tx,
6622 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6623 : : "Change tx flow control parameter",
6624 : : .tokens = {
6625 : : (void *)&cmd_lfc_set_set,
6626 : : (void *)&cmd_lfc_set_flow_ctrl,
6627 : : (void *)&cmd_lfc_set_tx,
6628 : : (void *)&cmd_lfc_set_tx_mode,
6629 : : (void *)&cmd_lfc_set_portid,
6630 : : NULL,
6631 : : },
6632 : : };
6633 : :
6634 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6635 : : .f = cmd_link_flow_ctrl_set_parsed,
6636 : : .data = (void *)&cmd_link_flow_control_set_hw,
6637 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6638 : : "Change high water flow control parameter",
6639 : : .tokens = {
6640 : : (void *)&cmd_lfc_set_set,
6641 : : (void *)&cmd_lfc_set_flow_ctrl,
6642 : : (void *)&cmd_lfc_set_high_water_str,
6643 : : (void *)&cmd_lfc_set_high_water,
6644 : : (void *)&cmd_lfc_set_portid,
6645 : : NULL,
6646 : : },
6647 : : };
6648 : :
6649 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6650 : : .f = cmd_link_flow_ctrl_set_parsed,
6651 : : .data = (void *)&cmd_link_flow_control_set_lw,
6652 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6653 : : "Change low water flow control parameter",
6654 : : .tokens = {
6655 : : (void *)&cmd_lfc_set_set,
6656 : : (void *)&cmd_lfc_set_flow_ctrl,
6657 : : (void *)&cmd_lfc_set_low_water_str,
6658 : : (void *)&cmd_lfc_set_low_water,
6659 : : (void *)&cmd_lfc_set_portid,
6660 : : NULL,
6661 : : },
6662 : : };
6663 : :
6664 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6665 : : .f = cmd_link_flow_ctrl_set_parsed,
6666 : : .data = (void *)&cmd_link_flow_control_set_pt,
6667 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6668 : : "Change pause time flow control parameter",
6669 : : .tokens = {
6670 : : (void *)&cmd_lfc_set_set,
6671 : : (void *)&cmd_lfc_set_flow_ctrl,
6672 : : (void *)&cmd_lfc_set_pause_time_str,
6673 : : (void *)&cmd_lfc_set_pause_time,
6674 : : (void *)&cmd_lfc_set_portid,
6675 : : NULL,
6676 : : },
6677 : : };
6678 : :
6679 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6680 : : .f = cmd_link_flow_ctrl_set_parsed,
6681 : : .data = (void *)&cmd_link_flow_control_set_xon,
6682 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6683 : : "Change send_xon flow control parameter",
6684 : : .tokens = {
6685 : : (void *)&cmd_lfc_set_set,
6686 : : (void *)&cmd_lfc_set_flow_ctrl,
6687 : : (void *)&cmd_lfc_set_send_xon_str,
6688 : : (void *)&cmd_lfc_set_send_xon,
6689 : : (void *)&cmd_lfc_set_portid,
6690 : : NULL,
6691 : : },
6692 : : };
6693 : :
6694 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6695 : : .f = cmd_link_flow_ctrl_set_parsed,
6696 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6697 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6698 : : "Change mac ctrl fwd flow control parameter",
6699 : : .tokens = {
6700 : : (void *)&cmd_lfc_set_set,
6701 : : (void *)&cmd_lfc_set_flow_ctrl,
6702 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6703 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6704 : : (void *)&cmd_lfc_set_portid,
6705 : : NULL,
6706 : : },
6707 : : };
6708 : :
6709 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6710 : : .f = cmd_link_flow_ctrl_set_parsed,
6711 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6712 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6713 : : "Change autoneg flow control parameter",
6714 : : .tokens = {
6715 : : (void *)&cmd_lfc_set_set,
6716 : : (void *)&cmd_lfc_set_flow_ctrl,
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 void
6725 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6726 : : __rte_unused struct cmdline *cl,
6727 : : void *data)
6728 : : {
6729 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6730 : : cmdline_parse_inst_t *cmd = data;
6731 : : struct rte_eth_fc_conf fc_conf;
6732 : : int rx_fc_en = 0;
6733 : : int tx_fc_en = 0;
6734 : : int ret;
6735 : :
6736 : : /*
6737 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6738 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6739 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6740 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6741 : : */
6742 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6743 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6744 : : };
6745 : :
6746 : : /* Partial command line, retrieve current configuration */
6747 : 0 : if (cmd) {
6748 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6749 : 0 : if (ret != 0) {
6750 : 0 : fprintf(stderr,
6751 : : "cannot get current flow ctrl parameters, return code = %d\n",
6752 : : ret);
6753 : 0 : return;
6754 : : }
6755 : :
6756 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6757 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6758 : : rx_fc_en = 1;
6759 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6760 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6761 : : tx_fc_en = 1;
6762 : : }
6763 : :
6764 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6765 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6766 : :
6767 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6768 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6769 : :
6770 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6771 : :
6772 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6773 : 0 : fc_conf.high_water = res->high_water;
6774 : :
6775 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6776 : 0 : fc_conf.low_water = res->low_water;
6777 : :
6778 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6779 : 0 : fc_conf.pause_time = res->pause_time;
6780 : :
6781 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6782 : 0 : fc_conf.send_xon = res->send_xon;
6783 : :
6784 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6785 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6786 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6787 : : else
6788 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6789 : : }
6790 : :
6791 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6792 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6793 : :
6794 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6795 : 0 : if (ret != 0)
6796 : 0 : fprintf(stderr,
6797 : : "bad flow control parameter, return code = %d\n",
6798 : : ret);
6799 : : }
6800 : :
6801 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6802 : : struct cmd_priority_flow_ctrl_set_result {
6803 : : cmdline_fixed_string_t set;
6804 : : cmdline_fixed_string_t pfc_ctrl;
6805 : : cmdline_fixed_string_t rx;
6806 : : cmdline_fixed_string_t rx_pfc_mode;
6807 : : cmdline_fixed_string_t tx;
6808 : : cmdline_fixed_string_t tx_pfc_mode;
6809 : : uint32_t high_water;
6810 : : uint32_t low_water;
6811 : : uint16_t pause_time;
6812 : : uint8_t priority;
6813 : : portid_t port_id;
6814 : : };
6815 : :
6816 : : static void
6817 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6818 : : __rte_unused struct cmdline *cl,
6819 : : __rte_unused void *data)
6820 : : {
6821 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6822 : : struct rte_eth_pfc_conf pfc_conf;
6823 : : int rx_fc_enable, tx_fc_enable;
6824 : : int ret;
6825 : :
6826 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
6827 : 0 : return;
6828 : :
6829 : : /*
6830 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6831 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6832 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6833 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6834 : : */
6835 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6836 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6837 : : };
6838 : :
6839 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
6840 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6841 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6842 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6843 : 0 : pfc_conf.fc.high_water = res->high_water;
6844 : 0 : pfc_conf.fc.low_water = res->low_water;
6845 : 0 : pfc_conf.fc.pause_time = res->pause_time;
6846 : 0 : pfc_conf.priority = res->priority;
6847 : :
6848 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6849 : 0 : if (ret != 0)
6850 : 0 : fprintf(stderr,
6851 : : "bad priority flow control parameter, return code = %d\n",
6852 : : ret);
6853 : : }
6854 : :
6855 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
6856 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6857 : : set, "set");
6858 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6859 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6860 : : pfc_ctrl, "pfc_ctrl");
6861 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
6862 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6863 : : rx, "rx");
6864 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6865 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6866 : : rx_pfc_mode, "on#off");
6867 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
6868 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6869 : : tx, "tx");
6870 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6871 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6872 : : tx_pfc_mode, "on#off");
6873 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
6874 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6875 : : high_water, RTE_UINT32);
6876 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
6877 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6878 : : low_water, RTE_UINT32);
6879 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6880 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6881 : : pause_time, RTE_UINT16);
6882 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
6883 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6884 : : priority, RTE_UINT8);
6885 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
6886 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6887 : : port_id, RTE_UINT16);
6888 : :
6889 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
6890 : : .f = cmd_priority_flow_ctrl_set_parsed,
6891 : : .data = NULL,
6892 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6893 : : "<pause_time> <priority> <port_id>: "
6894 : : "Configure the Ethernet priority flow control",
6895 : : .tokens = {
6896 : : (void *)&cmd_pfc_set_set,
6897 : : (void *)&cmd_pfc_set_flow_ctrl,
6898 : : (void *)&cmd_pfc_set_rx,
6899 : : (void *)&cmd_pfc_set_rx_mode,
6900 : : (void *)&cmd_pfc_set_tx,
6901 : : (void *)&cmd_pfc_set_tx_mode,
6902 : : (void *)&cmd_pfc_set_high_water,
6903 : : (void *)&cmd_pfc_set_low_water,
6904 : : (void *)&cmd_pfc_set_pause_time,
6905 : : (void *)&cmd_pfc_set_priority,
6906 : : (void *)&cmd_pfc_set_portid,
6907 : : NULL,
6908 : : },
6909 : : };
6910 : :
6911 : : struct cmd_queue_priority_flow_ctrl_set_result {
6912 : : cmdline_fixed_string_t set;
6913 : : cmdline_fixed_string_t pfc_queue_ctrl;
6914 : : portid_t port_id;
6915 : : cmdline_fixed_string_t rx;
6916 : : cmdline_fixed_string_t rx_pfc_mode;
6917 : : uint16_t tx_qid;
6918 : : uint8_t tx_tc;
6919 : : cmdline_fixed_string_t tx;
6920 : : cmdline_fixed_string_t tx_pfc_mode;
6921 : : uint16_t rx_qid;
6922 : : uint8_t rx_tc;
6923 : : uint16_t pause_time;
6924 : : };
6925 : :
6926 : : static void
6927 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
6928 : : __rte_unused struct cmdline *cl,
6929 : : __rte_unused void *data)
6930 : : {
6931 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
6932 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
6933 : : int rx_fc_enable, tx_fc_enable;
6934 : : int ret;
6935 : :
6936 : : /*
6937 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
6938 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
6939 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
6940 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
6941 : : * the Tx side.
6942 : : */
6943 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
6944 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
6945 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6946 : : };
6947 : :
6948 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
6949 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
6950 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
6951 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
6952 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
6953 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
6954 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
6955 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
6956 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
6957 : :
6958 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
6959 : : &pfc_queue_conf);
6960 : 0 : if (ret != 0) {
6961 : 0 : fprintf(stderr,
6962 : : "bad queue priority flow control parameter, rc = %d\n",
6963 : : ret);
6964 : : }
6965 : 0 : }
6966 : :
6967 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
6968 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6969 : : set, "set");
6970 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
6971 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6972 : : pfc_queue_ctrl, "pfc_queue_ctrl");
6973 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
6974 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6975 : : port_id, RTE_UINT16);
6976 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
6977 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6978 : : rx, "rx");
6979 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
6980 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6981 : : rx_pfc_mode, "on#off");
6982 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
6983 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6984 : : tx_qid, RTE_UINT16);
6985 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
6986 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6987 : : tx_tc, RTE_UINT8);
6988 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
6989 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6990 : : tx, "tx");
6991 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
6992 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6993 : : tx_pfc_mode, "on#off");
6994 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
6995 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6996 : : rx_qid, RTE_UINT16);
6997 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
6998 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6999 : : rx_tc, RTE_UINT8);
7000 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
7001 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
7002 : : pause_time, RTE_UINT16);
7003 : :
7004 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
7005 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
7006 : : .data = NULL,
7007 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
7008 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
7009 : : "Configure the Ethernet queue priority flow control",
7010 : : .tokens = {
7011 : : (void *)&cmd_q_pfc_set_set,
7012 : : (void *)&cmd_q_pfc_set_flow_ctrl,
7013 : : (void *)&cmd_q_pfc_set_portid,
7014 : : (void *)&cmd_q_pfc_set_rx,
7015 : : (void *)&cmd_q_pfc_set_rx_mode,
7016 : : (void *)&cmd_q_pfc_set_tx_qid,
7017 : : (void *)&cmd_q_pfc_set_tx_tc,
7018 : : (void *)&cmd_q_pfc_set_tx,
7019 : : (void *)&cmd_q_pfc_set_tx_mode,
7020 : : (void *)&cmd_q_pfc_set_rx_qid,
7021 : : (void *)&cmd_q_pfc_set_rx_tc,
7022 : : (void *)&cmd_q_pfc_set_pause_time,
7023 : : NULL,
7024 : : },
7025 : : };
7026 : :
7027 : : /* *** RESET CONFIGURATION *** */
7028 : : struct cmd_reset_result {
7029 : : cmdline_fixed_string_t reset;
7030 : : cmdline_fixed_string_t def;
7031 : : };
7032 : :
7033 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
7034 : : struct cmdline *cl,
7035 : : __rte_unused void *data)
7036 : : {
7037 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
7038 : 0 : set_def_fwd_config();
7039 : 0 : }
7040 : :
7041 : : static cmdline_parse_token_string_t cmd_reset_set =
7042 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
7043 : : static cmdline_parse_token_string_t cmd_reset_def =
7044 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
7045 : : "default");
7046 : :
7047 : : static cmdline_parse_inst_t cmd_reset = {
7048 : : .f = cmd_reset_parsed,
7049 : : .data = NULL,
7050 : : .help_str = "set default: Reset default forwarding configuration",
7051 : : .tokens = {
7052 : : (void *)&cmd_reset_set,
7053 : : (void *)&cmd_reset_def,
7054 : : NULL,
7055 : : },
7056 : : };
7057 : :
7058 : : /* *** START FORWARDING *** */
7059 : : struct cmd_start_result {
7060 : : cmdline_fixed_string_t start;
7061 : : };
7062 : :
7063 : : static cmdline_parse_token_string_t cmd_start_start =
7064 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
7065 : :
7066 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
7067 : : __rte_unused struct cmdline *cl,
7068 : : __rte_unused void *data)
7069 : : {
7070 : 0 : start_packet_forwarding(0);
7071 : 0 : }
7072 : :
7073 : : static cmdline_parse_inst_t cmd_start = {
7074 : : .f = cmd_start_parsed,
7075 : : .data = NULL,
7076 : : .help_str = "start: Start packet forwarding",
7077 : : .tokens = {
7078 : : (void *)&cmd_start_start,
7079 : : NULL,
7080 : : },
7081 : : };
7082 : :
7083 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
7084 : : struct cmd_start_tx_first_result {
7085 : : cmdline_fixed_string_t start;
7086 : : cmdline_fixed_string_t tx_first;
7087 : : };
7088 : :
7089 : : static void
7090 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
7091 : : __rte_unused struct cmdline *cl,
7092 : : __rte_unused void *data)
7093 : : {
7094 : 0 : start_packet_forwarding(1);
7095 : 0 : }
7096 : :
7097 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
7098 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
7099 : : "start");
7100 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
7101 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
7102 : : tx_first, "tx_first");
7103 : :
7104 : : static cmdline_parse_inst_t cmd_start_tx_first = {
7105 : : .f = cmd_start_tx_first_parsed,
7106 : : .data = NULL,
7107 : : .help_str = "start tx_first: Start packet forwarding, "
7108 : : "after sending 1 burst of packets",
7109 : : .tokens = {
7110 : : (void *)&cmd_start_tx_first_start,
7111 : : (void *)&cmd_start_tx_first_tx_first,
7112 : : NULL,
7113 : : },
7114 : : };
7115 : :
7116 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
7117 : : struct cmd_start_tx_first_n_result {
7118 : : cmdline_fixed_string_t start;
7119 : : cmdline_fixed_string_t tx_first;
7120 : : uint32_t tx_num;
7121 : : };
7122 : :
7123 : : static void
7124 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
7125 : : __rte_unused struct cmdline *cl,
7126 : : __rte_unused void *data)
7127 : : {
7128 : : struct cmd_start_tx_first_n_result *res = parsed_result;
7129 : :
7130 : 0 : start_packet_forwarding(res->tx_num);
7131 : 0 : }
7132 : :
7133 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
7134 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7135 : : start, "start");
7136 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
7137 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
7138 : : tx_first, "tx_first");
7139 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
7140 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
7141 : : tx_num, RTE_UINT32);
7142 : :
7143 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
7144 : : .f = cmd_start_tx_first_n_parsed,
7145 : : .data = NULL,
7146 : : .help_str = "start tx_first <num>: "
7147 : : "packet forwarding, after sending <num> bursts of packets",
7148 : : .tokens = {
7149 : : (void *)&cmd_start_tx_first_n_start,
7150 : : (void *)&cmd_start_tx_first_n_tx_first,
7151 : : (void *)&cmd_start_tx_first_n_tx_num,
7152 : : NULL,
7153 : : },
7154 : : };
7155 : :
7156 : : /* *** SET LINK UP *** */
7157 : : struct cmd_set_link_up_result {
7158 : : cmdline_fixed_string_t set;
7159 : : cmdline_fixed_string_t link_up;
7160 : : cmdline_fixed_string_t port;
7161 : : portid_t port_id;
7162 : : };
7163 : :
7164 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
7165 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
7166 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
7167 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
7168 : : "link-up");
7169 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
7170 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
7171 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
7172 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
7173 : : RTE_UINT16);
7174 : :
7175 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
7176 : : __rte_unused struct cmdline *cl,
7177 : : __rte_unused void *data)
7178 : : {
7179 : : struct cmd_set_link_up_result *res = parsed_result;
7180 : 0 : dev_set_link_up(res->port_id);
7181 : 0 : }
7182 : :
7183 : : static cmdline_parse_inst_t cmd_set_link_up = {
7184 : : .f = cmd_set_link_up_parsed,
7185 : : .data = NULL,
7186 : : .help_str = "set link-up port <port id>",
7187 : : .tokens = {
7188 : : (void *)&cmd_set_link_up_set,
7189 : : (void *)&cmd_set_link_up_link_up,
7190 : : (void *)&cmd_set_link_up_port,
7191 : : (void *)&cmd_set_link_up_port_id,
7192 : : NULL,
7193 : : },
7194 : : };
7195 : :
7196 : : /* *** SET LINK DOWN *** */
7197 : : struct cmd_set_link_down_result {
7198 : : cmdline_fixed_string_t set;
7199 : : cmdline_fixed_string_t link_down;
7200 : : cmdline_fixed_string_t port;
7201 : : portid_t port_id;
7202 : : };
7203 : :
7204 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
7205 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
7206 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
7207 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
7208 : : "link-down");
7209 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
7210 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
7211 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
7212 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
7213 : : RTE_UINT16);
7214 : :
7215 : 0 : static void cmd_set_link_down_parsed(
7216 : : __rte_unused void *parsed_result,
7217 : : __rte_unused struct cmdline *cl,
7218 : : __rte_unused void *data)
7219 : : {
7220 : : struct cmd_set_link_down_result *res = parsed_result;
7221 : 0 : dev_set_link_down(res->port_id);
7222 : 0 : }
7223 : :
7224 : : static cmdline_parse_inst_t cmd_set_link_down = {
7225 : : .f = cmd_set_link_down_parsed,
7226 : : .data = NULL,
7227 : : .help_str = "set link-down port <port id>",
7228 : : .tokens = {
7229 : : (void *)&cmd_set_link_down_set,
7230 : : (void *)&cmd_set_link_down_link_down,
7231 : : (void *)&cmd_set_link_down_port,
7232 : : (void *)&cmd_set_link_down_port_id,
7233 : : NULL,
7234 : : },
7235 : : };
7236 : :
7237 : : /* *** SHOW CFG *** */
7238 : : struct cmd_showcfg_result {
7239 : : cmdline_fixed_string_t show;
7240 : : cmdline_fixed_string_t cfg;
7241 : : cmdline_fixed_string_t what;
7242 : : };
7243 : :
7244 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
7245 : : __rte_unused struct cmdline *cl,
7246 : : __rte_unused void *data)
7247 : : {
7248 : : struct cmd_showcfg_result *res = parsed_result;
7249 : 0 : if (!strcmp(res->what, "rxtx"))
7250 : 0 : rxtx_config_display();
7251 : 0 : else if (!strcmp(res->what, "cores"))
7252 : 0 : fwd_lcores_config_display();
7253 : 0 : else if (!strcmp(res->what, "fwd"))
7254 : 0 : pkt_fwd_config_display(&cur_fwd_config);
7255 : 0 : else if (!strcmp(res->what, "rxoffs"))
7256 : 0 : show_rx_pkt_offsets();
7257 : 0 : else if (!strcmp(res->what, "rxpkts"))
7258 : 0 : show_rx_pkt_segments();
7259 : 0 : else if (!strcmp(res->what, "rxhdrs"))
7260 : 0 : show_rx_pkt_hdrs();
7261 : 0 : else if (!strcmp(res->what, "txpkts"))
7262 : 0 : show_tx_pkt_segments();
7263 : 0 : else if (!strcmp(res->what, "txtimes"))
7264 : 0 : show_tx_pkt_times();
7265 : 0 : }
7266 : :
7267 : : static cmdline_parse_token_string_t cmd_showcfg_show =
7268 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
7269 : : static cmdline_parse_token_string_t cmd_showcfg_port =
7270 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
7271 : : static cmdline_parse_token_string_t cmd_showcfg_what =
7272 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
7273 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
7274 : :
7275 : : static cmdline_parse_inst_t cmd_showcfg = {
7276 : : .f = cmd_showcfg_parsed,
7277 : : .data = NULL,
7278 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
7279 : : .tokens = {
7280 : : (void *)&cmd_showcfg_show,
7281 : : (void *)&cmd_showcfg_port,
7282 : : (void *)&cmd_showcfg_what,
7283 : : NULL,
7284 : : },
7285 : : };
7286 : :
7287 : : /* *** SHOW ALL PORT INFO *** */
7288 : : struct cmd_showportall_result {
7289 : : cmdline_fixed_string_t show;
7290 : : cmdline_fixed_string_t port;
7291 : : cmdline_fixed_string_t what;
7292 : : cmdline_fixed_string_t all;
7293 : : };
7294 : :
7295 : 0 : static void cmd_showportall_parsed(void *parsed_result,
7296 : : __rte_unused struct cmdline *cl,
7297 : : __rte_unused void *data)
7298 : : {
7299 : : portid_t i;
7300 : :
7301 : : struct cmd_showportall_result *res = parsed_result;
7302 : 0 : if (!strcmp(res->show, "clear")) {
7303 : 0 : if (!strcmp(res->what, "stats"))
7304 : 0 : RTE_ETH_FOREACH_DEV(i)
7305 : 0 : nic_stats_clear(i);
7306 : 0 : else if (!strcmp(res->what, "xstats"))
7307 : 0 : RTE_ETH_FOREACH_DEV(i)
7308 : 0 : nic_xstats_clear(i);
7309 : 0 : } else if (!strcmp(res->what, "info"))
7310 : 0 : RTE_ETH_FOREACH_DEV(i)
7311 : 0 : port_infos_display(i);
7312 : 0 : else if (!strcmp(res->what, "summary")) {
7313 : 0 : port_summary_header_display();
7314 : 0 : RTE_ETH_FOREACH_DEV(i)
7315 : 0 : port_summary_display(i);
7316 : : }
7317 : 0 : else if (!strcmp(res->what, "stats"))
7318 : 0 : RTE_ETH_FOREACH_DEV(i)
7319 : 0 : nic_stats_display(i);
7320 : 0 : else if (!strcmp(res->what, "xstats"))
7321 : 0 : RTE_ETH_FOREACH_DEV(i)
7322 : 0 : nic_xstats_display(i);
7323 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7324 : 0 : else if (!strcmp(res->what, "fdir"))
7325 : 0 : RTE_ETH_FOREACH_DEV(i)
7326 : 0 : fdir_get_infos(i);
7327 : : #endif
7328 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7329 : 0 : RTE_ETH_FOREACH_DEV(i)
7330 : 0 : port_dcb_info_display(i);
7331 : 0 : }
7332 : :
7333 : : static cmdline_parse_token_string_t cmd_showportall_show =
7334 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
7335 : : "show#clear");
7336 : : static cmdline_parse_token_string_t cmd_showportall_port =
7337 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
7338 : : static cmdline_parse_token_string_t cmd_showportall_what =
7339 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
7340 : : "info#summary#stats#xstats#fdir#dcb_tc");
7341 : : static cmdline_parse_token_string_t cmd_showportall_all =
7342 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
7343 : : static cmdline_parse_inst_t cmd_showportall = {
7344 : : .f = cmd_showportall_parsed,
7345 : : .data = NULL,
7346 : : .help_str = "show|clear port "
7347 : : "info|summary|stats|xstats|fdir|dcb_tc all",
7348 : : .tokens = {
7349 : : (void *)&cmd_showportall_show,
7350 : : (void *)&cmd_showportall_port,
7351 : : (void *)&cmd_showportall_what,
7352 : : (void *)&cmd_showportall_all,
7353 : : NULL,
7354 : : },
7355 : : };
7356 : :
7357 : : /* *** SHOW PORT INFO *** */
7358 : : struct cmd_showport_result {
7359 : : cmdline_fixed_string_t show;
7360 : : cmdline_fixed_string_t port;
7361 : : cmdline_fixed_string_t what;
7362 : : uint16_t portnum;
7363 : : };
7364 : :
7365 : 0 : static void cmd_showport_parsed(void *parsed_result,
7366 : : __rte_unused struct cmdline *cl,
7367 : : __rte_unused void *data)
7368 : : {
7369 : : struct cmd_showport_result *res = parsed_result;
7370 : 0 : if (!strcmp(res->show, "clear")) {
7371 : 0 : if (!strcmp(res->what, "stats"))
7372 : 0 : nic_stats_clear(res->portnum);
7373 : 0 : else if (!strcmp(res->what, "xstats"))
7374 : 0 : nic_xstats_clear(res->portnum);
7375 : 0 : } else if (!strcmp(res->what, "info"))
7376 : 0 : port_infos_display(res->portnum);
7377 : 0 : else if (!strcmp(res->what, "summary")) {
7378 : 0 : port_summary_header_display();
7379 : 0 : port_summary_display(res->portnum);
7380 : : }
7381 : 0 : else if (!strcmp(res->what, "stats"))
7382 : 0 : nic_stats_display(res->portnum);
7383 : 0 : else if (!strcmp(res->what, "xstats"))
7384 : 0 : nic_xstats_display(res->portnum);
7385 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
7386 : 0 : else if (!strcmp(res->what, "fdir"))
7387 : 0 : fdir_get_infos(res->portnum);
7388 : : #endif
7389 : 0 : else if (!strcmp(res->what, "dcb_tc"))
7390 : 0 : port_dcb_info_display(res->portnum);
7391 : 0 : }
7392 : :
7393 : : static cmdline_parse_token_string_t cmd_showport_show =
7394 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
7395 : : "show#clear");
7396 : : static cmdline_parse_token_string_t cmd_showport_port =
7397 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
7398 : : static cmdline_parse_token_string_t cmd_showport_what =
7399 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
7400 : : "info#summary#stats#xstats#fdir#dcb_tc");
7401 : : static cmdline_parse_token_num_t cmd_showport_portnum =
7402 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
7403 : :
7404 : : static cmdline_parse_inst_t cmd_showport = {
7405 : : .f = cmd_showport_parsed,
7406 : : .data = NULL,
7407 : : .help_str = "show|clear port "
7408 : : "info|summary|stats|xstats|fdir|dcb_tc "
7409 : : "<port_id>",
7410 : : .tokens = {
7411 : : (void *)&cmd_showport_show,
7412 : : (void *)&cmd_showport_port,
7413 : : (void *)&cmd_showport_what,
7414 : : (void *)&cmd_showport_portnum,
7415 : : NULL,
7416 : : },
7417 : : };
7418 : :
7419 : : /* *** show port representors information *** */
7420 : : struct cmd_representor_info_result {
7421 : : cmdline_fixed_string_t cmd_show;
7422 : : cmdline_fixed_string_t cmd_port;
7423 : : cmdline_fixed_string_t cmd_info;
7424 : : cmdline_fixed_string_t cmd_keyword;
7425 : : portid_t cmd_pid;
7426 : : };
7427 : :
7428 : : static void
7429 : 0 : cmd_representor_info_parsed(void *parsed_result,
7430 : : __rte_unused struct cmdline *cl,
7431 : : __rte_unused void *data)
7432 : : {
7433 : : struct cmd_representor_info_result *res = parsed_result;
7434 : : struct rte_eth_representor_info *info;
7435 : : struct rte_eth_representor_range *range;
7436 : : uint32_t range_diff;
7437 : : uint32_t i;
7438 : : int ret;
7439 : : int num;
7440 : :
7441 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7442 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7443 : 0 : return;
7444 : : }
7445 : :
7446 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7447 : 0 : if (ret < 0) {
7448 : 0 : fprintf(stderr,
7449 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7450 : 0 : res->cmd_pid, rte_strerror(-ret));
7451 : 0 : return;
7452 : : }
7453 : : num = ret;
7454 : :
7455 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7456 : 0 : if (info == NULL) {
7457 : 0 : fprintf(stderr,
7458 : : "Failed to allocate memory for representor info for port %hu\n",
7459 : 0 : res->cmd_pid);
7460 : 0 : return;
7461 : : }
7462 : 0 : info->nb_ranges_alloc = num;
7463 : :
7464 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7465 : 0 : if (ret < 0) {
7466 : 0 : fprintf(stderr,
7467 : : "Failed to get the representor info for port %hu: %s\n",
7468 : 0 : res->cmd_pid, rte_strerror(-ret));
7469 : 0 : free(info);
7470 : 0 : return;
7471 : : }
7472 : :
7473 : 0 : printf("Port controller: %hu\n", info->controller);
7474 : 0 : printf("Port PF: %hu\n", info->pf);
7475 : :
7476 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7477 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7478 : : range = &info->ranges[i];
7479 : 0 : range_diff = range->id_end - range->id_base;
7480 : :
7481 : 0 : printf("%u. ", i + 1);
7482 : 0 : printf("'%s' ", range->name);
7483 : 0 : if (range_diff > 0)
7484 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7485 : : else
7486 : 0 : printf("[%u]: ", range->id_base);
7487 : :
7488 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7489 : :
7490 : 0 : switch (range->type) {
7491 : : case RTE_ETH_REPRESENTOR_NONE:
7492 : : printf(", NONE\n");
7493 : : break;
7494 : 0 : case RTE_ETH_REPRESENTOR_VF:
7495 : 0 : if (range_diff > 0)
7496 : 0 : printf(", VF %d..%d\n", range->vf,
7497 : 0 : range->vf + range_diff);
7498 : : else
7499 : 0 : printf(", VF %d\n", range->vf);
7500 : : break;
7501 : 0 : case RTE_ETH_REPRESENTOR_SF:
7502 : 0 : printf(", SF %d\n", range->sf);
7503 : : break;
7504 : 0 : case RTE_ETH_REPRESENTOR_PF:
7505 : 0 : if (range_diff > 0)
7506 : 0 : printf("..%d\n", range->pf + range_diff);
7507 : : else
7508 : : printf("\n");
7509 : : break;
7510 : 0 : default:
7511 : : printf(", UNKNOWN TYPE %d\n", range->type);
7512 : : break;
7513 : : }
7514 : : }
7515 : :
7516 : 0 : free(info);
7517 : : }
7518 : :
7519 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7520 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7521 : : cmd_show, "show");
7522 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7523 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7524 : : cmd_port, "port");
7525 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7526 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7527 : : cmd_info, "info");
7528 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7529 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7530 : : cmd_pid, RTE_UINT16);
7531 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7532 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7533 : : cmd_keyword, "representor");
7534 : :
7535 : : static cmdline_parse_inst_t cmd_representor_info = {
7536 : : .f = cmd_representor_info_parsed,
7537 : : .data = NULL,
7538 : : .help_str = "show port info <port_id> representor",
7539 : : .tokens = {
7540 : : (void *)&cmd_representor_info_show,
7541 : : (void *)&cmd_representor_info_port,
7542 : : (void *)&cmd_representor_info_info,
7543 : : (void *)&cmd_representor_info_pid,
7544 : : (void *)&cmd_representor_info_keyword,
7545 : : NULL,
7546 : : },
7547 : : };
7548 : :
7549 : :
7550 : : /* *** SHOW DEVICE INFO *** */
7551 : : struct cmd_showdevice_result {
7552 : : cmdline_fixed_string_t show;
7553 : : cmdline_fixed_string_t device;
7554 : : cmdline_fixed_string_t what;
7555 : : cmdline_fixed_string_t identifier;
7556 : : };
7557 : :
7558 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7559 : : __rte_unused struct cmdline *cl,
7560 : : __rte_unused void *data)
7561 : : {
7562 : : struct cmd_showdevice_result *res = parsed_result;
7563 : 0 : if (!strcmp(res->what, "info")) {
7564 : 0 : if (!strcmp(res->identifier, "all"))
7565 : 0 : device_infos_display(NULL);
7566 : : else
7567 : 0 : device_infos_display(res->identifier);
7568 : : }
7569 : 0 : }
7570 : :
7571 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7572 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7573 : : "show");
7574 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7575 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7576 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7577 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7578 : : "info");
7579 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7580 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7581 : : identifier, NULL);
7582 : :
7583 : : static cmdline_parse_inst_t cmd_showdevice = {
7584 : : .f = cmd_showdevice_parsed,
7585 : : .data = NULL,
7586 : : .help_str = "show device info <identifier>|all",
7587 : : .tokens = {
7588 : : (void *)&cmd_showdevice_show,
7589 : : (void *)&cmd_showdevice_device,
7590 : : (void *)&cmd_showdevice_what,
7591 : : (void *)&cmd_showdevice_identifier,
7592 : : NULL,
7593 : : },
7594 : : };
7595 : :
7596 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7597 : : struct cmd_showeeprom_result {
7598 : : cmdline_fixed_string_t show;
7599 : : cmdline_fixed_string_t port;
7600 : : uint16_t portnum;
7601 : : cmdline_fixed_string_t type;
7602 : : };
7603 : :
7604 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7605 : : __rte_unused struct cmdline *cl,
7606 : : __rte_unused void *data)
7607 : : {
7608 : : struct cmd_showeeprom_result *res = parsed_result;
7609 : :
7610 : 0 : if (!strcmp(res->type, "eeprom"))
7611 : 0 : port_eeprom_display(res->portnum);
7612 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7613 : 0 : port_module_eeprom_display(res->portnum);
7614 : : else
7615 : 0 : fprintf(stderr, "Unknown argument\n");
7616 : 0 : }
7617 : :
7618 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7619 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7620 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7621 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7622 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7623 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7624 : : RTE_UINT16);
7625 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7626 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7627 : :
7628 : : static cmdline_parse_inst_t cmd_showeeprom = {
7629 : : .f = cmd_showeeprom_parsed,
7630 : : .data = NULL,
7631 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7632 : : .tokens = {
7633 : : (void *)&cmd_showeeprom_show,
7634 : : (void *)&cmd_showeeprom_port,
7635 : : (void *)&cmd_showeeprom_portnum,
7636 : : (void *)&cmd_showeeprom_type,
7637 : : NULL,
7638 : : },
7639 : : };
7640 : :
7641 : : /* *** SET PORT EEPROM *** */
7642 : : struct cmd_seteeprom_result {
7643 : : cmdline_fixed_string_t set;
7644 : : cmdline_fixed_string_t port;
7645 : : uint16_t portnum;
7646 : : cmdline_fixed_string_t eeprom;
7647 : : cmdline_fixed_string_t confirm_str;
7648 : : cmdline_fixed_string_t magic_str;
7649 : : uint32_t magic;
7650 : : cmdline_fixed_string_t value;
7651 : : cmdline_multi_string_t token_str;
7652 : : };
7653 : :
7654 : 0 : static void cmd_seteeprom_parsed(void *parsed_result,
7655 : : __rte_unused struct cmdline *cl,
7656 : : __rte_unused void *data)
7657 : : {
7658 : : struct cmd_seteeprom_result *res = parsed_result;
7659 : : uint32_t offset = 0;
7660 : : uint32_t length;
7661 : : uint8_t *value;
7662 : : char *token_str;
7663 : : char *token;
7664 : :
7665 : 0 : token_str = res->token_str;
7666 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7667 : :
7668 : : /* Parse Hex string to Byte data */
7669 : 0 : if (strlen(token) % 2 != 0) {
7670 : 0 : fprintf(stderr, "Bad Argument: %s\nHex string must be in multiples of 2 Bytes\n",
7671 : : token);
7672 : 0 : return;
7673 : : }
7674 : :
7675 : 0 : length = strlen(token) / 2;
7676 : 0 : value = calloc(length, sizeof(uint8_t));
7677 : 0 : for (int count = 0; count < (int)(length); count++) {
7678 : 0 : if (sscanf(token, "%2hhx", &value[count]) != 1) {
7679 : 0 : fprintf(stderr, "Bad Argument: %s\nValue must be a hex string\n",
7680 : 0 : token - (count + 1));
7681 : 0 : goto out;
7682 : : }
7683 : 0 : token += 2;
7684 : : }
7685 : :
7686 : : /* Second token: offset string */
7687 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7688 : 0 : if (token != NULL) {
7689 : 0 : if (strcmp(token, "offset") == 0) {
7690 : : /* Third token: offset */
7691 : 0 : token = strtok_r(token_str, " \f\n\r\t\v", &token_str);
7692 : 0 : if (token == NULL) {
7693 : 0 : fprintf(stderr, "No offset specified\n");
7694 : 0 : goto out;
7695 : : }
7696 : :
7697 : : char *end;
7698 : 0 : offset = strtoul(token, &end, 10);
7699 : 0 : if (offset == 0 && strcmp(end, "") != 0) {
7700 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7701 : 0 : goto out;
7702 : : }
7703 : : } else {
7704 : 0 : fprintf(stderr, "Bad Argument: %s\n", token);
7705 : 0 : goto out;
7706 : : }
7707 : : }
7708 : :
7709 : 0 : port_eeprom_set(res->portnum, res->magic, offset, length, value);
7710 : :
7711 : 0 : out:
7712 : 0 : free(value);
7713 : : }
7714 : :
7715 : : static cmdline_parse_token_string_t cmd_seteeprom_set =
7716 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, set, "set");
7717 : : static cmdline_parse_token_string_t cmd_seteeprom_port =
7718 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, port, "port");
7719 : : static cmdline_parse_token_num_t cmd_seteeprom_portnum =
7720 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, portnum, RTE_UINT16);
7721 : : static cmdline_parse_token_string_t cmd_seteeprom_eeprom =
7722 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, eeprom, "eeprom");
7723 : : static cmdline_parse_token_string_t cmd_seteeprom_confirm_str =
7724 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, confirm_str, "accept_risk");
7725 : : static cmdline_parse_token_string_t cmd_seteeprom_magic_str =
7726 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, magic_str, "magic");
7727 : : static cmdline_parse_token_num_t cmd_seteeprom_magic =
7728 : : TOKEN_NUM_INITIALIZER(struct cmd_seteeprom_result, magic, RTE_UINT32);
7729 : : static cmdline_parse_token_string_t cmd_seteeprom_value =
7730 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, value, "value");
7731 : : static cmdline_parse_token_string_t cmd_seteeprom_token_str =
7732 : : TOKEN_STRING_INITIALIZER(struct cmd_seteeprom_result, token_str, TOKEN_STRING_MULTI);
7733 : :
7734 : : static cmdline_parse_inst_t cmd_seteeprom = {
7735 : : .f = cmd_seteeprom_parsed,
7736 : : .data = NULL,
7737 : : .help_str = "set port <port_id> eeprom <accept_risk> magic <magic_num> "
7738 : : "value <value> offset <offset>: Set eeprom value for port_id.\n"
7739 : : "Note:\n"
7740 : : "This is a high-risk command and its misuse may result in "
7741 : : "unexpected behaviour from the NIC.\n"
7742 : : "By inserting \"accept_risk\" into the command, the user is "
7743 : : "acknowledging and taking responsibility for this risk.",
7744 : : .tokens = {
7745 : : (void *)&cmd_seteeprom_set,
7746 : : (void *)&cmd_seteeprom_port,
7747 : : (void *)&cmd_seteeprom_portnum,
7748 : : (void *)&cmd_seteeprom_eeprom,
7749 : : (void *)&cmd_seteeprom_confirm_str,
7750 : : (void *)&cmd_seteeprom_magic_str,
7751 : : (void *)&cmd_seteeprom_magic,
7752 : : (void *)&cmd_seteeprom_value,
7753 : : (void *)&cmd_seteeprom_token_str,
7754 : : NULL,
7755 : : },
7756 : : };
7757 : :
7758 : : /* *** SHOW QUEUE INFO *** */
7759 : : struct cmd_showqueue_result {
7760 : : cmdline_fixed_string_t show;
7761 : : cmdline_fixed_string_t type;
7762 : : cmdline_fixed_string_t what;
7763 : : uint16_t portnum;
7764 : : uint16_t queuenum;
7765 : : };
7766 : :
7767 : : static void
7768 : 0 : cmd_showqueue_parsed(void *parsed_result,
7769 : : __rte_unused struct cmdline *cl,
7770 : : __rte_unused void *data)
7771 : : {
7772 : : struct cmd_showqueue_result *res = parsed_result;
7773 : :
7774 : 0 : if (!strcmp(res->type, "rxq"))
7775 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7776 : 0 : else if (!strcmp(res->type, "txq"))
7777 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7778 : 0 : }
7779 : :
7780 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7781 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7782 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7783 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7784 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7785 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7786 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7787 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7788 : : RTE_UINT16);
7789 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7790 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7791 : : RTE_UINT16);
7792 : :
7793 : : static cmdline_parse_inst_t cmd_showqueue = {
7794 : : .f = cmd_showqueue_parsed,
7795 : : .data = NULL,
7796 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7797 : : .tokens = {
7798 : : (void *)&cmd_showqueue_show,
7799 : : (void *)&cmd_showqueue_type,
7800 : : (void *)&cmd_showqueue_what,
7801 : : (void *)&cmd_showqueue_portnum,
7802 : : (void *)&cmd_showqueue_queuenum,
7803 : : NULL,
7804 : : },
7805 : : };
7806 : :
7807 : : /* show/clear fwd engine statistics */
7808 : : struct fwd_result {
7809 : : cmdline_fixed_string_t action;
7810 : : cmdline_fixed_string_t fwd;
7811 : : cmdline_fixed_string_t stats;
7812 : : cmdline_fixed_string_t all;
7813 : : };
7814 : :
7815 : : static cmdline_parse_token_string_t cmd_fwd_action =
7816 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7817 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
7818 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7819 : : static cmdline_parse_token_string_t cmd_fwd_stats =
7820 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7821 : : static cmdline_parse_token_string_t cmd_fwd_all =
7822 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7823 : :
7824 : : static void
7825 : 0 : cmd_showfwdall_parsed(void *parsed_result,
7826 : : __rte_unused struct cmdline *cl,
7827 : : __rte_unused void *data)
7828 : : {
7829 : : struct fwd_result *res = parsed_result;
7830 : :
7831 : 0 : if (!strcmp(res->action, "show"))
7832 : 0 : fwd_stats_display();
7833 : : else
7834 : 0 : fwd_stats_reset();
7835 : 0 : }
7836 : :
7837 : : static cmdline_parse_inst_t cmd_showfwdall = {
7838 : : .f = cmd_showfwdall_parsed,
7839 : : .data = NULL,
7840 : : .help_str = "show|clear fwd stats all",
7841 : : .tokens = {
7842 : : (void *)&cmd_fwd_action,
7843 : : (void *)&cmd_fwd_fwd,
7844 : : (void *)&cmd_fwd_stats,
7845 : : (void *)&cmd_fwd_all,
7846 : : NULL,
7847 : : },
7848 : : };
7849 : :
7850 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7851 : : struct cmd_read_rxd_txd_result {
7852 : : cmdline_fixed_string_t read;
7853 : : cmdline_fixed_string_t rxd_txd;
7854 : : portid_t port_id;
7855 : : uint16_t queue_id;
7856 : : uint16_t desc_id;
7857 : : };
7858 : :
7859 : : static void
7860 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
7861 : : __rte_unused struct cmdline *cl,
7862 : : __rte_unused void *data)
7863 : : {
7864 : : struct cmd_read_rxd_txd_result *res = parsed_result;
7865 : :
7866 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
7867 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7868 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
7869 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7870 : 0 : }
7871 : :
7872 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7873 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7874 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7875 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7876 : : "rxd#txd");
7877 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7878 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
7879 : : RTE_UINT16);
7880 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7881 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
7882 : : RTE_UINT16);
7883 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7884 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
7885 : : RTE_UINT16);
7886 : :
7887 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
7888 : : .f = cmd_read_rxd_txd_parsed,
7889 : : .data = NULL,
7890 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7891 : : .tokens = {
7892 : : (void *)&cmd_read_rxd_txd_read,
7893 : : (void *)&cmd_read_rxd_txd_rxd_txd,
7894 : : (void *)&cmd_read_rxd_txd_port_id,
7895 : : (void *)&cmd_read_rxd_txd_queue_id,
7896 : : (void *)&cmd_read_rxd_txd_desc_id,
7897 : : NULL,
7898 : : },
7899 : : };
7900 : :
7901 : : /* *** QUIT *** */
7902 : : struct cmd_quit_result {
7903 : : cmdline_fixed_string_t quit;
7904 : : };
7905 : :
7906 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
7907 : : struct cmdline *cl,
7908 : : __rte_unused void *data)
7909 : : {
7910 : 0 : cmdline_quit(cl);
7911 : 0 : cl_quit = 1;
7912 : 0 : }
7913 : :
7914 : : static cmdline_parse_token_string_t cmd_quit_quit =
7915 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7916 : :
7917 : : static cmdline_parse_inst_t cmd_quit = {
7918 : : .f = cmd_quit_parsed,
7919 : : .data = NULL,
7920 : : .help_str = "quit: Exit application",
7921 : : .tokens = {
7922 : : (void *)&cmd_quit_quit,
7923 : : NULL,
7924 : : },
7925 : : };
7926 : :
7927 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7928 : : struct cmd_mac_addr_result {
7929 : : cmdline_fixed_string_t mac_addr_cmd;
7930 : : cmdline_fixed_string_t what;
7931 : : uint16_t port_num;
7932 : : struct rte_ether_addr address;
7933 : : };
7934 : :
7935 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
7936 : : __rte_unused struct cmdline *cl,
7937 : : __rte_unused void *data)
7938 : : {
7939 : : struct cmd_mac_addr_result *res = parsed_result;
7940 : : int ret;
7941 : :
7942 : 0 : if (strcmp(res->what, "add") == 0)
7943 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7944 : 0 : else if (strcmp(res->what, "set") == 0)
7945 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7946 : : &res->address);
7947 : : else
7948 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7949 : :
7950 : : /* check the return value and print it if is < 0 */
7951 : 0 : if(ret < 0)
7952 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
7953 : :
7954 : 0 : }
7955 : :
7956 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
7957 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7958 : : "mac_addr");
7959 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
7960 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7961 : : "add#remove#set");
7962 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
7963 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7964 : : RTE_UINT16);
7965 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7966 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7967 : :
7968 : : static cmdline_parse_inst_t cmd_mac_addr = {
7969 : : .f = cmd_mac_addr_parsed,
7970 : : .data = (void *)0,
7971 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7972 : : "Add/Remove/Set MAC address on port_id",
7973 : : .tokens = {
7974 : : (void *)&cmd_mac_addr_cmd,
7975 : : (void *)&cmd_mac_addr_what,
7976 : : (void *)&cmd_mac_addr_portnum,
7977 : : (void *)&cmd_mac_addr_addr,
7978 : : NULL,
7979 : : },
7980 : : };
7981 : :
7982 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7983 : : struct cmd_eth_peer_result {
7984 : : cmdline_fixed_string_t set;
7985 : : cmdline_fixed_string_t eth_peer;
7986 : : portid_t port_id;
7987 : : cmdline_fixed_string_t peer_addr;
7988 : : };
7989 : :
7990 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
7991 : : __rte_unused struct cmdline *cl,
7992 : : __rte_unused void *data)
7993 : : {
7994 : : struct cmd_eth_peer_result *res = parsed_result;
7995 : :
7996 : 0 : if (test_done == 0) {
7997 : 0 : fprintf(stderr, "Please stop forwarding first\n");
7998 : 0 : return;
7999 : : }
8000 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
8001 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
8002 : 0 : fwd_config_setup();
8003 : : }
8004 : : }
8005 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
8006 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
8007 : : static cmdline_parse_token_string_t cmd_eth_peer =
8008 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
8009 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
8010 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
8011 : : RTE_UINT16);
8012 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
8013 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
8014 : :
8015 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
8016 : : .f = cmd_set_eth_peer_parsed,
8017 : : .data = NULL,
8018 : : .help_str = "set eth-peer <port_id> <peer_mac>",
8019 : : .tokens = {
8020 : : (void *)&cmd_eth_peer_set,
8021 : : (void *)&cmd_eth_peer,
8022 : : (void *)&cmd_eth_peer_port_id,
8023 : : (void *)&cmd_eth_peer_addr,
8024 : : NULL,
8025 : : },
8026 : : };
8027 : :
8028 : : /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
8029 : : struct cmd_set_qmap_result {
8030 : : cmdline_fixed_string_t set;
8031 : : cmdline_fixed_string_t qmap;
8032 : : cmdline_fixed_string_t what;
8033 : : portid_t port_id;
8034 : : uint16_t queue_id;
8035 : : uint8_t map_value;
8036 : : };
8037 : :
8038 : : static void
8039 : 0 : cmd_set_qmap_parsed(void *parsed_result,
8040 : : __rte_unused struct cmdline *cl,
8041 : : __rte_unused void *data)
8042 : : {
8043 : : struct cmd_set_qmap_result *res = parsed_result;
8044 : 0 : int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
8045 : :
8046 : 0 : set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
8047 : 0 : }
8048 : :
8049 : : static cmdline_parse_token_string_t cmd_setqmap_set =
8050 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8051 : : set, "set");
8052 : : static cmdline_parse_token_string_t cmd_setqmap_qmap =
8053 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8054 : : qmap, "stat_qmap");
8055 : : static cmdline_parse_token_string_t cmd_setqmap_what =
8056 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
8057 : : what, "tx#rx");
8058 : : static cmdline_parse_token_num_t cmd_setqmap_portid =
8059 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8060 : : port_id, RTE_UINT16);
8061 : : static cmdline_parse_token_num_t cmd_setqmap_queueid =
8062 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8063 : : queue_id, RTE_UINT16);
8064 : : static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
8065 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
8066 : : map_value, RTE_UINT8);
8067 : :
8068 : : static cmdline_parse_inst_t cmd_set_qmap = {
8069 : : .f = cmd_set_qmap_parsed,
8070 : : .data = NULL,
8071 : : .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
8072 : : "Set statistics mapping value on tx|rx queue_id of port_id",
8073 : : .tokens = {
8074 : : (void *)&cmd_setqmap_set,
8075 : : (void *)&cmd_setqmap_qmap,
8076 : : (void *)&cmd_setqmap_what,
8077 : : (void *)&cmd_setqmap_portid,
8078 : : (void *)&cmd_setqmap_queueid,
8079 : : (void *)&cmd_setqmap_mapvalue,
8080 : : NULL,
8081 : : },
8082 : : };
8083 : :
8084 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
8085 : : struct cmd_set_xstats_hide_zero_result {
8086 : : cmdline_fixed_string_t keyword;
8087 : : cmdline_fixed_string_t name;
8088 : : cmdline_fixed_string_t on_off;
8089 : : };
8090 : :
8091 : : static void
8092 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
8093 : : __rte_unused struct cmdline *cl,
8094 : : __rte_unused void *data)
8095 : : {
8096 : : struct cmd_set_xstats_hide_zero_result *res;
8097 : : uint16_t on_off = 0;
8098 : :
8099 : : res = parsed_result;
8100 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8101 : 0 : set_xstats_hide_zero(on_off);
8102 : 0 : }
8103 : :
8104 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
8105 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8106 : : keyword, "set");
8107 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
8108 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8109 : : name, "xstats-hide-zero");
8110 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
8111 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
8112 : : on_off, "on#off");
8113 : :
8114 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
8115 : : .f = cmd_set_xstats_hide_zero_parsed,
8116 : : .data = NULL,
8117 : : .help_str = "set xstats-hide-zero on|off",
8118 : : .tokens = {
8119 : : (void *)&cmd_set_xstats_hide_zero_keyword,
8120 : : (void *)&cmd_set_xstats_hide_zero_name,
8121 : : (void *)&cmd_set_xstats_hide_zero_on_off,
8122 : : NULL,
8123 : : },
8124 : : };
8125 : :
8126 : : /* *** SET OPTION TO DISPLAY XSTAT STATE *** */
8127 : : struct cmd_set_xstats_show_state_result {
8128 : : cmdline_fixed_string_t keyword;
8129 : : cmdline_fixed_string_t name;
8130 : : uint8_t on_off;
8131 : : };
8132 : : static void
8133 : 0 : cmd_set_xstats_show_state_parsed(void *parsed_result,
8134 : : __rte_unused struct cmdline *cl,
8135 : : __rte_unused void *data)
8136 : : {
8137 : : struct cmd_set_xstats_show_state_result *res = parsed_result;
8138 : 0 : set_xstats_show_state(res->on_off);
8139 : 0 : }
8140 : :
8141 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword =
8142 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8143 : : keyword, "set");
8144 : : static cmdline_parse_token_string_t cmd_set_xstats_show_state_name =
8145 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result,
8146 : : name, "xstats-show-state");
8147 : : static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off =
8148 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result,
8149 : : on_off);
8150 : :
8151 : : static cmdline_parse_inst_t cmd_set_xstats_show_state = {
8152 : : .f = cmd_set_xstats_show_state_parsed,
8153 : : .data = NULL,
8154 : : .help_str = "set xstats-show-state on|off",
8155 : : .tokens = {
8156 : : (void *)&cmd_set_xstats_show_state_keyword,
8157 : : (void *)&cmd_set_xstats_show_state_name,
8158 : : (void *)&cmd_set_xstats_show_state_on_off,
8159 : : NULL,
8160 : : },
8161 : : };
8162 : :
8163 : : /* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */
8164 : : struct cmd_set_xstats_hide_disabled_result {
8165 : : cmdline_fixed_string_t keyword;
8166 : : cmdline_fixed_string_t name;
8167 : : uint8_t on_off;
8168 : : };
8169 : :
8170 : : static void
8171 : 0 : cmd_set_xstats_hide_disabled_parsed(void *parsed_result,
8172 : : __rte_unused struct cmdline *cl,
8173 : : __rte_unused void *data)
8174 : : {
8175 : : struct cmd_set_xstats_hide_disabled_result *res = parsed_result;
8176 : 0 : set_xstats_hide_disabled(res->on_off);
8177 : 0 : }
8178 : :
8179 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword =
8180 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8181 : : keyword, "set");
8182 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name =
8183 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8184 : : name, "xstats-hide-disabled");
8185 : : static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off =
8186 : : TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result,
8187 : : on_off);
8188 : :
8189 : : static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = {
8190 : : .f = cmd_set_xstats_hide_disabled_parsed,
8191 : : .data = NULL,
8192 : : .help_str = "set xstats-hide-disabled on|off",
8193 : : .tokens = {
8194 : : (void *)&cmd_set_xstats_hide_disabled_keyword,
8195 : : (void *)&cmd_set_xstats_hide_disabled_name,
8196 : : (void *)&cmd_set_xstats_hide_disabled_on_off,
8197 : : NULL,
8198 : : },
8199 : : };
8200 : :
8201 : : /* *** enable/disable counter by name *** */
8202 : : struct cmd_operate_set_counter_result {
8203 : : cmdline_fixed_string_t port;
8204 : : portid_t port_id;
8205 : : cmdline_fixed_string_t what;
8206 : : cmdline_multi_string_t counter_name;
8207 : : };
8208 : :
8209 : : static void
8210 : 0 : cmd_operate_set_counter_parsed(void *parsed_result,
8211 : : __rte_unused struct cmdline *cl,
8212 : : __rte_unused void *data)
8213 : : {
8214 : : struct cmd_operate_set_counter_result *res = parsed_result;
8215 : 0 : uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1;
8216 : :
8217 : 0 : if ((strcmp(res->port, "port") == 0))
8218 : 0 : nic_xstats_set_counter(res->port_id, res->counter_name, on_off);
8219 : 0 : }
8220 : :
8221 : : static cmdline_parse_token_string_t cmd_operate_set_counter_port =
8222 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8223 : : port, "port");
8224 : : static cmdline_parse_token_num_t cmd_operate_set_counter_port_id =
8225 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result,
8226 : : port_id, RTE_UINT16);
8227 : : static cmdline_parse_token_string_t cmd_operate_set_counter_what =
8228 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8229 : : what, "enable#disable");
8230 : : static cmdline_parse_token_string_t cmd_operate_set_counter_name =
8231 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result,
8232 : : counter_name, TOKEN_STRING_MULTI);
8233 : :
8234 : : static cmdline_parse_inst_t cmd_operate_set_counter = {
8235 : : .f = cmd_operate_set_counter_parsed,
8236 : : .data = NULL,
8237 : : .help_str = "port (port_id) enable|disable <counter_name>",
8238 : : .tokens = {
8239 : : (void *)&cmd_operate_set_counter_port,
8240 : : (void *)&cmd_operate_set_counter_port_id,
8241 : : (void *)&cmd_operate_set_counter_what,
8242 : : (void *)&cmd_operate_set_counter_name,
8243 : : NULL,
8244 : : },
8245 : : };
8246 : :
8247 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
8248 : : struct cmd_set_record_core_cycles_result {
8249 : : cmdline_fixed_string_t keyword;
8250 : : cmdline_fixed_string_t name;
8251 : : cmdline_fixed_string_t on_off;
8252 : : };
8253 : :
8254 : : static void
8255 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
8256 : : __rte_unused struct cmdline *cl,
8257 : : __rte_unused void *data)
8258 : : {
8259 : : struct cmd_set_record_core_cycles_result *res;
8260 : : uint16_t on_off = 0;
8261 : :
8262 : : res = parsed_result;
8263 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8264 : 0 : set_record_core_cycles(on_off);
8265 : 0 : }
8266 : :
8267 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
8268 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8269 : : keyword, "set");
8270 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
8271 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8272 : : name, "record-core-cycles");
8273 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
8274 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
8275 : : on_off, "on#off");
8276 : :
8277 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
8278 : : .f = cmd_set_record_core_cycles_parsed,
8279 : : .data = NULL,
8280 : : .help_str = "set record-core-cycles on|off",
8281 : : .tokens = {
8282 : : (void *)&cmd_set_record_core_cycles_keyword,
8283 : : (void *)&cmd_set_record_core_cycles_name,
8284 : : (void *)&cmd_set_record_core_cycles_on_off,
8285 : : NULL,
8286 : : },
8287 : : };
8288 : :
8289 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
8290 : : struct cmd_set_record_burst_stats_result {
8291 : : cmdline_fixed_string_t keyword;
8292 : : cmdline_fixed_string_t name;
8293 : : cmdline_fixed_string_t on_off;
8294 : : };
8295 : :
8296 : : static void
8297 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
8298 : : __rte_unused struct cmdline *cl,
8299 : : __rte_unused void *data)
8300 : : {
8301 : : struct cmd_set_record_burst_stats_result *res;
8302 : : uint16_t on_off = 0;
8303 : :
8304 : : res = parsed_result;
8305 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
8306 : 0 : set_record_burst_stats(on_off);
8307 : 0 : }
8308 : :
8309 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
8310 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8311 : : keyword, "set");
8312 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
8313 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8314 : : name, "record-burst-stats");
8315 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
8316 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
8317 : : on_off, "on#off");
8318 : :
8319 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
8320 : : .f = cmd_set_record_burst_stats_parsed,
8321 : : .data = NULL,
8322 : : .help_str = "set record-burst-stats on|off",
8323 : : .tokens = {
8324 : : (void *)&cmd_set_record_burst_stats_keyword,
8325 : : (void *)&cmd_set_record_burst_stats_name,
8326 : : (void *)&cmd_set_record_burst_stats_on_off,
8327 : : NULL,
8328 : : },
8329 : : };
8330 : :
8331 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
8332 : : struct cmd_set_uc_hash_table {
8333 : : cmdline_fixed_string_t set;
8334 : : cmdline_fixed_string_t port;
8335 : : portid_t port_id;
8336 : : cmdline_fixed_string_t what;
8337 : : struct rte_ether_addr address;
8338 : : cmdline_fixed_string_t mode;
8339 : : };
8340 : :
8341 : : static void
8342 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
8343 : : __rte_unused struct cmdline *cl,
8344 : : __rte_unused void *data)
8345 : : {
8346 : : int ret=0;
8347 : : struct cmd_set_uc_hash_table *res = parsed_result;
8348 : :
8349 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8350 : :
8351 : 0 : if (strcmp(res->what, "uta") == 0)
8352 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
8353 : : &res->address,(uint8_t)is_on);
8354 : 0 : if (ret < 0)
8355 : 0 : fprintf(stderr,
8356 : : "bad unicast hash table parameter, return code = %d\n",
8357 : : ret);
8358 : :
8359 : 0 : }
8360 : :
8361 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
8362 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8363 : : set, "set");
8364 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
8365 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8366 : : port, "port");
8367 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
8368 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
8369 : : port_id, RTE_UINT16);
8370 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
8371 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8372 : : what, "uta");
8373 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
8374 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
8375 : : address);
8376 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
8377 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
8378 : : mode, "on#off");
8379 : :
8380 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
8381 : : .f = cmd_set_uc_hash_parsed,
8382 : : .data = NULL,
8383 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
8384 : : .tokens = {
8385 : : (void *)&cmd_set_uc_hash_set,
8386 : : (void *)&cmd_set_uc_hash_port,
8387 : : (void *)&cmd_set_uc_hash_portid,
8388 : : (void *)&cmd_set_uc_hash_what,
8389 : : (void *)&cmd_set_uc_hash_mac,
8390 : : (void *)&cmd_set_uc_hash_mode,
8391 : : NULL,
8392 : : },
8393 : : };
8394 : :
8395 : : struct cmd_set_uc_all_hash_table {
8396 : : cmdline_fixed_string_t set;
8397 : : cmdline_fixed_string_t port;
8398 : : portid_t port_id;
8399 : : cmdline_fixed_string_t what;
8400 : : cmdline_fixed_string_t value;
8401 : : cmdline_fixed_string_t mode;
8402 : : };
8403 : :
8404 : : static void
8405 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
8406 : : __rte_unused struct cmdline *cl,
8407 : : __rte_unused void *data)
8408 : : {
8409 : : int ret=0;
8410 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
8411 : :
8412 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8413 : :
8414 : 0 : if ((strcmp(res->what, "uta") == 0) &&
8415 : 0 : (strcmp(res->value, "all") == 0))
8416 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
8417 : 0 : if (ret < 0)
8418 : 0 : fprintf(stderr,
8419 : : "bad unicast hash table parameter, return code = %d\n",
8420 : : ret);
8421 : 0 : }
8422 : :
8423 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
8424 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8425 : : set, "set");
8426 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
8427 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8428 : : port, "port");
8429 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
8430 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
8431 : : port_id, RTE_UINT16);
8432 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
8433 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8434 : : what, "uta");
8435 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
8436 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8437 : : value,"all");
8438 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
8439 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
8440 : : mode, "on#off");
8441 : :
8442 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
8443 : : .f = cmd_set_uc_all_hash_parsed,
8444 : : .data = NULL,
8445 : : .help_str = "set port <port_id> uta all on|off",
8446 : : .tokens = {
8447 : : (void *)&cmd_set_uc_all_hash_set,
8448 : : (void *)&cmd_set_uc_all_hash_port,
8449 : : (void *)&cmd_set_uc_all_hash_portid,
8450 : : (void *)&cmd_set_uc_all_hash_what,
8451 : : (void *)&cmd_set_uc_all_hash_value,
8452 : : (void *)&cmd_set_uc_all_hash_mode,
8453 : : NULL,
8454 : : },
8455 : : };
8456 : :
8457 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
8458 : : struct cmd_set_vf_traffic {
8459 : : cmdline_fixed_string_t set;
8460 : : cmdline_fixed_string_t port;
8461 : : portid_t port_id;
8462 : : cmdline_fixed_string_t vf;
8463 : : uint8_t vf_id;
8464 : : cmdline_fixed_string_t what;
8465 : : cmdline_fixed_string_t mode;
8466 : : };
8467 : :
8468 : : static void
8469 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
8470 : : __rte_unused struct cmdline *cl,
8471 : : __rte_unused void *data)
8472 : : {
8473 : : struct cmd_set_vf_traffic *res = parsed_result;
8474 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
8475 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
8476 : :
8477 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
8478 : 0 : }
8479 : :
8480 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
8481 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8482 : : set, "set");
8483 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
8484 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8485 : : port, "port");
8486 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
8487 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8488 : : port_id, RTE_UINT16);
8489 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
8490 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8491 : : vf, "vf");
8492 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
8493 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
8494 : : vf_id, RTE_UINT8);
8495 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
8496 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8497 : : what, "tx#rx");
8498 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
8499 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
8500 : : mode, "on#off");
8501 : :
8502 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
8503 : : .f = cmd_set_vf_traffic_parsed,
8504 : : .data = NULL,
8505 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
8506 : : .tokens = {
8507 : : (void *)&cmd_setvf_traffic_set,
8508 : : (void *)&cmd_setvf_traffic_port,
8509 : : (void *)&cmd_setvf_traffic_portid,
8510 : : (void *)&cmd_setvf_traffic_vf,
8511 : : (void *)&cmd_setvf_traffic_vfid,
8512 : : (void *)&cmd_setvf_traffic_what,
8513 : : (void *)&cmd_setvf_traffic_mode,
8514 : : NULL,
8515 : : },
8516 : : };
8517 : :
8518 : : /* *** CONFIGURE VF RECEIVE MODE *** */
8519 : : struct cmd_set_vf_rxmode {
8520 : : cmdline_fixed_string_t set;
8521 : : cmdline_fixed_string_t port;
8522 : : portid_t port_id;
8523 : : cmdline_fixed_string_t vf;
8524 : : uint8_t vf_id;
8525 : : cmdline_fixed_string_t what;
8526 : : cmdline_fixed_string_t mode;
8527 : : cmdline_fixed_string_t on;
8528 : : };
8529 : :
8530 : : static void
8531 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
8532 : : __rte_unused struct cmdline *cl,
8533 : : __rte_unused void *data)
8534 : : {
8535 : : int ret = -ENOTSUP;
8536 : : uint16_t vf_rxmode = 0;
8537 : : struct cmd_set_vf_rxmode *res = parsed_result;
8538 : :
8539 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
8540 : 0 : if (!strcmp(res->what,"rxmode")) {
8541 : 0 : if (!strcmp(res->mode, "AUPE"))
8542 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
8543 : 0 : else if (!strcmp(res->mode, "ROPE"))
8544 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
8545 : 0 : else if (!strcmp(res->mode, "BAM"))
8546 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
8547 : 0 : else if (!strncmp(res->mode, "MPE",3))
8548 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
8549 : : }
8550 : :
8551 : : RTE_SET_USED(is_on);
8552 : : RTE_SET_USED(vf_rxmode);
8553 : :
8554 : : #ifdef RTE_NET_IXGBE
8555 : : if (ret == -ENOTSUP)
8556 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
8557 : : vf_rxmode, (uint8_t)is_on);
8558 : : #endif
8559 : : #ifdef RTE_NET_BNXT
8560 : 0 : if (ret == -ENOTSUP)
8561 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
8562 : : vf_rxmode, (uint8_t)is_on);
8563 : : #endif
8564 : 0 : if (ret < 0)
8565 : 0 : fprintf(stderr,
8566 : : "bad VF receive mode parameter, return code = %d\n",
8567 : : ret);
8568 : 0 : }
8569 : :
8570 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
8571 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8572 : : set, "set");
8573 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
8574 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8575 : : port, "port");
8576 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
8577 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8578 : : port_id, RTE_UINT16);
8579 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
8580 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8581 : : vf, "vf");
8582 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
8583 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
8584 : : vf_id, RTE_UINT8);
8585 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
8586 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8587 : : what, "rxmode");
8588 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
8589 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8590 : : mode, "AUPE#ROPE#BAM#MPE");
8591 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
8592 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
8593 : : on, "on#off");
8594 : :
8595 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
8596 : : .f = cmd_set_vf_rxmode_parsed,
8597 : : .data = NULL,
8598 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
8599 : : "AUPE|ROPE|BAM|MPE on|off",
8600 : : .tokens = {
8601 : : (void *)&cmd_set_vf_rxmode_set,
8602 : : (void *)&cmd_set_vf_rxmode_port,
8603 : : (void *)&cmd_set_vf_rxmode_portid,
8604 : : (void *)&cmd_set_vf_rxmode_vf,
8605 : : (void *)&cmd_set_vf_rxmode_vfid,
8606 : : (void *)&cmd_set_vf_rxmode_what,
8607 : : (void *)&cmd_set_vf_rxmode_mode,
8608 : : (void *)&cmd_set_vf_rxmode_on,
8609 : : NULL,
8610 : : },
8611 : : };
8612 : :
8613 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
8614 : : struct cmd_vf_mac_addr_result {
8615 : : cmdline_fixed_string_t mac_addr_cmd;
8616 : : cmdline_fixed_string_t what;
8617 : : cmdline_fixed_string_t port;
8618 : : uint16_t port_num;
8619 : : cmdline_fixed_string_t vf;
8620 : : uint8_t vf_num;
8621 : : struct rte_ether_addr address;
8622 : : };
8623 : :
8624 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
8625 : : __rte_unused struct cmdline *cl,
8626 : : __rte_unused void *data)
8627 : : {
8628 : : struct cmd_vf_mac_addr_result *res = parsed_result;
8629 : : int ret = -ENOTSUP;
8630 : :
8631 : 0 : if (strcmp(res->what, "add") != 0)
8632 : : return;
8633 : :
8634 : : #ifdef RTE_NET_I40E
8635 : : if (ret == -ENOTSUP)
8636 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
8637 : : &res->address);
8638 : : #endif
8639 : : #ifdef RTE_NET_BNXT
8640 : 0 : if (ret == -ENOTSUP)
8641 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
8642 : 0 : res->vf_num);
8643 : : #endif
8644 : :
8645 : 0 : if(ret < 0)
8646 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
8647 : :
8648 : : }
8649 : :
8650 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
8651 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8652 : : mac_addr_cmd,"mac_addr");
8653 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
8654 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8655 : : what,"add");
8656 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
8657 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8658 : : port,"port");
8659 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8660 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8661 : : port_num, RTE_UINT16);
8662 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8663 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8664 : : vf,"vf");
8665 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8666 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8667 : : vf_num, RTE_UINT8);
8668 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8669 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8670 : : address);
8671 : :
8672 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8673 : : .f = cmd_vf_mac_addr_parsed,
8674 : : .data = (void *)0,
8675 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8676 : : "Add MAC address filtering for a VF on port_id",
8677 : : .tokens = {
8678 : : (void *)&cmd_vf_mac_addr_cmd,
8679 : : (void *)&cmd_vf_mac_addr_what,
8680 : : (void *)&cmd_vf_mac_addr_port,
8681 : : (void *)&cmd_vf_mac_addr_portnum,
8682 : : (void *)&cmd_vf_mac_addr_vf,
8683 : : (void *)&cmd_vf_mac_addr_vfnum,
8684 : : (void *)&cmd_vf_mac_addr_addr,
8685 : : NULL,
8686 : : },
8687 : : };
8688 : :
8689 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8690 : : struct cmd_vf_rx_vlan_filter {
8691 : : cmdline_fixed_string_t rx_vlan;
8692 : : cmdline_fixed_string_t what;
8693 : : uint16_t vlan_id;
8694 : : cmdline_fixed_string_t port;
8695 : : portid_t port_id;
8696 : : cmdline_fixed_string_t vf;
8697 : : uint64_t vf_mask;
8698 : : };
8699 : :
8700 : : static void
8701 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8702 : : __rte_unused struct cmdline *cl,
8703 : : __rte_unused void *data)
8704 : : {
8705 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8706 : : int ret = -ENOTSUP;
8707 : :
8708 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8709 : :
8710 : : #ifdef RTE_NET_IXGBE
8711 : : if (ret == -ENOTSUP)
8712 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8713 : 0 : res->vlan_id, res->vf_mask, is_add);
8714 : : #endif
8715 : : #ifdef RTE_NET_I40E
8716 : 0 : if (ret == -ENOTSUP)
8717 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8718 : 0 : res->vlan_id, res->vf_mask, is_add);
8719 : : #endif
8720 : : #ifdef RTE_NET_BNXT
8721 : 0 : if (ret == -ENOTSUP)
8722 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8723 : 0 : res->vlan_id, res->vf_mask, is_add);
8724 : : #endif
8725 : :
8726 : 0 : switch (ret) {
8727 : : case 0:
8728 : : break;
8729 : 0 : case -EINVAL:
8730 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8731 : 0 : res->vlan_id, res->vf_mask);
8732 : : break;
8733 : 0 : case -ENODEV:
8734 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8735 : : break;
8736 : 0 : case -ENOTSUP:
8737 : 0 : fprintf(stderr, "function not implemented or supported\n");
8738 : : break;
8739 : 0 : default:
8740 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8741 : : }
8742 : 0 : }
8743 : :
8744 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8745 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8746 : : rx_vlan, "rx_vlan");
8747 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8748 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8749 : : what, "add#rm");
8750 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8751 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8752 : : vlan_id, RTE_UINT16);
8753 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8754 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8755 : : port, "port");
8756 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8757 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8758 : : port_id, RTE_UINT16);
8759 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8760 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8761 : : vf, "vf");
8762 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8763 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8764 : : vf_mask, RTE_UINT64);
8765 : :
8766 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8767 : : .f = cmd_vf_rx_vlan_filter_parsed,
8768 : : .data = NULL,
8769 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8770 : : "(vf_mask = hexadecimal VF mask)",
8771 : : .tokens = {
8772 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8773 : : (void *)&cmd_vf_rx_vlan_filter_what,
8774 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8775 : : (void *)&cmd_vf_rx_vlan_filter_port,
8776 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8777 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8778 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8779 : : NULL,
8780 : : },
8781 : : };
8782 : :
8783 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8784 : : struct cmd_queue_rate_limit_result {
8785 : : cmdline_fixed_string_t set;
8786 : : cmdline_fixed_string_t port;
8787 : : uint16_t port_num;
8788 : : cmdline_fixed_string_t queue;
8789 : : uint8_t queue_num;
8790 : : cmdline_fixed_string_t rate;
8791 : : uint32_t rate_num;
8792 : : };
8793 : :
8794 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8795 : : __rte_unused struct cmdline *cl,
8796 : : __rte_unused void *data)
8797 : : {
8798 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8799 : : int ret = 0;
8800 : :
8801 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8802 : 0 : && (strcmp(res->queue, "queue") == 0)
8803 : 0 : && (strcmp(res->rate, "rate") == 0))
8804 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8805 : : res->rate_num);
8806 : 0 : if (ret < 0)
8807 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8808 : : strerror(-ret));
8809 : :
8810 : 0 : }
8811 : :
8812 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8813 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8814 : : set, "set");
8815 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8816 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8817 : : port, "port");
8818 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8819 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8820 : : port_num, RTE_UINT16);
8821 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8822 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8823 : : queue, "queue");
8824 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8825 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8826 : : queue_num, RTE_UINT8);
8827 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8828 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8829 : : rate, "rate");
8830 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8831 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8832 : : rate_num, RTE_UINT32);
8833 : :
8834 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8835 : : .f = cmd_queue_rate_limit_parsed,
8836 : : .data = (void *)0,
8837 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8838 : : "Set rate limit for a queue on port_id",
8839 : : .tokens = {
8840 : : (void *)&cmd_queue_rate_limit_set,
8841 : : (void *)&cmd_queue_rate_limit_port,
8842 : : (void *)&cmd_queue_rate_limit_portnum,
8843 : : (void *)&cmd_queue_rate_limit_queue,
8844 : : (void *)&cmd_queue_rate_limit_queuenum,
8845 : : (void *)&cmd_queue_rate_limit_rate,
8846 : : (void *)&cmd_queue_rate_limit_ratenum,
8847 : : NULL,
8848 : : },
8849 : : };
8850 : :
8851 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8852 : : struct cmd_vf_rate_limit_result {
8853 : : cmdline_fixed_string_t set;
8854 : : cmdline_fixed_string_t port;
8855 : : uint16_t port_num;
8856 : : cmdline_fixed_string_t vf;
8857 : : uint8_t vf_num;
8858 : : cmdline_fixed_string_t rate;
8859 : : uint32_t rate_num;
8860 : : cmdline_fixed_string_t q_msk;
8861 : : uint64_t q_msk_val;
8862 : : };
8863 : :
8864 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
8865 : : __rte_unused struct cmdline *cl,
8866 : : __rte_unused void *data)
8867 : : {
8868 : : struct cmd_vf_rate_limit_result *res = parsed_result;
8869 : : int ret = 0;
8870 : :
8871 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8872 : 0 : && (strcmp(res->vf, "vf") == 0)
8873 : 0 : && (strcmp(res->rate, "rate") == 0)
8874 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
8875 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
8876 : : res->rate_num, res->q_msk_val);
8877 : 0 : if (ret < 0)
8878 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
8879 : : strerror(-ret));
8880 : :
8881 : 0 : }
8882 : :
8883 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8884 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8885 : : set, "set");
8886 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8887 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8888 : : port, "port");
8889 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8890 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8891 : : port_num, RTE_UINT16);
8892 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8893 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8894 : : vf, "vf");
8895 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8896 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8897 : : vf_num, RTE_UINT8);
8898 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8899 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8900 : : rate, "rate");
8901 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8902 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8903 : : rate_num, RTE_UINT32);
8904 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8905 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8906 : : q_msk, "queue_mask");
8907 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8908 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8909 : : q_msk_val, RTE_UINT64);
8910 : :
8911 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
8912 : : .f = cmd_vf_rate_limit_parsed,
8913 : : .data = (void *)0,
8914 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8915 : : "queue_mask <queue_mask_value>: "
8916 : : "Set rate limit for queues of VF on port_id",
8917 : : .tokens = {
8918 : : (void *)&cmd_vf_rate_limit_set,
8919 : : (void *)&cmd_vf_rate_limit_port,
8920 : : (void *)&cmd_vf_rate_limit_portnum,
8921 : : (void *)&cmd_vf_rate_limit_vf,
8922 : : (void *)&cmd_vf_rate_limit_vfnum,
8923 : : (void *)&cmd_vf_rate_limit_rate,
8924 : : (void *)&cmd_vf_rate_limit_ratenum,
8925 : : (void *)&cmd_vf_rate_limit_q_msk,
8926 : : (void *)&cmd_vf_rate_limit_q_msk_val,
8927 : : NULL,
8928 : : },
8929 : : };
8930 : :
8931 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
8932 : : struct cmd_tunnel_udp_config {
8933 : : cmdline_fixed_string_t rx_vxlan_port;
8934 : : cmdline_fixed_string_t what;
8935 : : uint16_t udp_port;
8936 : : portid_t port_id;
8937 : : };
8938 : :
8939 : : static void
8940 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
8941 : : __rte_unused struct cmdline *cl,
8942 : : __rte_unused void *data)
8943 : : {
8944 : : struct cmd_tunnel_udp_config *res = parsed_result;
8945 : : struct rte_eth_udp_tunnel tunnel_udp;
8946 : : int ret;
8947 : :
8948 : 0 : tunnel_udp.udp_port = res->udp_port;
8949 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8950 : :
8951 : 0 : if (!strcmp(res->what, "add"))
8952 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8953 : : &tunnel_udp);
8954 : : else
8955 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8956 : : &tunnel_udp);
8957 : :
8958 : 0 : if (ret < 0)
8959 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
8960 : : strerror(-ret));
8961 : 0 : }
8962 : :
8963 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
8964 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8965 : : rx_vxlan_port, "rx_vxlan_port");
8966 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8967 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8968 : : what, "add#rm");
8969 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8970 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8971 : : udp_port, RTE_UINT16);
8972 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8973 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8974 : : port_id, RTE_UINT16);
8975 : :
8976 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
8977 : : .f = cmd_tunnel_udp_config_parsed,
8978 : : .data = (void *)0,
8979 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8980 : : "Add/Remove a tunneling UDP port filter",
8981 : : .tokens = {
8982 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
8983 : : (void *)&cmd_tunnel_udp_config_what,
8984 : : (void *)&cmd_tunnel_udp_config_udp_port,
8985 : : (void *)&cmd_tunnel_udp_config_port_id,
8986 : : NULL,
8987 : : },
8988 : : };
8989 : :
8990 : : struct cmd_config_tunnel_udp_port {
8991 : : cmdline_fixed_string_t port;
8992 : : cmdline_fixed_string_t config;
8993 : : portid_t port_id;
8994 : : cmdline_fixed_string_t udp_tunnel_port;
8995 : : cmdline_fixed_string_t action;
8996 : : cmdline_fixed_string_t tunnel_type;
8997 : : uint16_t udp_port;
8998 : : };
8999 : :
9000 : : static void
9001 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
9002 : : __rte_unused struct cmdline *cl,
9003 : : __rte_unused void *data)
9004 : : {
9005 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
9006 : : struct rte_eth_udp_tunnel tunnel_udp;
9007 : : int ret = 0;
9008 : :
9009 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9010 : 0 : return;
9011 : :
9012 : 0 : tunnel_udp.udp_port = res->udp_port;
9013 : :
9014 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
9015 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
9016 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
9017 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
9018 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
9019 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
9020 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
9021 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
9022 : : } else {
9023 : 0 : fprintf(stderr, "Invalid tunnel type\n");
9024 : 0 : return;
9025 : : }
9026 : :
9027 : 0 : if (!strcmp(res->action, "add"))
9028 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
9029 : : &tunnel_udp);
9030 : : else
9031 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
9032 : : &tunnel_udp);
9033 : :
9034 : 0 : if (ret < 0)
9035 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
9036 : : strerror(-ret));
9037 : : }
9038 : :
9039 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
9040 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
9041 : : "port");
9042 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
9043 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
9044 : : "config");
9045 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
9046 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
9047 : : RTE_UINT16);
9048 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
9049 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
9050 : : udp_tunnel_port,
9051 : : "udp_tunnel_port");
9052 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
9053 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
9054 : : "add#rm");
9055 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
9056 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
9057 : : "vxlan#geneve#vxlan-gpe#ecpri");
9058 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
9059 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
9060 : : RTE_UINT16);
9061 : :
9062 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
9063 : : .f = cmd_cfg_tunnel_udp_port_parsed,
9064 : : .data = NULL,
9065 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
9066 : : "geneve|vxlan-gpe|ecpri <udp_port>",
9067 : : .tokens = {
9068 : : (void *)&cmd_config_tunnel_udp_port_port,
9069 : : (void *)&cmd_config_tunnel_udp_port_config,
9070 : : (void *)&cmd_config_tunnel_udp_port_port_id,
9071 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
9072 : : (void *)&cmd_config_tunnel_udp_port_action,
9073 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
9074 : : (void *)&cmd_config_tunnel_udp_port_value,
9075 : : NULL,
9076 : : },
9077 : : };
9078 : :
9079 : : /* ******************************************************************************** */
9080 : :
9081 : : struct cmd_dump_result {
9082 : : cmdline_fixed_string_t dump;
9083 : : };
9084 : :
9085 : : static void
9086 : 0 : dump_struct_sizes(void)
9087 : : {
9088 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
9089 : : DUMP_SIZE(struct rte_mbuf);
9090 : : DUMP_SIZE(struct rte_mempool);
9091 : : DUMP_SIZE(struct rte_ring);
9092 : : #undef DUMP_SIZE
9093 : 0 : }
9094 : :
9095 : :
9096 : : /* Dump the socket memory statistics on console */
9097 : : static void
9098 : 0 : dump_socket_mem(FILE *f)
9099 : : {
9100 : : struct rte_malloc_socket_stats socket_stats;
9101 : : unsigned int i;
9102 : : size_t total = 0;
9103 : : size_t alloc = 0;
9104 : : size_t free = 0;
9105 : : unsigned int n_alloc = 0;
9106 : : unsigned int n_free = 0;
9107 : : static size_t last_allocs;
9108 : : static size_t last_total;
9109 : :
9110 : :
9111 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
9112 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
9113 : 0 : !socket_stats.heap_totalsz_bytes)
9114 : 0 : continue;
9115 : 0 : total += socket_stats.heap_totalsz_bytes;
9116 : 0 : alloc += socket_stats.heap_allocsz_bytes;
9117 : 0 : free += socket_stats.heap_freesz_bytes;
9118 : 0 : n_alloc += socket_stats.alloc_count;
9119 : 0 : n_free += socket_stats.free_count;
9120 : 0 : fprintf(f,
9121 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9122 : : i,
9123 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
9124 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
9125 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
9126 : 0 : (double)socket_stats.heap_totalsz_bytes,
9127 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
9128 : : socket_stats.alloc_count,
9129 : : socket_stats.free_count);
9130 : : }
9131 : 0 : fprintf(f,
9132 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
9133 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
9134 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
9135 : 0 : (double)free / (1024 * 1024),
9136 : : n_alloc, n_free);
9137 : 0 : if (last_allocs)
9138 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
9139 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
9140 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
9141 : 0 : last_allocs = alloc;
9142 : 0 : last_total = total;
9143 : 0 : }
9144 : :
9145 : 0 : static void cmd_dump_parsed(void *parsed_result,
9146 : : __rte_unused struct cmdline *cl,
9147 : : __rte_unused void *data)
9148 : : {
9149 : : struct cmd_dump_result *res = parsed_result;
9150 : :
9151 : 0 : if (!strcmp(res->dump, "dump_physmem"))
9152 : 0 : rte_dump_physmem_layout(stdout);
9153 : 0 : else if (!strcmp(res->dump, "dump_socket_mem"))
9154 : 0 : dump_socket_mem(stdout);
9155 : 0 : else if (!strcmp(res->dump, "dump_memzone"))
9156 : 0 : rte_memzone_dump(stdout);
9157 : 0 : else if (!strcmp(res->dump, "dump_struct_sizes"))
9158 : 0 : dump_struct_sizes();
9159 : 0 : else if (!strcmp(res->dump, "dump_ring"))
9160 : 0 : rte_ring_list_dump(stdout);
9161 : 0 : else if (!strcmp(res->dump, "dump_mempool"))
9162 : 0 : rte_mempool_list_dump(stdout);
9163 : 0 : else if (!strcmp(res->dump, "dump_devargs"))
9164 : 0 : rte_devargs_dump(stdout);
9165 : 0 : else if (!strcmp(res->dump, "dump_lcores"))
9166 : 0 : rte_lcore_dump(stdout);
9167 : : #ifndef RTE_EXEC_ENV_WINDOWS
9168 : 0 : else if (!strcmp(res->dump, "dump_trace"))
9169 : 0 : rte_trace_save();
9170 : : #endif
9171 : 0 : else if (!strcmp(res->dump, "dump_log_types"))
9172 : 0 : rte_log_dump(stdout);
9173 : 0 : }
9174 : :
9175 : : static cmdline_parse_token_string_t cmd_dump_dump =
9176 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
9177 : : "" /* defined at init */);
9178 : :
9179 : : static void
9180 : : cmd_dump_init(void)
9181 : : {
9182 : 0 : cmd_dump_dump.string_data.str =
9183 : : "dump_physmem#"
9184 : : "dump_memzone#"
9185 : : "dump_socket_mem#"
9186 : : "dump_struct_sizes#"
9187 : : "dump_ring#"
9188 : : "dump_mempool#"
9189 : : "dump_devargs#"
9190 : : "dump_lcores#"
9191 : : #ifndef RTE_EXEC_ENV_WINDOWS
9192 : : "dump_trace#"
9193 : : #endif
9194 : : "dump_log_types";
9195 : : }
9196 : :
9197 : : static cmdline_parse_inst_t cmd_dump = {
9198 : : .f = cmd_dump_parsed, /* function to call */
9199 : : .data = NULL, /* 2nd arg of func */
9200 : : .help_str = "Dump status",
9201 : : .tokens = { /* token list, NULL terminated */
9202 : : (void *)&cmd_dump_dump,
9203 : : NULL,
9204 : : },
9205 : : };
9206 : :
9207 : : /* ******************************************************************************** */
9208 : :
9209 : : struct cmd_dump_one_result {
9210 : : cmdline_fixed_string_t dump;
9211 : : cmdline_fixed_string_t name;
9212 : : };
9213 : :
9214 : 0 : static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
9215 : : __rte_unused void *data)
9216 : : {
9217 : : struct cmd_dump_one_result *res = parsed_result;
9218 : :
9219 : 0 : if (!strcmp(res->dump, "dump_ring")) {
9220 : : struct rte_ring *r;
9221 : 0 : r = rte_ring_lookup(res->name);
9222 : 0 : if (r == NULL) {
9223 : 0 : cmdline_printf(cl, "Cannot find ring\n");
9224 : 0 : return;
9225 : : }
9226 : 0 : rte_ring_dump(stdout, r);
9227 : 0 : } else if (!strcmp(res->dump, "dump_mempool")) {
9228 : : struct rte_mempool *mp;
9229 : 0 : mp = rte_mempool_lookup(res->name);
9230 : 0 : if (mp == NULL) {
9231 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
9232 : 0 : return;
9233 : : }
9234 : 0 : rte_mempool_dump(stdout, mp);
9235 : : }
9236 : : }
9237 : :
9238 : : static cmdline_parse_token_string_t cmd_dump_one_dump =
9239 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
9240 : : "dump_ring#dump_mempool");
9241 : :
9242 : : static cmdline_parse_token_string_t cmd_dump_one_name =
9243 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
9244 : :
9245 : : static cmdline_parse_inst_t cmd_dump_one = {
9246 : : .f = cmd_dump_one_parsed, /* function to call */
9247 : : .data = NULL, /* 2nd arg of func */
9248 : : .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
9249 : : .tokens = { /* token list, NULL terminated */
9250 : : (void *)&cmd_dump_one_dump,
9251 : : (void *)&cmd_dump_one_name,
9252 : : NULL,
9253 : : },
9254 : : };
9255 : :
9256 : : /* *** Filters Control *** */
9257 : :
9258 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
9259 : : do { \
9260 : : if ((ip_addr).family == AF_INET) \
9261 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
9262 : : else { \
9263 : : fprintf(stderr, "invalid parameter.\n"); \
9264 : : return; \
9265 : : } \
9266 : : } while (0)
9267 : :
9268 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
9269 : : do { \
9270 : : if ((ip_addr).family == AF_INET6) \
9271 : : ip = ip_addr.addr.ipv6; \
9272 : : else { \
9273 : : fprintf(stderr, "invalid parameter.\n"); \
9274 : : return; \
9275 : : } \
9276 : : } while (0)
9277 : :
9278 : : /* Generic flow interface command. */
9279 : : extern cmdline_parse_inst_t cmd_flow;
9280 : :
9281 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
9282 : : struct cmd_mcast_addr_result {
9283 : : cmdline_fixed_string_t mcast_addr_cmd;
9284 : : cmdline_fixed_string_t what;
9285 : : uint16_t port_num;
9286 : : struct rte_ether_addr mc_addr;
9287 : : };
9288 : :
9289 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
9290 : : __rte_unused struct cmdline *cl,
9291 : : __rte_unused void *data)
9292 : : {
9293 : : struct cmd_mcast_addr_result *res = parsed_result;
9294 : :
9295 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
9296 : 0 : fprintf(stderr,
9297 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
9298 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
9299 : 0 : return;
9300 : : }
9301 : 0 : if (strcmp(res->what, "add") == 0)
9302 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
9303 : : else
9304 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
9305 : : }
9306 : :
9307 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
9308 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9309 : : mcast_addr_cmd, "mcast_addr");
9310 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
9311 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9312 : : "add#remove");
9313 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
9314 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9315 : : RTE_UINT16);
9316 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
9317 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
9318 : :
9319 : : static cmdline_parse_inst_t cmd_mcast_addr = {
9320 : : .f = cmd_mcast_addr_parsed,
9321 : : .data = (void *)0,
9322 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
9323 : : "Add/Remove multicast MAC address on port_id",
9324 : : .tokens = {
9325 : : (void *)&cmd_mcast_addr_cmd,
9326 : : (void *)&cmd_mcast_addr_what,
9327 : : (void *)&cmd_mcast_addr_portnum,
9328 : : (void *)&cmd_mcast_addr_addr,
9329 : : NULL,
9330 : : },
9331 : : };
9332 : :
9333 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
9334 : : struct cmd_mcast_addr_flush_result {
9335 : : cmdline_fixed_string_t mcast_addr_cmd;
9336 : : cmdline_fixed_string_t what;
9337 : : uint16_t port_num;
9338 : : };
9339 : :
9340 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
9341 : : __rte_unused struct cmdline *cl,
9342 : : __rte_unused void *data)
9343 : : {
9344 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
9345 : :
9346 : 0 : mcast_addr_flush(res->port_num);
9347 : 0 : }
9348 : :
9349 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
9350 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
9351 : : mcast_addr_cmd, "mcast_addr");
9352 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
9353 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
9354 : : "flush");
9355 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
9356 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
9357 : : RTE_UINT16);
9358 : :
9359 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
9360 : : .f = cmd_mcast_addr_flush_parsed,
9361 : : .data = (void *)0,
9362 : : .help_str = "mcast_addr flush <port_id> : "
9363 : : "flush all multicast MAC addresses on port_id",
9364 : : .tokens = {
9365 : : (void *)&cmd_mcast_addr_flush_cmd,
9366 : : (void *)&cmd_mcast_addr_flush_what,
9367 : : (void *)&cmd_mcast_addr_flush_portnum,
9368 : : NULL,
9369 : : },
9370 : : };
9371 : :
9372 : : /* vf vlan anti spoof configuration */
9373 : :
9374 : : /* Common result structure for vf vlan anti spoof */
9375 : : struct cmd_vf_vlan_anti_spoof_result {
9376 : : cmdline_fixed_string_t set;
9377 : : cmdline_fixed_string_t vf;
9378 : : cmdline_fixed_string_t vlan;
9379 : : cmdline_fixed_string_t antispoof;
9380 : : portid_t port_id;
9381 : : uint32_t vf_id;
9382 : : cmdline_fixed_string_t on_off;
9383 : : };
9384 : :
9385 : : /* Common CLI fields for vf vlan anti spoof enable disable */
9386 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
9387 : : TOKEN_STRING_INITIALIZER
9388 : : (struct cmd_vf_vlan_anti_spoof_result,
9389 : : set, "set");
9390 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
9391 : : TOKEN_STRING_INITIALIZER
9392 : : (struct cmd_vf_vlan_anti_spoof_result,
9393 : : vf, "vf");
9394 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
9395 : : TOKEN_STRING_INITIALIZER
9396 : : (struct cmd_vf_vlan_anti_spoof_result,
9397 : : vlan, "vlan");
9398 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
9399 : : TOKEN_STRING_INITIALIZER
9400 : : (struct cmd_vf_vlan_anti_spoof_result,
9401 : : antispoof, "antispoof");
9402 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
9403 : : TOKEN_NUM_INITIALIZER
9404 : : (struct cmd_vf_vlan_anti_spoof_result,
9405 : : port_id, RTE_UINT16);
9406 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
9407 : : TOKEN_NUM_INITIALIZER
9408 : : (struct cmd_vf_vlan_anti_spoof_result,
9409 : : vf_id, RTE_UINT32);
9410 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
9411 : : TOKEN_STRING_INITIALIZER
9412 : : (struct cmd_vf_vlan_anti_spoof_result,
9413 : : on_off, "on#off");
9414 : :
9415 : : static void
9416 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
9417 : : void *parsed_result,
9418 : : __rte_unused struct cmdline *cl,
9419 : : __rte_unused void *data)
9420 : : {
9421 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
9422 : : int ret = -ENOTSUP;
9423 : :
9424 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9425 : :
9426 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9427 : : return;
9428 : :
9429 : : #ifdef RTE_NET_IXGBE
9430 : : if (ret == -ENOTSUP)
9431 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
9432 : 0 : res->vf_id, is_on);
9433 : : #endif
9434 : : #ifdef RTE_NET_I40E
9435 : 0 : if (ret == -ENOTSUP)
9436 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
9437 : 0 : res->vf_id, is_on);
9438 : : #endif
9439 : : #ifdef RTE_NET_BNXT
9440 : 0 : if (ret == -ENOTSUP)
9441 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
9442 : 0 : res->vf_id, is_on);
9443 : : #endif
9444 : :
9445 : 0 : switch (ret) {
9446 : : case 0:
9447 : : break;
9448 : 0 : case -EINVAL:
9449 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
9450 : : break;
9451 : 0 : case -ENODEV:
9452 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9453 : : break;
9454 : 0 : case -ENOTSUP:
9455 : 0 : fprintf(stderr, "function not implemented\n");
9456 : : break;
9457 : 0 : default:
9458 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9459 : : }
9460 : : }
9461 : :
9462 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
9463 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
9464 : : .data = NULL,
9465 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
9466 : : .tokens = {
9467 : : (void *)&cmd_vf_vlan_anti_spoof_set,
9468 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
9469 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
9470 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
9471 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
9472 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
9473 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
9474 : : NULL,
9475 : : },
9476 : : };
9477 : :
9478 : : /* vf mac anti spoof configuration */
9479 : :
9480 : : /* Common result structure for vf mac anti spoof */
9481 : : struct cmd_vf_mac_anti_spoof_result {
9482 : : cmdline_fixed_string_t set;
9483 : : cmdline_fixed_string_t vf;
9484 : : cmdline_fixed_string_t mac;
9485 : : cmdline_fixed_string_t antispoof;
9486 : : portid_t port_id;
9487 : : uint32_t vf_id;
9488 : : cmdline_fixed_string_t on_off;
9489 : : };
9490 : :
9491 : : /* Common CLI fields for vf mac anti spoof enable disable */
9492 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
9493 : : TOKEN_STRING_INITIALIZER
9494 : : (struct cmd_vf_mac_anti_spoof_result,
9495 : : set, "set");
9496 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
9497 : : TOKEN_STRING_INITIALIZER
9498 : : (struct cmd_vf_mac_anti_spoof_result,
9499 : : vf, "vf");
9500 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
9501 : : TOKEN_STRING_INITIALIZER
9502 : : (struct cmd_vf_mac_anti_spoof_result,
9503 : : mac, "mac");
9504 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
9505 : : TOKEN_STRING_INITIALIZER
9506 : : (struct cmd_vf_mac_anti_spoof_result,
9507 : : antispoof, "antispoof");
9508 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
9509 : : TOKEN_NUM_INITIALIZER
9510 : : (struct cmd_vf_mac_anti_spoof_result,
9511 : : port_id, RTE_UINT16);
9512 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
9513 : : TOKEN_NUM_INITIALIZER
9514 : : (struct cmd_vf_mac_anti_spoof_result,
9515 : : vf_id, RTE_UINT32);
9516 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
9517 : : TOKEN_STRING_INITIALIZER
9518 : : (struct cmd_vf_mac_anti_spoof_result,
9519 : : on_off, "on#off");
9520 : :
9521 : : static void
9522 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
9523 : : void *parsed_result,
9524 : : __rte_unused struct cmdline *cl,
9525 : : __rte_unused void *data)
9526 : : {
9527 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
9528 : : int ret = -ENOTSUP;
9529 : :
9530 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9531 : :
9532 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9533 : : return;
9534 : :
9535 : : #ifdef RTE_NET_IXGBE
9536 : : if (ret == -ENOTSUP)
9537 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
9538 : 0 : res->vf_id, is_on);
9539 : : #endif
9540 : : #ifdef RTE_NET_I40E
9541 : 0 : if (ret == -ENOTSUP)
9542 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
9543 : 0 : res->vf_id, is_on);
9544 : : #endif
9545 : : #ifdef RTE_NET_BNXT
9546 : 0 : if (ret == -ENOTSUP)
9547 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
9548 : 0 : res->vf_id, is_on);
9549 : : #endif
9550 : :
9551 : 0 : switch (ret) {
9552 : : case 0:
9553 : : break;
9554 : 0 : case -EINVAL:
9555 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9556 : : res->vf_id, is_on);
9557 : : break;
9558 : 0 : case -ENODEV:
9559 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9560 : : break;
9561 : 0 : case -ENOTSUP:
9562 : 0 : fprintf(stderr, "function not implemented\n");
9563 : : break;
9564 : 0 : default:
9565 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9566 : : }
9567 : : }
9568 : :
9569 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
9570 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
9571 : : .data = NULL,
9572 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
9573 : : .tokens = {
9574 : : (void *)&cmd_vf_mac_anti_spoof_set,
9575 : : (void *)&cmd_vf_mac_anti_spoof_vf,
9576 : : (void *)&cmd_vf_mac_anti_spoof_mac,
9577 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
9578 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
9579 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
9580 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
9581 : : NULL,
9582 : : },
9583 : : };
9584 : :
9585 : : /* vf vlan strip queue configuration */
9586 : :
9587 : : /* Common result structure for vf mac anti spoof */
9588 : : struct cmd_vf_vlan_stripq_result {
9589 : : cmdline_fixed_string_t set;
9590 : : cmdline_fixed_string_t vf;
9591 : : cmdline_fixed_string_t vlan;
9592 : : cmdline_fixed_string_t stripq;
9593 : : portid_t port_id;
9594 : : uint16_t vf_id;
9595 : : cmdline_fixed_string_t on_off;
9596 : : };
9597 : :
9598 : : /* Common CLI fields for vf vlan strip enable disable */
9599 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
9600 : : TOKEN_STRING_INITIALIZER
9601 : : (struct cmd_vf_vlan_stripq_result,
9602 : : set, "set");
9603 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
9604 : : TOKEN_STRING_INITIALIZER
9605 : : (struct cmd_vf_vlan_stripq_result,
9606 : : vf, "vf");
9607 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
9608 : : TOKEN_STRING_INITIALIZER
9609 : : (struct cmd_vf_vlan_stripq_result,
9610 : : vlan, "vlan");
9611 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
9612 : : TOKEN_STRING_INITIALIZER
9613 : : (struct cmd_vf_vlan_stripq_result,
9614 : : stripq, "stripq");
9615 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
9616 : : TOKEN_NUM_INITIALIZER
9617 : : (struct cmd_vf_vlan_stripq_result,
9618 : : port_id, RTE_UINT16);
9619 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
9620 : : TOKEN_NUM_INITIALIZER
9621 : : (struct cmd_vf_vlan_stripq_result,
9622 : : vf_id, RTE_UINT16);
9623 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
9624 : : TOKEN_STRING_INITIALIZER
9625 : : (struct cmd_vf_vlan_stripq_result,
9626 : : on_off, "on#off");
9627 : :
9628 : : static void
9629 : 0 : cmd_set_vf_vlan_stripq_parsed(
9630 : : void *parsed_result,
9631 : : __rte_unused struct cmdline *cl,
9632 : : __rte_unused void *data)
9633 : : {
9634 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
9635 : : int ret = -ENOTSUP;
9636 : :
9637 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9638 : :
9639 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9640 : : return;
9641 : :
9642 : : #ifdef RTE_NET_IXGBE
9643 : : if (ret == -ENOTSUP)
9644 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
9645 : 0 : res->vf_id, is_on);
9646 : : #endif
9647 : : #ifdef RTE_NET_I40E
9648 : 0 : if (ret == -ENOTSUP)
9649 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
9650 : 0 : res->vf_id, is_on);
9651 : : #endif
9652 : : #ifdef RTE_NET_BNXT
9653 : 0 : if (ret == -ENOTSUP)
9654 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
9655 : 0 : res->vf_id, is_on);
9656 : : #endif
9657 : :
9658 : 0 : switch (ret) {
9659 : : case 0:
9660 : : break;
9661 : 0 : case -EINVAL:
9662 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9663 : 0 : res->vf_id, is_on);
9664 : : break;
9665 : 0 : case -ENODEV:
9666 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9667 : : break;
9668 : 0 : case -ENOTSUP:
9669 : 0 : fprintf(stderr, "function not implemented\n");
9670 : : break;
9671 : 0 : default:
9672 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9673 : : }
9674 : : }
9675 : :
9676 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
9677 : : .f = cmd_set_vf_vlan_stripq_parsed,
9678 : : .data = NULL,
9679 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
9680 : : .tokens = {
9681 : : (void *)&cmd_vf_vlan_stripq_set,
9682 : : (void *)&cmd_vf_vlan_stripq_vf,
9683 : : (void *)&cmd_vf_vlan_stripq_vlan,
9684 : : (void *)&cmd_vf_vlan_stripq_stripq,
9685 : : (void *)&cmd_vf_vlan_stripq_port_id,
9686 : : (void *)&cmd_vf_vlan_stripq_vf_id,
9687 : : (void *)&cmd_vf_vlan_stripq_on_off,
9688 : : NULL,
9689 : : },
9690 : : };
9691 : :
9692 : : /* vf vlan insert configuration */
9693 : :
9694 : : /* Common result structure for vf vlan insert */
9695 : : struct cmd_vf_vlan_insert_result {
9696 : : cmdline_fixed_string_t set;
9697 : : cmdline_fixed_string_t vf;
9698 : : cmdline_fixed_string_t vlan;
9699 : : cmdline_fixed_string_t insert;
9700 : : portid_t port_id;
9701 : : uint16_t vf_id;
9702 : : uint16_t vlan_id;
9703 : : };
9704 : :
9705 : : /* Common CLI fields for vf vlan insert enable disable */
9706 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
9707 : : TOKEN_STRING_INITIALIZER
9708 : : (struct cmd_vf_vlan_insert_result,
9709 : : set, "set");
9710 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
9711 : : TOKEN_STRING_INITIALIZER
9712 : : (struct cmd_vf_vlan_insert_result,
9713 : : vf, "vf");
9714 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
9715 : : TOKEN_STRING_INITIALIZER
9716 : : (struct cmd_vf_vlan_insert_result,
9717 : : vlan, "vlan");
9718 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
9719 : : TOKEN_STRING_INITIALIZER
9720 : : (struct cmd_vf_vlan_insert_result,
9721 : : insert, "insert");
9722 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
9723 : : TOKEN_NUM_INITIALIZER
9724 : : (struct cmd_vf_vlan_insert_result,
9725 : : port_id, RTE_UINT16);
9726 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
9727 : : TOKEN_NUM_INITIALIZER
9728 : : (struct cmd_vf_vlan_insert_result,
9729 : : vf_id, RTE_UINT16);
9730 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
9731 : : TOKEN_NUM_INITIALIZER
9732 : : (struct cmd_vf_vlan_insert_result,
9733 : : vlan_id, RTE_UINT16);
9734 : :
9735 : : static void
9736 : 0 : cmd_set_vf_vlan_insert_parsed(
9737 : : void *parsed_result,
9738 : : __rte_unused struct cmdline *cl,
9739 : : __rte_unused void *data)
9740 : : {
9741 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
9742 : : int ret = -ENOTSUP;
9743 : :
9744 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9745 : : return;
9746 : :
9747 : : #ifdef RTE_NET_IXGBE
9748 : : if (ret == -ENOTSUP)
9749 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
9750 : 0 : res->vlan_id);
9751 : : #endif
9752 : : #ifdef RTE_NET_I40E
9753 : 0 : if (ret == -ENOTSUP)
9754 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
9755 : 0 : res->vlan_id);
9756 : : #endif
9757 : : #ifdef RTE_NET_BNXT
9758 : 0 : if (ret == -ENOTSUP)
9759 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
9760 : 0 : res->vlan_id);
9761 : : #endif
9762 : :
9763 : 0 : switch (ret) {
9764 : : case 0:
9765 : : break;
9766 : 0 : case -EINVAL:
9767 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
9768 : 0 : res->vf_id, res->vlan_id);
9769 : : break;
9770 : 0 : case -ENODEV:
9771 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9772 : : break;
9773 : 0 : case -ENOTSUP:
9774 : 0 : fprintf(stderr, "function not implemented\n");
9775 : : break;
9776 : 0 : default:
9777 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9778 : : }
9779 : : }
9780 : :
9781 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
9782 : : .f = cmd_set_vf_vlan_insert_parsed,
9783 : : .data = NULL,
9784 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
9785 : : .tokens = {
9786 : : (void *)&cmd_vf_vlan_insert_set,
9787 : : (void *)&cmd_vf_vlan_insert_vf,
9788 : : (void *)&cmd_vf_vlan_insert_vlan,
9789 : : (void *)&cmd_vf_vlan_insert_insert,
9790 : : (void *)&cmd_vf_vlan_insert_port_id,
9791 : : (void *)&cmd_vf_vlan_insert_vf_id,
9792 : : (void *)&cmd_vf_vlan_insert_vlan_id,
9793 : : NULL,
9794 : : },
9795 : : };
9796 : :
9797 : : /* tx loopback configuration */
9798 : :
9799 : : /* Common result structure for tx loopback */
9800 : : struct cmd_tx_loopback_result {
9801 : : cmdline_fixed_string_t set;
9802 : : cmdline_fixed_string_t tx;
9803 : : cmdline_fixed_string_t loopback;
9804 : : portid_t port_id;
9805 : : cmdline_fixed_string_t on_off;
9806 : : };
9807 : :
9808 : : /* Common CLI fields for tx loopback enable disable */
9809 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
9810 : : TOKEN_STRING_INITIALIZER
9811 : : (struct cmd_tx_loopback_result,
9812 : : set, "set");
9813 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
9814 : : TOKEN_STRING_INITIALIZER
9815 : : (struct cmd_tx_loopback_result,
9816 : : tx, "tx");
9817 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
9818 : : TOKEN_STRING_INITIALIZER
9819 : : (struct cmd_tx_loopback_result,
9820 : : loopback, "loopback");
9821 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
9822 : : TOKEN_NUM_INITIALIZER
9823 : : (struct cmd_tx_loopback_result,
9824 : : port_id, RTE_UINT16);
9825 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
9826 : : TOKEN_STRING_INITIALIZER
9827 : : (struct cmd_tx_loopback_result,
9828 : : on_off, "on#off");
9829 : :
9830 : : static void
9831 : 0 : cmd_set_tx_loopback_parsed(
9832 : : void *parsed_result,
9833 : : __rte_unused struct cmdline *cl,
9834 : : __rte_unused void *data)
9835 : : {
9836 : : struct cmd_tx_loopback_result *res = parsed_result;
9837 : : int ret = -ENOTSUP;
9838 : :
9839 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9840 : :
9841 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9842 : : return;
9843 : :
9844 : : #ifdef RTE_NET_IXGBE
9845 : : if (ret == -ENOTSUP)
9846 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
9847 : : #endif
9848 : : #ifdef RTE_NET_I40E
9849 : 0 : if (ret == -ENOTSUP)
9850 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
9851 : : #endif
9852 : : #ifdef RTE_NET_BNXT
9853 : 0 : if (ret == -ENOTSUP)
9854 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
9855 : : #endif
9856 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
9857 : 0 : if (ret == -ENOTSUP)
9858 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
9859 : : #endif
9860 : :
9861 : 0 : switch (ret) {
9862 : : case 0:
9863 : : break;
9864 : 0 : case -EINVAL:
9865 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9866 : : break;
9867 : 0 : case -ENODEV:
9868 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9869 : : break;
9870 : 0 : case -ENOTSUP:
9871 : 0 : fprintf(stderr, "function not implemented\n");
9872 : : break;
9873 : 0 : default:
9874 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9875 : : }
9876 : : }
9877 : :
9878 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
9879 : : .f = cmd_set_tx_loopback_parsed,
9880 : : .data = NULL,
9881 : : .help_str = "set tx loopback <port_id> on|off",
9882 : : .tokens = {
9883 : : (void *)&cmd_tx_loopback_set,
9884 : : (void *)&cmd_tx_loopback_tx,
9885 : : (void *)&cmd_tx_loopback_loopback,
9886 : : (void *)&cmd_tx_loopback_port_id,
9887 : : (void *)&cmd_tx_loopback_on_off,
9888 : : NULL,
9889 : : },
9890 : : };
9891 : :
9892 : : /* all queues drop enable configuration */
9893 : :
9894 : : /* Common result structure for all queues drop enable */
9895 : : struct cmd_all_queues_drop_en_result {
9896 : : cmdline_fixed_string_t set;
9897 : : cmdline_fixed_string_t all;
9898 : : cmdline_fixed_string_t queues;
9899 : : cmdline_fixed_string_t drop;
9900 : : portid_t port_id;
9901 : : cmdline_fixed_string_t on_off;
9902 : : };
9903 : :
9904 : : /* Common CLI fields for tx loopback enable disable */
9905 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
9906 : : TOKEN_STRING_INITIALIZER
9907 : : (struct cmd_all_queues_drop_en_result,
9908 : : set, "set");
9909 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
9910 : : TOKEN_STRING_INITIALIZER
9911 : : (struct cmd_all_queues_drop_en_result,
9912 : : all, "all");
9913 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
9914 : : TOKEN_STRING_INITIALIZER
9915 : : (struct cmd_all_queues_drop_en_result,
9916 : : queues, "queues");
9917 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
9918 : : TOKEN_STRING_INITIALIZER
9919 : : (struct cmd_all_queues_drop_en_result,
9920 : : drop, "drop");
9921 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
9922 : : TOKEN_NUM_INITIALIZER
9923 : : (struct cmd_all_queues_drop_en_result,
9924 : : port_id, RTE_UINT16);
9925 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
9926 : : TOKEN_STRING_INITIALIZER
9927 : : (struct cmd_all_queues_drop_en_result,
9928 : : on_off, "on#off");
9929 : :
9930 : : static void
9931 : 0 : cmd_set_all_queues_drop_en_parsed(
9932 : : void *parsed_result,
9933 : : __rte_unused struct cmdline *cl,
9934 : : __rte_unused void *data)
9935 : : {
9936 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
9937 : : int ret = -ENOTSUP;
9938 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9939 : :
9940 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9941 : : return;
9942 : :
9943 : : #ifdef RTE_NET_IXGBE
9944 : : if (ret == -ENOTSUP)
9945 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
9946 : : #endif
9947 : : #ifdef RTE_NET_BNXT
9948 : 0 : if (ret == -ENOTSUP)
9949 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
9950 : : #endif
9951 : 0 : switch (ret) {
9952 : : case 0:
9953 : : break;
9954 : 0 : case -EINVAL:
9955 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9956 : : break;
9957 : 0 : case -ENODEV:
9958 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9959 : : break;
9960 : 0 : case -ENOTSUP:
9961 : 0 : fprintf(stderr, "function not implemented\n");
9962 : : break;
9963 : 0 : default:
9964 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9965 : : }
9966 : : }
9967 : :
9968 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
9969 : : .f = cmd_set_all_queues_drop_en_parsed,
9970 : : .data = NULL,
9971 : : .help_str = "set all queues drop <port_id> on|off",
9972 : : .tokens = {
9973 : : (void *)&cmd_all_queues_drop_en_set,
9974 : : (void *)&cmd_all_queues_drop_en_all,
9975 : : (void *)&cmd_all_queues_drop_en_queues,
9976 : : (void *)&cmd_all_queues_drop_en_drop,
9977 : : (void *)&cmd_all_queues_drop_en_port_id,
9978 : : (void *)&cmd_all_queues_drop_en_on_off,
9979 : : NULL,
9980 : : },
9981 : : };
9982 : :
9983 : : /* vf mac address configuration */
9984 : :
9985 : : /* Common result structure for vf mac address */
9986 : : struct cmd_set_vf_mac_addr_result {
9987 : : cmdline_fixed_string_t set;
9988 : : cmdline_fixed_string_t vf;
9989 : : cmdline_fixed_string_t mac;
9990 : : cmdline_fixed_string_t addr;
9991 : : portid_t port_id;
9992 : : uint16_t vf_id;
9993 : : struct rte_ether_addr mac_addr;
9994 : :
9995 : : };
9996 : :
9997 : : /* Common CLI fields for vf split drop enable disable */
9998 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
9999 : : TOKEN_STRING_INITIALIZER
10000 : : (struct cmd_set_vf_mac_addr_result,
10001 : : set, "set");
10002 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
10003 : : TOKEN_STRING_INITIALIZER
10004 : : (struct cmd_set_vf_mac_addr_result,
10005 : : vf, "vf");
10006 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
10007 : : TOKEN_STRING_INITIALIZER
10008 : : (struct cmd_set_vf_mac_addr_result,
10009 : : mac, "mac");
10010 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
10011 : : TOKEN_STRING_INITIALIZER
10012 : : (struct cmd_set_vf_mac_addr_result,
10013 : : addr, "addr");
10014 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
10015 : : TOKEN_NUM_INITIALIZER
10016 : : (struct cmd_set_vf_mac_addr_result,
10017 : : port_id, RTE_UINT16);
10018 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
10019 : : TOKEN_NUM_INITIALIZER
10020 : : (struct cmd_set_vf_mac_addr_result,
10021 : : vf_id, RTE_UINT16);
10022 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
10023 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
10024 : : mac_addr);
10025 : :
10026 : : static void
10027 : 0 : cmd_set_vf_mac_addr_parsed(
10028 : : void *parsed_result,
10029 : : __rte_unused struct cmdline *cl,
10030 : : __rte_unused void *data)
10031 : : {
10032 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
10033 : : int ret = -ENOTSUP;
10034 : :
10035 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10036 : : return;
10037 : :
10038 : : #ifdef RTE_NET_IXGBE
10039 : : if (ret == -ENOTSUP)
10040 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
10041 : : &res->mac_addr);
10042 : : #endif
10043 : : #ifdef RTE_NET_I40E
10044 : 0 : if (ret == -ENOTSUP)
10045 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
10046 : : &res->mac_addr);
10047 : : #endif
10048 : : #ifdef RTE_NET_BNXT
10049 : 0 : if (ret == -ENOTSUP)
10050 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
10051 : : &res->mac_addr);
10052 : : #endif
10053 : :
10054 : 0 : switch (ret) {
10055 : : case 0:
10056 : : break;
10057 : 0 : case -EINVAL:
10058 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
10059 : : break;
10060 : 0 : case -ENODEV:
10061 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10062 : : break;
10063 : 0 : case -ENOTSUP:
10064 : 0 : fprintf(stderr, "function not implemented\n");
10065 : : break;
10066 : 0 : default:
10067 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10068 : : }
10069 : : }
10070 : :
10071 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
10072 : : .f = cmd_set_vf_mac_addr_parsed,
10073 : : .data = NULL,
10074 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
10075 : : .tokens = {
10076 : : (void *)&cmd_set_vf_mac_addr_set,
10077 : : (void *)&cmd_set_vf_mac_addr_vf,
10078 : : (void *)&cmd_set_vf_mac_addr_mac,
10079 : : (void *)&cmd_set_vf_mac_addr_addr,
10080 : : (void *)&cmd_set_vf_mac_addr_port_id,
10081 : : (void *)&cmd_set_vf_mac_addr_vf_id,
10082 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
10083 : : NULL,
10084 : : },
10085 : : };
10086 : :
10087 : : /** Set VXLAN encapsulation details */
10088 : : struct cmd_set_vxlan_result {
10089 : : cmdline_fixed_string_t set;
10090 : : cmdline_fixed_string_t vxlan;
10091 : : cmdline_fixed_string_t pos_token;
10092 : : cmdline_fixed_string_t ip_version;
10093 : : uint32_t vlan_present:1;
10094 : : uint32_t vni;
10095 : : uint16_t udp_src;
10096 : : uint16_t udp_dst;
10097 : : cmdline_ipaddr_t ip_src;
10098 : : cmdline_ipaddr_t ip_dst;
10099 : : uint16_t tci;
10100 : : uint8_t tos;
10101 : : uint8_t ttl;
10102 : : struct rte_ether_addr eth_src;
10103 : : struct rte_ether_addr eth_dst;
10104 : : };
10105 : :
10106 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
10107 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
10108 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
10109 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
10110 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
10111 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10112 : : "vxlan-tos-ttl");
10113 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
10114 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
10115 : : "vxlan-with-vlan");
10116 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
10117 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10118 : : "ip-version");
10119 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
10120 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
10121 : : "ipv4#ipv6");
10122 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
10123 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10124 : : "vni");
10125 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
10126 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
10127 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
10128 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10129 : : "udp-src");
10130 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
10131 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
10132 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
10133 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10134 : : "udp-dst");
10135 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
10136 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
10137 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
10138 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10139 : : "ip-tos");
10140 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
10141 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
10142 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
10143 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10144 : : "ip-ttl");
10145 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
10146 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
10147 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
10148 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10149 : : "ip-src");
10150 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
10151 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
10152 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
10153 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10154 : : "ip-dst");
10155 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
10156 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
10157 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
10158 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10159 : : "vlan-tci");
10160 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
10161 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
10162 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
10163 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10164 : : "eth-src");
10165 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
10166 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
10167 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
10168 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
10169 : : "eth-dst");
10170 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
10171 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
10172 : :
10173 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
10174 : : __rte_unused struct cmdline *cl,
10175 : : __rte_unused void *data)
10176 : : {
10177 : : struct cmd_set_vxlan_result *res = parsed_result;
10178 : : union {
10179 : : uint32_t vxlan_id;
10180 : : uint8_t vni[4];
10181 : 0 : } id = {
10182 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
10183 : : };
10184 : :
10185 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
10186 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
10187 : 0 : vxlan_encap_conf.select_vlan = 0;
10188 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
10189 : 0 : vxlan_encap_conf.select_vlan = 1;
10190 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
10191 : 0 : vxlan_encap_conf.select_vlan = 0;
10192 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
10193 : : }
10194 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10195 : 0 : vxlan_encap_conf.select_ipv4 = 1;
10196 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10197 : 0 : vxlan_encap_conf.select_ipv4 = 0;
10198 : : else
10199 : 0 : return;
10200 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
10201 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10202 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10203 : 0 : vxlan_encap_conf.ip_tos = res->tos;
10204 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
10205 : 0 : if (vxlan_encap_conf.select_ipv4) {
10206 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
10207 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
10208 : : } else {
10209 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
10210 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
10211 : : }
10212 : 0 : if (vxlan_encap_conf.select_vlan)
10213 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10214 : 0 : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
10215 : : RTE_ETHER_ADDR_LEN);
10216 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10217 : : RTE_ETHER_ADDR_LEN);
10218 : : }
10219 : :
10220 : : static cmdline_parse_inst_t cmd_set_vxlan = {
10221 : : .f = cmd_set_vxlan_parsed,
10222 : : .data = NULL,
10223 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
10224 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
10225 : : " eth-src <eth-src> eth-dst <eth-dst>",
10226 : : .tokens = {
10227 : : (void *)&cmd_set_vxlan_set,
10228 : : (void *)&cmd_set_vxlan_vxlan,
10229 : : (void *)&cmd_set_vxlan_ip_version,
10230 : : (void *)&cmd_set_vxlan_ip_version_value,
10231 : : (void *)&cmd_set_vxlan_vni,
10232 : : (void *)&cmd_set_vxlan_vni_value,
10233 : : (void *)&cmd_set_vxlan_udp_src,
10234 : : (void *)&cmd_set_vxlan_udp_src_value,
10235 : : (void *)&cmd_set_vxlan_udp_dst,
10236 : : (void *)&cmd_set_vxlan_udp_dst_value,
10237 : : (void *)&cmd_set_vxlan_ip_src,
10238 : : (void *)&cmd_set_vxlan_ip_src_value,
10239 : : (void *)&cmd_set_vxlan_ip_dst,
10240 : : (void *)&cmd_set_vxlan_ip_dst_value,
10241 : : (void *)&cmd_set_vxlan_eth_src,
10242 : : (void *)&cmd_set_vxlan_eth_src_value,
10243 : : (void *)&cmd_set_vxlan_eth_dst,
10244 : : (void *)&cmd_set_vxlan_eth_dst_value,
10245 : : NULL,
10246 : : },
10247 : : };
10248 : :
10249 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
10250 : : .f = cmd_set_vxlan_parsed,
10251 : : .data = NULL,
10252 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
10253 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
10254 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10255 : : " eth-dst <eth-dst>",
10256 : : .tokens = {
10257 : : (void *)&cmd_set_vxlan_set,
10258 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
10259 : : (void *)&cmd_set_vxlan_ip_version,
10260 : : (void *)&cmd_set_vxlan_ip_version_value,
10261 : : (void *)&cmd_set_vxlan_vni,
10262 : : (void *)&cmd_set_vxlan_vni_value,
10263 : : (void *)&cmd_set_vxlan_udp_src,
10264 : : (void *)&cmd_set_vxlan_udp_src_value,
10265 : : (void *)&cmd_set_vxlan_udp_dst,
10266 : : (void *)&cmd_set_vxlan_udp_dst_value,
10267 : : (void *)&cmd_set_vxlan_ip_tos,
10268 : : (void *)&cmd_set_vxlan_ip_tos_value,
10269 : : (void *)&cmd_set_vxlan_ip_ttl,
10270 : : (void *)&cmd_set_vxlan_ip_ttl_value,
10271 : : (void *)&cmd_set_vxlan_ip_src,
10272 : : (void *)&cmd_set_vxlan_ip_src_value,
10273 : : (void *)&cmd_set_vxlan_ip_dst,
10274 : : (void *)&cmd_set_vxlan_ip_dst_value,
10275 : : (void *)&cmd_set_vxlan_eth_src,
10276 : : (void *)&cmd_set_vxlan_eth_src_value,
10277 : : (void *)&cmd_set_vxlan_eth_dst,
10278 : : (void *)&cmd_set_vxlan_eth_dst_value,
10279 : : NULL,
10280 : : },
10281 : : };
10282 : :
10283 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
10284 : : .f = cmd_set_vxlan_parsed,
10285 : : .data = NULL,
10286 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
10287 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
10288 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
10289 : : " <eth-dst>",
10290 : : .tokens = {
10291 : : (void *)&cmd_set_vxlan_set,
10292 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
10293 : : (void *)&cmd_set_vxlan_ip_version,
10294 : : (void *)&cmd_set_vxlan_ip_version_value,
10295 : : (void *)&cmd_set_vxlan_vni,
10296 : : (void *)&cmd_set_vxlan_vni_value,
10297 : : (void *)&cmd_set_vxlan_udp_src,
10298 : : (void *)&cmd_set_vxlan_udp_src_value,
10299 : : (void *)&cmd_set_vxlan_udp_dst,
10300 : : (void *)&cmd_set_vxlan_udp_dst_value,
10301 : : (void *)&cmd_set_vxlan_ip_src,
10302 : : (void *)&cmd_set_vxlan_ip_src_value,
10303 : : (void *)&cmd_set_vxlan_ip_dst,
10304 : : (void *)&cmd_set_vxlan_ip_dst_value,
10305 : : (void *)&cmd_set_vxlan_vlan,
10306 : : (void *)&cmd_set_vxlan_vlan_value,
10307 : : (void *)&cmd_set_vxlan_eth_src,
10308 : : (void *)&cmd_set_vxlan_eth_src_value,
10309 : : (void *)&cmd_set_vxlan_eth_dst,
10310 : : (void *)&cmd_set_vxlan_eth_dst_value,
10311 : : NULL,
10312 : : },
10313 : : };
10314 : :
10315 : : /** Set NVGRE encapsulation details */
10316 : : struct cmd_set_nvgre_result {
10317 : : cmdline_fixed_string_t set;
10318 : : cmdline_fixed_string_t nvgre;
10319 : : cmdline_fixed_string_t pos_token;
10320 : : cmdline_fixed_string_t ip_version;
10321 : : uint32_t tni;
10322 : : cmdline_ipaddr_t ip_src;
10323 : : cmdline_ipaddr_t ip_dst;
10324 : : uint16_t tci;
10325 : : struct rte_ether_addr eth_src;
10326 : : struct rte_ether_addr eth_dst;
10327 : : };
10328 : :
10329 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
10330 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
10331 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
10332 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
10333 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
10334 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
10335 : : "nvgre-with-vlan");
10336 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
10337 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10338 : : "ip-version");
10339 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
10340 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
10341 : : "ipv4#ipv6");
10342 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
10343 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10344 : : "tni");
10345 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
10346 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
10347 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
10348 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10349 : : "ip-src");
10350 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
10351 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
10352 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
10353 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10354 : : "ip-dst");
10355 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
10356 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
10357 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
10358 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10359 : : "vlan-tci");
10360 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
10361 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
10362 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
10363 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10364 : : "eth-src");
10365 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
10366 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
10367 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
10368 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
10369 : : "eth-dst");
10370 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
10371 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
10372 : :
10373 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
10374 : : __rte_unused struct cmdline *cl,
10375 : : __rte_unused void *data)
10376 : : {
10377 : : struct cmd_set_nvgre_result *res = parsed_result;
10378 : : union {
10379 : : uint32_t nvgre_tni;
10380 : : uint8_t tni[4];
10381 : 0 : } id = {
10382 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
10383 : : };
10384 : :
10385 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
10386 : 0 : nvgre_encap_conf.select_vlan = 0;
10387 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
10388 : 0 : nvgre_encap_conf.select_vlan = 1;
10389 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10390 : 0 : nvgre_encap_conf.select_ipv4 = 1;
10391 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10392 : 0 : nvgre_encap_conf.select_ipv4 = 0;
10393 : : else
10394 : 0 : return;
10395 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
10396 : 0 : if (nvgre_encap_conf.select_ipv4) {
10397 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
10398 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
10399 : : } else {
10400 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
10401 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
10402 : : }
10403 : 0 : if (nvgre_encap_conf.select_vlan)
10404 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10405 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
10406 : : RTE_ETHER_ADDR_LEN);
10407 : 0 : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10408 : : RTE_ETHER_ADDR_LEN);
10409 : : }
10410 : :
10411 : : static cmdline_parse_inst_t cmd_set_nvgre = {
10412 : : .f = cmd_set_nvgre_parsed,
10413 : : .data = NULL,
10414 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
10415 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10416 : : " eth-dst <eth-dst>",
10417 : : .tokens = {
10418 : : (void *)&cmd_set_nvgre_set,
10419 : : (void *)&cmd_set_nvgre_nvgre,
10420 : : (void *)&cmd_set_nvgre_ip_version,
10421 : : (void *)&cmd_set_nvgre_ip_version_value,
10422 : : (void *)&cmd_set_nvgre_tni,
10423 : : (void *)&cmd_set_nvgre_tni_value,
10424 : : (void *)&cmd_set_nvgre_ip_src,
10425 : : (void *)&cmd_set_nvgre_ip_src_value,
10426 : : (void *)&cmd_set_nvgre_ip_dst,
10427 : : (void *)&cmd_set_nvgre_ip_dst_value,
10428 : : (void *)&cmd_set_nvgre_eth_src,
10429 : : (void *)&cmd_set_nvgre_eth_src_value,
10430 : : (void *)&cmd_set_nvgre_eth_dst,
10431 : : (void *)&cmd_set_nvgre_eth_dst_value,
10432 : : NULL,
10433 : : },
10434 : : };
10435 : :
10436 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
10437 : : .f = cmd_set_nvgre_parsed,
10438 : : .data = NULL,
10439 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
10440 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10441 : : " eth-src <eth-src> eth-dst <eth-dst>",
10442 : : .tokens = {
10443 : : (void *)&cmd_set_nvgre_set,
10444 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
10445 : : (void *)&cmd_set_nvgre_ip_version,
10446 : : (void *)&cmd_set_nvgre_ip_version_value,
10447 : : (void *)&cmd_set_nvgre_tni,
10448 : : (void *)&cmd_set_nvgre_tni_value,
10449 : : (void *)&cmd_set_nvgre_ip_src,
10450 : : (void *)&cmd_set_nvgre_ip_src_value,
10451 : : (void *)&cmd_set_nvgre_ip_dst,
10452 : : (void *)&cmd_set_nvgre_ip_dst_value,
10453 : : (void *)&cmd_set_nvgre_vlan,
10454 : : (void *)&cmd_set_nvgre_vlan_value,
10455 : : (void *)&cmd_set_nvgre_eth_src,
10456 : : (void *)&cmd_set_nvgre_eth_src_value,
10457 : : (void *)&cmd_set_nvgre_eth_dst,
10458 : : (void *)&cmd_set_nvgre_eth_dst_value,
10459 : : NULL,
10460 : : },
10461 : : };
10462 : :
10463 : : /** Set L2 encapsulation details */
10464 : : struct cmd_set_l2_encap_result {
10465 : : cmdline_fixed_string_t set;
10466 : : cmdline_fixed_string_t l2_encap;
10467 : : cmdline_fixed_string_t pos_token;
10468 : : cmdline_fixed_string_t ip_version;
10469 : : uint32_t vlan_present:1;
10470 : : uint16_t tci;
10471 : : struct rte_ether_addr eth_src;
10472 : : struct rte_ether_addr eth_dst;
10473 : : };
10474 : :
10475 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
10476 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
10477 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
10478 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
10479 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
10480 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
10481 : : "l2_encap-with-vlan");
10482 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
10483 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10484 : : "ip-version");
10485 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
10486 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
10487 : : "ipv4#ipv6");
10488 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
10489 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10490 : : "vlan-tci");
10491 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
10492 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
10493 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
10494 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10495 : : "eth-src");
10496 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
10497 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
10498 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
10499 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
10500 : : "eth-dst");
10501 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
10502 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
10503 : :
10504 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
10505 : : __rte_unused struct cmdline *cl,
10506 : : __rte_unused void *data)
10507 : : {
10508 : : struct cmd_set_l2_encap_result *res = parsed_result;
10509 : :
10510 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
10511 : 0 : l2_encap_conf.select_vlan = 0;
10512 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
10513 : 0 : l2_encap_conf.select_vlan = 1;
10514 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10515 : 0 : l2_encap_conf.select_ipv4 = 1;
10516 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10517 : 0 : l2_encap_conf.select_ipv4 = 0;
10518 : : else
10519 : : return;
10520 : 0 : if (l2_encap_conf.select_vlan)
10521 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10522 : 0 : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
10523 : : RTE_ETHER_ADDR_LEN);
10524 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10525 : : RTE_ETHER_ADDR_LEN);
10526 : : }
10527 : :
10528 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
10529 : : .f = cmd_set_l2_encap_parsed,
10530 : : .data = NULL,
10531 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
10532 : : " eth-src <eth-src> eth-dst <eth-dst>",
10533 : : .tokens = {
10534 : : (void *)&cmd_set_l2_encap_set,
10535 : : (void *)&cmd_set_l2_encap_l2_encap,
10536 : : (void *)&cmd_set_l2_encap_ip_version,
10537 : : (void *)&cmd_set_l2_encap_ip_version_value,
10538 : : (void *)&cmd_set_l2_encap_eth_src,
10539 : : (void *)&cmd_set_l2_encap_eth_src_value,
10540 : : (void *)&cmd_set_l2_encap_eth_dst,
10541 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10542 : : NULL,
10543 : : },
10544 : : };
10545 : :
10546 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
10547 : : .f = cmd_set_l2_encap_parsed,
10548 : : .data = NULL,
10549 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
10550 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10551 : : .tokens = {
10552 : : (void *)&cmd_set_l2_encap_set,
10553 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
10554 : : (void *)&cmd_set_l2_encap_ip_version,
10555 : : (void *)&cmd_set_l2_encap_ip_version_value,
10556 : : (void *)&cmd_set_l2_encap_vlan,
10557 : : (void *)&cmd_set_l2_encap_vlan_value,
10558 : : (void *)&cmd_set_l2_encap_eth_src,
10559 : : (void *)&cmd_set_l2_encap_eth_src_value,
10560 : : (void *)&cmd_set_l2_encap_eth_dst,
10561 : : (void *)&cmd_set_l2_encap_eth_dst_value,
10562 : : NULL,
10563 : : },
10564 : : };
10565 : :
10566 : : /** Set L2 decapsulation details */
10567 : : struct cmd_set_l2_decap_result {
10568 : : cmdline_fixed_string_t set;
10569 : : cmdline_fixed_string_t l2_decap;
10570 : : cmdline_fixed_string_t pos_token;
10571 : : uint32_t vlan_present:1;
10572 : : };
10573 : :
10574 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
10575 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
10576 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
10577 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10578 : : "l2_decap");
10579 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
10580 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
10581 : : "l2_decap-with-vlan");
10582 : :
10583 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
10584 : : __rte_unused struct cmdline *cl,
10585 : : __rte_unused void *data)
10586 : : {
10587 : : struct cmd_set_l2_decap_result *res = parsed_result;
10588 : :
10589 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
10590 : 0 : l2_decap_conf.select_vlan = 0;
10591 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
10592 : 0 : l2_decap_conf.select_vlan = 1;
10593 : 0 : }
10594 : :
10595 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
10596 : : .f = cmd_set_l2_decap_parsed,
10597 : : .data = NULL,
10598 : : .help_str = "set l2_decap",
10599 : : .tokens = {
10600 : : (void *)&cmd_set_l2_decap_set,
10601 : : (void *)&cmd_set_l2_decap_l2_decap,
10602 : : NULL,
10603 : : },
10604 : : };
10605 : :
10606 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
10607 : : .f = cmd_set_l2_decap_parsed,
10608 : : .data = NULL,
10609 : : .help_str = "set l2_decap-with-vlan",
10610 : : .tokens = {
10611 : : (void *)&cmd_set_l2_decap_set,
10612 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
10613 : : NULL,
10614 : : },
10615 : : };
10616 : :
10617 : : /** Set MPLSoGRE encapsulation details */
10618 : : struct cmd_set_mplsogre_encap_result {
10619 : : cmdline_fixed_string_t set;
10620 : : cmdline_fixed_string_t mplsogre;
10621 : : cmdline_fixed_string_t pos_token;
10622 : : cmdline_fixed_string_t ip_version;
10623 : : uint32_t vlan_present:1;
10624 : : uint32_t label;
10625 : : cmdline_ipaddr_t ip_src;
10626 : : cmdline_ipaddr_t ip_dst;
10627 : : uint16_t tci;
10628 : : struct rte_ether_addr eth_src;
10629 : : struct rte_ether_addr eth_dst;
10630 : : };
10631 : :
10632 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
10633 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
10634 : : "set");
10635 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
10636 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
10637 : : "mplsogre_encap");
10638 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
10639 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10640 : : mplsogre, "mplsogre_encap-with-vlan");
10641 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
10642 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10643 : : pos_token, "ip-version");
10644 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
10645 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10646 : : ip_version, "ipv4#ipv6");
10647 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
10648 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10649 : : pos_token, "label");
10650 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
10651 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
10652 : : RTE_UINT32);
10653 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
10654 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10655 : : pos_token, "ip-src");
10656 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
10657 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
10658 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
10659 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10660 : : pos_token, "ip-dst");
10661 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
10662 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
10663 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
10664 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10665 : : pos_token, "vlan-tci");
10666 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
10667 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
10668 : : RTE_UINT16);
10669 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
10670 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10671 : : pos_token, "eth-src");
10672 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
10673 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10674 : : eth_src);
10675 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
10676 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10677 : : pos_token, "eth-dst");
10678 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
10679 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10680 : : eth_dst);
10681 : :
10682 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
10683 : : __rte_unused struct cmdline *cl,
10684 : : __rte_unused void *data)
10685 : : {
10686 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
10687 : : union {
10688 : : uint32_t mplsogre_label;
10689 : : uint8_t label[4];
10690 : 0 : } id = {
10691 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
10692 : : };
10693 : :
10694 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
10695 : 0 : mplsogre_encap_conf.select_vlan = 0;
10696 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
10697 : 0 : mplsogre_encap_conf.select_vlan = 1;
10698 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10699 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
10700 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10701 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
10702 : : else
10703 : 0 : return;
10704 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
10705 : 0 : if (mplsogre_encap_conf.select_ipv4) {
10706 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
10707 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
10708 : : } else {
10709 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
10710 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
10711 : : }
10712 : 0 : if (mplsogre_encap_conf.select_vlan)
10713 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10714 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
10715 : : RTE_ETHER_ADDR_LEN);
10716 : 0 : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10717 : : RTE_ETHER_ADDR_LEN);
10718 : : }
10719 : :
10720 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
10721 : : .f = cmd_set_mplsogre_encap_parsed,
10722 : : .data = NULL,
10723 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
10724 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10725 : : " eth-dst <eth-dst>",
10726 : : .tokens = {
10727 : : (void *)&cmd_set_mplsogre_encap_set,
10728 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
10729 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10730 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10731 : : (void *)&cmd_set_mplsogre_encap_label,
10732 : : (void *)&cmd_set_mplsogre_encap_label_value,
10733 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10734 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10735 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10736 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10737 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10738 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10739 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10740 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10741 : : NULL,
10742 : : },
10743 : : };
10744 : :
10745 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
10746 : : .f = cmd_set_mplsogre_encap_parsed,
10747 : : .data = NULL,
10748 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
10749 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
10750 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10751 : : .tokens = {
10752 : : (void *)&cmd_set_mplsogre_encap_set,
10753 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
10754 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10755 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10756 : : (void *)&cmd_set_mplsogre_encap_label,
10757 : : (void *)&cmd_set_mplsogre_encap_label_value,
10758 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10759 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10760 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10761 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10762 : : (void *)&cmd_set_mplsogre_encap_vlan,
10763 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
10764 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10765 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10766 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10767 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10768 : : NULL,
10769 : : },
10770 : : };
10771 : :
10772 : : /** Set MPLSoGRE decapsulation details */
10773 : : struct cmd_set_mplsogre_decap_result {
10774 : : cmdline_fixed_string_t set;
10775 : : cmdline_fixed_string_t mplsogre;
10776 : : cmdline_fixed_string_t pos_token;
10777 : : cmdline_fixed_string_t ip_version;
10778 : : uint32_t vlan_present:1;
10779 : : };
10780 : :
10781 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
10782 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
10783 : : "set");
10784 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
10785 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
10786 : : "mplsogre_decap");
10787 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
10788 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10789 : : mplsogre, "mplsogre_decap-with-vlan");
10790 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
10791 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10792 : : pos_token, "ip-version");
10793 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
10794 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10795 : : ip_version, "ipv4#ipv6");
10796 : :
10797 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
10798 : : __rte_unused struct cmdline *cl,
10799 : : __rte_unused void *data)
10800 : : {
10801 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
10802 : :
10803 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
10804 : 0 : mplsogre_decap_conf.select_vlan = 0;
10805 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
10806 : 0 : mplsogre_decap_conf.select_vlan = 1;
10807 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10808 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
10809 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10810 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
10811 : 0 : }
10812 : :
10813 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
10814 : : .f = cmd_set_mplsogre_decap_parsed,
10815 : : .data = NULL,
10816 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
10817 : : .tokens = {
10818 : : (void *)&cmd_set_mplsogre_decap_set,
10819 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
10820 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10821 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10822 : : NULL,
10823 : : },
10824 : : };
10825 : :
10826 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
10827 : : .f = cmd_set_mplsogre_decap_parsed,
10828 : : .data = NULL,
10829 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
10830 : : .tokens = {
10831 : : (void *)&cmd_set_mplsogre_decap_set,
10832 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
10833 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10834 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10835 : : NULL,
10836 : : },
10837 : : };
10838 : :
10839 : : /** Set MPLSoUDP encapsulation details */
10840 : : struct cmd_set_mplsoudp_encap_result {
10841 : : cmdline_fixed_string_t set;
10842 : : cmdline_fixed_string_t mplsoudp;
10843 : : cmdline_fixed_string_t pos_token;
10844 : : cmdline_fixed_string_t ip_version;
10845 : : uint32_t vlan_present:1;
10846 : : uint32_t label;
10847 : : uint16_t udp_src;
10848 : : uint16_t udp_dst;
10849 : : cmdline_ipaddr_t ip_src;
10850 : : cmdline_ipaddr_t ip_dst;
10851 : : uint16_t tci;
10852 : : struct rte_ether_addr eth_src;
10853 : : struct rte_ether_addr eth_dst;
10854 : : };
10855 : :
10856 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
10857 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
10858 : : "set");
10859 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
10860 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
10861 : : "mplsoudp_encap");
10862 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
10863 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10864 : : mplsoudp, "mplsoudp_encap-with-vlan");
10865 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
10866 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10867 : : pos_token, "ip-version");
10868 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
10869 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10870 : : ip_version, "ipv4#ipv6");
10871 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
10872 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10873 : : pos_token, "label");
10874 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
10875 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
10876 : : RTE_UINT32);
10877 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
10878 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10879 : : pos_token, "udp-src");
10880 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
10881 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
10882 : : RTE_UINT16);
10883 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
10884 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10885 : : pos_token, "udp-dst");
10886 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
10887 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
10888 : : RTE_UINT16);
10889 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
10890 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10891 : : pos_token, "ip-src");
10892 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
10893 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
10894 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
10895 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10896 : : pos_token, "ip-dst");
10897 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
10898 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
10899 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
10900 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10901 : : pos_token, "vlan-tci");
10902 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
10903 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
10904 : : RTE_UINT16);
10905 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
10906 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10907 : : pos_token, "eth-src");
10908 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
10909 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10910 : : eth_src);
10911 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
10912 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10913 : : pos_token, "eth-dst");
10914 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
10915 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10916 : : eth_dst);
10917 : :
10918 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
10919 : : __rte_unused struct cmdline *cl,
10920 : : __rte_unused void *data)
10921 : : {
10922 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
10923 : : union {
10924 : : uint32_t mplsoudp_label;
10925 : : uint8_t label[4];
10926 : 0 : } id = {
10927 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
10928 : : };
10929 : :
10930 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
10931 : 0 : mplsoudp_encap_conf.select_vlan = 0;
10932 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
10933 : 0 : mplsoudp_encap_conf.select_vlan = 1;
10934 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10935 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
10936 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10937 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
10938 : : else
10939 : 0 : return;
10940 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
10941 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10942 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10943 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10944 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
10945 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
10946 : : } else {
10947 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
10948 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
10949 : : }
10950 : 0 : if (mplsoudp_encap_conf.select_vlan)
10951 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10952 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
10953 : : RTE_ETHER_ADDR_LEN);
10954 : 0 : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10955 : : RTE_ETHER_ADDR_LEN);
10956 : : }
10957 : :
10958 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
10959 : : .f = cmd_set_mplsoudp_encap_parsed,
10960 : : .data = NULL,
10961 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
10962 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
10963 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
10964 : : .tokens = {
10965 : : (void *)&cmd_set_mplsoudp_encap_set,
10966 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
10967 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10968 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10969 : : (void *)&cmd_set_mplsoudp_encap_label,
10970 : : (void *)&cmd_set_mplsoudp_encap_label_value,
10971 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
10972 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
10973 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
10974 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10975 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
10976 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
10977 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
10978 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10979 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
10980 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
10981 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
10982 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10983 : : NULL,
10984 : : },
10985 : : };
10986 : :
10987 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
10988 : : .f = cmd_set_mplsoudp_encap_parsed,
10989 : : .data = NULL,
10990 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
10991 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
10992 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10993 : : " eth-src <eth-src> eth-dst <eth-dst>",
10994 : : .tokens = {
10995 : : (void *)&cmd_set_mplsoudp_encap_set,
10996 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
10997 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10998 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10999 : : (void *)&cmd_set_mplsoudp_encap_label,
11000 : : (void *)&cmd_set_mplsoudp_encap_label_value,
11001 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
11002 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
11003 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
11004 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
11005 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
11006 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
11007 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
11008 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
11009 : : (void *)&cmd_set_mplsoudp_encap_vlan,
11010 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
11011 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
11012 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
11013 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
11014 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
11015 : : NULL,
11016 : : },
11017 : : };
11018 : :
11019 : : /** Set MPLSoUDP decapsulation details */
11020 : : struct cmd_set_mplsoudp_decap_result {
11021 : : cmdline_fixed_string_t set;
11022 : : cmdline_fixed_string_t mplsoudp;
11023 : : cmdline_fixed_string_t pos_token;
11024 : : cmdline_fixed_string_t ip_version;
11025 : : uint32_t vlan_present:1;
11026 : : };
11027 : :
11028 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
11029 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
11030 : : "set");
11031 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
11032 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
11033 : : "mplsoudp_decap");
11034 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
11035 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11036 : : mplsoudp, "mplsoudp_decap-with-vlan");
11037 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
11038 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11039 : : pos_token, "ip-version");
11040 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
11041 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
11042 : : ip_version, "ipv4#ipv6");
11043 : :
11044 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
11045 : : __rte_unused struct cmdline *cl,
11046 : : __rte_unused void *data)
11047 : : {
11048 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
11049 : :
11050 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
11051 : 0 : mplsoudp_decap_conf.select_vlan = 0;
11052 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
11053 : 0 : mplsoudp_decap_conf.select_vlan = 1;
11054 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
11055 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
11056 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
11057 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
11058 : 0 : }
11059 : :
11060 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
11061 : : .f = cmd_set_mplsoudp_decap_parsed,
11062 : : .data = NULL,
11063 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
11064 : : .tokens = {
11065 : : (void *)&cmd_set_mplsoudp_decap_set,
11066 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
11067 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11068 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11069 : : NULL,
11070 : : },
11071 : : };
11072 : :
11073 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
11074 : : .f = cmd_set_mplsoudp_decap_parsed,
11075 : : .data = NULL,
11076 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
11077 : : .tokens = {
11078 : : (void *)&cmd_set_mplsoudp_decap_set,
11079 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
11080 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
11081 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
11082 : : NULL,
11083 : : },
11084 : : };
11085 : :
11086 : : /** Set connection tracking object common details */
11087 : : struct cmd_set_conntrack_common_result {
11088 : : cmdline_fixed_string_t set;
11089 : : cmdline_fixed_string_t conntrack;
11090 : : cmdline_fixed_string_t common;
11091 : : cmdline_fixed_string_t peer;
11092 : : cmdline_fixed_string_t is_orig;
11093 : : cmdline_fixed_string_t enable;
11094 : : cmdline_fixed_string_t live;
11095 : : cmdline_fixed_string_t sack;
11096 : : cmdline_fixed_string_t cack;
11097 : : cmdline_fixed_string_t last_dir;
11098 : : cmdline_fixed_string_t liberal;
11099 : : cmdline_fixed_string_t state;
11100 : : cmdline_fixed_string_t max_ack_win;
11101 : : cmdline_fixed_string_t retrans;
11102 : : cmdline_fixed_string_t last_win;
11103 : : cmdline_fixed_string_t last_seq;
11104 : : cmdline_fixed_string_t last_ack;
11105 : : cmdline_fixed_string_t last_end;
11106 : : cmdline_fixed_string_t last_index;
11107 : : uint8_t stat;
11108 : : uint8_t factor;
11109 : : uint16_t peer_port;
11110 : : uint32_t is_original;
11111 : : uint32_t en;
11112 : : uint32_t is_live;
11113 : : uint32_t s_ack;
11114 : : uint32_t c_ack;
11115 : : uint32_t ld;
11116 : : uint32_t lb;
11117 : : uint8_t re_num;
11118 : : uint8_t li;
11119 : : uint16_t lw;
11120 : : uint32_t ls;
11121 : : uint32_t la;
11122 : : uint32_t le;
11123 : : };
11124 : :
11125 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
11126 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11127 : : set, "set");
11128 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
11129 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11130 : : conntrack, "conntrack");
11131 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
11132 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11133 : : common, "com");
11134 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
11135 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11136 : : peer, "peer");
11137 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
11138 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11139 : : peer_port, RTE_UINT16);
11140 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
11141 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11142 : : is_orig, "is_orig");
11143 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
11144 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11145 : : is_original, RTE_UINT32);
11146 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
11147 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11148 : : enable, "enable");
11149 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
11150 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11151 : : en, RTE_UINT32);
11152 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
11153 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11154 : : live, "live");
11155 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
11156 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11157 : : is_live, RTE_UINT32);
11158 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
11159 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11160 : : sack, "sack");
11161 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
11162 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11163 : : s_ack, RTE_UINT32);
11164 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
11165 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11166 : : cack, "cack");
11167 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
11168 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11169 : : c_ack, RTE_UINT32);
11170 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
11171 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11172 : : last_dir, "last_dir");
11173 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
11174 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11175 : : ld, RTE_UINT32);
11176 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
11177 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11178 : : liberal, "liberal");
11179 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
11180 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11181 : : lb, RTE_UINT32);
11182 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
11183 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11184 : : state, "state");
11185 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
11186 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11187 : : stat, RTE_UINT8);
11188 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
11189 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11190 : : max_ack_win, "max_ack_win");
11191 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
11192 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11193 : : factor, RTE_UINT8);
11194 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
11195 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11196 : : retrans, "r_lim");
11197 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
11198 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11199 : : re_num, RTE_UINT8);
11200 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
11201 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11202 : : last_win, "last_win");
11203 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
11204 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11205 : : lw, RTE_UINT16);
11206 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
11207 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11208 : : last_seq, "last_seq");
11209 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
11210 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11211 : : ls, RTE_UINT32);
11212 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
11213 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11214 : : last_ack, "last_ack");
11215 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
11216 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11217 : : la, RTE_UINT32);
11218 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
11219 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11220 : : last_end, "last_end");
11221 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
11222 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11223 : : le, RTE_UINT32);
11224 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
11225 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
11226 : : last_index, "last_index");
11227 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
11228 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
11229 : : li, RTE_UINT8);
11230 : :
11231 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
11232 : : __rte_unused struct cmdline *cl,
11233 : : __rte_unused void *data)
11234 : : {
11235 : : struct cmd_set_conntrack_common_result *res = parsed_result;
11236 : :
11237 : : /* No need to swap to big endian. */
11238 : 0 : conntrack_context.peer_port = res->peer_port;
11239 : 0 : conntrack_context.is_original_dir = res->is_original;
11240 : 0 : conntrack_context.enable = res->en;
11241 : 0 : conntrack_context.live_connection = res->is_live;
11242 : 0 : conntrack_context.selective_ack = res->s_ack;
11243 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
11244 : 0 : conntrack_context.last_direction = res->ld;
11245 : 0 : conntrack_context.liberal_mode = res->lb;
11246 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
11247 : 0 : conntrack_context.max_ack_window = res->factor;
11248 : 0 : conntrack_context.retransmission_limit = res->re_num;
11249 : 0 : conntrack_context.last_window = res->lw;
11250 : 0 : conntrack_context.last_index =
11251 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
11252 : 0 : conntrack_context.last_seq = res->ls;
11253 : 0 : conntrack_context.last_ack = res->la;
11254 : 0 : conntrack_context.last_end = res->le;
11255 : 0 : }
11256 : :
11257 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
11258 : : .f = cmd_set_conntrack_common_parsed,
11259 : : .data = NULL,
11260 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
11261 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
11262 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
11263 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
11264 : : " last_index <flag>",
11265 : : .tokens = {
11266 : : (void *)&cmd_set_conntrack_set,
11267 : : (void *)&cmd_set_conntrack_conntrack,
11268 : : (void *)&cmd_set_conntrack_common_com,
11269 : : (void *)&cmd_set_conntrack_common_peer,
11270 : : (void *)&cmd_set_conntrack_common_peer_value,
11271 : : (void *)&cmd_set_conntrack_common_is_orig,
11272 : : (void *)&cmd_set_conntrack_common_is_orig_value,
11273 : : (void *)&cmd_set_conntrack_common_enable,
11274 : : (void *)&cmd_set_conntrack_common_enable_value,
11275 : : (void *)&cmd_set_conntrack_common_live,
11276 : : (void *)&cmd_set_conntrack_common_live_value,
11277 : : (void *)&cmd_set_conntrack_common_sack,
11278 : : (void *)&cmd_set_conntrack_common_sack_value,
11279 : : (void *)&cmd_set_conntrack_common_cack,
11280 : : (void *)&cmd_set_conntrack_common_cack_value,
11281 : : (void *)&cmd_set_conntrack_common_last_dir,
11282 : : (void *)&cmd_set_conntrack_common_last_dir_value,
11283 : : (void *)&cmd_set_conntrack_common_liberal,
11284 : : (void *)&cmd_set_conntrack_common_liberal_value,
11285 : : (void *)&cmd_set_conntrack_common_state,
11286 : : (void *)&cmd_set_conntrack_common_state_value,
11287 : : (void *)&cmd_set_conntrack_common_max_ackwin,
11288 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
11289 : : (void *)&cmd_set_conntrack_common_retrans,
11290 : : (void *)&cmd_set_conntrack_common_retrans_value,
11291 : : (void *)&cmd_set_conntrack_common_last_win,
11292 : : (void *)&cmd_set_conntrack_common_last_win_value,
11293 : : (void *)&cmd_set_conntrack_common_last_seq,
11294 : : (void *)&cmd_set_conntrack_common_last_seq_value,
11295 : : (void *)&cmd_set_conntrack_common_last_ack,
11296 : : (void *)&cmd_set_conntrack_common_last_ack_value,
11297 : : (void *)&cmd_set_conntrack_common_last_end,
11298 : : (void *)&cmd_set_conntrack_common_last_end_value,
11299 : : (void *)&cmd_set_conntrack_common_last_index,
11300 : : (void *)&cmd_set_conntrack_common_last_index_value,
11301 : : NULL,
11302 : : },
11303 : : };
11304 : :
11305 : : /** Set connection tracking object both directions' details */
11306 : : struct cmd_set_conntrack_dir_result {
11307 : : cmdline_fixed_string_t set;
11308 : : cmdline_fixed_string_t conntrack;
11309 : : cmdline_fixed_string_t dir;
11310 : : cmdline_fixed_string_t scale;
11311 : : cmdline_fixed_string_t fin;
11312 : : cmdline_fixed_string_t ack_seen;
11313 : : cmdline_fixed_string_t unack;
11314 : : cmdline_fixed_string_t sent_end;
11315 : : cmdline_fixed_string_t reply_end;
11316 : : cmdline_fixed_string_t max_win;
11317 : : cmdline_fixed_string_t max_ack;
11318 : : uint32_t factor;
11319 : : uint32_t f;
11320 : : uint32_t as;
11321 : : uint32_t un;
11322 : : uint32_t se;
11323 : : uint32_t re;
11324 : : uint32_t mw;
11325 : : uint32_t ma;
11326 : : };
11327 : :
11328 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
11329 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11330 : : dir, "orig#rply");
11331 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
11332 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11333 : : scale, "scale");
11334 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
11335 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11336 : : factor, RTE_UINT32);
11337 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
11338 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11339 : : fin, "fin");
11340 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
11341 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11342 : : f, RTE_UINT32);
11343 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
11344 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11345 : : ack_seen, "acked");
11346 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
11347 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11348 : : as, RTE_UINT32);
11349 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
11350 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11351 : : unack, "unack_data");
11352 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
11353 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11354 : : un, RTE_UINT32);
11355 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
11356 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11357 : : sent_end, "sent_end");
11358 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
11359 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11360 : : se, RTE_UINT32);
11361 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
11362 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11363 : : reply_end, "reply_end");
11364 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
11365 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11366 : : re, RTE_UINT32);
11367 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
11368 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11369 : : max_win, "max_win");
11370 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
11371 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11372 : : mw, RTE_UINT32);
11373 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
11374 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
11375 : : max_ack, "max_ack");
11376 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
11377 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
11378 : : ma, RTE_UINT32);
11379 : :
11380 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
11381 : : __rte_unused struct cmdline *cl,
11382 : : __rte_unused void *data)
11383 : : {
11384 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
11385 : : struct rte_flow_tcp_dir_param *dir = NULL;
11386 : :
11387 : 0 : if (strcmp(res->dir, "orig") == 0)
11388 : : dir = &conntrack_context.original_dir;
11389 : 0 : else if (strcmp(res->dir, "rply") == 0)
11390 : : dir = &conntrack_context.reply_dir;
11391 : : else
11392 : : return;
11393 : 0 : dir->scale = res->factor;
11394 : 0 : dir->close_initiated = res->f;
11395 : 0 : dir->last_ack_seen = res->as;
11396 : 0 : dir->data_unacked = res->un;
11397 : 0 : dir->sent_end = res->se;
11398 : 0 : dir->reply_end = res->re;
11399 : 0 : dir->max_ack = res->ma;
11400 : 0 : dir->max_win = res->mw;
11401 : : }
11402 : :
11403 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
11404 : : .f = cmd_set_conntrack_dir_parsed,
11405 : : .data = NULL,
11406 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
11407 : : " acked <seen> unack_data <unack> sent_end <sent>"
11408 : : " reply_end <reply> max_win <win> max_ack <ack>",
11409 : : .tokens = {
11410 : : (void *)&cmd_set_conntrack_set,
11411 : : (void *)&cmd_set_conntrack_conntrack,
11412 : : (void *)&cmd_set_conntrack_dir_dir,
11413 : : (void *)&cmd_set_conntrack_dir_scale,
11414 : : (void *)&cmd_set_conntrack_dir_scale_value,
11415 : : (void *)&cmd_set_conntrack_dir_fin,
11416 : : (void *)&cmd_set_conntrack_dir_fin_value,
11417 : : (void *)&cmd_set_conntrack_dir_ack,
11418 : : (void *)&cmd_set_conntrack_dir_ack_value,
11419 : : (void *)&cmd_set_conntrack_dir_unack_data,
11420 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
11421 : : (void *)&cmd_set_conntrack_dir_sent_end,
11422 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
11423 : : (void *)&cmd_set_conntrack_dir_reply_end,
11424 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
11425 : : (void *)&cmd_set_conntrack_dir_max_win,
11426 : : (void *)&cmd_set_conntrack_dir_max_win_value,
11427 : : (void *)&cmd_set_conntrack_dir_max_ack,
11428 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
11429 : : NULL,
11430 : : },
11431 : : };
11432 : :
11433 : : /* show vf stats */
11434 : :
11435 : : /* Common result structure for show vf stats */
11436 : : struct cmd_show_vf_stats_result {
11437 : : cmdline_fixed_string_t show;
11438 : : cmdline_fixed_string_t vf;
11439 : : cmdline_fixed_string_t stats;
11440 : : portid_t port_id;
11441 : : uint16_t vf_id;
11442 : : };
11443 : :
11444 : : /* Common CLI fields show vf stats*/
11445 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
11446 : : TOKEN_STRING_INITIALIZER
11447 : : (struct cmd_show_vf_stats_result,
11448 : : show, "show");
11449 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
11450 : : TOKEN_STRING_INITIALIZER
11451 : : (struct cmd_show_vf_stats_result,
11452 : : vf, "vf");
11453 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
11454 : : TOKEN_STRING_INITIALIZER
11455 : : (struct cmd_show_vf_stats_result,
11456 : : stats, "stats");
11457 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
11458 : : TOKEN_NUM_INITIALIZER
11459 : : (struct cmd_show_vf_stats_result,
11460 : : port_id, RTE_UINT16);
11461 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
11462 : : TOKEN_NUM_INITIALIZER
11463 : : (struct cmd_show_vf_stats_result,
11464 : : vf_id, RTE_UINT16);
11465 : :
11466 : : static void
11467 : 0 : cmd_show_vf_stats_parsed(
11468 : : void *parsed_result,
11469 : : __rte_unused struct cmdline *cl,
11470 : : __rte_unused void *data)
11471 : : {
11472 : : struct cmd_show_vf_stats_result *res = parsed_result;
11473 : : struct rte_eth_stats stats;
11474 : : int ret = -ENOTSUP;
11475 : : static const char *nic_stats_border = "########################";
11476 : :
11477 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11478 : 0 : return;
11479 : :
11480 : : memset(&stats, 0, sizeof(stats));
11481 : :
11482 : : #ifdef RTE_NET_I40E
11483 : : if (ret == -ENOTSUP)
11484 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
11485 : 0 : res->vf_id,
11486 : : &stats);
11487 : : #endif
11488 : : #ifdef RTE_NET_BNXT
11489 : 0 : if (ret == -ENOTSUP)
11490 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
11491 : 0 : res->vf_id,
11492 : : &stats);
11493 : : #endif
11494 : :
11495 : 0 : switch (ret) {
11496 : : case 0:
11497 : : break;
11498 : 0 : case -EINVAL:
11499 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11500 : : break;
11501 : 0 : case -ENODEV:
11502 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11503 : : break;
11504 : 0 : case -ENOTSUP:
11505 : 0 : fprintf(stderr, "function not implemented\n");
11506 : : break;
11507 : 0 : default:
11508 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11509 : : }
11510 : :
11511 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
11512 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
11513 : :
11514 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
11515 : : "%-"PRIu64"\n",
11516 : : stats.ipackets, stats.imissed, stats.ibytes);
11517 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
11518 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
11519 : : stats.rx_nombuf);
11520 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
11521 : : "%-"PRIu64"\n",
11522 : : stats.opackets, stats.oerrors, stats.obytes);
11523 : :
11524 : 0 : printf(" %s############################%s\n",
11525 : : nic_stats_border, nic_stats_border);
11526 : : }
11527 : :
11528 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
11529 : : .f = cmd_show_vf_stats_parsed,
11530 : : .data = NULL,
11531 : : .help_str = "show vf stats <port_id> <vf_id>",
11532 : : .tokens = {
11533 : : (void *)&cmd_show_vf_stats_show,
11534 : : (void *)&cmd_show_vf_stats_vf,
11535 : : (void *)&cmd_show_vf_stats_stats,
11536 : : (void *)&cmd_show_vf_stats_port_id,
11537 : : (void *)&cmd_show_vf_stats_vf_id,
11538 : : NULL,
11539 : : },
11540 : : };
11541 : :
11542 : : /* clear vf stats */
11543 : :
11544 : : /* Common result structure for clear vf stats */
11545 : : struct cmd_clear_vf_stats_result {
11546 : : cmdline_fixed_string_t clear;
11547 : : cmdline_fixed_string_t vf;
11548 : : cmdline_fixed_string_t stats;
11549 : : portid_t port_id;
11550 : : uint16_t vf_id;
11551 : : };
11552 : :
11553 : : /* Common CLI fields clear vf stats*/
11554 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
11555 : : TOKEN_STRING_INITIALIZER
11556 : : (struct cmd_clear_vf_stats_result,
11557 : : clear, "clear");
11558 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
11559 : : TOKEN_STRING_INITIALIZER
11560 : : (struct cmd_clear_vf_stats_result,
11561 : : vf, "vf");
11562 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
11563 : : TOKEN_STRING_INITIALIZER
11564 : : (struct cmd_clear_vf_stats_result,
11565 : : stats, "stats");
11566 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
11567 : : TOKEN_NUM_INITIALIZER
11568 : : (struct cmd_clear_vf_stats_result,
11569 : : port_id, RTE_UINT16);
11570 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
11571 : : TOKEN_NUM_INITIALIZER
11572 : : (struct cmd_clear_vf_stats_result,
11573 : : vf_id, RTE_UINT16);
11574 : :
11575 : : static void
11576 : 0 : cmd_clear_vf_stats_parsed(
11577 : : void *parsed_result,
11578 : : __rte_unused struct cmdline *cl,
11579 : : __rte_unused void *data)
11580 : : {
11581 : : struct cmd_clear_vf_stats_result *res = parsed_result;
11582 : : int ret = -ENOTSUP;
11583 : :
11584 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
11585 : : return;
11586 : :
11587 : : #ifdef RTE_NET_I40E
11588 : : if (ret == -ENOTSUP)
11589 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
11590 : 0 : res->vf_id);
11591 : : #endif
11592 : : #ifdef RTE_NET_BNXT
11593 : 0 : if (ret == -ENOTSUP)
11594 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
11595 : 0 : res->vf_id);
11596 : : #endif
11597 : :
11598 : 0 : switch (ret) {
11599 : : case 0:
11600 : : break;
11601 : 0 : case -EINVAL:
11602 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
11603 : : break;
11604 : 0 : case -ENODEV:
11605 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
11606 : : break;
11607 : 0 : case -ENOTSUP:
11608 : 0 : fprintf(stderr, "function not implemented\n");
11609 : : break;
11610 : 0 : default:
11611 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
11612 : : }
11613 : : }
11614 : :
11615 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
11616 : : .f = cmd_clear_vf_stats_parsed,
11617 : : .data = NULL,
11618 : : .help_str = "clear vf stats <port_id> <vf_id>",
11619 : : .tokens = {
11620 : : (void *)&cmd_clear_vf_stats_clear,
11621 : : (void *)&cmd_clear_vf_stats_vf,
11622 : : (void *)&cmd_clear_vf_stats_stats,
11623 : : (void *)&cmd_clear_vf_stats_port_id,
11624 : : (void *)&cmd_clear_vf_stats_vf_id,
11625 : : NULL,
11626 : : },
11627 : : };
11628 : :
11629 : : /* Common result structure for file commands */
11630 : : struct cmd_cmdfile_result {
11631 : : cmdline_fixed_string_t load;
11632 : : cmdline_fixed_string_t filename;
11633 : : };
11634 : :
11635 : : /* Common CLI fields for file commands */
11636 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
11637 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
11638 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
11639 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
11640 : :
11641 : : static void
11642 : 0 : cmd_load_from_file_parsed(
11643 : : void *parsed_result,
11644 : : __rte_unused struct cmdline *cl,
11645 : : __rte_unused void *data)
11646 : : {
11647 : : struct cmd_cmdfile_result *res = parsed_result;
11648 : :
11649 : 0 : cmdline_read_from_file(res->filename);
11650 : 0 : }
11651 : :
11652 : : static cmdline_parse_inst_t cmd_load_from_file = {
11653 : : .f = cmd_load_from_file_parsed,
11654 : : .data = NULL,
11655 : : .help_str = "load <filename>",
11656 : : .tokens = {
11657 : : (void *)&cmd_load_cmdfile,
11658 : : (void *)&cmd_load_cmdfile_filename,
11659 : : NULL,
11660 : : },
11661 : : };
11662 : :
11663 : : /* Get Rx offloads capabilities */
11664 : : struct cmd_rx_offload_get_capa_result {
11665 : : cmdline_fixed_string_t show;
11666 : : cmdline_fixed_string_t port;
11667 : : portid_t port_id;
11668 : : cmdline_fixed_string_t rx_offload;
11669 : : cmdline_fixed_string_t capabilities;
11670 : : };
11671 : :
11672 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
11673 : : TOKEN_STRING_INITIALIZER
11674 : : (struct cmd_rx_offload_get_capa_result,
11675 : : show, "show");
11676 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
11677 : : TOKEN_STRING_INITIALIZER
11678 : : (struct cmd_rx_offload_get_capa_result,
11679 : : port, "port");
11680 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
11681 : : TOKEN_NUM_INITIALIZER
11682 : : (struct cmd_rx_offload_get_capa_result,
11683 : : port_id, RTE_UINT16);
11684 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
11685 : : TOKEN_STRING_INITIALIZER
11686 : : (struct cmd_rx_offload_get_capa_result,
11687 : : rx_offload, "rx_offload");
11688 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
11689 : : TOKEN_STRING_INITIALIZER
11690 : : (struct cmd_rx_offload_get_capa_result,
11691 : : capabilities, "capabilities");
11692 : :
11693 : : static void
11694 : 0 : print_rx_offloads(uint64_t offloads)
11695 : : {
11696 : : uint64_t single_offload;
11697 : : int begin;
11698 : : int end;
11699 : : int bit;
11700 : :
11701 : 0 : if (offloads == 0)
11702 : : return;
11703 : :
11704 : : begin = rte_ctz64(offloads);
11705 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11706 : :
11707 : 0 : single_offload = 1ULL << begin;
11708 : 0 : for (bit = begin; bit < end; bit++) {
11709 : 0 : if (offloads & single_offload)
11710 : 0 : printf(" %s",
11711 : : rte_eth_dev_rx_offload_name(single_offload));
11712 : 0 : single_offload <<= 1;
11713 : : }
11714 : : }
11715 : :
11716 : : static void
11717 : 0 : cmd_rx_offload_get_capa_parsed(
11718 : : void *parsed_result,
11719 : : __rte_unused struct cmdline *cl,
11720 : : __rte_unused void *data)
11721 : : {
11722 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
11723 : : struct rte_eth_dev_info dev_info;
11724 : 0 : portid_t port_id = res->port_id;
11725 : : uint64_t queue_offloads;
11726 : : uint64_t port_offloads;
11727 : : int ret;
11728 : :
11729 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11730 : 0 : if (ret != 0)
11731 : 0 : return;
11732 : :
11733 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
11734 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
11735 : :
11736 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
11737 : : printf(" Per Queue :");
11738 : 0 : print_rx_offloads(queue_offloads);
11739 : :
11740 : : printf("\n");
11741 : : printf(" Per Port :");
11742 : 0 : print_rx_offloads(port_offloads);
11743 : : printf("\n\n");
11744 : : }
11745 : :
11746 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
11747 : : .f = cmd_rx_offload_get_capa_parsed,
11748 : : .data = NULL,
11749 : : .help_str = "show port <port_id> rx_offload capabilities",
11750 : : .tokens = {
11751 : : (void *)&cmd_rx_offload_get_capa_show,
11752 : : (void *)&cmd_rx_offload_get_capa_port,
11753 : : (void *)&cmd_rx_offload_get_capa_port_id,
11754 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
11755 : : (void *)&cmd_rx_offload_get_capa_capabilities,
11756 : : NULL,
11757 : : }
11758 : : };
11759 : :
11760 : : /* Get Rx offloads configuration */
11761 : : struct cmd_rx_offload_get_configuration_result {
11762 : : cmdline_fixed_string_t show;
11763 : : cmdline_fixed_string_t port;
11764 : : portid_t port_id;
11765 : : cmdline_fixed_string_t rx_offload;
11766 : : cmdline_fixed_string_t configuration;
11767 : : };
11768 : :
11769 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
11770 : : TOKEN_STRING_INITIALIZER
11771 : : (struct cmd_rx_offload_get_configuration_result,
11772 : : show, "show");
11773 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
11774 : : TOKEN_STRING_INITIALIZER
11775 : : (struct cmd_rx_offload_get_configuration_result,
11776 : : port, "port");
11777 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
11778 : : TOKEN_NUM_INITIALIZER
11779 : : (struct cmd_rx_offload_get_configuration_result,
11780 : : port_id, RTE_UINT16);
11781 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
11782 : : TOKEN_STRING_INITIALIZER
11783 : : (struct cmd_rx_offload_get_configuration_result,
11784 : : rx_offload, "rx_offload");
11785 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
11786 : : TOKEN_STRING_INITIALIZER
11787 : : (struct cmd_rx_offload_get_configuration_result,
11788 : : configuration, "configuration");
11789 : :
11790 : : static void
11791 : 0 : cmd_rx_offload_get_configuration_parsed(
11792 : : void *parsed_result,
11793 : : __rte_unused struct cmdline *cl,
11794 : : __rte_unused void *data)
11795 : : {
11796 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
11797 : : struct rte_eth_dev_info dev_info;
11798 : 0 : portid_t port_id = res->port_id;
11799 : : struct rte_port *port;
11800 : : struct rte_eth_conf dev_conf;
11801 : : uint64_t port_offloads;
11802 : : uint64_t queue_offloads;
11803 : : uint16_t nb_rx_queues;
11804 : : int q;
11805 : : int ret;
11806 : :
11807 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11808 : 0 : if (ret != 0)
11809 : 0 : return;
11810 : :
11811 : 0 : port = &ports[port_id];
11812 : : printf("Rx Offloading Configuration of port %d :\n", port_id);
11813 : :
11814 : 0 : port_offloads = dev_conf.rxmode.offloads;
11815 : : printf(" Port :");
11816 : 0 : print_rx_offloads(port_offloads);
11817 : : printf("\n");
11818 : :
11819 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11820 : 0 : if (ret != 0)
11821 : : return;
11822 : :
11823 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11824 : 0 : for (q = 0; q < nb_rx_queues; q++) {
11825 : 0 : queue_offloads = port->rxq[q].conf.offloads;
11826 : : printf(" Queue[%2d] :", q);
11827 : 0 : print_rx_offloads(queue_offloads);
11828 : : printf("\n");
11829 : : }
11830 : : printf("\n");
11831 : : }
11832 : :
11833 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
11834 : : .f = cmd_rx_offload_get_configuration_parsed,
11835 : : .data = NULL,
11836 : : .help_str = "show port <port_id> rx_offload configuration",
11837 : : .tokens = {
11838 : : (void *)&cmd_rx_offload_get_configuration_show,
11839 : : (void *)&cmd_rx_offload_get_configuration_port,
11840 : : (void *)&cmd_rx_offload_get_configuration_port_id,
11841 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
11842 : : (void *)&cmd_rx_offload_get_configuration_configuration,
11843 : : NULL,
11844 : : }
11845 : : };
11846 : :
11847 : : /* Enable/Disable a per port offloading */
11848 : : struct cmd_config_per_port_rx_offload_result {
11849 : : cmdline_fixed_string_t port;
11850 : : cmdline_fixed_string_t config;
11851 : : portid_t port_id;
11852 : : cmdline_fixed_string_t rx_offload;
11853 : : cmdline_fixed_string_t offload;
11854 : : cmdline_fixed_string_t on_off;
11855 : : };
11856 : :
11857 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
11858 : : TOKEN_STRING_INITIALIZER
11859 : : (struct cmd_config_per_port_rx_offload_result,
11860 : : port, "port");
11861 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
11862 : : TOKEN_STRING_INITIALIZER
11863 : : (struct cmd_config_per_port_rx_offload_result,
11864 : : config, "config");
11865 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
11866 : : TOKEN_NUM_INITIALIZER
11867 : : (struct cmd_config_per_port_rx_offload_result,
11868 : : port_id, RTE_UINT16);
11869 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
11870 : : TOKEN_STRING_INITIALIZER
11871 : : (struct cmd_config_per_port_rx_offload_result,
11872 : : rx_offload, "rx_offload");
11873 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
11874 : : TOKEN_STRING_INITIALIZER
11875 : : (struct cmd_config_per_port_rx_offload_result,
11876 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11877 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11878 : : "vlan_filter#vlan_extend#"
11879 : : "scatter#buffer_split#timestamp#security#"
11880 : : "keep_crc#rss_hash");
11881 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
11882 : : TOKEN_STRING_INITIALIZER
11883 : : (struct cmd_config_per_port_rx_offload_result,
11884 : : on_off, "on#off");
11885 : :
11886 : : static uint64_t
11887 : 0 : search_rx_offload(const char *name)
11888 : : {
11889 : : uint64_t single_offload;
11890 : : const char *single_name;
11891 : : int found = 0;
11892 : : unsigned int bit;
11893 : :
11894 : : single_offload = 1;
11895 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11896 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
11897 : 0 : if (!strcasecmp(single_name, name)) {
11898 : : found = 1;
11899 : : break;
11900 : : }
11901 : 0 : single_offload <<= 1;
11902 : : }
11903 : :
11904 : 0 : if (found)
11905 : 0 : return single_offload;
11906 : :
11907 : : return 0;
11908 : : }
11909 : :
11910 : : static void
11911 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
11912 : : {
11913 : : struct rte_eth_dev_info dev_info;
11914 : : struct rte_port *port;
11915 : : uint16_t nb_rx_queues;
11916 : : uint64_t offload;
11917 : : int q;
11918 : : int ret;
11919 : :
11920 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11921 : 0 : if (ret != 0)
11922 : 0 : return;
11923 : :
11924 : 0 : port = &ports[port_id];
11925 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11926 : 0 : fprintf(stderr,
11927 : : "Error: Can't config offload when Port %d is not stopped\n",
11928 : : port_id);
11929 : 0 : return;
11930 : : }
11931 : :
11932 : 0 : if (!strcmp(name, "all")) {
11933 : 0 : offload = dev_info.rx_offload_capa;
11934 : : } else {
11935 : 0 : offload = search_rx_offload(name);
11936 : 0 : if (offload == 0) {
11937 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
11938 : 0 : return;
11939 : : }
11940 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
11941 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11942 : : port_id, name);
11943 : 0 : return;
11944 : : }
11945 : : }
11946 : :
11947 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11948 : 0 : if (on) {
11949 : 0 : port->dev_conf.rxmode.offloads |= offload;
11950 : 0 : for (q = 0; q < nb_rx_queues; q++)
11951 : 0 : port->rxq[q].conf.offloads |= offload;
11952 : : } else {
11953 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
11954 : 0 : for (q = 0; q < nb_rx_queues; q++)
11955 : 0 : port->rxq[q].conf.offloads &= ~offload;
11956 : : }
11957 : :
11958 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11959 : : }
11960 : :
11961 : : static void
11962 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
11963 : : __rte_unused struct cmdline *cl,
11964 : : __rte_unused void *data)
11965 : : {
11966 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
11967 : : bool on;
11968 : :
11969 : 0 : on = strcmp(res->on_off, "on") == 0;
11970 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
11971 : 0 : }
11972 : :
11973 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
11974 : : .f = cmd_config_per_port_rx_offload_parsed,
11975 : : .data = NULL,
11976 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
11977 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11978 : : "macsec_strip|vlan_filter|vlan_extend|"
11979 : : "scatter|buffer_split|timestamp|security|"
11980 : : "keep_crc|rss_hash on|off",
11981 : : .tokens = {
11982 : : (void *)&cmd_config_per_port_rx_offload_result_port,
11983 : : (void *)&cmd_config_per_port_rx_offload_result_config,
11984 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
11985 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
11986 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
11987 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
11988 : : NULL,
11989 : : }
11990 : : };
11991 : :
11992 : : /* Enable/Disable all port Rx offloading */
11993 : : struct cmd_config_all_port_rx_offload_result {
11994 : : cmdline_fixed_string_t port;
11995 : : cmdline_fixed_string_t config;
11996 : : cmdline_fixed_string_t port_all;
11997 : : cmdline_fixed_string_t rx_offload;
11998 : : cmdline_fixed_string_t offload;
11999 : : cmdline_fixed_string_t on_off;
12000 : : };
12001 : :
12002 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
12003 : : TOKEN_STRING_INITIALIZER
12004 : : (struct cmd_config_all_port_rx_offload_result,
12005 : : port, "port");
12006 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
12007 : : TOKEN_STRING_INITIALIZER
12008 : : (struct cmd_config_all_port_rx_offload_result,
12009 : : config, "config");
12010 : :
12011 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
12012 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
12013 : : port_all, "all");
12014 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
12015 : : TOKEN_STRING_INITIALIZER
12016 : : (struct cmd_config_all_port_rx_offload_result,
12017 : : rx_offload, "rx_offload");
12018 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
12019 : : TOKEN_STRING_INITIALIZER
12020 : : (struct cmd_config_all_port_rx_offload_result,
12021 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12022 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12023 : : "vlan_filter#vlan_extend#"
12024 : : "scatter#buffer_split#timestamp#security#"
12025 : : "keep_crc#rss_hash");
12026 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
12027 : : TOKEN_STRING_INITIALIZER
12028 : : (struct cmd_config_all_port_rx_offload_result,
12029 : : on_off, "on#off");
12030 : :
12031 : : static void
12032 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
12033 : : __rte_unused struct cmdline *cl,
12034 : : __rte_unused void *data)
12035 : : {
12036 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
12037 : : bool on_off;
12038 : : portid_t i;
12039 : :
12040 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12041 : 0 : RTE_ETH_FOREACH_DEV(i)
12042 : 0 : config_port_rx_offload(i, res->offload, on_off);
12043 : :
12044 : 0 : }
12045 : :
12046 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
12047 : : .f = cmd_config_all_port_rx_offload_parsed,
12048 : : .data = NULL,
12049 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
12050 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12051 : : "macsec_strip|vlan_filter|vlan_extend|"
12052 : : "scatter|buffer_split|timestamp|security|"
12053 : : "keep_crc|rss_hash on|off",
12054 : : .tokens = {
12055 : : (void *)&cmd_config_all_port_rx_offload_result_port,
12056 : : (void *)&cmd_config_all_port_rx_offload_result_config,
12057 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
12058 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
12059 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
12060 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
12061 : : NULL,
12062 : : }
12063 : : };
12064 : :
12065 : : /* Enable/Disable a per queue offloading */
12066 : : struct cmd_config_per_queue_rx_offload_result {
12067 : : cmdline_fixed_string_t port;
12068 : : portid_t port_id;
12069 : : cmdline_fixed_string_t rxq;
12070 : : uint16_t queue_id;
12071 : : cmdline_fixed_string_t rx_offload;
12072 : : cmdline_fixed_string_t offload;
12073 : : cmdline_fixed_string_t on_off;
12074 : : };
12075 : :
12076 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
12077 : : TOKEN_STRING_INITIALIZER
12078 : : (struct cmd_config_per_queue_rx_offload_result,
12079 : : port, "port");
12080 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
12081 : : TOKEN_NUM_INITIALIZER
12082 : : (struct cmd_config_per_queue_rx_offload_result,
12083 : : port_id, RTE_UINT16);
12084 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
12085 : : TOKEN_STRING_INITIALIZER
12086 : : (struct cmd_config_per_queue_rx_offload_result,
12087 : : rxq, "rxq");
12088 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
12089 : : TOKEN_NUM_INITIALIZER
12090 : : (struct cmd_config_per_queue_rx_offload_result,
12091 : : queue_id, RTE_UINT16);
12092 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
12093 : : TOKEN_STRING_INITIALIZER
12094 : : (struct cmd_config_per_queue_rx_offload_result,
12095 : : rx_offload, "rx_offload");
12096 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
12097 : : TOKEN_STRING_INITIALIZER
12098 : : (struct cmd_config_per_queue_rx_offload_result,
12099 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
12100 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
12101 : : "vlan_filter#vlan_extend#"
12102 : : "scatter#buffer_split#timestamp#security#keep_crc");
12103 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
12104 : : TOKEN_STRING_INITIALIZER
12105 : : (struct cmd_config_per_queue_rx_offload_result,
12106 : : on_off, "on#off");
12107 : :
12108 : : static void
12109 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
12110 : : __rte_unused struct cmdline *cl,
12111 : : __rte_unused void *data)
12112 : : {
12113 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
12114 : : struct rte_eth_dev_info dev_info;
12115 : 0 : portid_t port_id = res->port_id;
12116 : 0 : uint16_t queue_id = res->queue_id;
12117 : : struct rte_port *port;
12118 : : uint64_t offload;
12119 : : int ret;
12120 : :
12121 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12122 : 0 : if (ret != 0)
12123 : 0 : return;
12124 : :
12125 : 0 : port = &ports[port_id];
12126 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12127 : 0 : fprintf(stderr,
12128 : : "Error: Can't config offload when Port %d is not stopped\n",
12129 : : port_id);
12130 : 0 : return;
12131 : : }
12132 : :
12133 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
12134 : 0 : fprintf(stderr,
12135 : : "Error: input queue_id should be 0 ... %d\n",
12136 : 0 : dev_info.nb_rx_queues - 1);
12137 : 0 : return;
12138 : : }
12139 : :
12140 : 0 : if (!strcmp(res->offload, "all")) {
12141 : 0 : offload = dev_info.rx_queue_offload_capa;
12142 : : } else {
12143 : 0 : offload = search_rx_offload(res->offload);
12144 : 0 : if (offload == 0) {
12145 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12146 : 0 : return;
12147 : : }
12148 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
12149 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12150 : : port_id, res->offload);
12151 : 0 : return;
12152 : : }
12153 : : }
12154 : :
12155 : 0 : if (!strcmp(res->on_off, "on"))
12156 : 0 : port->rxq[queue_id].conf.offloads |= offload;
12157 : : else
12158 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
12159 : :
12160 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12161 : : }
12162 : :
12163 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
12164 : : .f = cmd_config_per_queue_rx_offload_parsed,
12165 : : .data = NULL,
12166 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
12167 : : "all|vlan_strip|ipv4_cksum|"
12168 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
12169 : : "macsec_strip|vlan_filter|vlan_extend|"
12170 : : "scatter|buffer_split|timestamp|security|"
12171 : : "keep_crc on|off",
12172 : : .tokens = {
12173 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
12174 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
12175 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
12176 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
12177 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
12178 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
12179 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
12180 : : NULL,
12181 : : }
12182 : : };
12183 : :
12184 : : /* Get Tx offloads capabilities */
12185 : : struct cmd_tx_offload_get_capa_result {
12186 : : cmdline_fixed_string_t show;
12187 : : cmdline_fixed_string_t port;
12188 : : portid_t port_id;
12189 : : cmdline_fixed_string_t tx_offload;
12190 : : cmdline_fixed_string_t capabilities;
12191 : : };
12192 : :
12193 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
12194 : : TOKEN_STRING_INITIALIZER
12195 : : (struct cmd_tx_offload_get_capa_result,
12196 : : show, "show");
12197 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
12198 : : TOKEN_STRING_INITIALIZER
12199 : : (struct cmd_tx_offload_get_capa_result,
12200 : : port, "port");
12201 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
12202 : : TOKEN_NUM_INITIALIZER
12203 : : (struct cmd_tx_offload_get_capa_result,
12204 : : port_id, RTE_UINT16);
12205 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
12206 : : TOKEN_STRING_INITIALIZER
12207 : : (struct cmd_tx_offload_get_capa_result,
12208 : : tx_offload, "tx_offload");
12209 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
12210 : : TOKEN_STRING_INITIALIZER
12211 : : (struct cmd_tx_offload_get_capa_result,
12212 : : capabilities, "capabilities");
12213 : :
12214 : : static void
12215 : 0 : print_tx_offloads(uint64_t offloads)
12216 : : {
12217 : : uint64_t single_offload;
12218 : : int begin;
12219 : : int end;
12220 : : int bit;
12221 : :
12222 : 0 : if (offloads == 0)
12223 : : return;
12224 : :
12225 : : begin = rte_ctz64(offloads);
12226 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
12227 : :
12228 : 0 : single_offload = 1ULL << begin;
12229 : 0 : for (bit = begin; bit < end; bit++) {
12230 : 0 : if (offloads & single_offload)
12231 : 0 : printf(" %s",
12232 : : rte_eth_dev_tx_offload_name(single_offload));
12233 : 0 : single_offload <<= 1;
12234 : : }
12235 : : }
12236 : :
12237 : : static void
12238 : 0 : cmd_tx_offload_get_capa_parsed(
12239 : : void *parsed_result,
12240 : : __rte_unused struct cmdline *cl,
12241 : : __rte_unused void *data)
12242 : : {
12243 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
12244 : : struct rte_eth_dev_info dev_info;
12245 : 0 : portid_t port_id = res->port_id;
12246 : : uint64_t queue_offloads;
12247 : : uint64_t port_offloads;
12248 : : int ret;
12249 : :
12250 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12251 : 0 : if (ret != 0)
12252 : 0 : return;
12253 : :
12254 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
12255 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
12256 : :
12257 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
12258 : : printf(" Per Queue :");
12259 : 0 : print_tx_offloads(queue_offloads);
12260 : :
12261 : : printf("\n");
12262 : : printf(" Per Port :");
12263 : 0 : print_tx_offloads(port_offloads);
12264 : : printf("\n\n");
12265 : : }
12266 : :
12267 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
12268 : : .f = cmd_tx_offload_get_capa_parsed,
12269 : : .data = NULL,
12270 : : .help_str = "show port <port_id> tx_offload capabilities",
12271 : : .tokens = {
12272 : : (void *)&cmd_tx_offload_get_capa_show,
12273 : : (void *)&cmd_tx_offload_get_capa_port,
12274 : : (void *)&cmd_tx_offload_get_capa_port_id,
12275 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
12276 : : (void *)&cmd_tx_offload_get_capa_capabilities,
12277 : : NULL,
12278 : : }
12279 : : };
12280 : :
12281 : : /* Get Tx offloads configuration */
12282 : : struct cmd_tx_offload_get_configuration_result {
12283 : : cmdline_fixed_string_t show;
12284 : : cmdline_fixed_string_t port;
12285 : : portid_t port_id;
12286 : : cmdline_fixed_string_t tx_offload;
12287 : : cmdline_fixed_string_t configuration;
12288 : : };
12289 : :
12290 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
12291 : : TOKEN_STRING_INITIALIZER
12292 : : (struct cmd_tx_offload_get_configuration_result,
12293 : : show, "show");
12294 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
12295 : : TOKEN_STRING_INITIALIZER
12296 : : (struct cmd_tx_offload_get_configuration_result,
12297 : : port, "port");
12298 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
12299 : : TOKEN_NUM_INITIALIZER
12300 : : (struct cmd_tx_offload_get_configuration_result,
12301 : : port_id, RTE_UINT16);
12302 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
12303 : : TOKEN_STRING_INITIALIZER
12304 : : (struct cmd_tx_offload_get_configuration_result,
12305 : : tx_offload, "tx_offload");
12306 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
12307 : : TOKEN_STRING_INITIALIZER
12308 : : (struct cmd_tx_offload_get_configuration_result,
12309 : : configuration, "configuration");
12310 : :
12311 : : static void
12312 : 0 : cmd_tx_offload_get_configuration_parsed(
12313 : : void *parsed_result,
12314 : : __rte_unused struct cmdline *cl,
12315 : : __rte_unused void *data)
12316 : : {
12317 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
12318 : : struct rte_eth_dev_info dev_info;
12319 : 0 : portid_t port_id = res->port_id;
12320 : : struct rte_port *port;
12321 : : struct rte_eth_conf dev_conf;
12322 : : uint64_t port_offloads;
12323 : : uint64_t queue_offloads;
12324 : : uint16_t nb_tx_queues;
12325 : : int q;
12326 : : int ret;
12327 : :
12328 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
12329 : 0 : if (ret != 0)
12330 : 0 : return;
12331 : :
12332 : : printf("Tx Offloading Configuration of port %d :\n", port_id);
12333 : 0 : port = &ports[port_id];
12334 : 0 : port_offloads = dev_conf.txmode.offloads;
12335 : : printf(" Port :");
12336 : 0 : print_tx_offloads(port_offloads);
12337 : : printf("\n");
12338 : :
12339 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12340 : 0 : if (ret != 0)
12341 : : return;
12342 : :
12343 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12344 : 0 : for (q = 0; q < nb_tx_queues; q++) {
12345 : 0 : queue_offloads = port->txq[q].conf.offloads;
12346 : : printf(" Queue[%2d] :", q);
12347 : 0 : print_tx_offloads(queue_offloads);
12348 : : printf("\n");
12349 : : }
12350 : : printf("\n");
12351 : : }
12352 : :
12353 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
12354 : : .f = cmd_tx_offload_get_configuration_parsed,
12355 : : .data = NULL,
12356 : : .help_str = "show port <port_id> tx_offload configuration",
12357 : : .tokens = {
12358 : : (void *)&cmd_tx_offload_get_configuration_show,
12359 : : (void *)&cmd_tx_offload_get_configuration_port,
12360 : : (void *)&cmd_tx_offload_get_configuration_port_id,
12361 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
12362 : : (void *)&cmd_tx_offload_get_configuration_configuration,
12363 : : NULL,
12364 : : }
12365 : : };
12366 : :
12367 : : /* Enable/Disable a per port offloading */
12368 : : struct cmd_config_per_port_tx_offload_result {
12369 : : cmdline_fixed_string_t port;
12370 : : cmdline_fixed_string_t config;
12371 : : portid_t port_id;
12372 : : cmdline_fixed_string_t tx_offload;
12373 : : cmdline_fixed_string_t offload;
12374 : : cmdline_fixed_string_t on_off;
12375 : : };
12376 : :
12377 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
12378 : : TOKEN_STRING_INITIALIZER
12379 : : (struct cmd_config_per_port_tx_offload_result,
12380 : : port, "port");
12381 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
12382 : : TOKEN_STRING_INITIALIZER
12383 : : (struct cmd_config_per_port_tx_offload_result,
12384 : : config, "config");
12385 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
12386 : : TOKEN_NUM_INITIALIZER
12387 : : (struct cmd_config_per_port_tx_offload_result,
12388 : : port_id, RTE_UINT16);
12389 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
12390 : : TOKEN_STRING_INITIALIZER
12391 : : (struct cmd_config_per_port_tx_offload_result,
12392 : : tx_offload, "tx_offload");
12393 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
12394 : : TOKEN_STRING_INITIALIZER
12395 : : (struct cmd_config_per_port_tx_offload_result,
12396 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12397 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12398 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12399 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12400 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12401 : : "send_on_timestamp");
12402 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
12403 : : TOKEN_STRING_INITIALIZER
12404 : : (struct cmd_config_per_port_tx_offload_result,
12405 : : on_off, "on#off");
12406 : :
12407 : : static uint64_t
12408 : 0 : search_tx_offload(const char *name)
12409 : : {
12410 : : uint64_t single_offload;
12411 : : const char *single_name;
12412 : : int found = 0;
12413 : : unsigned int bit;
12414 : :
12415 : : single_offload = 1;
12416 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
12417 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
12418 : 0 : if (single_name == NULL)
12419 : : break;
12420 : 0 : if (!strcasecmp(single_name, name)) {
12421 : : found = 1;
12422 : : break;
12423 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
12424 : : break;
12425 : 0 : single_offload <<= 1;
12426 : : }
12427 : :
12428 : 0 : if (found)
12429 : 0 : return single_offload;
12430 : :
12431 : : return 0;
12432 : : }
12433 : :
12434 : : static void
12435 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
12436 : : {
12437 : : struct rte_eth_dev_info dev_info;
12438 : : struct rte_port *port;
12439 : : uint16_t nb_tx_queues;
12440 : : uint64_t offload;
12441 : : int q;
12442 : : int ret;
12443 : :
12444 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12445 : 0 : if (ret != 0)
12446 : 0 : return;
12447 : :
12448 : 0 : port = &ports[port_id];
12449 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12450 : 0 : fprintf(stderr,
12451 : : "Error: Can't config offload when Port %d is not stopped\n",
12452 : : port_id);
12453 : 0 : return;
12454 : : }
12455 : :
12456 : 0 : if (!strcmp(name, "all")) {
12457 : 0 : offload = dev_info.tx_offload_capa;
12458 : : } else {
12459 : 0 : offload = search_tx_offload(name);
12460 : 0 : if (offload == 0) {
12461 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
12462 : 0 : return;
12463 : : }
12464 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
12465 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
12466 : : port_id, name);
12467 : 0 : return;
12468 : : }
12469 : : }
12470 : :
12471 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
12472 : 0 : if (on) {
12473 : 0 : port->dev_conf.txmode.offloads |= offload;
12474 : 0 : for (q = 0; q < nb_tx_queues; q++)
12475 : 0 : port->txq[q].conf.offloads |= offload;
12476 : : } else {
12477 : 0 : port->dev_conf.txmode.offloads &= ~offload;
12478 : 0 : for (q = 0; q < nb_tx_queues; q++)
12479 : 0 : port->txq[q].conf.offloads &= ~offload;
12480 : : }
12481 : :
12482 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12483 : : }
12484 : :
12485 : : static void
12486 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
12487 : : __rte_unused struct cmdline *cl,
12488 : : __rte_unused void *data)
12489 : : {
12490 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
12491 : : bool on;
12492 : :
12493 : 0 : on = strcmp(res->on_off, "on") == 0;
12494 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
12495 : 0 : }
12496 : :
12497 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
12498 : : .f = cmd_config_per_port_tx_offload_parsed,
12499 : : .data = NULL,
12500 : : .help_str = "port config <port_id> tx_offload "
12501 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12502 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12503 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12504 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12505 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12506 : : "send_on_timestamp on|off",
12507 : : .tokens = {
12508 : : (void *)&cmd_config_per_port_tx_offload_result_port,
12509 : : (void *)&cmd_config_per_port_tx_offload_result_config,
12510 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
12511 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
12512 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
12513 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
12514 : : NULL,
12515 : : }
12516 : : };
12517 : :
12518 : : /* Enable/Disable all port Tx offloading */
12519 : : struct cmd_config_all_port_tx_offload_result {
12520 : : cmdline_fixed_string_t port;
12521 : : cmdline_fixed_string_t config;
12522 : : cmdline_fixed_string_t port_all;
12523 : : cmdline_fixed_string_t tx_offload;
12524 : : cmdline_fixed_string_t offload;
12525 : : cmdline_fixed_string_t on_off;
12526 : : };
12527 : :
12528 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
12529 : : TOKEN_STRING_INITIALIZER
12530 : : (struct cmd_config_all_port_tx_offload_result,
12531 : : port, "port");
12532 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
12533 : : TOKEN_STRING_INITIALIZER
12534 : : (struct cmd_config_all_port_tx_offload_result,
12535 : : config, "config");
12536 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
12537 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
12538 : : port_all, "all");
12539 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
12540 : : TOKEN_STRING_INITIALIZER
12541 : : (struct cmd_config_all_port_tx_offload_result,
12542 : : tx_offload, "tx_offload");
12543 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
12544 : : TOKEN_STRING_INITIALIZER
12545 : : (struct cmd_config_all_port_tx_offload_result,
12546 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12547 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12548 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12549 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12550 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
12551 : : "send_on_timestamp");
12552 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
12553 : : TOKEN_STRING_INITIALIZER
12554 : : (struct cmd_config_all_port_tx_offload_result,
12555 : : on_off, "on#off");
12556 : :
12557 : : static void
12558 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
12559 : : __rte_unused struct cmdline *cl,
12560 : : __rte_unused void *data)
12561 : : {
12562 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
12563 : : portid_t i;
12564 : : bool on_off;
12565 : :
12566 : 0 : on_off = strcmp(res->on_off, "on") == 0;
12567 : 0 : RTE_ETH_FOREACH_DEV(i)
12568 : 0 : config_port_tx_offload(i, res->offload, on_off);
12569 : 0 : }
12570 : :
12571 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
12572 : : .f = cmd_config_all_port_tx_offload_parsed,
12573 : : .data = NULL,
12574 : : .help_str = "port config all tx_offload "
12575 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12576 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12577 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12578 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12579 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
12580 : : "send_on_timestamp on|off",
12581 : : .tokens = {
12582 : : (void *)&cmd_config_all_port_tx_offload_result_port,
12583 : : (void *)&cmd_config_all_port_tx_offload_result_config,
12584 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
12585 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
12586 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
12587 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
12588 : : NULL,
12589 : : }
12590 : : };
12591 : :
12592 : : /* Enable/Disable a per queue offloading */
12593 : : struct cmd_config_per_queue_tx_offload_result {
12594 : : cmdline_fixed_string_t port;
12595 : : portid_t port_id;
12596 : : cmdline_fixed_string_t txq;
12597 : : uint16_t queue_id;
12598 : : cmdline_fixed_string_t tx_offload;
12599 : : cmdline_fixed_string_t offload;
12600 : : cmdline_fixed_string_t on_off;
12601 : : };
12602 : :
12603 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
12604 : : TOKEN_STRING_INITIALIZER
12605 : : (struct cmd_config_per_queue_tx_offload_result,
12606 : : port, "port");
12607 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
12608 : : TOKEN_NUM_INITIALIZER
12609 : : (struct cmd_config_per_queue_tx_offload_result,
12610 : : port_id, RTE_UINT16);
12611 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
12612 : : TOKEN_STRING_INITIALIZER
12613 : : (struct cmd_config_per_queue_tx_offload_result,
12614 : : txq, "txq");
12615 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
12616 : : TOKEN_NUM_INITIALIZER
12617 : : (struct cmd_config_per_queue_tx_offload_result,
12618 : : queue_id, RTE_UINT16);
12619 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
12620 : : TOKEN_STRING_INITIALIZER
12621 : : (struct cmd_config_per_queue_tx_offload_result,
12622 : : tx_offload, "tx_offload");
12623 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
12624 : : TOKEN_STRING_INITIALIZER
12625 : : (struct cmd_config_per_queue_tx_offload_result,
12626 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
12627 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
12628 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
12629 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
12630 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
12631 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
12632 : : TOKEN_STRING_INITIALIZER
12633 : : (struct cmd_config_per_queue_tx_offload_result,
12634 : : on_off, "on#off");
12635 : :
12636 : : static void
12637 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
12638 : : __rte_unused struct cmdline *cl,
12639 : : __rte_unused void *data)
12640 : : {
12641 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
12642 : : struct rte_eth_dev_info dev_info;
12643 : 0 : portid_t port_id = res->port_id;
12644 : 0 : uint16_t queue_id = res->queue_id;
12645 : : struct rte_port *port;
12646 : : uint64_t offload;
12647 : : int ret;
12648 : :
12649 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
12650 : 0 : if (ret != 0)
12651 : 0 : return;
12652 : :
12653 : 0 : port = &ports[port_id];
12654 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
12655 : 0 : fprintf(stderr,
12656 : : "Error: Can't config offload when Port %d is not stopped\n",
12657 : : port_id);
12658 : 0 : return;
12659 : : }
12660 : :
12661 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
12662 : 0 : fprintf(stderr,
12663 : : "Error: input queue_id should be 0 ... %d\n",
12664 : 0 : dev_info.nb_tx_queues - 1);
12665 : 0 : return;
12666 : : }
12667 : :
12668 : 0 : if (!strcmp(res->offload, "all")) {
12669 : 0 : offload = dev_info.tx_queue_offload_capa;
12670 : : } else {
12671 : 0 : offload = search_tx_offload(res->offload);
12672 : 0 : if (offload == 0) {
12673 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12674 : 0 : return;
12675 : : }
12676 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
12677 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12678 : : port_id, res->offload);
12679 : 0 : return;
12680 : : }
12681 : : }
12682 : :
12683 : 0 : if (!strcmp(res->on_off, "on"))
12684 : 0 : port->txq[queue_id].conf.offloads |= offload;
12685 : : else
12686 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
12687 : :
12688 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12689 : : }
12690 : :
12691 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
12692 : : .f = cmd_config_per_queue_tx_offload_parsed,
12693 : : .data = NULL,
12694 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
12695 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12696 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12697 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12698 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12699 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
12700 : : "on|off",
12701 : : .tokens = {
12702 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
12703 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
12704 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
12705 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
12706 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
12707 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
12708 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
12709 : : NULL,
12710 : : }
12711 : : };
12712 : :
12713 : : /* *** configure tx_metadata for specific port *** */
12714 : : struct cmd_config_tx_metadata_specific_result {
12715 : : cmdline_fixed_string_t port;
12716 : : cmdline_fixed_string_t keyword;
12717 : : uint16_t port_id;
12718 : : cmdline_fixed_string_t item;
12719 : : uint32_t value;
12720 : : };
12721 : :
12722 : : static void
12723 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
12724 : : __rte_unused struct cmdline *cl,
12725 : : __rte_unused void *data)
12726 : : {
12727 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
12728 : :
12729 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12730 : : return;
12731 : 0 : ports[res->port_id].tx_metadata = res->value;
12732 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
12733 : 0 : if (ports[res->port_id].tx_metadata)
12734 : 0 : add_tx_md_callback(res->port_id);
12735 : : else
12736 : 0 : remove_tx_md_callback(res->port_id);
12737 : 0 : rte_flow_dynf_metadata_register();
12738 : : }
12739 : :
12740 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
12741 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12742 : : port, "port");
12743 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
12744 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12745 : : keyword, "config");
12746 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
12747 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12748 : : port_id, RTE_UINT16);
12749 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
12750 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12751 : : item, "tx_metadata");
12752 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
12753 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12754 : : value, RTE_UINT32);
12755 : :
12756 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
12757 : : .f = cmd_config_tx_metadata_specific_parsed,
12758 : : .data = NULL,
12759 : : .help_str = "port config <port_id> tx_metadata <value>",
12760 : : .tokens = {
12761 : : (void *)&cmd_config_tx_metadata_specific_port,
12762 : : (void *)&cmd_config_tx_metadata_specific_keyword,
12763 : : (void *)&cmd_config_tx_metadata_specific_id,
12764 : : (void *)&cmd_config_tx_metadata_specific_item,
12765 : : (void *)&cmd_config_tx_metadata_specific_value,
12766 : : NULL,
12767 : : },
12768 : : };
12769 : :
12770 : : /* *** set dynf *** */
12771 : : struct cmd_config_tx_dynf_specific_result {
12772 : : cmdline_fixed_string_t port;
12773 : : cmdline_fixed_string_t keyword;
12774 : : uint16_t port_id;
12775 : : cmdline_fixed_string_t item;
12776 : : cmdline_fixed_string_t name;
12777 : : cmdline_fixed_string_t value;
12778 : : };
12779 : :
12780 : : static void
12781 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
12782 : : __rte_unused struct cmdline *cl,
12783 : : __rte_unused void *data)
12784 : : {
12785 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
12786 : : struct rte_mbuf_dynflag desc_flag;
12787 : : int flag;
12788 : : uint64_t old_port_flags;
12789 : :
12790 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12791 : 0 : return;
12792 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
12793 : 0 : if (flag <= 0) {
12794 : 0 : if (strlcpy(desc_flag.name, res->name,
12795 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
12796 : 0 : fprintf(stderr, "Flag name too long\n");
12797 : 0 : return;
12798 : : }
12799 : 0 : desc_flag.flags = 0;
12800 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
12801 : 0 : if (flag < 0) {
12802 : 0 : fprintf(stderr, "Can't register flag\n");
12803 : 0 : return;
12804 : : }
12805 : 0 : strcpy(dynf_names[flag], desc_flag.name);
12806 : : }
12807 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
12808 : 0 : if (!strcmp(res->value, "set")) {
12809 : 0 : ports[res->port_id].mbuf_dynf |= RTE_BIT64(flag);
12810 : 0 : if (old_port_flags == 0)
12811 : 0 : add_tx_dynf_callback(res->port_id);
12812 : : } else {
12813 : 0 : ports[res->port_id].mbuf_dynf &= ~RTE_BIT64(flag);
12814 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
12815 : 0 : remove_tx_dynf_callback(res->port_id);
12816 : : }
12817 : : }
12818 : :
12819 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
12820 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12821 : : keyword, "port");
12822 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
12823 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12824 : : keyword, "config");
12825 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
12826 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12827 : : port_id, RTE_UINT16);
12828 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
12829 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12830 : : item, "dynf");
12831 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
12832 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12833 : : name, NULL);
12834 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
12835 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12836 : : value, "set#clear");
12837 : :
12838 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
12839 : : .f = cmd_config_dynf_specific_parsed,
12840 : : .data = NULL,
12841 : : .help_str = "port config <port id> dynf <name> set|clear",
12842 : : .tokens = {
12843 : : (void *)&cmd_config_tx_dynf_specific_port,
12844 : : (void *)&cmd_config_tx_dynf_specific_keyword,
12845 : : (void *)&cmd_config_tx_dynf_specific_port_id,
12846 : : (void *)&cmd_config_tx_dynf_specific_item,
12847 : : (void *)&cmd_config_tx_dynf_specific_name,
12848 : : (void *)&cmd_config_tx_dynf_specific_value,
12849 : : NULL,
12850 : : },
12851 : : };
12852 : :
12853 : : /* *** display tx_metadata per port configuration *** */
12854 : : struct cmd_show_tx_metadata_result {
12855 : : cmdline_fixed_string_t cmd_show;
12856 : : cmdline_fixed_string_t cmd_port;
12857 : : cmdline_fixed_string_t cmd_keyword;
12858 : : portid_t cmd_pid;
12859 : : };
12860 : :
12861 : : static void
12862 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
12863 : : __rte_unused struct cmdline *cl,
12864 : : __rte_unused void *data)
12865 : : {
12866 : : struct cmd_show_tx_metadata_result *res = parsed_result;
12867 : :
12868 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12869 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
12870 : 0 : return;
12871 : : }
12872 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
12873 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
12874 : 0 : ports[res->cmd_pid].tx_metadata);
12875 : : }
12876 : : }
12877 : :
12878 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
12879 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12880 : : cmd_show, "show");
12881 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
12882 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12883 : : cmd_port, "port");
12884 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
12885 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
12886 : : cmd_pid, RTE_UINT16);
12887 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
12888 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12889 : : cmd_keyword, "tx_metadata");
12890 : :
12891 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
12892 : : .f = cmd_show_tx_metadata_parsed,
12893 : : .data = NULL,
12894 : : .help_str = "show port <port_id> tx_metadata",
12895 : : .tokens = {
12896 : : (void *)&cmd_show_tx_metadata_show,
12897 : : (void *)&cmd_show_tx_metadata_port,
12898 : : (void *)&cmd_show_tx_metadata_pid,
12899 : : (void *)&cmd_show_tx_metadata_keyword,
12900 : : NULL,
12901 : : },
12902 : : };
12903 : :
12904 : : /* *** show fec capability per port configuration *** */
12905 : : struct cmd_show_fec_capability_result {
12906 : : cmdline_fixed_string_t cmd_show;
12907 : : cmdline_fixed_string_t cmd_port;
12908 : : cmdline_fixed_string_t cmd_fec;
12909 : : cmdline_fixed_string_t cmd_keyword;
12910 : : portid_t cmd_pid;
12911 : : };
12912 : :
12913 : : static void
12914 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
12915 : : __rte_unused struct cmdline *cl,
12916 : : __rte_unused void *data)
12917 : : {
12918 : : struct cmd_show_fec_capability_result *res = parsed_result;
12919 : : struct rte_eth_fec_capa *speed_fec_capa;
12920 : : unsigned int num;
12921 : : int ret;
12922 : :
12923 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12924 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12925 : 0 : return;
12926 : : }
12927 : :
12928 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
12929 : 0 : if (ret == -ENOTSUP) {
12930 : 0 : fprintf(stderr, "Function not implemented\n");
12931 : 0 : return;
12932 : 0 : } else if (ret < 0) {
12933 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
12934 : 0 : return;
12935 : : }
12936 : :
12937 : 0 : num = (unsigned int)ret;
12938 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
12939 : 0 : if (speed_fec_capa == NULL) {
12940 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
12941 : 0 : return;
12942 : : }
12943 : :
12944 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
12945 : 0 : if (ret < 0) {
12946 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
12947 : 0 : goto out;
12948 : : }
12949 : :
12950 : 0 : show_fec_capability(num, speed_fec_capa);
12951 : 0 : out:
12952 : 0 : free(speed_fec_capa);
12953 : : }
12954 : :
12955 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
12956 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12957 : : cmd_show, "show");
12958 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
12959 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12960 : : cmd_port, "port");
12961 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
12962 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
12963 : : cmd_pid, RTE_UINT16);
12964 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
12965 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12966 : : cmd_fec, "fec");
12967 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
12968 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12969 : : cmd_keyword, "capabilities");
12970 : :
12971 : : static cmdline_parse_inst_t cmd_show_capability = {
12972 : : .f = cmd_show_fec_capability_parsed,
12973 : : .data = NULL,
12974 : : .help_str = "show port <port_id> fec capabilities",
12975 : : .tokens = {
12976 : : (void *)&cmd_show_fec_capability_show,
12977 : : (void *)&cmd_show_fec_capability_port,
12978 : : (void *)&cmd_show_fec_capability_pid,
12979 : : (void *)&cmd_show_fec_capability_fec,
12980 : : (void *)&cmd_show_fec_capability_keyword,
12981 : : NULL,
12982 : : },
12983 : : };
12984 : :
12985 : : /* *** show fec mode per port configuration *** */
12986 : : struct cmd_show_fec_metadata_result {
12987 : : cmdline_fixed_string_t cmd_show;
12988 : : cmdline_fixed_string_t cmd_port;
12989 : : cmdline_fixed_string_t cmd_keyword;
12990 : : portid_t cmd_pid;
12991 : : };
12992 : :
12993 : : static void
12994 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
12995 : : __rte_unused struct cmdline *cl,
12996 : : __rte_unused void *data)
12997 : : {
12998 : : #define FEC_NAME_SIZE 16
12999 : : struct cmd_show_fec_metadata_result *res = parsed_result;
13000 : : uint32_t mode;
13001 : : char buf[FEC_NAME_SIZE];
13002 : : int ret;
13003 : :
13004 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
13005 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
13006 : 0 : return;
13007 : : }
13008 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
13009 : 0 : if (ret == -ENOTSUP) {
13010 : 0 : fprintf(stderr, "Function not implemented\n");
13011 : 0 : return;
13012 : 0 : } else if (ret < 0) {
13013 : 0 : fprintf(stderr, "Get FEC mode failed\n");
13014 : 0 : return;
13015 : : }
13016 : :
13017 : 0 : switch (mode) {
13018 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
13019 : : strlcpy(buf, "off", sizeof(buf));
13020 : : break;
13021 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
13022 : : strlcpy(buf, "auto", sizeof(buf));
13023 : : break;
13024 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
13025 : : strlcpy(buf, "baser", sizeof(buf));
13026 : : break;
13027 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
13028 : : strlcpy(buf, "rs", sizeof(buf));
13029 : : break;
13030 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
13031 : : strlcpy(buf, "llrs", sizeof(buf));
13032 : : break;
13033 : : default:
13034 : : return;
13035 : : }
13036 : :
13037 : : printf("%s\n", buf);
13038 : : }
13039 : :
13040 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
13041 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13042 : : cmd_show, "show");
13043 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
13044 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13045 : : cmd_port, "port");
13046 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
13047 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
13048 : : cmd_pid, RTE_UINT16);
13049 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
13050 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
13051 : : cmd_keyword, "fec_mode");
13052 : :
13053 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
13054 : : .f = cmd_show_fec_mode_parsed,
13055 : : .data = NULL,
13056 : : .help_str = "show port <port_id> fec_mode",
13057 : : .tokens = {
13058 : : (void *)&cmd_show_fec_mode_show,
13059 : : (void *)&cmd_show_fec_mode_port,
13060 : : (void *)&cmd_show_fec_mode_pid,
13061 : : (void *)&cmd_show_fec_mode_keyword,
13062 : : NULL,
13063 : : },
13064 : : };
13065 : :
13066 : : /* *** set fec mode per port configuration *** */
13067 : : struct cmd_set_port_fec_mode {
13068 : : cmdline_fixed_string_t set;
13069 : : cmdline_fixed_string_t port;
13070 : : portid_t port_id;
13071 : : cmdline_fixed_string_t fec_mode;
13072 : : cmdline_fixed_string_t fec_value;
13073 : : };
13074 : :
13075 : : /* Common CLI fields for set fec mode */
13076 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
13077 : : TOKEN_STRING_INITIALIZER
13078 : : (struct cmd_set_port_fec_mode,
13079 : : set, "set");
13080 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
13081 : : TOKEN_STRING_INITIALIZER
13082 : : (struct cmd_set_port_fec_mode,
13083 : : port, "port");
13084 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
13085 : : TOKEN_NUM_INITIALIZER
13086 : : (struct cmd_set_port_fec_mode,
13087 : : port_id, RTE_UINT16);
13088 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
13089 : : TOKEN_STRING_INITIALIZER
13090 : : (struct cmd_set_port_fec_mode,
13091 : : fec_mode, "fec_mode");
13092 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
13093 : : TOKEN_STRING_INITIALIZER
13094 : : (struct cmd_set_port_fec_mode,
13095 : : fec_value, NULL);
13096 : :
13097 : : static void
13098 : 0 : cmd_set_port_fec_mode_parsed(
13099 : : void *parsed_result,
13100 : : __rte_unused struct cmdline *cl,
13101 : : __rte_unused void *data)
13102 : : {
13103 : : struct cmd_set_port_fec_mode *res = parsed_result;
13104 : 0 : uint16_t port_id = res->port_id;
13105 : : uint32_t fec_capa;
13106 : : int ret;
13107 : :
13108 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
13109 : 0 : if (ret < 0) {
13110 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
13111 : : res->fec_value, port_id);
13112 : 0 : return;
13113 : : }
13114 : :
13115 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
13116 : 0 : if (ret == -ENOTSUP) {
13117 : 0 : fprintf(stderr, "Function not implemented\n");
13118 : 0 : return;
13119 : 0 : } else if (ret < 0) {
13120 : 0 : fprintf(stderr, "Set FEC mode failed\n");
13121 : 0 : return;
13122 : : }
13123 : : }
13124 : :
13125 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
13126 : : .f = cmd_set_port_fec_mode_parsed,
13127 : : .data = NULL,
13128 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
13129 : : .tokens = {
13130 : : (void *)&cmd_set_port_fec_mode_set,
13131 : : (void *)&cmd_set_port_fec_mode_port,
13132 : : (void *)&cmd_set_port_fec_mode_port_id,
13133 : : (void *)&cmd_set_port_fec_mode_str,
13134 : : (void *)&cmd_set_port_fec_mode_value,
13135 : : NULL,
13136 : : },
13137 : : };
13138 : :
13139 : : /* *** set available descriptors threshold for an RxQ of a port *** */
13140 : : struct cmd_set_rxq_avail_thresh_result {
13141 : : cmdline_fixed_string_t set;
13142 : : cmdline_fixed_string_t port;
13143 : : uint16_t port_num;
13144 : : cmdline_fixed_string_t rxq;
13145 : : uint16_t rxq_num;
13146 : : cmdline_fixed_string_t avail_thresh;
13147 : : uint8_t avail_thresh_num;
13148 : : };
13149 : :
13150 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
13151 : : __rte_unused struct cmdline *cl,
13152 : : __rte_unused void *data)
13153 : : {
13154 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
13155 : : int ret = 0;
13156 : :
13157 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
13158 : 0 : && (strcmp(res->rxq, "rxq") == 0)
13159 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
13160 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
13161 : 0 : res->avail_thresh_num);
13162 : 0 : if (ret < 0)
13163 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
13164 : :
13165 : 0 : }
13166 : :
13167 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
13168 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13169 : : set, "set");
13170 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
13171 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13172 : : port, "port");
13173 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
13174 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13175 : : port_num, RTE_UINT16);
13176 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
13177 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13178 : : rxq, "rxq");
13179 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
13180 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13181 : : rxq_num, RTE_UINT16);
13182 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
13183 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13184 : : avail_thresh, "avail_thresh");
13185 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
13186 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
13187 : : avail_thresh_num, RTE_UINT8);
13188 : :
13189 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
13190 : : .f = cmd_set_rxq_avail_thresh_parsed,
13191 : : .data = (void *)0,
13192 : : .help_str =
13193 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
13194 : : "Set available descriptors threshold for Rx queue",
13195 : : .tokens = {
13196 : : (void *)&cmd_set_rxq_avail_thresh_set,
13197 : : (void *)&cmd_set_rxq_avail_thresh_port,
13198 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
13199 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
13200 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
13201 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
13202 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
13203 : : NULL,
13204 : : },
13205 : : };
13206 : :
13207 : : /* show port supported ptypes */
13208 : :
13209 : : /* Common result structure for show port ptypes */
13210 : : struct cmd_show_port_supported_ptypes_result {
13211 : : cmdline_fixed_string_t show;
13212 : : cmdline_fixed_string_t port;
13213 : : portid_t port_id;
13214 : : cmdline_fixed_string_t ptypes;
13215 : : };
13216 : :
13217 : : /* Common CLI fields for show port ptypes */
13218 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
13219 : : TOKEN_STRING_INITIALIZER
13220 : : (struct cmd_show_port_supported_ptypes_result,
13221 : : show, "show");
13222 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
13223 : : TOKEN_STRING_INITIALIZER
13224 : : (struct cmd_show_port_supported_ptypes_result,
13225 : : port, "port");
13226 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
13227 : : TOKEN_NUM_INITIALIZER
13228 : : (struct cmd_show_port_supported_ptypes_result,
13229 : : port_id, RTE_UINT16);
13230 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
13231 : : TOKEN_STRING_INITIALIZER
13232 : : (struct cmd_show_port_supported_ptypes_result,
13233 : : ptypes, "ptypes");
13234 : :
13235 : : static void
13236 : 0 : cmd_show_port_supported_ptypes_parsed(
13237 : : void *parsed_result,
13238 : : __rte_unused struct cmdline *cl,
13239 : : __rte_unused void *data)
13240 : : {
13241 : : #define RSVD_PTYPE_MASK 0xf0000000
13242 : : #define MAX_PTYPES_PER_LAYER 16
13243 : : #define LTYPE_NAMESIZE 32
13244 : : #define PTYPE_NAMESIZE 256
13245 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
13246 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
13247 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
13248 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
13249 : 0 : uint16_t port_id = res->port_id;
13250 : : int ret, i;
13251 : :
13252 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
13253 : 0 : if (ret < 0)
13254 : 0 : return;
13255 : :
13256 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
13257 : :
13258 : 0 : switch (ptype_mask) {
13259 : : case RTE_PTYPE_L2_MASK:
13260 : : strlcpy(ltype, "L2", sizeof(ltype));
13261 : : break;
13262 : : case RTE_PTYPE_L3_MASK:
13263 : : strlcpy(ltype, "L3", sizeof(ltype));
13264 : : break;
13265 : : case RTE_PTYPE_L4_MASK:
13266 : : strlcpy(ltype, "L4", sizeof(ltype));
13267 : : break;
13268 : : case RTE_PTYPE_TUNNEL_MASK:
13269 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
13270 : : break;
13271 : : case RTE_PTYPE_INNER_L2_MASK:
13272 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
13273 : : break;
13274 : : case RTE_PTYPE_INNER_L3_MASK:
13275 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
13276 : : break;
13277 : : case RTE_PTYPE_INNER_L4_MASK:
13278 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
13279 : : break;
13280 : : default:
13281 : : return;
13282 : : }
13283 : :
13284 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
13285 : : ptype_mask, ptypes,
13286 : : MAX_PTYPES_PER_LAYER);
13287 : :
13288 : 0 : if (ret > 0)
13289 : : printf("Supported %s ptypes:\n", ltype);
13290 : : else
13291 : : printf("%s ptypes unsupported\n", ltype);
13292 : :
13293 : 0 : for (i = 0; i < ret; ++i) {
13294 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
13295 : : printf("%s\n", buf);
13296 : : }
13297 : :
13298 : 0 : ptype_mask <<= 4;
13299 : : }
13300 : : }
13301 : :
13302 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
13303 : : .f = cmd_show_port_supported_ptypes_parsed,
13304 : : .data = NULL,
13305 : : .help_str = "show port <port_id> ptypes",
13306 : : .tokens = {
13307 : : (void *)&cmd_show_port_supported_ptypes_show,
13308 : : (void *)&cmd_show_port_supported_ptypes_port,
13309 : : (void *)&cmd_show_port_supported_ptypes_port_id,
13310 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
13311 : : NULL,
13312 : : },
13313 : : };
13314 : :
13315 : : /* *** display rx/tx descriptor status *** */
13316 : : struct cmd_show_rx_tx_desc_status_result {
13317 : : cmdline_fixed_string_t cmd_show;
13318 : : cmdline_fixed_string_t cmd_port;
13319 : : cmdline_fixed_string_t cmd_keyword;
13320 : : cmdline_fixed_string_t cmd_desc;
13321 : : cmdline_fixed_string_t cmd_status;
13322 : : portid_t cmd_pid;
13323 : : portid_t cmd_qid;
13324 : : portid_t cmd_did;
13325 : : };
13326 : :
13327 : : static void
13328 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
13329 : : __rte_unused struct cmdline *cl,
13330 : : __rte_unused void *data)
13331 : : {
13332 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
13333 : : int rc;
13334 : :
13335 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
13336 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13337 : 0 : fprintf(stderr,
13338 : : "Invalid input: port id = %d, queue id = %d\n",
13339 : 0 : res->cmd_pid, res->cmd_qid);
13340 : 0 : return;
13341 : : }
13342 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
13343 : 0 : res->cmd_did);
13344 : 0 : if (rc < 0) {
13345 : 0 : fprintf(stderr,
13346 : : "Invalid input: queue id = %d, desc id = %d\n",
13347 : 0 : res->cmd_qid, res->cmd_did);
13348 : 0 : return;
13349 : : }
13350 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
13351 : : printf("Desc status = AVAILABLE\n");
13352 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
13353 : : printf("Desc status = DONE\n");
13354 : : else
13355 : : printf("Desc status = UNAVAILABLE\n");
13356 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
13357 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13358 : 0 : fprintf(stderr,
13359 : : "Invalid input: port id = %d, queue id = %d\n",
13360 : 0 : res->cmd_pid, res->cmd_qid);
13361 : 0 : return;
13362 : : }
13363 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
13364 : 0 : res->cmd_did);
13365 : 0 : if (rc < 0) {
13366 : 0 : fprintf(stderr,
13367 : : "Invalid input: queue id = %d, desc id = %d\n",
13368 : 0 : res->cmd_qid, res->cmd_did);
13369 : 0 : return;
13370 : : }
13371 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
13372 : : printf("Desc status = FULL\n");
13373 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
13374 : : printf("Desc status = DONE\n");
13375 : : else
13376 : : printf("Desc status = UNAVAILABLE\n");
13377 : : }
13378 : : }
13379 : :
13380 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
13381 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13382 : : cmd_show, "show");
13383 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
13384 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13385 : : cmd_port, "port");
13386 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
13387 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13388 : : cmd_pid, RTE_UINT16);
13389 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
13390 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13391 : : cmd_keyword, "rxq#txq");
13392 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
13393 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13394 : : cmd_qid, RTE_UINT16);
13395 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
13396 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13397 : : cmd_desc, "desc");
13398 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
13399 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13400 : : cmd_did, RTE_UINT16);
13401 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
13402 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
13403 : : cmd_status, "status");
13404 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
13405 : : .f = cmd_show_rx_tx_desc_status_parsed,
13406 : : .data = NULL,
13407 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
13408 : : "status",
13409 : : .tokens = {
13410 : : (void *)&cmd_show_rx_tx_desc_status_show,
13411 : : (void *)&cmd_show_rx_tx_desc_status_port,
13412 : : (void *)&cmd_show_rx_tx_desc_status_pid,
13413 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
13414 : : (void *)&cmd_show_rx_tx_desc_status_qid,
13415 : : (void *)&cmd_show_rx_tx_desc_status_desc,
13416 : : (void *)&cmd_show_rx_tx_desc_status_did,
13417 : : (void *)&cmd_show_rx_tx_desc_status_status,
13418 : : NULL,
13419 : : },
13420 : : };
13421 : :
13422 : : /* *** display rx/tx queue descriptor used count *** */
13423 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
13424 : : cmdline_fixed_string_t cmd_show;
13425 : : cmdline_fixed_string_t cmd_port;
13426 : : cmdline_fixed_string_t cmd_dir;
13427 : : cmdline_fixed_string_t cmd_desc;
13428 : : cmdline_fixed_string_t cmd_used;
13429 : : cmdline_fixed_string_t cmd_count;
13430 : : portid_t cmd_pid;
13431 : : portid_t cmd_qid;
13432 : : };
13433 : :
13434 : : static void
13435 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
13436 : : __rte_unused void *data)
13437 : : {
13438 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
13439 : : int rc;
13440 : :
13441 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
13442 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13443 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13444 : 0 : res->cmd_pid, res->cmd_qid);
13445 : 0 : return;
13446 : : }
13447 : :
13448 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
13449 : 0 : if (rc < 0) {
13450 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
13451 : 0 : res->cmd_qid);
13452 : 0 : return;
13453 : : }
13454 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
13455 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
13456 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
13457 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
13458 : 0 : res->cmd_pid, res->cmd_qid);
13459 : 0 : return;
13460 : : }
13461 : :
13462 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
13463 : 0 : if (rc < 0) {
13464 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
13465 : 0 : res->cmd_qid);
13466 : 0 : return;
13467 : : }
13468 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
13469 : : }
13470 : : }
13471 : :
13472 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
13473 : : TOKEN_STRING_INITIALIZER
13474 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13475 : : cmd_show, "show");
13476 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
13477 : : TOKEN_STRING_INITIALIZER
13478 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13479 : : cmd_port, "port");
13480 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
13481 : : TOKEN_NUM_INITIALIZER
13482 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13483 : : cmd_pid, RTE_UINT16);
13484 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
13485 : : TOKEN_STRING_INITIALIZER
13486 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13487 : : cmd_dir, "rxq#txq");
13488 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
13489 : : TOKEN_NUM_INITIALIZER
13490 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13491 : : cmd_qid, RTE_UINT16);
13492 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
13493 : : TOKEN_STRING_INITIALIZER
13494 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13495 : : cmd_desc, "desc");
13496 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
13497 : : TOKEN_STRING_INITIALIZER
13498 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13499 : : cmd_count, "used");
13500 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
13501 : : TOKEN_STRING_INITIALIZER
13502 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
13503 : : cmd_count, "count");
13504 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
13505 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
13506 : : .data = NULL,
13507 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
13508 : : .tokens = {
13509 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
13510 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
13511 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
13512 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
13513 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
13514 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
13515 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
13516 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
13517 : : NULL,
13518 : : },
13519 : : };
13520 : :
13521 : : /* Common result structure for set port ptypes */
13522 : : struct cmd_set_port_ptypes_result {
13523 : : cmdline_fixed_string_t set;
13524 : : cmdline_fixed_string_t port;
13525 : : portid_t port_id;
13526 : : cmdline_fixed_string_t ptype_mask;
13527 : : uint32_t mask;
13528 : : };
13529 : :
13530 : : /* Common CLI fields for set port ptypes */
13531 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
13532 : : TOKEN_STRING_INITIALIZER
13533 : : (struct cmd_set_port_ptypes_result,
13534 : : set, "set");
13535 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
13536 : : TOKEN_STRING_INITIALIZER
13537 : : (struct cmd_set_port_ptypes_result,
13538 : : port, "port");
13539 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
13540 : : TOKEN_NUM_INITIALIZER
13541 : : (struct cmd_set_port_ptypes_result,
13542 : : port_id, RTE_UINT16);
13543 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
13544 : : TOKEN_STRING_INITIALIZER
13545 : : (struct cmd_set_port_ptypes_result,
13546 : : ptype_mask, "ptype_mask");
13547 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
13548 : : TOKEN_NUM_INITIALIZER
13549 : : (struct cmd_set_port_ptypes_result,
13550 : : mask, RTE_UINT32);
13551 : :
13552 : : static void
13553 : 0 : cmd_set_port_ptypes_parsed(
13554 : : void *parsed_result,
13555 : : __rte_unused struct cmdline *cl,
13556 : : __rte_unused void *data)
13557 : : {
13558 : : struct cmd_set_port_ptypes_result *res = parsed_result;
13559 : : #define PTYPE_NAMESIZE 256
13560 : : char ptype_name[PTYPE_NAMESIZE];
13561 : 0 : uint16_t port_id = res->port_id;
13562 : 0 : uint32_t ptype_mask = res->mask;
13563 : : int ret, i;
13564 : :
13565 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
13566 : : NULL, 0);
13567 : 0 : if (ret <= 0) {
13568 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
13569 : : port_id);
13570 : 0 : return;
13571 : : }
13572 : :
13573 : 0 : uint32_t *ptypes = alloca(sizeof(uint32_t) * ret);
13574 : :
13575 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
13576 : 0 : if (ret < 0) {
13577 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
13578 : : port_id);
13579 : 0 : return;
13580 : : }
13581 : :
13582 : : printf("Successfully set following ptypes for Port %d\n", port_id);
13583 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
13584 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
13585 : : printf("%s\n", ptype_name);
13586 : : }
13587 : :
13588 : 0 : clear_ptypes = false;
13589 : : }
13590 : :
13591 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
13592 : : .f = cmd_set_port_ptypes_parsed,
13593 : : .data = NULL,
13594 : : .help_str = "set port <port_id> ptype_mask <mask>",
13595 : : .tokens = {
13596 : : (void *)&cmd_set_port_ptypes_set,
13597 : : (void *)&cmd_set_port_ptypes_port,
13598 : : (void *)&cmd_set_port_ptypes_port_id,
13599 : : (void *)&cmd_set_port_ptypes_mask_str,
13600 : : (void *)&cmd_set_port_ptypes_mask_u32,
13601 : : NULL,
13602 : : },
13603 : : };
13604 : :
13605 : : /* *** display mac addresses added to a port *** */
13606 : : struct cmd_showport_macs_result {
13607 : : cmdline_fixed_string_t cmd_show;
13608 : : cmdline_fixed_string_t cmd_port;
13609 : : cmdline_fixed_string_t cmd_keyword;
13610 : : portid_t cmd_pid;
13611 : : };
13612 : :
13613 : : static void
13614 : 0 : cmd_showport_macs_parsed(void *parsed_result,
13615 : : __rte_unused struct cmdline *cl,
13616 : : __rte_unused void *data)
13617 : : {
13618 : : struct cmd_showport_macs_result *res = parsed_result;
13619 : :
13620 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
13621 : : return;
13622 : :
13623 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
13624 : 0 : show_macs(res->cmd_pid);
13625 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
13626 : 0 : show_mcast_macs(res->cmd_pid);
13627 : : }
13628 : :
13629 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
13630 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13631 : : cmd_show, "show");
13632 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
13633 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13634 : : cmd_port, "port");
13635 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
13636 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
13637 : : cmd_pid, RTE_UINT16);
13638 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
13639 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
13640 : : cmd_keyword, "macs#mcast_macs");
13641 : :
13642 : : static cmdline_parse_inst_t cmd_showport_macs = {
13643 : : .f = cmd_showport_macs_parsed,
13644 : : .data = NULL,
13645 : : .help_str = "show port <port_id> macs|mcast_macs",
13646 : : .tokens = {
13647 : : (void *)&cmd_showport_macs_show,
13648 : : (void *)&cmd_showport_macs_port,
13649 : : (void *)&cmd_showport_macs_pid,
13650 : : (void *)&cmd_showport_macs_keyword,
13651 : : NULL,
13652 : : },
13653 : : };
13654 : :
13655 : : /* *** show flow transfer proxy port ID for the given port *** */
13656 : : struct cmd_show_port_flow_transfer_proxy_result {
13657 : : cmdline_fixed_string_t show;
13658 : : cmdline_fixed_string_t port;
13659 : : portid_t port_id;
13660 : : cmdline_fixed_string_t flow;
13661 : : cmdline_fixed_string_t transfer;
13662 : : cmdline_fixed_string_t proxy;
13663 : : };
13664 : :
13665 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
13666 : : TOKEN_STRING_INITIALIZER
13667 : : (struct cmd_show_port_flow_transfer_proxy_result,
13668 : : show, "show");
13669 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
13670 : : TOKEN_STRING_INITIALIZER
13671 : : (struct cmd_show_port_flow_transfer_proxy_result,
13672 : : port, "port");
13673 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
13674 : : TOKEN_NUM_INITIALIZER
13675 : : (struct cmd_show_port_flow_transfer_proxy_result,
13676 : : port_id, RTE_UINT16);
13677 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
13678 : : TOKEN_STRING_INITIALIZER
13679 : : (struct cmd_show_port_flow_transfer_proxy_result,
13680 : : flow, "flow");
13681 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
13682 : : TOKEN_STRING_INITIALIZER
13683 : : (struct cmd_show_port_flow_transfer_proxy_result,
13684 : : transfer, "transfer");
13685 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
13686 : : TOKEN_STRING_INITIALIZER
13687 : : (struct cmd_show_port_flow_transfer_proxy_result,
13688 : : proxy, "proxy");
13689 : :
13690 : : static void
13691 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
13692 : : __rte_unused struct cmdline *cl,
13693 : : __rte_unused void *data)
13694 : : {
13695 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
13696 : : portid_t proxy_port_id;
13697 : : int ret;
13698 : :
13699 : : printf("\n");
13700 : :
13701 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
13702 : 0 : if (ret != 0) {
13703 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
13704 : : rte_strerror(-ret));
13705 : 0 : return;
13706 : : }
13707 : :
13708 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
13709 : : }
13710 : :
13711 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
13712 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
13713 : : .data = NULL,
13714 : : .help_str = "show port <port_id> flow transfer proxy",
13715 : : .tokens = {
13716 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
13717 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
13718 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
13719 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
13720 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
13721 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
13722 : : NULL,
13723 : : }
13724 : : };
13725 : :
13726 : : /* *** configure port txq affinity value *** */
13727 : : struct cmd_config_tx_affinity_map {
13728 : : cmdline_fixed_string_t port;
13729 : : cmdline_fixed_string_t config;
13730 : : portid_t portid;
13731 : : cmdline_fixed_string_t txq;
13732 : : uint16_t qid;
13733 : : cmdline_fixed_string_t affinity;
13734 : : uint8_t value;
13735 : : };
13736 : :
13737 : : static void
13738 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
13739 : : __rte_unused struct cmdline *cl,
13740 : : __rte_unused void *data)
13741 : : {
13742 : : struct cmd_config_tx_affinity_map *res = parsed_result;
13743 : : int ret;
13744 : :
13745 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
13746 : : return;
13747 : :
13748 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
13749 : : printf("Invalid port id\n");
13750 : 0 : return;
13751 : : }
13752 : :
13753 : 0 : if (strcmp(res->txq, "txq")) {
13754 : : printf("Unknown parameter\n");
13755 : 0 : return;
13756 : : }
13757 : 0 : if (tx_queue_id_is_invalid(res->qid))
13758 : : return;
13759 : :
13760 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
13761 : 0 : if (ret < 0) {
13762 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
13763 : : strerror(-ret));
13764 : 0 : return;
13765 : : }
13766 : :
13767 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
13768 : 0 : if (ret != 0) {
13769 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
13770 : : rte_strerror(-ret));
13771 : 0 : return;
13772 : : }
13773 : : }
13774 : :
13775 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
13776 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13777 : : port, "port");
13778 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
13779 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13780 : : config, "config");
13781 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
13782 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13783 : : portid, RTE_UINT16);
13784 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
13785 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13786 : : txq, "txq");
13787 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
13788 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13789 : : qid, RTE_UINT16);
13790 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
13791 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13792 : : affinity, "affinity");
13793 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
13794 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13795 : : value, RTE_UINT8);
13796 : :
13797 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
13798 : : .f = cmd_config_tx_affinity_map_parsed,
13799 : : .data = (void *)0,
13800 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
13801 : : .tokens = {
13802 : : (void *)&cmd_config_tx_affinity_map_port,
13803 : : (void *)&cmd_config_tx_affinity_map_config,
13804 : : (void *)&cmd_config_tx_affinity_map_portid,
13805 : : (void *)&cmd_config_tx_affinity_map_txq,
13806 : : (void *)&cmd_config_tx_affinity_map_qid,
13807 : : (void *)&cmd_config_tx_affinity_map_affinity,
13808 : : (void *)&cmd_config_tx_affinity_map_value,
13809 : : NULL,
13810 : : },
13811 : : };
13812 : :
13813 : : /* *** SET THE LED FOR CERTAIN PORT TO ON/OFF *** */
13814 : : struct cmd_dev_led_result {
13815 : : cmdline_fixed_string_t set;
13816 : : cmdline_fixed_string_t port;
13817 : : portid_t port_id;
13818 : : cmdline_fixed_string_t led;
13819 : : cmdline_fixed_string_t state;
13820 : : };
13821 : :
13822 : : static void
13823 : 0 : cmd_set_dev_led_parsed(void *parsed_result,
13824 : : __rte_unused struct cmdline *cl,
13825 : : __rte_unused void *data)
13826 : : {
13827 : : struct cmd_dev_led_result *res = parsed_result;
13828 : :
13829 : 0 : if (strcmp(res->state, "on") == 0)
13830 : 0 : set_dev_led(res->port_id, true);
13831 : : else
13832 : 0 : set_dev_led(res->port_id, false);
13833 : 0 : }
13834 : :
13835 : : static cmdline_parse_token_string_t cmd_dev_led_set =
13836 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, set, "set");
13837 : : static cmdline_parse_token_string_t cmd_dev_led_port =
13838 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, port, "port");
13839 : : static cmdline_parse_token_num_t cmd_dev_led_port_id =
13840 : : TOKEN_NUM_INITIALIZER(struct cmd_dev_led_result, port_id, RTE_UINT16);
13841 : : static cmdline_parse_token_string_t cmd_dev_led =
13842 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, led, "led");
13843 : : static cmdline_parse_token_string_t cmd_dev_state =
13844 : : TOKEN_STRING_INITIALIZER(struct cmd_dev_led_result, state, "on#off");
13845 : :
13846 : : static cmdline_parse_inst_t cmd_set_dev_led = {
13847 : : .f = cmd_set_dev_led_parsed,
13848 : : .data = NULL,
13849 : : .help_str = "set port <port_id> led <on/off>",
13850 : : .tokens = {
13851 : : (void *)&cmd_dev_led_set,
13852 : : (void *)&cmd_dev_led_port,
13853 : : (void *)&cmd_dev_led_port_id,
13854 : : (void *)&cmd_dev_led,
13855 : : (void *)&cmd_dev_state,
13856 : : NULL,
13857 : : },
13858 : : };
13859 : :
13860 : : /* ******************************************************************************** */
13861 : :
13862 : : /* list of instructions */
13863 : : static cmdline_parse_ctx_t builtin_ctx[] = {
13864 : : &cmd_help_brief,
13865 : : &cmd_help_long,
13866 : : &cmd_quit,
13867 : : &cmd_load_from_file,
13868 : : &cmd_showport,
13869 : : &cmd_showqueue,
13870 : : &cmd_showeeprom,
13871 : : &cmd_seteeprom,
13872 : : &cmd_showportall,
13873 : : &cmd_representor_info,
13874 : : &cmd_showdevice,
13875 : : &cmd_showcfg,
13876 : : &cmd_showfwdall,
13877 : : &cmd_start,
13878 : : &cmd_start_tx_first,
13879 : : &cmd_start_tx_first_n,
13880 : : &cmd_set_link_up,
13881 : : &cmd_set_link_down,
13882 : : &cmd_reset,
13883 : : &cmd_set_numbers,
13884 : : &cmd_set_log,
13885 : : &cmd_set_rxoffs,
13886 : : &cmd_set_rxpkts,
13887 : : &cmd_set_rxhdrs,
13888 : : &cmd_set_txpkts,
13889 : : &cmd_set_txsplit,
13890 : : &cmd_set_txtimes,
13891 : : &cmd_set_fwd_list,
13892 : : &cmd_set_fwd_mask,
13893 : : &cmd_set_fwd_mode,
13894 : : &cmd_set_fwd_retry_mode,
13895 : : &cmd_set_burst_tx_retry,
13896 : : &cmd_set_promisc_mode_one,
13897 : : &cmd_set_promisc_mode_all,
13898 : : &cmd_set_allmulti_mode_one,
13899 : : &cmd_set_allmulti_mode_all,
13900 : : &cmd_set_flush_rx,
13901 : : &cmd_set_link_check,
13902 : : &cmd_vlan_offload,
13903 : : &cmd_vlan_tpid,
13904 : : &cmd_rx_vlan_filter_all,
13905 : : &cmd_rx_vlan_filter,
13906 : : &cmd_tx_vlan_set,
13907 : : &cmd_tx_vlan_set_qinq,
13908 : : &cmd_tx_vlan_reset,
13909 : : &cmd_tx_vlan_set_pvid,
13910 : : &cmd_csum_set,
13911 : : &cmd_csum_show,
13912 : : &cmd_csum_tunnel,
13913 : : &cmd_csum_mac_swap,
13914 : : &cmd_tso_set,
13915 : : &cmd_tso_show,
13916 : : &cmd_tunnel_tso_set,
13917 : : &cmd_tunnel_tso_show,
13918 : : #ifdef RTE_LIB_GRO
13919 : : &cmd_gro_enable,
13920 : : &cmd_gro_flush,
13921 : : &cmd_gro_show,
13922 : : #endif
13923 : : #ifdef RTE_LIB_GSO
13924 : : &cmd_gso_enable,
13925 : : &cmd_gso_size,
13926 : : &cmd_gso_show,
13927 : : #endif
13928 : : &cmd_link_flow_control_set,
13929 : : &cmd_link_flow_control_set_rx,
13930 : : &cmd_link_flow_control_set_tx,
13931 : : &cmd_link_flow_control_set_hw,
13932 : : &cmd_link_flow_control_set_lw,
13933 : : &cmd_link_flow_control_set_pt,
13934 : : &cmd_link_flow_control_set_xon,
13935 : : &cmd_link_flow_control_set_macfwd,
13936 : : &cmd_link_flow_control_set_autoneg,
13937 : : &cmd_link_flow_control_show,
13938 : : &cmd_priority_flow_control_set,
13939 : : &cmd_queue_priority_flow_control_set,
13940 : : &cmd_config_dcb,
13941 : : &cmd_read_rxd_txd,
13942 : : &cmd_stop,
13943 : : &cmd_mac_addr,
13944 : : &cmd_set_fwd_eth_peer,
13945 : : &cmd_set_qmap,
13946 : : &cmd_set_xstats_hide_zero,
13947 : : &cmd_set_xstats_show_state,
13948 : : &cmd_set_xstats_hide_disabled,
13949 : : &cmd_operate_set_counter,
13950 : : &cmd_set_record_core_cycles,
13951 : : &cmd_set_record_burst_stats,
13952 : : &cmd_operate_port,
13953 : : &cmd_operate_specific_port,
13954 : : &cmd_operate_attach_port,
13955 : : &cmd_operate_detach_port,
13956 : : &cmd_operate_detach_device,
13957 : : &cmd_set_port_setup_on,
13958 : : &cmd_config_speed_all,
13959 : : &cmd_config_speed_specific,
13960 : : &cmd_config_speed_lanes_all,
13961 : : &cmd_config_speed_lanes_specific,
13962 : : &cmd_show_speed_lanes,
13963 : : &cmd_config_loopback_all,
13964 : : &cmd_config_loopback_specific,
13965 : : &cmd_config_rx_tx,
13966 : : &cmd_config_mtu,
13967 : : &cmd_config_max_pkt_len,
13968 : : &cmd_config_max_lro_pkt_size,
13969 : : &cmd_config_rx_mode_flag,
13970 : : &cmd_config_rss,
13971 : : &cmd_config_rxtx_ring_size,
13972 : : &cmd_config_rxtx_queue,
13973 : : &cmd_config_deferred_start_rxtx_queue,
13974 : : &cmd_setup_rxtx_queue,
13975 : : &cmd_config_rss_reta,
13976 : : &cmd_showport_reta,
13977 : : &cmd_showport_macs,
13978 : : &cmd_show_port_flow_transfer_proxy,
13979 : : &cmd_config_burst,
13980 : : &cmd_config_thresh,
13981 : : &cmd_config_threshold,
13982 : : &cmd_set_uc_hash_filter,
13983 : : &cmd_set_uc_all_hash_filter,
13984 : : &cmd_vf_mac_addr_filter,
13985 : : &cmd_queue_rate_limit,
13986 : : &cmd_tunnel_udp_config,
13987 : : &cmd_showport_rss_hash,
13988 : : &cmd_showport_rss_hash_key,
13989 : : &cmd_showport_rss_hash_algo,
13990 : : &cmd_config_rss_hash_key,
13991 : : &cmd_config_rss_hash_algo,
13992 : : &cmd_cleanup_txq_mbufs,
13993 : : &cmd_dump,
13994 : : &cmd_dump_one,
13995 : : &cmd_flow,
13996 : : &cmd_show_port_meter_cap,
13997 : : &cmd_add_port_meter_profile_srtcm,
13998 : : &cmd_add_port_meter_profile_trtcm,
13999 : : &cmd_add_port_meter_profile_trtcm_rfc4115,
14000 : : &cmd_del_port_meter_profile,
14001 : : &cmd_create_port_meter,
14002 : : &cmd_enable_port_meter,
14003 : : &cmd_disable_port_meter,
14004 : : &cmd_del_port_meter,
14005 : : &cmd_del_port_meter_policy,
14006 : : &cmd_set_port_meter_profile,
14007 : : &cmd_set_port_meter_dscp_table,
14008 : : &cmd_set_port_meter_vlan_table,
14009 : : &cmd_set_port_meter_in_proto,
14010 : : &cmd_get_port_meter_in_proto,
14011 : : &cmd_get_port_meter_in_proto_prio,
14012 : : &cmd_set_port_meter_stats_mask,
14013 : : &cmd_show_port_meter_stats,
14014 : : &cmd_mcast_addr,
14015 : : &cmd_mcast_addr_flush,
14016 : : &cmd_set_vf_vlan_anti_spoof,
14017 : : &cmd_set_vf_mac_anti_spoof,
14018 : : &cmd_set_vf_vlan_stripq,
14019 : : &cmd_set_vf_vlan_insert,
14020 : : &cmd_set_tx_loopback,
14021 : : &cmd_set_all_queues_drop_en,
14022 : : &cmd_set_vf_traffic,
14023 : : &cmd_set_vf_rxmode,
14024 : : &cmd_vf_rate_limit,
14025 : : &cmd_vf_rxvlan_filter,
14026 : : &cmd_set_vf_mac_addr,
14027 : : &cmd_set_vxlan,
14028 : : &cmd_set_vxlan_tos_ttl,
14029 : : &cmd_set_vxlan_with_vlan,
14030 : : &cmd_set_nvgre,
14031 : : &cmd_set_nvgre_with_vlan,
14032 : : &cmd_set_l2_encap,
14033 : : &cmd_set_l2_encap_with_vlan,
14034 : : &cmd_set_l2_decap,
14035 : : &cmd_set_l2_decap_with_vlan,
14036 : : &cmd_set_mplsogre_encap,
14037 : : &cmd_set_mplsogre_encap_with_vlan,
14038 : : &cmd_set_mplsogre_decap,
14039 : : &cmd_set_mplsogre_decap_with_vlan,
14040 : : &cmd_set_mplsoudp_encap,
14041 : : &cmd_set_mplsoudp_encap_with_vlan,
14042 : : &cmd_set_mplsoudp_decap,
14043 : : &cmd_set_mplsoudp_decap_with_vlan,
14044 : : &cmd_set_conntrack_common,
14045 : : &cmd_set_conntrack_dir,
14046 : : &cmd_show_vf_stats,
14047 : : &cmd_clear_vf_stats,
14048 : : &cmd_show_port_supported_ptypes,
14049 : : &cmd_set_port_ptypes,
14050 : : &cmd_show_port_tm_cap,
14051 : : &cmd_show_port_tm_level_cap,
14052 : : &cmd_show_port_tm_node,
14053 : : &cmd_show_port_tm_node_cap,
14054 : : &cmd_show_port_tm_node_type,
14055 : : &cmd_show_port_tm_node_stats,
14056 : : &cmd_add_port_tm_node_shaper_profile,
14057 : : &cmd_del_port_tm_node_shaper_profile,
14058 : : &cmd_add_port_tm_node_shared_shaper,
14059 : : &cmd_del_port_tm_node_shared_shaper,
14060 : : &cmd_add_port_tm_node_wred_profile,
14061 : : &cmd_del_port_tm_node_wred_profile,
14062 : : &cmd_set_port_tm_node_shaper_profile,
14063 : : &cmd_add_port_tm_nonleaf_node,
14064 : : &cmd_add_port_tm_nonleaf_node_pmode,
14065 : : &cmd_add_port_tm_leaf_node,
14066 : : &cmd_del_port_tm_node,
14067 : : &cmd_set_port_tm_node_parent,
14068 : : &cmd_suspend_port_tm_node,
14069 : : &cmd_resume_port_tm_node,
14070 : : &cmd_port_tm_hierarchy_commit,
14071 : : &cmd_port_tm_mark_ip_ecn,
14072 : : &cmd_port_tm_mark_ip_dscp,
14073 : : &cmd_port_tm_mark_vlan_dei,
14074 : : &cmd_cfg_tunnel_udp_port,
14075 : : &cmd_rx_offload_get_capa,
14076 : : &cmd_rx_offload_get_configuration,
14077 : : &cmd_config_per_port_rx_offload,
14078 : : &cmd_config_all_port_rx_offload,
14079 : : &cmd_config_per_queue_rx_offload,
14080 : : &cmd_tx_offload_get_capa,
14081 : : &cmd_tx_offload_get_configuration,
14082 : : &cmd_config_per_port_tx_offload,
14083 : : &cmd_config_all_port_tx_offload,
14084 : : &cmd_config_per_queue_tx_offload,
14085 : : #ifdef RTE_LIB_BPF
14086 : : &cmd_operate_bpf_ld_parse,
14087 : : &cmd_operate_bpf_unld_parse,
14088 : : #endif
14089 : : &cmd_config_tx_metadata_specific,
14090 : : &cmd_show_tx_metadata,
14091 : : &cmd_show_rx_tx_desc_status,
14092 : : &cmd_show_rx_tx_queue_desc_used_count,
14093 : : &cmd_set_raw,
14094 : : &cmd_show_set_raw,
14095 : : &cmd_show_set_raw_all,
14096 : : &cmd_config_tx_dynf_specific,
14097 : : &cmd_show_fec_mode,
14098 : : &cmd_set_fec_mode,
14099 : : &cmd_set_rxq_avail_thresh,
14100 : : &cmd_show_capability,
14101 : : &cmd_set_flex_is_pattern,
14102 : : &cmd_set_flex_spec_pattern,
14103 : : &cmd_show_port_cman_capa,
14104 : : &cmd_show_port_cman_config,
14105 : : &cmd_set_port_cman_config,
14106 : : &cmd_config_tx_affinity_map,
14107 : : &cmd_set_dev_led,
14108 : : NULL,
14109 : : };
14110 : :
14111 : : void
14112 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
14113 : : {
14114 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
14115 : 0 : }
14116 : :
14117 : : int
14118 : 0 : init_cmdline(void)
14119 : : {
14120 : : struct testpmd_driver_commands *c;
14121 : : unsigned int count;
14122 : : unsigned int i;
14123 : :
14124 : : /* initialize non-constant commands */
14125 : 0 : cmd_set_fwd_mode_init();
14126 : 0 : cmd_set_fwd_retry_mode_init();
14127 : : cmd_dump_init();
14128 : :
14129 : : count = 0;
14130 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
14131 : 0 : count++;
14132 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14133 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
14134 : 0 : count++;
14135 : : }
14136 : :
14137 : : /* cmdline expects a NULL terminated array */
14138 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
14139 : 0 : if (main_ctx == NULL)
14140 : : return -1;
14141 : :
14142 : : count = 0;
14143 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
14144 : 0 : main_ctx[count] = builtin_ctx[i];
14145 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
14146 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
14147 : 0 : main_ctx[count] = c->commands[i].ctx;
14148 : : }
14149 : :
14150 : : return 0;
14151 : : }
14152 : :
14153 : : /* read cmdline commands from file */
14154 : : void
14155 : 0 : cmdline_read_from_file(const char *filename)
14156 : : {
14157 : : struct cmdline *cl;
14158 : : int fd = -1;
14159 : :
14160 : : /* cmdline_file_new does not produce any output
14161 : : * so when echoing is requested we open filename directly
14162 : : * and then pass that to cmdline_new with stdout as the output path.
14163 : : */
14164 : 0 : if (!echo_cmdline_file) {
14165 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
14166 : : } else {
14167 : : fd = open(filename, O_RDONLY);
14168 : 0 : if (fd < 0) {
14169 : 0 : fprintf(stderr, "Failed to open file %s: %s\n",
14170 : 0 : filename, strerror(errno));
14171 : 0 : return;
14172 : : }
14173 : :
14174 : 0 : cl = cmdline_new(main_ctx, "testpmd> ", fd, STDOUT_FILENO);
14175 : : }
14176 : 0 : if (cl == NULL) {
14177 : 0 : fprintf(stderr,
14178 : : "Failed to create file based cmdline context: %s\n",
14179 : : filename);
14180 : 0 : goto end;
14181 : : }
14182 : :
14183 : 0 : cmdline_interact(cl);
14184 : 0 : cmdline_quit(cl);
14185 : :
14186 : 0 : cmdline_free(cl);
14187 : :
14188 : : printf("Read CLI commands from %s\n", filename);
14189 : :
14190 : 0 : end:
14191 : 0 : if (fd >= 0)
14192 : 0 : close(fd);
14193 : : }
14194 : :
14195 : : void
14196 : 0 : prompt_exit(void)
14197 : : {
14198 : 0 : cmdline_quit(testpmd_cl);
14199 : 0 : }
14200 : :
14201 : : /* prompt function, called from main on MAIN lcore */
14202 : : void
14203 : 0 : prompt(void)
14204 : : {
14205 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
14206 : 0 : if (testpmd_cl == NULL) {
14207 : 0 : fprintf(stderr,
14208 : : "Failed to create stdin based cmdline context\n");
14209 : 0 : return;
14210 : : }
14211 : :
14212 : 0 : cmdline_interact(testpmd_cl);
14213 : 0 : cmdline_stdin_exit(testpmd_cl);
14214 : : }
14215 : :
14216 : : void
14217 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
14218 : : {
14219 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
14220 : : portid_t pid;
14221 : :
14222 : 0 : RTE_ETH_FOREACH_DEV(pid) {
14223 : : /* check if need_reconfig has been set to 1 */
14224 : 0 : if (ports[pid].need_reconfig == 0)
14225 : 0 : ports[pid].need_reconfig = dev;
14226 : : /* check if need_reconfig_queues has been set to 1 */
14227 : 0 : if (ports[pid].need_reconfig_queues == 0)
14228 : 0 : ports[pid].need_reconfig_queues = queue;
14229 : : }
14230 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
14231 : : /* check if need_reconfig has been set to 1 */
14232 : 0 : if (ports[id].need_reconfig == 0)
14233 : 0 : ports[id].need_reconfig = dev;
14234 : : /* check if need_reconfig_queues has been set to 1 */
14235 : 0 : if (ports[id].need_reconfig_queues == 0)
14236 : 0 : ports[id].need_reconfig_queues = queue;
14237 : : }
14238 : 0 : }
|