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 <stdio.h>
10 : : #include <stdint.h>
11 : : #include <stdlib.h>
12 : : #include <string.h>
13 : : #include <unistd.h>
14 : : #include <inttypes.h>
15 : : #include <sys/queue.h>
16 : :
17 : : #include <rte_common.h>
18 : : #include <rte_byteorder.h>
19 : : #include <rte_log.h>
20 : : #include <rte_debug.h>
21 : : #include <rte_cycles.h>
22 : : #include <rte_memory.h>
23 : : #include <rte_memzone.h>
24 : : #include <rte_malloc.h>
25 : : #include <rte_launch.h>
26 : : #include <rte_eal.h>
27 : : #include <rte_per_lcore.h>
28 : : #include <rte_lcore.h>
29 : : #include <rte_branch_prediction.h>
30 : : #include <rte_ring.h>
31 : : #include <rte_mempool.h>
32 : : #include <rte_interrupts.h>
33 : : #include <rte_ether.h>
34 : : #include <rte_ethdev.h>
35 : : #include <rte_string_fns.h>
36 : : #include <rte_devargs.h>
37 : : #include <rte_flow.h>
38 : : #ifdef RTE_LIB_GRO
39 : : #include <rte_gro.h>
40 : : #endif
41 : : #include <rte_mbuf_dyn.h>
42 : : #include <rte_trace.h>
43 : :
44 : : #include <cmdline_rdline.h>
45 : : #include <cmdline_parse.h>
46 : : #include <cmdline_parse_num.h>
47 : : #include <cmdline_parse_string.h>
48 : : #include <cmdline_parse_ipaddr.h>
49 : : #include <cmdline_parse_etheraddr.h>
50 : : #include <cmdline_socket.h>
51 : : #include <cmdline.h>
52 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
53 : : #include <rte_pmd_dpaa.h>
54 : : #endif
55 : : #ifdef RTE_NET_IXGBE
56 : : #include <rte_pmd_ixgbe.h>
57 : : #endif
58 : : #ifdef RTE_NET_I40E
59 : : #include <rte_pmd_i40e.h>
60 : : #endif
61 : : #ifdef RTE_NET_BNXT
62 : : #include <rte_pmd_bnxt.h>
63 : : #endif
64 : : #include "testpmd.h"
65 : : #include "cmdline_cman.h"
66 : : #include "cmdline_mtr.h"
67 : : #include "cmdline_tm.h"
68 : : #include "bpf_cmd.h"
69 : :
70 : : static struct cmdline *testpmd_cl;
71 : : static cmdline_parse_ctx_t *main_ctx;
72 : : static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head =
73 : : TAILQ_HEAD_INITIALIZER(driver_commands_head);
74 : :
75 : : /* *** Help command with introduction. *** */
76 : : struct cmd_help_brief_result {
77 : : cmdline_fixed_string_t help;
78 : : };
79 : :
80 : 0 : static void cmd_help_brief_parsed(__rte_unused void *parsed_result,
81 : : struct cmdline *cl,
82 : : __rte_unused void *data)
83 : : {
84 : 0 : cmdline_printf(
85 : : cl,
86 : : "\n"
87 : : "Help is available for the following sections:\n\n"
88 : : " help control : Start and stop forwarding.\n"
89 : : " help display : Displaying port, stats and config "
90 : : "information.\n"
91 : : " help config : Configuration information.\n"
92 : : " help ports : Configuring ports.\n"
93 : : " help filters : Filters configuration help.\n"
94 : : " help traffic_management : Traffic Management commands.\n"
95 : : " help devices : Device related commands.\n"
96 : : " help drivers : Driver specific commands.\n"
97 : : " help all : All of the above sections.\n\n"
98 : : );
99 : :
100 : 0 : }
101 : :
102 : : static cmdline_parse_token_string_t cmd_help_brief_help =
103 : : TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help");
104 : :
105 : : static cmdline_parse_inst_t cmd_help_brief = {
106 : : .f = cmd_help_brief_parsed,
107 : : .data = NULL,
108 : : .help_str = "help: Show help",
109 : : .tokens = {
110 : : (void *)&cmd_help_brief_help,
111 : : NULL,
112 : : },
113 : : };
114 : :
115 : : /* *** Help command with help sections. *** */
116 : : struct cmd_help_long_result {
117 : : cmdline_fixed_string_t help;
118 : : cmdline_fixed_string_t section;
119 : : };
120 : :
121 : 0 : static void cmd_help_long_parsed(void *parsed_result,
122 : : struct cmdline *cl,
123 : : __rte_unused void *data)
124 : : {
125 : : int show_all = 0;
126 : : struct cmd_help_long_result *res = parsed_result;
127 : :
128 : 0 : if (!strcmp(res->section, "all"))
129 : : show_all = 1;
130 : :
131 : 0 : if (show_all || !strcmp(res->section, "control")) {
132 : :
133 : 0 : cmdline_printf(
134 : : cl,
135 : : "\n"
136 : : "Control forwarding:\n"
137 : : "-------------------\n\n"
138 : :
139 : : "start\n"
140 : : " Start packet forwarding with current configuration.\n\n"
141 : :
142 : : "start tx_first\n"
143 : : " Start packet forwarding with current config"
144 : : " after sending one burst of packets.\n\n"
145 : :
146 : : "stop\n"
147 : : " Stop packet forwarding, and display accumulated"
148 : : " statistics.\n\n"
149 : :
150 : : "quit\n"
151 : : " Quit to prompt.\n\n"
152 : : );
153 : : }
154 : :
155 : 0 : if (show_all || !strcmp(res->section, "display")) {
156 : :
157 : 0 : cmdline_printf(
158 : : cl,
159 : : "\n"
160 : : "Display:\n"
161 : : "--------\n\n"
162 : :
163 : : "show port (info|stats|summary|xstats|fdir|dcb_tc) (port_id|all)\n"
164 : : " Display information for port_id, or all.\n\n"
165 : :
166 : : "show port info (port_id) representor\n"
167 : : " Show supported representors for a specific port\n\n"
168 : :
169 : : "show port port_id (module_eeprom|eeprom)\n"
170 : : " Display the module EEPROM or EEPROM information for port_id.\n\n"
171 : :
172 : : "show port X rss reta (size) (mask0,mask1,...)\n"
173 : : " Display the rss redirection table entry indicated"
174 : : " by masks on port X. size is used to indicate the"
175 : : " hardware supported reta size\n\n"
176 : :
177 : : "show port (port_id) rss-hash [key | algorithm]\n"
178 : : " Display the RSS hash functions, RSS hash key and RSS hash algorithms of port\n\n"
179 : :
180 : : "clear port (info|stats|xstats|fdir) (port_id|all)\n"
181 : : " Clear information for port_id, or all.\n\n"
182 : :
183 : : "show (rxq|txq) info (port_id) (queue_id)\n"
184 : : " Display information for configured RX/TX queue.\n\n"
185 : :
186 : : "show config (rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts)\n"
187 : : " Display the given configuration.\n\n"
188 : :
189 : : "read rxd (port_id) (queue_id) (rxd_id)\n"
190 : : " Display an RX descriptor of a port RX queue.\n\n"
191 : :
192 : : "read txd (port_id) (queue_id) (txd_id)\n"
193 : : " Display a TX descriptor of a port TX queue.\n\n"
194 : :
195 : : "show vf stats (port_id) (vf_id)\n"
196 : : " Display a VF's statistics.\n\n"
197 : :
198 : : "clear vf stats (port_id) (vf_id)\n"
199 : : " Reset a VF's statistics.\n\n"
200 : :
201 : : "show port meter stats (port_id) (meter_id) (clear)\n"
202 : : " Get meter stats on a port\n\n"
203 : :
204 : : "show fwd stats all\n"
205 : : " Display statistics for all fwd engines.\n\n"
206 : :
207 : : "clear fwd stats all\n"
208 : : " Clear statistics for all fwd engines.\n\n"
209 : :
210 : : "show port (port_id) rx_offload capabilities\n"
211 : : " List all per queue and per port Rx offloading"
212 : : " capabilities of a port\n\n"
213 : :
214 : : "show port (port_id) rx_offload configuration\n"
215 : : " List port level and all queue level"
216 : : " Rx offloading configuration\n\n"
217 : :
218 : : "show port (port_id) tx_offload capabilities\n"
219 : : " List all per queue and per port"
220 : : " Tx offloading capabilities of a port\n\n"
221 : :
222 : : "show port (port_id) tx_offload configuration\n"
223 : : " List port level and all queue level"
224 : : " Tx offloading configuration\n\n"
225 : :
226 : : "show port (port_id) tx_metadata\n"
227 : : " Show Tx metadata value set"
228 : : " for a specific port\n\n"
229 : :
230 : : "show port (port_id) ptypes\n"
231 : : " Show port supported ptypes"
232 : : " for a specific port\n\n"
233 : :
234 : : "show device info (<identifier>|all)"
235 : : " Show general information about devices probed.\n\n"
236 : :
237 : : "show port (port_id) rxq|txq (queue_id) desc (desc_id) status"
238 : : " Show status of rx|tx descriptor.\n\n"
239 : :
240 : : "show port (port_id) rxq|txq (queue_id) desc used count\n"
241 : : " Show current number of used descriptor count for rx|tx.\n\n"
242 : :
243 : : "show port (port_id) macs|mcast_macs"
244 : : " Display list of mac addresses added to port.\n\n"
245 : :
246 : : "show port (port_id) flow transfer proxy\n"
247 : : " Display proxy port to manage transfer flows\n\n"
248 : :
249 : : "show port (port_id) fec capabilities"
250 : : " Show fec capabilities of a port.\n\n"
251 : :
252 : : "show port (port_id) fec_mode"
253 : : " Show fec mode of a port.\n\n"
254 : :
255 : : "show port (port_id) flow_ctrl"
256 : : " Show flow control info of a port.\n\n"
257 : :
258 : : "dump_physmem\n"
259 : : " Dumps all physical memory segment layouts\n\n"
260 : :
261 : : "dump_socket_mem\n"
262 : : " Dumps the memory usage of all sockets\n\n"
263 : :
264 : : "dump_memzone\n"
265 : : " Dumps the layout of all memory zones\n\n"
266 : :
267 : : "dump_struct_sizes\n"
268 : : " Dumps the size of all memory structures\n\n"
269 : :
270 : : "dump_ring\n"
271 : : " Dumps the status of all or specific element in DPDK rings\n\n"
272 : :
273 : : "dump_mempool\n"
274 : : " Dumps the statistics of all or specific memory pool\n\n"
275 : :
276 : : "dump_devargs\n"
277 : : " Dumps the user device list\n\n"
278 : :
279 : : "dump_lcores\n"
280 : : " Dumps the logical cores list\n\n"
281 : :
282 : : "dump_trace\n"
283 : : " Dumps the tracing data to the folder according to the current EAL settings\n\n"
284 : :
285 : : "dump_log_types\n"
286 : : " Dumps the log level for all the dpdk modules\n\n"
287 : : );
288 : : }
289 : :
290 : 0 : if (show_all || !strcmp(res->section, "config")) {
291 : 0 : cmdline_printf(
292 : : cl,
293 : : "\n"
294 : : "Configuration:\n"
295 : : "--------------\n"
296 : : "Configuration changes only become active when"
297 : : " forwarding is started/restarted.\n\n"
298 : :
299 : : "set default\n"
300 : : " Reset forwarding to the default configuration.\n\n"
301 : :
302 : : "set verbose (level)\n"
303 : : " Set the debug verbosity level X.\n\n"
304 : :
305 : : "set log global|(type) (level)\n"
306 : : " Set the log level.\n\n"
307 : :
308 : : "set nbport (num)\n"
309 : : " Set number of ports.\n\n"
310 : :
311 : : "set nbcore (num)\n"
312 : : " Set number of cores.\n\n"
313 : :
314 : : "set coremask (mask)\n"
315 : : " Set the forwarding cores hexadecimal mask.\n\n"
316 : :
317 : : "set portmask (mask)\n"
318 : : " Set the forwarding ports hexadecimal mask.\n\n"
319 : :
320 : : "set burst (num)\n"
321 : : " Set number of packets per burst.\n\n"
322 : :
323 : : "set burst tx delay (microseconds) retry (num)\n"
324 : : " Set the transmit delay time and number of retries,"
325 : : " effective when retry is enabled.\n\n"
326 : :
327 : : "set rxoffs (x[,y]*)\n"
328 : : " Set the offset of each packet segment on"
329 : : " receiving if split feature is engaged."
330 : : " Affects only the queues configured with split"
331 : : " offloads.\n\n"
332 : :
333 : : "set rxpkts (x[,y]*)\n"
334 : : " Set the length of each segment to scatter"
335 : : " packets on receiving if split feature is engaged."
336 : : " Affects only the queues configured with split"
337 : : " offloads.\n\n"
338 : :
339 : : "set rxhdrs (eth[,ipv4])*\n"
340 : : " Set the protocol hdr of each segment to scatter"
341 : : " packets on receiving if split feature is engaged."
342 : : " Affects only the queues configured with split"
343 : : " offloads.\n"
344 : : " Supported values: eth|ipv4|ipv6|ipv4-tcp|ipv6-tcp|"
345 : : "ipv4-udp|ipv6-udp|ipv4-sctp|ipv6-sctp|"
346 : : "grenat|inner-eth|inner-ipv4|inner-ipv6|inner-ipv4-tcp|"
347 : : "inner-ipv6-tcp|inner-ipv4-udp|inner-ipv6-udp|"
348 : : "inner-ipv4-sctp|inner-ipv6-sctp\n\n"
349 : :
350 : : "set txpkts (x[,y]*)\n"
351 : : " Set the length of each segment of TXONLY"
352 : : " and optionally CSUM packets.\n\n"
353 : :
354 : : "set txsplit (off|on|rand)\n"
355 : : " Set the split policy for the TX packets."
356 : : " Right now only applicable for CSUM and TXONLY"
357 : : " modes\n\n"
358 : :
359 : : "set txtimes (x, y)\n"
360 : : " Set the scheduling on timestamps"
361 : : " timings for the TXONLY mode\n\n"
362 : :
363 : : "set corelist (x[,y]*)\n"
364 : : " Set the list of forwarding cores.\n\n"
365 : :
366 : : "set portlist (x[,y]*)\n"
367 : : " Set the list of forwarding ports.\n\n"
368 : :
369 : : "set port setup on (iterator|event)\n"
370 : : " Select how attached port is retrieved for setup.\n\n"
371 : :
372 : : "set tx loopback (port_id) (on|off)\n"
373 : : " Enable or disable tx loopback.\n\n"
374 : :
375 : : "set all queues drop (port_id) (on|off)\n"
376 : : " Set drop enable bit for all queues.\n\n"
377 : :
378 : : "set vf mac antispoof (port_id) (vf_id) (on|off).\n"
379 : : " Set MAC antispoof for a VF from the PF.\n\n"
380 : :
381 : : "vlan set stripq (on|off) (port_id,queue_id)\n"
382 : : " Set the VLAN strip for a queue on a port.\n\n"
383 : :
384 : : "set vf vlan stripq (port_id) (vf_id) (on|off)\n"
385 : : " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n"
386 : :
387 : : "set vf vlan insert (port_id) (vf_id) (vlan_id)\n"
388 : : " Set VLAN insert for a VF from the PF.\n\n"
389 : :
390 : : "set vf vlan antispoof (port_id) (vf_id) (on|off)\n"
391 : : " Set VLAN antispoof for a VF from the PF.\n\n"
392 : :
393 : : "vlan set (strip|filter|qinq_strip|extend) (on|off) (port_id)\n"
394 : : " Set the VLAN strip or filter or qinq strip or extend\n\n"
395 : :
396 : : "vlan set (inner|outer) tpid (value) (port_id)\n"
397 : : " Set the VLAN TPID for Packet Filtering on"
398 : : " a port\n\n"
399 : :
400 : : "rx_vlan add (vlan_id|all) (port_id)\n"
401 : : " Add a vlan_id, or all identifiers, to the set"
402 : : " of VLAN identifiers filtered by port_id.\n\n"
403 : :
404 : : "rx_vlan rm (vlan_id|all) (port_id)\n"
405 : : " Remove a vlan_id, or all identifiers, from the set"
406 : : " of VLAN identifiers filtered by port_id.\n\n"
407 : :
408 : : "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n"
409 : : " Add a vlan_id, to the set of VLAN identifiers"
410 : : "filtered for VF(s) from port_id.\n\n"
411 : :
412 : : "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n"
413 : : " Remove a vlan_id, to the set of VLAN identifiers"
414 : : "filtered for VF(s) from port_id.\n\n"
415 : :
416 : : "rx_vxlan_port add (udp_port) (port_id)\n"
417 : : " Add an UDP port for VXLAN packet filter on a port\n\n"
418 : :
419 : : "rx_vxlan_port rm (udp_port) (port_id)\n"
420 : : " Remove an UDP port for VXLAN packet filter on a port\n\n"
421 : :
422 : : "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n"
423 : : " Set hardware insertion of VLAN IDs (single or double VLAN "
424 : : "depends on the number of VLAN IDs) in packets sent on a port.\n\n"
425 : :
426 : : "tx_vlan set pvid port_id vlan_id (on|off)\n"
427 : : " Set port based TX VLAN insertion.\n\n"
428 : :
429 : : "tx_vlan reset (port_id)\n"
430 : : " Disable hardware insertion of a VLAN header in"
431 : : " packets sent on a port.\n\n"
432 : :
433 : : "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n"
434 : : " Select hardware or software calculation of the"
435 : : " checksum when transmitting a packet using the"
436 : : " csum forward engine.\n"
437 : : " ip|udp|tcp|sctp always concern the inner layer.\n"
438 : : " outer-ip concerns the outer IP layer in"
439 : : " outer-udp concerns the outer UDP layer in"
440 : : " case the packet is recognized as a tunnel packet by"
441 : : " the forward engine (vxlan, gre and ipip are supported)\n"
442 : : " Please check the NIC datasheet for HW limits.\n\n"
443 : :
444 : : "csum parse-tunnel (on|off) (tx_port_id)\n"
445 : : " If disabled, treat tunnel packets as non-tunneled"
446 : : " packets (treat inner headers as payload). The port\n"
447 : : " argument is the port used for TX in csum forward"
448 : : " engine.\n\n"
449 : :
450 : : "csum show (port_id)\n"
451 : : " Display tx checksum offload configuration\n\n"
452 : :
453 : : "tso set (segsize) (portid)\n"
454 : : " Enable TCP Segmentation Offload in csum forward"
455 : : " engine.\n"
456 : : " Please check the NIC datasheet for HW limits.\n\n"
457 : :
458 : : "tso show (portid)"
459 : : " Display the status of TCP Segmentation Offload.\n\n"
460 : :
461 : : #ifdef RTE_LIB_GRO
462 : : "set port (port_id) gro on|off\n"
463 : : " Enable or disable Generic Receive Offload in"
464 : : " csum forwarding engine.\n\n"
465 : :
466 : : "show port (port_id) gro\n"
467 : : " Display GRO configuration.\n\n"
468 : :
469 : : "set gro flush (cycles)\n"
470 : : " Set the cycle to flush GROed packets from"
471 : : " reassembly tables.\n\n"
472 : : #endif
473 : :
474 : : #ifdef RTE_LIB_GSO
475 : : "set port (port_id) gso (on|off)"
476 : : " Enable or disable Generic Segmentation Offload in"
477 : : " csum forwarding engine.\n\n"
478 : :
479 : : "set gso segsz (length)\n"
480 : : " Set max packet length for output GSO segments,"
481 : : " including packet header and payload.\n\n"
482 : :
483 : : "show port (port_id) gso\n"
484 : : " Show GSO configuration.\n\n"
485 : : #endif
486 : :
487 : : "set fwd (%s)\n"
488 : : " Set packet forwarding mode.\n\n"
489 : :
490 : : "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n"
491 : : " Add a MAC address on port_id.\n\n"
492 : :
493 : : "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n"
494 : : " Remove a MAC address from port_id.\n\n"
495 : :
496 : : "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n"
497 : : " Set the default MAC address for port_id.\n\n"
498 : :
499 : : "mac_addr add port (port_id) vf (vf_id) (mac_address)\n"
500 : : " Add a MAC address for a VF on the port.\n\n"
501 : :
502 : : "mcast_addr add (port_id) (mcast_addr)\n"
503 : : " Add a multicast MAC addresses on port_id.\n\n"
504 : :
505 : : "mcast_addr remove (port_id) (mcast_addr)\n"
506 : : " Remove a multicast MAC address from port_id.\n\n"
507 : :
508 : : "mcast_addr flush (port_id)\n"
509 : : " Flush all multicast MAC addresses on port_id.\n\n"
510 : :
511 : : "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n"
512 : : " Set the MAC address for a VF from the PF.\n\n"
513 : :
514 : : "set eth-peer (port_id) (peer_addr)\n"
515 : : " set the peer address for certain port.\n\n"
516 : :
517 : : "set port (port_id) uta (mac_address|all) (on|off)\n"
518 : : " Add/Remove a or all unicast hash filter(s)"
519 : : "from port X.\n\n"
520 : :
521 : : "set promisc (port_id|all) (on|off)\n"
522 : : " Set the promiscuous mode on port_id, or all.\n\n"
523 : :
524 : : "set allmulti (port_id|all) (on|off)\n"
525 : : " Set the allmulti mode on port_id, or all.\n\n"
526 : :
527 : : "set flow_ctrl rx (on|off) tx (on|off) (high_water)"
528 : : " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
529 : : " (on|off) autoneg (on|off) (port_id)\n"
530 : : "set flow_ctrl rx (on|off) (portid)\n"
531 : : "set flow_ctrl tx (on|off) (portid)\n"
532 : : "set flow_ctrl high_water (high_water) (portid)\n"
533 : : "set flow_ctrl low_water (low_water) (portid)\n"
534 : : "set flow_ctrl pause_time (pause_time) (portid)\n"
535 : : "set flow_ctrl send_xon (send_xon) (portid)\n"
536 : : "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
537 : : "set flow_ctrl autoneg (on|off) (port_id)\n"
538 : : " Set the link flow control parameter on a port.\n\n"
539 : :
540 : : "set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
541 : : " (low_water) (pause_time) (priority) (port_id)\n"
542 : : " Set the priority flow control parameter on a"
543 : : " port.\n\n"
544 : :
545 : : "set pfc_queue_ctrl (port_id) rx (on|off) (tx_qid)"
546 : : " (tx_tc) tx (on|off) (rx_qid) (rx_tc) (pause_time)\n"
547 : : " Set the queue priority flow control parameter on a"
548 : : " given Rx and Tx queues of a port.\n\n"
549 : :
550 : : "set port (port_id) rxq (queue_id) avail_thresh (0..99)>\n "
551 : : " set available descriptors threshold for Rx queue\n\n"
552 : :
553 : : "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n"
554 : : " Set statistics mapping (qmapping 0..15) for RX/TX"
555 : : " queue on port.\n"
556 : : " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2"
557 : : " on port 0 to mapping 5.\n\n"
558 : :
559 : : "set xstats-hide-zero on|off\n"
560 : : " Set the option to hide the zero values"
561 : : " for xstats display.\n"
562 : :
563 : : "set record-core-cycles on|off\n"
564 : : " Set the option to enable measurement of CPU cycles.\n"
565 : :
566 : : "set record-burst-stats on|off\n"
567 : : " Set the option to enable display of RX and TX bursts.\n"
568 : :
569 : : "set port (port_id) vf (vf_id) rx|tx on|off\n"
570 : : " Enable/Disable a VF receive/transmit from a port\n\n"
571 : :
572 : : "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM"
573 : : "|MPE) (on|off)\n"
574 : : " AUPE:accepts untagged VLAN;"
575 : : "ROPE:accept unicast hash\n\n"
576 : : " BAM:accepts broadcast packets;"
577 : : "MPE:accepts all multicast packets\n\n"
578 : : " Enable/Disable a VF receive mode of a port\n\n"
579 : :
580 : : "set port (port_id) queue (queue_id) rate (rate_num)\n"
581 : : " Set rate limit for a queue of a port\n\n"
582 : :
583 : : "set port (port_id) vf (vf_id) rate (rate_num) "
584 : : "queue_mask (queue_mask_value)\n"
585 : : " Set rate limit for queues in VF of a port\n\n"
586 : :
587 : : "set flush_rx (on|off)\n"
588 : : " Flush (default) or don't flush RX streams before"
589 : : " forwarding. Mainly used with PCAP drivers.\n\n"
590 : :
591 : : "set link-up port (port_id)\n"
592 : : " Set link up for a port.\n\n"
593 : :
594 : : "set link-down port (port_id)\n"
595 : : " Set link down for a port.\n\n"
596 : :
597 : : "set port (port_id) ptype_mask (ptype_mask)\n"
598 : : " set packet types classification for a specific port\n\n"
599 : :
600 : : "show port meter cap (port_id)\n"
601 : : " Show port meter capability information\n\n"
602 : :
603 : : "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs) (packet_mode)\n"
604 : : " meter profile add - srtcm rfc 2697\n\n"
605 : :
606 : : "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs) (packet_mode)\n"
607 : : " meter profile add - trtcm rfc 2698\n\n"
608 : :
609 : : "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs) (packet_mode)\n"
610 : : " meter profile add - trtcm rfc 4115\n\n"
611 : :
612 : : "del port meter profile (port_id) (profile_id)\n"
613 : : " meter profile delete\n\n"
614 : :
615 : : "create port meter (port_id) (mtr_id) (profile_id) (policy_id) (meter_enable)\n"
616 : : "(stats_mask) (shared) (use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n"
617 : : "(dscp_tbl_entry63)]\n"
618 : : " meter create\n\n"
619 : :
620 : : "enable port meter (port_id) (mtr_id)\n"
621 : : " meter enable\n\n"
622 : :
623 : : "disable port meter (port_id) (mtr_id)\n"
624 : : " meter disable\n\n"
625 : :
626 : : "del port meter (port_id) (mtr_id)\n"
627 : : " meter delete\n\n"
628 : :
629 : : "add port meter policy (port_id) (policy_id) g_actions (actions)\n"
630 : : "y_actions (actions) r_actions (actions)\n"
631 : : " meter policy add\n\n"
632 : :
633 : : "del port meter policy (port_id) (policy_id)\n"
634 : : " meter policy delete\n\n"
635 : :
636 : : "set port meter profile (port_id) (mtr_id) (profile_id)\n"
637 : : " meter update meter profile\n\n"
638 : :
639 : : "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n"
640 : : "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n"
641 : : " update meter dscp table entries\n\n"
642 : :
643 : : "set port meter policer action (port_id) (mtr_id) (action_mask)\n"
644 : : "(action0) [(action1) (action2)]\n"
645 : : " meter update policer action\n\n"
646 : :
647 : : "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n"
648 : : " meter update stats\n\n"
649 : :
650 : : "set port (port_id) fec_mode auto|off|rs|baser\n"
651 : : " set fec mode for a specific port\n\n"
652 : :
653 : : "show port cman capa (port_id)\n"
654 : : " Show congestion management capabilities\n\n"
655 : :
656 : : "show port cman config (port_id)\n"
657 : : " Show congestion management configuration\n\n"
658 : :
659 : : "set port cman config (port_id) (queue_id) default | "
660 : : "[obj (queue|queue_mempool) mode red (min_thresh) "
661 : : "(max_thresh) (prob_inv)]\n"
662 : : " Set congestion management configuration\n\n"
663 : :
664 : : , list_pkt_forwarding_modes()
665 : : );
666 : : }
667 : :
668 : 0 : if (show_all || !strcmp(res->section, "ports")) {
669 : :
670 : 0 : cmdline_printf(
671 : : cl,
672 : : "\n"
673 : : "Port Operations:\n"
674 : : "----------------\n\n"
675 : :
676 : : "port start (port_id|all)\n"
677 : : " Start all ports or port_id.\n\n"
678 : :
679 : : "port stop (port_id|all)\n"
680 : : " Stop all ports or port_id.\n\n"
681 : :
682 : : "port close (port_id|all)\n"
683 : : " Close all ports or port_id.\n\n"
684 : :
685 : : "port reset (port_id|all)\n"
686 : : " Reset all ports or port_id.\n\n"
687 : :
688 : : "port attach (ident)\n"
689 : : " Attach physical or virtual dev by pci address or virtual device name\n\n"
690 : :
691 : : "port detach (port_id)\n"
692 : : " Detach physical or virtual dev by port_id\n\n"
693 : :
694 : : "port config (port_id|all)"
695 : : " speed (10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto)"
696 : : " duplex (half|full|auto)\n"
697 : : " Set speed and duplex for all ports or port_id\n\n"
698 : :
699 : : "port config (port_id|all) loopback (mode)\n"
700 : : " Set loopback mode for all ports or port_id\n\n"
701 : :
702 : : "port config all (rxq|txq|rxd|txd) (value)\n"
703 : : " Set number for rxq/txq/rxd/txd.\n\n"
704 : :
705 : : "port config all max-pkt-len (value)\n"
706 : : " Set the max packet length.\n\n"
707 : :
708 : : "port config all max-lro-pkt-size (value)\n"
709 : : " Set the max LRO aggregated packet size.\n\n"
710 : :
711 : : "port config all drop-en (on|off)\n"
712 : : " Enable or disable packet drop on all RX queues of all ports when no "
713 : : "receive buffers available.\n\n"
714 : :
715 : : "port config all rss (all|default|level-default|level-outer|level-inner|"
716 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
717 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
718 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
719 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
720 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
721 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
722 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>)\n"
723 : : " Set the RSS mode.\n\n"
724 : :
725 : : "port config port-id rss reta (hash,queue)[,(hash,queue)]\n"
726 : : " Set the RSS redirection table.\n\n"
727 : :
728 : : "port config (port_id) rss-hash-algo (default|simple_xor|toeplitz|"
729 : : "symmetric_toeplitz|symmetric_toeplitz_sort)\n"
730 : : " Set the RSS hash algorithm.\n\n"
731 : :
732 : : "port config (port_id) dcb vt (on|off) (traffic_class)"
733 : : " pfc (on|off)\n"
734 : : " Set the DCB mode.\n\n"
735 : :
736 : : "port config all burst (value)\n"
737 : : " Set the number of packets per burst.\n\n"
738 : :
739 : : "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)"
740 : : " (value)\n"
741 : : " Set the ring prefetch/host/writeback threshold"
742 : : " for tx/rx queue.\n\n"
743 : :
744 : : "port config all (txfreet|txrst|rxfreet) (value)\n"
745 : : " Set free threshold for rx/tx, or set"
746 : : " tx rs bit threshold.\n\n"
747 : : "port config mtu X value\n"
748 : : " Set the MTU of port X to a given value\n\n"
749 : :
750 : : "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n"
751 : : " Set a rx/tx queue's ring size configuration, the new"
752 : : " value will take effect after command that (re-)start the port"
753 : : " or command that setup the specific queue\n\n"
754 : :
755 : : "port (port_id) (rxq|txq) (queue_id) (start|stop)\n"
756 : : " Start/stop a rx/tx queue of port X. Only take effect"
757 : : " when port X is started\n\n"
758 : :
759 : : "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n"
760 : : " Switch on/off a deferred start of port X rx/tx queue. Only"
761 : : " take effect when port X is stopped.\n\n"
762 : :
763 : : "port (port_id) (rxq|txq) (queue_id) setup\n"
764 : : " Setup a rx/tx queue of port X.\n\n"
765 : :
766 : : "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|ecpri (udp_port)\n\n"
767 : : " Add/remove UDP tunnel port for tunneling offload\n\n"
768 : :
769 : : "port config (port_id|all) rx_offload all|vlan_strip|"
770 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
771 : : "outer_ipv4_cksum|macsec_strip|"
772 : : "vlan_filter|vlan_extend|scatter|"
773 : : "buffer_split|timestamp|security|keep_crc on|off\n"
774 : : " Enable or disable a per port Rx offloading"
775 : : " on all Rx queues of a port\n\n"
776 : :
777 : : "port (port_id) rxq (queue_id) rx_offload all|vlan_strip|"
778 : : "ipv4_cksum|udp_cksum|tcp_cksum|tcp_lro|qinq_strip|"
779 : : "outer_ipv4_cksum|macsec_strip|"
780 : : "vlan_filter|vlan_extend|scatter|"
781 : : "buffer_split|timestamp|security|keep_crc on|off\n"
782 : : " Enable or disable a per queue Rx offloading"
783 : : " only on a specific Rx queue\n\n"
784 : :
785 : : "port config (port_id|all) tx_offload all|vlan_insert|"
786 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
787 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
788 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|"
789 : : "macsec_insert|mt_lockfree|multi_segs|mbuf_fast_free|"
790 : : "security on|off\n"
791 : : " Enable or disable a per port Tx offloading"
792 : : " on all Tx queues of a port\n\n"
793 : :
794 : : "port (port_id) txq (queue_id) tx_offload all|vlan_insert|"
795 : : "ipv4_cksum|udp_cksum|tcp_cksum|sctp_cksum|tcp_tso|"
796 : : "udp_tso|outer_ipv4_cksum|qinq_insert|vxlan_tnl_tso|"
797 : : "gre_tnl_tso|ipip_tnl_tso|geneve_tnl_tso|macsec_insert"
798 : : "|mt_lockfree|multi_segs|mbuf_fast_free|security"
799 : : " on|off\n"
800 : : " Enable or disable a per queue Tx offloading"
801 : : " only on a specific Tx queue\n\n"
802 : :
803 : : "bpf-load rx|tx (port) (queue) (J|M|B) (file_name)\n"
804 : : " Load an eBPF program as a callback"
805 : : " for particular RX/TX queue\n\n"
806 : :
807 : : "bpf-unload rx|tx (port) (queue)\n"
808 : : " Unload previously loaded eBPF program"
809 : : " for particular RX/TX queue\n\n"
810 : :
811 : : "port config (port_id) tx_metadata (value)\n"
812 : : " Set Tx metadata value per port. Testpmd will add this value"
813 : : " to any Tx packet sent from this port\n\n"
814 : :
815 : : "port config (port_id) dynf (name) set|clear\n"
816 : : " Register a dynf and Set/clear this flag on Tx. "
817 : : "Testpmd will set this value to any Tx packet "
818 : : "sent from this port\n\n"
819 : :
820 : : "port cleanup (port_id) txq (queue_id) (free_cnt)\n"
821 : : " Cleanup txq mbufs for a specific Tx queue\n\n"
822 : :
823 : : "port config (port_id) txq (queue_id) affinity (value)\n"
824 : : " Map a Tx queue with an aggregated port "
825 : : "of the DPDK port\n\n"
826 : : );
827 : : }
828 : :
829 : 0 : if (show_all || !strcmp(res->section, "filters")) {
830 : :
831 : 0 : cmdline_printf(
832 : : cl,
833 : : "\n"
834 : : "filters:\n"
835 : : "--------\n\n"
836 : :
837 : : "flow validate {port_id}"
838 : : " [group {group_id}] [priority {level}]"
839 : : " [ingress] [egress]"
840 : : " pattern {item} [/ {item} [...]] / end"
841 : : " actions {action} [/ {action} [...]] / end\n"
842 : : " Check whether a flow rule can be created.\n\n"
843 : :
844 : : "flow create {port_id}"
845 : : " [group {group_id}] [priority {level}]"
846 : : " [ingress] [egress]"
847 : : " pattern {item} [/ {item} [...]] / end"
848 : : " actions {action} [/ {action} [...]] / end\n"
849 : : " Create a flow rule.\n\n"
850 : :
851 : : "flow destroy {port_id} rule {rule_id} [...]\n"
852 : : " Destroy specific flow rules.\n\n"
853 : :
854 : : "flow flush {port_id}\n"
855 : : " Destroy all flow rules.\n\n"
856 : :
857 : : "flow query {port_id} {rule_id} {action}\n"
858 : : " Query an existing flow rule.\n\n"
859 : :
860 : : "flow list {port_id} [group {group_id}] [...]\n"
861 : : " List existing flow rules sorted by priority,"
862 : : " filtered by group identifiers.\n\n"
863 : :
864 : : "flow isolate {port_id} {boolean}\n"
865 : : " Restrict ingress traffic to the defined"
866 : : " flow rules\n\n"
867 : :
868 : : "flow aged {port_id} [destroy]\n"
869 : : " List and destroy aged flows"
870 : : " flow rules\n\n"
871 : :
872 : : "flow indirect_action {port_id} create"
873 : : " [action_id {indirect_action_id}]"
874 : : " [ingress] [egress]"
875 : : " action {action} / end\n"
876 : : " Create indirect action.\n\n"
877 : :
878 : : "flow indirect_action {port_id} update"
879 : : " {indirect_action_id} action {action} / end\n"
880 : : " Update indirect action.\n\n"
881 : :
882 : : "flow indirect_action {port_id} destroy"
883 : : " action_id {indirect_action_id} [...]\n"
884 : : " Destroy specific indirect actions.\n\n"
885 : :
886 : : "flow indirect_action {port_id} query"
887 : : " {indirect_action_id}\n"
888 : : " Query an existing indirect action.\n\n"
889 : :
890 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
891 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
892 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
893 : : " Configure the VXLAN encapsulation for flows.\n\n"
894 : :
895 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
896 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
897 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
898 : : " eth-dst (eth-dst)\n"
899 : : " Configure the VXLAN encapsulation for flows.\n\n"
900 : :
901 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
902 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
903 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
904 : : " eth-dst (eth-dst)\n"
905 : : " Configure the VXLAN encapsulation for flows.\n\n"
906 : :
907 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
908 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
909 : : " (eth-dst)\n"
910 : : " Configure the NVGRE encapsulation for flows.\n\n"
911 : :
912 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
913 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
914 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
915 : : " Configure the NVGRE encapsulation for flows.\n\n"
916 : :
917 : : "set raw_encap {flow items}\n"
918 : : " Configure the encapsulation with raw data.\n\n"
919 : :
920 : : "set raw_decap {flow items}\n"
921 : : " Configure the decapsulation with raw data.\n\n"
922 : :
923 : : );
924 : : }
925 : :
926 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
927 : 0 : cmdline_printf(
928 : : cl,
929 : : "\n"
930 : : "Traffic Management:\n"
931 : : "--------------\n"
932 : : "show port tm cap (port_id)\n"
933 : : " Display the port TM capability.\n\n"
934 : :
935 : : "show port tm level cap (port_id) (level_id)\n"
936 : : " Display the port TM hierarchical level capability.\n\n"
937 : :
938 : : "show port tm node cap (port_id) (node_id)\n"
939 : : " Display the port TM node capability.\n\n"
940 : :
941 : : "show port tm node type (port_id) (node_id)\n"
942 : : " Display the port TM node type.\n\n"
943 : :
944 : : "show port tm node stats (port_id) (node_id) (clear)\n"
945 : : " Display the port TM node stats.\n\n"
946 : :
947 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
948 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
949 : : " (packet_length_adjust) (packet_mode)\n"
950 : : " Add port tm node private shaper profile.\n\n"
951 : :
952 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
953 : : " Delete port tm node private shaper profile.\n\n"
954 : :
955 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
956 : : " (shaper_profile_id)\n"
957 : : " Add/update port tm node shared shaper.\n\n"
958 : :
959 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
960 : : " Delete port tm node shared shaper.\n\n"
961 : :
962 : : "set port tm node shaper profile (port_id) (node_id)"
963 : : " (shaper_profile_id)\n"
964 : : " Set port tm node shaper profile.\n\n"
965 : :
966 : : "add port tm node wred profile (port_id) (wred_profile_id)"
967 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
968 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
969 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
970 : : " Add port tm node wred profile.\n\n"
971 : :
972 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
973 : : " Delete port tm node wred profile.\n\n"
974 : :
975 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
976 : : " (priority) (weight) (level_id) (shaper_profile_id)"
977 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
978 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
979 : : " Add port tm nonleaf node.\n\n"
980 : :
981 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
982 : : " (priority) (weight) (level_id) (shaper_profile_id)"
983 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
984 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
985 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
986 : :
987 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
988 : : " (priority) (weight) (level_id) (shaper_profile_id)"
989 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
990 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
991 : : " Add port tm leaf node.\n\n"
992 : :
993 : : "del port tm node (port_id) (node_id)\n"
994 : : " Delete port tm node.\n\n"
995 : :
996 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
997 : : " (priority) (weight)\n"
998 : : " Set port tm node parent.\n\n"
999 : :
1000 : : "suspend port tm node (port_id) (node_id)"
1001 : : " Suspend tm node.\n\n"
1002 : :
1003 : : "resume port tm node (port_id) (node_id)"
1004 : : " Resume tm node.\n\n"
1005 : :
1006 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1007 : : " Commit tm hierarchy.\n\n"
1008 : :
1009 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1010 : : " (red)\n"
1011 : : " Enables/Disables the traffic management marking"
1012 : : " for IP ECN (Explicit Congestion Notification)"
1013 : : " packets on a given port\n\n"
1014 : :
1015 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1016 : : " (red)\n"
1017 : : " Enables/Disables the traffic management marking"
1018 : : " on the port for IP dscp packets\n\n"
1019 : :
1020 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1021 : : " (red)\n"
1022 : : " Enables/Disables the traffic management marking"
1023 : : " on the port for VLAN packets with DEI enabled\n\n"
1024 : : );
1025 : : }
1026 : :
1027 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1028 : 0 : cmdline_printf(
1029 : : cl,
1030 : : "\n"
1031 : : "Device Operations:\n"
1032 : : "--------------\n"
1033 : : "device detach (identifier)\n"
1034 : : " Detach device by identifier.\n\n"
1035 : : );
1036 : : }
1037 : :
1038 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1039 : : struct testpmd_driver_commands *c;
1040 : : unsigned int i;
1041 : :
1042 : 0 : cmdline_printf(
1043 : : cl,
1044 : : "\n"
1045 : : "Driver specific:\n"
1046 : : "----------------\n"
1047 : : );
1048 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1049 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1050 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1051 : : }
1052 : : }
1053 : 0 : }
1054 : :
1055 : : static cmdline_parse_token_string_t cmd_help_long_help =
1056 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1057 : :
1058 : : static cmdline_parse_token_string_t cmd_help_long_section =
1059 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1060 : : "all#control#display#config#ports#"
1061 : : "filters#traffic_management#devices#drivers");
1062 : :
1063 : : static cmdline_parse_inst_t cmd_help_long = {
1064 : : .f = cmd_help_long_parsed,
1065 : : .data = NULL,
1066 : : .help_str = "help all|control|display|config|ports|"
1067 : : "filters|traffic_management|devices|drivers: "
1068 : : "Show help",
1069 : : .tokens = {
1070 : : (void *)&cmd_help_long_help,
1071 : : (void *)&cmd_help_long_section,
1072 : : NULL,
1073 : : },
1074 : : };
1075 : :
1076 : :
1077 : : /* *** start/stop/close all ports *** */
1078 : : struct cmd_operate_port_result {
1079 : : cmdline_fixed_string_t keyword;
1080 : : cmdline_fixed_string_t name;
1081 : : cmdline_fixed_string_t value;
1082 : : };
1083 : :
1084 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1085 : : __rte_unused struct cmdline *cl,
1086 : : __rte_unused void *data)
1087 : : {
1088 : : struct cmd_operate_port_result *res = parsed_result;
1089 : :
1090 : 0 : if (!strcmp(res->name, "start"))
1091 : 0 : start_port(RTE_PORT_ALL);
1092 : 0 : else if (!strcmp(res->name, "stop"))
1093 : 0 : stop_port(RTE_PORT_ALL);
1094 : 0 : else if (!strcmp(res->name, "close"))
1095 : 0 : close_port(RTE_PORT_ALL);
1096 : 0 : else if (!strcmp(res->name, "reset"))
1097 : 0 : reset_port(RTE_PORT_ALL);
1098 : : else
1099 : 0 : fprintf(stderr, "Unknown parameter\n");
1100 : 0 : }
1101 : :
1102 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1103 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1104 : : "port");
1105 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1106 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1107 : : "start#stop#close#reset");
1108 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1109 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1110 : :
1111 : : static cmdline_parse_inst_t cmd_operate_port = {
1112 : : .f = cmd_operate_port_parsed,
1113 : : .data = NULL,
1114 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1115 : : .tokens = {
1116 : : (void *)&cmd_operate_port_all_cmd,
1117 : : (void *)&cmd_operate_port_all_port,
1118 : : (void *)&cmd_operate_port_all_all,
1119 : : NULL,
1120 : : },
1121 : : };
1122 : :
1123 : : /* *** start/stop/close specific port *** */
1124 : : struct cmd_operate_specific_port_result {
1125 : : cmdline_fixed_string_t keyword;
1126 : : cmdline_fixed_string_t name;
1127 : : uint8_t value;
1128 : : };
1129 : :
1130 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1131 : : __rte_unused struct cmdline *cl,
1132 : : __rte_unused void *data)
1133 : : {
1134 : : struct cmd_operate_specific_port_result *res = parsed_result;
1135 : :
1136 : 0 : if (!strcmp(res->name, "start"))
1137 : 0 : start_port(res->value);
1138 : 0 : else if (!strcmp(res->name, "stop"))
1139 : 0 : stop_port(res->value);
1140 : 0 : else if (!strcmp(res->name, "close"))
1141 : 0 : close_port(res->value);
1142 : 0 : else if (!strcmp(res->name, "reset"))
1143 : 0 : reset_port(res->value);
1144 : : else
1145 : 0 : fprintf(stderr, "Unknown parameter\n");
1146 : 0 : }
1147 : :
1148 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1149 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1150 : : keyword, "port");
1151 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1152 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1153 : : name, "start#stop#close#reset");
1154 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1155 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1156 : : value, RTE_UINT8);
1157 : :
1158 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1159 : : .f = cmd_operate_specific_port_parsed,
1160 : : .data = NULL,
1161 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1162 : : .tokens = {
1163 : : (void *)&cmd_operate_specific_port_cmd,
1164 : : (void *)&cmd_operate_specific_port_port,
1165 : : (void *)&cmd_operate_specific_port_id,
1166 : : NULL,
1167 : : },
1168 : : };
1169 : :
1170 : : /* *** enable port setup (after attach) via iterator or event *** */
1171 : : struct cmd_set_port_setup_on_result {
1172 : : cmdline_fixed_string_t set;
1173 : : cmdline_fixed_string_t port;
1174 : : cmdline_fixed_string_t setup;
1175 : : cmdline_fixed_string_t on;
1176 : : cmdline_fixed_string_t mode;
1177 : : };
1178 : :
1179 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1180 : : __rte_unused struct cmdline *cl,
1181 : : __rte_unused void *data)
1182 : : {
1183 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1184 : :
1185 : 0 : if (strcmp(res->mode, "event") == 0)
1186 : 0 : setup_on_probe_event = true;
1187 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1188 : 0 : setup_on_probe_event = false;
1189 : : else
1190 : 0 : fprintf(stderr, "Unknown mode\n");
1191 : 0 : }
1192 : :
1193 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1194 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1195 : : set, "set");
1196 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1197 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1198 : : port, "port");
1199 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1200 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1201 : : setup, "setup");
1202 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1203 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1204 : : on, "on");
1205 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1206 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1207 : : mode, "iterator#event");
1208 : :
1209 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1210 : : .f = cmd_set_port_setup_on_parsed,
1211 : : .data = NULL,
1212 : : .help_str = "set port setup on iterator|event",
1213 : : .tokens = {
1214 : : (void *)&cmd_set_port_setup_on_set,
1215 : : (void *)&cmd_set_port_setup_on_port,
1216 : : (void *)&cmd_set_port_setup_on_setup,
1217 : : (void *)&cmd_set_port_setup_on_on,
1218 : : (void *)&cmd_set_port_setup_on_mode,
1219 : : NULL,
1220 : : },
1221 : : };
1222 : :
1223 : : /* *** attach a specified port *** */
1224 : : struct cmd_operate_attach_port_result {
1225 : : cmdline_fixed_string_t port;
1226 : : cmdline_fixed_string_t keyword;
1227 : : cmdline_multi_string_t identifier;
1228 : : };
1229 : :
1230 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1231 : : __rte_unused struct cmdline *cl,
1232 : : __rte_unused void *data)
1233 : : {
1234 : : struct cmd_operate_attach_port_result *res = parsed_result;
1235 : :
1236 : 0 : if (!strcmp(res->keyword, "attach"))
1237 : 0 : attach_port(res->identifier);
1238 : : else
1239 : 0 : fprintf(stderr, "Unknown parameter\n");
1240 : 0 : }
1241 : :
1242 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1243 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1244 : : port, "port");
1245 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1246 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1247 : : keyword, "attach");
1248 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1249 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1250 : : identifier, TOKEN_STRING_MULTI);
1251 : :
1252 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1253 : : .f = cmd_operate_attach_port_parsed,
1254 : : .data = NULL,
1255 : : .help_str = "port attach <identifier>: "
1256 : : "(identifier: pci address or virtual dev name)",
1257 : : .tokens = {
1258 : : (void *)&cmd_operate_attach_port_port,
1259 : : (void *)&cmd_operate_attach_port_keyword,
1260 : : (void *)&cmd_operate_attach_port_identifier,
1261 : : NULL,
1262 : : },
1263 : : };
1264 : :
1265 : : /* *** detach a specified port *** */
1266 : : struct cmd_operate_detach_port_result {
1267 : : cmdline_fixed_string_t port;
1268 : : cmdline_fixed_string_t keyword;
1269 : : portid_t port_id;
1270 : : };
1271 : :
1272 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1273 : : __rte_unused struct cmdline *cl,
1274 : : __rte_unused void *data)
1275 : : {
1276 : : struct cmd_operate_detach_port_result *res = parsed_result;
1277 : :
1278 : 0 : if (!strcmp(res->keyword, "detach")) {
1279 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1280 : 0 : detach_port_device(res->port_id);
1281 : : } else {
1282 : 0 : fprintf(stderr, "Unknown parameter\n");
1283 : : }
1284 : : }
1285 : :
1286 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1287 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1288 : : port, "port");
1289 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1290 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1291 : : keyword, "detach");
1292 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1293 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1294 : : port_id, RTE_UINT16);
1295 : :
1296 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1297 : : .f = cmd_operate_detach_port_parsed,
1298 : : .data = NULL,
1299 : : .help_str = "port detach <port_id>",
1300 : : .tokens = {
1301 : : (void *)&cmd_operate_detach_port_port,
1302 : : (void *)&cmd_operate_detach_port_keyword,
1303 : : (void *)&cmd_operate_detach_port_port_id,
1304 : : NULL,
1305 : : },
1306 : : };
1307 : :
1308 : : /* *** detach device by identifier *** */
1309 : : struct cmd_operate_detach_device_result {
1310 : : cmdline_fixed_string_t device;
1311 : : cmdline_fixed_string_t keyword;
1312 : : cmdline_fixed_string_t identifier;
1313 : : };
1314 : :
1315 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1316 : : __rte_unused struct cmdline *cl,
1317 : : __rte_unused void *data)
1318 : : {
1319 : : struct cmd_operate_detach_device_result *res = parsed_result;
1320 : :
1321 : 0 : if (!strcmp(res->keyword, "detach"))
1322 : 0 : detach_devargs(res->identifier);
1323 : : else
1324 : 0 : fprintf(stderr, "Unknown parameter\n");
1325 : 0 : }
1326 : :
1327 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1328 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1329 : : device, "device");
1330 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1331 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1332 : : keyword, "detach");
1333 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1334 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1335 : : identifier, NULL);
1336 : :
1337 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1338 : : .f = cmd_operate_detach_device_parsed,
1339 : : .data = NULL,
1340 : : .help_str = "device detach <identifier>:"
1341 : : "(identifier: pci address or virtual dev name)",
1342 : : .tokens = {
1343 : : (void *)&cmd_operate_detach_device_device,
1344 : : (void *)&cmd_operate_detach_device_keyword,
1345 : : (void *)&cmd_operate_detach_device_identifier,
1346 : : NULL,
1347 : : },
1348 : : };
1349 : : /* *** configure speed for all ports *** */
1350 : : struct cmd_config_speed_all {
1351 : : cmdline_fixed_string_t port;
1352 : : cmdline_fixed_string_t keyword;
1353 : : cmdline_fixed_string_t all;
1354 : : cmdline_fixed_string_t item1;
1355 : : cmdline_fixed_string_t item2;
1356 : : cmdline_fixed_string_t value1;
1357 : : cmdline_fixed_string_t value2;
1358 : : };
1359 : :
1360 : : static int
1361 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1362 : : {
1363 : :
1364 : : int duplex;
1365 : :
1366 : 0 : if (!strcmp(duplexstr, "half")) {
1367 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1368 : 0 : } else if (!strcmp(duplexstr, "full")) {
1369 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1370 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1371 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1372 : : } else {
1373 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1374 : 0 : return -1;
1375 : : }
1376 : :
1377 : 0 : if (!strcmp(speedstr, "10")) {
1378 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1379 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1380 : 0 : } else if (!strcmp(speedstr, "100")) {
1381 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1382 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1383 : : } else {
1384 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1385 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1386 : 0 : return -1;
1387 : : }
1388 : 0 : if (!strcmp(speedstr, "1000")) {
1389 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1390 : 0 : } else if (!strcmp(speedstr, "2500")) {
1391 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1392 : 0 : } else if (!strcmp(speedstr, "5000")) {
1393 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1394 : 0 : } else if (!strcmp(speedstr, "10000")) {
1395 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1396 : 0 : } else if (!strcmp(speedstr, "25000")) {
1397 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1398 : 0 : } else if (!strcmp(speedstr, "40000")) {
1399 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1400 : 0 : } else if (!strcmp(speedstr, "50000")) {
1401 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1402 : 0 : } else if (!strcmp(speedstr, "100000")) {
1403 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1404 : 0 : } else if (!strcmp(speedstr, "200000")) {
1405 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1406 : 0 : } else if (!strcmp(speedstr, "400000")) {
1407 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1408 : 0 : } else if (!strcmp(speedstr, "auto")) {
1409 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1410 : : } else {
1411 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1412 : 0 : return -1;
1413 : : }
1414 : : }
1415 : :
1416 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1417 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1418 : :
1419 : : return 0;
1420 : : }
1421 : :
1422 : : static void
1423 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1424 : : __rte_unused struct cmdline *cl,
1425 : : __rte_unused void *data)
1426 : : {
1427 : : struct cmd_config_speed_all *res = parsed_result;
1428 : : uint32_t link_speed;
1429 : : portid_t pid;
1430 : :
1431 : 0 : if (!all_ports_stopped()) {
1432 : 0 : fprintf(stderr, "Please stop all ports first\n");
1433 : 0 : return;
1434 : : }
1435 : :
1436 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1437 : : &link_speed) < 0)
1438 : : return;
1439 : :
1440 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1441 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1442 : : }
1443 : :
1444 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1445 : : }
1446 : :
1447 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1448 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1449 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1450 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1451 : : "config");
1452 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1453 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1454 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1455 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1456 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1457 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1458 : : "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1459 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1460 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1461 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1462 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1463 : : "half#full#auto");
1464 : :
1465 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1466 : : .f = cmd_config_speed_all_parsed,
1467 : : .data = NULL,
1468 : : .help_str = "port config all speed "
1469 : : "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1470 : : "half|full|auto",
1471 : : .tokens = {
1472 : : (void *)&cmd_config_speed_all_port,
1473 : : (void *)&cmd_config_speed_all_keyword,
1474 : : (void *)&cmd_config_speed_all_all,
1475 : : (void *)&cmd_config_speed_all_item1,
1476 : : (void *)&cmd_config_speed_all_value1,
1477 : : (void *)&cmd_config_speed_all_item2,
1478 : : (void *)&cmd_config_speed_all_value2,
1479 : : NULL,
1480 : : },
1481 : : };
1482 : :
1483 : : /* *** configure speed for specific port *** */
1484 : : struct cmd_config_speed_specific {
1485 : : cmdline_fixed_string_t port;
1486 : : cmdline_fixed_string_t keyword;
1487 : : portid_t id;
1488 : : cmdline_fixed_string_t item1;
1489 : : cmdline_fixed_string_t item2;
1490 : : cmdline_fixed_string_t value1;
1491 : : cmdline_fixed_string_t value2;
1492 : : };
1493 : :
1494 : : static void
1495 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1496 : : __rte_unused struct cmdline *cl,
1497 : : __rte_unused void *data)
1498 : : {
1499 : : struct cmd_config_speed_specific *res = parsed_result;
1500 : : uint32_t link_speed;
1501 : :
1502 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1503 : 0 : return;
1504 : :
1505 : 0 : if (!port_is_stopped(res->id)) {
1506 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1507 : 0 : return;
1508 : : }
1509 : :
1510 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1511 : : &link_speed) < 0)
1512 : : return;
1513 : :
1514 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1515 : :
1516 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1517 : : }
1518 : :
1519 : :
1520 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1521 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1522 : : "port");
1523 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1524 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1525 : : "config");
1526 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1527 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1528 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1529 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1530 : : "speed");
1531 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1532 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1533 : : "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1534 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1535 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1536 : : "duplex");
1537 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1538 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1539 : : "half#full#auto");
1540 : :
1541 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1542 : : .f = cmd_config_speed_specific_parsed,
1543 : : .data = NULL,
1544 : : .help_str = "port config <port_id> speed "
1545 : : "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1546 : : "half|full|auto",
1547 : : .tokens = {
1548 : : (void *)&cmd_config_speed_specific_port,
1549 : : (void *)&cmd_config_speed_specific_keyword,
1550 : : (void *)&cmd_config_speed_specific_id,
1551 : : (void *)&cmd_config_speed_specific_item1,
1552 : : (void *)&cmd_config_speed_specific_value1,
1553 : : (void *)&cmd_config_speed_specific_item2,
1554 : : (void *)&cmd_config_speed_specific_value2,
1555 : : NULL,
1556 : : },
1557 : : };
1558 : :
1559 : : /* *** configure loopback for all ports *** */
1560 : : struct cmd_config_loopback_all {
1561 : : cmdline_fixed_string_t port;
1562 : : cmdline_fixed_string_t keyword;
1563 : : cmdline_fixed_string_t all;
1564 : : cmdline_fixed_string_t item;
1565 : : uint32_t mode;
1566 : : };
1567 : :
1568 : : static void
1569 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1570 : : __rte_unused struct cmdline *cl,
1571 : : __rte_unused void *data)
1572 : : {
1573 : : struct cmd_config_loopback_all *res = parsed_result;
1574 : : portid_t pid;
1575 : :
1576 : 0 : if (!all_ports_stopped()) {
1577 : 0 : fprintf(stderr, "Please stop all ports first\n");
1578 : 0 : return;
1579 : : }
1580 : :
1581 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1582 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1583 : : }
1584 : :
1585 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1586 : : }
1587 : :
1588 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1589 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1590 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1591 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1592 : : "config");
1593 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1594 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1595 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1596 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1597 : : "loopback");
1598 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1599 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1600 : :
1601 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1602 : : .f = cmd_config_loopback_all_parsed,
1603 : : .data = NULL,
1604 : : .help_str = "port config all loopback <mode>",
1605 : : .tokens = {
1606 : : (void *)&cmd_config_loopback_all_port,
1607 : : (void *)&cmd_config_loopback_all_keyword,
1608 : : (void *)&cmd_config_loopback_all_all,
1609 : : (void *)&cmd_config_loopback_all_item,
1610 : : (void *)&cmd_config_loopback_all_mode,
1611 : : NULL,
1612 : : },
1613 : : };
1614 : :
1615 : : /* *** configure loopback for specific port *** */
1616 : : struct cmd_config_loopback_specific {
1617 : : cmdline_fixed_string_t port;
1618 : : cmdline_fixed_string_t keyword;
1619 : : uint16_t port_id;
1620 : : cmdline_fixed_string_t item;
1621 : : uint32_t mode;
1622 : : };
1623 : :
1624 : : static void
1625 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1626 : : __rte_unused struct cmdline *cl,
1627 : : __rte_unused void *data)
1628 : : {
1629 : : struct cmd_config_loopback_specific *res = parsed_result;
1630 : :
1631 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1632 : : return;
1633 : :
1634 : 0 : if (!port_is_stopped(res->port_id)) {
1635 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1636 : 0 : return;
1637 : : }
1638 : :
1639 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1640 : :
1641 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1642 : : }
1643 : :
1644 : :
1645 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1646 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1647 : : "port");
1648 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1649 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1650 : : "config");
1651 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1652 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1653 : : RTE_UINT16);
1654 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1655 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1656 : : "loopback");
1657 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1658 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1659 : : RTE_UINT32);
1660 : :
1661 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1662 : : .f = cmd_config_loopback_specific_parsed,
1663 : : .data = NULL,
1664 : : .help_str = "port config <port_id> loopback <mode>",
1665 : : .tokens = {
1666 : : (void *)&cmd_config_loopback_specific_port,
1667 : : (void *)&cmd_config_loopback_specific_keyword,
1668 : : (void *)&cmd_config_loopback_specific_id,
1669 : : (void *)&cmd_config_loopback_specific_item,
1670 : : (void *)&cmd_config_loopback_specific_mode,
1671 : : NULL,
1672 : : },
1673 : : };
1674 : :
1675 : : /* *** configure txq/rxq, txd/rxd *** */
1676 : : struct cmd_config_rx_tx {
1677 : : cmdline_fixed_string_t port;
1678 : : cmdline_fixed_string_t keyword;
1679 : : cmdline_fixed_string_t all;
1680 : : cmdline_fixed_string_t name;
1681 : : uint16_t value;
1682 : : };
1683 : :
1684 : : static void
1685 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1686 : : __rte_unused struct cmdline *cl,
1687 : : __rte_unused void *data)
1688 : : {
1689 : : struct cmd_config_rx_tx *res = parsed_result;
1690 : :
1691 : 0 : if (!all_ports_stopped()) {
1692 : 0 : fprintf(stderr, "Please stop all ports first\n");
1693 : 0 : return;
1694 : : }
1695 : 0 : if (!strcmp(res->name, "rxq")) {
1696 : 0 : if (!res->value && !nb_txq) {
1697 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1698 : 0 : return;
1699 : : }
1700 : 0 : if (check_nb_rxq(res->value) != 0)
1701 : : return;
1702 : 0 : nb_rxq = res->value;
1703 : : }
1704 : 0 : else if (!strcmp(res->name, "txq")) {
1705 : 0 : if (!res->value && !nb_rxq) {
1706 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1707 : 0 : return;
1708 : : }
1709 : 0 : if (check_nb_txq(res->value) != 0)
1710 : : return;
1711 : 0 : nb_txq = res->value;
1712 : : }
1713 : 0 : else if (!strcmp(res->name, "rxd")) {
1714 : 0 : if (check_nb_rxd(res->value) != 0)
1715 : : return;
1716 : 0 : nb_rxd = res->value;
1717 : 0 : } else if (!strcmp(res->name, "txd")) {
1718 : 0 : if (check_nb_txd(res->value) != 0)
1719 : : return;
1720 : :
1721 : 0 : nb_txd = res->value;
1722 : : } else {
1723 : 0 : fprintf(stderr, "Unknown parameter\n");
1724 : 0 : return;
1725 : : }
1726 : :
1727 : 0 : fwd_config_setup();
1728 : :
1729 : 0 : init_port_config();
1730 : :
1731 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1732 : : }
1733 : :
1734 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
1735 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1736 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1737 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1738 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
1739 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1740 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
1741 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1742 : : "rxq#txq#rxd#txd");
1743 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
1744 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1745 : :
1746 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
1747 : : .f = cmd_config_rx_tx_parsed,
1748 : : .data = NULL,
1749 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
1750 : : .tokens = {
1751 : : (void *)&cmd_config_rx_tx_port,
1752 : : (void *)&cmd_config_rx_tx_keyword,
1753 : : (void *)&cmd_config_rx_tx_all,
1754 : : (void *)&cmd_config_rx_tx_name,
1755 : : (void *)&cmd_config_rx_tx_value,
1756 : : NULL,
1757 : : },
1758 : : };
1759 : :
1760 : : /* *** config max packet length *** */
1761 : : struct cmd_config_max_pkt_len_result {
1762 : : cmdline_fixed_string_t port;
1763 : : cmdline_fixed_string_t keyword;
1764 : : cmdline_fixed_string_t all;
1765 : : cmdline_fixed_string_t name;
1766 : : uint32_t value;
1767 : : };
1768 : :
1769 : : static void
1770 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
1771 : : __rte_unused struct cmdline *cl,
1772 : : __rte_unused void *data)
1773 : : {
1774 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
1775 : : portid_t port_id;
1776 : : int ret;
1777 : :
1778 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
1779 : : printf("Unknown parameter\n");
1780 : 0 : return;
1781 : : }
1782 : :
1783 : 0 : if (!all_ports_stopped()) {
1784 : 0 : fprintf(stderr, "Please stop all ports first\n");
1785 : 0 : return;
1786 : : }
1787 : :
1788 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
1789 : 0 : struct rte_port *port = &ports[port_id];
1790 : :
1791 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
1792 : 0 : fprintf(stderr,
1793 : : "max-pkt-len can not be less than %d\n",
1794 : : RTE_ETHER_MIN_LEN);
1795 : 0 : return;
1796 : : }
1797 : :
1798 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1799 : 0 : if (ret != 0) {
1800 : 0 : fprintf(stderr,
1801 : : "rte_eth_dev_info_get() failed for port %u\n",
1802 : : port_id);
1803 : 0 : return;
1804 : : }
1805 : :
1806 : 0 : update_mtu_from_frame_size(port_id, res->value);
1807 : : }
1808 : :
1809 : 0 : init_port_config();
1810 : :
1811 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1812 : : }
1813 : :
1814 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1815 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1816 : : "port");
1817 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1818 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1819 : : "config");
1820 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1821 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1822 : : "all");
1823 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1824 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1825 : : "max-pkt-len");
1826 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1827 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1828 : : RTE_UINT32);
1829 : :
1830 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
1831 : : .f = cmd_config_max_pkt_len_parsed,
1832 : : .data = NULL,
1833 : : .help_str = "port config all max-pkt-len <value>",
1834 : : .tokens = {
1835 : : (void *)&cmd_config_max_pkt_len_port,
1836 : : (void *)&cmd_config_max_pkt_len_keyword,
1837 : : (void *)&cmd_config_max_pkt_len_all,
1838 : : (void *)&cmd_config_max_pkt_len_name,
1839 : : (void *)&cmd_config_max_pkt_len_value,
1840 : : NULL,
1841 : : },
1842 : : };
1843 : :
1844 : : /* *** config max LRO aggregated packet size *** */
1845 : : struct cmd_config_max_lro_pkt_size_result {
1846 : : cmdline_fixed_string_t port;
1847 : : cmdline_fixed_string_t keyword;
1848 : : cmdline_fixed_string_t all;
1849 : : cmdline_fixed_string_t name;
1850 : : uint32_t value;
1851 : : };
1852 : :
1853 : : static void
1854 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1855 : : __rte_unused struct cmdline *cl,
1856 : : __rte_unused void *data)
1857 : : {
1858 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1859 : : portid_t pid;
1860 : :
1861 : 0 : if (!all_ports_stopped()) {
1862 : 0 : fprintf(stderr, "Please stop all ports first\n");
1863 : 0 : return;
1864 : : }
1865 : :
1866 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1867 : 0 : struct rte_port *port = &ports[pid];
1868 : :
1869 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
1870 : 0 : if (res->value ==
1871 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
1872 : : return;
1873 : :
1874 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1875 : : } else {
1876 : 0 : fprintf(stderr, "Unknown parameter\n");
1877 : 0 : return;
1878 : : }
1879 : : }
1880 : :
1881 : 0 : init_port_config();
1882 : :
1883 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1884 : : }
1885 : :
1886 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1887 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1888 : : port, "port");
1889 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
1890 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1891 : : keyword, "config");
1892 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
1893 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1894 : : all, "all");
1895 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
1896 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1897 : : name, "max-lro-pkt-size");
1898 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
1899 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1900 : : value, RTE_UINT32);
1901 : :
1902 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
1903 : : .f = cmd_config_max_lro_pkt_size_parsed,
1904 : : .data = NULL,
1905 : : .help_str = "port config all max-lro-pkt-size <value>",
1906 : : .tokens = {
1907 : : (void *)&cmd_config_max_lro_pkt_size_port,
1908 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
1909 : : (void *)&cmd_config_max_lro_pkt_size_all,
1910 : : (void *)&cmd_config_max_lro_pkt_size_name,
1911 : : (void *)&cmd_config_max_lro_pkt_size_value,
1912 : : NULL,
1913 : : },
1914 : : };
1915 : :
1916 : : /* *** configure port MTU *** */
1917 : : struct cmd_config_mtu_result {
1918 : : cmdline_fixed_string_t port;
1919 : : cmdline_fixed_string_t keyword;
1920 : : cmdline_fixed_string_t mtu;
1921 : : portid_t port_id;
1922 : : uint16_t value;
1923 : : };
1924 : :
1925 : : static void
1926 : 0 : cmd_config_mtu_parsed(void *parsed_result,
1927 : : __rte_unused struct cmdline *cl,
1928 : : __rte_unused void *data)
1929 : : {
1930 : : struct cmd_config_mtu_result *res = parsed_result;
1931 : :
1932 : 0 : port_mtu_set(res->port_id, res->value);
1933 : 0 : }
1934 : :
1935 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
1936 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1937 : : "port");
1938 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
1939 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1940 : : "config");
1941 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
1942 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1943 : : "mtu");
1944 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
1945 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
1946 : : RTE_UINT16);
1947 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
1948 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
1949 : : RTE_UINT16);
1950 : :
1951 : : static cmdline_parse_inst_t cmd_config_mtu = {
1952 : : .f = cmd_config_mtu_parsed,
1953 : : .data = NULL,
1954 : : .help_str = "port config mtu <port_id> <value>",
1955 : : .tokens = {
1956 : : (void *)&cmd_config_mtu_port,
1957 : : (void *)&cmd_config_mtu_keyword,
1958 : : (void *)&cmd_config_mtu_mtu,
1959 : : (void *)&cmd_config_mtu_port_id,
1960 : : (void *)&cmd_config_mtu_value,
1961 : : NULL,
1962 : : },
1963 : : };
1964 : :
1965 : : /* *** configure rx mode *** */
1966 : : struct cmd_config_rx_mode_flag {
1967 : : cmdline_fixed_string_t port;
1968 : : cmdline_fixed_string_t keyword;
1969 : : cmdline_fixed_string_t all;
1970 : : cmdline_fixed_string_t name;
1971 : : cmdline_fixed_string_t value;
1972 : : };
1973 : :
1974 : : static void
1975 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
1976 : : __rte_unused struct cmdline *cl,
1977 : : __rte_unused void *data)
1978 : : {
1979 : : struct cmd_config_rx_mode_flag *res = parsed_result;
1980 : :
1981 : 0 : if (!all_ports_stopped()) {
1982 : 0 : fprintf(stderr, "Please stop all ports first\n");
1983 : 0 : return;
1984 : : }
1985 : :
1986 : 0 : if (!strcmp(res->name, "drop-en")) {
1987 : 0 : if (!strcmp(res->value, "on"))
1988 : 0 : rx_drop_en = 1;
1989 : 0 : else if (!strcmp(res->value, "off"))
1990 : 0 : rx_drop_en = 0;
1991 : : else {
1992 : 0 : fprintf(stderr, "Unknown parameter\n");
1993 : 0 : return;
1994 : : }
1995 : : } else {
1996 : 0 : fprintf(stderr, "Unknown parameter\n");
1997 : 0 : return;
1998 : : }
1999 : :
2000 : 0 : init_port_config();
2001 : :
2002 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2003 : : }
2004 : :
2005 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2006 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2007 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2008 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2009 : : "config");
2010 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2011 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2012 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2013 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2014 : : "drop-en");
2015 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2016 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2017 : : "on#off");
2018 : :
2019 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2020 : : .f = cmd_config_rx_mode_flag_parsed,
2021 : : .data = NULL,
2022 : : .help_str = "port config all drop-en on|off",
2023 : : .tokens = {
2024 : : (void *)&cmd_config_rx_mode_flag_port,
2025 : : (void *)&cmd_config_rx_mode_flag_keyword,
2026 : : (void *)&cmd_config_rx_mode_flag_all,
2027 : : (void *)&cmd_config_rx_mode_flag_name,
2028 : : (void *)&cmd_config_rx_mode_flag_value,
2029 : : NULL,
2030 : : },
2031 : : };
2032 : :
2033 : : /* *** configure rss *** */
2034 : : struct cmd_config_rss {
2035 : : cmdline_fixed_string_t port;
2036 : : cmdline_fixed_string_t keyword;
2037 : : cmdline_fixed_string_t all;
2038 : : cmdline_fixed_string_t name;
2039 : : cmdline_fixed_string_t value;
2040 : : };
2041 : :
2042 : : static void
2043 : 0 : cmd_config_rss_parsed(void *parsed_result,
2044 : : __rte_unused struct cmdline *cl,
2045 : : __rte_unused void *data)
2046 : : {
2047 : : struct cmd_config_rss *res = parsed_result;
2048 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2049 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2050 : : int use_default = 0;
2051 : : int all_updated = 1;
2052 : : int diag;
2053 : : uint16_t i;
2054 : : int ret;
2055 : :
2056 : 0 : if (!strcmp(res->value, "level-default")) {
2057 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2058 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2059 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2060 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2061 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2062 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2063 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2064 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2065 : 0 : } else if (!strcmp(res->value, "default")) {
2066 : : use_default = 1;
2067 : 0 : } else if (isdigit(res->value[0])) {
2068 : : int value = atoi(res->value);
2069 : 0 : if (value > 0 && value < 64)
2070 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2071 : : else {
2072 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2073 : 0 : return;
2074 : : }
2075 : 0 : } else if (!strcmp(res->value, "none")) {
2076 : : rss_conf.rss_hf = 0;
2077 : : } else {
2078 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2079 : 0 : if (rss_conf.rss_hf == 0) {
2080 : 0 : fprintf(stderr, "Unknown parameter\n");
2081 : 0 : return;
2082 : : }
2083 : : }
2084 : : rss_conf.rss_key = NULL;
2085 : : /* Update global configuration for RSS types. */
2086 : 0 : RTE_ETH_FOREACH_DEV(i) {
2087 : : struct rte_eth_rss_conf local_rss_conf;
2088 : :
2089 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2090 : 0 : if (ret != 0)
2091 : 0 : return;
2092 : :
2093 : 0 : if (use_default)
2094 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2095 : :
2096 : 0 : local_rss_conf = rss_conf;
2097 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2098 : 0 : dev_info.flow_type_rss_offloads;
2099 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2100 : : printf("Port %u modified RSS hash function based on hardware support,"
2101 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2102 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2103 : : }
2104 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2105 : 0 : if (diag < 0) {
2106 : : all_updated = 0;
2107 : 0 : fprintf(stderr,
2108 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2109 : : i, -diag, strerror(-diag));
2110 : : }
2111 : : }
2112 : 0 : if (all_updated && !use_default) {
2113 : 0 : rss_hf = rss_conf.rss_hf;
2114 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2115 : : }
2116 : : }
2117 : :
2118 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2119 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2120 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2121 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2122 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2123 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2124 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2125 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2126 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2127 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2128 : :
2129 : : static cmdline_parse_inst_t cmd_config_rss = {
2130 : : .f = cmd_config_rss_parsed,
2131 : : .data = NULL,
2132 : : .help_str = "port config all rss "
2133 : : "all|default|level-default|level-outer|level-inner|"
2134 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2135 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2136 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2137 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2138 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2139 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2140 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2141 : : .tokens = {
2142 : : (void *)&cmd_config_rss_port,
2143 : : (void *)&cmd_config_rss_keyword,
2144 : : (void *)&cmd_config_rss_all,
2145 : : (void *)&cmd_config_rss_name,
2146 : : (void *)&cmd_config_rss_value,
2147 : : NULL,
2148 : : },
2149 : : };
2150 : :
2151 : : /* *** configure rss hash key *** */
2152 : : struct cmd_config_rss_hash_key {
2153 : : cmdline_fixed_string_t port;
2154 : : cmdline_fixed_string_t config;
2155 : : portid_t port_id;
2156 : : cmdline_fixed_string_t rss_hash_key;
2157 : : cmdline_fixed_string_t rss_type;
2158 : : cmdline_fixed_string_t key;
2159 : : };
2160 : :
2161 : : static uint8_t
2162 : : hexa_digit_to_value(char hexa_digit)
2163 : : {
2164 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2165 : : return (uint8_t) (hexa_digit - '0');
2166 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2167 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2168 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2169 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2170 : : /* Invalid hexa digit */
2171 : : return 0xFF;
2172 : : }
2173 : :
2174 : : static uint8_t
2175 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2176 : : {
2177 : : uint8_t hexa_v;
2178 : :
2179 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2180 : : if (hexa_v == 0xFF)
2181 : 0 : fprintf(stderr,
2182 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2183 : : key[idx], idx);
2184 : 0 : return hexa_v;
2185 : : }
2186 : :
2187 : : static void
2188 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2189 : : __rte_unused struct cmdline *cl,
2190 : : __rte_unused void *data)
2191 : : {
2192 : : struct cmd_config_rss_hash_key *res = parsed_result;
2193 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2194 : : uint8_t xdgt0;
2195 : : uint8_t xdgt1;
2196 : : int i;
2197 : : struct rte_eth_dev_info dev_info;
2198 : : uint8_t hash_key_size;
2199 : : uint32_t key_len;
2200 : : int ret;
2201 : :
2202 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2203 : 0 : if (ret != 0)
2204 : 0 : return;
2205 : :
2206 : 0 : if (dev_info.hash_key_size > 0 &&
2207 : : dev_info.hash_key_size <= sizeof(hash_key))
2208 : : hash_key_size = dev_info.hash_key_size;
2209 : : else {
2210 : 0 : fprintf(stderr,
2211 : : "dev_info did not provide a valid hash key size\n");
2212 : 0 : return;
2213 : : }
2214 : : /* Check the length of the RSS hash key */
2215 : 0 : key_len = strlen(res->key);
2216 : 0 : if (key_len != (hash_key_size * 2)) {
2217 : 0 : fprintf(stderr,
2218 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2219 : : (int)key_len, hash_key_size * 2);
2220 : 0 : return;
2221 : : }
2222 : : /* Translate RSS hash key into binary representation */
2223 : 0 : for (i = 0; i < hash_key_size; i++) {
2224 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2225 : 0 : if (xdgt0 == 0xFF)
2226 : : return;
2227 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2228 : 0 : if (xdgt1 == 0xFF)
2229 : : return;
2230 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2231 : : }
2232 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2233 : : hash_key_size);
2234 : : }
2235 : :
2236 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2237 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2238 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2239 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2240 : : "config");
2241 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2242 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2243 : : RTE_UINT16);
2244 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2245 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2246 : : rss_hash_key, "rss-hash-key");
2247 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2248 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2249 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2250 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2251 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2252 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2253 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2254 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2255 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2256 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2257 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2258 : :
2259 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2260 : : .f = cmd_config_rss_hash_key_parsed,
2261 : : .data = NULL,
2262 : : .help_str = "port config <port_id> rss-hash-key "
2263 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2264 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2265 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2266 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2267 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2268 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2269 : : "<string of hex digits (variable length, NIC dependent)>",
2270 : : .tokens = {
2271 : : (void *)&cmd_config_rss_hash_key_port,
2272 : : (void *)&cmd_config_rss_hash_key_config,
2273 : : (void *)&cmd_config_rss_hash_key_port_id,
2274 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2275 : : (void *)&cmd_config_rss_hash_key_rss_type,
2276 : : (void *)&cmd_config_rss_hash_key_value,
2277 : : NULL,
2278 : : },
2279 : : };
2280 : :
2281 : : /* *** configure rss hash algorithm *** */
2282 : : struct cmd_config_rss_hash_algo {
2283 : : cmdline_fixed_string_t port;
2284 : : cmdline_fixed_string_t config;
2285 : : portid_t port_id;
2286 : : cmdline_fixed_string_t rss_hash_algo;
2287 : : cmdline_fixed_string_t algo;
2288 : : };
2289 : :
2290 : : static void
2291 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2292 : : __rte_unused struct cmdline *cl,
2293 : : __rte_unused void *data)
2294 : : {
2295 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2296 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2297 : : struct rte_eth_rss_conf rss_conf;
2298 : : uint32_t algorithm;
2299 : : int ret;
2300 : :
2301 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2302 : 0 : rss_conf.rss_key = rss_key;
2303 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2304 : 0 : if (ret != 0) {
2305 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2306 : 0 : res->port_id);
2307 : 0 : return;
2308 : : }
2309 : :
2310 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2311 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2312 : 0 : if (ret != 0) {
2313 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2314 : 0 : res->port_id, res->algo);
2315 : 0 : return;
2316 : : }
2317 : :
2318 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2319 : 0 : if (ret != 0) {
2320 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2321 : 0 : res->port_id);
2322 : 0 : return;
2323 : : }
2324 : : }
2325 : :
2326 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2327 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2328 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2329 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2330 : : "config");
2331 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2332 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2333 : : RTE_UINT16);
2334 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2335 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2336 : : rss_hash_algo, "rss-hash-algo");
2337 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2338 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2339 : : "default#simple_xor#toeplitz#"
2340 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2341 : :
2342 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2343 : : .f = cmd_config_rss_hash_algo_parsed,
2344 : : .data = NULL,
2345 : : .help_str = "port config <port_id> rss-hash-algo "
2346 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2347 : : .tokens = {
2348 : : (void *)&cmd_config_rss_hash_algo_port,
2349 : : (void *)&cmd_config_rss_hash_algo_config,
2350 : : (void *)&cmd_config_rss_hash_algo_port_id,
2351 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2352 : : (void *)&cmd_config_rss_hash_algo_algo,
2353 : : NULL,
2354 : : },
2355 : : };
2356 : :
2357 : : /* *** cleanup txq mbufs *** */
2358 : : struct cmd_cleanup_txq_mbufs_result {
2359 : : cmdline_fixed_string_t port;
2360 : : cmdline_fixed_string_t keyword;
2361 : : cmdline_fixed_string_t name;
2362 : : uint16_t port_id;
2363 : : uint16_t queue_id;
2364 : : uint32_t free_cnt;
2365 : : };
2366 : :
2367 : : static void
2368 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2369 : : __rte_unused struct cmdline *cl,
2370 : : __rte_unused void *data)
2371 : : {
2372 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2373 : 0 : uint16_t port_id = res->port_id;
2374 : 0 : uint16_t queue_id = res->queue_id;
2375 : 0 : uint32_t free_cnt = res->free_cnt;
2376 : : struct rte_eth_txq_info qinfo;
2377 : : int ret;
2378 : :
2379 : 0 : if (test_done == 0) {
2380 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2381 : 0 : return;
2382 : : }
2383 : :
2384 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2385 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2386 : : port_id, queue_id);
2387 : 0 : return;
2388 : : }
2389 : :
2390 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2391 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2392 : 0 : return;
2393 : : }
2394 : :
2395 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2396 : 0 : if (ret < 0) {
2397 : 0 : fprintf(stderr,
2398 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2399 : : port_id, queue_id, strerror(-ret), ret);
2400 : 0 : return;
2401 : : }
2402 : :
2403 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2404 : : port_id, queue_id, ret);
2405 : : }
2406 : :
2407 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2408 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2409 : : "port");
2410 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2411 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2412 : : "cleanup");
2413 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2414 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2415 : : RTE_UINT16);
2416 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2417 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2418 : : "txq");
2419 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2420 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2421 : : RTE_UINT16);
2422 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2423 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2424 : : RTE_UINT32);
2425 : :
2426 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2427 : : .f = cmd_cleanup_txq_mbufs_parsed,
2428 : : .data = NULL,
2429 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2430 : : .tokens = {
2431 : : (void *)&cmd_cleanup_txq_mbufs_port,
2432 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2433 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2434 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2435 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2436 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2437 : : NULL,
2438 : : },
2439 : : };
2440 : :
2441 : : /* *** configure port rxq/txq ring size *** */
2442 : : struct cmd_config_rxtx_ring_size {
2443 : : cmdline_fixed_string_t port;
2444 : : cmdline_fixed_string_t config;
2445 : : portid_t portid;
2446 : : cmdline_fixed_string_t rxtxq;
2447 : : uint16_t qid;
2448 : : cmdline_fixed_string_t rsize;
2449 : : uint16_t size;
2450 : : };
2451 : :
2452 : : static void
2453 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2454 : : __rte_unused struct cmdline *cl,
2455 : : __rte_unused void *data)
2456 : : {
2457 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2458 : : struct rte_port *port;
2459 : : uint8_t isrx;
2460 : :
2461 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2462 : : return;
2463 : :
2464 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2465 : 0 : fprintf(stderr, "Invalid port id\n");
2466 : 0 : return;
2467 : : }
2468 : :
2469 : 0 : port = &ports[res->portid];
2470 : :
2471 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2472 : : isrx = 1;
2473 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2474 : : isrx = 0;
2475 : : else {
2476 : 0 : fprintf(stderr, "Unknown parameter\n");
2477 : 0 : return;
2478 : : }
2479 : :
2480 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2481 : : return;
2482 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2483 : : return;
2484 : :
2485 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2486 : 0 : fprintf(stderr,
2487 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2488 : : rx_free_thresh);
2489 : 0 : return;
2490 : : }
2491 : :
2492 : 0 : if (isrx)
2493 : 0 : port->nb_rx_desc[res->qid] = res->size;
2494 : : else
2495 : 0 : port->nb_tx_desc[res->qid] = res->size;
2496 : :
2497 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2498 : : }
2499 : :
2500 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2501 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2502 : : port, "port");
2503 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2504 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2505 : : config, "config");
2506 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2507 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2508 : : portid, RTE_UINT16);
2509 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2510 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2511 : : rxtxq, "rxq#txq");
2512 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2513 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2514 : : qid, RTE_UINT16);
2515 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2516 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2517 : : rsize, "ring_size");
2518 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2519 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2520 : : size, RTE_UINT16);
2521 : :
2522 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2523 : : .f = cmd_config_rxtx_ring_size_parsed,
2524 : : .data = NULL,
2525 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2526 : : .tokens = {
2527 : : (void *)&cmd_config_rxtx_ring_size_port,
2528 : : (void *)&cmd_config_rxtx_ring_size_config,
2529 : : (void *)&cmd_config_rxtx_ring_size_portid,
2530 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2531 : : (void *)&cmd_config_rxtx_ring_size_qid,
2532 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2533 : : (void *)&cmd_config_rxtx_ring_size_size,
2534 : : NULL,
2535 : : },
2536 : : };
2537 : :
2538 : : /* *** configure port rxq/txq start/stop *** */
2539 : : struct cmd_config_rxtx_queue {
2540 : : cmdline_fixed_string_t port;
2541 : : portid_t portid;
2542 : : cmdline_fixed_string_t rxtxq;
2543 : : uint16_t qid;
2544 : : cmdline_fixed_string_t opname;
2545 : : };
2546 : :
2547 : : static void
2548 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2549 : : __rte_unused struct cmdline *cl,
2550 : : __rte_unused void *data)
2551 : : {
2552 : : struct cmd_config_rxtx_queue *res = parsed_result;
2553 : : struct rte_port *port;
2554 : : uint8_t isrx;
2555 : : uint8_t isstart;
2556 : : uint8_t *state;
2557 : : int ret = 0;
2558 : :
2559 : 0 : if (test_done == 0) {
2560 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2561 : 0 : return;
2562 : : }
2563 : :
2564 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2565 : : return;
2566 : :
2567 : 0 : if (port_is_started(res->portid) != 1) {
2568 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2569 : 0 : return;
2570 : : }
2571 : :
2572 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2573 : : isrx = 1;
2574 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2575 : : isrx = 0;
2576 : : else {
2577 : 0 : fprintf(stderr, "Unknown parameter\n");
2578 : 0 : return;
2579 : : }
2580 : :
2581 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2582 : : return;
2583 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2584 : : return;
2585 : :
2586 : 0 : if (!strcmp(res->opname, "start"))
2587 : : isstart = 1;
2588 : 0 : else if (!strcmp(res->opname, "stop"))
2589 : : isstart = 0;
2590 : : else {
2591 : 0 : fprintf(stderr, "Unknown parameter\n");
2592 : 0 : return;
2593 : : }
2594 : :
2595 : 0 : if (isstart && isrx)
2596 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2597 : 0 : else if (!isstart && isrx)
2598 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2599 : 0 : else if (isstart && !isrx)
2600 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2601 : : else
2602 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2603 : :
2604 : 0 : if (ret == -ENOTSUP) {
2605 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2606 : 0 : return;
2607 : : }
2608 : :
2609 : 0 : port = &ports[res->portid];
2610 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2611 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2612 : : RTE_ETH_QUEUE_STATE_STOPPED;
2613 : : }
2614 : :
2615 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2616 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2617 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2618 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2619 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2620 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2621 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2622 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2623 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2624 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2625 : : "start#stop");
2626 : :
2627 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2628 : : .f = cmd_config_rxtx_queue_parsed,
2629 : : .data = NULL,
2630 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2631 : : .tokens = {
2632 : : (void *)&cmd_config_rxtx_queue_port,
2633 : : (void *)&cmd_config_rxtx_queue_portid,
2634 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2635 : : (void *)&cmd_config_rxtx_queue_qid,
2636 : : (void *)&cmd_config_rxtx_queue_opname,
2637 : : NULL,
2638 : : },
2639 : : };
2640 : :
2641 : : /* *** configure port rxq/txq deferred start on/off *** */
2642 : : struct cmd_config_deferred_start_rxtx_queue {
2643 : : cmdline_fixed_string_t port;
2644 : : portid_t port_id;
2645 : : cmdline_fixed_string_t rxtxq;
2646 : : uint16_t qid;
2647 : : cmdline_fixed_string_t opname;
2648 : : cmdline_fixed_string_t state;
2649 : : };
2650 : :
2651 : : static void
2652 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2653 : : __rte_unused struct cmdline *cl,
2654 : : __rte_unused void *data)
2655 : : {
2656 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2657 : : struct rte_port *port;
2658 : : uint8_t isrx;
2659 : : uint8_t ison;
2660 : : uint8_t needreconfig = 0;
2661 : :
2662 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2663 : : return;
2664 : :
2665 : 0 : if (port_is_started(res->port_id) != 0) {
2666 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2667 : 0 : return;
2668 : : }
2669 : :
2670 : 0 : port = &ports[res->port_id];
2671 : :
2672 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2673 : :
2674 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2675 : : return;
2676 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2677 : : return;
2678 : :
2679 : 0 : ison = !strcmp(res->state, "on");
2680 : :
2681 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2682 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2683 : : needreconfig = 1;
2684 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2685 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2686 : : needreconfig = 1;
2687 : : }
2688 : :
2689 : : if (needreconfig)
2690 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2691 : : }
2692 : :
2693 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2694 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2695 : : port, "port");
2696 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2697 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2698 : : port_id, RTE_UINT16);
2699 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2700 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2701 : : rxtxq, "rxq#txq");
2702 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2703 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2704 : : qid, RTE_UINT16);
2705 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2706 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2707 : : opname, "deferred_start");
2708 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2709 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2710 : : state, "on#off");
2711 : :
2712 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2713 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
2714 : : .data = NULL,
2715 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2716 : : .tokens = {
2717 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
2718 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2719 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2720 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2721 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2722 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
2723 : : NULL,
2724 : : },
2725 : : };
2726 : :
2727 : : /* *** configure port rxq/txq setup *** */
2728 : : struct cmd_setup_rxtx_queue {
2729 : : cmdline_fixed_string_t port;
2730 : : portid_t portid;
2731 : : cmdline_fixed_string_t rxtxq;
2732 : : uint16_t qid;
2733 : : cmdline_fixed_string_t setup;
2734 : : };
2735 : :
2736 : : /* Common CLI fields for queue setup */
2737 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2738 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2739 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2740 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2741 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2742 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2743 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2744 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2745 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2746 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2747 : :
2748 : : static void
2749 : 0 : cmd_setup_rxtx_queue_parsed(
2750 : : void *parsed_result,
2751 : : __rte_unused struct cmdline *cl,
2752 : : __rte_unused void *data)
2753 : : {
2754 : : struct cmd_setup_rxtx_queue *res = parsed_result;
2755 : : struct rte_port *port;
2756 : : struct rte_mempool *mp;
2757 : : unsigned int socket_id;
2758 : : uint8_t isrx = 0;
2759 : : int ret;
2760 : :
2761 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2762 : : return;
2763 : :
2764 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2765 : 0 : fprintf(stderr, "Invalid port id\n");
2766 : 0 : return;
2767 : : }
2768 : :
2769 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2770 : : isrx = 1;
2771 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2772 : : isrx = 0;
2773 : : else {
2774 : 0 : fprintf(stderr, "Unknown parameter\n");
2775 : 0 : return;
2776 : : }
2777 : :
2778 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
2779 : 0 : fprintf(stderr, "Invalid rx queue\n");
2780 : 0 : return;
2781 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2782 : 0 : fprintf(stderr, "Invalid tx queue\n");
2783 : 0 : return;
2784 : : }
2785 : :
2786 : 0 : port = &ports[res->portid];
2787 : 0 : if (isrx) {
2788 : 0 : socket_id = rxring_numa[res->portid];
2789 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
2790 : 0 : socket_id = port->socket_id;
2791 : :
2792 : : mp = mbuf_pool_find(socket_id, 0);
2793 : 0 : if (mp == NULL) {
2794 : 0 : fprintf(stderr,
2795 : : "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2796 : 0 : rxring_numa[res->portid]);
2797 : 0 : return;
2798 : : }
2799 : 0 : ret = rx_queue_setup(res->portid,
2800 : : res->qid,
2801 : 0 : port->nb_rx_desc[res->qid],
2802 : : socket_id,
2803 : 0 : &port->rxq[res->qid].conf,
2804 : : mp);
2805 : 0 : if (ret)
2806 : 0 : fprintf(stderr, "Failed to setup RX queue\n");
2807 : : } else {
2808 : 0 : socket_id = txring_numa[res->portid];
2809 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
2810 : 0 : socket_id = port->socket_id;
2811 : :
2812 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2813 : 0 : fprintf(stderr,
2814 : : "Failed to setup TX queue: not enough descriptors\n");
2815 : 0 : return;
2816 : : }
2817 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
2818 : : res->qid,
2819 : : port->nb_tx_desc[res->qid],
2820 : : socket_id,
2821 : 0 : &port->txq[res->qid].conf);
2822 : 0 : if (ret)
2823 : 0 : fprintf(stderr, "Failed to setup TX queue\n");
2824 : : }
2825 : : }
2826 : :
2827 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2828 : : .f = cmd_setup_rxtx_queue_parsed,
2829 : : .data = NULL,
2830 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2831 : : .tokens = {
2832 : : (void *)&cmd_setup_rxtx_queue_port,
2833 : : (void *)&cmd_setup_rxtx_queue_portid,
2834 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
2835 : : (void *)&cmd_setup_rxtx_queue_qid,
2836 : : (void *)&cmd_setup_rxtx_queue_setup,
2837 : : NULL,
2838 : : },
2839 : : };
2840 : :
2841 : :
2842 : : /* *** Configure RSS RETA *** */
2843 : : struct cmd_config_rss_reta {
2844 : : cmdline_fixed_string_t port;
2845 : : cmdline_fixed_string_t keyword;
2846 : : portid_t port_id;
2847 : : cmdline_fixed_string_t name;
2848 : : cmdline_fixed_string_t list_name;
2849 : : cmdline_fixed_string_t list_of_items;
2850 : : };
2851 : :
2852 : : static int
2853 : 0 : parse_reta_config(const char *str,
2854 : : struct rte_eth_rss_reta_entry64 *reta_conf,
2855 : : uint16_t nb_entries)
2856 : : {
2857 : : int i;
2858 : : unsigned size;
2859 : : uint16_t hash_index, idx, shift;
2860 : : uint16_t nb_queue;
2861 : : char s[256];
2862 : : const char *p, *p0 = str;
2863 : : char *end;
2864 : : enum fieldnames {
2865 : : FLD_HASH_INDEX = 0,
2866 : : FLD_QUEUE,
2867 : : _NUM_FLD
2868 : : };
2869 : : unsigned long int_fld[_NUM_FLD];
2870 : : char *str_fld[_NUM_FLD];
2871 : :
2872 : 0 : while ((p = strchr(p0,'(')) != NULL) {
2873 : 0 : ++p;
2874 : 0 : if((p0 = strchr(p,')')) == NULL)
2875 : : return -1;
2876 : :
2877 : 0 : size = p0 - p;
2878 : 0 : if(size >= sizeof(s))
2879 : : return -1;
2880 : :
2881 : : snprintf(s, sizeof(s), "%.*s", size, p);
2882 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2883 : : return -1;
2884 : 0 : for (i = 0; i < _NUM_FLD; i++) {
2885 : 0 : errno = 0;
2886 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
2887 : 0 : if (errno != 0 || end == str_fld[i] ||
2888 : : int_fld[i] > 65535)
2889 : : return -1;
2890 : : }
2891 : :
2892 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2893 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2894 : :
2895 : 0 : if (hash_index >= nb_entries) {
2896 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
2897 : : hash_index);
2898 : 0 : return -1;
2899 : : }
2900 : :
2901 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2902 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
2903 : 0 : reta_conf[idx].mask |= (1ULL << shift);
2904 : 0 : reta_conf[idx].reta[shift] = nb_queue;
2905 : : }
2906 : :
2907 : : return 0;
2908 : : }
2909 : :
2910 : : static void
2911 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
2912 : : __rte_unused struct cmdline *cl,
2913 : : __rte_unused void *data)
2914 : : {
2915 : : int ret;
2916 : : struct rte_eth_dev_info dev_info;
2917 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
2918 : : struct cmd_config_rss_reta *res = parsed_result;
2919 : :
2920 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2921 : 0 : if (ret != 0)
2922 : 0 : return;
2923 : :
2924 : 0 : if (dev_info.reta_size == 0) {
2925 : 0 : fprintf(stderr,
2926 : : "Redirection table size is 0 which is invalid for RSS\n");
2927 : 0 : return;
2928 : : } else
2929 : 0 : printf("The reta size of port %d is %u\n",
2930 : 0 : res->port_id, dev_info.reta_size);
2931 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
2932 : 0 : fprintf(stderr,
2933 : : "Currently do not support more than %u entries of redirection table\n",
2934 : : RTE_ETH_RSS_RETA_SIZE_512);
2935 : 0 : return;
2936 : : }
2937 : :
2938 : : memset(reta_conf, 0, sizeof(reta_conf));
2939 : 0 : if (!strcmp(res->list_name, "reta")) {
2940 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
2941 : : dev_info.reta_size)) {
2942 : 0 : fprintf(stderr,
2943 : : "Invalid RSS Redirection Table config entered\n");
2944 : 0 : return;
2945 : : }
2946 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
2947 : 0 : reta_conf, dev_info.reta_size);
2948 : 0 : if (ret != 0)
2949 : 0 : fprintf(stderr,
2950 : : "Bad redirection table parameter, return code = %d\n",
2951 : : ret);
2952 : : }
2953 : : }
2954 : :
2955 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
2956 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2957 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2958 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2959 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2960 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2961 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
2962 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2963 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2964 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2965 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2966 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2967 : : NULL);
2968 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
2969 : : .f = cmd_set_rss_reta_parsed,
2970 : : .data = NULL,
2971 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2972 : : .tokens = {
2973 : : (void *)&cmd_config_rss_reta_port,
2974 : : (void *)&cmd_config_rss_reta_keyword,
2975 : : (void *)&cmd_config_rss_reta_port_id,
2976 : : (void *)&cmd_config_rss_reta_name,
2977 : : (void *)&cmd_config_rss_reta_list_name,
2978 : : (void *)&cmd_config_rss_reta_list_of_items,
2979 : : NULL,
2980 : : },
2981 : : };
2982 : :
2983 : : /* *** SHOW PORT RETA INFO *** */
2984 : : struct cmd_showport_reta {
2985 : : cmdline_fixed_string_t show;
2986 : : cmdline_fixed_string_t port;
2987 : : portid_t port_id;
2988 : : cmdline_fixed_string_t rss;
2989 : : cmdline_fixed_string_t reta;
2990 : : uint16_t size;
2991 : : cmdline_fixed_string_t list_of_items;
2992 : : };
2993 : :
2994 : : static int
2995 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
2996 : : uint16_t nb_entries,
2997 : : char *str)
2998 : : {
2999 : : uint32_t size;
3000 : : const char *p, *p0 = str;
3001 : : char s[256];
3002 : : char *end;
3003 : : char *str_fld[8];
3004 : : uint16_t i;
3005 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3006 : : RTE_ETH_RETA_GROUP_SIZE;
3007 : : int ret;
3008 : :
3009 : 0 : p = strchr(p0, '(');
3010 : 0 : if (p == NULL)
3011 : : return -1;
3012 : 0 : p++;
3013 : 0 : p0 = strchr(p, ')');
3014 : 0 : if (p0 == NULL)
3015 : : return -1;
3016 : 0 : size = p0 - p;
3017 : 0 : if (size >= sizeof(s)) {
3018 : 0 : fprintf(stderr,
3019 : : "The string size exceeds the internal buffer size\n");
3020 : 0 : return -1;
3021 : : }
3022 : : snprintf(s, sizeof(s), "%.*s", size, p);
3023 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3024 : 0 : if (ret <= 0 || ret != num) {
3025 : 0 : fprintf(stderr,
3026 : : "The bits of masks do not match the number of reta entries: %u\n",
3027 : : num);
3028 : 0 : return -1;
3029 : : }
3030 : 0 : for (i = 0; i < ret; i++)
3031 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3032 : :
3033 : : return 0;
3034 : : }
3035 : :
3036 : : static void
3037 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3038 : : __rte_unused struct cmdline *cl,
3039 : : __rte_unused void *data)
3040 : : {
3041 : : struct cmd_showport_reta *res = parsed_result;
3042 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3043 : : struct rte_eth_dev_info dev_info;
3044 : : uint16_t max_reta_size;
3045 : : int ret;
3046 : :
3047 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3048 : 0 : if (ret != 0)
3049 : 0 : return;
3050 : :
3051 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3052 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3053 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3054 : : res->size, max_reta_size);
3055 : 0 : return;
3056 : : }
3057 : :
3058 : : memset(reta_conf, 0, sizeof(reta_conf));
3059 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3060 : 0 : res->list_of_items) < 0) {
3061 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3062 : : res->list_of_items);
3063 : 0 : return;
3064 : : }
3065 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3066 : : }
3067 : :
3068 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3069 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3070 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3071 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3072 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3073 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3074 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3075 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3076 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3077 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3078 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3079 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3080 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3081 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3082 : : list_of_items, NULL);
3083 : :
3084 : : static cmdline_parse_inst_t cmd_showport_reta = {
3085 : : .f = cmd_showport_reta_parsed,
3086 : : .data = NULL,
3087 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3088 : : .tokens = {
3089 : : (void *)&cmd_showport_reta_show,
3090 : : (void *)&cmd_showport_reta_port,
3091 : : (void *)&cmd_showport_reta_port_id,
3092 : : (void *)&cmd_showport_reta_rss,
3093 : : (void *)&cmd_showport_reta_reta,
3094 : : (void *)&cmd_showport_reta_size,
3095 : : (void *)&cmd_showport_reta_list_of_items,
3096 : : NULL,
3097 : : },
3098 : : };
3099 : :
3100 : : /* *** Show RSS hash configuration *** */
3101 : : struct cmd_showport_rss_hash {
3102 : : cmdline_fixed_string_t show;
3103 : : cmdline_fixed_string_t port;
3104 : : portid_t port_id;
3105 : : cmdline_fixed_string_t rss_hash;
3106 : : cmdline_fixed_string_t rss_type;
3107 : : cmdline_fixed_string_t key; /* optional argument */
3108 : : cmdline_fixed_string_t algorithm; /* optional argument */
3109 : : };
3110 : :
3111 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3112 : : __rte_unused struct cmdline *cl,
3113 : : __rte_unused void *data)
3114 : : {
3115 : : struct cmd_showport_rss_hash *res = parsed_result;
3116 : :
3117 : 0 : port_rss_hash_conf_show(res->port_id,
3118 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3119 : 0 : }
3120 : :
3121 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3122 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3123 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3124 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3125 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3126 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3127 : : RTE_UINT16);
3128 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3129 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3130 : : "rss-hash");
3131 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3132 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3133 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3134 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3135 : :
3136 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3137 : : .f = cmd_showport_rss_hash_parsed,
3138 : : .data = NULL,
3139 : : .help_str = "show port <port_id> rss-hash",
3140 : : .tokens = {
3141 : : (void *)&cmd_showport_rss_hash_show,
3142 : : (void *)&cmd_showport_rss_hash_port,
3143 : : (void *)&cmd_showport_rss_hash_port_id,
3144 : : (void *)&cmd_showport_rss_hash_rss_hash,
3145 : : NULL,
3146 : : },
3147 : : };
3148 : :
3149 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3150 : : .f = cmd_showport_rss_hash_parsed,
3151 : : .data = NULL,
3152 : : .help_str = "show port <port_id> rss-hash key",
3153 : : .tokens = {
3154 : : (void *)&cmd_showport_rss_hash_show,
3155 : : (void *)&cmd_showport_rss_hash_port,
3156 : : (void *)&cmd_showport_rss_hash_port_id,
3157 : : (void *)&cmd_showport_rss_hash_rss_hash,
3158 : : (void *)&cmd_showport_rss_hash_rss_key,
3159 : : NULL,
3160 : : },
3161 : : };
3162 : :
3163 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3164 : : .f = cmd_showport_rss_hash_parsed,
3165 : : .data = NULL,
3166 : : .help_str = "show port <port_id> rss-hash algorithm",
3167 : : .tokens = {
3168 : : (void *)&cmd_showport_rss_hash_show,
3169 : : (void *)&cmd_showport_rss_hash_port,
3170 : : (void *)&cmd_showport_rss_hash_port_id,
3171 : : (void *)&cmd_showport_rss_hash_rss_hash,
3172 : : (void *)&cmd_showport_rss_hash_rss_algo,
3173 : : NULL,
3174 : : },
3175 : : };
3176 : :
3177 : : /* *** Configure DCB *** */
3178 : : struct cmd_config_dcb {
3179 : : cmdline_fixed_string_t port;
3180 : : cmdline_fixed_string_t config;
3181 : : portid_t port_id;
3182 : : cmdline_fixed_string_t dcb;
3183 : : cmdline_fixed_string_t vt;
3184 : : cmdline_fixed_string_t vt_en;
3185 : : uint8_t num_tcs;
3186 : : cmdline_fixed_string_t pfc;
3187 : : cmdline_fixed_string_t pfc_en;
3188 : : };
3189 : :
3190 : : static void
3191 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3192 : : __rte_unused struct cmdline *cl,
3193 : : __rte_unused void *data)
3194 : : {
3195 : : struct cmd_config_dcb *res = parsed_result;
3196 : : struct rte_eth_dcb_info dcb_info;
3197 : 0 : portid_t port_id = res->port_id;
3198 : : struct rte_port *port;
3199 : : uint8_t pfc_en;
3200 : : int ret;
3201 : :
3202 : 0 : port = &ports[port_id];
3203 : : /** Check if the port is not started **/
3204 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3205 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3206 : 0 : return;
3207 : : }
3208 : :
3209 : 0 : if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3210 : 0 : fprintf(stderr,
3211 : : "The invalid number of traffic class, only 4 or 8 allowed.\n");
3212 : 0 : return;
3213 : : }
3214 : :
3215 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3216 : 0 : fprintf(stderr,
3217 : : "nb_cores shouldn't be less than number of TCs.\n");
3218 : 0 : return;
3219 : : }
3220 : :
3221 : : /* Check whether the port supports the report of DCB info. */
3222 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3223 : 0 : if (ret == -ENOTSUP) {
3224 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3225 : 0 : return;
3226 : : }
3227 : :
3228 : 0 : if (!strncmp(res->pfc_en, "on", 2))
3229 : : pfc_en = 1;
3230 : : else
3231 : : pfc_en = 0;
3232 : :
3233 : : /* DCB in VT mode */
3234 : 0 : if (!strncmp(res->vt_en, "on", 2))
3235 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3236 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3237 : : pfc_en);
3238 : : else
3239 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3240 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3241 : : pfc_en);
3242 : 0 : if (ret != 0) {
3243 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3244 : 0 : return;
3245 : : }
3246 : :
3247 : 0 : fwd_config_setup();
3248 : :
3249 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3250 : : }
3251 : :
3252 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3253 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3254 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3255 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3256 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3257 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3258 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3259 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3260 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3261 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3262 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3263 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3264 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3265 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3266 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3267 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3268 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3269 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3270 : :
3271 : : static cmdline_parse_inst_t cmd_config_dcb = {
3272 : : .f = cmd_config_dcb_parsed,
3273 : : .data = NULL,
3274 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3275 : : .tokens = {
3276 : : (void *)&cmd_config_dcb_port,
3277 : : (void *)&cmd_config_dcb_config,
3278 : : (void *)&cmd_config_dcb_port_id,
3279 : : (void *)&cmd_config_dcb_dcb,
3280 : : (void *)&cmd_config_dcb_vt,
3281 : : (void *)&cmd_config_dcb_vt_en,
3282 : : (void *)&cmd_config_dcb_num_tcs,
3283 : : (void *)&cmd_config_dcb_pfc,
3284 : : (void *)&cmd_config_dcb_pfc_en,
3285 : : NULL,
3286 : : },
3287 : : };
3288 : :
3289 : : /* *** configure number of packets per burst *** */
3290 : : struct cmd_config_burst {
3291 : : cmdline_fixed_string_t port;
3292 : : cmdline_fixed_string_t keyword;
3293 : : cmdline_fixed_string_t all;
3294 : : cmdline_fixed_string_t name;
3295 : : uint16_t value;
3296 : : };
3297 : :
3298 : : static void
3299 : 0 : cmd_config_burst_parsed(void *parsed_result,
3300 : : __rte_unused struct cmdline *cl,
3301 : : __rte_unused void *data)
3302 : : {
3303 : : struct cmd_config_burst *res = parsed_result;
3304 : : struct rte_eth_dev_info dev_info;
3305 : : uint16_t rec_nb_pkts;
3306 : : int ret;
3307 : :
3308 : 0 : if (!all_ports_stopped()) {
3309 : 0 : fprintf(stderr, "Please stop all ports first\n");
3310 : 0 : return;
3311 : : }
3312 : :
3313 : 0 : if (!strcmp(res->name, "burst")) {
3314 : 0 : if (res->value == 0) {
3315 : : /* If user gives a value of zero, query the PMD for
3316 : : * its recommended Rx burst size. Testpmd uses a single
3317 : : * size for all ports, so assume all ports are the same
3318 : : * NIC model and use the values from Port 0.
3319 : : */
3320 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3321 : 0 : if (ret != 0)
3322 : : return;
3323 : :
3324 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3325 : :
3326 : 0 : if (rec_nb_pkts == 0) {
3327 : : printf("PMD does not recommend a burst size.\n"
3328 : : "User provided value must be between"
3329 : : " 1 and %d\n", MAX_PKT_BURST);
3330 : 0 : return;
3331 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3332 : 0 : printf("PMD recommended burst size of %d"
3333 : : " exceeds maximum value of %d\n",
3334 : : rec_nb_pkts, MAX_PKT_BURST);
3335 : 0 : return;
3336 : : }
3337 : 0 : printf("Using PMD-provided burst value of %d\n",
3338 : : rec_nb_pkts);
3339 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3340 : 0 : } else if (res->value > MAX_PKT_BURST) {
3341 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3342 : : MAX_PKT_BURST);
3343 : 0 : return;
3344 : : } else
3345 : 0 : nb_pkt_per_burst = res->value;
3346 : : } else {
3347 : 0 : fprintf(stderr, "Unknown parameter\n");
3348 : 0 : return;
3349 : : }
3350 : :
3351 : 0 : init_port_config();
3352 : :
3353 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3354 : : }
3355 : :
3356 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3357 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3358 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3359 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3360 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3361 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3362 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3363 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3364 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3365 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3366 : :
3367 : : static cmdline_parse_inst_t cmd_config_burst = {
3368 : : .f = cmd_config_burst_parsed,
3369 : : .data = NULL,
3370 : : .help_str = "port config all burst <value>",
3371 : : .tokens = {
3372 : : (void *)&cmd_config_burst_port,
3373 : : (void *)&cmd_config_burst_keyword,
3374 : : (void *)&cmd_config_burst_all,
3375 : : (void *)&cmd_config_burst_name,
3376 : : (void *)&cmd_config_burst_value,
3377 : : NULL,
3378 : : },
3379 : : };
3380 : :
3381 : : /* *** configure rx/tx queues *** */
3382 : : struct cmd_config_thresh {
3383 : : cmdline_fixed_string_t port;
3384 : : cmdline_fixed_string_t keyword;
3385 : : cmdline_fixed_string_t all;
3386 : : cmdline_fixed_string_t name;
3387 : : uint8_t value;
3388 : : };
3389 : :
3390 : : static void
3391 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3392 : : __rte_unused struct cmdline *cl,
3393 : : __rte_unused void *data)
3394 : : {
3395 : : struct cmd_config_thresh *res = parsed_result;
3396 : :
3397 : 0 : if (!all_ports_stopped()) {
3398 : 0 : fprintf(stderr, "Please stop all ports first\n");
3399 : 0 : return;
3400 : : }
3401 : :
3402 : 0 : if (!strcmp(res->name, "txpt"))
3403 : 0 : tx_pthresh = res->value;
3404 : 0 : else if(!strcmp(res->name, "txht"))
3405 : 0 : tx_hthresh = res->value;
3406 : 0 : else if(!strcmp(res->name, "txwt"))
3407 : 0 : tx_wthresh = res->value;
3408 : 0 : else if(!strcmp(res->name, "rxpt"))
3409 : 0 : rx_pthresh = res->value;
3410 : 0 : else if(!strcmp(res->name, "rxht"))
3411 : 0 : rx_hthresh = res->value;
3412 : 0 : else if(!strcmp(res->name, "rxwt"))
3413 : 0 : rx_wthresh = res->value;
3414 : : else {
3415 : 0 : fprintf(stderr, "Unknown parameter\n");
3416 : 0 : return;
3417 : : }
3418 : :
3419 : 0 : init_port_config();
3420 : :
3421 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3422 : : }
3423 : :
3424 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3425 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3426 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3427 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3428 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3429 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3430 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3431 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3432 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3433 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3434 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3435 : :
3436 : : static cmdline_parse_inst_t cmd_config_thresh = {
3437 : : .f = cmd_config_thresh_parsed,
3438 : : .data = NULL,
3439 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3440 : : .tokens = {
3441 : : (void *)&cmd_config_thresh_port,
3442 : : (void *)&cmd_config_thresh_keyword,
3443 : : (void *)&cmd_config_thresh_all,
3444 : : (void *)&cmd_config_thresh_name,
3445 : : (void *)&cmd_config_thresh_value,
3446 : : NULL,
3447 : : },
3448 : : };
3449 : :
3450 : : /* *** configure free/rs threshold *** */
3451 : : struct cmd_config_threshold {
3452 : : cmdline_fixed_string_t port;
3453 : : cmdline_fixed_string_t keyword;
3454 : : cmdline_fixed_string_t all;
3455 : : cmdline_fixed_string_t name;
3456 : : uint16_t value;
3457 : : };
3458 : :
3459 : : static void
3460 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3461 : : __rte_unused struct cmdline *cl,
3462 : : __rte_unused void *data)
3463 : : {
3464 : : struct cmd_config_threshold *res = parsed_result;
3465 : :
3466 : 0 : if (!all_ports_stopped()) {
3467 : 0 : fprintf(stderr, "Please stop all ports first\n");
3468 : 0 : return;
3469 : : }
3470 : :
3471 : 0 : if (!strcmp(res->name, "txfreet"))
3472 : 0 : tx_free_thresh = res->value;
3473 : 0 : else if (!strcmp(res->name, "txrst"))
3474 : 0 : tx_rs_thresh = res->value;
3475 : 0 : else if (!strcmp(res->name, "rxfreet"))
3476 : 0 : rx_free_thresh = res->value;
3477 : : else {
3478 : 0 : fprintf(stderr, "Unknown parameter\n");
3479 : 0 : return;
3480 : : }
3481 : :
3482 : 0 : init_port_config();
3483 : :
3484 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3485 : : }
3486 : :
3487 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3488 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3489 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3490 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3491 : : "config");
3492 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3493 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3494 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3495 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3496 : : "txfreet#txrst#rxfreet");
3497 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3498 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3499 : :
3500 : : static cmdline_parse_inst_t cmd_config_threshold = {
3501 : : .f = cmd_config_threshold_parsed,
3502 : : .data = NULL,
3503 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3504 : : .tokens = {
3505 : : (void *)&cmd_config_threshold_port,
3506 : : (void *)&cmd_config_threshold_keyword,
3507 : : (void *)&cmd_config_threshold_all,
3508 : : (void *)&cmd_config_threshold_name,
3509 : : (void *)&cmd_config_threshold_value,
3510 : : NULL,
3511 : : },
3512 : : };
3513 : :
3514 : : /* *** stop *** */
3515 : : struct cmd_stop_result {
3516 : : cmdline_fixed_string_t stop;
3517 : : };
3518 : :
3519 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3520 : : __rte_unused struct cmdline *cl,
3521 : : __rte_unused void *data)
3522 : : {
3523 : 0 : stop_packet_forwarding();
3524 : 0 : }
3525 : :
3526 : : static cmdline_parse_token_string_t cmd_stop_stop =
3527 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3528 : :
3529 : : static cmdline_parse_inst_t cmd_stop = {
3530 : : .f = cmd_stop_parsed,
3531 : : .data = NULL,
3532 : : .help_str = "stop: Stop packet forwarding",
3533 : : .tokens = {
3534 : : (void *)&cmd_stop_stop,
3535 : : NULL,
3536 : : },
3537 : : };
3538 : :
3539 : : static unsigned int
3540 : 0 : get_ptype(char *value)
3541 : : {
3542 : : uint32_t protocol;
3543 : :
3544 : 0 : if (!strcmp(value, "eth"))
3545 : : protocol = RTE_PTYPE_L2_ETHER;
3546 : 0 : else if (!strcmp(value, "ipv4"))
3547 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3548 : 0 : else if (!strcmp(value, "ipv6"))
3549 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3550 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3551 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3552 : 0 : else if (!strcmp(value, "ipv4-udp"))
3553 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3554 : 0 : else if (!strcmp(value, "ipv4-sctp"))
3555 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3556 : 0 : else if (!strcmp(value, "ipv6-tcp"))
3557 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3558 : 0 : else if (!strcmp(value, "ipv6-udp"))
3559 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3560 : 0 : else if (!strcmp(value, "ipv6-sctp"))
3561 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3562 : 0 : else if (!strcmp(value, "grenat"))
3563 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
3564 : 0 : else if (!strcmp(value, "inner-eth"))
3565 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
3566 : 0 : else if (!strcmp(value, "inner-ipv4"))
3567 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3568 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
3569 : 0 : else if (!strcmp(value, "inner-ipv6"))
3570 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3571 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
3572 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
3573 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3574 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3575 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
3576 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3577 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
3578 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
3579 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3580 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
3581 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
3582 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3583 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3584 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
3585 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3586 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
3587 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
3588 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3589 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
3590 : : else {
3591 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
3592 : : protocol = RTE_PTYPE_UNKNOWN;
3593 : : }
3594 : :
3595 : 0 : return protocol;
3596 : : }
3597 : :
3598 : : /* *** SET RXHDRSLIST *** */
3599 : :
3600 : : unsigned int
3601 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
3602 : : unsigned int *parsed_items)
3603 : : {
3604 : : unsigned int nb_item;
3605 : : char *cur;
3606 : : char *tmp;
3607 : :
3608 : : nb_item = 0;
3609 : 0 : char *str2 = strdup(str);
3610 : 0 : if (str2 == NULL)
3611 : : return nb_item;
3612 : 0 : cur = strtok_r(str2, ",", &tmp);
3613 : 0 : while (cur != NULL) {
3614 : 0 : parsed_items[nb_item] = get_ptype(cur);
3615 : 0 : cur = strtok_r(NULL, ",", &tmp);
3616 : 0 : nb_item++;
3617 : : }
3618 : 0 : if (nb_item > max_items)
3619 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3620 : : item_name, nb_item + 1, max_items);
3621 : 0 : free(str2);
3622 : 0 : return nb_item;
3623 : : }
3624 : :
3625 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3626 : :
3627 : : unsigned int
3628 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3629 : : unsigned int *parsed_items, int check_unique_values)
3630 : : {
3631 : : unsigned int nb_item;
3632 : : unsigned int value;
3633 : : unsigned int i;
3634 : : unsigned int j;
3635 : : int value_ok;
3636 : : char c;
3637 : :
3638 : : /*
3639 : : * First parse all items in the list and store their value.
3640 : : */
3641 : : value = 0;
3642 : : nb_item = 0;
3643 : : value_ok = 0;
3644 : 0 : for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3645 : 0 : c = str[i];
3646 : 0 : if ((c >= '0') && (c <= '9')) {
3647 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
3648 : : value_ok = 1;
3649 : 0 : continue;
3650 : : }
3651 : 0 : if (c != ',') {
3652 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
3653 : 0 : return 0;
3654 : : }
3655 : 0 : if (! value_ok) {
3656 : 0 : fprintf(stderr, "No valid value before comma\n");
3657 : 0 : return 0;
3658 : : }
3659 : 0 : if (nb_item < max_items) {
3660 : 0 : parsed_items[nb_item] = value;
3661 : : value_ok = 0;
3662 : : value = 0;
3663 : : }
3664 : 0 : nb_item++;
3665 : : }
3666 : 0 : if (nb_item >= max_items) {
3667 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3668 : : item_name, nb_item + 1, max_items);
3669 : 0 : return 0;
3670 : : }
3671 : 0 : parsed_items[nb_item++] = value;
3672 : 0 : if (! check_unique_values)
3673 : : return nb_item;
3674 : :
3675 : : /*
3676 : : * Then, check that all values in the list are different.
3677 : : * No optimization here...
3678 : : */
3679 : 0 : for (i = 0; i < nb_item; i++) {
3680 : 0 : for (j = i + 1; j < nb_item; j++) {
3681 : 0 : if (parsed_items[j] == parsed_items[i]) {
3682 : 0 : fprintf(stderr,
3683 : : "duplicated %s %u at index %u and %u\n",
3684 : : item_name, parsed_items[i], i, j);
3685 : 0 : return 0;
3686 : : }
3687 : : }
3688 : : }
3689 : : return nb_item;
3690 : : }
3691 : :
3692 : : struct cmd_set_list_result {
3693 : : cmdline_fixed_string_t cmd_keyword;
3694 : : cmdline_fixed_string_t list_name;
3695 : : cmdline_fixed_string_t list_of_items;
3696 : : };
3697 : :
3698 : 0 : static void cmd_set_list_parsed(void *parsed_result,
3699 : : __rte_unused struct cmdline *cl,
3700 : : __rte_unused void *data)
3701 : : {
3702 : : struct cmd_set_list_result *res;
3703 : : union {
3704 : : unsigned int lcorelist[RTE_MAX_LCORE];
3705 : : unsigned int portlist[RTE_MAX_ETHPORTS];
3706 : : } parsed_items;
3707 : : unsigned int nb_item;
3708 : :
3709 : 0 : if (test_done == 0) {
3710 : 0 : fprintf(stderr, "Please stop forwarding first\n");
3711 : 0 : return;
3712 : : }
3713 : :
3714 : : res = parsed_result;
3715 : 0 : if (!strcmp(res->list_name, "corelist")) {
3716 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
3717 : : RTE_MAX_LCORE,
3718 : : parsed_items.lcorelist, 1);
3719 : 0 : if (nb_item > 0) {
3720 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3721 : 0 : fwd_config_setup();
3722 : : }
3723 : 0 : return;
3724 : : }
3725 : 0 : if (!strcmp(res->list_name, "portlist")) {
3726 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
3727 : : RTE_MAX_ETHPORTS,
3728 : : parsed_items.portlist, 1);
3729 : 0 : if (nb_item > 0) {
3730 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
3731 : 0 : fwd_config_setup();
3732 : : }
3733 : : }
3734 : : }
3735 : :
3736 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
3737 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3738 : : "set");
3739 : : static cmdline_parse_token_string_t cmd_set_list_name =
3740 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3741 : : "corelist#portlist");
3742 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
3743 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3744 : : NULL);
3745 : :
3746 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
3747 : : .f = cmd_set_list_parsed,
3748 : : .data = NULL,
3749 : : .help_str = "set corelist|portlist <list0[,list1]*>",
3750 : : .tokens = {
3751 : : (void *)&cmd_set_list_keyword,
3752 : : (void *)&cmd_set_list_name,
3753 : : (void *)&cmd_set_list_of_items,
3754 : : NULL,
3755 : : },
3756 : : };
3757 : :
3758 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3759 : :
3760 : : struct cmd_setmask_result {
3761 : : cmdline_fixed_string_t set;
3762 : : cmdline_fixed_string_t mask;
3763 : : uint64_t hexavalue;
3764 : : };
3765 : :
3766 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
3767 : : __rte_unused struct cmdline *cl,
3768 : : __rte_unused void *data)
3769 : : {
3770 : : struct cmd_setmask_result *res = parsed_result;
3771 : :
3772 : 0 : if (test_done == 0) {
3773 : 0 : fprintf(stderr, "Please stop forwarding first\n");
3774 : 0 : return;
3775 : : }
3776 : 0 : if (!strcmp(res->mask, "coremask")) {
3777 : 0 : set_fwd_lcores_mask(res->hexavalue);
3778 : 0 : fwd_config_setup();
3779 : 0 : } else if (!strcmp(res->mask, "portmask")) {
3780 : 0 : set_fwd_ports_mask(res->hexavalue);
3781 : 0 : fwd_config_setup();
3782 : : }
3783 : : }
3784 : :
3785 : : static cmdline_parse_token_string_t cmd_setmask_set =
3786 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3787 : : static cmdline_parse_token_string_t cmd_setmask_mask =
3788 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3789 : : "coremask#portmask");
3790 : : static cmdline_parse_token_num_t cmd_setmask_value =
3791 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3792 : :
3793 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
3794 : : .f = cmd_set_mask_parsed,
3795 : : .data = NULL,
3796 : : .help_str = "set coremask|portmask <hexadecimal value>",
3797 : : .tokens = {
3798 : : (void *)&cmd_setmask_set,
3799 : : (void *)&cmd_setmask_mask,
3800 : : (void *)&cmd_setmask_value,
3801 : : NULL,
3802 : : },
3803 : : };
3804 : :
3805 : : /*
3806 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3807 : : */
3808 : : struct cmd_set_result {
3809 : : cmdline_fixed_string_t set;
3810 : : cmdline_fixed_string_t what;
3811 : : uint16_t value;
3812 : : };
3813 : :
3814 : 0 : static void cmd_set_parsed(void *parsed_result,
3815 : : __rte_unused struct cmdline *cl,
3816 : : __rte_unused void *data)
3817 : : {
3818 : : struct cmd_set_result *res = parsed_result;
3819 : 0 : if (!strcmp(res->what, "nbport")) {
3820 : 0 : set_fwd_ports_number(res->value);
3821 : 0 : fwd_config_setup();
3822 : 0 : } else if (!strcmp(res->what, "nbcore")) {
3823 : 0 : set_fwd_lcores_number(res->value);
3824 : 0 : fwd_config_setup();
3825 : 0 : } else if (!strcmp(res->what, "burst"))
3826 : 0 : set_nb_pkt_per_burst(res->value);
3827 : 0 : else if (!strcmp(res->what, "verbose"))
3828 : 0 : set_verbose_level(res->value);
3829 : 0 : }
3830 : :
3831 : : static cmdline_parse_token_string_t cmd_set_set =
3832 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3833 : : static cmdline_parse_token_string_t cmd_set_what =
3834 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3835 : : "nbport#nbcore#burst#verbose");
3836 : : static cmdline_parse_token_num_t cmd_set_value =
3837 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3838 : :
3839 : : static cmdline_parse_inst_t cmd_set_numbers = {
3840 : : .f = cmd_set_parsed,
3841 : : .data = NULL,
3842 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
3843 : : .tokens = {
3844 : : (void *)&cmd_set_set,
3845 : : (void *)&cmd_set_what,
3846 : : (void *)&cmd_set_value,
3847 : : NULL,
3848 : : },
3849 : : };
3850 : :
3851 : : /* *** SET LOG LEVEL CONFIGURATION *** */
3852 : :
3853 : : struct cmd_set_log_result {
3854 : : cmdline_fixed_string_t set;
3855 : : cmdline_fixed_string_t log;
3856 : : cmdline_fixed_string_t type;
3857 : : uint32_t level;
3858 : : };
3859 : :
3860 : : static void
3861 : 0 : cmd_set_log_parsed(void *parsed_result,
3862 : : __rte_unused struct cmdline *cl,
3863 : : __rte_unused void *data)
3864 : : {
3865 : : struct cmd_set_log_result *res;
3866 : : int ret;
3867 : :
3868 : : res = parsed_result;
3869 : 0 : if (!strcmp(res->type, "global"))
3870 : 0 : rte_log_set_global_level(res->level);
3871 : : else {
3872 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
3873 : 0 : if (ret < 0)
3874 : 0 : fprintf(stderr, "Unable to set log level\n");
3875 : : }
3876 : 0 : }
3877 : :
3878 : : static cmdline_parse_token_string_t cmd_set_log_set =
3879 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3880 : : static cmdline_parse_token_string_t cmd_set_log_log =
3881 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3882 : : static cmdline_parse_token_string_t cmd_set_log_type =
3883 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3884 : : static cmdline_parse_token_num_t cmd_set_log_level =
3885 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3886 : :
3887 : : static cmdline_parse_inst_t cmd_set_log = {
3888 : : .f = cmd_set_log_parsed,
3889 : : .data = NULL,
3890 : : .help_str = "set log global|<type> <level>",
3891 : : .tokens = {
3892 : : (void *)&cmd_set_log_set,
3893 : : (void *)&cmd_set_log_log,
3894 : : (void *)&cmd_set_log_type,
3895 : : (void *)&cmd_set_log_level,
3896 : : NULL,
3897 : : },
3898 : : };
3899 : :
3900 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3901 : :
3902 : : struct cmd_set_rxoffs_result {
3903 : : cmdline_fixed_string_t cmd_keyword;
3904 : : cmdline_fixed_string_t rxoffs;
3905 : : cmdline_fixed_string_t seg_offsets;
3906 : : };
3907 : :
3908 : : static void
3909 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
3910 : : __rte_unused struct cmdline *cl,
3911 : : __rte_unused void *data)
3912 : : {
3913 : : struct cmd_set_rxoffs_result *res;
3914 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3915 : : unsigned int nb_segs;
3916 : :
3917 : : res = parsed_result;
3918 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3919 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3920 : 0 : if (nb_segs > 0)
3921 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
3922 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3923 : 0 : }
3924 : :
3925 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3926 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3927 : : cmd_keyword, "set");
3928 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
3929 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3930 : : rxoffs, "rxoffs");
3931 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3932 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3933 : : seg_offsets, NULL);
3934 : :
3935 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
3936 : : .f = cmd_set_rxoffs_parsed,
3937 : : .data = NULL,
3938 : : .help_str = "set rxoffs <len0[,len1]*>",
3939 : : .tokens = {
3940 : : (void *)&cmd_set_rxoffs_keyword,
3941 : : (void *)&cmd_set_rxoffs_name,
3942 : : (void *)&cmd_set_rxoffs_offsets,
3943 : : NULL,
3944 : : },
3945 : : };
3946 : :
3947 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3948 : :
3949 : : struct cmd_set_rxpkts_result {
3950 : : cmdline_fixed_string_t cmd_keyword;
3951 : : cmdline_fixed_string_t rxpkts;
3952 : : cmdline_fixed_string_t seg_lengths;
3953 : : };
3954 : :
3955 : : static void
3956 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
3957 : : __rte_unused struct cmdline *cl,
3958 : : __rte_unused void *data)
3959 : : {
3960 : : struct cmd_set_rxpkts_result *res;
3961 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3962 : : unsigned int nb_segs;
3963 : :
3964 : : res = parsed_result;
3965 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3966 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3967 : 0 : if (nb_segs > 0)
3968 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
3969 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3970 : 0 : }
3971 : :
3972 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3973 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3974 : : cmd_keyword, "set");
3975 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
3976 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3977 : : rxpkts, "rxpkts");
3978 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3979 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3980 : : seg_lengths, NULL);
3981 : :
3982 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
3983 : : .f = cmd_set_rxpkts_parsed,
3984 : : .data = NULL,
3985 : : .help_str = "set rxpkts <len0[,len1]*>",
3986 : : .tokens = {
3987 : : (void *)&cmd_set_rxpkts_keyword,
3988 : : (void *)&cmd_set_rxpkts_name,
3989 : : (void *)&cmd_set_rxpkts_lengths,
3990 : : NULL,
3991 : : },
3992 : : };
3993 : :
3994 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
3995 : : struct cmd_set_rxhdrs_result {
3996 : : cmdline_fixed_string_t set;
3997 : : cmdline_fixed_string_t rxhdrs;
3998 : : cmdline_fixed_string_t values;
3999 : : };
4000 : :
4001 : : static void
4002 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4003 : : __rte_unused struct cmdline *cl,
4004 : : __rte_unused void *data)
4005 : : {
4006 : : struct cmd_set_rxhdrs_result *res;
4007 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4008 : : unsigned int nb_segs;
4009 : :
4010 : : res = parsed_result;
4011 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4012 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4013 : 0 : if (nb_segs > 0)
4014 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4015 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4016 : 0 : }
4017 : :
4018 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4019 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4020 : : set, "set");
4021 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4022 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4023 : : rxhdrs, "rxhdrs");
4024 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4025 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4026 : : values, NULL);
4027 : :
4028 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4029 : : .f = cmd_set_rxhdrs_parsed,
4030 : : .data = NULL,
4031 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4032 : : .tokens = {
4033 : : (void *)&cmd_set_rxhdrs_set,
4034 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4035 : : (void *)&cmd_set_rxhdrs_values,
4036 : : NULL,
4037 : : },
4038 : : };
4039 : :
4040 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4041 : :
4042 : : struct cmd_set_txpkts_result {
4043 : : cmdline_fixed_string_t cmd_keyword;
4044 : : cmdline_fixed_string_t txpkts;
4045 : : cmdline_fixed_string_t seg_lengths;
4046 : : };
4047 : :
4048 : : static void
4049 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4050 : : __rte_unused struct cmdline *cl,
4051 : : __rte_unused void *data)
4052 : : {
4053 : : struct cmd_set_txpkts_result *res;
4054 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4055 : : unsigned int nb_segs;
4056 : :
4057 : : res = parsed_result;
4058 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4059 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4060 : 0 : if (nb_segs > 0)
4061 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4062 : 0 : }
4063 : :
4064 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4065 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4066 : : cmd_keyword, "set");
4067 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4068 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4069 : : txpkts, "txpkts");
4070 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4071 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4072 : : seg_lengths, NULL);
4073 : :
4074 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4075 : : .f = cmd_set_txpkts_parsed,
4076 : : .data = NULL,
4077 : : .help_str = "set txpkts <len0[,len1]*>",
4078 : : .tokens = {
4079 : : (void *)&cmd_set_txpkts_keyword,
4080 : : (void *)&cmd_set_txpkts_name,
4081 : : (void *)&cmd_set_txpkts_lengths,
4082 : : NULL,
4083 : : },
4084 : : };
4085 : :
4086 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4087 : :
4088 : : struct cmd_set_txsplit_result {
4089 : : cmdline_fixed_string_t cmd_keyword;
4090 : : cmdline_fixed_string_t txsplit;
4091 : : cmdline_fixed_string_t mode;
4092 : : };
4093 : :
4094 : : static void
4095 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4096 : : __rte_unused struct cmdline *cl,
4097 : : __rte_unused void *data)
4098 : : {
4099 : : struct cmd_set_txsplit_result *res;
4100 : :
4101 : : res = parsed_result;
4102 : 0 : set_tx_pkt_split(res->mode);
4103 : 0 : }
4104 : :
4105 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4106 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4107 : : cmd_keyword, "set");
4108 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4109 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4110 : : txsplit, "txsplit");
4111 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4112 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4113 : : mode, NULL);
4114 : :
4115 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4116 : : .f = cmd_set_txsplit_parsed,
4117 : : .data = NULL,
4118 : : .help_str = "set txsplit on|off|rand",
4119 : : .tokens = {
4120 : : (void *)&cmd_set_txsplit_keyword,
4121 : : (void *)&cmd_set_txsplit_name,
4122 : : (void *)&cmd_set_txsplit_mode,
4123 : : NULL,
4124 : : },
4125 : : };
4126 : :
4127 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4128 : :
4129 : : struct cmd_set_txtimes_result {
4130 : : cmdline_fixed_string_t cmd_keyword;
4131 : : cmdline_fixed_string_t txtimes;
4132 : : cmdline_fixed_string_t tx_times;
4133 : : };
4134 : :
4135 : : static void
4136 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4137 : : __rte_unused struct cmdline *cl,
4138 : : __rte_unused void *data)
4139 : : {
4140 : : struct cmd_set_txtimes_result *res;
4141 : 0 : unsigned int tx_times[2] = {0, 0};
4142 : : unsigned int n_times;
4143 : :
4144 : : res = parsed_result;
4145 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4146 : : 2, tx_times, 0);
4147 : 0 : if (n_times == 2)
4148 : 0 : set_tx_pkt_times(tx_times);
4149 : 0 : }
4150 : :
4151 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4152 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4153 : : cmd_keyword, "set");
4154 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4155 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4156 : : txtimes, "txtimes");
4157 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4158 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4159 : : tx_times, NULL);
4160 : :
4161 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4162 : : .f = cmd_set_txtimes_parsed,
4163 : : .data = NULL,
4164 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4165 : : .tokens = {
4166 : : (void *)&cmd_set_txtimes_keyword,
4167 : : (void *)&cmd_set_txtimes_name,
4168 : : (void *)&cmd_set_txtimes_value,
4169 : : NULL,
4170 : : },
4171 : : };
4172 : :
4173 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4174 : : struct cmd_rx_vlan_filter_all_result {
4175 : : cmdline_fixed_string_t rx_vlan;
4176 : : cmdline_fixed_string_t what;
4177 : : cmdline_fixed_string_t all;
4178 : : portid_t port_id;
4179 : : };
4180 : :
4181 : : static void
4182 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4183 : : __rte_unused struct cmdline *cl,
4184 : : __rte_unused void *data)
4185 : : {
4186 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4187 : :
4188 : 0 : if (!strcmp(res->what, "add"))
4189 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4190 : : else
4191 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4192 : 0 : }
4193 : :
4194 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4195 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4196 : : rx_vlan, "rx_vlan");
4197 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4198 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4199 : : what, "add#rm");
4200 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4201 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4202 : : all, "all");
4203 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4204 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4205 : : port_id, RTE_UINT16);
4206 : :
4207 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4208 : : .f = cmd_rx_vlan_filter_all_parsed,
4209 : : .data = NULL,
4210 : : .help_str = "rx_vlan add|rm all <port_id>: "
4211 : : "Add/Remove all identifiers to/from the set of VLAN "
4212 : : "identifiers filtered by a port",
4213 : : .tokens = {
4214 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4215 : : (void *)&cmd_rx_vlan_filter_all_what,
4216 : : (void *)&cmd_rx_vlan_filter_all_all,
4217 : : (void *)&cmd_rx_vlan_filter_all_portid,
4218 : : NULL,
4219 : : },
4220 : : };
4221 : :
4222 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4223 : : struct cmd_vlan_offload_result {
4224 : : cmdline_fixed_string_t vlan;
4225 : : cmdline_fixed_string_t set;
4226 : : cmdline_fixed_string_t vlan_type;
4227 : : cmdline_fixed_string_t what;
4228 : : cmdline_fixed_string_t on;
4229 : : cmdline_fixed_string_t port_id;
4230 : : };
4231 : :
4232 : : static void
4233 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4234 : : __rte_unused struct cmdline *cl,
4235 : : __rte_unused void *data)
4236 : : {
4237 : : int on;
4238 : : struct cmd_vlan_offload_result *res = parsed_result;
4239 : : char *str;
4240 : : int i, len = 0;
4241 : : portid_t port_id = 0;
4242 : : unsigned int tmp;
4243 : :
4244 : 0 : str = res->port_id;
4245 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4246 : : i = 0;
4247 : : /* Get port_id first */
4248 : 0 : while(i < len){
4249 : 0 : if(str[i] == ',')
4250 : : break;
4251 : :
4252 : 0 : i++;
4253 : : }
4254 : 0 : str[i]='\0';
4255 : 0 : tmp = strtoul(str, NULL, 0);
4256 : : /* If port_id greater that what portid_t can represent, return */
4257 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4258 : : return;
4259 : 0 : port_id = (portid_t)tmp;
4260 : :
4261 : 0 : if (!strcmp(res->on, "on"))
4262 : : on = 1;
4263 : : else
4264 : : on = 0;
4265 : :
4266 : 0 : if (!strcmp(res->what, "strip"))
4267 : 0 : rx_vlan_strip_set(port_id, on);
4268 : 0 : else if(!strcmp(res->what, "stripq")){
4269 : : uint16_t queue_id = 0;
4270 : :
4271 : : /* No queue_id, return */
4272 : 0 : if(i + 1 >= len) {
4273 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4274 : 0 : return;
4275 : : }
4276 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4277 : : /* If queue_id greater that what 16-bits can represent, return */
4278 : 0 : if(tmp > 0xffff)
4279 : : return;
4280 : :
4281 : 0 : queue_id = (uint16_t)tmp;
4282 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4283 : : }
4284 : 0 : else if (!strcmp(res->what, "filter"))
4285 : 0 : rx_vlan_filter_set(port_id, on);
4286 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4287 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4288 : : else
4289 : 0 : vlan_extend_set(port_id, on);
4290 : :
4291 : : return;
4292 : : }
4293 : :
4294 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4295 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4296 : : vlan, "vlan");
4297 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4298 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4299 : : set, "set");
4300 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4301 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4302 : : what, "strip#filter#qinq_strip#extend#stripq");
4303 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4304 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4305 : : on, "on#off");
4306 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4307 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4308 : : port_id, NULL);
4309 : :
4310 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4311 : : .f = cmd_vlan_offload_parsed,
4312 : : .data = NULL,
4313 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4314 : : "<port_id[,queue_id]>: "
4315 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4316 : : .tokens = {
4317 : : (void *)&cmd_vlan_offload_vlan,
4318 : : (void *)&cmd_vlan_offload_set,
4319 : : (void *)&cmd_vlan_offload_what,
4320 : : (void *)&cmd_vlan_offload_on,
4321 : : (void *)&cmd_vlan_offload_portid,
4322 : : NULL,
4323 : : },
4324 : : };
4325 : :
4326 : : /* *** VLAN TPID SET ON A PORT *** */
4327 : : struct cmd_vlan_tpid_result {
4328 : : cmdline_fixed_string_t vlan;
4329 : : cmdline_fixed_string_t set;
4330 : : cmdline_fixed_string_t vlan_type;
4331 : : cmdline_fixed_string_t what;
4332 : : uint16_t tp_id;
4333 : : portid_t port_id;
4334 : : };
4335 : :
4336 : : static void
4337 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4338 : : __rte_unused struct cmdline *cl,
4339 : : __rte_unused void *data)
4340 : : {
4341 : : struct cmd_vlan_tpid_result *res = parsed_result;
4342 : : enum rte_vlan_type vlan_type;
4343 : :
4344 : 0 : if (!strcmp(res->vlan_type, "inner"))
4345 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4346 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4347 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4348 : : else {
4349 : 0 : fprintf(stderr, "Unknown vlan type\n");
4350 : 0 : return;
4351 : : }
4352 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4353 : : }
4354 : :
4355 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4356 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4357 : : vlan, "vlan");
4358 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4359 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4360 : : set, "set");
4361 : : static cmdline_parse_token_string_t cmd_vlan_type =
4362 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4363 : : vlan_type, "inner#outer");
4364 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4365 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4366 : : what, "tpid");
4367 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4368 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4369 : : tp_id, RTE_UINT16);
4370 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4371 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4372 : : port_id, RTE_UINT16);
4373 : :
4374 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4375 : : .f = cmd_vlan_tpid_parsed,
4376 : : .data = NULL,
4377 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4378 : : "Set the VLAN Ether type",
4379 : : .tokens = {
4380 : : (void *)&cmd_vlan_tpid_vlan,
4381 : : (void *)&cmd_vlan_tpid_set,
4382 : : (void *)&cmd_vlan_type,
4383 : : (void *)&cmd_vlan_tpid_what,
4384 : : (void *)&cmd_vlan_tpid_tpid,
4385 : : (void *)&cmd_vlan_tpid_portid,
4386 : : NULL,
4387 : : },
4388 : : };
4389 : :
4390 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4391 : : struct cmd_rx_vlan_filter_result {
4392 : : cmdline_fixed_string_t rx_vlan;
4393 : : cmdline_fixed_string_t what;
4394 : : uint16_t vlan_id;
4395 : : portid_t port_id;
4396 : : };
4397 : :
4398 : : static void
4399 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4400 : : __rte_unused struct cmdline *cl,
4401 : : __rte_unused void *data)
4402 : : {
4403 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4404 : :
4405 : 0 : if (!strcmp(res->what, "add"))
4406 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4407 : : else
4408 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4409 : 0 : }
4410 : :
4411 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4412 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4413 : : rx_vlan, "rx_vlan");
4414 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4415 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4416 : : what, "add#rm");
4417 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4418 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4419 : : vlan_id, RTE_UINT16);
4420 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4421 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4422 : : port_id, RTE_UINT16);
4423 : :
4424 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4425 : : .f = cmd_rx_vlan_filter_parsed,
4426 : : .data = NULL,
4427 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4428 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4429 : : "identifiers filtered by a port",
4430 : : .tokens = {
4431 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4432 : : (void *)&cmd_rx_vlan_filter_what,
4433 : : (void *)&cmd_rx_vlan_filter_vlanid,
4434 : : (void *)&cmd_rx_vlan_filter_portid,
4435 : : NULL,
4436 : : },
4437 : : };
4438 : :
4439 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4440 : : struct cmd_tx_vlan_set_result {
4441 : : cmdline_fixed_string_t tx_vlan;
4442 : : cmdline_fixed_string_t set;
4443 : : portid_t port_id;
4444 : : uint16_t vlan_id;
4445 : : };
4446 : :
4447 : : static void
4448 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4449 : : __rte_unused struct cmdline *cl,
4450 : : __rte_unused void *data)
4451 : : {
4452 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4453 : :
4454 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4455 : : return;
4456 : :
4457 : 0 : if (!port_is_stopped(res->port_id)) {
4458 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4459 : 0 : return;
4460 : : }
4461 : :
4462 : 0 : tx_vlan_set(res->port_id, res->vlan_id);
4463 : :
4464 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4465 : : }
4466 : :
4467 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4468 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4469 : : tx_vlan, "tx_vlan");
4470 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4471 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4472 : : set, "set");
4473 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4474 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4475 : : port_id, RTE_UINT16);
4476 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4477 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4478 : : vlan_id, RTE_UINT16);
4479 : :
4480 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4481 : : .f = cmd_tx_vlan_set_parsed,
4482 : : .data = NULL,
4483 : : .help_str = "tx_vlan set <port_id> <vlan_id>: "
4484 : : "Enable hardware insertion of a single VLAN header "
4485 : : "with a given TAG Identifier in packets sent on a port",
4486 : : .tokens = {
4487 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4488 : : (void *)&cmd_tx_vlan_set_set,
4489 : : (void *)&cmd_tx_vlan_set_portid,
4490 : : (void *)&cmd_tx_vlan_set_vlanid,
4491 : : NULL,
4492 : : },
4493 : : };
4494 : :
4495 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4496 : : struct cmd_tx_vlan_set_qinq_result {
4497 : : cmdline_fixed_string_t tx_vlan;
4498 : : cmdline_fixed_string_t set;
4499 : : portid_t port_id;
4500 : : uint16_t vlan_id;
4501 : : uint16_t vlan_id_outer;
4502 : : };
4503 : :
4504 : : static void
4505 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4506 : : __rte_unused struct cmdline *cl,
4507 : : __rte_unused void *data)
4508 : : {
4509 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4510 : :
4511 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4512 : : return;
4513 : :
4514 : 0 : if (!port_is_stopped(res->port_id)) {
4515 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4516 : 0 : return;
4517 : : }
4518 : :
4519 : 0 : tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4520 : :
4521 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4522 : : }
4523 : :
4524 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4525 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4526 : : tx_vlan, "tx_vlan");
4527 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4528 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4529 : : set, "set");
4530 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4531 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4532 : : port_id, RTE_UINT16);
4533 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4534 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4535 : : vlan_id, RTE_UINT16);
4536 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4537 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4538 : : vlan_id_outer, RTE_UINT16);
4539 : :
4540 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4541 : : .f = cmd_tx_vlan_set_qinq_parsed,
4542 : : .data = NULL,
4543 : : .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4544 : : "Enable hardware insertion of double VLAN header "
4545 : : "with given TAG Identifiers in packets sent on a port",
4546 : : .tokens = {
4547 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4548 : : (void *)&cmd_tx_vlan_set_qinq_set,
4549 : : (void *)&cmd_tx_vlan_set_qinq_portid,
4550 : : (void *)&cmd_tx_vlan_set_qinq_vlanid,
4551 : : (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4552 : : NULL,
4553 : : },
4554 : : };
4555 : :
4556 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4557 : : struct cmd_tx_vlan_set_pvid_result {
4558 : : cmdline_fixed_string_t tx_vlan;
4559 : : cmdline_fixed_string_t set;
4560 : : cmdline_fixed_string_t pvid;
4561 : : portid_t port_id;
4562 : : uint16_t vlan_id;
4563 : : cmdline_fixed_string_t mode;
4564 : : };
4565 : :
4566 : : static void
4567 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4568 : : __rte_unused struct cmdline *cl,
4569 : : __rte_unused void *data)
4570 : : {
4571 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4572 : :
4573 : 0 : if (strcmp(res->mode, "on") == 0)
4574 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4575 : : else
4576 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4577 : 0 : }
4578 : :
4579 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4580 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4581 : : tx_vlan, "tx_vlan");
4582 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4583 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4584 : : set, "set");
4585 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4586 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4587 : : pvid, "pvid");
4588 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4589 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4590 : : port_id, RTE_UINT16);
4591 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4592 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4593 : : vlan_id, RTE_UINT16);
4594 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4595 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4596 : : mode, "on#off");
4597 : :
4598 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4599 : : .f = cmd_tx_vlan_set_pvid_parsed,
4600 : : .data = NULL,
4601 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4602 : : .tokens = {
4603 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4604 : : (void *)&cmd_tx_vlan_set_pvid_set,
4605 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
4606 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
4607 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4608 : : (void *)&cmd_tx_vlan_set_pvid_mode,
4609 : : NULL,
4610 : : },
4611 : : };
4612 : :
4613 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4614 : : struct cmd_tx_vlan_reset_result {
4615 : : cmdline_fixed_string_t tx_vlan;
4616 : : cmdline_fixed_string_t reset;
4617 : : portid_t port_id;
4618 : : };
4619 : :
4620 : : static void
4621 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
4622 : : __rte_unused struct cmdline *cl,
4623 : : __rte_unused void *data)
4624 : : {
4625 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
4626 : :
4627 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4628 : : return;
4629 : :
4630 : 0 : if (!port_is_stopped(res->port_id)) {
4631 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4632 : 0 : return;
4633 : : }
4634 : :
4635 : 0 : tx_vlan_reset(res->port_id);
4636 : :
4637 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4638 : : }
4639 : :
4640 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4641 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4642 : : tx_vlan, "tx_vlan");
4643 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4644 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4645 : : reset, "reset");
4646 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4647 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4648 : : port_id, RTE_UINT16);
4649 : :
4650 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
4651 : : .f = cmd_tx_vlan_reset_parsed,
4652 : : .data = NULL,
4653 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4654 : : "VLAN header in packets sent on a port",
4655 : : .tokens = {
4656 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
4657 : : (void *)&cmd_tx_vlan_reset_reset,
4658 : : (void *)&cmd_tx_vlan_reset_portid,
4659 : : NULL,
4660 : : },
4661 : : };
4662 : :
4663 : :
4664 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4665 : : struct cmd_csum_result {
4666 : : cmdline_fixed_string_t csum;
4667 : : cmdline_fixed_string_t mode;
4668 : : cmdline_fixed_string_t proto;
4669 : : cmdline_fixed_string_t hwsw;
4670 : : portid_t port_id;
4671 : : };
4672 : :
4673 : : static void
4674 : 0 : csum_show(int port_id)
4675 : : {
4676 : : struct rte_eth_dev_info dev_info;
4677 : : uint64_t tx_offloads;
4678 : : int ret;
4679 : :
4680 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4681 : 0 : printf("Parse tunnel is %s\n",
4682 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
4683 : 0 : printf("IP checksum offload is %s\n",
4684 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4685 : 0 : printf("UDP checksum offload is %s\n",
4686 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4687 : 0 : printf("TCP checksum offload is %s\n",
4688 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4689 : 0 : printf("SCTP checksum offload is %s\n",
4690 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4691 : 0 : printf("Outer-Ip checksum offload is %s\n",
4692 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4693 : 0 : printf("Outer-Udp checksum offload is %s\n",
4694 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4695 : :
4696 : : /* display warnings if configuration is not supported by the NIC */
4697 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
4698 : 0 : if (ret != 0)
4699 : 0 : return;
4700 : :
4701 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4702 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4703 : 0 : fprintf(stderr,
4704 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
4705 : : port_id);
4706 : : }
4707 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4708 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4709 : 0 : fprintf(stderr,
4710 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4711 : : port_id);
4712 : : }
4713 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4714 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4715 : 0 : fprintf(stderr,
4716 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4717 : : port_id);
4718 : : }
4719 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4720 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4721 : 0 : fprintf(stderr,
4722 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4723 : : port_id);
4724 : : }
4725 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4726 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4727 : 0 : fprintf(stderr,
4728 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4729 : : port_id);
4730 : : }
4731 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4732 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4733 : : == 0) {
4734 : 0 : fprintf(stderr,
4735 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4736 : : port_id);
4737 : : }
4738 : : }
4739 : :
4740 : : static void
4741 : : cmd_config_queue_tx_offloads(struct rte_port *port)
4742 : : {
4743 : : int k;
4744 : :
4745 : : /* Apply queue tx offloads configuration */
4746 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
4747 : 0 : port->txq[k].conf.offloads =
4748 : 0 : port->dev_conf.txmode.offloads;
4749 : : }
4750 : :
4751 : : static void
4752 : 0 : cmd_csum_parsed(void *parsed_result,
4753 : : __rte_unused struct cmdline *cl,
4754 : : __rte_unused void *data)
4755 : : {
4756 : : struct cmd_csum_result *res = parsed_result;
4757 : : int hw = 0;
4758 : : uint64_t csum_offloads = 0;
4759 : : struct rte_eth_dev_info dev_info;
4760 : : int ret;
4761 : :
4762 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4763 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
4764 : 0 : return;
4765 : : }
4766 : 0 : if (!port_is_stopped(res->port_id)) {
4767 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4768 : 0 : return;
4769 : : }
4770 : :
4771 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4772 : 0 : if (ret != 0)
4773 : : return;
4774 : :
4775 : 0 : if (!strcmp(res->mode, "set")) {
4776 : :
4777 : 0 : if (!strcmp(res->hwsw, "hw"))
4778 : : hw = 1;
4779 : :
4780 : 0 : if (!strcmp(res->proto, "ip")) {
4781 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4782 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4783 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4784 : : } else {
4785 : 0 : fprintf(stderr,
4786 : : "IP checksum offload is not supported by port %u\n",
4787 : 0 : res->port_id);
4788 : : }
4789 : 0 : } else if (!strcmp(res->proto, "udp")) {
4790 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4791 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4792 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4793 : : } else {
4794 : 0 : fprintf(stderr,
4795 : : "UDP checksum offload is not supported by port %u\n",
4796 : 0 : res->port_id);
4797 : : }
4798 : 0 : } else if (!strcmp(res->proto, "tcp")) {
4799 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4800 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4801 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4802 : : } else {
4803 : 0 : fprintf(stderr,
4804 : : "TCP checksum offload is not supported by port %u\n",
4805 : 0 : res->port_id);
4806 : : }
4807 : 0 : } else if (!strcmp(res->proto, "sctp")) {
4808 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4809 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4810 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4811 : : } else {
4812 : 0 : fprintf(stderr,
4813 : : "SCTP checksum offload is not supported by port %u\n",
4814 : 0 : res->port_id);
4815 : : }
4816 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
4817 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4818 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4819 : : csum_offloads |=
4820 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4821 : : } else {
4822 : 0 : fprintf(stderr,
4823 : : "Outer IP checksum offload is not supported by port %u\n",
4824 : 0 : res->port_id);
4825 : : }
4826 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
4827 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4828 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4829 : : csum_offloads |=
4830 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4831 : : } else {
4832 : 0 : fprintf(stderr,
4833 : : "Outer UDP checksum offload is not supported by port %u\n",
4834 : 0 : res->port_id);
4835 : : }
4836 : : }
4837 : :
4838 : 0 : if (hw) {
4839 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
4840 : : csum_offloads;
4841 : : } else {
4842 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
4843 : 0 : (~csum_offloads);
4844 : : }
4845 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
4846 : : }
4847 : 0 : csum_show(res->port_id);
4848 : :
4849 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4850 : : }
4851 : :
4852 : : static cmdline_parse_token_string_t cmd_csum_csum =
4853 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4854 : : csum, "csum");
4855 : : static cmdline_parse_token_string_t cmd_csum_mode =
4856 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4857 : : mode, "set");
4858 : : static cmdline_parse_token_string_t cmd_csum_proto =
4859 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4860 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4861 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
4862 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4863 : : hwsw, "hw#sw");
4864 : : static cmdline_parse_token_num_t cmd_csum_portid =
4865 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4866 : : port_id, RTE_UINT16);
4867 : :
4868 : : static cmdline_parse_inst_t cmd_csum_set = {
4869 : : .f = cmd_csum_parsed,
4870 : : .data = NULL,
4871 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4872 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
4873 : : "using csum forward engine",
4874 : : .tokens = {
4875 : : (void *)&cmd_csum_csum,
4876 : : (void *)&cmd_csum_mode,
4877 : : (void *)&cmd_csum_proto,
4878 : : (void *)&cmd_csum_hwsw,
4879 : : (void *)&cmd_csum_portid,
4880 : : NULL,
4881 : : },
4882 : : };
4883 : :
4884 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
4885 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4886 : : mode, "show");
4887 : :
4888 : : static cmdline_parse_inst_t cmd_csum_show = {
4889 : : .f = cmd_csum_parsed,
4890 : : .data = NULL,
4891 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
4892 : : .tokens = {
4893 : : (void *)&cmd_csum_csum,
4894 : : (void *)&cmd_csum_mode_show,
4895 : : (void *)&cmd_csum_portid,
4896 : : NULL,
4897 : : },
4898 : : };
4899 : :
4900 : : /* Enable/disable tunnel parsing */
4901 : : struct cmd_csum_tunnel_result {
4902 : : cmdline_fixed_string_t csum;
4903 : : cmdline_fixed_string_t parse;
4904 : : cmdline_fixed_string_t onoff;
4905 : : portid_t port_id;
4906 : : };
4907 : :
4908 : : static void
4909 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
4910 : : __rte_unused struct cmdline *cl,
4911 : : __rte_unused void *data)
4912 : : {
4913 : : struct cmd_csum_tunnel_result *res = parsed_result;
4914 : :
4915 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4916 : : return;
4917 : :
4918 : 0 : if (!strcmp(res->onoff, "on"))
4919 : 0 : ports[res->port_id].parse_tunnel = 1;
4920 : : else
4921 : 0 : ports[res->port_id].parse_tunnel = 0;
4922 : :
4923 : 0 : csum_show(res->port_id);
4924 : : }
4925 : :
4926 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4927 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4928 : : csum, "csum");
4929 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4930 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4931 : : parse, "parse-tunnel");
4932 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4933 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4934 : : onoff, "on#off");
4935 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4936 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4937 : : port_id, RTE_UINT16);
4938 : :
4939 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
4940 : : .f = cmd_csum_tunnel_parsed,
4941 : : .data = NULL,
4942 : : .help_str = "csum parse-tunnel on|off <port_id>: "
4943 : : "Enable/Disable parsing of tunnels for csum engine",
4944 : : .tokens = {
4945 : : (void *)&cmd_csum_tunnel_csum,
4946 : : (void *)&cmd_csum_tunnel_parse,
4947 : : (void *)&cmd_csum_tunnel_onoff,
4948 : : (void *)&cmd_csum_tunnel_portid,
4949 : : NULL,
4950 : : },
4951 : : };
4952 : :
4953 : : struct cmd_csum_mac_swap_result {
4954 : : cmdline_fixed_string_t csum;
4955 : : cmdline_fixed_string_t parse;
4956 : : cmdline_fixed_string_t onoff;
4957 : : portid_t port_id;
4958 : : };
4959 : :
4960 : : static void
4961 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
4962 : : __rte_unused struct cmdline *cl,
4963 : : __rte_unused void *data)
4964 : : {
4965 : : struct cmd_csum_mac_swap_result *res = parsed_result;
4966 : :
4967 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4968 : : return;
4969 : 0 : if (strcmp(res->onoff, "on") == 0)
4970 : 0 : ports[res->port_id].fwd_mac_swap = 1;
4971 : : else
4972 : 0 : ports[res->port_id].fwd_mac_swap = 0;
4973 : : }
4974 : :
4975 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
4976 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4977 : : csum, "csum");
4978 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
4979 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4980 : : parse, "mac-swap");
4981 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
4982 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4983 : : onoff, "on#off");
4984 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
4985 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
4986 : : port_id, RTE_UINT16);
4987 : :
4988 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
4989 : : .f = cmd_csum_mac_swap_parsed,
4990 : : .data = NULL,
4991 : : .help_str = "csum mac-swap on|off <port_id>: "
4992 : : "Enable/Disable forward mac address swap",
4993 : : .tokens = {
4994 : : (void *)&cmd_csum_mac_swap_csum,
4995 : : (void *)&cmd_csum_mac_swap_parse,
4996 : : (void *)&cmd_csum_mac_swap_onoff,
4997 : : (void *)&cmd_csum_mac_swap_portid,
4998 : : NULL,
4999 : : },
5000 : : };
5001 : :
5002 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5003 : : struct cmd_tso_set_result {
5004 : : cmdline_fixed_string_t tso;
5005 : : cmdline_fixed_string_t mode;
5006 : : uint16_t tso_segsz;
5007 : : portid_t port_id;
5008 : : };
5009 : :
5010 : : static void
5011 : 0 : cmd_tso_set_parsed(void *parsed_result,
5012 : : __rte_unused struct cmdline *cl,
5013 : : __rte_unused void *data)
5014 : : {
5015 : : struct cmd_tso_set_result *res = parsed_result;
5016 : : struct rte_eth_dev_info dev_info;
5017 : : uint64_t offloads;
5018 : : int ret;
5019 : :
5020 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5021 : 0 : return;
5022 : 0 : if (!port_is_stopped(res->port_id)) {
5023 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5024 : 0 : return;
5025 : : }
5026 : :
5027 : 0 : if (!strcmp(res->mode, "set"))
5028 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5029 : :
5030 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5031 : 0 : if (ret != 0)
5032 : : return;
5033 : :
5034 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5035 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5036 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5037 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5038 : : res->port_id);
5039 : 0 : return;
5040 : : }
5041 : : /* display warnings if configuration is not supported by the NIC */
5042 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5043 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5044 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5045 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5046 : : }
5047 : :
5048 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5049 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5050 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5051 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5052 : : } else {
5053 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5054 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5055 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5056 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5057 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5058 : 0 : printf("segment size for non-tunneled packets is %d\n",
5059 : : ports[res->port_id].tso_segsz);
5060 : : }
5061 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5062 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5063 : : }
5064 : :
5065 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5066 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5067 : : tso, "tso");
5068 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5069 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5070 : : mode, "set");
5071 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5072 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5073 : : tso_segsz, RTE_UINT16);
5074 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5075 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5076 : : port_id, RTE_UINT16);
5077 : :
5078 : : static cmdline_parse_inst_t cmd_tso_set = {
5079 : : .f = cmd_tso_set_parsed,
5080 : : .data = NULL,
5081 : : .help_str = "tso set <tso_segsz> <port_id>: "
5082 : : "Set TSO segment size of non-tunneled packets for csum engine "
5083 : : "(0 to disable)",
5084 : : .tokens = {
5085 : : (void *)&cmd_tso_set_tso,
5086 : : (void *)&cmd_tso_set_mode,
5087 : : (void *)&cmd_tso_set_tso_segsz,
5088 : : (void *)&cmd_tso_set_portid,
5089 : : NULL,
5090 : : },
5091 : : };
5092 : :
5093 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5094 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5095 : : mode, "show");
5096 : :
5097 : :
5098 : : static cmdline_parse_inst_t cmd_tso_show = {
5099 : : .f = cmd_tso_set_parsed,
5100 : : .data = NULL,
5101 : : .help_str = "tso show <port_id>: "
5102 : : "Show TSO segment size of non-tunneled packets for csum engine",
5103 : : .tokens = {
5104 : : (void *)&cmd_tso_set_tso,
5105 : : (void *)&cmd_tso_show_mode,
5106 : : (void *)&cmd_tso_set_portid,
5107 : : NULL,
5108 : : },
5109 : : };
5110 : :
5111 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5112 : : struct cmd_tunnel_tso_set_result {
5113 : : cmdline_fixed_string_t tso;
5114 : : cmdline_fixed_string_t mode;
5115 : : uint16_t tso_segsz;
5116 : : portid_t port_id;
5117 : : };
5118 : :
5119 : : static void
5120 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5121 : : {
5122 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5123 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5124 : : port_id);
5125 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5126 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5127 : : port_id);
5128 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5129 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5130 : : port_id);
5131 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5132 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5133 : : port_id);
5134 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5135 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5136 : : port_id);
5137 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5138 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5139 : : port_id);
5140 : 0 : }
5141 : :
5142 : : static void
5143 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5144 : : __rte_unused struct cmdline *cl,
5145 : : __rte_unused void *data)
5146 : : {
5147 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5148 : : struct rte_eth_dev_info dev_info;
5149 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5150 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5151 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5152 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5153 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5154 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5155 : : int ret;
5156 : :
5157 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5158 : 0 : return;
5159 : 0 : if (!port_is_stopped(res->port_id)) {
5160 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5161 : 0 : return;
5162 : : }
5163 : :
5164 : 0 : if (!strcmp(res->mode, "set"))
5165 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5166 : :
5167 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5168 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5169 : : printf("TSO for tunneled packets is disabled\n");
5170 : : } else {
5171 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5172 : 0 : if (ret != 0)
5173 : : return;
5174 : :
5175 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5176 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5177 : 0 : res->port_id);
5178 : 0 : return;
5179 : : }
5180 : :
5181 : : /* Below conditions are needed to make it work:
5182 : : * (1) tunnel TSO is supported by the NIC;
5183 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5184 : : * are recognized;
5185 : : * (3) for tunneled pkts with outer L3 of IPv4,
5186 : : * "csum set outer-ip" must be set to hw, because after tso,
5187 : : * total_len of outer IP header is changed, and the checksum
5188 : : * of outer IP header calculated by sw should be wrong; that
5189 : : * is not necessary for IPv6 tunneled pkts because there's no
5190 : : * checksum in IP header anymore.
5191 : : */
5192 : 0 : if (!ports[res->port_id].parse_tunnel) {
5193 : 0 : fprintf(stderr,
5194 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5195 : 0 : return;
5196 : : }
5197 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5198 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5199 : 0 : fprintf(stderr,
5200 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5201 : 0 : return;
5202 : : }
5203 : :
5204 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5205 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5206 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5207 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5208 : 0 : ports[res->port_id].tunnel_tso_segsz);
5209 : : }
5210 : :
5211 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5212 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5213 : : }
5214 : :
5215 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5216 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5217 : : tso, "tunnel_tso");
5218 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5219 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5220 : : mode, "set");
5221 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5222 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5223 : : tso_segsz, RTE_UINT16);
5224 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5225 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5226 : : port_id, RTE_UINT16);
5227 : :
5228 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5229 : : .f = cmd_tunnel_tso_set_parsed,
5230 : : .data = NULL,
5231 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5232 : : "Set TSO segment size of tunneled packets for csum engine "
5233 : : "(0 to disable)",
5234 : : .tokens = {
5235 : : (void *)&cmd_tunnel_tso_set_tso,
5236 : : (void *)&cmd_tunnel_tso_set_mode,
5237 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5238 : : (void *)&cmd_tunnel_tso_set_portid,
5239 : : NULL,
5240 : : },
5241 : : };
5242 : :
5243 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5244 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5245 : : mode, "show");
5246 : :
5247 : :
5248 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5249 : : .f = cmd_tunnel_tso_set_parsed,
5250 : : .data = NULL,
5251 : : .help_str = "tunnel_tso show <port_id> "
5252 : : "Show TSO segment size of tunneled packets for csum engine",
5253 : : .tokens = {
5254 : : (void *)&cmd_tunnel_tso_set_tso,
5255 : : (void *)&cmd_tunnel_tso_show_mode,
5256 : : (void *)&cmd_tunnel_tso_set_portid,
5257 : : NULL,
5258 : : },
5259 : : };
5260 : :
5261 : : #ifdef RTE_LIB_GRO
5262 : : /* *** SET GRO FOR A PORT *** */
5263 : : struct cmd_gro_enable_result {
5264 : : cmdline_fixed_string_t cmd_set;
5265 : : cmdline_fixed_string_t cmd_port;
5266 : : cmdline_fixed_string_t cmd_keyword;
5267 : : cmdline_fixed_string_t cmd_onoff;
5268 : : portid_t cmd_pid;
5269 : : };
5270 : :
5271 : : static void
5272 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5273 : : __rte_unused struct cmdline *cl,
5274 : : __rte_unused void *data)
5275 : : {
5276 : : struct cmd_gro_enable_result *res;
5277 : :
5278 : : res = parsed_result;
5279 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5280 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5281 : 0 : }
5282 : :
5283 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5284 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5285 : : cmd_set, "set");
5286 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5287 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5288 : : cmd_keyword, "port");
5289 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5290 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5291 : : cmd_pid, RTE_UINT16);
5292 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5293 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5294 : : cmd_keyword, "gro");
5295 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5296 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5297 : : cmd_onoff, "on#off");
5298 : :
5299 : : static cmdline_parse_inst_t cmd_gro_enable = {
5300 : : .f = cmd_gro_enable_parsed,
5301 : : .data = NULL,
5302 : : .help_str = "set port <port_id> gro on|off",
5303 : : .tokens = {
5304 : : (void *)&cmd_gro_enable_set,
5305 : : (void *)&cmd_gro_enable_port,
5306 : : (void *)&cmd_gro_enable_pid,
5307 : : (void *)&cmd_gro_enable_keyword,
5308 : : (void *)&cmd_gro_enable_onoff,
5309 : : NULL,
5310 : : },
5311 : : };
5312 : :
5313 : : /* *** DISPLAY GRO CONFIGURATION *** */
5314 : : struct cmd_gro_show_result {
5315 : : cmdline_fixed_string_t cmd_show;
5316 : : cmdline_fixed_string_t cmd_port;
5317 : : cmdline_fixed_string_t cmd_keyword;
5318 : : portid_t cmd_pid;
5319 : : };
5320 : :
5321 : : static void
5322 : 0 : cmd_gro_show_parsed(void *parsed_result,
5323 : : __rte_unused struct cmdline *cl,
5324 : : __rte_unused void *data)
5325 : : {
5326 : : struct cmd_gro_show_result *res;
5327 : :
5328 : : res = parsed_result;
5329 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5330 : 0 : show_gro(res->cmd_pid);
5331 : 0 : }
5332 : :
5333 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5334 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5335 : : cmd_show, "show");
5336 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5337 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5338 : : cmd_port, "port");
5339 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5340 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5341 : : cmd_pid, RTE_UINT16);
5342 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5343 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5344 : : cmd_keyword, "gro");
5345 : :
5346 : : static cmdline_parse_inst_t cmd_gro_show = {
5347 : : .f = cmd_gro_show_parsed,
5348 : : .data = NULL,
5349 : : .help_str = "show port <port_id> gro",
5350 : : .tokens = {
5351 : : (void *)&cmd_gro_show_show,
5352 : : (void *)&cmd_gro_show_port,
5353 : : (void *)&cmd_gro_show_pid,
5354 : : (void *)&cmd_gro_show_keyword,
5355 : : NULL,
5356 : : },
5357 : : };
5358 : :
5359 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5360 : : struct cmd_gro_flush_result {
5361 : : cmdline_fixed_string_t cmd_set;
5362 : : cmdline_fixed_string_t cmd_keyword;
5363 : : cmdline_fixed_string_t cmd_flush;
5364 : : uint8_t cmd_cycles;
5365 : : };
5366 : :
5367 : : static void
5368 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5369 : : __rte_unused struct cmdline *cl,
5370 : : __rte_unused void *data)
5371 : : {
5372 : : struct cmd_gro_flush_result *res;
5373 : :
5374 : : res = parsed_result;
5375 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5376 : 0 : (!strcmp(res->cmd_flush, "flush")))
5377 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5378 : 0 : }
5379 : :
5380 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5381 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5382 : : cmd_set, "set");
5383 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5384 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5385 : : cmd_keyword, "gro");
5386 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5387 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5388 : : cmd_flush, "flush");
5389 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5390 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5391 : : cmd_cycles, RTE_UINT8);
5392 : :
5393 : : static cmdline_parse_inst_t cmd_gro_flush = {
5394 : : .f = cmd_gro_flush_parsed,
5395 : : .data = NULL,
5396 : : .help_str = "set gro flush <cycles>",
5397 : : .tokens = {
5398 : : (void *)&cmd_gro_flush_set,
5399 : : (void *)&cmd_gro_flush_keyword,
5400 : : (void *)&cmd_gro_flush_flush,
5401 : : (void *)&cmd_gro_flush_cycles,
5402 : : NULL,
5403 : : },
5404 : : };
5405 : : #endif /* RTE_LIB_GRO */
5406 : :
5407 : : #ifdef RTE_LIB_GSO
5408 : : /* *** ENABLE/DISABLE GSO *** */
5409 : : struct cmd_gso_enable_result {
5410 : : cmdline_fixed_string_t cmd_set;
5411 : : cmdline_fixed_string_t cmd_port;
5412 : : cmdline_fixed_string_t cmd_keyword;
5413 : : cmdline_fixed_string_t cmd_mode;
5414 : : portid_t cmd_pid;
5415 : : };
5416 : :
5417 : : static void
5418 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5419 : : __rte_unused struct cmdline *cl,
5420 : : __rte_unused void *data)
5421 : : {
5422 : : struct cmd_gso_enable_result *res;
5423 : :
5424 : : res = parsed_result;
5425 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5426 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5427 : 0 : }
5428 : :
5429 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5430 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5431 : : cmd_set, "set");
5432 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5433 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5434 : : cmd_port, "port");
5435 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5436 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5437 : : cmd_keyword, "gso");
5438 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5439 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5440 : : cmd_mode, "on#off");
5441 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5442 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5443 : : cmd_pid, RTE_UINT16);
5444 : :
5445 : : static cmdline_parse_inst_t cmd_gso_enable = {
5446 : : .f = cmd_gso_enable_parsed,
5447 : : .data = NULL,
5448 : : .help_str = "set port <port_id> gso on|off",
5449 : : .tokens = {
5450 : : (void *)&cmd_gso_enable_set,
5451 : : (void *)&cmd_gso_enable_port,
5452 : : (void *)&cmd_gso_enable_pid,
5453 : : (void *)&cmd_gso_enable_keyword,
5454 : : (void *)&cmd_gso_enable_mode,
5455 : : NULL,
5456 : : },
5457 : : };
5458 : :
5459 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5460 : : struct cmd_gso_size_result {
5461 : : cmdline_fixed_string_t cmd_set;
5462 : : cmdline_fixed_string_t cmd_keyword;
5463 : : cmdline_fixed_string_t cmd_segsz;
5464 : : uint16_t cmd_size;
5465 : : };
5466 : :
5467 : : static void
5468 : 0 : cmd_gso_size_parsed(void *parsed_result,
5469 : : __rte_unused struct cmdline *cl,
5470 : : __rte_unused void *data)
5471 : : {
5472 : : struct cmd_gso_size_result *res = parsed_result;
5473 : :
5474 : 0 : if (test_done == 0) {
5475 : 0 : fprintf(stderr,
5476 : : "Before setting GSO segsz, please first stop forwarding\n");
5477 : 0 : return;
5478 : : }
5479 : :
5480 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5481 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5482 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5483 : 0 : fprintf(stderr,
5484 : : "gso_size should be larger than %zu. Please input a legal value\n",
5485 : : RTE_GSO_SEG_SIZE_MIN);
5486 : : else
5487 : 0 : gso_max_segment_size = res->cmd_size;
5488 : : }
5489 : : }
5490 : :
5491 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5492 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5493 : : cmd_set, "set");
5494 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5495 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5496 : : cmd_keyword, "gso");
5497 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5498 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5499 : : cmd_segsz, "segsz");
5500 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5501 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5502 : : cmd_size, RTE_UINT16);
5503 : :
5504 : : static cmdline_parse_inst_t cmd_gso_size = {
5505 : : .f = cmd_gso_size_parsed,
5506 : : .data = NULL,
5507 : : .help_str = "set gso segsz <length>",
5508 : : .tokens = {
5509 : : (void *)&cmd_gso_size_set,
5510 : : (void *)&cmd_gso_size_keyword,
5511 : : (void *)&cmd_gso_size_segsz,
5512 : : (void *)&cmd_gso_size_size,
5513 : : NULL,
5514 : : },
5515 : : };
5516 : :
5517 : : /* *** SHOW GSO CONFIGURATION *** */
5518 : : struct cmd_gso_show_result {
5519 : : cmdline_fixed_string_t cmd_show;
5520 : : cmdline_fixed_string_t cmd_port;
5521 : : cmdline_fixed_string_t cmd_keyword;
5522 : : portid_t cmd_pid;
5523 : : };
5524 : :
5525 : : static void
5526 : 0 : cmd_gso_show_parsed(void *parsed_result,
5527 : : __rte_unused struct cmdline *cl,
5528 : : __rte_unused void *data)
5529 : : {
5530 : : struct cmd_gso_show_result *res = parsed_result;
5531 : :
5532 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5533 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5534 : 0 : return;
5535 : : }
5536 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
5537 : 0 : if (gso_ports[res->cmd_pid].enable) {
5538 : 0 : printf("Max GSO'd packet size: %uB\n"
5539 : : "Supported GSO types: TCP/IPv4, "
5540 : : "UDP/IPv4, VxLAN with inner "
5541 : : "TCP/IPv4 packet, GRE with inner "
5542 : : "TCP/IPv4 packet\n",
5543 : : gso_max_segment_size);
5544 : : } else
5545 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5546 : : }
5547 : : }
5548 : :
5549 : : static cmdline_parse_token_string_t cmd_gso_show_show =
5550 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5551 : : cmd_show, "show");
5552 : : static cmdline_parse_token_string_t cmd_gso_show_port =
5553 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5554 : : cmd_port, "port");
5555 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
5556 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5557 : : cmd_keyword, "gso");
5558 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
5559 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5560 : : cmd_pid, RTE_UINT16);
5561 : :
5562 : : static cmdline_parse_inst_t cmd_gso_show = {
5563 : : .f = cmd_gso_show_parsed,
5564 : : .data = NULL,
5565 : : .help_str = "show port <port_id> gso",
5566 : : .tokens = {
5567 : : (void *)&cmd_gso_show_show,
5568 : : (void *)&cmd_gso_show_port,
5569 : : (void *)&cmd_gso_show_pid,
5570 : : (void *)&cmd_gso_show_keyword,
5571 : : NULL,
5572 : : },
5573 : : };
5574 : : #endif /* RTE_LIB_GSO */
5575 : :
5576 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5577 : : struct cmd_set_flush_rx {
5578 : : cmdline_fixed_string_t set;
5579 : : cmdline_fixed_string_t flush_rx;
5580 : : cmdline_fixed_string_t mode;
5581 : : };
5582 : :
5583 : : static void
5584 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
5585 : : __rte_unused struct cmdline *cl,
5586 : : __rte_unused void *data)
5587 : : {
5588 : : struct cmd_set_flush_rx *res = parsed_result;
5589 : :
5590 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5591 : : printf("multi-process doesn't support to flush Rx queues.\n");
5592 : 0 : return;
5593 : : }
5594 : :
5595 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5596 : : }
5597 : :
5598 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
5599 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5600 : : set, "set");
5601 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5602 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5603 : : flush_rx, "flush_rx");
5604 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
5605 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5606 : : mode, "on#off");
5607 : :
5608 : :
5609 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
5610 : : .f = cmd_set_flush_rx_parsed,
5611 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5612 : : .data = NULL,
5613 : : .tokens = {
5614 : : (void *)&cmd_setflushrx_set,
5615 : : (void *)&cmd_setflushrx_flush_rx,
5616 : : (void *)&cmd_setflushrx_mode,
5617 : : NULL,
5618 : : },
5619 : : };
5620 : :
5621 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5622 : : struct cmd_set_link_check {
5623 : : cmdline_fixed_string_t set;
5624 : : cmdline_fixed_string_t link_check;
5625 : : cmdline_fixed_string_t mode;
5626 : : };
5627 : :
5628 : : static void
5629 : 0 : cmd_set_link_check_parsed(void *parsed_result,
5630 : : __rte_unused struct cmdline *cl,
5631 : : __rte_unused void *data)
5632 : : {
5633 : : struct cmd_set_link_check *res = parsed_result;
5634 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5635 : 0 : }
5636 : :
5637 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
5638 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5639 : : set, "set");
5640 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5641 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5642 : : link_check, "link_check");
5643 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5644 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5645 : : mode, "on#off");
5646 : :
5647 : :
5648 : : static cmdline_parse_inst_t cmd_set_link_check = {
5649 : : .f = cmd_set_link_check_parsed,
5650 : : .help_str = "set link_check on|off: Enable/Disable link status check "
5651 : : "when starting/stopping a port",
5652 : : .data = NULL,
5653 : : .tokens = {
5654 : : (void *)&cmd_setlinkcheck_set,
5655 : : (void *)&cmd_setlinkcheck_link_check,
5656 : : (void *)&cmd_setlinkcheck_mode,
5657 : : NULL,
5658 : : },
5659 : : };
5660 : :
5661 : : /* *** SET FORWARDING MODE *** */
5662 : : struct cmd_set_fwd_mode_result {
5663 : : cmdline_fixed_string_t set;
5664 : : cmdline_fixed_string_t fwd;
5665 : : cmdline_fixed_string_t mode;
5666 : : };
5667 : :
5668 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
5669 : : __rte_unused struct cmdline *cl,
5670 : : __rte_unused void *data)
5671 : : {
5672 : : struct cmd_set_fwd_mode_result *res = parsed_result;
5673 : :
5674 : 0 : retry_enabled = 0;
5675 : 0 : set_pkt_forwarding_mode(res->mode);
5676 : 0 : }
5677 : :
5678 : : static cmdline_parse_token_string_t cmd_setfwd_set =
5679 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5680 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
5681 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5682 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
5683 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5684 : : "" /* defined at init */);
5685 : :
5686 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
5687 : : .f = cmd_set_fwd_mode_parsed,
5688 : : .data = NULL,
5689 : : .help_str = NULL, /* defined at init */
5690 : : .tokens = {
5691 : : (void *)&cmd_setfwd_set,
5692 : : (void *)&cmd_setfwd_fwd,
5693 : : (void *)&cmd_setfwd_mode,
5694 : : NULL,
5695 : : },
5696 : : };
5697 : :
5698 : 0 : static void cmd_set_fwd_mode_init(void)
5699 : : {
5700 : : char *modes, *c;
5701 : : static char token[128];
5702 : : static char help[256];
5703 : : cmdline_parse_token_string_t *token_struct;
5704 : :
5705 : 0 : modes = list_pkt_forwarding_modes();
5706 : : snprintf(help, sizeof(help), "set fwd %s: "
5707 : : "Set packet forwarding mode", modes);
5708 : 0 : cmd_set_fwd_mode.help_str = help;
5709 : :
5710 : : /* string token separator is # */
5711 : 0 : for (c = token; *modes != '\0'; modes++)
5712 : 0 : if (*modes == '|')
5713 : 0 : *c++ = '#';
5714 : : else
5715 : 0 : *c++ = *modes;
5716 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5717 : 0 : token_struct->string_data.str = token;
5718 : 0 : }
5719 : :
5720 : : /* *** SET RETRY FORWARDING MODE *** */
5721 : : struct cmd_set_fwd_retry_mode_result {
5722 : : cmdline_fixed_string_t set;
5723 : : cmdline_fixed_string_t fwd;
5724 : : cmdline_fixed_string_t mode;
5725 : : cmdline_fixed_string_t retry;
5726 : : };
5727 : :
5728 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5729 : : __rte_unused struct cmdline *cl,
5730 : : __rte_unused void *data)
5731 : : {
5732 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5733 : :
5734 : 0 : retry_enabled = 1;
5735 : 0 : set_pkt_forwarding_mode(res->mode);
5736 : 0 : }
5737 : :
5738 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
5739 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5740 : : set, "set");
5741 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5742 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5743 : : fwd, "fwd");
5744 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5745 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5746 : : mode,
5747 : : "" /* defined at init */);
5748 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5749 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5750 : : retry, "retry");
5751 : :
5752 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5753 : : .f = cmd_set_fwd_retry_mode_parsed,
5754 : : .data = NULL,
5755 : : .help_str = NULL, /* defined at init */
5756 : : .tokens = {
5757 : : (void *)&cmd_setfwd_retry_set,
5758 : : (void *)&cmd_setfwd_retry_fwd,
5759 : : (void *)&cmd_setfwd_retry_mode,
5760 : : (void *)&cmd_setfwd_retry_retry,
5761 : : NULL,
5762 : : },
5763 : : };
5764 : :
5765 : 0 : static void cmd_set_fwd_retry_mode_init(void)
5766 : : {
5767 : : char *modes, *c;
5768 : : static char token[128];
5769 : : static char help[256];
5770 : : cmdline_parse_token_string_t *token_struct;
5771 : :
5772 : 0 : modes = list_pkt_forwarding_retry_modes();
5773 : : snprintf(help, sizeof(help), "set fwd %s retry: "
5774 : : "Set packet forwarding mode with retry", modes);
5775 : 0 : cmd_set_fwd_retry_mode.help_str = help;
5776 : :
5777 : : /* string token separator is # */
5778 : 0 : for (c = token; *modes != '\0'; modes++)
5779 : 0 : if (*modes == '|')
5780 : 0 : *c++ = '#';
5781 : : else
5782 : 0 : *c++ = *modes;
5783 : 0 : token_struct = (cmdline_parse_token_string_t *)
5784 : : cmd_set_fwd_retry_mode.tokens[2];
5785 : 0 : token_struct->string_data.str = token;
5786 : 0 : }
5787 : :
5788 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5789 : : struct cmd_set_burst_tx_retry_result {
5790 : : cmdline_fixed_string_t set;
5791 : : cmdline_fixed_string_t burst;
5792 : : cmdline_fixed_string_t tx;
5793 : : cmdline_fixed_string_t delay;
5794 : : uint32_t time;
5795 : : cmdline_fixed_string_t retry;
5796 : : uint32_t retry_num;
5797 : : };
5798 : :
5799 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5800 : : __rte_unused struct cmdline *cl,
5801 : : __rte_unused void *data)
5802 : : {
5803 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
5804 : :
5805 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5806 : 0 : && !strcmp(res->tx, "tx")) {
5807 : 0 : if (!strcmp(res->delay, "delay"))
5808 : 0 : burst_tx_delay_time = res->time;
5809 : 0 : if (!strcmp(res->retry, "retry"))
5810 : 0 : burst_tx_retry_num = res->retry_num;
5811 : : }
5812 : :
5813 : 0 : }
5814 : :
5815 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5816 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5817 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5818 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5819 : : "burst");
5820 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5821 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5822 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5823 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5824 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5825 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
5826 : : RTE_UINT32);
5827 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5828 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5829 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5830 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
5831 : : RTE_UINT32);
5832 : :
5833 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5834 : : .f = cmd_set_burst_tx_retry_parsed,
5835 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5836 : : .tokens = {
5837 : : (void *)&cmd_set_burst_tx_retry_set,
5838 : : (void *)&cmd_set_burst_tx_retry_burst,
5839 : : (void *)&cmd_set_burst_tx_retry_tx,
5840 : : (void *)&cmd_set_burst_tx_retry_delay,
5841 : : (void *)&cmd_set_burst_tx_retry_time,
5842 : : (void *)&cmd_set_burst_tx_retry_retry,
5843 : : (void *)&cmd_set_burst_tx_retry_retry_num,
5844 : : NULL,
5845 : : },
5846 : : };
5847 : :
5848 : : /* *** SET PROMISC MODE *** */
5849 : : struct cmd_set_promisc_mode_result {
5850 : : cmdline_fixed_string_t set;
5851 : : cmdline_fixed_string_t promisc;
5852 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5853 : : uint16_t port_num; /* valid if "allports" argument == 0 */
5854 : : cmdline_fixed_string_t mode;
5855 : : };
5856 : :
5857 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
5858 : : __rte_unused struct cmdline *cl,
5859 : : void *allports)
5860 : : {
5861 : : struct cmd_set_promisc_mode_result *res = parsed_result;
5862 : : int enable;
5863 : : portid_t i;
5864 : :
5865 : 0 : if (!strcmp(res->mode, "on"))
5866 : : enable = 1;
5867 : : else
5868 : : enable = 0;
5869 : :
5870 : : /* all ports */
5871 : 0 : if (allports) {
5872 : 0 : RTE_ETH_FOREACH_DEV(i)
5873 : 0 : eth_set_promisc_mode(i, enable);
5874 : : } else {
5875 : 0 : eth_set_promisc_mode(res->port_num, enable);
5876 : : }
5877 : 0 : }
5878 : :
5879 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
5880 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5881 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
5882 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5883 : : "promisc");
5884 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
5885 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5886 : : "all");
5887 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
5888 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5889 : : RTE_UINT16);
5890 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
5891 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5892 : : "on#off");
5893 : :
5894 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5895 : : .f = cmd_set_promisc_mode_parsed,
5896 : : .data = (void *)1,
5897 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
5898 : : .tokens = {
5899 : : (void *)&cmd_setpromisc_set,
5900 : : (void *)&cmd_setpromisc_promisc,
5901 : : (void *)&cmd_setpromisc_portall,
5902 : : (void *)&cmd_setpromisc_mode,
5903 : : NULL,
5904 : : },
5905 : : };
5906 : :
5907 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5908 : : .f = cmd_set_promisc_mode_parsed,
5909 : : .data = (void *)0,
5910 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5911 : : .tokens = {
5912 : : (void *)&cmd_setpromisc_set,
5913 : : (void *)&cmd_setpromisc_promisc,
5914 : : (void *)&cmd_setpromisc_portnum,
5915 : : (void *)&cmd_setpromisc_mode,
5916 : : NULL,
5917 : : },
5918 : : };
5919 : :
5920 : : /* *** SET ALLMULTI MODE *** */
5921 : : struct cmd_set_allmulti_mode_result {
5922 : : cmdline_fixed_string_t set;
5923 : : cmdline_fixed_string_t allmulti;
5924 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5925 : : uint16_t port_num; /* valid if "allports" argument == 0 */
5926 : : cmdline_fixed_string_t mode;
5927 : : };
5928 : :
5929 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5930 : : __rte_unused struct cmdline *cl,
5931 : : void *allports)
5932 : : {
5933 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
5934 : : int enable;
5935 : : portid_t i;
5936 : :
5937 : 0 : if (!strcmp(res->mode, "on"))
5938 : : enable = 1;
5939 : : else
5940 : : enable = 0;
5941 : :
5942 : : /* all ports */
5943 : 0 : if (allports) {
5944 : 0 : RTE_ETH_FOREACH_DEV(i) {
5945 : 0 : eth_set_allmulticast_mode(i, enable);
5946 : : }
5947 : : }
5948 : : else {
5949 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
5950 : : }
5951 : 0 : }
5952 : :
5953 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
5954 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5955 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5956 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5957 : : "allmulti");
5958 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
5959 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5960 : : "all");
5961 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
5962 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5963 : : RTE_UINT16);
5964 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
5965 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5966 : : "on#off");
5967 : :
5968 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5969 : : .f = cmd_set_allmulti_mode_parsed,
5970 : : .data = (void *)1,
5971 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5972 : : .tokens = {
5973 : : (void *)&cmd_setallmulti_set,
5974 : : (void *)&cmd_setallmulti_allmulti,
5975 : : (void *)&cmd_setallmulti_portall,
5976 : : (void *)&cmd_setallmulti_mode,
5977 : : NULL,
5978 : : },
5979 : : };
5980 : :
5981 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5982 : : .f = cmd_set_allmulti_mode_parsed,
5983 : : .data = (void *)0,
5984 : : .help_str = "set allmulti <port_id> on|off: "
5985 : : "Set allmulti mode on port_id",
5986 : : .tokens = {
5987 : : (void *)&cmd_setallmulti_set,
5988 : : (void *)&cmd_setallmulti_allmulti,
5989 : : (void *)&cmd_setallmulti_portnum,
5990 : : (void *)&cmd_setallmulti_mode,
5991 : : NULL,
5992 : : },
5993 : : };
5994 : :
5995 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
5996 : : struct cmd_link_flow_ctrl_show {
5997 : : cmdline_fixed_string_t show;
5998 : : cmdline_fixed_string_t port;
5999 : : portid_t port_id;
6000 : : cmdline_fixed_string_t flow_ctrl;
6001 : : };
6002 : :
6003 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6004 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6005 : : show, "show");
6006 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6007 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6008 : : port, "port");
6009 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6010 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6011 : : port_id, RTE_UINT16);
6012 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6013 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6014 : : flow_ctrl, "flow_ctrl");
6015 : :
6016 : : static void
6017 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6018 : : __rte_unused struct cmdline *cl,
6019 : : __rte_unused void *data)
6020 : : {
6021 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6022 : : static const char *info_border = "*********************";
6023 : : struct rte_eth_fc_conf fc_conf;
6024 : : bool rx_fc_en = false;
6025 : : bool tx_fc_en = false;
6026 : : int ret;
6027 : :
6028 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6029 : 0 : if (ret != 0) {
6030 : 0 : fprintf(stderr,
6031 : : "Failed to get current flow ctrl information: err = %d\n",
6032 : : ret);
6033 : 0 : return;
6034 : : }
6035 : :
6036 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6037 : : rx_fc_en = true;
6038 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6039 : : tx_fc_en = true;
6040 : :
6041 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6042 : 0 : info_border, res->port_id, info_border);
6043 : : printf("FC mode:\n");
6044 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6045 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6046 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6047 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6048 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6049 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6050 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6051 : 0 : printf("Forward MAC control frames: %s\n",
6052 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6053 : 0 : printf("\n%s************** End ***********%s\n",
6054 : : info_border, info_border);
6055 : : }
6056 : :
6057 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6058 : : .f = cmd_link_flow_ctrl_show_parsed,
6059 : : .data = NULL,
6060 : : .help_str = "show port <port_id> flow_ctrl",
6061 : : .tokens = {
6062 : : (void *)&cmd_lfc_show_show,
6063 : : (void *)&cmd_lfc_show_port,
6064 : : (void *)&cmd_lfc_show_portid,
6065 : : (void *)&cmd_lfc_show_flow_ctrl,
6066 : : NULL,
6067 : : },
6068 : : };
6069 : :
6070 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6071 : : struct cmd_link_flow_ctrl_set_result {
6072 : : cmdline_fixed_string_t set;
6073 : : cmdline_fixed_string_t flow_ctrl;
6074 : : cmdline_fixed_string_t rx;
6075 : : cmdline_fixed_string_t rx_lfc_mode;
6076 : : cmdline_fixed_string_t tx;
6077 : : cmdline_fixed_string_t tx_lfc_mode;
6078 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6079 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6080 : : cmdline_fixed_string_t autoneg_str;
6081 : : cmdline_fixed_string_t autoneg;
6082 : : cmdline_fixed_string_t hw_str;
6083 : : uint32_t high_water;
6084 : : cmdline_fixed_string_t lw_str;
6085 : : uint32_t low_water;
6086 : : cmdline_fixed_string_t pt_str;
6087 : : uint16_t pause_time;
6088 : : cmdline_fixed_string_t xon_str;
6089 : : uint16_t send_xon;
6090 : : portid_t port_id;
6091 : : };
6092 : :
6093 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6094 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6095 : : set, "set");
6096 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6097 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6098 : : flow_ctrl, "flow_ctrl");
6099 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6100 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6101 : : rx, "rx");
6102 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6103 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6104 : : rx_lfc_mode, "on#off");
6105 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6106 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6107 : : tx, "tx");
6108 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6109 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6110 : : tx_lfc_mode, "on#off");
6111 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6112 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6113 : : hw_str, "high_water");
6114 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6115 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6116 : : high_water, RTE_UINT32);
6117 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6118 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6119 : : lw_str, "low_water");
6120 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6121 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6122 : : low_water, RTE_UINT32);
6123 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6124 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6125 : : pt_str, "pause_time");
6126 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6127 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6128 : : pause_time, RTE_UINT16);
6129 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6130 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6131 : : xon_str, "send_xon");
6132 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6133 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6134 : : send_xon, RTE_UINT16);
6135 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6136 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6137 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6138 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6139 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6140 : : mac_ctrl_frame_fwd_mode, "on#off");
6141 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6142 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6143 : : autoneg_str, "autoneg");
6144 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6145 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6146 : : autoneg, "on#off");
6147 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6148 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6149 : : port_id, RTE_UINT16);
6150 : :
6151 : : /* forward declaration */
6152 : : static void
6153 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6154 : : void *data);
6155 : :
6156 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6157 : : .f = cmd_link_flow_ctrl_set_parsed,
6158 : : .data = NULL,
6159 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6160 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6161 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6162 : : .tokens = {
6163 : : (void *)&cmd_lfc_set_set,
6164 : : (void *)&cmd_lfc_set_flow_ctrl,
6165 : : (void *)&cmd_lfc_set_rx,
6166 : : (void *)&cmd_lfc_set_rx_mode,
6167 : : (void *)&cmd_lfc_set_tx,
6168 : : (void *)&cmd_lfc_set_tx_mode,
6169 : : (void *)&cmd_lfc_set_high_water,
6170 : : (void *)&cmd_lfc_set_low_water,
6171 : : (void *)&cmd_lfc_set_pause_time,
6172 : : (void *)&cmd_lfc_set_send_xon,
6173 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6174 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6175 : : (void *)&cmd_lfc_set_autoneg_str,
6176 : : (void *)&cmd_lfc_set_autoneg,
6177 : : (void *)&cmd_lfc_set_portid,
6178 : : NULL,
6179 : : },
6180 : : };
6181 : :
6182 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6183 : : .f = cmd_link_flow_ctrl_set_parsed,
6184 : : .data = (void *)&cmd_link_flow_control_set_rx,
6185 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6186 : : "Change rx flow control parameter",
6187 : : .tokens = {
6188 : : (void *)&cmd_lfc_set_set,
6189 : : (void *)&cmd_lfc_set_flow_ctrl,
6190 : : (void *)&cmd_lfc_set_rx,
6191 : : (void *)&cmd_lfc_set_rx_mode,
6192 : : (void *)&cmd_lfc_set_portid,
6193 : : NULL,
6194 : : },
6195 : : };
6196 : :
6197 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6198 : : .f = cmd_link_flow_ctrl_set_parsed,
6199 : : .data = (void *)&cmd_link_flow_control_set_tx,
6200 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6201 : : "Change tx flow control parameter",
6202 : : .tokens = {
6203 : : (void *)&cmd_lfc_set_set,
6204 : : (void *)&cmd_lfc_set_flow_ctrl,
6205 : : (void *)&cmd_lfc_set_tx,
6206 : : (void *)&cmd_lfc_set_tx_mode,
6207 : : (void *)&cmd_lfc_set_portid,
6208 : : NULL,
6209 : : },
6210 : : };
6211 : :
6212 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6213 : : .f = cmd_link_flow_ctrl_set_parsed,
6214 : : .data = (void *)&cmd_link_flow_control_set_hw,
6215 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6216 : : "Change high water flow control parameter",
6217 : : .tokens = {
6218 : : (void *)&cmd_lfc_set_set,
6219 : : (void *)&cmd_lfc_set_flow_ctrl,
6220 : : (void *)&cmd_lfc_set_high_water_str,
6221 : : (void *)&cmd_lfc_set_high_water,
6222 : : (void *)&cmd_lfc_set_portid,
6223 : : NULL,
6224 : : },
6225 : : };
6226 : :
6227 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6228 : : .f = cmd_link_flow_ctrl_set_parsed,
6229 : : .data = (void *)&cmd_link_flow_control_set_lw,
6230 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6231 : : "Change low water flow control parameter",
6232 : : .tokens = {
6233 : : (void *)&cmd_lfc_set_set,
6234 : : (void *)&cmd_lfc_set_flow_ctrl,
6235 : : (void *)&cmd_lfc_set_low_water_str,
6236 : : (void *)&cmd_lfc_set_low_water,
6237 : : (void *)&cmd_lfc_set_portid,
6238 : : NULL,
6239 : : },
6240 : : };
6241 : :
6242 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6243 : : .f = cmd_link_flow_ctrl_set_parsed,
6244 : : .data = (void *)&cmd_link_flow_control_set_pt,
6245 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6246 : : "Change pause time flow control parameter",
6247 : : .tokens = {
6248 : : (void *)&cmd_lfc_set_set,
6249 : : (void *)&cmd_lfc_set_flow_ctrl,
6250 : : (void *)&cmd_lfc_set_pause_time_str,
6251 : : (void *)&cmd_lfc_set_pause_time,
6252 : : (void *)&cmd_lfc_set_portid,
6253 : : NULL,
6254 : : },
6255 : : };
6256 : :
6257 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6258 : : .f = cmd_link_flow_ctrl_set_parsed,
6259 : : .data = (void *)&cmd_link_flow_control_set_xon,
6260 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6261 : : "Change send_xon flow control parameter",
6262 : : .tokens = {
6263 : : (void *)&cmd_lfc_set_set,
6264 : : (void *)&cmd_lfc_set_flow_ctrl,
6265 : : (void *)&cmd_lfc_set_send_xon_str,
6266 : : (void *)&cmd_lfc_set_send_xon,
6267 : : (void *)&cmd_lfc_set_portid,
6268 : : NULL,
6269 : : },
6270 : : };
6271 : :
6272 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6273 : : .f = cmd_link_flow_ctrl_set_parsed,
6274 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6275 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6276 : : "Change mac ctrl fwd flow control parameter",
6277 : : .tokens = {
6278 : : (void *)&cmd_lfc_set_set,
6279 : : (void *)&cmd_lfc_set_flow_ctrl,
6280 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6281 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6282 : : (void *)&cmd_lfc_set_portid,
6283 : : NULL,
6284 : : },
6285 : : };
6286 : :
6287 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6288 : : .f = cmd_link_flow_ctrl_set_parsed,
6289 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6290 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6291 : : "Change autoneg flow control parameter",
6292 : : .tokens = {
6293 : : (void *)&cmd_lfc_set_set,
6294 : : (void *)&cmd_lfc_set_flow_ctrl,
6295 : : (void *)&cmd_lfc_set_autoneg_str,
6296 : : (void *)&cmd_lfc_set_autoneg,
6297 : : (void *)&cmd_lfc_set_portid,
6298 : : NULL,
6299 : : },
6300 : : };
6301 : :
6302 : : static void
6303 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6304 : : __rte_unused struct cmdline *cl,
6305 : : void *data)
6306 : : {
6307 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6308 : : cmdline_parse_inst_t *cmd = data;
6309 : : struct rte_eth_fc_conf fc_conf;
6310 : : int rx_fc_en = 0;
6311 : : int tx_fc_en = 0;
6312 : : int ret;
6313 : :
6314 : : /*
6315 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6316 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6317 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6318 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6319 : : */
6320 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6321 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6322 : : };
6323 : :
6324 : : /* Partial command line, retrieve current configuration */
6325 : 0 : if (cmd) {
6326 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6327 : 0 : if (ret != 0) {
6328 : 0 : fprintf(stderr,
6329 : : "cannot get current flow ctrl parameters, return code = %d\n",
6330 : : ret);
6331 : 0 : return;
6332 : : }
6333 : :
6334 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6335 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6336 : : rx_fc_en = 1;
6337 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6338 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6339 : : tx_fc_en = 1;
6340 : : }
6341 : :
6342 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6343 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6344 : :
6345 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6346 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6347 : :
6348 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6349 : :
6350 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6351 : 0 : fc_conf.high_water = res->high_water;
6352 : :
6353 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6354 : 0 : fc_conf.low_water = res->low_water;
6355 : :
6356 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6357 : 0 : fc_conf.pause_time = res->pause_time;
6358 : :
6359 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6360 : 0 : fc_conf.send_xon = res->send_xon;
6361 : :
6362 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6363 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6364 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6365 : : else
6366 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6367 : : }
6368 : :
6369 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6370 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6371 : :
6372 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6373 : 0 : if (ret != 0)
6374 : 0 : fprintf(stderr,
6375 : : "bad flow control parameter, return code = %d\n",
6376 : : ret);
6377 : : }
6378 : :
6379 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6380 : : struct cmd_priority_flow_ctrl_set_result {
6381 : : cmdline_fixed_string_t set;
6382 : : cmdline_fixed_string_t pfc_ctrl;
6383 : : cmdline_fixed_string_t rx;
6384 : : cmdline_fixed_string_t rx_pfc_mode;
6385 : : cmdline_fixed_string_t tx;
6386 : : cmdline_fixed_string_t tx_pfc_mode;
6387 : : uint32_t high_water;
6388 : : uint32_t low_water;
6389 : : uint16_t pause_time;
6390 : : uint8_t priority;
6391 : : portid_t port_id;
6392 : : };
6393 : :
6394 : : static void
6395 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6396 : : __rte_unused struct cmdline *cl,
6397 : : __rte_unused void *data)
6398 : : {
6399 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6400 : : struct rte_eth_pfc_conf pfc_conf;
6401 : : int rx_fc_enable, tx_fc_enable;
6402 : : int ret;
6403 : :
6404 : : /*
6405 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6406 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6407 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6408 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6409 : : */
6410 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6411 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6412 : : };
6413 : :
6414 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
6415 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6416 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6417 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6418 : 0 : pfc_conf.fc.high_water = res->high_water;
6419 : 0 : pfc_conf.fc.low_water = res->low_water;
6420 : 0 : pfc_conf.fc.pause_time = res->pause_time;
6421 : 0 : pfc_conf.priority = res->priority;
6422 : :
6423 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6424 : 0 : if (ret != 0)
6425 : 0 : fprintf(stderr,
6426 : : "bad priority flow control parameter, return code = %d\n",
6427 : : ret);
6428 : 0 : }
6429 : :
6430 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
6431 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6432 : : set, "set");
6433 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6434 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6435 : : pfc_ctrl, "pfc_ctrl");
6436 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
6437 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6438 : : rx, "rx");
6439 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6440 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6441 : : rx_pfc_mode, "on#off");
6442 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
6443 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6444 : : tx, "tx");
6445 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6446 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6447 : : tx_pfc_mode, "on#off");
6448 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
6449 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6450 : : high_water, RTE_UINT32);
6451 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
6452 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6453 : : low_water, RTE_UINT32);
6454 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6455 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6456 : : pause_time, RTE_UINT16);
6457 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
6458 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6459 : : priority, RTE_UINT8);
6460 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
6461 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6462 : : port_id, RTE_UINT16);
6463 : :
6464 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
6465 : : .f = cmd_priority_flow_ctrl_set_parsed,
6466 : : .data = NULL,
6467 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6468 : : "<pause_time> <priority> <port_id>: "
6469 : : "Configure the Ethernet priority flow control",
6470 : : .tokens = {
6471 : : (void *)&cmd_pfc_set_set,
6472 : : (void *)&cmd_pfc_set_flow_ctrl,
6473 : : (void *)&cmd_pfc_set_rx,
6474 : : (void *)&cmd_pfc_set_rx_mode,
6475 : : (void *)&cmd_pfc_set_tx,
6476 : : (void *)&cmd_pfc_set_tx_mode,
6477 : : (void *)&cmd_pfc_set_high_water,
6478 : : (void *)&cmd_pfc_set_low_water,
6479 : : (void *)&cmd_pfc_set_pause_time,
6480 : : (void *)&cmd_pfc_set_priority,
6481 : : (void *)&cmd_pfc_set_portid,
6482 : : NULL,
6483 : : },
6484 : : };
6485 : :
6486 : : struct cmd_queue_priority_flow_ctrl_set_result {
6487 : : cmdline_fixed_string_t set;
6488 : : cmdline_fixed_string_t pfc_queue_ctrl;
6489 : : portid_t port_id;
6490 : : cmdline_fixed_string_t rx;
6491 : : cmdline_fixed_string_t rx_pfc_mode;
6492 : : uint16_t tx_qid;
6493 : : uint8_t tx_tc;
6494 : : cmdline_fixed_string_t tx;
6495 : : cmdline_fixed_string_t tx_pfc_mode;
6496 : : uint16_t rx_qid;
6497 : : uint8_t rx_tc;
6498 : : uint16_t pause_time;
6499 : : };
6500 : :
6501 : : static void
6502 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
6503 : : __rte_unused struct cmdline *cl,
6504 : : __rte_unused void *data)
6505 : : {
6506 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
6507 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
6508 : : int rx_fc_enable, tx_fc_enable;
6509 : : int ret;
6510 : :
6511 : : /*
6512 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
6513 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
6514 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
6515 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
6516 : : * the Tx side.
6517 : : */
6518 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
6519 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
6520 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6521 : : };
6522 : :
6523 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
6524 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
6525 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
6526 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
6527 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
6528 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
6529 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
6530 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
6531 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
6532 : :
6533 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
6534 : : &pfc_queue_conf);
6535 : 0 : if (ret != 0) {
6536 : 0 : fprintf(stderr,
6537 : : "bad queue priority flow control parameter, rc = %d\n",
6538 : : ret);
6539 : : }
6540 : 0 : }
6541 : :
6542 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
6543 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6544 : : set, "set");
6545 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
6546 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6547 : : pfc_queue_ctrl, "pfc_queue_ctrl");
6548 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
6549 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6550 : : port_id, RTE_UINT16);
6551 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
6552 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6553 : : rx, "rx");
6554 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
6555 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6556 : : rx_pfc_mode, "on#off");
6557 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
6558 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6559 : : tx_qid, RTE_UINT16);
6560 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
6561 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6562 : : tx_tc, RTE_UINT8);
6563 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
6564 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6565 : : tx, "tx");
6566 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
6567 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6568 : : tx_pfc_mode, "on#off");
6569 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
6570 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6571 : : rx_qid, RTE_UINT16);
6572 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
6573 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6574 : : rx_tc, RTE_UINT8);
6575 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
6576 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6577 : : pause_time, RTE_UINT16);
6578 : :
6579 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
6580 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
6581 : : .data = NULL,
6582 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
6583 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
6584 : : "Configure the Ethernet queue priority flow control",
6585 : : .tokens = {
6586 : : (void *)&cmd_q_pfc_set_set,
6587 : : (void *)&cmd_q_pfc_set_flow_ctrl,
6588 : : (void *)&cmd_q_pfc_set_portid,
6589 : : (void *)&cmd_q_pfc_set_rx,
6590 : : (void *)&cmd_q_pfc_set_rx_mode,
6591 : : (void *)&cmd_q_pfc_set_tx_qid,
6592 : : (void *)&cmd_q_pfc_set_tx_tc,
6593 : : (void *)&cmd_q_pfc_set_tx,
6594 : : (void *)&cmd_q_pfc_set_tx_mode,
6595 : : (void *)&cmd_q_pfc_set_rx_qid,
6596 : : (void *)&cmd_q_pfc_set_rx_tc,
6597 : : (void *)&cmd_q_pfc_set_pause_time,
6598 : : NULL,
6599 : : },
6600 : : };
6601 : :
6602 : : /* *** RESET CONFIGURATION *** */
6603 : : struct cmd_reset_result {
6604 : : cmdline_fixed_string_t reset;
6605 : : cmdline_fixed_string_t def;
6606 : : };
6607 : :
6608 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
6609 : : struct cmdline *cl,
6610 : : __rte_unused void *data)
6611 : : {
6612 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6613 : 0 : set_def_fwd_config();
6614 : 0 : }
6615 : :
6616 : : static cmdline_parse_token_string_t cmd_reset_set =
6617 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6618 : : static cmdline_parse_token_string_t cmd_reset_def =
6619 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6620 : : "default");
6621 : :
6622 : : static cmdline_parse_inst_t cmd_reset = {
6623 : : .f = cmd_reset_parsed,
6624 : : .data = NULL,
6625 : : .help_str = "set default: Reset default forwarding configuration",
6626 : : .tokens = {
6627 : : (void *)&cmd_reset_set,
6628 : : (void *)&cmd_reset_def,
6629 : : NULL,
6630 : : },
6631 : : };
6632 : :
6633 : : /* *** START FORWARDING *** */
6634 : : struct cmd_start_result {
6635 : : cmdline_fixed_string_t start;
6636 : : };
6637 : :
6638 : : static cmdline_parse_token_string_t cmd_start_start =
6639 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6640 : :
6641 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
6642 : : __rte_unused struct cmdline *cl,
6643 : : __rte_unused void *data)
6644 : : {
6645 : 0 : start_packet_forwarding(0);
6646 : 0 : }
6647 : :
6648 : : static cmdline_parse_inst_t cmd_start = {
6649 : : .f = cmd_start_parsed,
6650 : : .data = NULL,
6651 : : .help_str = "start: Start packet forwarding",
6652 : : .tokens = {
6653 : : (void *)&cmd_start_start,
6654 : : NULL,
6655 : : },
6656 : : };
6657 : :
6658 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6659 : : struct cmd_start_tx_first_result {
6660 : : cmdline_fixed_string_t start;
6661 : : cmdline_fixed_string_t tx_first;
6662 : : };
6663 : :
6664 : : static void
6665 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
6666 : : __rte_unused struct cmdline *cl,
6667 : : __rte_unused void *data)
6668 : : {
6669 : 0 : start_packet_forwarding(1);
6670 : 0 : }
6671 : :
6672 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
6673 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6674 : : "start");
6675 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6676 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6677 : : tx_first, "tx_first");
6678 : :
6679 : : static cmdline_parse_inst_t cmd_start_tx_first = {
6680 : : .f = cmd_start_tx_first_parsed,
6681 : : .data = NULL,
6682 : : .help_str = "start tx_first: Start packet forwarding, "
6683 : : "after sending 1 burst of packets",
6684 : : .tokens = {
6685 : : (void *)&cmd_start_tx_first_start,
6686 : : (void *)&cmd_start_tx_first_tx_first,
6687 : : NULL,
6688 : : },
6689 : : };
6690 : :
6691 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
6692 : : struct cmd_start_tx_first_n_result {
6693 : : cmdline_fixed_string_t start;
6694 : : cmdline_fixed_string_t tx_first;
6695 : : uint32_t tx_num;
6696 : : };
6697 : :
6698 : : static void
6699 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
6700 : : __rte_unused struct cmdline *cl,
6701 : : __rte_unused void *data)
6702 : : {
6703 : : struct cmd_start_tx_first_n_result *res = parsed_result;
6704 : :
6705 : 0 : start_packet_forwarding(res->tx_num);
6706 : 0 : }
6707 : :
6708 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6709 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6710 : : start, "start");
6711 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6712 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6713 : : tx_first, "tx_first");
6714 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6715 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6716 : : tx_num, RTE_UINT32);
6717 : :
6718 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
6719 : : .f = cmd_start_tx_first_n_parsed,
6720 : : .data = NULL,
6721 : : .help_str = "start tx_first <num>: "
6722 : : "packet forwarding, after sending <num> bursts of packets",
6723 : : .tokens = {
6724 : : (void *)&cmd_start_tx_first_n_start,
6725 : : (void *)&cmd_start_tx_first_n_tx_first,
6726 : : (void *)&cmd_start_tx_first_n_tx_num,
6727 : : NULL,
6728 : : },
6729 : : };
6730 : :
6731 : : /* *** SET LINK UP *** */
6732 : : struct cmd_set_link_up_result {
6733 : : cmdline_fixed_string_t set;
6734 : : cmdline_fixed_string_t link_up;
6735 : : cmdline_fixed_string_t port;
6736 : : portid_t port_id;
6737 : : };
6738 : :
6739 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
6740 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6741 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
6742 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6743 : : "link-up");
6744 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
6745 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6746 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
6747 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
6748 : : RTE_UINT16);
6749 : :
6750 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
6751 : : __rte_unused struct cmdline *cl,
6752 : : __rte_unused void *data)
6753 : : {
6754 : : struct cmd_set_link_up_result *res = parsed_result;
6755 : 0 : dev_set_link_up(res->port_id);
6756 : 0 : }
6757 : :
6758 : : static cmdline_parse_inst_t cmd_set_link_up = {
6759 : : .f = cmd_set_link_up_parsed,
6760 : : .data = NULL,
6761 : : .help_str = "set link-up port <port id>",
6762 : : .tokens = {
6763 : : (void *)&cmd_set_link_up_set,
6764 : : (void *)&cmd_set_link_up_link_up,
6765 : : (void *)&cmd_set_link_up_port,
6766 : : (void *)&cmd_set_link_up_port_id,
6767 : : NULL,
6768 : : },
6769 : : };
6770 : :
6771 : : /* *** SET LINK DOWN *** */
6772 : : struct cmd_set_link_down_result {
6773 : : cmdline_fixed_string_t set;
6774 : : cmdline_fixed_string_t link_down;
6775 : : cmdline_fixed_string_t port;
6776 : : portid_t port_id;
6777 : : };
6778 : :
6779 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
6780 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6781 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
6782 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6783 : : "link-down");
6784 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
6785 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6786 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
6787 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
6788 : : RTE_UINT16);
6789 : :
6790 : 0 : static void cmd_set_link_down_parsed(
6791 : : __rte_unused void *parsed_result,
6792 : : __rte_unused struct cmdline *cl,
6793 : : __rte_unused void *data)
6794 : : {
6795 : : struct cmd_set_link_down_result *res = parsed_result;
6796 : 0 : dev_set_link_down(res->port_id);
6797 : 0 : }
6798 : :
6799 : : static cmdline_parse_inst_t cmd_set_link_down = {
6800 : : .f = cmd_set_link_down_parsed,
6801 : : .data = NULL,
6802 : : .help_str = "set link-down port <port id>",
6803 : : .tokens = {
6804 : : (void *)&cmd_set_link_down_set,
6805 : : (void *)&cmd_set_link_down_link_down,
6806 : : (void *)&cmd_set_link_down_port,
6807 : : (void *)&cmd_set_link_down_port_id,
6808 : : NULL,
6809 : : },
6810 : : };
6811 : :
6812 : : /* *** SHOW CFG *** */
6813 : : struct cmd_showcfg_result {
6814 : : cmdline_fixed_string_t show;
6815 : : cmdline_fixed_string_t cfg;
6816 : : cmdline_fixed_string_t what;
6817 : : };
6818 : :
6819 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
6820 : : __rte_unused struct cmdline *cl,
6821 : : __rte_unused void *data)
6822 : : {
6823 : : struct cmd_showcfg_result *res = parsed_result;
6824 : 0 : if (!strcmp(res->what, "rxtx"))
6825 : 0 : rxtx_config_display();
6826 : 0 : else if (!strcmp(res->what, "cores"))
6827 : 0 : fwd_lcores_config_display();
6828 : 0 : else if (!strcmp(res->what, "fwd"))
6829 : 0 : pkt_fwd_config_display(&cur_fwd_config);
6830 : 0 : else if (!strcmp(res->what, "rxoffs"))
6831 : 0 : show_rx_pkt_offsets();
6832 : 0 : else if (!strcmp(res->what, "rxpkts"))
6833 : 0 : show_rx_pkt_segments();
6834 : 0 : else if (!strcmp(res->what, "rxhdrs"))
6835 : 0 : show_rx_pkt_hdrs();
6836 : 0 : else if (!strcmp(res->what, "txpkts"))
6837 : 0 : show_tx_pkt_segments();
6838 : 0 : else if (!strcmp(res->what, "txtimes"))
6839 : 0 : show_tx_pkt_times();
6840 : 0 : }
6841 : :
6842 : : static cmdline_parse_token_string_t cmd_showcfg_show =
6843 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6844 : : static cmdline_parse_token_string_t cmd_showcfg_port =
6845 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6846 : : static cmdline_parse_token_string_t cmd_showcfg_what =
6847 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6848 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
6849 : :
6850 : : static cmdline_parse_inst_t cmd_showcfg = {
6851 : : .f = cmd_showcfg_parsed,
6852 : : .data = NULL,
6853 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
6854 : : .tokens = {
6855 : : (void *)&cmd_showcfg_show,
6856 : : (void *)&cmd_showcfg_port,
6857 : : (void *)&cmd_showcfg_what,
6858 : : NULL,
6859 : : },
6860 : : };
6861 : :
6862 : : /* *** SHOW ALL PORT INFO *** */
6863 : : struct cmd_showportall_result {
6864 : : cmdline_fixed_string_t show;
6865 : : cmdline_fixed_string_t port;
6866 : : cmdline_fixed_string_t what;
6867 : : cmdline_fixed_string_t all;
6868 : : };
6869 : :
6870 : 0 : static void cmd_showportall_parsed(void *parsed_result,
6871 : : __rte_unused struct cmdline *cl,
6872 : : __rte_unused void *data)
6873 : : {
6874 : : portid_t i;
6875 : :
6876 : : struct cmd_showportall_result *res = parsed_result;
6877 : 0 : if (!strcmp(res->show, "clear")) {
6878 : 0 : if (!strcmp(res->what, "stats"))
6879 : 0 : RTE_ETH_FOREACH_DEV(i)
6880 : 0 : nic_stats_clear(i);
6881 : 0 : else if (!strcmp(res->what, "xstats"))
6882 : 0 : RTE_ETH_FOREACH_DEV(i)
6883 : 0 : nic_xstats_clear(i);
6884 : 0 : } else if (!strcmp(res->what, "info"))
6885 : 0 : RTE_ETH_FOREACH_DEV(i)
6886 : 0 : port_infos_display(i);
6887 : 0 : else if (!strcmp(res->what, "summary")) {
6888 : 0 : port_summary_header_display();
6889 : 0 : RTE_ETH_FOREACH_DEV(i)
6890 : 0 : port_summary_display(i);
6891 : : }
6892 : 0 : else if (!strcmp(res->what, "stats"))
6893 : 0 : RTE_ETH_FOREACH_DEV(i)
6894 : 0 : nic_stats_display(i);
6895 : 0 : else if (!strcmp(res->what, "xstats"))
6896 : 0 : RTE_ETH_FOREACH_DEV(i)
6897 : 0 : nic_xstats_display(i);
6898 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
6899 : 0 : else if (!strcmp(res->what, "fdir"))
6900 : 0 : RTE_ETH_FOREACH_DEV(i)
6901 : 0 : fdir_get_infos(i);
6902 : : #endif
6903 : 0 : else if (!strcmp(res->what, "dcb_tc"))
6904 : 0 : RTE_ETH_FOREACH_DEV(i)
6905 : 0 : port_dcb_info_display(i);
6906 : 0 : }
6907 : :
6908 : : static cmdline_parse_token_string_t cmd_showportall_show =
6909 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6910 : : "show#clear");
6911 : : static cmdline_parse_token_string_t cmd_showportall_port =
6912 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6913 : : static cmdline_parse_token_string_t cmd_showportall_what =
6914 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6915 : : "info#summary#stats#xstats#fdir#dcb_tc");
6916 : : static cmdline_parse_token_string_t cmd_showportall_all =
6917 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6918 : : static cmdline_parse_inst_t cmd_showportall = {
6919 : : .f = cmd_showportall_parsed,
6920 : : .data = NULL,
6921 : : .help_str = "show|clear port "
6922 : : "info|summary|stats|xstats|fdir|dcb_tc all",
6923 : : .tokens = {
6924 : : (void *)&cmd_showportall_show,
6925 : : (void *)&cmd_showportall_port,
6926 : : (void *)&cmd_showportall_what,
6927 : : (void *)&cmd_showportall_all,
6928 : : NULL,
6929 : : },
6930 : : };
6931 : :
6932 : : /* *** SHOW PORT INFO *** */
6933 : : struct cmd_showport_result {
6934 : : cmdline_fixed_string_t show;
6935 : : cmdline_fixed_string_t port;
6936 : : cmdline_fixed_string_t what;
6937 : : uint16_t portnum;
6938 : : };
6939 : :
6940 : 0 : static void cmd_showport_parsed(void *parsed_result,
6941 : : __rte_unused struct cmdline *cl,
6942 : : __rte_unused void *data)
6943 : : {
6944 : : struct cmd_showport_result *res = parsed_result;
6945 : 0 : if (!strcmp(res->show, "clear")) {
6946 : 0 : if (!strcmp(res->what, "stats"))
6947 : 0 : nic_stats_clear(res->portnum);
6948 : 0 : else if (!strcmp(res->what, "xstats"))
6949 : 0 : nic_xstats_clear(res->portnum);
6950 : 0 : } else if (!strcmp(res->what, "info"))
6951 : 0 : port_infos_display(res->portnum);
6952 : 0 : else if (!strcmp(res->what, "summary")) {
6953 : 0 : port_summary_header_display();
6954 : 0 : port_summary_display(res->portnum);
6955 : : }
6956 : 0 : else if (!strcmp(res->what, "stats"))
6957 : 0 : nic_stats_display(res->portnum);
6958 : 0 : else if (!strcmp(res->what, "xstats"))
6959 : 0 : nic_xstats_display(res->portnum);
6960 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
6961 : 0 : else if (!strcmp(res->what, "fdir"))
6962 : 0 : fdir_get_infos(res->portnum);
6963 : : #endif
6964 : 0 : else if (!strcmp(res->what, "dcb_tc"))
6965 : 0 : port_dcb_info_display(res->portnum);
6966 : 0 : }
6967 : :
6968 : : static cmdline_parse_token_string_t cmd_showport_show =
6969 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6970 : : "show#clear");
6971 : : static cmdline_parse_token_string_t cmd_showport_port =
6972 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6973 : : static cmdline_parse_token_string_t cmd_showport_what =
6974 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6975 : : "info#summary#stats#xstats#fdir#dcb_tc");
6976 : : static cmdline_parse_token_num_t cmd_showport_portnum =
6977 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
6978 : :
6979 : : static cmdline_parse_inst_t cmd_showport = {
6980 : : .f = cmd_showport_parsed,
6981 : : .data = NULL,
6982 : : .help_str = "show|clear port "
6983 : : "info|summary|stats|xstats|fdir|dcb_tc "
6984 : : "<port_id>",
6985 : : .tokens = {
6986 : : (void *)&cmd_showport_show,
6987 : : (void *)&cmd_showport_port,
6988 : : (void *)&cmd_showport_what,
6989 : : (void *)&cmd_showport_portnum,
6990 : : NULL,
6991 : : },
6992 : : };
6993 : :
6994 : : /* *** show port representors information *** */
6995 : : struct cmd_representor_info_result {
6996 : : cmdline_fixed_string_t cmd_show;
6997 : : cmdline_fixed_string_t cmd_port;
6998 : : cmdline_fixed_string_t cmd_info;
6999 : : cmdline_fixed_string_t cmd_keyword;
7000 : : portid_t cmd_pid;
7001 : : };
7002 : :
7003 : : static void
7004 : 0 : cmd_representor_info_parsed(void *parsed_result,
7005 : : __rte_unused struct cmdline *cl,
7006 : : __rte_unused void *data)
7007 : : {
7008 : : struct cmd_representor_info_result *res = parsed_result;
7009 : : struct rte_eth_representor_info *info;
7010 : : struct rte_eth_representor_range *range;
7011 : : uint32_t range_diff;
7012 : : uint32_t i;
7013 : : int ret;
7014 : : int num;
7015 : :
7016 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7017 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7018 : 0 : return;
7019 : : }
7020 : :
7021 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7022 : 0 : if (ret < 0) {
7023 : 0 : fprintf(stderr,
7024 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7025 : 0 : res->cmd_pid, rte_strerror(-ret));
7026 : 0 : return;
7027 : : }
7028 : : num = ret;
7029 : :
7030 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7031 : 0 : if (info == NULL) {
7032 : 0 : fprintf(stderr,
7033 : : "Failed to allocate memory for representor info for port %hu\n",
7034 : 0 : res->cmd_pid);
7035 : 0 : return;
7036 : : }
7037 : 0 : info->nb_ranges_alloc = num;
7038 : :
7039 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7040 : 0 : if (ret < 0) {
7041 : 0 : fprintf(stderr,
7042 : : "Failed to get the representor info for port %hu: %s\n",
7043 : 0 : res->cmd_pid, rte_strerror(-ret));
7044 : 0 : free(info);
7045 : 0 : return;
7046 : : }
7047 : :
7048 : 0 : printf("Port controller: %hu\n", info->controller);
7049 : 0 : printf("Port PF: %hu\n", info->pf);
7050 : :
7051 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7052 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7053 : : range = &info->ranges[i];
7054 : 0 : range_diff = range->id_end - range->id_base;
7055 : :
7056 : 0 : printf("%u. ", i + 1);
7057 : 0 : printf("'%s' ", range->name);
7058 : 0 : if (range_diff > 0)
7059 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7060 : : else
7061 : 0 : printf("[%u]: ", range->id_base);
7062 : :
7063 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7064 : :
7065 : 0 : switch (range->type) {
7066 : : case RTE_ETH_REPRESENTOR_NONE:
7067 : : printf(", NONE\n");
7068 : : break;
7069 : 0 : case RTE_ETH_REPRESENTOR_VF:
7070 : 0 : if (range_diff > 0)
7071 : 0 : printf(", VF %d..%d\n", range->vf,
7072 : 0 : range->vf + range_diff);
7073 : : else
7074 : 0 : printf(", VF %d\n", range->vf);
7075 : : break;
7076 : 0 : case RTE_ETH_REPRESENTOR_SF:
7077 : 0 : printf(", SF %d\n", range->sf);
7078 : : break;
7079 : 0 : case RTE_ETH_REPRESENTOR_PF:
7080 : 0 : if (range_diff > 0)
7081 : 0 : printf("..%d\n", range->pf + range_diff);
7082 : : else
7083 : : printf("\n");
7084 : : break;
7085 : 0 : default:
7086 : : printf(", UNKNOWN TYPE %d\n", range->type);
7087 : : break;
7088 : : }
7089 : : }
7090 : :
7091 : 0 : free(info);
7092 : : }
7093 : :
7094 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7095 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7096 : : cmd_show, "show");
7097 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7098 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7099 : : cmd_port, "port");
7100 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7101 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7102 : : cmd_info, "info");
7103 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7104 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7105 : : cmd_pid, RTE_UINT16);
7106 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7107 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7108 : : cmd_keyword, "representor");
7109 : :
7110 : : static cmdline_parse_inst_t cmd_representor_info = {
7111 : : .f = cmd_representor_info_parsed,
7112 : : .data = NULL,
7113 : : .help_str = "show port info <port_id> representor",
7114 : : .tokens = {
7115 : : (void *)&cmd_representor_info_show,
7116 : : (void *)&cmd_representor_info_port,
7117 : : (void *)&cmd_representor_info_info,
7118 : : (void *)&cmd_representor_info_pid,
7119 : : (void *)&cmd_representor_info_keyword,
7120 : : NULL,
7121 : : },
7122 : : };
7123 : :
7124 : :
7125 : : /* *** SHOW DEVICE INFO *** */
7126 : : struct cmd_showdevice_result {
7127 : : cmdline_fixed_string_t show;
7128 : : cmdline_fixed_string_t device;
7129 : : cmdline_fixed_string_t what;
7130 : : cmdline_fixed_string_t identifier;
7131 : : };
7132 : :
7133 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7134 : : __rte_unused struct cmdline *cl,
7135 : : __rte_unused void *data)
7136 : : {
7137 : : struct cmd_showdevice_result *res = parsed_result;
7138 : 0 : if (!strcmp(res->what, "info")) {
7139 : 0 : if (!strcmp(res->identifier, "all"))
7140 : 0 : device_infos_display(NULL);
7141 : : else
7142 : 0 : device_infos_display(res->identifier);
7143 : : }
7144 : 0 : }
7145 : :
7146 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7147 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7148 : : "show");
7149 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7150 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7151 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7152 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7153 : : "info");
7154 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7155 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7156 : : identifier, NULL);
7157 : :
7158 : : static cmdline_parse_inst_t cmd_showdevice = {
7159 : : .f = cmd_showdevice_parsed,
7160 : : .data = NULL,
7161 : : .help_str = "show device info <identifier>|all",
7162 : : .tokens = {
7163 : : (void *)&cmd_showdevice_show,
7164 : : (void *)&cmd_showdevice_device,
7165 : : (void *)&cmd_showdevice_what,
7166 : : (void *)&cmd_showdevice_identifier,
7167 : : NULL,
7168 : : },
7169 : : };
7170 : :
7171 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7172 : : struct cmd_showeeprom_result {
7173 : : cmdline_fixed_string_t show;
7174 : : cmdline_fixed_string_t port;
7175 : : uint16_t portnum;
7176 : : cmdline_fixed_string_t type;
7177 : : };
7178 : :
7179 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7180 : : __rte_unused struct cmdline *cl,
7181 : : __rte_unused void *data)
7182 : : {
7183 : : struct cmd_showeeprom_result *res = parsed_result;
7184 : :
7185 : 0 : if (!strcmp(res->type, "eeprom"))
7186 : 0 : port_eeprom_display(res->portnum);
7187 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7188 : 0 : port_module_eeprom_display(res->portnum);
7189 : : else
7190 : 0 : fprintf(stderr, "Unknown argument\n");
7191 : 0 : }
7192 : :
7193 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7194 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7195 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7196 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7197 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7198 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7199 : : RTE_UINT16);
7200 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7201 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7202 : :
7203 : : static cmdline_parse_inst_t cmd_showeeprom = {
7204 : : .f = cmd_showeeprom_parsed,
7205 : : .data = NULL,
7206 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7207 : : .tokens = {
7208 : : (void *)&cmd_showeeprom_show,
7209 : : (void *)&cmd_showeeprom_port,
7210 : : (void *)&cmd_showeeprom_portnum,
7211 : : (void *)&cmd_showeeprom_type,
7212 : : NULL,
7213 : : },
7214 : : };
7215 : :
7216 : : /* *** SHOW QUEUE INFO *** */
7217 : : struct cmd_showqueue_result {
7218 : : cmdline_fixed_string_t show;
7219 : : cmdline_fixed_string_t type;
7220 : : cmdline_fixed_string_t what;
7221 : : uint16_t portnum;
7222 : : uint16_t queuenum;
7223 : : };
7224 : :
7225 : : static void
7226 : 0 : cmd_showqueue_parsed(void *parsed_result,
7227 : : __rte_unused struct cmdline *cl,
7228 : : __rte_unused void *data)
7229 : : {
7230 : : struct cmd_showqueue_result *res = parsed_result;
7231 : :
7232 : 0 : if (!strcmp(res->type, "rxq"))
7233 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7234 : 0 : else if (!strcmp(res->type, "txq"))
7235 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7236 : 0 : }
7237 : :
7238 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7239 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7240 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7241 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7242 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7243 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7244 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7245 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7246 : : RTE_UINT16);
7247 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7248 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7249 : : RTE_UINT16);
7250 : :
7251 : : static cmdline_parse_inst_t cmd_showqueue = {
7252 : : .f = cmd_showqueue_parsed,
7253 : : .data = NULL,
7254 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7255 : : .tokens = {
7256 : : (void *)&cmd_showqueue_show,
7257 : : (void *)&cmd_showqueue_type,
7258 : : (void *)&cmd_showqueue_what,
7259 : : (void *)&cmd_showqueue_portnum,
7260 : : (void *)&cmd_showqueue_queuenum,
7261 : : NULL,
7262 : : },
7263 : : };
7264 : :
7265 : : /* show/clear fwd engine statistics */
7266 : : struct fwd_result {
7267 : : cmdline_fixed_string_t action;
7268 : : cmdline_fixed_string_t fwd;
7269 : : cmdline_fixed_string_t stats;
7270 : : cmdline_fixed_string_t all;
7271 : : };
7272 : :
7273 : : static cmdline_parse_token_string_t cmd_fwd_action =
7274 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7275 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
7276 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7277 : : static cmdline_parse_token_string_t cmd_fwd_stats =
7278 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7279 : : static cmdline_parse_token_string_t cmd_fwd_all =
7280 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7281 : :
7282 : : static void
7283 : 0 : cmd_showfwdall_parsed(void *parsed_result,
7284 : : __rte_unused struct cmdline *cl,
7285 : : __rte_unused void *data)
7286 : : {
7287 : : struct fwd_result *res = parsed_result;
7288 : :
7289 : 0 : if (!strcmp(res->action, "show"))
7290 : 0 : fwd_stats_display();
7291 : : else
7292 : 0 : fwd_stats_reset();
7293 : 0 : }
7294 : :
7295 : : static cmdline_parse_inst_t cmd_showfwdall = {
7296 : : .f = cmd_showfwdall_parsed,
7297 : : .data = NULL,
7298 : : .help_str = "show|clear fwd stats all",
7299 : : .tokens = {
7300 : : (void *)&cmd_fwd_action,
7301 : : (void *)&cmd_fwd_fwd,
7302 : : (void *)&cmd_fwd_stats,
7303 : : (void *)&cmd_fwd_all,
7304 : : NULL,
7305 : : },
7306 : : };
7307 : :
7308 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7309 : : struct cmd_read_rxd_txd_result {
7310 : : cmdline_fixed_string_t read;
7311 : : cmdline_fixed_string_t rxd_txd;
7312 : : portid_t port_id;
7313 : : uint16_t queue_id;
7314 : : uint16_t desc_id;
7315 : : };
7316 : :
7317 : : static void
7318 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
7319 : : __rte_unused struct cmdline *cl,
7320 : : __rte_unused void *data)
7321 : : {
7322 : : struct cmd_read_rxd_txd_result *res = parsed_result;
7323 : :
7324 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
7325 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7326 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
7327 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7328 : 0 : }
7329 : :
7330 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7331 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7332 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7333 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7334 : : "rxd#txd");
7335 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7336 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
7337 : : RTE_UINT16);
7338 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7339 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
7340 : : RTE_UINT16);
7341 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7342 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
7343 : : RTE_UINT16);
7344 : :
7345 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
7346 : : .f = cmd_read_rxd_txd_parsed,
7347 : : .data = NULL,
7348 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7349 : : .tokens = {
7350 : : (void *)&cmd_read_rxd_txd_read,
7351 : : (void *)&cmd_read_rxd_txd_rxd_txd,
7352 : : (void *)&cmd_read_rxd_txd_port_id,
7353 : : (void *)&cmd_read_rxd_txd_queue_id,
7354 : : (void *)&cmd_read_rxd_txd_desc_id,
7355 : : NULL,
7356 : : },
7357 : : };
7358 : :
7359 : : /* *** QUIT *** */
7360 : : struct cmd_quit_result {
7361 : : cmdline_fixed_string_t quit;
7362 : : };
7363 : :
7364 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
7365 : : struct cmdline *cl,
7366 : : __rte_unused void *data)
7367 : : {
7368 : 0 : cmdline_quit(cl);
7369 : 0 : cl_quit = 1;
7370 : 0 : }
7371 : :
7372 : : static cmdline_parse_token_string_t cmd_quit_quit =
7373 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7374 : :
7375 : : static cmdline_parse_inst_t cmd_quit = {
7376 : : .f = cmd_quit_parsed,
7377 : : .data = NULL,
7378 : : .help_str = "quit: Exit application",
7379 : : .tokens = {
7380 : : (void *)&cmd_quit_quit,
7381 : : NULL,
7382 : : },
7383 : : };
7384 : :
7385 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7386 : : struct cmd_mac_addr_result {
7387 : : cmdline_fixed_string_t mac_addr_cmd;
7388 : : cmdline_fixed_string_t what;
7389 : : uint16_t port_num;
7390 : : struct rte_ether_addr address;
7391 : : };
7392 : :
7393 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
7394 : : __rte_unused struct cmdline *cl,
7395 : : __rte_unused void *data)
7396 : : {
7397 : : struct cmd_mac_addr_result *res = parsed_result;
7398 : : int ret;
7399 : :
7400 : 0 : if (strcmp(res->what, "add") == 0)
7401 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7402 : 0 : else if (strcmp(res->what, "set") == 0)
7403 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7404 : : &res->address);
7405 : : else
7406 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7407 : :
7408 : : /* check the return value and print it if is < 0 */
7409 : 0 : if(ret < 0)
7410 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
7411 : :
7412 : 0 : }
7413 : :
7414 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
7415 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7416 : : "mac_addr");
7417 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
7418 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7419 : : "add#remove#set");
7420 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
7421 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7422 : : RTE_UINT16);
7423 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7424 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7425 : :
7426 : : static cmdline_parse_inst_t cmd_mac_addr = {
7427 : : .f = cmd_mac_addr_parsed,
7428 : : .data = (void *)0,
7429 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7430 : : "Add/Remove/Set MAC address on port_id",
7431 : : .tokens = {
7432 : : (void *)&cmd_mac_addr_cmd,
7433 : : (void *)&cmd_mac_addr_what,
7434 : : (void *)&cmd_mac_addr_portnum,
7435 : : (void *)&cmd_mac_addr_addr,
7436 : : NULL,
7437 : : },
7438 : : };
7439 : :
7440 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7441 : : struct cmd_eth_peer_result {
7442 : : cmdline_fixed_string_t set;
7443 : : cmdline_fixed_string_t eth_peer;
7444 : : portid_t port_id;
7445 : : cmdline_fixed_string_t peer_addr;
7446 : : };
7447 : :
7448 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
7449 : : __rte_unused struct cmdline *cl,
7450 : : __rte_unused void *data)
7451 : : {
7452 : : struct cmd_eth_peer_result *res = parsed_result;
7453 : :
7454 : 0 : if (test_done == 0) {
7455 : 0 : fprintf(stderr, "Please stop forwarding first\n");
7456 : 0 : return;
7457 : : }
7458 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
7459 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
7460 : 0 : fwd_config_setup();
7461 : : }
7462 : : }
7463 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
7464 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7465 : : static cmdline_parse_token_string_t cmd_eth_peer =
7466 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7467 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
7468 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
7469 : : RTE_UINT16);
7470 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
7471 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7472 : :
7473 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7474 : : .f = cmd_set_eth_peer_parsed,
7475 : : .data = NULL,
7476 : : .help_str = "set eth-peer <port_id> <peer_mac>",
7477 : : .tokens = {
7478 : : (void *)&cmd_eth_peer_set,
7479 : : (void *)&cmd_eth_peer,
7480 : : (void *)&cmd_eth_peer_port_id,
7481 : : (void *)&cmd_eth_peer_addr,
7482 : : NULL,
7483 : : },
7484 : : };
7485 : :
7486 : : /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7487 : : struct cmd_set_qmap_result {
7488 : : cmdline_fixed_string_t set;
7489 : : cmdline_fixed_string_t qmap;
7490 : : cmdline_fixed_string_t what;
7491 : : portid_t port_id;
7492 : : uint16_t queue_id;
7493 : : uint8_t map_value;
7494 : : };
7495 : :
7496 : : static void
7497 : 0 : cmd_set_qmap_parsed(void *parsed_result,
7498 : : __rte_unused struct cmdline *cl,
7499 : : __rte_unused void *data)
7500 : : {
7501 : : struct cmd_set_qmap_result *res = parsed_result;
7502 : 0 : int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7503 : :
7504 : 0 : set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7505 : 0 : }
7506 : :
7507 : : static cmdline_parse_token_string_t cmd_setqmap_set =
7508 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7509 : : set, "set");
7510 : : static cmdline_parse_token_string_t cmd_setqmap_qmap =
7511 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7512 : : qmap, "stat_qmap");
7513 : : static cmdline_parse_token_string_t cmd_setqmap_what =
7514 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7515 : : what, "tx#rx");
7516 : : static cmdline_parse_token_num_t cmd_setqmap_portid =
7517 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7518 : : port_id, RTE_UINT16);
7519 : : static cmdline_parse_token_num_t cmd_setqmap_queueid =
7520 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7521 : : queue_id, RTE_UINT16);
7522 : : static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7523 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7524 : : map_value, RTE_UINT8);
7525 : :
7526 : : static cmdline_parse_inst_t cmd_set_qmap = {
7527 : : .f = cmd_set_qmap_parsed,
7528 : : .data = NULL,
7529 : : .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7530 : : "Set statistics mapping value on tx|rx queue_id of port_id",
7531 : : .tokens = {
7532 : : (void *)&cmd_setqmap_set,
7533 : : (void *)&cmd_setqmap_qmap,
7534 : : (void *)&cmd_setqmap_what,
7535 : : (void *)&cmd_setqmap_portid,
7536 : : (void *)&cmd_setqmap_queueid,
7537 : : (void *)&cmd_setqmap_mapvalue,
7538 : : NULL,
7539 : : },
7540 : : };
7541 : :
7542 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7543 : : struct cmd_set_xstats_hide_zero_result {
7544 : : cmdline_fixed_string_t keyword;
7545 : : cmdline_fixed_string_t name;
7546 : : cmdline_fixed_string_t on_off;
7547 : : };
7548 : :
7549 : : static void
7550 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7551 : : __rte_unused struct cmdline *cl,
7552 : : __rte_unused void *data)
7553 : : {
7554 : : struct cmd_set_xstats_hide_zero_result *res;
7555 : : uint16_t on_off = 0;
7556 : :
7557 : : res = parsed_result;
7558 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7559 : 0 : set_xstats_hide_zero(on_off);
7560 : 0 : }
7561 : :
7562 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7563 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7564 : : keyword, "set");
7565 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7566 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7567 : : name, "xstats-hide-zero");
7568 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7569 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7570 : : on_off, "on#off");
7571 : :
7572 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7573 : : .f = cmd_set_xstats_hide_zero_parsed,
7574 : : .data = NULL,
7575 : : .help_str = "set xstats-hide-zero on|off",
7576 : : .tokens = {
7577 : : (void *)&cmd_set_xstats_hide_zero_keyword,
7578 : : (void *)&cmd_set_xstats_hide_zero_name,
7579 : : (void *)&cmd_set_xstats_hide_zero_on_off,
7580 : : NULL,
7581 : : },
7582 : : };
7583 : :
7584 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
7585 : : struct cmd_set_record_core_cycles_result {
7586 : : cmdline_fixed_string_t keyword;
7587 : : cmdline_fixed_string_t name;
7588 : : cmdline_fixed_string_t on_off;
7589 : : };
7590 : :
7591 : : static void
7592 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
7593 : : __rte_unused struct cmdline *cl,
7594 : : __rte_unused void *data)
7595 : : {
7596 : : struct cmd_set_record_core_cycles_result *res;
7597 : : uint16_t on_off = 0;
7598 : :
7599 : : res = parsed_result;
7600 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7601 : 0 : set_record_core_cycles(on_off);
7602 : 0 : }
7603 : :
7604 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
7605 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7606 : : keyword, "set");
7607 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
7608 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7609 : : name, "record-core-cycles");
7610 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
7611 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7612 : : on_off, "on#off");
7613 : :
7614 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
7615 : : .f = cmd_set_record_core_cycles_parsed,
7616 : : .data = NULL,
7617 : : .help_str = "set record-core-cycles on|off",
7618 : : .tokens = {
7619 : : (void *)&cmd_set_record_core_cycles_keyword,
7620 : : (void *)&cmd_set_record_core_cycles_name,
7621 : : (void *)&cmd_set_record_core_cycles_on_off,
7622 : : NULL,
7623 : : },
7624 : : };
7625 : :
7626 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
7627 : : struct cmd_set_record_burst_stats_result {
7628 : : cmdline_fixed_string_t keyword;
7629 : : cmdline_fixed_string_t name;
7630 : : cmdline_fixed_string_t on_off;
7631 : : };
7632 : :
7633 : : static void
7634 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
7635 : : __rte_unused struct cmdline *cl,
7636 : : __rte_unused void *data)
7637 : : {
7638 : : struct cmd_set_record_burst_stats_result *res;
7639 : : uint16_t on_off = 0;
7640 : :
7641 : : res = parsed_result;
7642 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7643 : 0 : set_record_burst_stats(on_off);
7644 : 0 : }
7645 : :
7646 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
7647 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7648 : : keyword, "set");
7649 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
7650 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7651 : : name, "record-burst-stats");
7652 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
7653 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7654 : : on_off, "on#off");
7655 : :
7656 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
7657 : : .f = cmd_set_record_burst_stats_parsed,
7658 : : .data = NULL,
7659 : : .help_str = "set record-burst-stats on|off",
7660 : : .tokens = {
7661 : : (void *)&cmd_set_record_burst_stats_keyword,
7662 : : (void *)&cmd_set_record_burst_stats_name,
7663 : : (void *)&cmd_set_record_burst_stats_on_off,
7664 : : NULL,
7665 : : },
7666 : : };
7667 : :
7668 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
7669 : : struct cmd_set_uc_hash_table {
7670 : : cmdline_fixed_string_t set;
7671 : : cmdline_fixed_string_t port;
7672 : : portid_t port_id;
7673 : : cmdline_fixed_string_t what;
7674 : : struct rte_ether_addr address;
7675 : : cmdline_fixed_string_t mode;
7676 : : };
7677 : :
7678 : : static void
7679 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
7680 : : __rte_unused struct cmdline *cl,
7681 : : __rte_unused void *data)
7682 : : {
7683 : : int ret=0;
7684 : : struct cmd_set_uc_hash_table *res = parsed_result;
7685 : :
7686 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7687 : :
7688 : 0 : if (strcmp(res->what, "uta") == 0)
7689 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7690 : : &res->address,(uint8_t)is_on);
7691 : 0 : if (ret < 0)
7692 : 0 : fprintf(stderr,
7693 : : "bad unicast hash table parameter, return code = %d\n",
7694 : : ret);
7695 : :
7696 : 0 : }
7697 : :
7698 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
7699 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7700 : : set, "set");
7701 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
7702 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7703 : : port, "port");
7704 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7705 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7706 : : port_id, RTE_UINT16);
7707 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
7708 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7709 : : what, "uta");
7710 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7711 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7712 : : address);
7713 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7714 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7715 : : mode, "on#off");
7716 : :
7717 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7718 : : .f = cmd_set_uc_hash_parsed,
7719 : : .data = NULL,
7720 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
7721 : : .tokens = {
7722 : : (void *)&cmd_set_uc_hash_set,
7723 : : (void *)&cmd_set_uc_hash_port,
7724 : : (void *)&cmd_set_uc_hash_portid,
7725 : : (void *)&cmd_set_uc_hash_what,
7726 : : (void *)&cmd_set_uc_hash_mac,
7727 : : (void *)&cmd_set_uc_hash_mode,
7728 : : NULL,
7729 : : },
7730 : : };
7731 : :
7732 : : struct cmd_set_uc_all_hash_table {
7733 : : cmdline_fixed_string_t set;
7734 : : cmdline_fixed_string_t port;
7735 : : portid_t port_id;
7736 : : cmdline_fixed_string_t what;
7737 : : cmdline_fixed_string_t value;
7738 : : cmdline_fixed_string_t mode;
7739 : : };
7740 : :
7741 : : static void
7742 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
7743 : : __rte_unused struct cmdline *cl,
7744 : : __rte_unused void *data)
7745 : : {
7746 : : int ret=0;
7747 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
7748 : :
7749 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7750 : :
7751 : 0 : if ((strcmp(res->what, "uta") == 0) &&
7752 : 0 : (strcmp(res->value, "all") == 0))
7753 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7754 : 0 : if (ret < 0)
7755 : 0 : fprintf(stderr,
7756 : : "bad unicast hash table parameter, return code = %d\n",
7757 : : ret);
7758 : 0 : }
7759 : :
7760 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7761 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7762 : : set, "set");
7763 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7764 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7765 : : port, "port");
7766 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7767 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7768 : : port_id, RTE_UINT16);
7769 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7770 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7771 : : what, "uta");
7772 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7773 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7774 : : value,"all");
7775 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7776 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7777 : : mode, "on#off");
7778 : :
7779 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7780 : : .f = cmd_set_uc_all_hash_parsed,
7781 : : .data = NULL,
7782 : : .help_str = "set port <port_id> uta all on|off",
7783 : : .tokens = {
7784 : : (void *)&cmd_set_uc_all_hash_set,
7785 : : (void *)&cmd_set_uc_all_hash_port,
7786 : : (void *)&cmd_set_uc_all_hash_portid,
7787 : : (void *)&cmd_set_uc_all_hash_what,
7788 : : (void *)&cmd_set_uc_all_hash_value,
7789 : : (void *)&cmd_set_uc_all_hash_mode,
7790 : : NULL,
7791 : : },
7792 : : };
7793 : :
7794 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7795 : : struct cmd_set_vf_traffic {
7796 : : cmdline_fixed_string_t set;
7797 : : cmdline_fixed_string_t port;
7798 : : portid_t port_id;
7799 : : cmdline_fixed_string_t vf;
7800 : : uint8_t vf_id;
7801 : : cmdline_fixed_string_t what;
7802 : : cmdline_fixed_string_t mode;
7803 : : };
7804 : :
7805 : : static void
7806 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
7807 : : __rte_unused struct cmdline *cl,
7808 : : __rte_unused void *data)
7809 : : {
7810 : : struct cmd_set_vf_traffic *res = parsed_result;
7811 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7812 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7813 : :
7814 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7815 : 0 : }
7816 : :
7817 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
7818 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7819 : : set, "set");
7820 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
7821 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7822 : : port, "port");
7823 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7824 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7825 : : port_id, RTE_UINT16);
7826 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7827 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7828 : : vf, "vf");
7829 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7830 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7831 : : vf_id, RTE_UINT8);
7832 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
7833 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7834 : : what, "tx#rx");
7835 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7836 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7837 : : mode, "on#off");
7838 : :
7839 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
7840 : : .f = cmd_set_vf_traffic_parsed,
7841 : : .data = NULL,
7842 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7843 : : .tokens = {
7844 : : (void *)&cmd_setvf_traffic_set,
7845 : : (void *)&cmd_setvf_traffic_port,
7846 : : (void *)&cmd_setvf_traffic_portid,
7847 : : (void *)&cmd_setvf_traffic_vf,
7848 : : (void *)&cmd_setvf_traffic_vfid,
7849 : : (void *)&cmd_setvf_traffic_what,
7850 : : (void *)&cmd_setvf_traffic_mode,
7851 : : NULL,
7852 : : },
7853 : : };
7854 : :
7855 : : /* *** CONFIGURE VF RECEIVE MODE *** */
7856 : : struct cmd_set_vf_rxmode {
7857 : : cmdline_fixed_string_t set;
7858 : : cmdline_fixed_string_t port;
7859 : : portid_t port_id;
7860 : : cmdline_fixed_string_t vf;
7861 : : uint8_t vf_id;
7862 : : cmdline_fixed_string_t what;
7863 : : cmdline_fixed_string_t mode;
7864 : : cmdline_fixed_string_t on;
7865 : : };
7866 : :
7867 : : static void
7868 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
7869 : : __rte_unused struct cmdline *cl,
7870 : : __rte_unused void *data)
7871 : : {
7872 : : int ret = -ENOTSUP;
7873 : : uint16_t vf_rxmode = 0;
7874 : : struct cmd_set_vf_rxmode *res = parsed_result;
7875 : :
7876 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7877 : 0 : if (!strcmp(res->what,"rxmode")) {
7878 : 0 : if (!strcmp(res->mode, "AUPE"))
7879 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
7880 : 0 : else if (!strcmp(res->mode, "ROPE"))
7881 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
7882 : 0 : else if (!strcmp(res->mode, "BAM"))
7883 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
7884 : 0 : else if (!strncmp(res->mode, "MPE",3))
7885 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
7886 : : }
7887 : :
7888 : : RTE_SET_USED(is_on);
7889 : : RTE_SET_USED(vf_rxmode);
7890 : :
7891 : : #ifdef RTE_NET_IXGBE
7892 : : if (ret == -ENOTSUP)
7893 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7894 : : vf_rxmode, (uint8_t)is_on);
7895 : : #endif
7896 : : #ifdef RTE_NET_BNXT
7897 : 0 : if (ret == -ENOTSUP)
7898 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7899 : : vf_rxmode, (uint8_t)is_on);
7900 : : #endif
7901 : 0 : if (ret < 0)
7902 : 0 : fprintf(stderr,
7903 : : "bad VF receive mode parameter, return code = %d\n",
7904 : : ret);
7905 : 0 : }
7906 : :
7907 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7908 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7909 : : set, "set");
7910 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7911 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7912 : : port, "port");
7913 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7914 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7915 : : port_id, RTE_UINT16);
7916 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7917 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7918 : : vf, "vf");
7919 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7920 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7921 : : vf_id, RTE_UINT8);
7922 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7923 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7924 : : what, "rxmode");
7925 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7926 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7927 : : mode, "AUPE#ROPE#BAM#MPE");
7928 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7929 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7930 : : on, "on#off");
7931 : :
7932 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
7933 : : .f = cmd_set_vf_rxmode_parsed,
7934 : : .data = NULL,
7935 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
7936 : : "AUPE|ROPE|BAM|MPE on|off",
7937 : : .tokens = {
7938 : : (void *)&cmd_set_vf_rxmode_set,
7939 : : (void *)&cmd_set_vf_rxmode_port,
7940 : : (void *)&cmd_set_vf_rxmode_portid,
7941 : : (void *)&cmd_set_vf_rxmode_vf,
7942 : : (void *)&cmd_set_vf_rxmode_vfid,
7943 : : (void *)&cmd_set_vf_rxmode_what,
7944 : : (void *)&cmd_set_vf_rxmode_mode,
7945 : : (void *)&cmd_set_vf_rxmode_on,
7946 : : NULL,
7947 : : },
7948 : : };
7949 : :
7950 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7951 : : struct cmd_vf_mac_addr_result {
7952 : : cmdline_fixed_string_t mac_addr_cmd;
7953 : : cmdline_fixed_string_t what;
7954 : : cmdline_fixed_string_t port;
7955 : : uint16_t port_num;
7956 : : cmdline_fixed_string_t vf;
7957 : : uint8_t vf_num;
7958 : : struct rte_ether_addr address;
7959 : : };
7960 : :
7961 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
7962 : : __rte_unused struct cmdline *cl,
7963 : : __rte_unused void *data)
7964 : : {
7965 : : struct cmd_vf_mac_addr_result *res = parsed_result;
7966 : : int ret = -ENOTSUP;
7967 : :
7968 : 0 : if (strcmp(res->what, "add") != 0)
7969 : : return;
7970 : :
7971 : : #ifdef RTE_NET_I40E
7972 : : if (ret == -ENOTSUP)
7973 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7974 : : &res->address);
7975 : : #endif
7976 : : #ifdef RTE_NET_BNXT
7977 : 0 : if (ret == -ENOTSUP)
7978 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7979 : 0 : res->vf_num);
7980 : : #endif
7981 : :
7982 : 0 : if(ret < 0)
7983 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7984 : :
7985 : : }
7986 : :
7987 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7988 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7989 : : mac_addr_cmd,"mac_addr");
7990 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7991 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7992 : : what,"add");
7993 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7994 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7995 : : port,"port");
7996 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
7997 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
7998 : : port_num, RTE_UINT16);
7999 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8000 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8001 : : vf,"vf");
8002 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8003 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8004 : : vf_num, RTE_UINT8);
8005 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8006 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8007 : : address);
8008 : :
8009 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8010 : : .f = cmd_vf_mac_addr_parsed,
8011 : : .data = (void *)0,
8012 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8013 : : "Add MAC address filtering for a VF on port_id",
8014 : : .tokens = {
8015 : : (void *)&cmd_vf_mac_addr_cmd,
8016 : : (void *)&cmd_vf_mac_addr_what,
8017 : : (void *)&cmd_vf_mac_addr_port,
8018 : : (void *)&cmd_vf_mac_addr_portnum,
8019 : : (void *)&cmd_vf_mac_addr_vf,
8020 : : (void *)&cmd_vf_mac_addr_vfnum,
8021 : : (void *)&cmd_vf_mac_addr_addr,
8022 : : NULL,
8023 : : },
8024 : : };
8025 : :
8026 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8027 : : struct cmd_vf_rx_vlan_filter {
8028 : : cmdline_fixed_string_t rx_vlan;
8029 : : cmdline_fixed_string_t what;
8030 : : uint16_t vlan_id;
8031 : : cmdline_fixed_string_t port;
8032 : : portid_t port_id;
8033 : : cmdline_fixed_string_t vf;
8034 : : uint64_t vf_mask;
8035 : : };
8036 : :
8037 : : static void
8038 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8039 : : __rte_unused struct cmdline *cl,
8040 : : __rte_unused void *data)
8041 : : {
8042 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8043 : : int ret = -ENOTSUP;
8044 : :
8045 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8046 : :
8047 : : #ifdef RTE_NET_IXGBE
8048 : : if (ret == -ENOTSUP)
8049 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8050 : 0 : res->vlan_id, res->vf_mask, is_add);
8051 : : #endif
8052 : : #ifdef RTE_NET_I40E
8053 : 0 : if (ret == -ENOTSUP)
8054 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8055 : 0 : res->vlan_id, res->vf_mask, is_add);
8056 : : #endif
8057 : : #ifdef RTE_NET_BNXT
8058 : 0 : if (ret == -ENOTSUP)
8059 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8060 : 0 : res->vlan_id, res->vf_mask, is_add);
8061 : : #endif
8062 : :
8063 : 0 : switch (ret) {
8064 : : case 0:
8065 : : break;
8066 : 0 : case -EINVAL:
8067 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8068 : 0 : res->vlan_id, res->vf_mask);
8069 : : break;
8070 : 0 : case -ENODEV:
8071 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8072 : : break;
8073 : 0 : case -ENOTSUP:
8074 : 0 : fprintf(stderr, "function not implemented or supported\n");
8075 : : break;
8076 : 0 : default:
8077 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8078 : : }
8079 : 0 : }
8080 : :
8081 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8082 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8083 : : rx_vlan, "rx_vlan");
8084 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8085 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8086 : : what, "add#rm");
8087 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8088 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8089 : : vlan_id, RTE_UINT16);
8090 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8091 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8092 : : port, "port");
8093 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8094 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8095 : : port_id, RTE_UINT16);
8096 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8097 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8098 : : vf, "vf");
8099 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8100 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8101 : : vf_mask, RTE_UINT64);
8102 : :
8103 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8104 : : .f = cmd_vf_rx_vlan_filter_parsed,
8105 : : .data = NULL,
8106 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8107 : : "(vf_mask = hexadecimal VF mask)",
8108 : : .tokens = {
8109 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8110 : : (void *)&cmd_vf_rx_vlan_filter_what,
8111 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8112 : : (void *)&cmd_vf_rx_vlan_filter_port,
8113 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8114 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8115 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8116 : : NULL,
8117 : : },
8118 : : };
8119 : :
8120 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8121 : : struct cmd_queue_rate_limit_result {
8122 : : cmdline_fixed_string_t set;
8123 : : cmdline_fixed_string_t port;
8124 : : uint16_t port_num;
8125 : : cmdline_fixed_string_t queue;
8126 : : uint8_t queue_num;
8127 : : cmdline_fixed_string_t rate;
8128 : : uint32_t rate_num;
8129 : : };
8130 : :
8131 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8132 : : __rte_unused struct cmdline *cl,
8133 : : __rte_unused void *data)
8134 : : {
8135 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8136 : : int ret = 0;
8137 : :
8138 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8139 : 0 : && (strcmp(res->queue, "queue") == 0)
8140 : 0 : && (strcmp(res->rate, "rate") == 0))
8141 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8142 : : res->rate_num);
8143 : 0 : if (ret < 0)
8144 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8145 : : strerror(-ret));
8146 : :
8147 : 0 : }
8148 : :
8149 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8150 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8151 : : set, "set");
8152 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8153 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8154 : : port, "port");
8155 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8156 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8157 : : port_num, RTE_UINT16);
8158 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8159 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8160 : : queue, "queue");
8161 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8162 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8163 : : queue_num, RTE_UINT8);
8164 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8165 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8166 : : rate, "rate");
8167 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8168 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8169 : : rate_num, RTE_UINT32);
8170 : :
8171 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8172 : : .f = cmd_queue_rate_limit_parsed,
8173 : : .data = (void *)0,
8174 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8175 : : "Set rate limit for a queue on port_id",
8176 : : .tokens = {
8177 : : (void *)&cmd_queue_rate_limit_set,
8178 : : (void *)&cmd_queue_rate_limit_port,
8179 : : (void *)&cmd_queue_rate_limit_portnum,
8180 : : (void *)&cmd_queue_rate_limit_queue,
8181 : : (void *)&cmd_queue_rate_limit_queuenum,
8182 : : (void *)&cmd_queue_rate_limit_rate,
8183 : : (void *)&cmd_queue_rate_limit_ratenum,
8184 : : NULL,
8185 : : },
8186 : : };
8187 : :
8188 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8189 : : struct cmd_vf_rate_limit_result {
8190 : : cmdline_fixed_string_t set;
8191 : : cmdline_fixed_string_t port;
8192 : : uint16_t port_num;
8193 : : cmdline_fixed_string_t vf;
8194 : : uint8_t vf_num;
8195 : : cmdline_fixed_string_t rate;
8196 : : uint32_t rate_num;
8197 : : cmdline_fixed_string_t q_msk;
8198 : : uint64_t q_msk_val;
8199 : : };
8200 : :
8201 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
8202 : : __rte_unused struct cmdline *cl,
8203 : : __rte_unused void *data)
8204 : : {
8205 : : struct cmd_vf_rate_limit_result *res = parsed_result;
8206 : : int ret = 0;
8207 : :
8208 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8209 : 0 : && (strcmp(res->vf, "vf") == 0)
8210 : 0 : && (strcmp(res->rate, "rate") == 0)
8211 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
8212 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
8213 : : res->rate_num, res->q_msk_val);
8214 : 0 : if (ret < 0)
8215 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
8216 : : strerror(-ret));
8217 : :
8218 : 0 : }
8219 : :
8220 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8221 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8222 : : set, "set");
8223 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8224 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8225 : : port, "port");
8226 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8227 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8228 : : port_num, RTE_UINT16);
8229 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8230 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8231 : : vf, "vf");
8232 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8233 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8234 : : vf_num, RTE_UINT8);
8235 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8236 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8237 : : rate, "rate");
8238 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8239 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8240 : : rate_num, RTE_UINT32);
8241 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8242 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8243 : : q_msk, "queue_mask");
8244 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8245 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8246 : : q_msk_val, RTE_UINT64);
8247 : :
8248 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
8249 : : .f = cmd_vf_rate_limit_parsed,
8250 : : .data = (void *)0,
8251 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8252 : : "queue_mask <queue_mask_value>: "
8253 : : "Set rate limit for queues of VF on port_id",
8254 : : .tokens = {
8255 : : (void *)&cmd_vf_rate_limit_set,
8256 : : (void *)&cmd_vf_rate_limit_port,
8257 : : (void *)&cmd_vf_rate_limit_portnum,
8258 : : (void *)&cmd_vf_rate_limit_vf,
8259 : : (void *)&cmd_vf_rate_limit_vfnum,
8260 : : (void *)&cmd_vf_rate_limit_rate,
8261 : : (void *)&cmd_vf_rate_limit_ratenum,
8262 : : (void *)&cmd_vf_rate_limit_q_msk,
8263 : : (void *)&cmd_vf_rate_limit_q_msk_val,
8264 : : NULL,
8265 : : },
8266 : : };
8267 : :
8268 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
8269 : : struct cmd_tunnel_udp_config {
8270 : : cmdline_fixed_string_t rx_vxlan_port;
8271 : : cmdline_fixed_string_t what;
8272 : : uint16_t udp_port;
8273 : : portid_t port_id;
8274 : : };
8275 : :
8276 : : static void
8277 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
8278 : : __rte_unused struct cmdline *cl,
8279 : : __rte_unused void *data)
8280 : : {
8281 : : struct cmd_tunnel_udp_config *res = parsed_result;
8282 : : struct rte_eth_udp_tunnel tunnel_udp;
8283 : : int ret;
8284 : :
8285 : 0 : tunnel_udp.udp_port = res->udp_port;
8286 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8287 : :
8288 : 0 : if (!strcmp(res->what, "add"))
8289 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8290 : : &tunnel_udp);
8291 : : else
8292 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8293 : : &tunnel_udp);
8294 : :
8295 : 0 : if (ret < 0)
8296 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
8297 : : strerror(-ret));
8298 : 0 : }
8299 : :
8300 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
8301 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8302 : : rx_vxlan_port, "rx_vxlan_port");
8303 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8304 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8305 : : what, "add#rm");
8306 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8307 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8308 : : udp_port, RTE_UINT16);
8309 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8310 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8311 : : port_id, RTE_UINT16);
8312 : :
8313 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
8314 : : .f = cmd_tunnel_udp_config_parsed,
8315 : : .data = (void *)0,
8316 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8317 : : "Add/Remove a tunneling UDP port filter",
8318 : : .tokens = {
8319 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
8320 : : (void *)&cmd_tunnel_udp_config_what,
8321 : : (void *)&cmd_tunnel_udp_config_udp_port,
8322 : : (void *)&cmd_tunnel_udp_config_port_id,
8323 : : NULL,
8324 : : },
8325 : : };
8326 : :
8327 : : struct cmd_config_tunnel_udp_port {
8328 : : cmdline_fixed_string_t port;
8329 : : cmdline_fixed_string_t config;
8330 : : portid_t port_id;
8331 : : cmdline_fixed_string_t udp_tunnel_port;
8332 : : cmdline_fixed_string_t action;
8333 : : cmdline_fixed_string_t tunnel_type;
8334 : : uint16_t udp_port;
8335 : : };
8336 : :
8337 : : static void
8338 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8339 : : __rte_unused struct cmdline *cl,
8340 : : __rte_unused void *data)
8341 : : {
8342 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
8343 : : struct rte_eth_udp_tunnel tunnel_udp;
8344 : : int ret = 0;
8345 : :
8346 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8347 : 0 : return;
8348 : :
8349 : 0 : tunnel_udp.udp_port = res->udp_port;
8350 : :
8351 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
8352 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8353 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
8354 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
8355 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
8356 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
8357 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
8358 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
8359 : : } else {
8360 : 0 : fprintf(stderr, "Invalid tunnel type\n");
8361 : 0 : return;
8362 : : }
8363 : :
8364 : 0 : if (!strcmp(res->action, "add"))
8365 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8366 : : &tunnel_udp);
8367 : : else
8368 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8369 : : &tunnel_udp);
8370 : :
8371 : 0 : if (ret < 0)
8372 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
8373 : : strerror(-ret));
8374 : : }
8375 : :
8376 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8377 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8378 : : "port");
8379 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8380 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8381 : : "config");
8382 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8383 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8384 : : RTE_UINT16);
8385 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8386 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8387 : : udp_tunnel_port,
8388 : : "udp_tunnel_port");
8389 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8390 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8391 : : "add#rm");
8392 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8393 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8394 : : "vxlan#geneve#vxlan-gpe#ecpri");
8395 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8396 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8397 : : RTE_UINT16);
8398 : :
8399 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8400 : : .f = cmd_cfg_tunnel_udp_port_parsed,
8401 : : .data = NULL,
8402 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
8403 : : "geneve|vxlan-gpe|ecpri <udp_port>",
8404 : : .tokens = {
8405 : : (void *)&cmd_config_tunnel_udp_port_port,
8406 : : (void *)&cmd_config_tunnel_udp_port_config,
8407 : : (void *)&cmd_config_tunnel_udp_port_port_id,
8408 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8409 : : (void *)&cmd_config_tunnel_udp_port_action,
8410 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8411 : : (void *)&cmd_config_tunnel_udp_port_value,
8412 : : NULL,
8413 : : },
8414 : : };
8415 : :
8416 : : /* ******************************************************************************** */
8417 : :
8418 : : struct cmd_dump_result {
8419 : : cmdline_fixed_string_t dump;
8420 : : };
8421 : :
8422 : : static void
8423 : 0 : dump_struct_sizes(void)
8424 : : {
8425 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8426 : : DUMP_SIZE(struct rte_mbuf);
8427 : : DUMP_SIZE(struct rte_mempool);
8428 : : DUMP_SIZE(struct rte_ring);
8429 : : #undef DUMP_SIZE
8430 : 0 : }
8431 : :
8432 : :
8433 : : /* Dump the socket memory statistics on console */
8434 : : static void
8435 : 0 : dump_socket_mem(FILE *f)
8436 : : {
8437 : : struct rte_malloc_socket_stats socket_stats;
8438 : : unsigned int i;
8439 : : size_t total = 0;
8440 : : size_t alloc = 0;
8441 : : size_t free = 0;
8442 : : unsigned int n_alloc = 0;
8443 : : unsigned int n_free = 0;
8444 : : static size_t last_allocs;
8445 : : static size_t last_total;
8446 : :
8447 : :
8448 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
8449 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
8450 : 0 : !socket_stats.heap_totalsz_bytes)
8451 : 0 : continue;
8452 : 0 : total += socket_stats.heap_totalsz_bytes;
8453 : 0 : alloc += socket_stats.heap_allocsz_bytes;
8454 : 0 : free += socket_stats.heap_freesz_bytes;
8455 : 0 : n_alloc += socket_stats.alloc_count;
8456 : 0 : n_free += socket_stats.free_count;
8457 : 0 : fprintf(f,
8458 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
8459 : : i,
8460 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
8461 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
8462 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
8463 : 0 : (double)socket_stats.heap_totalsz_bytes,
8464 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
8465 : : socket_stats.alloc_count,
8466 : : socket_stats.free_count);
8467 : : }
8468 : 0 : fprintf(f,
8469 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
8470 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
8471 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
8472 : 0 : (double)free / (1024 * 1024),
8473 : : n_alloc, n_free);
8474 : 0 : if (last_allocs)
8475 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
8476 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
8477 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
8478 : 0 : last_allocs = alloc;
8479 : 0 : last_total = total;
8480 : 0 : }
8481 : :
8482 : 0 : static void cmd_dump_parsed(void *parsed_result,
8483 : : __rte_unused struct cmdline *cl,
8484 : : __rte_unused void *data)
8485 : : {
8486 : : struct cmd_dump_result *res = parsed_result;
8487 : :
8488 : 0 : if (!strcmp(res->dump, "dump_physmem"))
8489 : 0 : rte_dump_physmem_layout(stdout);
8490 : 0 : else if (!strcmp(res->dump, "dump_socket_mem"))
8491 : 0 : dump_socket_mem(stdout);
8492 : 0 : else if (!strcmp(res->dump, "dump_memzone"))
8493 : 0 : rte_memzone_dump(stdout);
8494 : 0 : else if (!strcmp(res->dump, "dump_struct_sizes"))
8495 : 0 : dump_struct_sizes();
8496 : 0 : else if (!strcmp(res->dump, "dump_ring"))
8497 : 0 : rte_ring_list_dump(stdout);
8498 : 0 : else if (!strcmp(res->dump, "dump_mempool"))
8499 : 0 : rte_mempool_list_dump(stdout);
8500 : 0 : else if (!strcmp(res->dump, "dump_devargs"))
8501 : 0 : rte_devargs_dump(stdout);
8502 : 0 : else if (!strcmp(res->dump, "dump_lcores"))
8503 : 0 : rte_lcore_dump(stdout);
8504 : : #ifndef RTE_EXEC_ENV_WINDOWS
8505 : 0 : else if (!strcmp(res->dump, "dump_trace"))
8506 : 0 : rte_trace_save();
8507 : : #endif
8508 : 0 : else if (!strcmp(res->dump, "dump_log_types"))
8509 : 0 : rte_log_dump(stdout);
8510 : 0 : }
8511 : :
8512 : : static cmdline_parse_token_string_t cmd_dump_dump =
8513 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8514 : : "dump_physmem#"
8515 : : "dump_memzone#"
8516 : : "dump_socket_mem#"
8517 : : "dump_struct_sizes#"
8518 : : "dump_ring#"
8519 : : "dump_mempool#"
8520 : : "dump_devargs#"
8521 : : "dump_lcores#"
8522 : : #ifndef RTE_EXEC_ENV_WINDOWS
8523 : : "dump_trace#"
8524 : : #endif
8525 : : "dump_log_types");
8526 : :
8527 : : static cmdline_parse_inst_t cmd_dump = {
8528 : : .f = cmd_dump_parsed, /* function to call */
8529 : : .data = NULL, /* 2nd arg of func */
8530 : : .help_str = "Dump status",
8531 : : .tokens = { /* token list, NULL terminated */
8532 : : (void *)&cmd_dump_dump,
8533 : : NULL,
8534 : : },
8535 : : };
8536 : :
8537 : : /* ******************************************************************************** */
8538 : :
8539 : : struct cmd_dump_one_result {
8540 : : cmdline_fixed_string_t dump;
8541 : : cmdline_fixed_string_t name;
8542 : : };
8543 : :
8544 : 0 : static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8545 : : __rte_unused void *data)
8546 : : {
8547 : : struct cmd_dump_one_result *res = parsed_result;
8548 : :
8549 : 0 : if (!strcmp(res->dump, "dump_ring")) {
8550 : : struct rte_ring *r;
8551 : 0 : r = rte_ring_lookup(res->name);
8552 : 0 : if (r == NULL) {
8553 : 0 : cmdline_printf(cl, "Cannot find ring\n");
8554 : 0 : return;
8555 : : }
8556 : 0 : rte_ring_dump(stdout, r);
8557 : 0 : } else if (!strcmp(res->dump, "dump_mempool")) {
8558 : : struct rte_mempool *mp;
8559 : 0 : mp = rte_mempool_lookup(res->name);
8560 : 0 : if (mp == NULL) {
8561 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
8562 : 0 : return;
8563 : : }
8564 : 0 : rte_mempool_dump(stdout, mp);
8565 : : }
8566 : : }
8567 : :
8568 : : static cmdline_parse_token_string_t cmd_dump_one_dump =
8569 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8570 : : "dump_ring#dump_mempool");
8571 : :
8572 : : static cmdline_parse_token_string_t cmd_dump_one_name =
8573 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8574 : :
8575 : : static cmdline_parse_inst_t cmd_dump_one = {
8576 : : .f = cmd_dump_one_parsed, /* function to call */
8577 : : .data = NULL, /* 2nd arg of func */
8578 : : .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8579 : : .tokens = { /* token list, NULL terminated */
8580 : : (void *)&cmd_dump_one_dump,
8581 : : (void *)&cmd_dump_one_name,
8582 : : NULL,
8583 : : },
8584 : : };
8585 : :
8586 : : /* *** Filters Control *** */
8587 : :
8588 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8589 : : do { \
8590 : : if ((ip_addr).family == AF_INET) \
8591 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
8592 : : else { \
8593 : : fprintf(stderr, "invalid parameter.\n"); \
8594 : : return; \
8595 : : } \
8596 : : } while (0)
8597 : :
8598 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8599 : : do { \
8600 : : if ((ip_addr).family == AF_INET6) \
8601 : : rte_memcpy(&(ip), \
8602 : : &((ip_addr).addr.ipv6), \
8603 : : sizeof(struct in6_addr)); \
8604 : : else { \
8605 : : fprintf(stderr, "invalid parameter.\n"); \
8606 : : return; \
8607 : : } \
8608 : : } while (0)
8609 : :
8610 : : /* Generic flow interface command. */
8611 : : extern cmdline_parse_inst_t cmd_flow;
8612 : :
8613 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
8614 : : struct cmd_mcast_addr_result {
8615 : : cmdline_fixed_string_t mcast_addr_cmd;
8616 : : cmdline_fixed_string_t what;
8617 : : uint16_t port_num;
8618 : : struct rte_ether_addr mc_addr;
8619 : : };
8620 : :
8621 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
8622 : : __rte_unused struct cmdline *cl,
8623 : : __rte_unused void *data)
8624 : : {
8625 : : struct cmd_mcast_addr_result *res = parsed_result;
8626 : :
8627 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
8628 : 0 : fprintf(stderr,
8629 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
8630 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
8631 : 0 : return;
8632 : : }
8633 : 0 : if (strcmp(res->what, "add") == 0)
8634 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
8635 : : else
8636 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
8637 : : }
8638 : :
8639 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
8640 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8641 : : mcast_addr_cmd, "mcast_addr");
8642 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
8643 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8644 : : "add#remove");
8645 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
8646 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
8647 : : RTE_UINT16);
8648 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
8649 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8650 : :
8651 : : static cmdline_parse_inst_t cmd_mcast_addr = {
8652 : : .f = cmd_mcast_addr_parsed,
8653 : : .data = (void *)0,
8654 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
8655 : : "Add/Remove multicast MAC address on port_id",
8656 : : .tokens = {
8657 : : (void *)&cmd_mcast_addr_cmd,
8658 : : (void *)&cmd_mcast_addr_what,
8659 : : (void *)&cmd_mcast_addr_portnum,
8660 : : (void *)&cmd_mcast_addr_addr,
8661 : : NULL,
8662 : : },
8663 : : };
8664 : :
8665 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
8666 : : struct cmd_mcast_addr_flush_result {
8667 : : cmdline_fixed_string_t mcast_addr_cmd;
8668 : : cmdline_fixed_string_t what;
8669 : : uint16_t port_num;
8670 : : };
8671 : :
8672 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
8673 : : __rte_unused struct cmdline *cl,
8674 : : __rte_unused void *data)
8675 : : {
8676 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
8677 : :
8678 : 0 : mcast_addr_flush(res->port_num);
8679 : 0 : }
8680 : :
8681 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
8682 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8683 : : mcast_addr_cmd, "mcast_addr");
8684 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
8685 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8686 : : "flush");
8687 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
8688 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
8689 : : RTE_UINT16);
8690 : :
8691 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
8692 : : .f = cmd_mcast_addr_flush_parsed,
8693 : : .data = (void *)0,
8694 : : .help_str = "mcast_addr flush <port_id> : "
8695 : : "flush all multicast MAC addresses on port_id",
8696 : : .tokens = {
8697 : : (void *)&cmd_mcast_addr_flush_cmd,
8698 : : (void *)&cmd_mcast_addr_flush_what,
8699 : : (void *)&cmd_mcast_addr_flush_portnum,
8700 : : NULL,
8701 : : },
8702 : : };
8703 : :
8704 : : /* vf vlan anti spoof configuration */
8705 : :
8706 : : /* Common result structure for vf vlan anti spoof */
8707 : : struct cmd_vf_vlan_anti_spoof_result {
8708 : : cmdline_fixed_string_t set;
8709 : : cmdline_fixed_string_t vf;
8710 : : cmdline_fixed_string_t vlan;
8711 : : cmdline_fixed_string_t antispoof;
8712 : : portid_t port_id;
8713 : : uint32_t vf_id;
8714 : : cmdline_fixed_string_t on_off;
8715 : : };
8716 : :
8717 : : /* Common CLI fields for vf vlan anti spoof enable disable */
8718 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
8719 : : TOKEN_STRING_INITIALIZER
8720 : : (struct cmd_vf_vlan_anti_spoof_result,
8721 : : set, "set");
8722 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
8723 : : TOKEN_STRING_INITIALIZER
8724 : : (struct cmd_vf_vlan_anti_spoof_result,
8725 : : vf, "vf");
8726 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
8727 : : TOKEN_STRING_INITIALIZER
8728 : : (struct cmd_vf_vlan_anti_spoof_result,
8729 : : vlan, "vlan");
8730 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
8731 : : TOKEN_STRING_INITIALIZER
8732 : : (struct cmd_vf_vlan_anti_spoof_result,
8733 : : antispoof, "antispoof");
8734 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
8735 : : TOKEN_NUM_INITIALIZER
8736 : : (struct cmd_vf_vlan_anti_spoof_result,
8737 : : port_id, RTE_UINT16);
8738 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
8739 : : TOKEN_NUM_INITIALIZER
8740 : : (struct cmd_vf_vlan_anti_spoof_result,
8741 : : vf_id, RTE_UINT32);
8742 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
8743 : : TOKEN_STRING_INITIALIZER
8744 : : (struct cmd_vf_vlan_anti_spoof_result,
8745 : : on_off, "on#off");
8746 : :
8747 : : static void
8748 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
8749 : : void *parsed_result,
8750 : : __rte_unused struct cmdline *cl,
8751 : : __rte_unused void *data)
8752 : : {
8753 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
8754 : : int ret = -ENOTSUP;
8755 : :
8756 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8757 : :
8758 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8759 : : return;
8760 : :
8761 : : #ifdef RTE_NET_IXGBE
8762 : : if (ret == -ENOTSUP)
8763 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
8764 : 0 : res->vf_id, is_on);
8765 : : #endif
8766 : : #ifdef RTE_NET_I40E
8767 : 0 : if (ret == -ENOTSUP)
8768 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
8769 : 0 : res->vf_id, is_on);
8770 : : #endif
8771 : : #ifdef RTE_NET_BNXT
8772 : 0 : if (ret == -ENOTSUP)
8773 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
8774 : 0 : res->vf_id, is_on);
8775 : : #endif
8776 : :
8777 : 0 : switch (ret) {
8778 : : case 0:
8779 : : break;
8780 : 0 : case -EINVAL:
8781 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
8782 : : break;
8783 : 0 : case -ENODEV:
8784 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8785 : : break;
8786 : 0 : case -ENOTSUP:
8787 : 0 : fprintf(stderr, "function not implemented\n");
8788 : : break;
8789 : 0 : default:
8790 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8791 : : }
8792 : : }
8793 : :
8794 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
8795 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
8796 : : .data = NULL,
8797 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
8798 : : .tokens = {
8799 : : (void *)&cmd_vf_vlan_anti_spoof_set,
8800 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
8801 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
8802 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
8803 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
8804 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
8805 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
8806 : : NULL,
8807 : : },
8808 : : };
8809 : :
8810 : : /* vf mac anti spoof configuration */
8811 : :
8812 : : /* Common result structure for vf mac anti spoof */
8813 : : struct cmd_vf_mac_anti_spoof_result {
8814 : : cmdline_fixed_string_t set;
8815 : : cmdline_fixed_string_t vf;
8816 : : cmdline_fixed_string_t mac;
8817 : : cmdline_fixed_string_t antispoof;
8818 : : portid_t port_id;
8819 : : uint32_t vf_id;
8820 : : cmdline_fixed_string_t on_off;
8821 : : };
8822 : :
8823 : : /* Common CLI fields for vf mac anti spoof enable disable */
8824 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
8825 : : TOKEN_STRING_INITIALIZER
8826 : : (struct cmd_vf_mac_anti_spoof_result,
8827 : : set, "set");
8828 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
8829 : : TOKEN_STRING_INITIALIZER
8830 : : (struct cmd_vf_mac_anti_spoof_result,
8831 : : vf, "vf");
8832 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
8833 : : TOKEN_STRING_INITIALIZER
8834 : : (struct cmd_vf_mac_anti_spoof_result,
8835 : : mac, "mac");
8836 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
8837 : : TOKEN_STRING_INITIALIZER
8838 : : (struct cmd_vf_mac_anti_spoof_result,
8839 : : antispoof, "antispoof");
8840 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
8841 : : TOKEN_NUM_INITIALIZER
8842 : : (struct cmd_vf_mac_anti_spoof_result,
8843 : : port_id, RTE_UINT16);
8844 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
8845 : : TOKEN_NUM_INITIALIZER
8846 : : (struct cmd_vf_mac_anti_spoof_result,
8847 : : vf_id, RTE_UINT32);
8848 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
8849 : : TOKEN_STRING_INITIALIZER
8850 : : (struct cmd_vf_mac_anti_spoof_result,
8851 : : on_off, "on#off");
8852 : :
8853 : : static void
8854 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
8855 : : void *parsed_result,
8856 : : __rte_unused struct cmdline *cl,
8857 : : __rte_unused void *data)
8858 : : {
8859 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
8860 : : int ret = -ENOTSUP;
8861 : :
8862 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8863 : :
8864 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8865 : : return;
8866 : :
8867 : : #ifdef RTE_NET_IXGBE
8868 : : if (ret == -ENOTSUP)
8869 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
8870 : 0 : res->vf_id, is_on);
8871 : : #endif
8872 : : #ifdef RTE_NET_I40E
8873 : 0 : if (ret == -ENOTSUP)
8874 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
8875 : 0 : res->vf_id, is_on);
8876 : : #endif
8877 : : #ifdef RTE_NET_BNXT
8878 : 0 : if (ret == -ENOTSUP)
8879 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
8880 : 0 : res->vf_id, is_on);
8881 : : #endif
8882 : :
8883 : 0 : switch (ret) {
8884 : : case 0:
8885 : : break;
8886 : 0 : case -EINVAL:
8887 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
8888 : : res->vf_id, is_on);
8889 : : break;
8890 : 0 : case -ENODEV:
8891 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8892 : : break;
8893 : 0 : case -ENOTSUP:
8894 : 0 : fprintf(stderr, "function not implemented\n");
8895 : : break;
8896 : 0 : default:
8897 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8898 : : }
8899 : : }
8900 : :
8901 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
8902 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
8903 : : .data = NULL,
8904 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
8905 : : .tokens = {
8906 : : (void *)&cmd_vf_mac_anti_spoof_set,
8907 : : (void *)&cmd_vf_mac_anti_spoof_vf,
8908 : : (void *)&cmd_vf_mac_anti_spoof_mac,
8909 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
8910 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
8911 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
8912 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
8913 : : NULL,
8914 : : },
8915 : : };
8916 : :
8917 : : /* vf vlan strip queue configuration */
8918 : :
8919 : : /* Common result structure for vf mac anti spoof */
8920 : : struct cmd_vf_vlan_stripq_result {
8921 : : cmdline_fixed_string_t set;
8922 : : cmdline_fixed_string_t vf;
8923 : : cmdline_fixed_string_t vlan;
8924 : : cmdline_fixed_string_t stripq;
8925 : : portid_t port_id;
8926 : : uint16_t vf_id;
8927 : : cmdline_fixed_string_t on_off;
8928 : : };
8929 : :
8930 : : /* Common CLI fields for vf vlan strip enable disable */
8931 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
8932 : : TOKEN_STRING_INITIALIZER
8933 : : (struct cmd_vf_vlan_stripq_result,
8934 : : set, "set");
8935 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
8936 : : TOKEN_STRING_INITIALIZER
8937 : : (struct cmd_vf_vlan_stripq_result,
8938 : : vf, "vf");
8939 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
8940 : : TOKEN_STRING_INITIALIZER
8941 : : (struct cmd_vf_vlan_stripq_result,
8942 : : vlan, "vlan");
8943 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
8944 : : TOKEN_STRING_INITIALIZER
8945 : : (struct cmd_vf_vlan_stripq_result,
8946 : : stripq, "stripq");
8947 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
8948 : : TOKEN_NUM_INITIALIZER
8949 : : (struct cmd_vf_vlan_stripq_result,
8950 : : port_id, RTE_UINT16);
8951 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
8952 : : TOKEN_NUM_INITIALIZER
8953 : : (struct cmd_vf_vlan_stripq_result,
8954 : : vf_id, RTE_UINT16);
8955 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
8956 : : TOKEN_STRING_INITIALIZER
8957 : : (struct cmd_vf_vlan_stripq_result,
8958 : : on_off, "on#off");
8959 : :
8960 : : static void
8961 : 0 : cmd_set_vf_vlan_stripq_parsed(
8962 : : void *parsed_result,
8963 : : __rte_unused struct cmdline *cl,
8964 : : __rte_unused void *data)
8965 : : {
8966 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
8967 : : int ret = -ENOTSUP;
8968 : :
8969 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8970 : :
8971 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8972 : : return;
8973 : :
8974 : : #ifdef RTE_NET_IXGBE
8975 : : if (ret == -ENOTSUP)
8976 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
8977 : 0 : res->vf_id, is_on);
8978 : : #endif
8979 : : #ifdef RTE_NET_I40E
8980 : 0 : if (ret == -ENOTSUP)
8981 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
8982 : 0 : res->vf_id, is_on);
8983 : : #endif
8984 : : #ifdef RTE_NET_BNXT
8985 : 0 : if (ret == -ENOTSUP)
8986 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
8987 : 0 : res->vf_id, is_on);
8988 : : #endif
8989 : :
8990 : 0 : switch (ret) {
8991 : : case 0:
8992 : : break;
8993 : 0 : case -EINVAL:
8994 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
8995 : 0 : res->vf_id, is_on);
8996 : : break;
8997 : 0 : case -ENODEV:
8998 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8999 : : break;
9000 : 0 : case -ENOTSUP:
9001 : 0 : fprintf(stderr, "function not implemented\n");
9002 : : break;
9003 : 0 : default:
9004 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9005 : : }
9006 : : }
9007 : :
9008 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
9009 : : .f = cmd_set_vf_vlan_stripq_parsed,
9010 : : .data = NULL,
9011 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
9012 : : .tokens = {
9013 : : (void *)&cmd_vf_vlan_stripq_set,
9014 : : (void *)&cmd_vf_vlan_stripq_vf,
9015 : : (void *)&cmd_vf_vlan_stripq_vlan,
9016 : : (void *)&cmd_vf_vlan_stripq_stripq,
9017 : : (void *)&cmd_vf_vlan_stripq_port_id,
9018 : : (void *)&cmd_vf_vlan_stripq_vf_id,
9019 : : (void *)&cmd_vf_vlan_stripq_on_off,
9020 : : NULL,
9021 : : },
9022 : : };
9023 : :
9024 : : /* vf vlan insert configuration */
9025 : :
9026 : : /* Common result structure for vf vlan insert */
9027 : : struct cmd_vf_vlan_insert_result {
9028 : : cmdline_fixed_string_t set;
9029 : : cmdline_fixed_string_t vf;
9030 : : cmdline_fixed_string_t vlan;
9031 : : cmdline_fixed_string_t insert;
9032 : : portid_t port_id;
9033 : : uint16_t vf_id;
9034 : : uint16_t vlan_id;
9035 : : };
9036 : :
9037 : : /* Common CLI fields for vf vlan insert enable disable */
9038 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
9039 : : TOKEN_STRING_INITIALIZER
9040 : : (struct cmd_vf_vlan_insert_result,
9041 : : set, "set");
9042 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
9043 : : TOKEN_STRING_INITIALIZER
9044 : : (struct cmd_vf_vlan_insert_result,
9045 : : vf, "vf");
9046 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
9047 : : TOKEN_STRING_INITIALIZER
9048 : : (struct cmd_vf_vlan_insert_result,
9049 : : vlan, "vlan");
9050 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
9051 : : TOKEN_STRING_INITIALIZER
9052 : : (struct cmd_vf_vlan_insert_result,
9053 : : insert, "insert");
9054 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
9055 : : TOKEN_NUM_INITIALIZER
9056 : : (struct cmd_vf_vlan_insert_result,
9057 : : port_id, RTE_UINT16);
9058 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
9059 : : TOKEN_NUM_INITIALIZER
9060 : : (struct cmd_vf_vlan_insert_result,
9061 : : vf_id, RTE_UINT16);
9062 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
9063 : : TOKEN_NUM_INITIALIZER
9064 : : (struct cmd_vf_vlan_insert_result,
9065 : : vlan_id, RTE_UINT16);
9066 : :
9067 : : static void
9068 : 0 : cmd_set_vf_vlan_insert_parsed(
9069 : : void *parsed_result,
9070 : : __rte_unused struct cmdline *cl,
9071 : : __rte_unused void *data)
9072 : : {
9073 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
9074 : : int ret = -ENOTSUP;
9075 : :
9076 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9077 : : return;
9078 : :
9079 : : #ifdef RTE_NET_IXGBE
9080 : : if (ret == -ENOTSUP)
9081 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
9082 : 0 : res->vlan_id);
9083 : : #endif
9084 : : #ifdef RTE_NET_I40E
9085 : 0 : if (ret == -ENOTSUP)
9086 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
9087 : 0 : res->vlan_id);
9088 : : #endif
9089 : : #ifdef RTE_NET_BNXT
9090 : 0 : if (ret == -ENOTSUP)
9091 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
9092 : 0 : res->vlan_id);
9093 : : #endif
9094 : :
9095 : 0 : switch (ret) {
9096 : : case 0:
9097 : : break;
9098 : 0 : case -EINVAL:
9099 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
9100 : 0 : res->vf_id, res->vlan_id);
9101 : : break;
9102 : 0 : case -ENODEV:
9103 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9104 : : break;
9105 : 0 : case -ENOTSUP:
9106 : 0 : fprintf(stderr, "function not implemented\n");
9107 : : break;
9108 : 0 : default:
9109 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9110 : : }
9111 : : }
9112 : :
9113 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
9114 : : .f = cmd_set_vf_vlan_insert_parsed,
9115 : : .data = NULL,
9116 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
9117 : : .tokens = {
9118 : : (void *)&cmd_vf_vlan_insert_set,
9119 : : (void *)&cmd_vf_vlan_insert_vf,
9120 : : (void *)&cmd_vf_vlan_insert_vlan,
9121 : : (void *)&cmd_vf_vlan_insert_insert,
9122 : : (void *)&cmd_vf_vlan_insert_port_id,
9123 : : (void *)&cmd_vf_vlan_insert_vf_id,
9124 : : (void *)&cmd_vf_vlan_insert_vlan_id,
9125 : : NULL,
9126 : : },
9127 : : };
9128 : :
9129 : : /* tx loopback configuration */
9130 : :
9131 : : /* Common result structure for tx loopback */
9132 : : struct cmd_tx_loopback_result {
9133 : : cmdline_fixed_string_t set;
9134 : : cmdline_fixed_string_t tx;
9135 : : cmdline_fixed_string_t loopback;
9136 : : portid_t port_id;
9137 : : cmdline_fixed_string_t on_off;
9138 : : };
9139 : :
9140 : : /* Common CLI fields for tx loopback enable disable */
9141 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
9142 : : TOKEN_STRING_INITIALIZER
9143 : : (struct cmd_tx_loopback_result,
9144 : : set, "set");
9145 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
9146 : : TOKEN_STRING_INITIALIZER
9147 : : (struct cmd_tx_loopback_result,
9148 : : tx, "tx");
9149 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
9150 : : TOKEN_STRING_INITIALIZER
9151 : : (struct cmd_tx_loopback_result,
9152 : : loopback, "loopback");
9153 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
9154 : : TOKEN_NUM_INITIALIZER
9155 : : (struct cmd_tx_loopback_result,
9156 : : port_id, RTE_UINT16);
9157 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
9158 : : TOKEN_STRING_INITIALIZER
9159 : : (struct cmd_tx_loopback_result,
9160 : : on_off, "on#off");
9161 : :
9162 : : static void
9163 : 0 : cmd_set_tx_loopback_parsed(
9164 : : void *parsed_result,
9165 : : __rte_unused struct cmdline *cl,
9166 : : __rte_unused void *data)
9167 : : {
9168 : : struct cmd_tx_loopback_result *res = parsed_result;
9169 : : int ret = -ENOTSUP;
9170 : :
9171 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9172 : :
9173 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9174 : : return;
9175 : :
9176 : : #ifdef RTE_NET_IXGBE
9177 : : if (ret == -ENOTSUP)
9178 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
9179 : : #endif
9180 : : #ifdef RTE_NET_I40E
9181 : 0 : if (ret == -ENOTSUP)
9182 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
9183 : : #endif
9184 : : #ifdef RTE_NET_BNXT
9185 : 0 : if (ret == -ENOTSUP)
9186 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
9187 : : #endif
9188 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
9189 : 0 : if (ret == -ENOTSUP)
9190 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
9191 : : #endif
9192 : :
9193 : 0 : switch (ret) {
9194 : : case 0:
9195 : : break;
9196 : 0 : case -EINVAL:
9197 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9198 : : break;
9199 : 0 : case -ENODEV:
9200 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9201 : : break;
9202 : 0 : case -ENOTSUP:
9203 : 0 : fprintf(stderr, "function not implemented\n");
9204 : : break;
9205 : 0 : default:
9206 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9207 : : }
9208 : : }
9209 : :
9210 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
9211 : : .f = cmd_set_tx_loopback_parsed,
9212 : : .data = NULL,
9213 : : .help_str = "set tx loopback <port_id> on|off",
9214 : : .tokens = {
9215 : : (void *)&cmd_tx_loopback_set,
9216 : : (void *)&cmd_tx_loopback_tx,
9217 : : (void *)&cmd_tx_loopback_loopback,
9218 : : (void *)&cmd_tx_loopback_port_id,
9219 : : (void *)&cmd_tx_loopback_on_off,
9220 : : NULL,
9221 : : },
9222 : : };
9223 : :
9224 : : /* all queues drop enable configuration */
9225 : :
9226 : : /* Common result structure for all queues drop enable */
9227 : : struct cmd_all_queues_drop_en_result {
9228 : : cmdline_fixed_string_t set;
9229 : : cmdline_fixed_string_t all;
9230 : : cmdline_fixed_string_t queues;
9231 : : cmdline_fixed_string_t drop;
9232 : : portid_t port_id;
9233 : : cmdline_fixed_string_t on_off;
9234 : : };
9235 : :
9236 : : /* Common CLI fields for tx loopback enable disable */
9237 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
9238 : : TOKEN_STRING_INITIALIZER
9239 : : (struct cmd_all_queues_drop_en_result,
9240 : : set, "set");
9241 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
9242 : : TOKEN_STRING_INITIALIZER
9243 : : (struct cmd_all_queues_drop_en_result,
9244 : : all, "all");
9245 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
9246 : : TOKEN_STRING_INITIALIZER
9247 : : (struct cmd_all_queues_drop_en_result,
9248 : : queues, "queues");
9249 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
9250 : : TOKEN_STRING_INITIALIZER
9251 : : (struct cmd_all_queues_drop_en_result,
9252 : : drop, "drop");
9253 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
9254 : : TOKEN_NUM_INITIALIZER
9255 : : (struct cmd_all_queues_drop_en_result,
9256 : : port_id, RTE_UINT16);
9257 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
9258 : : TOKEN_STRING_INITIALIZER
9259 : : (struct cmd_all_queues_drop_en_result,
9260 : : on_off, "on#off");
9261 : :
9262 : : static void
9263 : 0 : cmd_set_all_queues_drop_en_parsed(
9264 : : void *parsed_result,
9265 : : __rte_unused struct cmdline *cl,
9266 : : __rte_unused void *data)
9267 : : {
9268 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
9269 : : int ret = -ENOTSUP;
9270 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9271 : :
9272 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9273 : : return;
9274 : :
9275 : : #ifdef RTE_NET_IXGBE
9276 : : if (ret == -ENOTSUP)
9277 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
9278 : : #endif
9279 : : #ifdef RTE_NET_BNXT
9280 : 0 : if (ret == -ENOTSUP)
9281 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
9282 : : #endif
9283 : 0 : switch (ret) {
9284 : : case 0:
9285 : : break;
9286 : 0 : case -EINVAL:
9287 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9288 : : break;
9289 : 0 : case -ENODEV:
9290 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9291 : : break;
9292 : 0 : case -ENOTSUP:
9293 : 0 : fprintf(stderr, "function not implemented\n");
9294 : : break;
9295 : 0 : default:
9296 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9297 : : }
9298 : : }
9299 : :
9300 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
9301 : : .f = cmd_set_all_queues_drop_en_parsed,
9302 : : .data = NULL,
9303 : : .help_str = "set all queues drop <port_id> on|off",
9304 : : .tokens = {
9305 : : (void *)&cmd_all_queues_drop_en_set,
9306 : : (void *)&cmd_all_queues_drop_en_all,
9307 : : (void *)&cmd_all_queues_drop_en_queues,
9308 : : (void *)&cmd_all_queues_drop_en_drop,
9309 : : (void *)&cmd_all_queues_drop_en_port_id,
9310 : : (void *)&cmd_all_queues_drop_en_on_off,
9311 : : NULL,
9312 : : },
9313 : : };
9314 : :
9315 : : /* vf mac address configuration */
9316 : :
9317 : : /* Common result structure for vf mac address */
9318 : : struct cmd_set_vf_mac_addr_result {
9319 : : cmdline_fixed_string_t set;
9320 : : cmdline_fixed_string_t vf;
9321 : : cmdline_fixed_string_t mac;
9322 : : cmdline_fixed_string_t addr;
9323 : : portid_t port_id;
9324 : : uint16_t vf_id;
9325 : : struct rte_ether_addr mac_addr;
9326 : :
9327 : : };
9328 : :
9329 : : /* Common CLI fields for vf split drop enable disable */
9330 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
9331 : : TOKEN_STRING_INITIALIZER
9332 : : (struct cmd_set_vf_mac_addr_result,
9333 : : set, "set");
9334 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
9335 : : TOKEN_STRING_INITIALIZER
9336 : : (struct cmd_set_vf_mac_addr_result,
9337 : : vf, "vf");
9338 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
9339 : : TOKEN_STRING_INITIALIZER
9340 : : (struct cmd_set_vf_mac_addr_result,
9341 : : mac, "mac");
9342 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
9343 : : TOKEN_STRING_INITIALIZER
9344 : : (struct cmd_set_vf_mac_addr_result,
9345 : : addr, "addr");
9346 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
9347 : : TOKEN_NUM_INITIALIZER
9348 : : (struct cmd_set_vf_mac_addr_result,
9349 : : port_id, RTE_UINT16);
9350 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
9351 : : TOKEN_NUM_INITIALIZER
9352 : : (struct cmd_set_vf_mac_addr_result,
9353 : : vf_id, RTE_UINT16);
9354 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
9355 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
9356 : : mac_addr);
9357 : :
9358 : : static void
9359 : 0 : cmd_set_vf_mac_addr_parsed(
9360 : : void *parsed_result,
9361 : : __rte_unused struct cmdline *cl,
9362 : : __rte_unused void *data)
9363 : : {
9364 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
9365 : : int ret = -ENOTSUP;
9366 : :
9367 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9368 : : return;
9369 : :
9370 : : #ifdef RTE_NET_IXGBE
9371 : : if (ret == -ENOTSUP)
9372 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
9373 : : &res->mac_addr);
9374 : : #endif
9375 : : #ifdef RTE_NET_I40E
9376 : 0 : if (ret == -ENOTSUP)
9377 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
9378 : : &res->mac_addr);
9379 : : #endif
9380 : : #ifdef RTE_NET_BNXT
9381 : 0 : if (ret == -ENOTSUP)
9382 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
9383 : : &res->mac_addr);
9384 : : #endif
9385 : :
9386 : 0 : switch (ret) {
9387 : : case 0:
9388 : : break;
9389 : 0 : case -EINVAL:
9390 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
9391 : : break;
9392 : 0 : case -ENODEV:
9393 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9394 : : break;
9395 : 0 : case -ENOTSUP:
9396 : 0 : fprintf(stderr, "function not implemented\n");
9397 : : break;
9398 : 0 : default:
9399 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9400 : : }
9401 : : }
9402 : :
9403 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
9404 : : .f = cmd_set_vf_mac_addr_parsed,
9405 : : .data = NULL,
9406 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
9407 : : .tokens = {
9408 : : (void *)&cmd_set_vf_mac_addr_set,
9409 : : (void *)&cmd_set_vf_mac_addr_vf,
9410 : : (void *)&cmd_set_vf_mac_addr_mac,
9411 : : (void *)&cmd_set_vf_mac_addr_addr,
9412 : : (void *)&cmd_set_vf_mac_addr_port_id,
9413 : : (void *)&cmd_set_vf_mac_addr_vf_id,
9414 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
9415 : : NULL,
9416 : : },
9417 : : };
9418 : :
9419 : : /** Set VXLAN encapsulation details */
9420 : : struct cmd_set_vxlan_result {
9421 : : cmdline_fixed_string_t set;
9422 : : cmdline_fixed_string_t vxlan;
9423 : : cmdline_fixed_string_t pos_token;
9424 : : cmdline_fixed_string_t ip_version;
9425 : : uint32_t vlan_present:1;
9426 : : uint32_t vni;
9427 : : uint16_t udp_src;
9428 : : uint16_t udp_dst;
9429 : : cmdline_ipaddr_t ip_src;
9430 : : cmdline_ipaddr_t ip_dst;
9431 : : uint16_t tci;
9432 : : uint8_t tos;
9433 : : uint8_t ttl;
9434 : : struct rte_ether_addr eth_src;
9435 : : struct rte_ether_addr eth_dst;
9436 : : };
9437 : :
9438 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
9439 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
9440 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
9441 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
9442 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
9443 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
9444 : : "vxlan-tos-ttl");
9445 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
9446 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
9447 : : "vxlan-with-vlan");
9448 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
9449 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9450 : : "ip-version");
9451 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
9452 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
9453 : : "ipv4#ipv6");
9454 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
9455 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9456 : : "vni");
9457 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
9458 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
9459 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
9460 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9461 : : "udp-src");
9462 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
9463 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
9464 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
9465 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9466 : : "udp-dst");
9467 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
9468 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
9469 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
9470 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9471 : : "ip-tos");
9472 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
9473 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
9474 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
9475 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9476 : : "ip-ttl");
9477 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
9478 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
9479 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
9480 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9481 : : "ip-src");
9482 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
9483 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
9484 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
9485 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9486 : : "ip-dst");
9487 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
9488 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
9489 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
9490 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9491 : : "vlan-tci");
9492 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
9493 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
9494 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
9495 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9496 : : "eth-src");
9497 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
9498 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
9499 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
9500 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9501 : : "eth-dst");
9502 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
9503 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
9504 : :
9505 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
9506 : : __rte_unused struct cmdline *cl,
9507 : : __rte_unused void *data)
9508 : : {
9509 : : struct cmd_set_vxlan_result *res = parsed_result;
9510 : : union {
9511 : : uint32_t vxlan_id;
9512 : : uint8_t vni[4];
9513 : 0 : } id = {
9514 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
9515 : : };
9516 : :
9517 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
9518 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
9519 : 0 : vxlan_encap_conf.select_vlan = 0;
9520 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
9521 : 0 : vxlan_encap_conf.select_vlan = 1;
9522 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
9523 : 0 : vxlan_encap_conf.select_vlan = 0;
9524 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
9525 : : }
9526 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
9527 : 0 : vxlan_encap_conf.select_ipv4 = 1;
9528 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
9529 : 0 : vxlan_encap_conf.select_ipv4 = 0;
9530 : : else
9531 : 0 : return;
9532 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
9533 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
9534 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
9535 : 0 : vxlan_encap_conf.ip_tos = res->tos;
9536 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
9537 : 0 : if (vxlan_encap_conf.select_ipv4) {
9538 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
9539 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
9540 : : } else {
9541 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
9542 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
9543 : : }
9544 : 0 : if (vxlan_encap_conf.select_vlan)
9545 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9546 : 0 : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
9547 : : RTE_ETHER_ADDR_LEN);
9548 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9549 : : RTE_ETHER_ADDR_LEN);
9550 : : }
9551 : :
9552 : : static cmdline_parse_inst_t cmd_set_vxlan = {
9553 : : .f = cmd_set_vxlan_parsed,
9554 : : .data = NULL,
9555 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
9556 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
9557 : : " eth-src <eth-src> eth-dst <eth-dst>",
9558 : : .tokens = {
9559 : : (void *)&cmd_set_vxlan_set,
9560 : : (void *)&cmd_set_vxlan_vxlan,
9561 : : (void *)&cmd_set_vxlan_ip_version,
9562 : : (void *)&cmd_set_vxlan_ip_version_value,
9563 : : (void *)&cmd_set_vxlan_vni,
9564 : : (void *)&cmd_set_vxlan_vni_value,
9565 : : (void *)&cmd_set_vxlan_udp_src,
9566 : : (void *)&cmd_set_vxlan_udp_src_value,
9567 : : (void *)&cmd_set_vxlan_udp_dst,
9568 : : (void *)&cmd_set_vxlan_udp_dst_value,
9569 : : (void *)&cmd_set_vxlan_ip_src,
9570 : : (void *)&cmd_set_vxlan_ip_src_value,
9571 : : (void *)&cmd_set_vxlan_ip_dst,
9572 : : (void *)&cmd_set_vxlan_ip_dst_value,
9573 : : (void *)&cmd_set_vxlan_eth_src,
9574 : : (void *)&cmd_set_vxlan_eth_src_value,
9575 : : (void *)&cmd_set_vxlan_eth_dst,
9576 : : (void *)&cmd_set_vxlan_eth_dst_value,
9577 : : NULL,
9578 : : },
9579 : : };
9580 : :
9581 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
9582 : : .f = cmd_set_vxlan_parsed,
9583 : : .data = NULL,
9584 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
9585 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
9586 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
9587 : : " eth-dst <eth-dst>",
9588 : : .tokens = {
9589 : : (void *)&cmd_set_vxlan_set,
9590 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
9591 : : (void *)&cmd_set_vxlan_ip_version,
9592 : : (void *)&cmd_set_vxlan_ip_version_value,
9593 : : (void *)&cmd_set_vxlan_vni,
9594 : : (void *)&cmd_set_vxlan_vni_value,
9595 : : (void *)&cmd_set_vxlan_udp_src,
9596 : : (void *)&cmd_set_vxlan_udp_src_value,
9597 : : (void *)&cmd_set_vxlan_udp_dst,
9598 : : (void *)&cmd_set_vxlan_udp_dst_value,
9599 : : (void *)&cmd_set_vxlan_ip_tos,
9600 : : (void *)&cmd_set_vxlan_ip_tos_value,
9601 : : (void *)&cmd_set_vxlan_ip_ttl,
9602 : : (void *)&cmd_set_vxlan_ip_ttl_value,
9603 : : (void *)&cmd_set_vxlan_ip_src,
9604 : : (void *)&cmd_set_vxlan_ip_src_value,
9605 : : (void *)&cmd_set_vxlan_ip_dst,
9606 : : (void *)&cmd_set_vxlan_ip_dst_value,
9607 : : (void *)&cmd_set_vxlan_eth_src,
9608 : : (void *)&cmd_set_vxlan_eth_src_value,
9609 : : (void *)&cmd_set_vxlan_eth_dst,
9610 : : (void *)&cmd_set_vxlan_eth_dst_value,
9611 : : NULL,
9612 : : },
9613 : : };
9614 : :
9615 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
9616 : : .f = cmd_set_vxlan_parsed,
9617 : : .data = NULL,
9618 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
9619 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
9620 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
9621 : : " <eth-dst>",
9622 : : .tokens = {
9623 : : (void *)&cmd_set_vxlan_set,
9624 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
9625 : : (void *)&cmd_set_vxlan_ip_version,
9626 : : (void *)&cmd_set_vxlan_ip_version_value,
9627 : : (void *)&cmd_set_vxlan_vni,
9628 : : (void *)&cmd_set_vxlan_vni_value,
9629 : : (void *)&cmd_set_vxlan_udp_src,
9630 : : (void *)&cmd_set_vxlan_udp_src_value,
9631 : : (void *)&cmd_set_vxlan_udp_dst,
9632 : : (void *)&cmd_set_vxlan_udp_dst_value,
9633 : : (void *)&cmd_set_vxlan_ip_src,
9634 : : (void *)&cmd_set_vxlan_ip_src_value,
9635 : : (void *)&cmd_set_vxlan_ip_dst,
9636 : : (void *)&cmd_set_vxlan_ip_dst_value,
9637 : : (void *)&cmd_set_vxlan_vlan,
9638 : : (void *)&cmd_set_vxlan_vlan_value,
9639 : : (void *)&cmd_set_vxlan_eth_src,
9640 : : (void *)&cmd_set_vxlan_eth_src_value,
9641 : : (void *)&cmd_set_vxlan_eth_dst,
9642 : : (void *)&cmd_set_vxlan_eth_dst_value,
9643 : : NULL,
9644 : : },
9645 : : };
9646 : :
9647 : : /** Set NVGRE encapsulation details */
9648 : : struct cmd_set_nvgre_result {
9649 : : cmdline_fixed_string_t set;
9650 : : cmdline_fixed_string_t nvgre;
9651 : : cmdline_fixed_string_t pos_token;
9652 : : cmdline_fixed_string_t ip_version;
9653 : : uint32_t tni;
9654 : : cmdline_ipaddr_t ip_src;
9655 : : cmdline_ipaddr_t ip_dst;
9656 : : uint16_t tci;
9657 : : struct rte_ether_addr eth_src;
9658 : : struct rte_ether_addr eth_dst;
9659 : : };
9660 : :
9661 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
9662 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
9663 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
9664 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
9665 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
9666 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
9667 : : "nvgre-with-vlan");
9668 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
9669 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9670 : : "ip-version");
9671 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
9672 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
9673 : : "ipv4#ipv6");
9674 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
9675 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9676 : : "tni");
9677 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
9678 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
9679 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
9680 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9681 : : "ip-src");
9682 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
9683 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
9684 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
9685 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9686 : : "ip-dst");
9687 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
9688 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
9689 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
9690 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9691 : : "vlan-tci");
9692 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
9693 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
9694 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
9695 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9696 : : "eth-src");
9697 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
9698 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
9699 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
9700 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9701 : : "eth-dst");
9702 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
9703 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
9704 : :
9705 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
9706 : : __rte_unused struct cmdline *cl,
9707 : : __rte_unused void *data)
9708 : : {
9709 : : struct cmd_set_nvgre_result *res = parsed_result;
9710 : : union {
9711 : : uint32_t nvgre_tni;
9712 : : uint8_t tni[4];
9713 : 0 : } id = {
9714 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
9715 : : };
9716 : :
9717 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
9718 : 0 : nvgre_encap_conf.select_vlan = 0;
9719 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
9720 : 0 : nvgre_encap_conf.select_vlan = 1;
9721 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
9722 : 0 : nvgre_encap_conf.select_ipv4 = 1;
9723 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
9724 : 0 : nvgre_encap_conf.select_ipv4 = 0;
9725 : : else
9726 : 0 : return;
9727 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
9728 : 0 : if (nvgre_encap_conf.select_ipv4) {
9729 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
9730 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
9731 : : } else {
9732 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
9733 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
9734 : : }
9735 : 0 : if (nvgre_encap_conf.select_vlan)
9736 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9737 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
9738 : : RTE_ETHER_ADDR_LEN);
9739 : 0 : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9740 : : RTE_ETHER_ADDR_LEN);
9741 : : }
9742 : :
9743 : : static cmdline_parse_inst_t cmd_set_nvgre = {
9744 : : .f = cmd_set_nvgre_parsed,
9745 : : .data = NULL,
9746 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
9747 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
9748 : : " eth-dst <eth-dst>",
9749 : : .tokens = {
9750 : : (void *)&cmd_set_nvgre_set,
9751 : : (void *)&cmd_set_nvgre_nvgre,
9752 : : (void *)&cmd_set_nvgre_ip_version,
9753 : : (void *)&cmd_set_nvgre_ip_version_value,
9754 : : (void *)&cmd_set_nvgre_tni,
9755 : : (void *)&cmd_set_nvgre_tni_value,
9756 : : (void *)&cmd_set_nvgre_ip_src,
9757 : : (void *)&cmd_set_nvgre_ip_src_value,
9758 : : (void *)&cmd_set_nvgre_ip_dst,
9759 : : (void *)&cmd_set_nvgre_ip_dst_value,
9760 : : (void *)&cmd_set_nvgre_eth_src,
9761 : : (void *)&cmd_set_nvgre_eth_src_value,
9762 : : (void *)&cmd_set_nvgre_eth_dst,
9763 : : (void *)&cmd_set_nvgre_eth_dst_value,
9764 : : NULL,
9765 : : },
9766 : : };
9767 : :
9768 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
9769 : : .f = cmd_set_nvgre_parsed,
9770 : : .data = NULL,
9771 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
9772 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
9773 : : " eth-src <eth-src> eth-dst <eth-dst>",
9774 : : .tokens = {
9775 : : (void *)&cmd_set_nvgre_set,
9776 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
9777 : : (void *)&cmd_set_nvgre_ip_version,
9778 : : (void *)&cmd_set_nvgre_ip_version_value,
9779 : : (void *)&cmd_set_nvgre_tni,
9780 : : (void *)&cmd_set_nvgre_tni_value,
9781 : : (void *)&cmd_set_nvgre_ip_src,
9782 : : (void *)&cmd_set_nvgre_ip_src_value,
9783 : : (void *)&cmd_set_nvgre_ip_dst,
9784 : : (void *)&cmd_set_nvgre_ip_dst_value,
9785 : : (void *)&cmd_set_nvgre_vlan,
9786 : : (void *)&cmd_set_nvgre_vlan_value,
9787 : : (void *)&cmd_set_nvgre_eth_src,
9788 : : (void *)&cmd_set_nvgre_eth_src_value,
9789 : : (void *)&cmd_set_nvgre_eth_dst,
9790 : : (void *)&cmd_set_nvgre_eth_dst_value,
9791 : : NULL,
9792 : : },
9793 : : };
9794 : :
9795 : : /** Set L2 encapsulation details */
9796 : : struct cmd_set_l2_encap_result {
9797 : : cmdline_fixed_string_t set;
9798 : : cmdline_fixed_string_t l2_encap;
9799 : : cmdline_fixed_string_t pos_token;
9800 : : cmdline_fixed_string_t ip_version;
9801 : : uint32_t vlan_present:1;
9802 : : uint16_t tci;
9803 : : struct rte_ether_addr eth_src;
9804 : : struct rte_ether_addr eth_dst;
9805 : : };
9806 : :
9807 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
9808 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
9809 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
9810 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
9811 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
9812 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
9813 : : "l2_encap-with-vlan");
9814 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
9815 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9816 : : "ip-version");
9817 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
9818 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
9819 : : "ipv4#ipv6");
9820 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
9821 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9822 : : "vlan-tci");
9823 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
9824 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
9825 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
9826 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9827 : : "eth-src");
9828 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
9829 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
9830 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
9831 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9832 : : "eth-dst");
9833 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
9834 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
9835 : :
9836 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
9837 : : __rte_unused struct cmdline *cl,
9838 : : __rte_unused void *data)
9839 : : {
9840 : : struct cmd_set_l2_encap_result *res = parsed_result;
9841 : :
9842 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
9843 : 0 : l2_encap_conf.select_vlan = 0;
9844 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
9845 : 0 : l2_encap_conf.select_vlan = 1;
9846 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
9847 : 0 : l2_encap_conf.select_ipv4 = 1;
9848 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
9849 : 0 : l2_encap_conf.select_ipv4 = 0;
9850 : : else
9851 : : return;
9852 : 0 : if (l2_encap_conf.select_vlan)
9853 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9854 : 0 : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
9855 : : RTE_ETHER_ADDR_LEN);
9856 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9857 : : RTE_ETHER_ADDR_LEN);
9858 : : }
9859 : :
9860 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
9861 : : .f = cmd_set_l2_encap_parsed,
9862 : : .data = NULL,
9863 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
9864 : : " eth-src <eth-src> eth-dst <eth-dst>",
9865 : : .tokens = {
9866 : : (void *)&cmd_set_l2_encap_set,
9867 : : (void *)&cmd_set_l2_encap_l2_encap,
9868 : : (void *)&cmd_set_l2_encap_ip_version,
9869 : : (void *)&cmd_set_l2_encap_ip_version_value,
9870 : : (void *)&cmd_set_l2_encap_eth_src,
9871 : : (void *)&cmd_set_l2_encap_eth_src_value,
9872 : : (void *)&cmd_set_l2_encap_eth_dst,
9873 : : (void *)&cmd_set_l2_encap_eth_dst_value,
9874 : : NULL,
9875 : : },
9876 : : };
9877 : :
9878 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
9879 : : .f = cmd_set_l2_encap_parsed,
9880 : : .data = NULL,
9881 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
9882 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
9883 : : .tokens = {
9884 : : (void *)&cmd_set_l2_encap_set,
9885 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
9886 : : (void *)&cmd_set_l2_encap_ip_version,
9887 : : (void *)&cmd_set_l2_encap_ip_version_value,
9888 : : (void *)&cmd_set_l2_encap_vlan,
9889 : : (void *)&cmd_set_l2_encap_vlan_value,
9890 : : (void *)&cmd_set_l2_encap_eth_src,
9891 : : (void *)&cmd_set_l2_encap_eth_src_value,
9892 : : (void *)&cmd_set_l2_encap_eth_dst,
9893 : : (void *)&cmd_set_l2_encap_eth_dst_value,
9894 : : NULL,
9895 : : },
9896 : : };
9897 : :
9898 : : /** Set L2 decapsulation details */
9899 : : struct cmd_set_l2_decap_result {
9900 : : cmdline_fixed_string_t set;
9901 : : cmdline_fixed_string_t l2_decap;
9902 : : cmdline_fixed_string_t pos_token;
9903 : : uint32_t vlan_present:1;
9904 : : };
9905 : :
9906 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
9907 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
9908 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
9909 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
9910 : : "l2_decap");
9911 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
9912 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
9913 : : "l2_decap-with-vlan");
9914 : :
9915 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
9916 : : __rte_unused struct cmdline *cl,
9917 : : __rte_unused void *data)
9918 : : {
9919 : : struct cmd_set_l2_decap_result *res = parsed_result;
9920 : :
9921 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
9922 : 0 : l2_decap_conf.select_vlan = 0;
9923 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
9924 : 0 : l2_decap_conf.select_vlan = 1;
9925 : 0 : }
9926 : :
9927 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
9928 : : .f = cmd_set_l2_decap_parsed,
9929 : : .data = NULL,
9930 : : .help_str = "set l2_decap",
9931 : : .tokens = {
9932 : : (void *)&cmd_set_l2_decap_set,
9933 : : (void *)&cmd_set_l2_decap_l2_decap,
9934 : : NULL,
9935 : : },
9936 : : };
9937 : :
9938 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
9939 : : .f = cmd_set_l2_decap_parsed,
9940 : : .data = NULL,
9941 : : .help_str = "set l2_decap-with-vlan",
9942 : : .tokens = {
9943 : : (void *)&cmd_set_l2_decap_set,
9944 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
9945 : : NULL,
9946 : : },
9947 : : };
9948 : :
9949 : : /** Set MPLSoGRE encapsulation details */
9950 : : struct cmd_set_mplsogre_encap_result {
9951 : : cmdline_fixed_string_t set;
9952 : : cmdline_fixed_string_t mplsogre;
9953 : : cmdline_fixed_string_t pos_token;
9954 : : cmdline_fixed_string_t ip_version;
9955 : : uint32_t vlan_present:1;
9956 : : uint32_t label;
9957 : : cmdline_ipaddr_t ip_src;
9958 : : cmdline_ipaddr_t ip_dst;
9959 : : uint16_t tci;
9960 : : struct rte_ether_addr eth_src;
9961 : : struct rte_ether_addr eth_dst;
9962 : : };
9963 : :
9964 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
9965 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
9966 : : "set");
9967 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
9968 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
9969 : : "mplsogre_encap");
9970 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
9971 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9972 : : mplsogre, "mplsogre_encap-with-vlan");
9973 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
9974 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9975 : : pos_token, "ip-version");
9976 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
9977 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9978 : : ip_version, "ipv4#ipv6");
9979 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
9980 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9981 : : pos_token, "label");
9982 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
9983 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
9984 : : RTE_UINT32);
9985 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
9986 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9987 : : pos_token, "ip-src");
9988 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
9989 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
9990 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
9991 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9992 : : pos_token, "ip-dst");
9993 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
9994 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
9995 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
9996 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9997 : : pos_token, "vlan-tci");
9998 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
9999 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
10000 : : RTE_UINT16);
10001 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
10002 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10003 : : pos_token, "eth-src");
10004 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
10005 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10006 : : eth_src);
10007 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
10008 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10009 : : pos_token, "eth-dst");
10010 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
10011 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10012 : : eth_dst);
10013 : :
10014 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
10015 : : __rte_unused struct cmdline *cl,
10016 : : __rte_unused void *data)
10017 : : {
10018 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
10019 : : union {
10020 : : uint32_t mplsogre_label;
10021 : : uint8_t label[4];
10022 : 0 : } id = {
10023 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
10024 : : };
10025 : :
10026 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
10027 : 0 : mplsogre_encap_conf.select_vlan = 0;
10028 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
10029 : 0 : mplsogre_encap_conf.select_vlan = 1;
10030 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10031 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
10032 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10033 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
10034 : : else
10035 : 0 : return;
10036 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
10037 : 0 : if (mplsogre_encap_conf.select_ipv4) {
10038 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
10039 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
10040 : : } else {
10041 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
10042 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
10043 : : }
10044 : 0 : if (mplsogre_encap_conf.select_vlan)
10045 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10046 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
10047 : : RTE_ETHER_ADDR_LEN);
10048 : 0 : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10049 : : RTE_ETHER_ADDR_LEN);
10050 : : }
10051 : :
10052 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
10053 : : .f = cmd_set_mplsogre_encap_parsed,
10054 : : .data = NULL,
10055 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
10056 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10057 : : " eth-dst <eth-dst>",
10058 : : .tokens = {
10059 : : (void *)&cmd_set_mplsogre_encap_set,
10060 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
10061 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10062 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10063 : : (void *)&cmd_set_mplsogre_encap_label,
10064 : : (void *)&cmd_set_mplsogre_encap_label_value,
10065 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10066 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10067 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10068 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10069 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10070 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10071 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10072 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10073 : : NULL,
10074 : : },
10075 : : };
10076 : :
10077 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
10078 : : .f = cmd_set_mplsogre_encap_parsed,
10079 : : .data = NULL,
10080 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
10081 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
10082 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10083 : : .tokens = {
10084 : : (void *)&cmd_set_mplsogre_encap_set,
10085 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
10086 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10087 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10088 : : (void *)&cmd_set_mplsogre_encap_label,
10089 : : (void *)&cmd_set_mplsogre_encap_label_value,
10090 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10091 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10092 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10093 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10094 : : (void *)&cmd_set_mplsogre_encap_vlan,
10095 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
10096 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10097 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10098 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10099 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10100 : : NULL,
10101 : : },
10102 : : };
10103 : :
10104 : : /** Set MPLSoGRE decapsulation details */
10105 : : struct cmd_set_mplsogre_decap_result {
10106 : : cmdline_fixed_string_t set;
10107 : : cmdline_fixed_string_t mplsogre;
10108 : : cmdline_fixed_string_t pos_token;
10109 : : cmdline_fixed_string_t ip_version;
10110 : : uint32_t vlan_present:1;
10111 : : };
10112 : :
10113 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
10114 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
10115 : : "set");
10116 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
10117 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
10118 : : "mplsogre_decap");
10119 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
10120 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10121 : : mplsogre, "mplsogre_decap-with-vlan");
10122 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
10123 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10124 : : pos_token, "ip-version");
10125 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
10126 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10127 : : ip_version, "ipv4#ipv6");
10128 : :
10129 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
10130 : : __rte_unused struct cmdline *cl,
10131 : : __rte_unused void *data)
10132 : : {
10133 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
10134 : :
10135 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
10136 : 0 : mplsogre_decap_conf.select_vlan = 0;
10137 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
10138 : 0 : mplsogre_decap_conf.select_vlan = 1;
10139 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10140 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
10141 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10142 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
10143 : 0 : }
10144 : :
10145 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
10146 : : .f = cmd_set_mplsogre_decap_parsed,
10147 : : .data = NULL,
10148 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
10149 : : .tokens = {
10150 : : (void *)&cmd_set_mplsogre_decap_set,
10151 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
10152 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10153 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10154 : : NULL,
10155 : : },
10156 : : };
10157 : :
10158 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
10159 : : .f = cmd_set_mplsogre_decap_parsed,
10160 : : .data = NULL,
10161 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
10162 : : .tokens = {
10163 : : (void *)&cmd_set_mplsogre_decap_set,
10164 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
10165 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10166 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10167 : : NULL,
10168 : : },
10169 : : };
10170 : :
10171 : : /** Set MPLSoUDP encapsulation details */
10172 : : struct cmd_set_mplsoudp_encap_result {
10173 : : cmdline_fixed_string_t set;
10174 : : cmdline_fixed_string_t mplsoudp;
10175 : : cmdline_fixed_string_t pos_token;
10176 : : cmdline_fixed_string_t ip_version;
10177 : : uint32_t vlan_present:1;
10178 : : uint32_t label;
10179 : : uint16_t udp_src;
10180 : : uint16_t udp_dst;
10181 : : cmdline_ipaddr_t ip_src;
10182 : : cmdline_ipaddr_t ip_dst;
10183 : : uint16_t tci;
10184 : : struct rte_ether_addr eth_src;
10185 : : struct rte_ether_addr eth_dst;
10186 : : };
10187 : :
10188 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
10189 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
10190 : : "set");
10191 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
10192 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
10193 : : "mplsoudp_encap");
10194 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
10195 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10196 : : mplsoudp, "mplsoudp_encap-with-vlan");
10197 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
10198 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10199 : : pos_token, "ip-version");
10200 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
10201 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10202 : : ip_version, "ipv4#ipv6");
10203 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
10204 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10205 : : pos_token, "label");
10206 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
10207 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
10208 : : RTE_UINT32);
10209 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
10210 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10211 : : pos_token, "udp-src");
10212 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
10213 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
10214 : : RTE_UINT16);
10215 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
10216 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10217 : : pos_token, "udp-dst");
10218 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
10219 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
10220 : : RTE_UINT16);
10221 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
10222 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10223 : : pos_token, "ip-src");
10224 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
10225 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
10226 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
10227 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10228 : : pos_token, "ip-dst");
10229 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
10230 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
10231 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
10232 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10233 : : pos_token, "vlan-tci");
10234 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
10235 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
10236 : : RTE_UINT16);
10237 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
10238 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10239 : : pos_token, "eth-src");
10240 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
10241 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10242 : : eth_src);
10243 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
10244 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10245 : : pos_token, "eth-dst");
10246 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
10247 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10248 : : eth_dst);
10249 : :
10250 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
10251 : : __rte_unused struct cmdline *cl,
10252 : : __rte_unused void *data)
10253 : : {
10254 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
10255 : : union {
10256 : : uint32_t mplsoudp_label;
10257 : : uint8_t label[4];
10258 : 0 : } id = {
10259 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
10260 : : };
10261 : :
10262 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
10263 : 0 : mplsoudp_encap_conf.select_vlan = 0;
10264 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
10265 : 0 : mplsoudp_encap_conf.select_vlan = 1;
10266 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10267 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
10268 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10269 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
10270 : : else
10271 : 0 : return;
10272 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
10273 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10274 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10275 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10276 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
10277 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
10278 : : } else {
10279 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
10280 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
10281 : : }
10282 : 0 : if (mplsoudp_encap_conf.select_vlan)
10283 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10284 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
10285 : : RTE_ETHER_ADDR_LEN);
10286 : 0 : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10287 : : RTE_ETHER_ADDR_LEN);
10288 : : }
10289 : :
10290 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
10291 : : .f = cmd_set_mplsoudp_encap_parsed,
10292 : : .data = NULL,
10293 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
10294 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
10295 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
10296 : : .tokens = {
10297 : : (void *)&cmd_set_mplsoudp_encap_set,
10298 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
10299 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10300 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10301 : : (void *)&cmd_set_mplsoudp_encap_label,
10302 : : (void *)&cmd_set_mplsoudp_encap_label_value,
10303 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
10304 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
10305 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
10306 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10307 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
10308 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
10309 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
10310 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10311 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
10312 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
10313 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
10314 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10315 : : NULL,
10316 : : },
10317 : : };
10318 : :
10319 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
10320 : : .f = cmd_set_mplsoudp_encap_parsed,
10321 : : .data = NULL,
10322 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
10323 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
10324 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10325 : : " eth-src <eth-src> eth-dst <eth-dst>",
10326 : : .tokens = {
10327 : : (void *)&cmd_set_mplsoudp_encap_set,
10328 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
10329 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10330 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10331 : : (void *)&cmd_set_mplsoudp_encap_label,
10332 : : (void *)&cmd_set_mplsoudp_encap_label_value,
10333 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
10334 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
10335 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
10336 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10337 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
10338 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
10339 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
10340 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10341 : : (void *)&cmd_set_mplsoudp_encap_vlan,
10342 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
10343 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
10344 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
10345 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
10346 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10347 : : NULL,
10348 : : },
10349 : : };
10350 : :
10351 : : /** Set MPLSoUDP decapsulation details */
10352 : : struct cmd_set_mplsoudp_decap_result {
10353 : : cmdline_fixed_string_t set;
10354 : : cmdline_fixed_string_t mplsoudp;
10355 : : cmdline_fixed_string_t pos_token;
10356 : : cmdline_fixed_string_t ip_version;
10357 : : uint32_t vlan_present:1;
10358 : : };
10359 : :
10360 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
10361 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
10362 : : "set");
10363 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
10364 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
10365 : : "mplsoudp_decap");
10366 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
10367 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10368 : : mplsoudp, "mplsoudp_decap-with-vlan");
10369 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
10370 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10371 : : pos_token, "ip-version");
10372 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
10373 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10374 : : ip_version, "ipv4#ipv6");
10375 : :
10376 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
10377 : : __rte_unused struct cmdline *cl,
10378 : : __rte_unused void *data)
10379 : : {
10380 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
10381 : :
10382 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
10383 : 0 : mplsoudp_decap_conf.select_vlan = 0;
10384 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
10385 : 0 : mplsoudp_decap_conf.select_vlan = 1;
10386 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10387 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
10388 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10389 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
10390 : 0 : }
10391 : :
10392 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
10393 : : .f = cmd_set_mplsoudp_decap_parsed,
10394 : : .data = NULL,
10395 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
10396 : : .tokens = {
10397 : : (void *)&cmd_set_mplsoudp_decap_set,
10398 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
10399 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
10400 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
10401 : : NULL,
10402 : : },
10403 : : };
10404 : :
10405 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
10406 : : .f = cmd_set_mplsoudp_decap_parsed,
10407 : : .data = NULL,
10408 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
10409 : : .tokens = {
10410 : : (void *)&cmd_set_mplsoudp_decap_set,
10411 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
10412 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
10413 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
10414 : : NULL,
10415 : : },
10416 : : };
10417 : :
10418 : : /** Set connection tracking object common details */
10419 : : struct cmd_set_conntrack_common_result {
10420 : : cmdline_fixed_string_t set;
10421 : : cmdline_fixed_string_t conntrack;
10422 : : cmdline_fixed_string_t common;
10423 : : cmdline_fixed_string_t peer;
10424 : : cmdline_fixed_string_t is_orig;
10425 : : cmdline_fixed_string_t enable;
10426 : : cmdline_fixed_string_t live;
10427 : : cmdline_fixed_string_t sack;
10428 : : cmdline_fixed_string_t cack;
10429 : : cmdline_fixed_string_t last_dir;
10430 : : cmdline_fixed_string_t liberal;
10431 : : cmdline_fixed_string_t state;
10432 : : cmdline_fixed_string_t max_ack_win;
10433 : : cmdline_fixed_string_t retrans;
10434 : : cmdline_fixed_string_t last_win;
10435 : : cmdline_fixed_string_t last_seq;
10436 : : cmdline_fixed_string_t last_ack;
10437 : : cmdline_fixed_string_t last_end;
10438 : : cmdline_fixed_string_t last_index;
10439 : : uint8_t stat;
10440 : : uint8_t factor;
10441 : : uint16_t peer_port;
10442 : : uint32_t is_original;
10443 : : uint32_t en;
10444 : : uint32_t is_live;
10445 : : uint32_t s_ack;
10446 : : uint32_t c_ack;
10447 : : uint32_t ld;
10448 : : uint32_t lb;
10449 : : uint8_t re_num;
10450 : : uint8_t li;
10451 : : uint16_t lw;
10452 : : uint32_t ls;
10453 : : uint32_t la;
10454 : : uint32_t le;
10455 : : };
10456 : :
10457 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
10458 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10459 : : set, "set");
10460 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
10461 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10462 : : conntrack, "conntrack");
10463 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
10464 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10465 : : common, "com");
10466 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
10467 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10468 : : peer, "peer");
10469 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
10470 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10471 : : peer_port, RTE_UINT16);
10472 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
10473 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10474 : : is_orig, "is_orig");
10475 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
10476 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10477 : : is_original, RTE_UINT32);
10478 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
10479 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10480 : : enable, "enable");
10481 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
10482 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10483 : : en, RTE_UINT32);
10484 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
10485 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10486 : : live, "live");
10487 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
10488 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10489 : : is_live, RTE_UINT32);
10490 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
10491 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10492 : : sack, "sack");
10493 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
10494 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10495 : : s_ack, RTE_UINT32);
10496 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
10497 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10498 : : cack, "cack");
10499 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
10500 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10501 : : c_ack, RTE_UINT32);
10502 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
10503 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10504 : : last_dir, "last_dir");
10505 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
10506 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10507 : : ld, RTE_UINT32);
10508 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
10509 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10510 : : liberal, "liberal");
10511 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
10512 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10513 : : lb, RTE_UINT32);
10514 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
10515 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10516 : : state, "state");
10517 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
10518 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10519 : : stat, RTE_UINT8);
10520 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
10521 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10522 : : max_ack_win, "max_ack_win");
10523 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
10524 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10525 : : factor, RTE_UINT8);
10526 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
10527 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10528 : : retrans, "r_lim");
10529 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
10530 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10531 : : re_num, RTE_UINT8);
10532 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
10533 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10534 : : last_win, "last_win");
10535 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
10536 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10537 : : lw, RTE_UINT16);
10538 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
10539 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10540 : : last_seq, "last_seq");
10541 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
10542 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10543 : : ls, RTE_UINT32);
10544 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
10545 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10546 : : last_ack, "last_ack");
10547 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
10548 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10549 : : la, RTE_UINT32);
10550 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
10551 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10552 : : last_end, "last_end");
10553 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
10554 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10555 : : le, RTE_UINT32);
10556 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
10557 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10558 : : last_index, "last_index");
10559 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
10560 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10561 : : li, RTE_UINT8);
10562 : :
10563 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
10564 : : __rte_unused struct cmdline *cl,
10565 : : __rte_unused void *data)
10566 : : {
10567 : : struct cmd_set_conntrack_common_result *res = parsed_result;
10568 : :
10569 : : /* No need to swap to big endian. */
10570 : 0 : conntrack_context.peer_port = res->peer_port;
10571 : 0 : conntrack_context.is_original_dir = res->is_original;
10572 : 0 : conntrack_context.enable = res->en;
10573 : 0 : conntrack_context.live_connection = res->is_live;
10574 : 0 : conntrack_context.selective_ack = res->s_ack;
10575 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
10576 : 0 : conntrack_context.last_direction = res->ld;
10577 : 0 : conntrack_context.liberal_mode = res->lb;
10578 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
10579 : 0 : conntrack_context.max_ack_window = res->factor;
10580 : 0 : conntrack_context.retransmission_limit = res->re_num;
10581 : 0 : conntrack_context.last_window = res->lw;
10582 : 0 : conntrack_context.last_index =
10583 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
10584 : 0 : conntrack_context.last_seq = res->ls;
10585 : 0 : conntrack_context.last_ack = res->la;
10586 : 0 : conntrack_context.last_end = res->le;
10587 : 0 : }
10588 : :
10589 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
10590 : : .f = cmd_set_conntrack_common_parsed,
10591 : : .data = NULL,
10592 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
10593 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
10594 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
10595 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
10596 : : " last_index <flag>",
10597 : : .tokens = {
10598 : : (void *)&cmd_set_conntrack_set,
10599 : : (void *)&cmd_set_conntrack_conntrack,
10600 : : (void *)&cmd_set_conntrack_common_com,
10601 : : (void *)&cmd_set_conntrack_common_peer,
10602 : : (void *)&cmd_set_conntrack_common_peer_value,
10603 : : (void *)&cmd_set_conntrack_common_is_orig,
10604 : : (void *)&cmd_set_conntrack_common_is_orig_value,
10605 : : (void *)&cmd_set_conntrack_common_enable,
10606 : : (void *)&cmd_set_conntrack_common_enable_value,
10607 : : (void *)&cmd_set_conntrack_common_live,
10608 : : (void *)&cmd_set_conntrack_common_live_value,
10609 : : (void *)&cmd_set_conntrack_common_sack,
10610 : : (void *)&cmd_set_conntrack_common_sack_value,
10611 : : (void *)&cmd_set_conntrack_common_cack,
10612 : : (void *)&cmd_set_conntrack_common_cack_value,
10613 : : (void *)&cmd_set_conntrack_common_last_dir,
10614 : : (void *)&cmd_set_conntrack_common_last_dir_value,
10615 : : (void *)&cmd_set_conntrack_common_liberal,
10616 : : (void *)&cmd_set_conntrack_common_liberal_value,
10617 : : (void *)&cmd_set_conntrack_common_state,
10618 : : (void *)&cmd_set_conntrack_common_state_value,
10619 : : (void *)&cmd_set_conntrack_common_max_ackwin,
10620 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
10621 : : (void *)&cmd_set_conntrack_common_retrans,
10622 : : (void *)&cmd_set_conntrack_common_retrans_value,
10623 : : (void *)&cmd_set_conntrack_common_last_win,
10624 : : (void *)&cmd_set_conntrack_common_last_win_value,
10625 : : (void *)&cmd_set_conntrack_common_last_seq,
10626 : : (void *)&cmd_set_conntrack_common_last_seq_value,
10627 : : (void *)&cmd_set_conntrack_common_last_ack,
10628 : : (void *)&cmd_set_conntrack_common_last_ack_value,
10629 : : (void *)&cmd_set_conntrack_common_last_end,
10630 : : (void *)&cmd_set_conntrack_common_last_end_value,
10631 : : (void *)&cmd_set_conntrack_common_last_index,
10632 : : (void *)&cmd_set_conntrack_common_last_index_value,
10633 : : NULL,
10634 : : },
10635 : : };
10636 : :
10637 : : /** Set connection tracking object both directions' details */
10638 : : struct cmd_set_conntrack_dir_result {
10639 : : cmdline_fixed_string_t set;
10640 : : cmdline_fixed_string_t conntrack;
10641 : : cmdline_fixed_string_t dir;
10642 : : cmdline_fixed_string_t scale;
10643 : : cmdline_fixed_string_t fin;
10644 : : cmdline_fixed_string_t ack_seen;
10645 : : cmdline_fixed_string_t unack;
10646 : : cmdline_fixed_string_t sent_end;
10647 : : cmdline_fixed_string_t reply_end;
10648 : : cmdline_fixed_string_t max_win;
10649 : : cmdline_fixed_string_t max_ack;
10650 : : uint32_t factor;
10651 : : uint32_t f;
10652 : : uint32_t as;
10653 : : uint32_t un;
10654 : : uint32_t se;
10655 : : uint32_t re;
10656 : : uint32_t mw;
10657 : : uint32_t ma;
10658 : : };
10659 : :
10660 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
10661 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10662 : : dir, "orig#rply");
10663 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
10664 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10665 : : scale, "scale");
10666 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
10667 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10668 : : factor, RTE_UINT32);
10669 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
10670 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10671 : : fin, "fin");
10672 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
10673 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10674 : : f, RTE_UINT32);
10675 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
10676 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10677 : : ack_seen, "acked");
10678 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
10679 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10680 : : as, RTE_UINT32);
10681 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
10682 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10683 : : unack, "unack_data");
10684 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
10685 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10686 : : un, RTE_UINT32);
10687 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
10688 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10689 : : sent_end, "sent_end");
10690 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
10691 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10692 : : se, RTE_UINT32);
10693 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
10694 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10695 : : reply_end, "reply_end");
10696 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
10697 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10698 : : re, RTE_UINT32);
10699 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
10700 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10701 : : max_win, "max_win");
10702 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
10703 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10704 : : mw, RTE_UINT32);
10705 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
10706 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10707 : : max_ack, "max_ack");
10708 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
10709 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10710 : : ma, RTE_UINT32);
10711 : :
10712 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
10713 : : __rte_unused struct cmdline *cl,
10714 : : __rte_unused void *data)
10715 : : {
10716 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
10717 : : struct rte_flow_tcp_dir_param *dir = NULL;
10718 : :
10719 : 0 : if (strcmp(res->dir, "orig") == 0)
10720 : : dir = &conntrack_context.original_dir;
10721 : 0 : else if (strcmp(res->dir, "rply") == 0)
10722 : : dir = &conntrack_context.reply_dir;
10723 : : else
10724 : : return;
10725 : 0 : dir->scale = res->factor;
10726 : 0 : dir->close_initiated = res->f;
10727 : 0 : dir->last_ack_seen = res->as;
10728 : 0 : dir->data_unacked = res->un;
10729 : 0 : dir->sent_end = res->se;
10730 : 0 : dir->reply_end = res->re;
10731 : 0 : dir->max_ack = res->ma;
10732 : 0 : dir->max_win = res->mw;
10733 : : }
10734 : :
10735 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
10736 : : .f = cmd_set_conntrack_dir_parsed,
10737 : : .data = NULL,
10738 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
10739 : : " acked <seen> unack_data <unack> sent_end <sent>"
10740 : : " reply_end <reply> max_win <win> max_ack <ack>",
10741 : : .tokens = {
10742 : : (void *)&cmd_set_conntrack_set,
10743 : : (void *)&cmd_set_conntrack_conntrack,
10744 : : (void *)&cmd_set_conntrack_dir_dir,
10745 : : (void *)&cmd_set_conntrack_dir_scale,
10746 : : (void *)&cmd_set_conntrack_dir_scale_value,
10747 : : (void *)&cmd_set_conntrack_dir_fin,
10748 : : (void *)&cmd_set_conntrack_dir_fin_value,
10749 : : (void *)&cmd_set_conntrack_dir_ack,
10750 : : (void *)&cmd_set_conntrack_dir_ack_value,
10751 : : (void *)&cmd_set_conntrack_dir_unack_data,
10752 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
10753 : : (void *)&cmd_set_conntrack_dir_sent_end,
10754 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
10755 : : (void *)&cmd_set_conntrack_dir_reply_end,
10756 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
10757 : : (void *)&cmd_set_conntrack_dir_max_win,
10758 : : (void *)&cmd_set_conntrack_dir_max_win_value,
10759 : : (void *)&cmd_set_conntrack_dir_max_ack,
10760 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
10761 : : NULL,
10762 : : },
10763 : : };
10764 : :
10765 : : /* show vf stats */
10766 : :
10767 : : /* Common result structure for show vf stats */
10768 : : struct cmd_show_vf_stats_result {
10769 : : cmdline_fixed_string_t show;
10770 : : cmdline_fixed_string_t vf;
10771 : : cmdline_fixed_string_t stats;
10772 : : portid_t port_id;
10773 : : uint16_t vf_id;
10774 : : };
10775 : :
10776 : : /* Common CLI fields show vf stats*/
10777 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
10778 : : TOKEN_STRING_INITIALIZER
10779 : : (struct cmd_show_vf_stats_result,
10780 : : show, "show");
10781 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
10782 : : TOKEN_STRING_INITIALIZER
10783 : : (struct cmd_show_vf_stats_result,
10784 : : vf, "vf");
10785 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
10786 : : TOKEN_STRING_INITIALIZER
10787 : : (struct cmd_show_vf_stats_result,
10788 : : stats, "stats");
10789 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
10790 : : TOKEN_NUM_INITIALIZER
10791 : : (struct cmd_show_vf_stats_result,
10792 : : port_id, RTE_UINT16);
10793 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
10794 : : TOKEN_NUM_INITIALIZER
10795 : : (struct cmd_show_vf_stats_result,
10796 : : vf_id, RTE_UINT16);
10797 : :
10798 : : static void
10799 : 0 : cmd_show_vf_stats_parsed(
10800 : : void *parsed_result,
10801 : : __rte_unused struct cmdline *cl,
10802 : : __rte_unused void *data)
10803 : : {
10804 : : struct cmd_show_vf_stats_result *res = parsed_result;
10805 : : struct rte_eth_stats stats;
10806 : : int ret = -ENOTSUP;
10807 : : static const char *nic_stats_border = "########################";
10808 : :
10809 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10810 : 0 : return;
10811 : :
10812 : : memset(&stats, 0, sizeof(stats));
10813 : :
10814 : : #ifdef RTE_NET_I40E
10815 : : if (ret == -ENOTSUP)
10816 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
10817 : 0 : res->vf_id,
10818 : : &stats);
10819 : : #endif
10820 : : #ifdef RTE_NET_BNXT
10821 : 0 : if (ret == -ENOTSUP)
10822 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
10823 : 0 : res->vf_id,
10824 : : &stats);
10825 : : #endif
10826 : :
10827 : 0 : switch (ret) {
10828 : : case 0:
10829 : : break;
10830 : 0 : case -EINVAL:
10831 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
10832 : : break;
10833 : 0 : case -ENODEV:
10834 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10835 : : break;
10836 : 0 : case -ENOTSUP:
10837 : 0 : fprintf(stderr, "function not implemented\n");
10838 : : break;
10839 : 0 : default:
10840 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10841 : : }
10842 : :
10843 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
10844 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
10845 : :
10846 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
10847 : : "%-"PRIu64"\n",
10848 : : stats.ipackets, stats.imissed, stats.ibytes);
10849 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
10850 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
10851 : : stats.rx_nombuf);
10852 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
10853 : : "%-"PRIu64"\n",
10854 : : stats.opackets, stats.oerrors, stats.obytes);
10855 : :
10856 : 0 : printf(" %s############################%s\n",
10857 : : nic_stats_border, nic_stats_border);
10858 : : }
10859 : :
10860 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
10861 : : .f = cmd_show_vf_stats_parsed,
10862 : : .data = NULL,
10863 : : .help_str = "show vf stats <port_id> <vf_id>",
10864 : : .tokens = {
10865 : : (void *)&cmd_show_vf_stats_show,
10866 : : (void *)&cmd_show_vf_stats_vf,
10867 : : (void *)&cmd_show_vf_stats_stats,
10868 : : (void *)&cmd_show_vf_stats_port_id,
10869 : : (void *)&cmd_show_vf_stats_vf_id,
10870 : : NULL,
10871 : : },
10872 : : };
10873 : :
10874 : : /* clear vf stats */
10875 : :
10876 : : /* Common result structure for clear vf stats */
10877 : : struct cmd_clear_vf_stats_result {
10878 : : cmdline_fixed_string_t clear;
10879 : : cmdline_fixed_string_t vf;
10880 : : cmdline_fixed_string_t stats;
10881 : : portid_t port_id;
10882 : : uint16_t vf_id;
10883 : : };
10884 : :
10885 : : /* Common CLI fields clear vf stats*/
10886 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
10887 : : TOKEN_STRING_INITIALIZER
10888 : : (struct cmd_clear_vf_stats_result,
10889 : : clear, "clear");
10890 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
10891 : : TOKEN_STRING_INITIALIZER
10892 : : (struct cmd_clear_vf_stats_result,
10893 : : vf, "vf");
10894 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
10895 : : TOKEN_STRING_INITIALIZER
10896 : : (struct cmd_clear_vf_stats_result,
10897 : : stats, "stats");
10898 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
10899 : : TOKEN_NUM_INITIALIZER
10900 : : (struct cmd_clear_vf_stats_result,
10901 : : port_id, RTE_UINT16);
10902 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
10903 : : TOKEN_NUM_INITIALIZER
10904 : : (struct cmd_clear_vf_stats_result,
10905 : : vf_id, RTE_UINT16);
10906 : :
10907 : : static void
10908 : 0 : cmd_clear_vf_stats_parsed(
10909 : : void *parsed_result,
10910 : : __rte_unused struct cmdline *cl,
10911 : : __rte_unused void *data)
10912 : : {
10913 : : struct cmd_clear_vf_stats_result *res = parsed_result;
10914 : : int ret = -ENOTSUP;
10915 : :
10916 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10917 : : return;
10918 : :
10919 : : #ifdef RTE_NET_I40E
10920 : : if (ret == -ENOTSUP)
10921 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
10922 : 0 : res->vf_id);
10923 : : #endif
10924 : : #ifdef RTE_NET_BNXT
10925 : 0 : if (ret == -ENOTSUP)
10926 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
10927 : 0 : res->vf_id);
10928 : : #endif
10929 : :
10930 : 0 : switch (ret) {
10931 : : case 0:
10932 : : break;
10933 : 0 : case -EINVAL:
10934 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
10935 : : break;
10936 : 0 : case -ENODEV:
10937 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10938 : : break;
10939 : 0 : case -ENOTSUP:
10940 : 0 : fprintf(stderr, "function not implemented\n");
10941 : : break;
10942 : 0 : default:
10943 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10944 : : }
10945 : : }
10946 : :
10947 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
10948 : : .f = cmd_clear_vf_stats_parsed,
10949 : : .data = NULL,
10950 : : .help_str = "clear vf stats <port_id> <vf_id>",
10951 : : .tokens = {
10952 : : (void *)&cmd_clear_vf_stats_clear,
10953 : : (void *)&cmd_clear_vf_stats_vf,
10954 : : (void *)&cmd_clear_vf_stats_stats,
10955 : : (void *)&cmd_clear_vf_stats_port_id,
10956 : : (void *)&cmd_clear_vf_stats_vf_id,
10957 : : NULL,
10958 : : },
10959 : : };
10960 : :
10961 : : /* Common result structure for file commands */
10962 : : struct cmd_cmdfile_result {
10963 : : cmdline_fixed_string_t load;
10964 : : cmdline_fixed_string_t filename;
10965 : : };
10966 : :
10967 : : /* Common CLI fields for file commands */
10968 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
10969 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
10970 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
10971 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
10972 : :
10973 : : static void
10974 : 0 : cmd_load_from_file_parsed(
10975 : : void *parsed_result,
10976 : : __rte_unused struct cmdline *cl,
10977 : : __rte_unused void *data)
10978 : : {
10979 : : struct cmd_cmdfile_result *res = parsed_result;
10980 : :
10981 : 0 : cmdline_read_from_file(res->filename);
10982 : 0 : }
10983 : :
10984 : : static cmdline_parse_inst_t cmd_load_from_file = {
10985 : : .f = cmd_load_from_file_parsed,
10986 : : .data = NULL,
10987 : : .help_str = "load <filename>",
10988 : : .tokens = {
10989 : : (void *)&cmd_load_cmdfile,
10990 : : (void *)&cmd_load_cmdfile_filename,
10991 : : NULL,
10992 : : },
10993 : : };
10994 : :
10995 : : /* Get Rx offloads capabilities */
10996 : : struct cmd_rx_offload_get_capa_result {
10997 : : cmdline_fixed_string_t show;
10998 : : cmdline_fixed_string_t port;
10999 : : portid_t port_id;
11000 : : cmdline_fixed_string_t rx_offload;
11001 : : cmdline_fixed_string_t capabilities;
11002 : : };
11003 : :
11004 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
11005 : : TOKEN_STRING_INITIALIZER
11006 : : (struct cmd_rx_offload_get_capa_result,
11007 : : show, "show");
11008 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
11009 : : TOKEN_STRING_INITIALIZER
11010 : : (struct cmd_rx_offload_get_capa_result,
11011 : : port, "port");
11012 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
11013 : : TOKEN_NUM_INITIALIZER
11014 : : (struct cmd_rx_offload_get_capa_result,
11015 : : port_id, RTE_UINT16);
11016 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
11017 : : TOKEN_STRING_INITIALIZER
11018 : : (struct cmd_rx_offload_get_capa_result,
11019 : : rx_offload, "rx_offload");
11020 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
11021 : : TOKEN_STRING_INITIALIZER
11022 : : (struct cmd_rx_offload_get_capa_result,
11023 : : capabilities, "capabilities");
11024 : :
11025 : : static void
11026 : 0 : print_rx_offloads(uint64_t offloads)
11027 : : {
11028 : : uint64_t single_offload;
11029 : : int begin;
11030 : : int end;
11031 : : int bit;
11032 : :
11033 : 0 : if (offloads == 0)
11034 : : return;
11035 : :
11036 : : begin = rte_ctz64(offloads);
11037 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11038 : :
11039 : 0 : single_offload = 1ULL << begin;
11040 : 0 : for (bit = begin; bit < end; bit++) {
11041 : 0 : if (offloads & single_offload)
11042 : 0 : printf(" %s",
11043 : : rte_eth_dev_rx_offload_name(single_offload));
11044 : 0 : single_offload <<= 1;
11045 : : }
11046 : : }
11047 : :
11048 : : static void
11049 : 0 : cmd_rx_offload_get_capa_parsed(
11050 : : void *parsed_result,
11051 : : __rte_unused struct cmdline *cl,
11052 : : __rte_unused void *data)
11053 : : {
11054 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
11055 : : struct rte_eth_dev_info dev_info;
11056 : 0 : portid_t port_id = res->port_id;
11057 : : uint64_t queue_offloads;
11058 : : uint64_t port_offloads;
11059 : : int ret;
11060 : :
11061 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11062 : 0 : if (ret != 0)
11063 : 0 : return;
11064 : :
11065 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
11066 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
11067 : :
11068 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
11069 : : printf(" Per Queue :");
11070 : 0 : print_rx_offloads(queue_offloads);
11071 : :
11072 : : printf("\n");
11073 : : printf(" Per Port :");
11074 : 0 : print_rx_offloads(port_offloads);
11075 : : printf("\n\n");
11076 : : }
11077 : :
11078 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
11079 : : .f = cmd_rx_offload_get_capa_parsed,
11080 : : .data = NULL,
11081 : : .help_str = "show port <port_id> rx_offload capabilities",
11082 : : .tokens = {
11083 : : (void *)&cmd_rx_offload_get_capa_show,
11084 : : (void *)&cmd_rx_offload_get_capa_port,
11085 : : (void *)&cmd_rx_offload_get_capa_port_id,
11086 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
11087 : : (void *)&cmd_rx_offload_get_capa_capabilities,
11088 : : NULL,
11089 : : }
11090 : : };
11091 : :
11092 : : /* Get Rx offloads configuration */
11093 : : struct cmd_rx_offload_get_configuration_result {
11094 : : cmdline_fixed_string_t show;
11095 : : cmdline_fixed_string_t port;
11096 : : portid_t port_id;
11097 : : cmdline_fixed_string_t rx_offload;
11098 : : cmdline_fixed_string_t configuration;
11099 : : };
11100 : :
11101 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
11102 : : TOKEN_STRING_INITIALIZER
11103 : : (struct cmd_rx_offload_get_configuration_result,
11104 : : show, "show");
11105 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
11106 : : TOKEN_STRING_INITIALIZER
11107 : : (struct cmd_rx_offload_get_configuration_result,
11108 : : port, "port");
11109 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
11110 : : TOKEN_NUM_INITIALIZER
11111 : : (struct cmd_rx_offload_get_configuration_result,
11112 : : port_id, RTE_UINT16);
11113 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
11114 : : TOKEN_STRING_INITIALIZER
11115 : : (struct cmd_rx_offload_get_configuration_result,
11116 : : rx_offload, "rx_offload");
11117 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
11118 : : TOKEN_STRING_INITIALIZER
11119 : : (struct cmd_rx_offload_get_configuration_result,
11120 : : configuration, "configuration");
11121 : :
11122 : : static void
11123 : 0 : cmd_rx_offload_get_configuration_parsed(
11124 : : void *parsed_result,
11125 : : __rte_unused struct cmdline *cl,
11126 : : __rte_unused void *data)
11127 : : {
11128 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
11129 : : struct rte_eth_dev_info dev_info;
11130 : 0 : portid_t port_id = res->port_id;
11131 : 0 : struct rte_port *port = &ports[port_id];
11132 : : struct rte_eth_conf dev_conf;
11133 : : uint64_t port_offloads;
11134 : : uint64_t queue_offloads;
11135 : : uint16_t nb_rx_queues;
11136 : : int q;
11137 : : int ret;
11138 : :
11139 : 0 : printf("Rx Offloading Configuration of port %d :\n", port_id);
11140 : :
11141 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11142 : 0 : if (ret != 0)
11143 : 0 : return;
11144 : :
11145 : 0 : port_offloads = dev_conf.rxmode.offloads;
11146 : : printf(" Port :");
11147 : 0 : print_rx_offloads(port_offloads);
11148 : : printf("\n");
11149 : :
11150 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11151 : 0 : if (ret != 0)
11152 : : return;
11153 : :
11154 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11155 : 0 : for (q = 0; q < nb_rx_queues; q++) {
11156 : 0 : queue_offloads = port->rxq[q].conf.offloads;
11157 : : printf(" Queue[%2d] :", q);
11158 : 0 : print_rx_offloads(queue_offloads);
11159 : : printf("\n");
11160 : : }
11161 : : printf("\n");
11162 : : }
11163 : :
11164 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
11165 : : .f = cmd_rx_offload_get_configuration_parsed,
11166 : : .data = NULL,
11167 : : .help_str = "show port <port_id> rx_offload configuration",
11168 : : .tokens = {
11169 : : (void *)&cmd_rx_offload_get_configuration_show,
11170 : : (void *)&cmd_rx_offload_get_configuration_port,
11171 : : (void *)&cmd_rx_offload_get_configuration_port_id,
11172 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
11173 : : (void *)&cmd_rx_offload_get_configuration_configuration,
11174 : : NULL,
11175 : : }
11176 : : };
11177 : :
11178 : : /* Enable/Disable a per port offloading */
11179 : : struct cmd_config_per_port_rx_offload_result {
11180 : : cmdline_fixed_string_t port;
11181 : : cmdline_fixed_string_t config;
11182 : : portid_t port_id;
11183 : : cmdline_fixed_string_t rx_offload;
11184 : : cmdline_fixed_string_t offload;
11185 : : cmdline_fixed_string_t on_off;
11186 : : };
11187 : :
11188 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
11189 : : TOKEN_STRING_INITIALIZER
11190 : : (struct cmd_config_per_port_rx_offload_result,
11191 : : port, "port");
11192 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
11193 : : TOKEN_STRING_INITIALIZER
11194 : : (struct cmd_config_per_port_rx_offload_result,
11195 : : config, "config");
11196 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
11197 : : TOKEN_NUM_INITIALIZER
11198 : : (struct cmd_config_per_port_rx_offload_result,
11199 : : port_id, RTE_UINT16);
11200 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
11201 : : TOKEN_STRING_INITIALIZER
11202 : : (struct cmd_config_per_port_rx_offload_result,
11203 : : rx_offload, "rx_offload");
11204 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
11205 : : TOKEN_STRING_INITIALIZER
11206 : : (struct cmd_config_per_port_rx_offload_result,
11207 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11208 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11209 : : "vlan_filter#vlan_extend#"
11210 : : "scatter#buffer_split#timestamp#security#"
11211 : : "keep_crc#rss_hash");
11212 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
11213 : : TOKEN_STRING_INITIALIZER
11214 : : (struct cmd_config_per_port_rx_offload_result,
11215 : : on_off, "on#off");
11216 : :
11217 : : static uint64_t
11218 : 0 : search_rx_offload(const char *name)
11219 : : {
11220 : : uint64_t single_offload;
11221 : : const char *single_name;
11222 : : int found = 0;
11223 : : unsigned int bit;
11224 : :
11225 : : single_offload = 1;
11226 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11227 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
11228 : 0 : if (!strcasecmp(single_name, name)) {
11229 : : found = 1;
11230 : : break;
11231 : : }
11232 : 0 : single_offload <<= 1;
11233 : : }
11234 : :
11235 : 0 : if (found)
11236 : 0 : return single_offload;
11237 : :
11238 : : return 0;
11239 : : }
11240 : :
11241 : : static void
11242 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
11243 : : {
11244 : : struct rte_eth_dev_info dev_info;
11245 : 0 : struct rte_port *port = &ports[port_id];
11246 : : uint16_t nb_rx_queues;
11247 : : uint64_t offload;
11248 : : int q;
11249 : : int ret;
11250 : :
11251 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11252 : 0 : fprintf(stderr,
11253 : : "Error: Can't config offload when Port %d is not stopped\n",
11254 : : port_id);
11255 : 0 : return;
11256 : : }
11257 : :
11258 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11259 : 0 : if (ret != 0)
11260 : : return;
11261 : :
11262 : 0 : if (!strcmp(name, "all")) {
11263 : 0 : offload = dev_info.rx_offload_capa;
11264 : : } else {
11265 : 0 : offload = search_rx_offload(name);
11266 : 0 : if (offload == 0) {
11267 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
11268 : 0 : return;
11269 : : }
11270 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
11271 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11272 : : port_id, name);
11273 : 0 : return;
11274 : : }
11275 : : }
11276 : :
11277 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11278 : 0 : if (on) {
11279 : 0 : port->dev_conf.rxmode.offloads |= offload;
11280 : 0 : for (q = 0; q < nb_rx_queues; q++)
11281 : 0 : port->rxq[q].conf.offloads |= offload;
11282 : : } else {
11283 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
11284 : 0 : for (q = 0; q < nb_rx_queues; q++)
11285 : 0 : port->rxq[q].conf.offloads &= ~offload;
11286 : : }
11287 : :
11288 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11289 : : }
11290 : :
11291 : : static void
11292 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
11293 : : __rte_unused struct cmdline *cl,
11294 : : __rte_unused void *data)
11295 : : {
11296 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
11297 : : bool on;
11298 : :
11299 : 0 : on = strcmp(res->on_off, "on") == 0;
11300 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
11301 : 0 : }
11302 : :
11303 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
11304 : : .f = cmd_config_per_port_rx_offload_parsed,
11305 : : .data = NULL,
11306 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
11307 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11308 : : "macsec_strip|vlan_filter|vlan_extend|"
11309 : : "scatter|buffer_split|timestamp|security|"
11310 : : "keep_crc|rss_hash on|off",
11311 : : .tokens = {
11312 : : (void *)&cmd_config_per_port_rx_offload_result_port,
11313 : : (void *)&cmd_config_per_port_rx_offload_result_config,
11314 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
11315 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
11316 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
11317 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
11318 : : NULL,
11319 : : }
11320 : : };
11321 : :
11322 : : /* Enable/Disable all port Rx offloading */
11323 : : struct cmd_config_all_port_rx_offload_result {
11324 : : cmdline_fixed_string_t port;
11325 : : cmdline_fixed_string_t config;
11326 : : cmdline_fixed_string_t port_all;
11327 : : cmdline_fixed_string_t rx_offload;
11328 : : cmdline_fixed_string_t offload;
11329 : : cmdline_fixed_string_t on_off;
11330 : : };
11331 : :
11332 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
11333 : : TOKEN_STRING_INITIALIZER
11334 : : (struct cmd_config_all_port_rx_offload_result,
11335 : : port, "port");
11336 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
11337 : : TOKEN_STRING_INITIALIZER
11338 : : (struct cmd_config_all_port_rx_offload_result,
11339 : : config, "config");
11340 : :
11341 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
11342 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
11343 : : port_all, "all");
11344 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
11345 : : TOKEN_STRING_INITIALIZER
11346 : : (struct cmd_config_all_port_rx_offload_result,
11347 : : rx_offload, "rx_offload");
11348 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
11349 : : TOKEN_STRING_INITIALIZER
11350 : : (struct cmd_config_all_port_rx_offload_result,
11351 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11352 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11353 : : "vlan_filter#vlan_extend#"
11354 : : "scatter#buffer_split#timestamp#security#"
11355 : : "keep_crc#rss_hash");
11356 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
11357 : : TOKEN_STRING_INITIALIZER
11358 : : (struct cmd_config_all_port_rx_offload_result,
11359 : : on_off, "on#off");
11360 : :
11361 : : static void
11362 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
11363 : : __rte_unused struct cmdline *cl,
11364 : : __rte_unused void *data)
11365 : : {
11366 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
11367 : : bool on_off;
11368 : : portid_t i;
11369 : :
11370 : 0 : on_off = strcmp(res->on_off, "on") == 0;
11371 : 0 : RTE_ETH_FOREACH_DEV(i)
11372 : 0 : config_port_rx_offload(i, res->offload, on_off);
11373 : :
11374 : 0 : }
11375 : :
11376 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
11377 : : .f = cmd_config_all_port_rx_offload_parsed,
11378 : : .data = NULL,
11379 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
11380 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11381 : : "macsec_strip|vlan_filter|vlan_extend|"
11382 : : "scatter|buffer_split|timestamp|security|"
11383 : : "keep_crc|rss_hash on|off",
11384 : : .tokens = {
11385 : : (void *)&cmd_config_all_port_rx_offload_result_port,
11386 : : (void *)&cmd_config_all_port_rx_offload_result_config,
11387 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
11388 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
11389 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
11390 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
11391 : : NULL,
11392 : : }
11393 : : };
11394 : :
11395 : : /* Enable/Disable a per queue offloading */
11396 : : struct cmd_config_per_queue_rx_offload_result {
11397 : : cmdline_fixed_string_t port;
11398 : : portid_t port_id;
11399 : : cmdline_fixed_string_t rxq;
11400 : : uint16_t queue_id;
11401 : : cmdline_fixed_string_t rx_offload;
11402 : : cmdline_fixed_string_t offload;
11403 : : cmdline_fixed_string_t on_off;
11404 : : };
11405 : :
11406 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
11407 : : TOKEN_STRING_INITIALIZER
11408 : : (struct cmd_config_per_queue_rx_offload_result,
11409 : : port, "port");
11410 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
11411 : : TOKEN_NUM_INITIALIZER
11412 : : (struct cmd_config_per_queue_rx_offload_result,
11413 : : port_id, RTE_UINT16);
11414 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
11415 : : TOKEN_STRING_INITIALIZER
11416 : : (struct cmd_config_per_queue_rx_offload_result,
11417 : : rxq, "rxq");
11418 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
11419 : : TOKEN_NUM_INITIALIZER
11420 : : (struct cmd_config_per_queue_rx_offload_result,
11421 : : queue_id, RTE_UINT16);
11422 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
11423 : : TOKEN_STRING_INITIALIZER
11424 : : (struct cmd_config_per_queue_rx_offload_result,
11425 : : rx_offload, "rx_offload");
11426 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
11427 : : TOKEN_STRING_INITIALIZER
11428 : : (struct cmd_config_per_queue_rx_offload_result,
11429 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11430 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11431 : : "vlan_filter#vlan_extend#"
11432 : : "scatter#buffer_split#timestamp#security#keep_crc");
11433 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
11434 : : TOKEN_STRING_INITIALIZER
11435 : : (struct cmd_config_per_queue_rx_offload_result,
11436 : : on_off, "on#off");
11437 : :
11438 : : static void
11439 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
11440 : : __rte_unused struct cmdline *cl,
11441 : : __rte_unused void *data)
11442 : : {
11443 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
11444 : : struct rte_eth_dev_info dev_info;
11445 : 0 : portid_t port_id = res->port_id;
11446 : 0 : uint16_t queue_id = res->queue_id;
11447 : 0 : struct rte_port *port = &ports[port_id];
11448 : : uint64_t offload;
11449 : : int ret;
11450 : :
11451 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11452 : 0 : fprintf(stderr,
11453 : : "Error: Can't config offload when Port %d is not stopped\n",
11454 : : port_id);
11455 : 0 : return;
11456 : : }
11457 : :
11458 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11459 : 0 : if (ret != 0)
11460 : : return;
11461 : :
11462 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
11463 : 0 : fprintf(stderr,
11464 : : "Error: input queue_id should be 0 ... %d\n",
11465 : 0 : dev_info.nb_rx_queues - 1);
11466 : 0 : return;
11467 : : }
11468 : :
11469 : 0 : if (!strcmp(res->offload, "all")) {
11470 : 0 : offload = dev_info.rx_queue_offload_capa;
11471 : : } else {
11472 : 0 : offload = search_rx_offload(res->offload);
11473 : 0 : if (offload == 0) {
11474 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
11475 : 0 : return;
11476 : : }
11477 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
11478 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
11479 : : port_id, res->offload);
11480 : 0 : return;
11481 : : }
11482 : : }
11483 : :
11484 : 0 : if (!strcmp(res->on_off, "on"))
11485 : 0 : port->rxq[queue_id].conf.offloads |= offload;
11486 : : else
11487 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
11488 : :
11489 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11490 : : }
11491 : :
11492 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
11493 : : .f = cmd_config_per_queue_rx_offload_parsed,
11494 : : .data = NULL,
11495 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
11496 : : "all|vlan_strip|ipv4_cksum|"
11497 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11498 : : "macsec_strip|vlan_filter|vlan_extend|"
11499 : : "scatter|buffer_split|timestamp|security|"
11500 : : "keep_crc on|off",
11501 : : .tokens = {
11502 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
11503 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
11504 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
11505 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
11506 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
11507 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
11508 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
11509 : : NULL,
11510 : : }
11511 : : };
11512 : :
11513 : : /* Get Tx offloads capabilities */
11514 : : struct cmd_tx_offload_get_capa_result {
11515 : : cmdline_fixed_string_t show;
11516 : : cmdline_fixed_string_t port;
11517 : : portid_t port_id;
11518 : : cmdline_fixed_string_t tx_offload;
11519 : : cmdline_fixed_string_t capabilities;
11520 : : };
11521 : :
11522 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
11523 : : TOKEN_STRING_INITIALIZER
11524 : : (struct cmd_tx_offload_get_capa_result,
11525 : : show, "show");
11526 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
11527 : : TOKEN_STRING_INITIALIZER
11528 : : (struct cmd_tx_offload_get_capa_result,
11529 : : port, "port");
11530 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
11531 : : TOKEN_NUM_INITIALIZER
11532 : : (struct cmd_tx_offload_get_capa_result,
11533 : : port_id, RTE_UINT16);
11534 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
11535 : : TOKEN_STRING_INITIALIZER
11536 : : (struct cmd_tx_offload_get_capa_result,
11537 : : tx_offload, "tx_offload");
11538 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
11539 : : TOKEN_STRING_INITIALIZER
11540 : : (struct cmd_tx_offload_get_capa_result,
11541 : : capabilities, "capabilities");
11542 : :
11543 : : static void
11544 : 0 : print_tx_offloads(uint64_t offloads)
11545 : : {
11546 : : uint64_t single_offload;
11547 : : int begin;
11548 : : int end;
11549 : : int bit;
11550 : :
11551 : 0 : if (offloads == 0)
11552 : : return;
11553 : :
11554 : : begin = rte_ctz64(offloads);
11555 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11556 : :
11557 : 0 : single_offload = 1ULL << begin;
11558 : 0 : for (bit = begin; bit < end; bit++) {
11559 : 0 : if (offloads & single_offload)
11560 : 0 : printf(" %s",
11561 : : rte_eth_dev_tx_offload_name(single_offload));
11562 : 0 : single_offload <<= 1;
11563 : : }
11564 : : }
11565 : :
11566 : : static void
11567 : 0 : cmd_tx_offload_get_capa_parsed(
11568 : : void *parsed_result,
11569 : : __rte_unused struct cmdline *cl,
11570 : : __rte_unused void *data)
11571 : : {
11572 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
11573 : : struct rte_eth_dev_info dev_info;
11574 : 0 : portid_t port_id = res->port_id;
11575 : : uint64_t queue_offloads;
11576 : : uint64_t port_offloads;
11577 : : int ret;
11578 : :
11579 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11580 : 0 : if (ret != 0)
11581 : 0 : return;
11582 : :
11583 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
11584 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
11585 : :
11586 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
11587 : : printf(" Per Queue :");
11588 : 0 : print_tx_offloads(queue_offloads);
11589 : :
11590 : : printf("\n");
11591 : : printf(" Per Port :");
11592 : 0 : print_tx_offloads(port_offloads);
11593 : : printf("\n\n");
11594 : : }
11595 : :
11596 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
11597 : : .f = cmd_tx_offload_get_capa_parsed,
11598 : : .data = NULL,
11599 : : .help_str = "show port <port_id> tx_offload capabilities",
11600 : : .tokens = {
11601 : : (void *)&cmd_tx_offload_get_capa_show,
11602 : : (void *)&cmd_tx_offload_get_capa_port,
11603 : : (void *)&cmd_tx_offload_get_capa_port_id,
11604 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
11605 : : (void *)&cmd_tx_offload_get_capa_capabilities,
11606 : : NULL,
11607 : : }
11608 : : };
11609 : :
11610 : : /* Get Tx offloads configuration */
11611 : : struct cmd_tx_offload_get_configuration_result {
11612 : : cmdline_fixed_string_t show;
11613 : : cmdline_fixed_string_t port;
11614 : : portid_t port_id;
11615 : : cmdline_fixed_string_t tx_offload;
11616 : : cmdline_fixed_string_t configuration;
11617 : : };
11618 : :
11619 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
11620 : : TOKEN_STRING_INITIALIZER
11621 : : (struct cmd_tx_offload_get_configuration_result,
11622 : : show, "show");
11623 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
11624 : : TOKEN_STRING_INITIALIZER
11625 : : (struct cmd_tx_offload_get_configuration_result,
11626 : : port, "port");
11627 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
11628 : : TOKEN_NUM_INITIALIZER
11629 : : (struct cmd_tx_offload_get_configuration_result,
11630 : : port_id, RTE_UINT16);
11631 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
11632 : : TOKEN_STRING_INITIALIZER
11633 : : (struct cmd_tx_offload_get_configuration_result,
11634 : : tx_offload, "tx_offload");
11635 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
11636 : : TOKEN_STRING_INITIALIZER
11637 : : (struct cmd_tx_offload_get_configuration_result,
11638 : : configuration, "configuration");
11639 : :
11640 : : static void
11641 : 0 : cmd_tx_offload_get_configuration_parsed(
11642 : : void *parsed_result,
11643 : : __rte_unused struct cmdline *cl,
11644 : : __rte_unused void *data)
11645 : : {
11646 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
11647 : : struct rte_eth_dev_info dev_info;
11648 : 0 : portid_t port_id = res->port_id;
11649 : 0 : struct rte_port *port = &ports[port_id];
11650 : : struct rte_eth_conf dev_conf;
11651 : : uint64_t port_offloads;
11652 : : uint64_t queue_offloads;
11653 : : uint16_t nb_tx_queues;
11654 : : int q;
11655 : : int ret;
11656 : :
11657 : 0 : printf("Tx Offloading Configuration of port %d :\n", port_id);
11658 : :
11659 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11660 : 0 : if (ret != 0)
11661 : 0 : return;
11662 : :
11663 : 0 : port_offloads = dev_conf.txmode.offloads;
11664 : : printf(" Port :");
11665 : 0 : print_tx_offloads(port_offloads);
11666 : : printf("\n");
11667 : :
11668 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11669 : 0 : if (ret != 0)
11670 : : return;
11671 : :
11672 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
11673 : 0 : for (q = 0; q < nb_tx_queues; q++) {
11674 : 0 : queue_offloads = port->txq[q].conf.offloads;
11675 : : printf(" Queue[%2d] :", q);
11676 : 0 : print_tx_offloads(queue_offloads);
11677 : : printf("\n");
11678 : : }
11679 : : printf("\n");
11680 : : }
11681 : :
11682 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
11683 : : .f = cmd_tx_offload_get_configuration_parsed,
11684 : : .data = NULL,
11685 : : .help_str = "show port <port_id> tx_offload configuration",
11686 : : .tokens = {
11687 : : (void *)&cmd_tx_offload_get_configuration_show,
11688 : : (void *)&cmd_tx_offload_get_configuration_port,
11689 : : (void *)&cmd_tx_offload_get_configuration_port_id,
11690 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
11691 : : (void *)&cmd_tx_offload_get_configuration_configuration,
11692 : : NULL,
11693 : : }
11694 : : };
11695 : :
11696 : : /* Enable/Disable a per port offloading */
11697 : : struct cmd_config_per_port_tx_offload_result {
11698 : : cmdline_fixed_string_t port;
11699 : : cmdline_fixed_string_t config;
11700 : : portid_t port_id;
11701 : : cmdline_fixed_string_t tx_offload;
11702 : : cmdline_fixed_string_t offload;
11703 : : cmdline_fixed_string_t on_off;
11704 : : };
11705 : :
11706 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
11707 : : TOKEN_STRING_INITIALIZER
11708 : : (struct cmd_config_per_port_tx_offload_result,
11709 : : port, "port");
11710 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
11711 : : TOKEN_STRING_INITIALIZER
11712 : : (struct cmd_config_per_port_tx_offload_result,
11713 : : config, "config");
11714 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
11715 : : TOKEN_NUM_INITIALIZER
11716 : : (struct cmd_config_per_port_tx_offload_result,
11717 : : port_id, RTE_UINT16);
11718 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
11719 : : TOKEN_STRING_INITIALIZER
11720 : : (struct cmd_config_per_port_tx_offload_result,
11721 : : tx_offload, "tx_offload");
11722 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
11723 : : TOKEN_STRING_INITIALIZER
11724 : : (struct cmd_config_per_port_tx_offload_result,
11725 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11726 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11727 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11728 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11729 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
11730 : : "send_on_timestamp");
11731 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
11732 : : TOKEN_STRING_INITIALIZER
11733 : : (struct cmd_config_per_port_tx_offload_result,
11734 : : on_off, "on#off");
11735 : :
11736 : : static uint64_t
11737 : 0 : search_tx_offload(const char *name)
11738 : : {
11739 : : uint64_t single_offload;
11740 : : const char *single_name;
11741 : : int found = 0;
11742 : : unsigned int bit;
11743 : :
11744 : : single_offload = 1;
11745 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11746 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
11747 : 0 : if (single_name == NULL)
11748 : : break;
11749 : 0 : if (!strcasecmp(single_name, name)) {
11750 : : found = 1;
11751 : : break;
11752 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
11753 : : break;
11754 : 0 : single_offload <<= 1;
11755 : : }
11756 : :
11757 : 0 : if (found)
11758 : 0 : return single_offload;
11759 : :
11760 : : return 0;
11761 : : }
11762 : :
11763 : : static void
11764 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
11765 : : {
11766 : : struct rte_eth_dev_info dev_info;
11767 : 0 : struct rte_port *port = &ports[port_id];
11768 : : uint16_t nb_tx_queues;
11769 : : uint64_t offload;
11770 : : int q;
11771 : : int ret;
11772 : :
11773 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11774 : 0 : fprintf(stderr,
11775 : : "Error: Can't config offload when Port %d is not stopped\n",
11776 : : port_id);
11777 : 0 : return;
11778 : : }
11779 : :
11780 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11781 : 0 : if (ret != 0)
11782 : : return;
11783 : :
11784 : 0 : if (!strcmp(name, "all")) {
11785 : 0 : offload = dev_info.tx_offload_capa;
11786 : : } else {
11787 : 0 : offload = search_tx_offload(name);
11788 : 0 : if (offload == 0) {
11789 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
11790 : 0 : return;
11791 : : }
11792 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
11793 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11794 : : port_id, name);
11795 : 0 : return;
11796 : : }
11797 : : }
11798 : :
11799 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
11800 : 0 : if (on) {
11801 : 0 : port->dev_conf.txmode.offloads |= offload;
11802 : 0 : for (q = 0; q < nb_tx_queues; q++)
11803 : 0 : port->txq[q].conf.offloads |= offload;
11804 : : } else {
11805 : 0 : port->dev_conf.txmode.offloads &= ~offload;
11806 : 0 : for (q = 0; q < nb_tx_queues; q++)
11807 : 0 : port->txq[q].conf.offloads &= ~offload;
11808 : : }
11809 : :
11810 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11811 : : }
11812 : :
11813 : : static void
11814 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
11815 : : __rte_unused struct cmdline *cl,
11816 : : __rte_unused void *data)
11817 : : {
11818 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
11819 : : bool on;
11820 : :
11821 : 0 : on = strcmp(res->on_off, "on") == 0;
11822 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
11823 : 0 : }
11824 : :
11825 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
11826 : : .f = cmd_config_per_port_tx_offload_parsed,
11827 : : .data = NULL,
11828 : : .help_str = "port config <port_id> tx_offload "
11829 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
11830 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
11831 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
11832 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
11833 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
11834 : : "send_on_timestamp on|off",
11835 : : .tokens = {
11836 : : (void *)&cmd_config_per_port_tx_offload_result_port,
11837 : : (void *)&cmd_config_per_port_tx_offload_result_config,
11838 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
11839 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
11840 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
11841 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
11842 : : NULL,
11843 : : }
11844 : : };
11845 : :
11846 : : /* Enable/Disable all port Tx offloading */
11847 : : struct cmd_config_all_port_tx_offload_result {
11848 : : cmdline_fixed_string_t port;
11849 : : cmdline_fixed_string_t config;
11850 : : cmdline_fixed_string_t port_all;
11851 : : cmdline_fixed_string_t tx_offload;
11852 : : cmdline_fixed_string_t offload;
11853 : : cmdline_fixed_string_t on_off;
11854 : : };
11855 : :
11856 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
11857 : : TOKEN_STRING_INITIALIZER
11858 : : (struct cmd_config_all_port_tx_offload_result,
11859 : : port, "port");
11860 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
11861 : : TOKEN_STRING_INITIALIZER
11862 : : (struct cmd_config_all_port_tx_offload_result,
11863 : : config, "config");
11864 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
11865 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
11866 : : port_all, "all");
11867 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
11868 : : TOKEN_STRING_INITIALIZER
11869 : : (struct cmd_config_all_port_tx_offload_result,
11870 : : tx_offload, "tx_offload");
11871 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
11872 : : TOKEN_STRING_INITIALIZER
11873 : : (struct cmd_config_all_port_tx_offload_result,
11874 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11875 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11876 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11877 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11878 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
11879 : : "send_on_timestamp");
11880 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
11881 : : TOKEN_STRING_INITIALIZER
11882 : : (struct cmd_config_all_port_tx_offload_result,
11883 : : on_off, "on#off");
11884 : :
11885 : : static void
11886 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
11887 : : __rte_unused struct cmdline *cl,
11888 : : __rte_unused void *data)
11889 : : {
11890 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
11891 : : portid_t i;
11892 : : bool on_off;
11893 : :
11894 : 0 : on_off = strcmp(res->on_off, "on") == 0;
11895 : 0 : RTE_ETH_FOREACH_DEV(i)
11896 : 0 : config_port_tx_offload(i, res->offload, on_off);
11897 : 0 : }
11898 : :
11899 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
11900 : : .f = cmd_config_all_port_tx_offload_parsed,
11901 : : .data = NULL,
11902 : : .help_str = "port config all tx_offload "
11903 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
11904 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
11905 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
11906 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
11907 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
11908 : : "send_on_timestamp on|off",
11909 : : .tokens = {
11910 : : (void *)&cmd_config_all_port_tx_offload_result_port,
11911 : : (void *)&cmd_config_all_port_tx_offload_result_config,
11912 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
11913 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
11914 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
11915 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
11916 : : NULL,
11917 : : }
11918 : : };
11919 : :
11920 : : /* Enable/Disable a per queue offloading */
11921 : : struct cmd_config_per_queue_tx_offload_result {
11922 : : cmdline_fixed_string_t port;
11923 : : portid_t port_id;
11924 : : cmdline_fixed_string_t txq;
11925 : : uint16_t queue_id;
11926 : : cmdline_fixed_string_t tx_offload;
11927 : : cmdline_fixed_string_t offload;
11928 : : cmdline_fixed_string_t on_off;
11929 : : };
11930 : :
11931 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
11932 : : TOKEN_STRING_INITIALIZER
11933 : : (struct cmd_config_per_queue_tx_offload_result,
11934 : : port, "port");
11935 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
11936 : : TOKEN_NUM_INITIALIZER
11937 : : (struct cmd_config_per_queue_tx_offload_result,
11938 : : port_id, RTE_UINT16);
11939 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
11940 : : TOKEN_STRING_INITIALIZER
11941 : : (struct cmd_config_per_queue_tx_offload_result,
11942 : : txq, "txq");
11943 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
11944 : : TOKEN_NUM_INITIALIZER
11945 : : (struct cmd_config_per_queue_tx_offload_result,
11946 : : queue_id, RTE_UINT16);
11947 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
11948 : : TOKEN_STRING_INITIALIZER
11949 : : (struct cmd_config_per_queue_tx_offload_result,
11950 : : tx_offload, "tx_offload");
11951 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
11952 : : TOKEN_STRING_INITIALIZER
11953 : : (struct cmd_config_per_queue_tx_offload_result,
11954 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11955 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11956 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11957 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11958 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
11959 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
11960 : : TOKEN_STRING_INITIALIZER
11961 : : (struct cmd_config_per_queue_tx_offload_result,
11962 : : on_off, "on#off");
11963 : :
11964 : : static void
11965 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
11966 : : __rte_unused struct cmdline *cl,
11967 : : __rte_unused void *data)
11968 : : {
11969 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
11970 : : struct rte_eth_dev_info dev_info;
11971 : 0 : portid_t port_id = res->port_id;
11972 : 0 : uint16_t queue_id = res->queue_id;
11973 : 0 : struct rte_port *port = &ports[port_id];
11974 : : uint64_t offload;
11975 : : int ret;
11976 : :
11977 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11978 : 0 : fprintf(stderr,
11979 : : "Error: Can't config offload when Port %d is not stopped\n",
11980 : : port_id);
11981 : 0 : return;
11982 : : }
11983 : :
11984 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11985 : 0 : if (ret != 0)
11986 : : return;
11987 : :
11988 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
11989 : 0 : fprintf(stderr,
11990 : : "Error: input queue_id should be 0 ... %d\n",
11991 : 0 : dev_info.nb_tx_queues - 1);
11992 : 0 : return;
11993 : : }
11994 : :
11995 : 0 : if (!strcmp(res->offload, "all")) {
11996 : 0 : offload = dev_info.tx_queue_offload_capa;
11997 : : } else {
11998 : 0 : offload = search_tx_offload(res->offload);
11999 : 0 : if (offload == 0) {
12000 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12001 : 0 : return;
12002 : : }
12003 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
12004 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12005 : : port_id, res->offload);
12006 : 0 : return;
12007 : : }
12008 : : }
12009 : :
12010 : 0 : if (!strcmp(res->on_off, "on"))
12011 : 0 : port->txq[queue_id].conf.offloads |= offload;
12012 : : else
12013 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
12014 : :
12015 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12016 : : }
12017 : :
12018 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
12019 : : .f = cmd_config_per_queue_tx_offload_parsed,
12020 : : .data = NULL,
12021 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
12022 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12023 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12024 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12025 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12026 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
12027 : : "on|off",
12028 : : .tokens = {
12029 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
12030 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
12031 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
12032 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
12033 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
12034 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
12035 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
12036 : : NULL,
12037 : : }
12038 : : };
12039 : :
12040 : : /* *** configure tx_metadata for specific port *** */
12041 : : struct cmd_config_tx_metadata_specific_result {
12042 : : cmdline_fixed_string_t port;
12043 : : cmdline_fixed_string_t keyword;
12044 : : uint16_t port_id;
12045 : : cmdline_fixed_string_t item;
12046 : : uint32_t value;
12047 : : };
12048 : :
12049 : : static void
12050 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
12051 : : __rte_unused struct cmdline *cl,
12052 : : __rte_unused void *data)
12053 : : {
12054 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
12055 : :
12056 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12057 : : return;
12058 : 0 : ports[res->port_id].tx_metadata = res->value;
12059 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
12060 : 0 : if (ports[res->port_id].tx_metadata)
12061 : 0 : add_tx_md_callback(res->port_id);
12062 : : else
12063 : 0 : remove_tx_md_callback(res->port_id);
12064 : 0 : rte_flow_dynf_metadata_register();
12065 : : }
12066 : :
12067 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
12068 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12069 : : port, "port");
12070 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
12071 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12072 : : keyword, "config");
12073 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
12074 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12075 : : port_id, RTE_UINT16);
12076 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
12077 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12078 : : item, "tx_metadata");
12079 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
12080 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12081 : : value, RTE_UINT32);
12082 : :
12083 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
12084 : : .f = cmd_config_tx_metadata_specific_parsed,
12085 : : .data = NULL,
12086 : : .help_str = "port config <port_id> tx_metadata <value>",
12087 : : .tokens = {
12088 : : (void *)&cmd_config_tx_metadata_specific_port,
12089 : : (void *)&cmd_config_tx_metadata_specific_keyword,
12090 : : (void *)&cmd_config_tx_metadata_specific_id,
12091 : : (void *)&cmd_config_tx_metadata_specific_item,
12092 : : (void *)&cmd_config_tx_metadata_specific_value,
12093 : : NULL,
12094 : : },
12095 : : };
12096 : :
12097 : : /* *** set dynf *** */
12098 : : struct cmd_config_tx_dynf_specific_result {
12099 : : cmdline_fixed_string_t port;
12100 : : cmdline_fixed_string_t keyword;
12101 : : uint16_t port_id;
12102 : : cmdline_fixed_string_t item;
12103 : : cmdline_fixed_string_t name;
12104 : : cmdline_fixed_string_t value;
12105 : : };
12106 : :
12107 : : static void
12108 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
12109 : : __rte_unused struct cmdline *cl,
12110 : : __rte_unused void *data)
12111 : : {
12112 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
12113 : : struct rte_mbuf_dynflag desc_flag;
12114 : : int flag;
12115 : : uint64_t old_port_flags;
12116 : :
12117 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12118 : 0 : return;
12119 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
12120 : 0 : if (flag <= 0) {
12121 : 0 : if (strlcpy(desc_flag.name, res->name,
12122 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
12123 : 0 : fprintf(stderr, "Flag name too long\n");
12124 : 0 : return;
12125 : : }
12126 : 0 : desc_flag.flags = 0;
12127 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
12128 : 0 : if (flag < 0) {
12129 : 0 : fprintf(stderr, "Can't register flag\n");
12130 : 0 : return;
12131 : : }
12132 : 0 : strcpy(dynf_names[flag], desc_flag.name);
12133 : : }
12134 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
12135 : 0 : if (!strcmp(res->value, "set")) {
12136 : 0 : ports[res->port_id].mbuf_dynf |= 1UL << flag;
12137 : 0 : if (old_port_flags == 0)
12138 : 0 : add_tx_dynf_callback(res->port_id);
12139 : : } else {
12140 : 0 : ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
12141 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
12142 : 0 : remove_tx_dynf_callback(res->port_id);
12143 : : }
12144 : : }
12145 : :
12146 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
12147 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12148 : : keyword, "port");
12149 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
12150 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12151 : : keyword, "config");
12152 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
12153 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12154 : : port_id, RTE_UINT16);
12155 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
12156 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12157 : : item, "dynf");
12158 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
12159 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12160 : : name, NULL);
12161 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
12162 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12163 : : value, "set#clear");
12164 : :
12165 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
12166 : : .f = cmd_config_dynf_specific_parsed,
12167 : : .data = NULL,
12168 : : .help_str = "port config <port id> dynf <name> set|clear",
12169 : : .tokens = {
12170 : : (void *)&cmd_config_tx_dynf_specific_port,
12171 : : (void *)&cmd_config_tx_dynf_specific_keyword,
12172 : : (void *)&cmd_config_tx_dynf_specific_port_id,
12173 : : (void *)&cmd_config_tx_dynf_specific_item,
12174 : : (void *)&cmd_config_tx_dynf_specific_name,
12175 : : (void *)&cmd_config_tx_dynf_specific_value,
12176 : : NULL,
12177 : : },
12178 : : };
12179 : :
12180 : : /* *** display tx_metadata per port configuration *** */
12181 : : struct cmd_show_tx_metadata_result {
12182 : : cmdline_fixed_string_t cmd_show;
12183 : : cmdline_fixed_string_t cmd_port;
12184 : : cmdline_fixed_string_t cmd_keyword;
12185 : : portid_t cmd_pid;
12186 : : };
12187 : :
12188 : : static void
12189 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
12190 : : __rte_unused struct cmdline *cl,
12191 : : __rte_unused void *data)
12192 : : {
12193 : : struct cmd_show_tx_metadata_result *res = parsed_result;
12194 : :
12195 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12196 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
12197 : 0 : return;
12198 : : }
12199 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
12200 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
12201 : 0 : ports[res->cmd_pid].tx_metadata);
12202 : : }
12203 : : }
12204 : :
12205 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
12206 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12207 : : cmd_show, "show");
12208 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
12209 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12210 : : cmd_port, "port");
12211 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
12212 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
12213 : : cmd_pid, RTE_UINT16);
12214 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
12215 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12216 : : cmd_keyword, "tx_metadata");
12217 : :
12218 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
12219 : : .f = cmd_show_tx_metadata_parsed,
12220 : : .data = NULL,
12221 : : .help_str = "show port <port_id> tx_metadata",
12222 : : .tokens = {
12223 : : (void *)&cmd_show_tx_metadata_show,
12224 : : (void *)&cmd_show_tx_metadata_port,
12225 : : (void *)&cmd_show_tx_metadata_pid,
12226 : : (void *)&cmd_show_tx_metadata_keyword,
12227 : : NULL,
12228 : : },
12229 : : };
12230 : :
12231 : : /* *** show fec capability per port configuration *** */
12232 : : struct cmd_show_fec_capability_result {
12233 : : cmdline_fixed_string_t cmd_show;
12234 : : cmdline_fixed_string_t cmd_port;
12235 : : cmdline_fixed_string_t cmd_fec;
12236 : : cmdline_fixed_string_t cmd_keyword;
12237 : : portid_t cmd_pid;
12238 : : };
12239 : :
12240 : : static void
12241 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
12242 : : __rte_unused struct cmdline *cl,
12243 : : __rte_unused void *data)
12244 : : {
12245 : : struct cmd_show_fec_capability_result *res = parsed_result;
12246 : : struct rte_eth_fec_capa *speed_fec_capa;
12247 : : unsigned int num;
12248 : : int ret;
12249 : :
12250 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12251 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12252 : 0 : return;
12253 : : }
12254 : :
12255 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
12256 : 0 : if (ret == -ENOTSUP) {
12257 : 0 : fprintf(stderr, "Function not implemented\n");
12258 : 0 : return;
12259 : 0 : } else if (ret < 0) {
12260 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
12261 : 0 : return;
12262 : : }
12263 : :
12264 : 0 : num = (unsigned int)ret;
12265 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
12266 : 0 : if (speed_fec_capa == NULL) {
12267 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
12268 : 0 : return;
12269 : : }
12270 : :
12271 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
12272 : 0 : if (ret < 0) {
12273 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
12274 : 0 : goto out;
12275 : : }
12276 : :
12277 : 0 : show_fec_capability(num, speed_fec_capa);
12278 : 0 : out:
12279 : 0 : free(speed_fec_capa);
12280 : : }
12281 : :
12282 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
12283 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12284 : : cmd_show, "show");
12285 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
12286 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12287 : : cmd_port, "port");
12288 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
12289 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
12290 : : cmd_pid, RTE_UINT16);
12291 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
12292 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12293 : : cmd_fec, "fec");
12294 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
12295 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12296 : : cmd_keyword, "capabilities");
12297 : :
12298 : : static cmdline_parse_inst_t cmd_show_capability = {
12299 : : .f = cmd_show_fec_capability_parsed,
12300 : : .data = NULL,
12301 : : .help_str = "show port <port_id> fec capabilities",
12302 : : .tokens = {
12303 : : (void *)&cmd_show_fec_capability_show,
12304 : : (void *)&cmd_show_fec_capability_port,
12305 : : (void *)&cmd_show_fec_capability_pid,
12306 : : (void *)&cmd_show_fec_capability_fec,
12307 : : (void *)&cmd_show_fec_capability_keyword,
12308 : : NULL,
12309 : : },
12310 : : };
12311 : :
12312 : : /* *** show fec mode per port configuration *** */
12313 : : struct cmd_show_fec_metadata_result {
12314 : : cmdline_fixed_string_t cmd_show;
12315 : : cmdline_fixed_string_t cmd_port;
12316 : : cmdline_fixed_string_t cmd_keyword;
12317 : : portid_t cmd_pid;
12318 : : };
12319 : :
12320 : : static void
12321 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
12322 : : __rte_unused struct cmdline *cl,
12323 : : __rte_unused void *data)
12324 : : {
12325 : : #define FEC_NAME_SIZE 16
12326 : : struct cmd_show_fec_metadata_result *res = parsed_result;
12327 : : uint32_t mode;
12328 : : char buf[FEC_NAME_SIZE];
12329 : : int ret;
12330 : :
12331 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12332 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12333 : 0 : return;
12334 : : }
12335 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
12336 : 0 : if (ret == -ENOTSUP) {
12337 : 0 : fprintf(stderr, "Function not implemented\n");
12338 : 0 : return;
12339 : 0 : } else if (ret < 0) {
12340 : 0 : fprintf(stderr, "Get FEC mode failed\n");
12341 : 0 : return;
12342 : : }
12343 : :
12344 : 0 : switch (mode) {
12345 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
12346 : : strlcpy(buf, "off", sizeof(buf));
12347 : : break;
12348 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
12349 : : strlcpy(buf, "auto", sizeof(buf));
12350 : : break;
12351 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
12352 : : strlcpy(buf, "baser", sizeof(buf));
12353 : : break;
12354 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
12355 : : strlcpy(buf, "rs", sizeof(buf));
12356 : : break;
12357 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
12358 : : strlcpy(buf, "llrs", sizeof(buf));
12359 : : break;
12360 : : default:
12361 : : return;
12362 : : }
12363 : :
12364 : : printf("%s\n", buf);
12365 : : }
12366 : :
12367 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
12368 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12369 : : cmd_show, "show");
12370 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
12371 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12372 : : cmd_port, "port");
12373 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
12374 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
12375 : : cmd_pid, RTE_UINT16);
12376 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
12377 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12378 : : cmd_keyword, "fec_mode");
12379 : :
12380 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
12381 : : .f = cmd_show_fec_mode_parsed,
12382 : : .data = NULL,
12383 : : .help_str = "show port <port_id> fec_mode",
12384 : : .tokens = {
12385 : : (void *)&cmd_show_fec_mode_show,
12386 : : (void *)&cmd_show_fec_mode_port,
12387 : : (void *)&cmd_show_fec_mode_pid,
12388 : : (void *)&cmd_show_fec_mode_keyword,
12389 : : NULL,
12390 : : },
12391 : : };
12392 : :
12393 : : /* *** set fec mode per port configuration *** */
12394 : : struct cmd_set_port_fec_mode {
12395 : : cmdline_fixed_string_t set;
12396 : : cmdline_fixed_string_t port;
12397 : : portid_t port_id;
12398 : : cmdline_fixed_string_t fec_mode;
12399 : : cmdline_fixed_string_t fec_value;
12400 : : };
12401 : :
12402 : : /* Common CLI fields for set fec mode */
12403 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
12404 : : TOKEN_STRING_INITIALIZER
12405 : : (struct cmd_set_port_fec_mode,
12406 : : set, "set");
12407 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
12408 : : TOKEN_STRING_INITIALIZER
12409 : : (struct cmd_set_port_fec_mode,
12410 : : port, "port");
12411 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
12412 : : TOKEN_NUM_INITIALIZER
12413 : : (struct cmd_set_port_fec_mode,
12414 : : port_id, RTE_UINT16);
12415 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
12416 : : TOKEN_STRING_INITIALIZER
12417 : : (struct cmd_set_port_fec_mode,
12418 : : fec_mode, "fec_mode");
12419 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
12420 : : TOKEN_STRING_INITIALIZER
12421 : : (struct cmd_set_port_fec_mode,
12422 : : fec_value, NULL);
12423 : :
12424 : : static void
12425 : 0 : cmd_set_port_fec_mode_parsed(
12426 : : void *parsed_result,
12427 : : __rte_unused struct cmdline *cl,
12428 : : __rte_unused void *data)
12429 : : {
12430 : : struct cmd_set_port_fec_mode *res = parsed_result;
12431 : 0 : uint16_t port_id = res->port_id;
12432 : : uint32_t fec_capa;
12433 : : int ret;
12434 : :
12435 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
12436 : 0 : if (ret < 0) {
12437 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
12438 : : res->fec_value, port_id);
12439 : 0 : return;
12440 : : }
12441 : :
12442 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
12443 : 0 : if (ret == -ENOTSUP) {
12444 : 0 : fprintf(stderr, "Function not implemented\n");
12445 : 0 : return;
12446 : 0 : } else if (ret < 0) {
12447 : 0 : fprintf(stderr, "Set FEC mode failed\n");
12448 : 0 : return;
12449 : : }
12450 : : }
12451 : :
12452 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
12453 : : .f = cmd_set_port_fec_mode_parsed,
12454 : : .data = NULL,
12455 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
12456 : : .tokens = {
12457 : : (void *)&cmd_set_port_fec_mode_set,
12458 : : (void *)&cmd_set_port_fec_mode_port,
12459 : : (void *)&cmd_set_port_fec_mode_port_id,
12460 : : (void *)&cmd_set_port_fec_mode_str,
12461 : : (void *)&cmd_set_port_fec_mode_value,
12462 : : NULL,
12463 : : },
12464 : : };
12465 : :
12466 : : /* *** set available descriptors threshold for an RxQ of a port *** */
12467 : : struct cmd_set_rxq_avail_thresh_result {
12468 : : cmdline_fixed_string_t set;
12469 : : cmdline_fixed_string_t port;
12470 : : uint16_t port_num;
12471 : : cmdline_fixed_string_t rxq;
12472 : : uint16_t rxq_num;
12473 : : cmdline_fixed_string_t avail_thresh;
12474 : : uint8_t avail_thresh_num;
12475 : : };
12476 : :
12477 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
12478 : : __rte_unused struct cmdline *cl,
12479 : : __rte_unused void *data)
12480 : : {
12481 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
12482 : : int ret = 0;
12483 : :
12484 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
12485 : 0 : && (strcmp(res->rxq, "rxq") == 0)
12486 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
12487 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
12488 : 0 : res->avail_thresh_num);
12489 : 0 : if (ret < 0)
12490 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
12491 : :
12492 : 0 : }
12493 : :
12494 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
12495 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12496 : : set, "set");
12497 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
12498 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12499 : : port, "port");
12500 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
12501 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12502 : : port_num, RTE_UINT16);
12503 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
12504 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12505 : : rxq, "rxq");
12506 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
12507 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12508 : : rxq_num, RTE_UINT16);
12509 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
12510 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12511 : : avail_thresh, "avail_thresh");
12512 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
12513 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12514 : : avail_thresh_num, RTE_UINT8);
12515 : :
12516 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
12517 : : .f = cmd_set_rxq_avail_thresh_parsed,
12518 : : .data = (void *)0,
12519 : : .help_str =
12520 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
12521 : : "Set available descriptors threshold for Rx queue",
12522 : : .tokens = {
12523 : : (void *)&cmd_set_rxq_avail_thresh_set,
12524 : : (void *)&cmd_set_rxq_avail_thresh_port,
12525 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
12526 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
12527 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
12528 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
12529 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
12530 : : NULL,
12531 : : },
12532 : : };
12533 : :
12534 : : /* show port supported ptypes */
12535 : :
12536 : : /* Common result structure for show port ptypes */
12537 : : struct cmd_show_port_supported_ptypes_result {
12538 : : cmdline_fixed_string_t show;
12539 : : cmdline_fixed_string_t port;
12540 : : portid_t port_id;
12541 : : cmdline_fixed_string_t ptypes;
12542 : : };
12543 : :
12544 : : /* Common CLI fields for show port ptypes */
12545 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
12546 : : TOKEN_STRING_INITIALIZER
12547 : : (struct cmd_show_port_supported_ptypes_result,
12548 : : show, "show");
12549 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
12550 : : TOKEN_STRING_INITIALIZER
12551 : : (struct cmd_show_port_supported_ptypes_result,
12552 : : port, "port");
12553 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
12554 : : TOKEN_NUM_INITIALIZER
12555 : : (struct cmd_show_port_supported_ptypes_result,
12556 : : port_id, RTE_UINT16);
12557 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
12558 : : TOKEN_STRING_INITIALIZER
12559 : : (struct cmd_show_port_supported_ptypes_result,
12560 : : ptypes, "ptypes");
12561 : :
12562 : : static void
12563 : 0 : cmd_show_port_supported_ptypes_parsed(
12564 : : void *parsed_result,
12565 : : __rte_unused struct cmdline *cl,
12566 : : __rte_unused void *data)
12567 : : {
12568 : : #define RSVD_PTYPE_MASK 0xf0000000
12569 : : #define MAX_PTYPES_PER_LAYER 16
12570 : : #define LTYPE_NAMESIZE 32
12571 : : #define PTYPE_NAMESIZE 256
12572 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
12573 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
12574 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
12575 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
12576 : 0 : uint16_t port_id = res->port_id;
12577 : : int ret, i;
12578 : :
12579 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
12580 : 0 : if (ret < 0)
12581 : 0 : return;
12582 : :
12583 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
12584 : :
12585 : 0 : switch (ptype_mask) {
12586 : : case RTE_PTYPE_L2_MASK:
12587 : : strlcpy(ltype, "L2", sizeof(ltype));
12588 : : break;
12589 : : case RTE_PTYPE_L3_MASK:
12590 : : strlcpy(ltype, "L3", sizeof(ltype));
12591 : : break;
12592 : : case RTE_PTYPE_L4_MASK:
12593 : : strlcpy(ltype, "L4", sizeof(ltype));
12594 : : break;
12595 : : case RTE_PTYPE_TUNNEL_MASK:
12596 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
12597 : : break;
12598 : : case RTE_PTYPE_INNER_L2_MASK:
12599 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
12600 : : break;
12601 : : case RTE_PTYPE_INNER_L3_MASK:
12602 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
12603 : : break;
12604 : : case RTE_PTYPE_INNER_L4_MASK:
12605 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
12606 : : break;
12607 : : default:
12608 : : return;
12609 : : }
12610 : :
12611 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
12612 : : ptype_mask, ptypes,
12613 : : MAX_PTYPES_PER_LAYER);
12614 : :
12615 : 0 : if (ret > 0)
12616 : : printf("Supported %s ptypes:\n", ltype);
12617 : : else
12618 : : printf("%s ptypes unsupported\n", ltype);
12619 : :
12620 : 0 : for (i = 0; i < ret; ++i) {
12621 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
12622 : : printf("%s\n", buf);
12623 : : }
12624 : :
12625 : 0 : ptype_mask <<= 4;
12626 : : }
12627 : : }
12628 : :
12629 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
12630 : : .f = cmd_show_port_supported_ptypes_parsed,
12631 : : .data = NULL,
12632 : : .help_str = "show port <port_id> ptypes",
12633 : : .tokens = {
12634 : : (void *)&cmd_show_port_supported_ptypes_show,
12635 : : (void *)&cmd_show_port_supported_ptypes_port,
12636 : : (void *)&cmd_show_port_supported_ptypes_port_id,
12637 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
12638 : : NULL,
12639 : : },
12640 : : };
12641 : :
12642 : : /* *** display rx/tx descriptor status *** */
12643 : : struct cmd_show_rx_tx_desc_status_result {
12644 : : cmdline_fixed_string_t cmd_show;
12645 : : cmdline_fixed_string_t cmd_port;
12646 : : cmdline_fixed_string_t cmd_keyword;
12647 : : cmdline_fixed_string_t cmd_desc;
12648 : : cmdline_fixed_string_t cmd_status;
12649 : : portid_t cmd_pid;
12650 : : portid_t cmd_qid;
12651 : : portid_t cmd_did;
12652 : : };
12653 : :
12654 : : static void
12655 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
12656 : : __rte_unused struct cmdline *cl,
12657 : : __rte_unused void *data)
12658 : : {
12659 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
12660 : : int rc;
12661 : :
12662 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
12663 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12664 : 0 : fprintf(stderr,
12665 : : "Invalid input: port id = %d, queue id = %d\n",
12666 : 0 : res->cmd_pid, res->cmd_qid);
12667 : 0 : return;
12668 : : }
12669 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
12670 : 0 : res->cmd_did);
12671 : 0 : if (rc < 0) {
12672 : 0 : fprintf(stderr,
12673 : : "Invalid input: queue id = %d, desc id = %d\n",
12674 : 0 : res->cmd_qid, res->cmd_did);
12675 : 0 : return;
12676 : : }
12677 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
12678 : : printf("Desc status = AVAILABLE\n");
12679 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
12680 : : printf("Desc status = DONE\n");
12681 : : else
12682 : : printf("Desc status = UNAVAILABLE\n");
12683 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
12684 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12685 : 0 : fprintf(stderr,
12686 : : "Invalid input: port id = %d, queue id = %d\n",
12687 : 0 : res->cmd_pid, res->cmd_qid);
12688 : 0 : return;
12689 : : }
12690 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
12691 : 0 : res->cmd_did);
12692 : 0 : if (rc < 0) {
12693 : 0 : fprintf(stderr,
12694 : : "Invalid input: queue id = %d, desc id = %d\n",
12695 : 0 : res->cmd_qid, res->cmd_did);
12696 : 0 : return;
12697 : : }
12698 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
12699 : : printf("Desc status = FULL\n");
12700 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
12701 : : printf("Desc status = DONE\n");
12702 : : else
12703 : : printf("Desc status = UNAVAILABLE\n");
12704 : : }
12705 : : }
12706 : :
12707 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
12708 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12709 : : cmd_show, "show");
12710 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
12711 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12712 : : cmd_port, "port");
12713 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
12714 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12715 : : cmd_pid, RTE_UINT16);
12716 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
12717 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12718 : : cmd_keyword, "rxq#txq");
12719 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
12720 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12721 : : cmd_qid, RTE_UINT16);
12722 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
12723 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12724 : : cmd_desc, "desc");
12725 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
12726 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12727 : : cmd_did, RTE_UINT16);
12728 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
12729 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12730 : : cmd_status, "status");
12731 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
12732 : : .f = cmd_show_rx_tx_desc_status_parsed,
12733 : : .data = NULL,
12734 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
12735 : : "status",
12736 : : .tokens = {
12737 : : (void *)&cmd_show_rx_tx_desc_status_show,
12738 : : (void *)&cmd_show_rx_tx_desc_status_port,
12739 : : (void *)&cmd_show_rx_tx_desc_status_pid,
12740 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
12741 : : (void *)&cmd_show_rx_tx_desc_status_qid,
12742 : : (void *)&cmd_show_rx_tx_desc_status_desc,
12743 : : (void *)&cmd_show_rx_tx_desc_status_did,
12744 : : (void *)&cmd_show_rx_tx_desc_status_status,
12745 : : NULL,
12746 : : },
12747 : : };
12748 : :
12749 : : /* *** display rx/tx queue descriptor used count *** */
12750 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
12751 : : cmdline_fixed_string_t cmd_show;
12752 : : cmdline_fixed_string_t cmd_port;
12753 : : cmdline_fixed_string_t cmd_dir;
12754 : : cmdline_fixed_string_t cmd_desc;
12755 : : cmdline_fixed_string_t cmd_used;
12756 : : cmdline_fixed_string_t cmd_count;
12757 : : portid_t cmd_pid;
12758 : : portid_t cmd_qid;
12759 : : };
12760 : :
12761 : : static void
12762 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
12763 : : __rte_unused void *data)
12764 : : {
12765 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
12766 : : int rc;
12767 : :
12768 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
12769 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12770 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
12771 : 0 : res->cmd_pid, res->cmd_qid);
12772 : 0 : return;
12773 : : }
12774 : :
12775 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
12776 : 0 : if (rc < 0) {
12777 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
12778 : 0 : res->cmd_qid);
12779 : 0 : return;
12780 : : }
12781 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
12782 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
12783 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12784 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
12785 : 0 : res->cmd_pid, res->cmd_qid);
12786 : 0 : return;
12787 : : }
12788 : :
12789 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
12790 : 0 : if (rc < 0) {
12791 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
12792 : 0 : res->cmd_qid);
12793 : 0 : return;
12794 : : }
12795 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
12796 : : }
12797 : : }
12798 : :
12799 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
12800 : : TOKEN_STRING_INITIALIZER
12801 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12802 : : cmd_show, "show");
12803 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
12804 : : TOKEN_STRING_INITIALIZER
12805 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12806 : : cmd_port, "port");
12807 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
12808 : : TOKEN_NUM_INITIALIZER
12809 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12810 : : cmd_pid, RTE_UINT16);
12811 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
12812 : : TOKEN_STRING_INITIALIZER
12813 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12814 : : cmd_dir, "rxq#txq");
12815 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
12816 : : TOKEN_NUM_INITIALIZER
12817 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12818 : : cmd_qid, RTE_UINT16);
12819 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
12820 : : TOKEN_STRING_INITIALIZER
12821 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12822 : : cmd_desc, "desc");
12823 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
12824 : : TOKEN_STRING_INITIALIZER
12825 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12826 : : cmd_count, "used");
12827 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
12828 : : TOKEN_STRING_INITIALIZER
12829 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12830 : : cmd_count, "count");
12831 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
12832 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
12833 : : .data = NULL,
12834 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
12835 : : .tokens = {
12836 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
12837 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
12838 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
12839 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
12840 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
12841 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
12842 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
12843 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
12844 : : NULL,
12845 : : },
12846 : : };
12847 : :
12848 : : /* Common result structure for set port ptypes */
12849 : : struct cmd_set_port_ptypes_result {
12850 : : cmdline_fixed_string_t set;
12851 : : cmdline_fixed_string_t port;
12852 : : portid_t port_id;
12853 : : cmdline_fixed_string_t ptype_mask;
12854 : : uint32_t mask;
12855 : : };
12856 : :
12857 : : /* Common CLI fields for set port ptypes */
12858 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
12859 : : TOKEN_STRING_INITIALIZER
12860 : : (struct cmd_set_port_ptypes_result,
12861 : : set, "set");
12862 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
12863 : : TOKEN_STRING_INITIALIZER
12864 : : (struct cmd_set_port_ptypes_result,
12865 : : port, "port");
12866 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
12867 : : TOKEN_NUM_INITIALIZER
12868 : : (struct cmd_set_port_ptypes_result,
12869 : : port_id, RTE_UINT16);
12870 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
12871 : : TOKEN_STRING_INITIALIZER
12872 : : (struct cmd_set_port_ptypes_result,
12873 : : ptype_mask, "ptype_mask");
12874 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
12875 : : TOKEN_NUM_INITIALIZER
12876 : : (struct cmd_set_port_ptypes_result,
12877 : : mask, RTE_UINT32);
12878 : :
12879 : : static void
12880 : 0 : cmd_set_port_ptypes_parsed(
12881 : : void *parsed_result,
12882 : : __rte_unused struct cmdline *cl,
12883 : : __rte_unused void *data)
12884 : 0 : {
12885 : : struct cmd_set_port_ptypes_result *res = parsed_result;
12886 : : #define PTYPE_NAMESIZE 256
12887 : : char ptype_name[PTYPE_NAMESIZE];
12888 : 0 : uint16_t port_id = res->port_id;
12889 : 0 : uint32_t ptype_mask = res->mask;
12890 : : int ret, i;
12891 : :
12892 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
12893 : : NULL, 0);
12894 : 0 : if (ret <= 0) {
12895 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
12896 : : port_id);
12897 : 0 : return;
12898 : : }
12899 : :
12900 : 0 : uint32_t ptypes[ret];
12901 : :
12902 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
12903 : 0 : if (ret < 0) {
12904 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
12905 : : port_id);
12906 : 0 : return;
12907 : : }
12908 : :
12909 : : printf("Successfully set following ptypes for Port %d\n", port_id);
12910 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
12911 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
12912 : : printf("%s\n", ptype_name);
12913 : : }
12914 : :
12915 : 0 : clear_ptypes = false;
12916 : : }
12917 : :
12918 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
12919 : : .f = cmd_set_port_ptypes_parsed,
12920 : : .data = NULL,
12921 : : .help_str = "set port <port_id> ptype_mask <mask>",
12922 : : .tokens = {
12923 : : (void *)&cmd_set_port_ptypes_set,
12924 : : (void *)&cmd_set_port_ptypes_port,
12925 : : (void *)&cmd_set_port_ptypes_port_id,
12926 : : (void *)&cmd_set_port_ptypes_mask_str,
12927 : : (void *)&cmd_set_port_ptypes_mask_u32,
12928 : : NULL,
12929 : : },
12930 : : };
12931 : :
12932 : : /* *** display mac addresses added to a port *** */
12933 : : struct cmd_showport_macs_result {
12934 : : cmdline_fixed_string_t cmd_show;
12935 : : cmdline_fixed_string_t cmd_port;
12936 : : cmdline_fixed_string_t cmd_keyword;
12937 : : portid_t cmd_pid;
12938 : : };
12939 : :
12940 : : static void
12941 : 0 : cmd_showport_macs_parsed(void *parsed_result,
12942 : : __rte_unused struct cmdline *cl,
12943 : : __rte_unused void *data)
12944 : : {
12945 : : struct cmd_showport_macs_result *res = parsed_result;
12946 : :
12947 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
12948 : : return;
12949 : :
12950 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
12951 : 0 : show_macs(res->cmd_pid);
12952 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
12953 : 0 : show_mcast_macs(res->cmd_pid);
12954 : : }
12955 : :
12956 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
12957 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12958 : : cmd_show, "show");
12959 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
12960 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12961 : : cmd_port, "port");
12962 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
12963 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
12964 : : cmd_pid, RTE_UINT16);
12965 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
12966 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12967 : : cmd_keyword, "macs#mcast_macs");
12968 : :
12969 : : static cmdline_parse_inst_t cmd_showport_macs = {
12970 : : .f = cmd_showport_macs_parsed,
12971 : : .data = NULL,
12972 : : .help_str = "show port <port_id> macs|mcast_macs",
12973 : : .tokens = {
12974 : : (void *)&cmd_showport_macs_show,
12975 : : (void *)&cmd_showport_macs_port,
12976 : : (void *)&cmd_showport_macs_pid,
12977 : : (void *)&cmd_showport_macs_keyword,
12978 : : NULL,
12979 : : },
12980 : : };
12981 : :
12982 : : /* *** show flow transfer proxy port ID for the given port *** */
12983 : : struct cmd_show_port_flow_transfer_proxy_result {
12984 : : cmdline_fixed_string_t show;
12985 : : cmdline_fixed_string_t port;
12986 : : portid_t port_id;
12987 : : cmdline_fixed_string_t flow;
12988 : : cmdline_fixed_string_t transfer;
12989 : : cmdline_fixed_string_t proxy;
12990 : : };
12991 : :
12992 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
12993 : : TOKEN_STRING_INITIALIZER
12994 : : (struct cmd_show_port_flow_transfer_proxy_result,
12995 : : show, "show");
12996 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
12997 : : TOKEN_STRING_INITIALIZER
12998 : : (struct cmd_show_port_flow_transfer_proxy_result,
12999 : : port, "port");
13000 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
13001 : : TOKEN_NUM_INITIALIZER
13002 : : (struct cmd_show_port_flow_transfer_proxy_result,
13003 : : port_id, RTE_UINT16);
13004 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
13005 : : TOKEN_STRING_INITIALIZER
13006 : : (struct cmd_show_port_flow_transfer_proxy_result,
13007 : : flow, "flow");
13008 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
13009 : : TOKEN_STRING_INITIALIZER
13010 : : (struct cmd_show_port_flow_transfer_proxy_result,
13011 : : transfer, "transfer");
13012 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
13013 : : TOKEN_STRING_INITIALIZER
13014 : : (struct cmd_show_port_flow_transfer_proxy_result,
13015 : : proxy, "proxy");
13016 : :
13017 : : static void
13018 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
13019 : : __rte_unused struct cmdline *cl,
13020 : : __rte_unused void *data)
13021 : : {
13022 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
13023 : : portid_t proxy_port_id;
13024 : : int ret;
13025 : :
13026 : : printf("\n");
13027 : :
13028 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
13029 : 0 : if (ret != 0) {
13030 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
13031 : : rte_strerror(-ret));
13032 : 0 : return;
13033 : : }
13034 : :
13035 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
13036 : : }
13037 : :
13038 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
13039 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
13040 : : .data = NULL,
13041 : : .help_str = "show port <port_id> flow transfer proxy",
13042 : : .tokens = {
13043 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
13044 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
13045 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
13046 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
13047 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
13048 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
13049 : : NULL,
13050 : : }
13051 : : };
13052 : :
13053 : : /* *** configure port txq affinity value *** */
13054 : : struct cmd_config_tx_affinity_map {
13055 : : cmdline_fixed_string_t port;
13056 : : cmdline_fixed_string_t config;
13057 : : portid_t portid;
13058 : : cmdline_fixed_string_t txq;
13059 : : uint16_t qid;
13060 : : cmdline_fixed_string_t affinity;
13061 : : uint8_t value;
13062 : : };
13063 : :
13064 : : static void
13065 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
13066 : : __rte_unused struct cmdline *cl,
13067 : : __rte_unused void *data)
13068 : : {
13069 : : struct cmd_config_tx_affinity_map *res = parsed_result;
13070 : : int ret;
13071 : :
13072 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
13073 : : return;
13074 : :
13075 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
13076 : : printf("Invalid port id\n");
13077 : 0 : return;
13078 : : }
13079 : :
13080 : 0 : if (strcmp(res->txq, "txq")) {
13081 : : printf("Unknown parameter\n");
13082 : 0 : return;
13083 : : }
13084 : 0 : if (tx_queue_id_is_invalid(res->qid))
13085 : : return;
13086 : :
13087 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
13088 : 0 : if (ret < 0) {
13089 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
13090 : : strerror(-ret));
13091 : 0 : return;
13092 : : }
13093 : :
13094 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
13095 : 0 : if (ret != 0) {
13096 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
13097 : : rte_strerror(-ret));
13098 : 0 : return;
13099 : : }
13100 : : }
13101 : :
13102 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
13103 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13104 : : port, "port");
13105 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
13106 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13107 : : config, "config");
13108 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
13109 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13110 : : portid, RTE_UINT16);
13111 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
13112 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13113 : : txq, "txq");
13114 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
13115 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13116 : : qid, RTE_UINT16);
13117 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
13118 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13119 : : affinity, "affinity");
13120 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
13121 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13122 : : value, RTE_UINT8);
13123 : :
13124 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
13125 : : .f = cmd_config_tx_affinity_map_parsed,
13126 : : .data = (void *)0,
13127 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
13128 : : .tokens = {
13129 : : (void *)&cmd_config_tx_affinity_map_port,
13130 : : (void *)&cmd_config_tx_affinity_map_config,
13131 : : (void *)&cmd_config_tx_affinity_map_portid,
13132 : : (void *)&cmd_config_tx_affinity_map_txq,
13133 : : (void *)&cmd_config_tx_affinity_map_qid,
13134 : : (void *)&cmd_config_tx_affinity_map_affinity,
13135 : : (void *)&cmd_config_tx_affinity_map_value,
13136 : : NULL,
13137 : : },
13138 : : };
13139 : :
13140 : : /* ******************************************************************************** */
13141 : :
13142 : : /* list of instructions */
13143 : : static cmdline_parse_ctx_t builtin_ctx[] = {
13144 : : (cmdline_parse_inst_t *)&cmd_help_brief,
13145 : : (cmdline_parse_inst_t *)&cmd_help_long,
13146 : : (cmdline_parse_inst_t *)&cmd_quit,
13147 : : (cmdline_parse_inst_t *)&cmd_load_from_file,
13148 : : (cmdline_parse_inst_t *)&cmd_showport,
13149 : : (cmdline_parse_inst_t *)&cmd_showqueue,
13150 : : (cmdline_parse_inst_t *)&cmd_showeeprom,
13151 : : (cmdline_parse_inst_t *)&cmd_showportall,
13152 : : (cmdline_parse_inst_t *)&cmd_representor_info,
13153 : : (cmdline_parse_inst_t *)&cmd_showdevice,
13154 : : (cmdline_parse_inst_t *)&cmd_showcfg,
13155 : : (cmdline_parse_inst_t *)&cmd_showfwdall,
13156 : : (cmdline_parse_inst_t *)&cmd_start,
13157 : : (cmdline_parse_inst_t *)&cmd_start_tx_first,
13158 : : (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13159 : : (cmdline_parse_inst_t *)&cmd_set_link_up,
13160 : : (cmdline_parse_inst_t *)&cmd_set_link_down,
13161 : : (cmdline_parse_inst_t *)&cmd_reset,
13162 : : (cmdline_parse_inst_t *)&cmd_set_numbers,
13163 : : (cmdline_parse_inst_t *)&cmd_set_log,
13164 : : (cmdline_parse_inst_t *)&cmd_set_rxoffs,
13165 : : (cmdline_parse_inst_t *)&cmd_set_rxpkts,
13166 : : (cmdline_parse_inst_t *)&cmd_set_rxhdrs,
13167 : : (cmdline_parse_inst_t *)&cmd_set_txpkts,
13168 : : (cmdline_parse_inst_t *)&cmd_set_txsplit,
13169 : : (cmdline_parse_inst_t *)&cmd_set_txtimes,
13170 : : (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13171 : : (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13172 : : (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13173 : : (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13174 : : (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13175 : : (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13176 : : (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13177 : : (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13178 : : (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13179 : : (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13180 : : (cmdline_parse_inst_t *)&cmd_set_link_check,
13181 : : (cmdline_parse_inst_t *)&cmd_vlan_offload,
13182 : : (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13183 : : (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13184 : : (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13185 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13186 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13187 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13188 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13189 : : (cmdline_parse_inst_t *)&cmd_csum_set,
13190 : : (cmdline_parse_inst_t *)&cmd_csum_show,
13191 : : (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13192 : : (cmdline_parse_inst_t *)&cmd_csum_mac_swap,
13193 : : (cmdline_parse_inst_t *)&cmd_tso_set,
13194 : : (cmdline_parse_inst_t *)&cmd_tso_show,
13195 : : (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13196 : : (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13197 : : #ifdef RTE_LIB_GRO
13198 : : (cmdline_parse_inst_t *)&cmd_gro_enable,
13199 : : (cmdline_parse_inst_t *)&cmd_gro_flush,
13200 : : (cmdline_parse_inst_t *)&cmd_gro_show,
13201 : : #endif
13202 : : #ifdef RTE_LIB_GSO
13203 : : (cmdline_parse_inst_t *)&cmd_gso_enable,
13204 : : (cmdline_parse_inst_t *)&cmd_gso_size,
13205 : : (cmdline_parse_inst_t *)&cmd_gso_show,
13206 : : #endif
13207 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13208 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13209 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13210 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13211 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13212 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13213 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13214 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13215 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13216 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
13217 : : (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13218 : : (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
13219 : : (cmdline_parse_inst_t *)&cmd_config_dcb,
13220 : : (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13221 : : (cmdline_parse_inst_t *)&cmd_stop,
13222 : : (cmdline_parse_inst_t *)&cmd_mac_addr,
13223 : : (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
13224 : : (cmdline_parse_inst_t *)&cmd_set_qmap,
13225 : : (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
13226 : : (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
13227 : : (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
13228 : : (cmdline_parse_inst_t *)&cmd_operate_port,
13229 : : (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13230 : : (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13231 : : (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13232 : : (cmdline_parse_inst_t *)&cmd_operate_detach_device,
13233 : : (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
13234 : : (cmdline_parse_inst_t *)&cmd_config_speed_all,
13235 : : (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13236 : : (cmdline_parse_inst_t *)&cmd_config_loopback_all,
13237 : : (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
13238 : : (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13239 : : (cmdline_parse_inst_t *)&cmd_config_mtu,
13240 : : (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13241 : : (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
13242 : : (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13243 : : (cmdline_parse_inst_t *)&cmd_config_rss,
13244 : : (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
13245 : : (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13246 : : (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
13247 : : (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
13248 : : (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13249 : : (cmdline_parse_inst_t *)&cmd_showport_reta,
13250 : : (cmdline_parse_inst_t *)&cmd_showport_macs,
13251 : : (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
13252 : : (cmdline_parse_inst_t *)&cmd_config_burst,
13253 : : (cmdline_parse_inst_t *)&cmd_config_thresh,
13254 : : (cmdline_parse_inst_t *)&cmd_config_threshold,
13255 : : (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13256 : : (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13257 : : (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13258 : : (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13259 : : (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13260 : : (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13261 : : (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13262 : : (cmdline_parse_inst_t *)&cmd_showport_rss_hash_algo,
13263 : : (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13264 : : (cmdline_parse_inst_t *)&cmd_config_rss_hash_algo,
13265 : : (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
13266 : : (cmdline_parse_inst_t *)&cmd_dump,
13267 : : (cmdline_parse_inst_t *)&cmd_dump_one,
13268 : : (cmdline_parse_inst_t *)&cmd_flow,
13269 : : (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
13270 : : (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
13271 : : (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
13272 : : (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm_rfc4115,
13273 : : (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
13274 : : (cmdline_parse_inst_t *)&cmd_create_port_meter,
13275 : : (cmdline_parse_inst_t *)&cmd_enable_port_meter,
13276 : : (cmdline_parse_inst_t *)&cmd_disable_port_meter,
13277 : : (cmdline_parse_inst_t *)&cmd_del_port_meter,
13278 : : (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
13279 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
13280 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
13281 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
13282 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto,
13283 : : (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto,
13284 : : (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio,
13285 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
13286 : : (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
13287 : : (cmdline_parse_inst_t *)&cmd_mcast_addr,
13288 : : (cmdline_parse_inst_t *)&cmd_mcast_addr_flush,
13289 : : (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13290 : : (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13291 : : (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13292 : : (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13293 : : (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13294 : : (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13295 : : (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13296 : : (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13297 : : (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13298 : : (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13299 : : (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13300 : : (cmdline_parse_inst_t *)&cmd_set_vxlan,
13301 : : (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
13302 : : (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
13303 : : (cmdline_parse_inst_t *)&cmd_set_nvgre,
13304 : : (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
13305 : : (cmdline_parse_inst_t *)&cmd_set_l2_encap,
13306 : : (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
13307 : : (cmdline_parse_inst_t *)&cmd_set_l2_decap,
13308 : : (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
13309 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
13310 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
13311 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
13312 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
13313 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
13314 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
13315 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
13316 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
13317 : : (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
13318 : : (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
13319 : : (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13320 : : (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13321 : : (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
13322 : : (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
13323 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
13324 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
13325 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
13326 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
13327 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
13328 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
13329 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
13330 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
13331 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
13332 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
13333 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
13334 : : (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
13335 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
13336 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
13337 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
13338 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
13339 : : (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
13340 : : (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
13341 : : (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
13342 : : (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
13343 : : (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
13344 : : (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
13345 : : (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
13346 : : (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
13347 : : (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
13348 : : (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
13349 : : (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
13350 : : (cmdline_parse_inst_t *)&cmd_config_all_port_rx_offload,
13351 : : (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
13352 : : (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
13353 : : (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
13354 : : (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
13355 : : (cmdline_parse_inst_t *)&cmd_config_all_port_tx_offload,
13356 : : (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
13357 : : #ifdef RTE_LIB_BPF
13358 : : (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
13359 : : (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
13360 : : #endif
13361 : : (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
13362 : : (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
13363 : : (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
13364 : : (cmdline_parse_inst_t *)&cmd_show_rx_tx_queue_desc_used_count,
13365 : : (cmdline_parse_inst_t *)&cmd_set_raw,
13366 : : (cmdline_parse_inst_t *)&cmd_show_set_raw,
13367 : : (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
13368 : : (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
13369 : : (cmdline_parse_inst_t *)&cmd_show_fec_mode,
13370 : : (cmdline_parse_inst_t *)&cmd_set_fec_mode,
13371 : : (cmdline_parse_inst_t *)&cmd_set_rxq_avail_thresh,
13372 : : (cmdline_parse_inst_t *)&cmd_show_capability,
13373 : : (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
13374 : : (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
13375 : : (cmdline_parse_inst_t *)&cmd_show_port_cman_capa,
13376 : : (cmdline_parse_inst_t *)&cmd_show_port_cman_config,
13377 : : (cmdline_parse_inst_t *)&cmd_set_port_cman_config,
13378 : : (cmdline_parse_inst_t *)&cmd_config_tx_affinity_map,
13379 : : NULL,
13380 : : };
13381 : :
13382 : : void
13383 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
13384 : : {
13385 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
13386 : 0 : }
13387 : :
13388 : : int
13389 : 0 : init_cmdline(void)
13390 : : {
13391 : : struct testpmd_driver_commands *c;
13392 : : unsigned int count;
13393 : : unsigned int i;
13394 : :
13395 : : /* initialize non-constant commands */
13396 : 0 : cmd_set_fwd_mode_init();
13397 : 0 : cmd_set_fwd_retry_mode_init();
13398 : :
13399 : : count = 0;
13400 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
13401 : 0 : count++;
13402 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
13403 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
13404 : 0 : count++;
13405 : : }
13406 : :
13407 : : /* cmdline expects a NULL terminated array */
13408 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
13409 : 0 : if (main_ctx == NULL)
13410 : : return -1;
13411 : :
13412 : : count = 0;
13413 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
13414 : 0 : main_ctx[count] = builtin_ctx[i];
13415 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
13416 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
13417 : 0 : main_ctx[count] = c->commands[i].ctx;
13418 : : }
13419 : :
13420 : : return 0;
13421 : : }
13422 : :
13423 : : /* read cmdline commands from file */
13424 : : void
13425 : 0 : cmdline_read_from_file(const char *filename)
13426 : : {
13427 : : struct cmdline *cl;
13428 : :
13429 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
13430 : 0 : if (cl == NULL) {
13431 : 0 : fprintf(stderr,
13432 : : "Failed to create file based cmdline context: %s\n",
13433 : : filename);
13434 : 0 : return;
13435 : : }
13436 : :
13437 : 0 : cmdline_interact(cl);
13438 : 0 : cmdline_quit(cl);
13439 : :
13440 : 0 : cmdline_free(cl);
13441 : :
13442 : : printf("Read CLI commands from %s\n", filename);
13443 : : }
13444 : :
13445 : : void
13446 : 0 : prompt_exit(void)
13447 : : {
13448 : 0 : cmdline_quit(testpmd_cl);
13449 : 0 : }
13450 : :
13451 : : /* prompt function, called from main on MAIN lcore */
13452 : : void
13453 : 0 : prompt(void)
13454 : : {
13455 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13456 : 0 : if (testpmd_cl == NULL) {
13457 : 0 : fprintf(stderr,
13458 : : "Failed to create stdin based cmdline context\n");
13459 : 0 : return;
13460 : : }
13461 : :
13462 : 0 : cmdline_interact(testpmd_cl);
13463 : 0 : cmdline_stdin_exit(testpmd_cl);
13464 : : }
13465 : :
13466 : : void
13467 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13468 : : {
13469 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
13470 : : portid_t pid;
13471 : :
13472 : 0 : RTE_ETH_FOREACH_DEV(pid) {
13473 : : /* check if need_reconfig has been set to 1 */
13474 : 0 : if (ports[pid].need_reconfig == 0)
13475 : 0 : ports[pid].need_reconfig = dev;
13476 : : /* check if need_reconfig_queues has been set to 1 */
13477 : 0 : if (ports[pid].need_reconfig_queues == 0)
13478 : 0 : ports[pid].need_reconfig_queues = queue;
13479 : : }
13480 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13481 : : /* check if need_reconfig has been set to 1 */
13482 : 0 : if (ports[id].need_reconfig == 0)
13483 : 0 : ports[id].need_reconfig = dev;
13484 : : /* check if need_reconfig_queues has been set to 1 */
13485 : 0 : if (ports[id].need_reconfig_queues == 0)
13486 : 0 : ports[id].need_reconfig_queues = queue;
13487 : : }
13488 : 0 : }
|