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 update {port_id} {rule_id}"
855 : : " actions {action} [/ {action} [...]] / end [user_id]\n"
856 : : " Update a flow rule with new actions.\n\n"
857 : :
858 : : "flow flush {port_id}\n"
859 : : " Destroy all flow rules.\n\n"
860 : :
861 : : "flow query {port_id} {rule_id} {action}\n"
862 : : " Query an existing flow rule.\n\n"
863 : :
864 : : "flow list {port_id} [group {group_id}] [...]\n"
865 : : " List existing flow rules sorted by priority,"
866 : : " filtered by group identifiers.\n\n"
867 : :
868 : : "flow isolate {port_id} {boolean}\n"
869 : : " Restrict ingress traffic to the defined"
870 : : " flow rules\n\n"
871 : :
872 : : "flow aged {port_id} [destroy]\n"
873 : : " List and destroy aged flows"
874 : : " flow rules\n\n"
875 : :
876 : : "flow indirect_action {port_id} create"
877 : : " [action_id {indirect_action_id}]"
878 : : " [ingress] [egress]"
879 : : " action {action} / end\n"
880 : : " Create indirect action.\n\n"
881 : :
882 : : "flow indirect_action {port_id} update"
883 : : " {indirect_action_id} action {action} / end\n"
884 : : " Update indirect action.\n\n"
885 : :
886 : : "flow indirect_action {port_id} destroy"
887 : : " action_id {indirect_action_id} [...]\n"
888 : : " Destroy specific indirect actions.\n\n"
889 : :
890 : : "flow indirect_action {port_id} query"
891 : : " {indirect_action_id}\n"
892 : : " Query an existing indirect action.\n\n"
893 : :
894 : : "set vxlan ip-version (ipv4|ipv6) vni (vni) udp-src"
895 : : " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst"
896 : : " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n"
897 : : " Configure the VXLAN encapsulation for flows.\n\n"
898 : :
899 : : "set vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)"
900 : : " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)"
901 : : " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)"
902 : : " eth-dst (eth-dst)\n"
903 : : " Configure the VXLAN encapsulation for flows.\n\n"
904 : :
905 : : "set vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src"
906 : : " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)"
907 : : " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)"
908 : : " eth-dst (eth-dst)\n"
909 : : " Configure the VXLAN encapsulation for flows.\n\n"
910 : :
911 : : "set nvgre ip-version (ipv4|ipv6) tni (tni) ip-src"
912 : : " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst"
913 : : " (eth-dst)\n"
914 : : " Configure the NVGRE encapsulation for flows.\n\n"
915 : :
916 : : "set nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)"
917 : : " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)"
918 : : " eth-src (eth-src) eth-dst (eth-dst)\n"
919 : : " Configure the NVGRE encapsulation for flows.\n\n"
920 : :
921 : : "set raw_encap {flow items}\n"
922 : : " Configure the encapsulation with raw data.\n\n"
923 : :
924 : : "set raw_decap {flow items}\n"
925 : : " Configure the decapsulation with raw data.\n\n"
926 : :
927 : : );
928 : : }
929 : :
930 : 0 : if (show_all || !strcmp(res->section, "traffic_management")) {
931 : 0 : cmdline_printf(
932 : : cl,
933 : : "\n"
934 : : "Traffic Management:\n"
935 : : "--------------\n"
936 : : "show port tm cap (port_id)\n"
937 : : " Display the port TM capability.\n\n"
938 : :
939 : : "show port tm level cap (port_id) (level_id)\n"
940 : : " Display the port TM hierarchical level capability.\n\n"
941 : :
942 : : "show port tm node cap (port_id) (node_id)\n"
943 : : " Display the port TM node capability.\n\n"
944 : :
945 : : "show port tm node type (port_id) (node_id)\n"
946 : : " Display the port TM node type.\n\n"
947 : :
948 : : "show port tm node stats (port_id) (node_id) (clear)\n"
949 : : " Display the port TM node stats.\n\n"
950 : :
951 : : "add port tm node shaper profile (port_id) (shaper_profile_id)"
952 : : " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)"
953 : : " (packet_length_adjust) (packet_mode)\n"
954 : : " Add port tm node private shaper profile.\n\n"
955 : :
956 : : "del port tm node shaper profile (port_id) (shaper_profile_id)\n"
957 : : " Delete port tm node private shaper profile.\n\n"
958 : :
959 : : "add port tm node shared shaper (port_id) (shared_shaper_id)"
960 : : " (shaper_profile_id)\n"
961 : : " Add/update port tm node shared shaper.\n\n"
962 : :
963 : : "del port tm node shared shaper (port_id) (shared_shaper_id)\n"
964 : : " Delete port tm node shared shaper.\n\n"
965 : :
966 : : "set port tm node shaper profile (port_id) (node_id)"
967 : : " (shaper_profile_id)\n"
968 : : " Set port tm node shaper profile.\n\n"
969 : :
970 : : "add port tm node wred profile (port_id) (wred_profile_id)"
971 : : " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)"
972 : : " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)"
973 : : " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n"
974 : : " Add port tm node wred profile.\n\n"
975 : :
976 : : "del port tm node wred profile (port_id) (wred_profile_id)\n"
977 : : " Delete port tm node wred profile.\n\n"
978 : :
979 : : "add port tm nonleaf node (port_id) (node_id) (parent_node_id)"
980 : : " (priority) (weight) (level_id) (shaper_profile_id)"
981 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
982 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
983 : : " Add port tm nonleaf node.\n\n"
984 : :
985 : : "add port tm nonleaf node pktmode (port_id) (node_id) (parent_node_id)"
986 : : " (priority) (weight) (level_id) (shaper_profile_id)"
987 : : " (n_sp_priorities) (stats_mask) (n_shared_shapers)"
988 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
989 : : " Add port tm nonleaf node with pkt mode enabled.\n\n"
990 : :
991 : : "add port tm leaf node (port_id) (node_id) (parent_node_id)"
992 : : " (priority) (weight) (level_id) (shaper_profile_id)"
993 : : " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)"
994 : : " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n"
995 : : " Add port tm leaf node.\n\n"
996 : :
997 : : "del port tm node (port_id) (node_id)\n"
998 : : " Delete port tm node.\n\n"
999 : :
1000 : : "set port tm node parent (port_id) (node_id) (parent_node_id)"
1001 : : " (priority) (weight)\n"
1002 : : " Set port tm node parent.\n\n"
1003 : :
1004 : : "suspend port tm node (port_id) (node_id)"
1005 : : " Suspend tm node.\n\n"
1006 : :
1007 : : "resume port tm node (port_id) (node_id)"
1008 : : " Resume tm node.\n\n"
1009 : :
1010 : : "port tm hierarchy commit (port_id) (clean_on_fail)\n"
1011 : : " Commit tm hierarchy.\n\n"
1012 : :
1013 : : "set port tm mark ip_ecn (port) (green) (yellow)"
1014 : : " (red)\n"
1015 : : " Enables/Disables the traffic management marking"
1016 : : " for IP ECN (Explicit Congestion Notification)"
1017 : : " packets on a given port\n\n"
1018 : :
1019 : : "set port tm mark ip_dscp (port) (green) (yellow)"
1020 : : " (red)\n"
1021 : : " Enables/Disables the traffic management marking"
1022 : : " on the port for IP dscp packets\n\n"
1023 : :
1024 : : "set port tm mark vlan_dei (port) (green) (yellow)"
1025 : : " (red)\n"
1026 : : " Enables/Disables the traffic management marking"
1027 : : " on the port for VLAN packets with DEI enabled\n\n"
1028 : : );
1029 : : }
1030 : :
1031 : 0 : if (show_all || !strcmp(res->section, "devices")) {
1032 : 0 : cmdline_printf(
1033 : : cl,
1034 : : "\n"
1035 : : "Device Operations:\n"
1036 : : "--------------\n"
1037 : : "device detach (identifier)\n"
1038 : : " Detach device by identifier.\n\n"
1039 : : );
1040 : : }
1041 : :
1042 : 0 : if (show_all || !strcmp(res->section, "drivers")) {
1043 : : struct testpmd_driver_commands *c;
1044 : : unsigned int i;
1045 : :
1046 : 0 : cmdline_printf(
1047 : : cl,
1048 : : "\n"
1049 : : "Driver specific:\n"
1050 : : "----------------\n"
1051 : : );
1052 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
1053 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
1054 : 0 : cmdline_printf(cl, "%s\n", c->commands[i].help);
1055 : : }
1056 : : }
1057 : 0 : }
1058 : :
1059 : : static cmdline_parse_token_string_t cmd_help_long_help =
1060 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help");
1061 : :
1062 : : static cmdline_parse_token_string_t cmd_help_long_section =
1063 : : TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section,
1064 : : "all#control#display#config#ports#"
1065 : : "filters#traffic_management#devices#drivers");
1066 : :
1067 : : static cmdline_parse_inst_t cmd_help_long = {
1068 : : .f = cmd_help_long_parsed,
1069 : : .data = NULL,
1070 : : .help_str = "help all|control|display|config|ports|"
1071 : : "filters|traffic_management|devices|drivers: "
1072 : : "Show help",
1073 : : .tokens = {
1074 : : (void *)&cmd_help_long_help,
1075 : : (void *)&cmd_help_long_section,
1076 : : NULL,
1077 : : },
1078 : : };
1079 : :
1080 : :
1081 : : /* *** start/stop/close all ports *** */
1082 : : struct cmd_operate_port_result {
1083 : : cmdline_fixed_string_t keyword;
1084 : : cmdline_fixed_string_t name;
1085 : : cmdline_fixed_string_t value;
1086 : : };
1087 : :
1088 : 0 : static void cmd_operate_port_parsed(void *parsed_result,
1089 : : __rte_unused struct cmdline *cl,
1090 : : __rte_unused void *data)
1091 : : {
1092 : : struct cmd_operate_port_result *res = parsed_result;
1093 : :
1094 : 0 : if (!strcmp(res->name, "start"))
1095 : 0 : start_port(RTE_PORT_ALL);
1096 : 0 : else if (!strcmp(res->name, "stop"))
1097 : 0 : stop_port(RTE_PORT_ALL);
1098 : 0 : else if (!strcmp(res->name, "close"))
1099 : 0 : close_port(RTE_PORT_ALL);
1100 : 0 : else if (!strcmp(res->name, "reset"))
1101 : 0 : reset_port(RTE_PORT_ALL);
1102 : : else
1103 : 0 : fprintf(stderr, "Unknown parameter\n");
1104 : 0 : }
1105 : :
1106 : : static cmdline_parse_token_string_t cmd_operate_port_all_cmd =
1107 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword,
1108 : : "port");
1109 : : static cmdline_parse_token_string_t cmd_operate_port_all_port =
1110 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name,
1111 : : "start#stop#close#reset");
1112 : : static cmdline_parse_token_string_t cmd_operate_port_all_all =
1113 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all");
1114 : :
1115 : : static cmdline_parse_inst_t cmd_operate_port = {
1116 : : .f = cmd_operate_port_parsed,
1117 : : .data = NULL,
1118 : : .help_str = "port start|stop|close|reset all: Start/Stop/Close/Reset all ports",
1119 : : .tokens = {
1120 : : (void *)&cmd_operate_port_all_cmd,
1121 : : (void *)&cmd_operate_port_all_port,
1122 : : (void *)&cmd_operate_port_all_all,
1123 : : NULL,
1124 : : },
1125 : : };
1126 : :
1127 : : /* *** start/stop/close specific port *** */
1128 : : struct cmd_operate_specific_port_result {
1129 : : cmdline_fixed_string_t keyword;
1130 : : cmdline_fixed_string_t name;
1131 : : uint8_t value;
1132 : : };
1133 : :
1134 : 0 : static void cmd_operate_specific_port_parsed(void *parsed_result,
1135 : : __rte_unused struct cmdline *cl,
1136 : : __rte_unused void *data)
1137 : : {
1138 : : struct cmd_operate_specific_port_result *res = parsed_result;
1139 : :
1140 : 0 : if (!strcmp(res->name, "start"))
1141 : 0 : start_port(res->value);
1142 : 0 : else if (!strcmp(res->name, "stop"))
1143 : 0 : stop_port(res->value);
1144 : 0 : else if (!strcmp(res->name, "close"))
1145 : 0 : close_port(res->value);
1146 : 0 : else if (!strcmp(res->name, "reset"))
1147 : 0 : reset_port(res->value);
1148 : : else
1149 : 0 : fprintf(stderr, "Unknown parameter\n");
1150 : 0 : }
1151 : :
1152 : : static cmdline_parse_token_string_t cmd_operate_specific_port_cmd =
1153 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1154 : : keyword, "port");
1155 : : static cmdline_parse_token_string_t cmd_operate_specific_port_port =
1156 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result,
1157 : : name, "start#stop#close#reset");
1158 : : static cmdline_parse_token_num_t cmd_operate_specific_port_id =
1159 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result,
1160 : : value, RTE_UINT8);
1161 : :
1162 : : static cmdline_parse_inst_t cmd_operate_specific_port = {
1163 : : .f = cmd_operate_specific_port_parsed,
1164 : : .data = NULL,
1165 : : .help_str = "port start|stop|close|reset <port_id>: Start/Stop/Close/Reset port_id",
1166 : : .tokens = {
1167 : : (void *)&cmd_operate_specific_port_cmd,
1168 : : (void *)&cmd_operate_specific_port_port,
1169 : : (void *)&cmd_operate_specific_port_id,
1170 : : NULL,
1171 : : },
1172 : : };
1173 : :
1174 : : /* *** enable port setup (after attach) via iterator or event *** */
1175 : : struct cmd_set_port_setup_on_result {
1176 : : cmdline_fixed_string_t set;
1177 : : cmdline_fixed_string_t port;
1178 : : cmdline_fixed_string_t setup;
1179 : : cmdline_fixed_string_t on;
1180 : : cmdline_fixed_string_t mode;
1181 : : };
1182 : :
1183 : 0 : static void cmd_set_port_setup_on_parsed(void *parsed_result,
1184 : : __rte_unused struct cmdline *cl,
1185 : : __rte_unused void *data)
1186 : : {
1187 : : struct cmd_set_port_setup_on_result *res = parsed_result;
1188 : :
1189 : 0 : if (strcmp(res->mode, "event") == 0)
1190 : 0 : setup_on_probe_event = true;
1191 : 0 : else if (strcmp(res->mode, "iterator") == 0)
1192 : 0 : setup_on_probe_event = false;
1193 : : else
1194 : 0 : fprintf(stderr, "Unknown mode\n");
1195 : 0 : }
1196 : :
1197 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_set =
1198 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1199 : : set, "set");
1200 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_port =
1201 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1202 : : port, "port");
1203 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_setup =
1204 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1205 : : setup, "setup");
1206 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_on =
1207 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1208 : : on, "on");
1209 : : static cmdline_parse_token_string_t cmd_set_port_setup_on_mode =
1210 : : TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result,
1211 : : mode, "iterator#event");
1212 : :
1213 : : static cmdline_parse_inst_t cmd_set_port_setup_on = {
1214 : : .f = cmd_set_port_setup_on_parsed,
1215 : : .data = NULL,
1216 : : .help_str = "set port setup on iterator|event",
1217 : : .tokens = {
1218 : : (void *)&cmd_set_port_setup_on_set,
1219 : : (void *)&cmd_set_port_setup_on_port,
1220 : : (void *)&cmd_set_port_setup_on_setup,
1221 : : (void *)&cmd_set_port_setup_on_on,
1222 : : (void *)&cmd_set_port_setup_on_mode,
1223 : : NULL,
1224 : : },
1225 : : };
1226 : :
1227 : : /* *** attach a specified port *** */
1228 : : struct cmd_operate_attach_port_result {
1229 : : cmdline_fixed_string_t port;
1230 : : cmdline_fixed_string_t keyword;
1231 : : cmdline_multi_string_t identifier;
1232 : : };
1233 : :
1234 : 0 : static void cmd_operate_attach_port_parsed(void *parsed_result,
1235 : : __rte_unused struct cmdline *cl,
1236 : : __rte_unused void *data)
1237 : : {
1238 : : struct cmd_operate_attach_port_result *res = parsed_result;
1239 : :
1240 : 0 : if (!strcmp(res->keyword, "attach"))
1241 : 0 : attach_port(res->identifier);
1242 : : else
1243 : 0 : fprintf(stderr, "Unknown parameter\n");
1244 : 0 : }
1245 : :
1246 : : static cmdline_parse_token_string_t cmd_operate_attach_port_port =
1247 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1248 : : port, "port");
1249 : : static cmdline_parse_token_string_t cmd_operate_attach_port_keyword =
1250 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1251 : : keyword, "attach");
1252 : : static cmdline_parse_token_string_t cmd_operate_attach_port_identifier =
1253 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result,
1254 : : identifier, TOKEN_STRING_MULTI);
1255 : :
1256 : : static cmdline_parse_inst_t cmd_operate_attach_port = {
1257 : : .f = cmd_operate_attach_port_parsed,
1258 : : .data = NULL,
1259 : : .help_str = "port attach <identifier>: "
1260 : : "(identifier: pci address or virtual dev name)",
1261 : : .tokens = {
1262 : : (void *)&cmd_operate_attach_port_port,
1263 : : (void *)&cmd_operate_attach_port_keyword,
1264 : : (void *)&cmd_operate_attach_port_identifier,
1265 : : NULL,
1266 : : },
1267 : : };
1268 : :
1269 : : /* *** detach a specified port *** */
1270 : : struct cmd_operate_detach_port_result {
1271 : : cmdline_fixed_string_t port;
1272 : : cmdline_fixed_string_t keyword;
1273 : : portid_t port_id;
1274 : : };
1275 : :
1276 : 0 : static void cmd_operate_detach_port_parsed(void *parsed_result,
1277 : : __rte_unused struct cmdline *cl,
1278 : : __rte_unused void *data)
1279 : : {
1280 : : struct cmd_operate_detach_port_result *res = parsed_result;
1281 : :
1282 : 0 : if (!strcmp(res->keyword, "detach")) {
1283 : 0 : RTE_ETH_VALID_PORTID_OR_RET(res->port_id);
1284 : 0 : detach_port_device(res->port_id);
1285 : : } else {
1286 : 0 : fprintf(stderr, "Unknown parameter\n");
1287 : : }
1288 : : }
1289 : :
1290 : : static cmdline_parse_token_string_t cmd_operate_detach_port_port =
1291 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1292 : : port, "port");
1293 : : static cmdline_parse_token_string_t cmd_operate_detach_port_keyword =
1294 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result,
1295 : : keyword, "detach");
1296 : : static cmdline_parse_token_num_t cmd_operate_detach_port_port_id =
1297 : : TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result,
1298 : : port_id, RTE_UINT16);
1299 : :
1300 : : static cmdline_parse_inst_t cmd_operate_detach_port = {
1301 : : .f = cmd_operate_detach_port_parsed,
1302 : : .data = NULL,
1303 : : .help_str = "port detach <port_id>",
1304 : : .tokens = {
1305 : : (void *)&cmd_operate_detach_port_port,
1306 : : (void *)&cmd_operate_detach_port_keyword,
1307 : : (void *)&cmd_operate_detach_port_port_id,
1308 : : NULL,
1309 : : },
1310 : : };
1311 : :
1312 : : /* *** detach device by identifier *** */
1313 : : struct cmd_operate_detach_device_result {
1314 : : cmdline_fixed_string_t device;
1315 : : cmdline_fixed_string_t keyword;
1316 : : cmdline_fixed_string_t identifier;
1317 : : };
1318 : :
1319 : 0 : static void cmd_operate_detach_device_parsed(void *parsed_result,
1320 : : __rte_unused struct cmdline *cl,
1321 : : __rte_unused void *data)
1322 : : {
1323 : : struct cmd_operate_detach_device_result *res = parsed_result;
1324 : :
1325 : 0 : if (!strcmp(res->keyword, "detach"))
1326 : 0 : detach_devargs(res->identifier);
1327 : : else
1328 : 0 : fprintf(stderr, "Unknown parameter\n");
1329 : 0 : }
1330 : :
1331 : : static cmdline_parse_token_string_t cmd_operate_detach_device_device =
1332 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1333 : : device, "device");
1334 : : static cmdline_parse_token_string_t cmd_operate_detach_device_keyword =
1335 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1336 : : keyword, "detach");
1337 : : static cmdline_parse_token_string_t cmd_operate_detach_device_identifier =
1338 : : TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_device_result,
1339 : : identifier, NULL);
1340 : :
1341 : : static cmdline_parse_inst_t cmd_operate_detach_device = {
1342 : : .f = cmd_operate_detach_device_parsed,
1343 : : .data = NULL,
1344 : : .help_str = "device detach <identifier>:"
1345 : : "(identifier: pci address or virtual dev name)",
1346 : : .tokens = {
1347 : : (void *)&cmd_operate_detach_device_device,
1348 : : (void *)&cmd_operate_detach_device_keyword,
1349 : : (void *)&cmd_operate_detach_device_identifier,
1350 : : NULL,
1351 : : },
1352 : : };
1353 : : /* *** configure speed for all ports *** */
1354 : : struct cmd_config_speed_all {
1355 : : cmdline_fixed_string_t port;
1356 : : cmdline_fixed_string_t keyword;
1357 : : cmdline_fixed_string_t all;
1358 : : cmdline_fixed_string_t item1;
1359 : : cmdline_fixed_string_t item2;
1360 : : cmdline_fixed_string_t value1;
1361 : : cmdline_fixed_string_t value2;
1362 : : };
1363 : :
1364 : : static int
1365 : 0 : parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed)
1366 : : {
1367 : :
1368 : : int duplex;
1369 : :
1370 : 0 : if (!strcmp(duplexstr, "half")) {
1371 : : duplex = RTE_ETH_LINK_HALF_DUPLEX;
1372 : 0 : } else if (!strcmp(duplexstr, "full")) {
1373 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1374 : 0 : } else if (!strcmp(duplexstr, "auto")) {
1375 : : duplex = RTE_ETH_LINK_FULL_DUPLEX;
1376 : : } else {
1377 : 0 : fprintf(stderr, "Unknown duplex parameter\n");
1378 : 0 : return -1;
1379 : : }
1380 : :
1381 : 0 : if (!strcmp(speedstr, "10")) {
1382 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1383 : 0 : RTE_ETH_LINK_SPEED_10M_HD : RTE_ETH_LINK_SPEED_10M;
1384 : 0 : } else if (!strcmp(speedstr, "100")) {
1385 : 0 : *speed = (duplex == RTE_ETH_LINK_HALF_DUPLEX) ?
1386 : 0 : RTE_ETH_LINK_SPEED_100M_HD : RTE_ETH_LINK_SPEED_100M;
1387 : : } else {
1388 : 0 : if (duplex != RTE_ETH_LINK_FULL_DUPLEX) {
1389 : 0 : fprintf(stderr, "Invalid speed/duplex parameters\n");
1390 : 0 : return -1;
1391 : : }
1392 : 0 : if (!strcmp(speedstr, "1000")) {
1393 : 0 : *speed = RTE_ETH_LINK_SPEED_1G;
1394 : 0 : } else if (!strcmp(speedstr, "2500")) {
1395 : 0 : *speed = RTE_ETH_LINK_SPEED_2_5G;
1396 : 0 : } else if (!strcmp(speedstr, "5000")) {
1397 : 0 : *speed = RTE_ETH_LINK_SPEED_5G;
1398 : 0 : } else if (!strcmp(speedstr, "10000")) {
1399 : 0 : *speed = RTE_ETH_LINK_SPEED_10G;
1400 : 0 : } else if (!strcmp(speedstr, "25000")) {
1401 : 0 : *speed = RTE_ETH_LINK_SPEED_25G;
1402 : 0 : } else if (!strcmp(speedstr, "40000")) {
1403 : 0 : *speed = RTE_ETH_LINK_SPEED_40G;
1404 : 0 : } else if (!strcmp(speedstr, "50000")) {
1405 : 0 : *speed = RTE_ETH_LINK_SPEED_50G;
1406 : 0 : } else if (!strcmp(speedstr, "100000")) {
1407 : 0 : *speed = RTE_ETH_LINK_SPEED_100G;
1408 : 0 : } else if (!strcmp(speedstr, "200000")) {
1409 : 0 : *speed = RTE_ETH_LINK_SPEED_200G;
1410 : 0 : } else if (!strcmp(speedstr, "400000")) {
1411 : 0 : *speed = RTE_ETH_LINK_SPEED_400G;
1412 : 0 : } else if (!strcmp(speedstr, "auto")) {
1413 : 0 : *speed = RTE_ETH_LINK_SPEED_AUTONEG;
1414 : : } else {
1415 : 0 : fprintf(stderr, "Unknown speed parameter\n");
1416 : 0 : return -1;
1417 : : }
1418 : : }
1419 : :
1420 : 0 : if (*speed != RTE_ETH_LINK_SPEED_AUTONEG)
1421 : 0 : *speed |= RTE_ETH_LINK_SPEED_FIXED;
1422 : :
1423 : : return 0;
1424 : : }
1425 : :
1426 : : static void
1427 : 0 : cmd_config_speed_all_parsed(void *parsed_result,
1428 : : __rte_unused struct cmdline *cl,
1429 : : __rte_unused void *data)
1430 : : {
1431 : : struct cmd_config_speed_all *res = parsed_result;
1432 : : uint32_t link_speed;
1433 : : portid_t pid;
1434 : :
1435 : 0 : if (!all_ports_stopped()) {
1436 : 0 : fprintf(stderr, "Please stop all ports first\n");
1437 : 0 : return;
1438 : : }
1439 : :
1440 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1441 : : &link_speed) < 0)
1442 : : return;
1443 : :
1444 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1445 : 0 : ports[pid].dev_conf.link_speeds = link_speed;
1446 : : }
1447 : :
1448 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1449 : : }
1450 : :
1451 : : static cmdline_parse_token_string_t cmd_config_speed_all_port =
1452 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port");
1453 : : static cmdline_parse_token_string_t cmd_config_speed_all_keyword =
1454 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword,
1455 : : "config");
1456 : : static cmdline_parse_token_string_t cmd_config_speed_all_all =
1457 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all");
1458 : : static cmdline_parse_token_string_t cmd_config_speed_all_item1 =
1459 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed");
1460 : : static cmdline_parse_token_string_t cmd_config_speed_all_value1 =
1461 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1,
1462 : : "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1463 : : static cmdline_parse_token_string_t cmd_config_speed_all_item2 =
1464 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex");
1465 : : static cmdline_parse_token_string_t cmd_config_speed_all_value2 =
1466 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2,
1467 : : "half#full#auto");
1468 : :
1469 : : static cmdline_parse_inst_t cmd_config_speed_all = {
1470 : : .f = cmd_config_speed_all_parsed,
1471 : : .data = NULL,
1472 : : .help_str = "port config all speed "
1473 : : "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1474 : : "half|full|auto",
1475 : : .tokens = {
1476 : : (void *)&cmd_config_speed_all_port,
1477 : : (void *)&cmd_config_speed_all_keyword,
1478 : : (void *)&cmd_config_speed_all_all,
1479 : : (void *)&cmd_config_speed_all_item1,
1480 : : (void *)&cmd_config_speed_all_value1,
1481 : : (void *)&cmd_config_speed_all_item2,
1482 : : (void *)&cmd_config_speed_all_value2,
1483 : : NULL,
1484 : : },
1485 : : };
1486 : :
1487 : : /* *** configure speed for specific port *** */
1488 : : struct cmd_config_speed_specific {
1489 : : cmdline_fixed_string_t port;
1490 : : cmdline_fixed_string_t keyword;
1491 : : portid_t id;
1492 : : cmdline_fixed_string_t item1;
1493 : : cmdline_fixed_string_t item2;
1494 : : cmdline_fixed_string_t value1;
1495 : : cmdline_fixed_string_t value2;
1496 : : };
1497 : :
1498 : : static void
1499 : 0 : cmd_config_speed_specific_parsed(void *parsed_result,
1500 : : __rte_unused struct cmdline *cl,
1501 : : __rte_unused void *data)
1502 : : {
1503 : : struct cmd_config_speed_specific *res = parsed_result;
1504 : : uint32_t link_speed;
1505 : :
1506 : 0 : if (port_id_is_invalid(res->id, ENABLED_WARN))
1507 : 0 : return;
1508 : :
1509 : 0 : if (!port_is_stopped(res->id)) {
1510 : 0 : fprintf(stderr, "Please stop port %d first\n", res->id);
1511 : 0 : return;
1512 : : }
1513 : :
1514 : 0 : if (parse_and_check_speed_duplex(res->value1, res->value2,
1515 : : &link_speed) < 0)
1516 : : return;
1517 : :
1518 : 0 : ports[res->id].dev_conf.link_speeds = link_speed;
1519 : :
1520 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1521 : : }
1522 : :
1523 : :
1524 : : static cmdline_parse_token_string_t cmd_config_speed_specific_port =
1525 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port,
1526 : : "port");
1527 : : static cmdline_parse_token_string_t cmd_config_speed_specific_keyword =
1528 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword,
1529 : : "config");
1530 : : static cmdline_parse_token_num_t cmd_config_speed_specific_id =
1531 : : TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, RTE_UINT16);
1532 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item1 =
1533 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1,
1534 : : "speed");
1535 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value1 =
1536 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1,
1537 : : "10#100#1000#2500#5000#10000#25000#40000#50000#100000#200000#400000#auto");
1538 : : static cmdline_parse_token_string_t cmd_config_speed_specific_item2 =
1539 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2,
1540 : : "duplex");
1541 : : static cmdline_parse_token_string_t cmd_config_speed_specific_value2 =
1542 : : TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2,
1543 : : "half#full#auto");
1544 : :
1545 : : static cmdline_parse_inst_t cmd_config_speed_specific = {
1546 : : .f = cmd_config_speed_specific_parsed,
1547 : : .data = NULL,
1548 : : .help_str = "port config <port_id> speed "
1549 : : "10|100|1000|2500|5000|10000|25000|40000|50000|100000|200000|400000|auto duplex "
1550 : : "half|full|auto",
1551 : : .tokens = {
1552 : : (void *)&cmd_config_speed_specific_port,
1553 : : (void *)&cmd_config_speed_specific_keyword,
1554 : : (void *)&cmd_config_speed_specific_id,
1555 : : (void *)&cmd_config_speed_specific_item1,
1556 : : (void *)&cmd_config_speed_specific_value1,
1557 : : (void *)&cmd_config_speed_specific_item2,
1558 : : (void *)&cmd_config_speed_specific_value2,
1559 : : NULL,
1560 : : },
1561 : : };
1562 : :
1563 : : /* *** configure loopback for all ports *** */
1564 : : struct cmd_config_loopback_all {
1565 : : cmdline_fixed_string_t port;
1566 : : cmdline_fixed_string_t keyword;
1567 : : cmdline_fixed_string_t all;
1568 : : cmdline_fixed_string_t item;
1569 : : uint32_t mode;
1570 : : };
1571 : :
1572 : : static void
1573 : 0 : cmd_config_loopback_all_parsed(void *parsed_result,
1574 : : __rte_unused struct cmdline *cl,
1575 : : __rte_unused void *data)
1576 : : {
1577 : : struct cmd_config_loopback_all *res = parsed_result;
1578 : : portid_t pid;
1579 : :
1580 : 0 : if (!all_ports_stopped()) {
1581 : 0 : fprintf(stderr, "Please stop all ports first\n");
1582 : 0 : return;
1583 : : }
1584 : :
1585 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1586 : 0 : ports[pid].dev_conf.lpbk_mode = res->mode;
1587 : : }
1588 : :
1589 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1590 : : }
1591 : :
1592 : : static cmdline_parse_token_string_t cmd_config_loopback_all_port =
1593 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port");
1594 : : static cmdline_parse_token_string_t cmd_config_loopback_all_keyword =
1595 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword,
1596 : : "config");
1597 : : static cmdline_parse_token_string_t cmd_config_loopback_all_all =
1598 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all");
1599 : : static cmdline_parse_token_string_t cmd_config_loopback_all_item =
1600 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item,
1601 : : "loopback");
1602 : : static cmdline_parse_token_num_t cmd_config_loopback_all_mode =
1603 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, RTE_UINT32);
1604 : :
1605 : : static cmdline_parse_inst_t cmd_config_loopback_all = {
1606 : : .f = cmd_config_loopback_all_parsed,
1607 : : .data = NULL,
1608 : : .help_str = "port config all loopback <mode>",
1609 : : .tokens = {
1610 : : (void *)&cmd_config_loopback_all_port,
1611 : : (void *)&cmd_config_loopback_all_keyword,
1612 : : (void *)&cmd_config_loopback_all_all,
1613 : : (void *)&cmd_config_loopback_all_item,
1614 : : (void *)&cmd_config_loopback_all_mode,
1615 : : NULL,
1616 : : },
1617 : : };
1618 : :
1619 : : /* *** configure loopback for specific port *** */
1620 : : struct cmd_config_loopback_specific {
1621 : : cmdline_fixed_string_t port;
1622 : : cmdline_fixed_string_t keyword;
1623 : : uint16_t port_id;
1624 : : cmdline_fixed_string_t item;
1625 : : uint32_t mode;
1626 : : };
1627 : :
1628 : : static void
1629 : 0 : cmd_config_loopback_specific_parsed(void *parsed_result,
1630 : : __rte_unused struct cmdline *cl,
1631 : : __rte_unused void *data)
1632 : : {
1633 : : struct cmd_config_loopback_specific *res = parsed_result;
1634 : :
1635 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
1636 : : return;
1637 : :
1638 : 0 : if (!port_is_stopped(res->port_id)) {
1639 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
1640 : 0 : return;
1641 : : }
1642 : :
1643 : 0 : ports[res->port_id].dev_conf.lpbk_mode = res->mode;
1644 : :
1645 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
1646 : : }
1647 : :
1648 : :
1649 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_port =
1650 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port,
1651 : : "port");
1652 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_keyword =
1653 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword,
1654 : : "config");
1655 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_id =
1656 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id,
1657 : : RTE_UINT16);
1658 : : static cmdline_parse_token_string_t cmd_config_loopback_specific_item =
1659 : : TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item,
1660 : : "loopback");
1661 : : static cmdline_parse_token_num_t cmd_config_loopback_specific_mode =
1662 : : TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode,
1663 : : RTE_UINT32);
1664 : :
1665 : : static cmdline_parse_inst_t cmd_config_loopback_specific = {
1666 : : .f = cmd_config_loopback_specific_parsed,
1667 : : .data = NULL,
1668 : : .help_str = "port config <port_id> loopback <mode>",
1669 : : .tokens = {
1670 : : (void *)&cmd_config_loopback_specific_port,
1671 : : (void *)&cmd_config_loopback_specific_keyword,
1672 : : (void *)&cmd_config_loopback_specific_id,
1673 : : (void *)&cmd_config_loopback_specific_item,
1674 : : (void *)&cmd_config_loopback_specific_mode,
1675 : : NULL,
1676 : : },
1677 : : };
1678 : :
1679 : : /* *** configure txq/rxq, txd/rxd *** */
1680 : : struct cmd_config_rx_tx {
1681 : : cmdline_fixed_string_t port;
1682 : : cmdline_fixed_string_t keyword;
1683 : : cmdline_fixed_string_t all;
1684 : : cmdline_fixed_string_t name;
1685 : : uint16_t value;
1686 : : };
1687 : :
1688 : : static void
1689 : 0 : cmd_config_rx_tx_parsed(void *parsed_result,
1690 : : __rte_unused struct cmdline *cl,
1691 : : __rte_unused void *data)
1692 : : {
1693 : : struct cmd_config_rx_tx *res = parsed_result;
1694 : :
1695 : 0 : if (!all_ports_stopped()) {
1696 : 0 : fprintf(stderr, "Please stop all ports first\n");
1697 : 0 : return;
1698 : : }
1699 : 0 : if (!strcmp(res->name, "rxq")) {
1700 : 0 : if (!res->value && !nb_txq) {
1701 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1702 : 0 : return;
1703 : : }
1704 : 0 : if (check_nb_rxq(res->value) != 0)
1705 : : return;
1706 : 0 : nb_rxq = res->value;
1707 : : }
1708 : 0 : else if (!strcmp(res->name, "txq")) {
1709 : 0 : if (!res->value && !nb_rxq) {
1710 : 0 : fprintf(stderr, "Warning: Either rx or tx queues should be non zero\n");
1711 : 0 : return;
1712 : : }
1713 : 0 : if (check_nb_txq(res->value) != 0)
1714 : : return;
1715 : 0 : nb_txq = res->value;
1716 : : }
1717 : 0 : else if (!strcmp(res->name, "rxd")) {
1718 : 0 : if (check_nb_rxd(res->value) != 0)
1719 : : return;
1720 : 0 : nb_rxd = res->value;
1721 : 0 : } else if (!strcmp(res->name, "txd")) {
1722 : 0 : if (check_nb_txd(res->value) != 0)
1723 : : return;
1724 : :
1725 : 0 : nb_txd = res->value;
1726 : : } else {
1727 : 0 : fprintf(stderr, "Unknown parameter\n");
1728 : 0 : return;
1729 : : }
1730 : :
1731 : 0 : fwd_config_setup();
1732 : :
1733 : 0 : init_port_config();
1734 : :
1735 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1736 : : }
1737 : :
1738 : : static cmdline_parse_token_string_t cmd_config_rx_tx_port =
1739 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port");
1740 : : static cmdline_parse_token_string_t cmd_config_rx_tx_keyword =
1741 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config");
1742 : : static cmdline_parse_token_string_t cmd_config_rx_tx_all =
1743 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all");
1744 : : static cmdline_parse_token_string_t cmd_config_rx_tx_name =
1745 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name,
1746 : : "rxq#txq#rxd#txd");
1747 : : static cmdline_parse_token_num_t cmd_config_rx_tx_value =
1748 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, RTE_UINT16);
1749 : :
1750 : : static cmdline_parse_inst_t cmd_config_rx_tx = {
1751 : : .f = cmd_config_rx_tx_parsed,
1752 : : .data = NULL,
1753 : : .help_str = "port config all rxq|txq|rxd|txd <value>",
1754 : : .tokens = {
1755 : : (void *)&cmd_config_rx_tx_port,
1756 : : (void *)&cmd_config_rx_tx_keyword,
1757 : : (void *)&cmd_config_rx_tx_all,
1758 : : (void *)&cmd_config_rx_tx_name,
1759 : : (void *)&cmd_config_rx_tx_value,
1760 : : NULL,
1761 : : },
1762 : : };
1763 : :
1764 : : /* *** config max packet length *** */
1765 : : struct cmd_config_max_pkt_len_result {
1766 : : cmdline_fixed_string_t port;
1767 : : cmdline_fixed_string_t keyword;
1768 : : cmdline_fixed_string_t all;
1769 : : cmdline_fixed_string_t name;
1770 : : uint32_t value;
1771 : : };
1772 : :
1773 : : static void
1774 : 0 : cmd_config_max_pkt_len_parsed(void *parsed_result,
1775 : : __rte_unused struct cmdline *cl,
1776 : : __rte_unused void *data)
1777 : : {
1778 : : struct cmd_config_max_pkt_len_result *res = parsed_result;
1779 : : portid_t port_id;
1780 : : int ret;
1781 : :
1782 : 0 : if (strcmp(res->name, "max-pkt-len") != 0) {
1783 : : printf("Unknown parameter\n");
1784 : 0 : return;
1785 : : }
1786 : :
1787 : 0 : if (!all_ports_stopped()) {
1788 : 0 : fprintf(stderr, "Please stop all ports first\n");
1789 : 0 : return;
1790 : : }
1791 : :
1792 : 0 : RTE_ETH_FOREACH_DEV(port_id) {
1793 : 0 : struct rte_port *port = &ports[port_id];
1794 : :
1795 : 0 : if (res->value < RTE_ETHER_MIN_LEN) {
1796 : 0 : fprintf(stderr,
1797 : : "max-pkt-len can not be less than %d\n",
1798 : : RTE_ETHER_MIN_LEN);
1799 : 0 : return;
1800 : : }
1801 : :
1802 : 0 : ret = eth_dev_info_get_print_err(port_id, &port->dev_info);
1803 : 0 : if (ret != 0) {
1804 : 0 : fprintf(stderr,
1805 : : "rte_eth_dev_info_get() failed for port %u\n",
1806 : : port_id);
1807 : 0 : return;
1808 : : }
1809 : :
1810 : 0 : update_mtu_from_frame_size(port_id, res->value);
1811 : : }
1812 : :
1813 : 0 : init_port_config();
1814 : :
1815 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1816 : : }
1817 : :
1818 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_port =
1819 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port,
1820 : : "port");
1821 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword =
1822 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword,
1823 : : "config");
1824 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_all =
1825 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all,
1826 : : "all");
1827 : : static cmdline_parse_token_string_t cmd_config_max_pkt_len_name =
1828 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name,
1829 : : "max-pkt-len");
1830 : : static cmdline_parse_token_num_t cmd_config_max_pkt_len_value =
1831 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value,
1832 : : RTE_UINT32);
1833 : :
1834 : : static cmdline_parse_inst_t cmd_config_max_pkt_len = {
1835 : : .f = cmd_config_max_pkt_len_parsed,
1836 : : .data = NULL,
1837 : : .help_str = "port config all max-pkt-len <value>",
1838 : : .tokens = {
1839 : : (void *)&cmd_config_max_pkt_len_port,
1840 : : (void *)&cmd_config_max_pkt_len_keyword,
1841 : : (void *)&cmd_config_max_pkt_len_all,
1842 : : (void *)&cmd_config_max_pkt_len_name,
1843 : : (void *)&cmd_config_max_pkt_len_value,
1844 : : NULL,
1845 : : },
1846 : : };
1847 : :
1848 : : /* *** config max LRO aggregated packet size *** */
1849 : : struct cmd_config_max_lro_pkt_size_result {
1850 : : cmdline_fixed_string_t port;
1851 : : cmdline_fixed_string_t keyword;
1852 : : cmdline_fixed_string_t all;
1853 : : cmdline_fixed_string_t name;
1854 : : uint32_t value;
1855 : : };
1856 : :
1857 : : static void
1858 : 0 : cmd_config_max_lro_pkt_size_parsed(void *parsed_result,
1859 : : __rte_unused struct cmdline *cl,
1860 : : __rte_unused void *data)
1861 : : {
1862 : : struct cmd_config_max_lro_pkt_size_result *res = parsed_result;
1863 : : portid_t pid;
1864 : :
1865 : 0 : if (!all_ports_stopped()) {
1866 : 0 : fprintf(stderr, "Please stop all ports first\n");
1867 : 0 : return;
1868 : : }
1869 : :
1870 : 0 : RTE_ETH_FOREACH_DEV(pid) {
1871 : 0 : struct rte_port *port = &ports[pid];
1872 : :
1873 : 0 : if (!strcmp(res->name, "max-lro-pkt-size")) {
1874 : 0 : if (res->value ==
1875 : 0 : port->dev_conf.rxmode.max_lro_pkt_size)
1876 : : return;
1877 : :
1878 : 0 : port->dev_conf.rxmode.max_lro_pkt_size = res->value;
1879 : : } else {
1880 : 0 : fprintf(stderr, "Unknown parameter\n");
1881 : 0 : return;
1882 : : }
1883 : : }
1884 : :
1885 : 0 : init_port_config();
1886 : :
1887 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
1888 : : }
1889 : :
1890 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_port =
1891 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1892 : : port, "port");
1893 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_keyword =
1894 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1895 : : keyword, "config");
1896 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_all =
1897 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1898 : : all, "all");
1899 : : static cmdline_parse_token_string_t cmd_config_max_lro_pkt_size_name =
1900 : : TOKEN_STRING_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1901 : : name, "max-lro-pkt-size");
1902 : : static cmdline_parse_token_num_t cmd_config_max_lro_pkt_size_value =
1903 : : TOKEN_NUM_INITIALIZER(struct cmd_config_max_lro_pkt_size_result,
1904 : : value, RTE_UINT32);
1905 : :
1906 : : static cmdline_parse_inst_t cmd_config_max_lro_pkt_size = {
1907 : : .f = cmd_config_max_lro_pkt_size_parsed,
1908 : : .data = NULL,
1909 : : .help_str = "port config all max-lro-pkt-size <value>",
1910 : : .tokens = {
1911 : : (void *)&cmd_config_max_lro_pkt_size_port,
1912 : : (void *)&cmd_config_max_lro_pkt_size_keyword,
1913 : : (void *)&cmd_config_max_lro_pkt_size_all,
1914 : : (void *)&cmd_config_max_lro_pkt_size_name,
1915 : : (void *)&cmd_config_max_lro_pkt_size_value,
1916 : : NULL,
1917 : : },
1918 : : };
1919 : :
1920 : : /* *** configure port MTU *** */
1921 : : struct cmd_config_mtu_result {
1922 : : cmdline_fixed_string_t port;
1923 : : cmdline_fixed_string_t keyword;
1924 : : cmdline_fixed_string_t mtu;
1925 : : portid_t port_id;
1926 : : uint16_t value;
1927 : : };
1928 : :
1929 : : static void
1930 : 0 : cmd_config_mtu_parsed(void *parsed_result,
1931 : : __rte_unused struct cmdline *cl,
1932 : : __rte_unused void *data)
1933 : : {
1934 : : struct cmd_config_mtu_result *res = parsed_result;
1935 : :
1936 : 0 : port_mtu_set(res->port_id, res->value);
1937 : 0 : }
1938 : :
1939 : : static cmdline_parse_token_string_t cmd_config_mtu_port =
1940 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
1941 : : "port");
1942 : : static cmdline_parse_token_string_t cmd_config_mtu_keyword =
1943 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1944 : : "config");
1945 : : static cmdline_parse_token_string_t cmd_config_mtu_mtu =
1946 : : TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
1947 : : "mtu");
1948 : : static cmdline_parse_token_num_t cmd_config_mtu_port_id =
1949 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id,
1950 : : RTE_UINT16);
1951 : : static cmdline_parse_token_num_t cmd_config_mtu_value =
1952 : : TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value,
1953 : : RTE_UINT16);
1954 : :
1955 : : static cmdline_parse_inst_t cmd_config_mtu = {
1956 : : .f = cmd_config_mtu_parsed,
1957 : : .data = NULL,
1958 : : .help_str = "port config mtu <port_id> <value>",
1959 : : .tokens = {
1960 : : (void *)&cmd_config_mtu_port,
1961 : : (void *)&cmd_config_mtu_keyword,
1962 : : (void *)&cmd_config_mtu_mtu,
1963 : : (void *)&cmd_config_mtu_port_id,
1964 : : (void *)&cmd_config_mtu_value,
1965 : : NULL,
1966 : : },
1967 : : };
1968 : :
1969 : : /* *** configure rx mode *** */
1970 : : struct cmd_config_rx_mode_flag {
1971 : : cmdline_fixed_string_t port;
1972 : : cmdline_fixed_string_t keyword;
1973 : : cmdline_fixed_string_t all;
1974 : : cmdline_fixed_string_t name;
1975 : : cmdline_fixed_string_t value;
1976 : : };
1977 : :
1978 : : static void
1979 : 0 : cmd_config_rx_mode_flag_parsed(void *parsed_result,
1980 : : __rte_unused struct cmdline *cl,
1981 : : __rte_unused void *data)
1982 : : {
1983 : : struct cmd_config_rx_mode_flag *res = parsed_result;
1984 : :
1985 : 0 : if (!all_ports_stopped()) {
1986 : 0 : fprintf(stderr, "Please stop all ports first\n");
1987 : 0 : return;
1988 : : }
1989 : :
1990 : 0 : if (!strcmp(res->name, "drop-en")) {
1991 : 0 : if (!strcmp(res->value, "on"))
1992 : 0 : rx_drop_en = 1;
1993 : 0 : else if (!strcmp(res->value, "off"))
1994 : 0 : rx_drop_en = 0;
1995 : : else {
1996 : 0 : fprintf(stderr, "Unknown parameter\n");
1997 : 0 : return;
1998 : : }
1999 : : } else {
2000 : 0 : fprintf(stderr, "Unknown parameter\n");
2001 : 0 : return;
2002 : : }
2003 : :
2004 : 0 : init_port_config();
2005 : :
2006 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
2007 : : }
2008 : :
2009 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_port =
2010 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port");
2011 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword =
2012 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword,
2013 : : "config");
2014 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_all =
2015 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all");
2016 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_name =
2017 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name,
2018 : : "drop-en");
2019 : : static cmdline_parse_token_string_t cmd_config_rx_mode_flag_value =
2020 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value,
2021 : : "on#off");
2022 : :
2023 : : static cmdline_parse_inst_t cmd_config_rx_mode_flag = {
2024 : : .f = cmd_config_rx_mode_flag_parsed,
2025 : : .data = NULL,
2026 : : .help_str = "port config all drop-en on|off",
2027 : : .tokens = {
2028 : : (void *)&cmd_config_rx_mode_flag_port,
2029 : : (void *)&cmd_config_rx_mode_flag_keyword,
2030 : : (void *)&cmd_config_rx_mode_flag_all,
2031 : : (void *)&cmd_config_rx_mode_flag_name,
2032 : : (void *)&cmd_config_rx_mode_flag_value,
2033 : : NULL,
2034 : : },
2035 : : };
2036 : :
2037 : : /* *** configure rss *** */
2038 : : struct cmd_config_rss {
2039 : : cmdline_fixed_string_t port;
2040 : : cmdline_fixed_string_t keyword;
2041 : : cmdline_fixed_string_t all;
2042 : : cmdline_fixed_string_t name;
2043 : : cmdline_fixed_string_t value;
2044 : : };
2045 : :
2046 : : static void
2047 : 0 : cmd_config_rss_parsed(void *parsed_result,
2048 : : __rte_unused struct cmdline *cl,
2049 : : __rte_unused void *data)
2050 : : {
2051 : : struct cmd_config_rss *res = parsed_result;
2052 : : struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
2053 : 0 : struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, };
2054 : : int use_default = 0;
2055 : : int all_updated = 1;
2056 : : int diag;
2057 : : uint16_t i;
2058 : : int ret;
2059 : :
2060 : 0 : if (!strcmp(res->value, "level-default")) {
2061 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2062 : : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_PMD_DEFAULT);
2063 : 0 : } else if (!strcmp(res->value, "level-outer")) {
2064 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2065 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_OUTERMOST);
2066 : 0 : } else if (!strcmp(res->value, "level-inner")) {
2067 : 0 : rss_hf &= (~RTE_ETH_RSS_LEVEL_MASK);
2068 : 0 : rss_conf.rss_hf = (rss_hf | RTE_ETH_RSS_LEVEL_INNERMOST);
2069 : 0 : } else if (!strcmp(res->value, "default")) {
2070 : : use_default = 1;
2071 : 0 : } else if (isdigit(res->value[0])) {
2072 : : int value = atoi(res->value);
2073 : 0 : if (value > 0 && value < 64)
2074 : 0 : rss_conf.rss_hf = 1ULL << (uint8_t)value;
2075 : : else {
2076 : 0 : fprintf(stderr, "flowtype_id should be greater than 0 and less than 64.\n");
2077 : 0 : return;
2078 : : }
2079 : 0 : } else if (!strcmp(res->value, "none")) {
2080 : : rss_conf.rss_hf = 0;
2081 : : } else {
2082 : 0 : rss_conf.rss_hf = str_to_rsstypes(res->value);
2083 : 0 : if (rss_conf.rss_hf == 0) {
2084 : 0 : fprintf(stderr, "Unknown parameter\n");
2085 : 0 : return;
2086 : : }
2087 : : }
2088 : : rss_conf.rss_key = NULL;
2089 : : /* Update global configuration for RSS types. */
2090 : 0 : RTE_ETH_FOREACH_DEV(i) {
2091 : : struct rte_eth_rss_conf local_rss_conf;
2092 : :
2093 : 0 : ret = eth_dev_info_get_print_err(i, &dev_info);
2094 : 0 : if (ret != 0)
2095 : 0 : return;
2096 : :
2097 : 0 : if (use_default)
2098 : 0 : rss_conf.rss_hf = dev_info.flow_type_rss_offloads;
2099 : :
2100 : 0 : local_rss_conf = rss_conf;
2101 : 0 : local_rss_conf.rss_hf = rss_conf.rss_hf &
2102 : 0 : dev_info.flow_type_rss_offloads;
2103 : 0 : if (local_rss_conf.rss_hf != rss_conf.rss_hf) {
2104 : : printf("Port %u modified RSS hash function based on hardware support,"
2105 : : "requested:%#"PRIx64" configured:%#"PRIx64"\n",
2106 : : i, rss_conf.rss_hf, local_rss_conf.rss_hf);
2107 : : }
2108 : 0 : diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf);
2109 : 0 : if (diag < 0) {
2110 : : all_updated = 0;
2111 : 0 : fprintf(stderr,
2112 : : "Configuration of RSS hash at ethernet port %d failed with error (%d): %s.\n",
2113 : : i, -diag, strerror(-diag));
2114 : : }
2115 : : }
2116 : 0 : if (all_updated && !use_default) {
2117 : 0 : rss_hf = rss_conf.rss_hf;
2118 : : printf("rss_hf %#"PRIx64"\n", rss_hf);
2119 : : }
2120 : : }
2121 : :
2122 : : static cmdline_parse_token_string_t cmd_config_rss_port =
2123 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port");
2124 : : static cmdline_parse_token_string_t cmd_config_rss_keyword =
2125 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config");
2126 : : static cmdline_parse_token_string_t cmd_config_rss_all =
2127 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all");
2128 : : static cmdline_parse_token_string_t cmd_config_rss_name =
2129 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss");
2130 : : static cmdline_parse_token_string_t cmd_config_rss_value =
2131 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL);
2132 : :
2133 : : static cmdline_parse_inst_t cmd_config_rss = {
2134 : : .f = cmd_config_rss_parsed,
2135 : : .data = NULL,
2136 : : .help_str = "port config all rss "
2137 : : "all|default|level-default|level-outer|level-inner|"
2138 : : "ip|tcp|udp|sctp|tunnel|vlan|none|"
2139 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2140 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2141 : : "l2-payload|port|vxlan|geneve|nvgre|gtpu|eth|s-vlan|c-vlan|"
2142 : : "esp|ah|l2tpv3|pfcp|pppoe|ecpri|mpls|ipv4-chksum|l4-chksum|"
2143 : : "l2tpv2|l3-pre96|l3-pre64|l3-pre56|l3-pre48|l3-pre40|l3-pre32|"
2144 : : "l2-dst-only|l2-src-only|l4-dst-only|l4-src-only|l3-dst-only|l3-src-only|<rsstype_id>",
2145 : : .tokens = {
2146 : : (void *)&cmd_config_rss_port,
2147 : : (void *)&cmd_config_rss_keyword,
2148 : : (void *)&cmd_config_rss_all,
2149 : : (void *)&cmd_config_rss_name,
2150 : : (void *)&cmd_config_rss_value,
2151 : : NULL,
2152 : : },
2153 : : };
2154 : :
2155 : : /* *** configure rss hash key *** */
2156 : : struct cmd_config_rss_hash_key {
2157 : : cmdline_fixed_string_t port;
2158 : : cmdline_fixed_string_t config;
2159 : : portid_t port_id;
2160 : : cmdline_fixed_string_t rss_hash_key;
2161 : : cmdline_fixed_string_t rss_type;
2162 : : cmdline_fixed_string_t key;
2163 : : };
2164 : :
2165 : : static uint8_t
2166 : : hexa_digit_to_value(char hexa_digit)
2167 : : {
2168 : 0 : if ((hexa_digit >= '0') && (hexa_digit <= '9'))
2169 : : return (uint8_t) (hexa_digit - '0');
2170 : 0 : if ((hexa_digit >= 'a') && (hexa_digit <= 'f'))
2171 : 0 : return (uint8_t) ((hexa_digit - 'a') + 10);
2172 : 0 : if ((hexa_digit >= 'A') && (hexa_digit <= 'F'))
2173 : 0 : return (uint8_t) ((hexa_digit - 'A') + 10);
2174 : : /* Invalid hexa digit */
2175 : : return 0xFF;
2176 : : }
2177 : :
2178 : : static uint8_t
2179 : 0 : parse_and_check_key_hexa_digit(char *key, int idx)
2180 : : {
2181 : : uint8_t hexa_v;
2182 : :
2183 : 0 : hexa_v = hexa_digit_to_value(key[idx]);
2184 : : if (hexa_v == 0xFF)
2185 : 0 : fprintf(stderr,
2186 : : "invalid key: character %c at position %d is not a valid hexa digit\n",
2187 : : key[idx], idx);
2188 : 0 : return hexa_v;
2189 : : }
2190 : :
2191 : : static void
2192 : 0 : cmd_config_rss_hash_key_parsed(void *parsed_result,
2193 : : __rte_unused struct cmdline *cl,
2194 : : __rte_unused void *data)
2195 : : {
2196 : : struct cmd_config_rss_hash_key *res = parsed_result;
2197 : : uint8_t hash_key[RSS_HASH_KEY_LENGTH];
2198 : : uint8_t xdgt0;
2199 : : uint8_t xdgt1;
2200 : : int i;
2201 : : struct rte_eth_dev_info dev_info;
2202 : : uint8_t hash_key_size;
2203 : : uint32_t key_len;
2204 : : int ret;
2205 : :
2206 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2207 : 0 : if (ret != 0)
2208 : 0 : return;
2209 : :
2210 : 0 : if (dev_info.hash_key_size > 0 &&
2211 : : dev_info.hash_key_size <= sizeof(hash_key))
2212 : : hash_key_size = dev_info.hash_key_size;
2213 : : else {
2214 : 0 : fprintf(stderr,
2215 : : "dev_info did not provide a valid hash key size\n");
2216 : 0 : return;
2217 : : }
2218 : : /* Check the length of the RSS hash key */
2219 : 0 : key_len = strlen(res->key);
2220 : 0 : if (key_len != (hash_key_size * 2)) {
2221 : 0 : fprintf(stderr,
2222 : : "key length: %d invalid - key must be a string of %d hexa-decimal numbers\n",
2223 : : (int)key_len, hash_key_size * 2);
2224 : 0 : return;
2225 : : }
2226 : : /* Translate RSS hash key into binary representation */
2227 : 0 : for (i = 0; i < hash_key_size; i++) {
2228 : 0 : xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2));
2229 : 0 : if (xdgt0 == 0xFF)
2230 : : return;
2231 : 0 : xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1);
2232 : 0 : if (xdgt1 == 0xFF)
2233 : : return;
2234 : 0 : hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1);
2235 : : }
2236 : 0 : port_rss_hash_key_update(res->port_id, res->rss_type, hash_key,
2237 : : hash_key_size);
2238 : : }
2239 : :
2240 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_port =
2241 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port");
2242 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_config =
2243 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config,
2244 : : "config");
2245 : : static cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id =
2246 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id,
2247 : : RTE_UINT16);
2248 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key =
2249 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key,
2250 : : rss_hash_key, "rss-hash-key");
2251 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type =
2252 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type,
2253 : : "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#"
2254 : : "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#"
2255 : : "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#"
2256 : : "ipv6-tcp-ex#ipv6-udp-ex#ipv6-flow-label#"
2257 : : "l3-src-only#l3-dst-only#l4-src-only#l4-dst-only#"
2258 : : "l2-src-only#l2-dst-only#s-vlan#c-vlan#"
2259 : : "l2tpv3#esp#ah#pfcp#pppoe#gtpu#ecpri#mpls#l2tpv2");
2260 : : static cmdline_parse_token_string_t cmd_config_rss_hash_key_value =
2261 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL);
2262 : :
2263 : : static cmdline_parse_inst_t cmd_config_rss_hash_key = {
2264 : : .f = cmd_config_rss_hash_key_parsed,
2265 : : .data = NULL,
2266 : : .help_str = "port config <port_id> rss-hash-key "
2267 : : "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|"
2268 : : "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
2269 : : "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex|ipv6-flow-label|"
2270 : : "l3-src-only|l3-dst-only|l4-src-only|l4-dst-only|"
2271 : : "l2-src-only|l2-dst-only|s-vlan|c-vlan|"
2272 : : "l2tpv3|esp|ah|pfcp|pppoe|gtpu|ecpri|mpls|l2tpv2 "
2273 : : "<string of hex digits (variable length, NIC dependent)>",
2274 : : .tokens = {
2275 : : (void *)&cmd_config_rss_hash_key_port,
2276 : : (void *)&cmd_config_rss_hash_key_config,
2277 : : (void *)&cmd_config_rss_hash_key_port_id,
2278 : : (void *)&cmd_config_rss_hash_key_rss_hash_key,
2279 : : (void *)&cmd_config_rss_hash_key_rss_type,
2280 : : (void *)&cmd_config_rss_hash_key_value,
2281 : : NULL,
2282 : : },
2283 : : };
2284 : :
2285 : : /* *** configure rss hash algorithm *** */
2286 : : struct cmd_config_rss_hash_algo {
2287 : : cmdline_fixed_string_t port;
2288 : : cmdline_fixed_string_t config;
2289 : : portid_t port_id;
2290 : : cmdline_fixed_string_t rss_hash_algo;
2291 : : cmdline_fixed_string_t algo;
2292 : : };
2293 : :
2294 : : static void
2295 : 0 : cmd_config_rss_hash_algo_parsed(void *parsed_result,
2296 : : __rte_unused struct cmdline *cl,
2297 : : __rte_unused void *data)
2298 : : {
2299 : : struct cmd_config_rss_hash_algo *res = parsed_result;
2300 : : uint8_t rss_key[RSS_HASH_KEY_LENGTH];
2301 : : struct rte_eth_rss_conf rss_conf;
2302 : : uint32_t algorithm;
2303 : : int ret;
2304 : :
2305 : 0 : rss_conf.rss_key_len = RSS_HASH_KEY_LENGTH;
2306 : 0 : rss_conf.rss_key = rss_key;
2307 : 0 : ret = rte_eth_dev_rss_hash_conf_get(res->port_id, &rss_conf);
2308 : 0 : if (ret != 0) {
2309 : 0 : fprintf(stderr, "failed to get port %u RSS configuration\n",
2310 : 0 : res->port_id);
2311 : 0 : return;
2312 : : }
2313 : :
2314 : 0 : algorithm = (uint32_t)rss_conf.algorithm;
2315 : 0 : ret = rte_eth_find_rss_algo(res->algo, &algorithm);
2316 : 0 : if (ret != 0) {
2317 : 0 : fprintf(stderr, "port %u configured invalid RSS hash algorithm: %s\n",
2318 : 0 : res->port_id, res->algo);
2319 : 0 : return;
2320 : : }
2321 : :
2322 : 0 : rss_conf.algorithm = algorithm;
2323 : 0 : ret = rte_eth_dev_rss_hash_update(res->port_id, &rss_conf);
2324 : 0 : if (ret != 0) {
2325 : 0 : fprintf(stderr, "failed to set port %u RSS hash algorithm\n",
2326 : 0 : res->port_id);
2327 : 0 : return;
2328 : : }
2329 : : }
2330 : :
2331 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_port =
2332 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, port, "port");
2333 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_config =
2334 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, config,
2335 : : "config");
2336 : : static cmdline_parse_token_num_t cmd_config_rss_hash_algo_port_id =
2337 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_algo, port_id,
2338 : : RTE_UINT16);
2339 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_rss_hash_algo =
2340 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo,
2341 : : rss_hash_algo, "rss-hash-algo");
2342 : : static cmdline_parse_token_string_t cmd_config_rss_hash_algo_algo =
2343 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_algo, algo,
2344 : : "default#simple_xor#toeplitz#"
2345 : : "symmetric_toeplitz#symmetric_toeplitz_sort");
2346 : :
2347 : : static cmdline_parse_inst_t cmd_config_rss_hash_algo = {
2348 : : .f = cmd_config_rss_hash_algo_parsed,
2349 : : .data = NULL,
2350 : : .help_str = "port config <port_id> rss-hash-algo "
2351 : : "default|simple_xor|toeplitz|symmetric_toeplitz|symmetric_toeplitz_sort",
2352 : : .tokens = {
2353 : : (void *)&cmd_config_rss_hash_algo_port,
2354 : : (void *)&cmd_config_rss_hash_algo_config,
2355 : : (void *)&cmd_config_rss_hash_algo_port_id,
2356 : : (void *)&cmd_config_rss_hash_algo_rss_hash_algo,
2357 : : (void *)&cmd_config_rss_hash_algo_algo,
2358 : : NULL,
2359 : : },
2360 : : };
2361 : :
2362 : : /* *** cleanup txq mbufs *** */
2363 : : struct cmd_cleanup_txq_mbufs_result {
2364 : : cmdline_fixed_string_t port;
2365 : : cmdline_fixed_string_t keyword;
2366 : : cmdline_fixed_string_t name;
2367 : : uint16_t port_id;
2368 : : uint16_t queue_id;
2369 : : uint32_t free_cnt;
2370 : : };
2371 : :
2372 : : static void
2373 : 0 : cmd_cleanup_txq_mbufs_parsed(void *parsed_result,
2374 : : __rte_unused struct cmdline *cl,
2375 : : __rte_unused void *data)
2376 : : {
2377 : : struct cmd_cleanup_txq_mbufs_result *res = parsed_result;
2378 : 0 : uint16_t port_id = res->port_id;
2379 : 0 : uint16_t queue_id = res->queue_id;
2380 : 0 : uint32_t free_cnt = res->free_cnt;
2381 : : struct rte_eth_txq_info qinfo;
2382 : : int ret;
2383 : :
2384 : 0 : if (test_done == 0) {
2385 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2386 : 0 : return;
2387 : : }
2388 : :
2389 : 0 : if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) {
2390 : 0 : fprintf(stderr, "Failed to get port %u Tx queue %u info\n",
2391 : : port_id, queue_id);
2392 : 0 : return;
2393 : : }
2394 : :
2395 : 0 : if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) {
2396 : 0 : fprintf(stderr, "Tx queue %u not started\n", queue_id);
2397 : 0 : return;
2398 : : }
2399 : :
2400 : 0 : ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt);
2401 : 0 : if (ret < 0) {
2402 : 0 : fprintf(stderr,
2403 : : "Failed to cleanup mbuf for port %u Tx queue %u error desc: %s(%d)\n",
2404 : : port_id, queue_id, strerror(-ret), ret);
2405 : 0 : return;
2406 : : }
2407 : :
2408 : : printf("Cleanup port %u Tx queue %u mbuf nums: %u\n",
2409 : : port_id, queue_id, ret);
2410 : : }
2411 : :
2412 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port =
2413 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port,
2414 : : "port");
2415 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup =
2416 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword,
2417 : : "cleanup");
2418 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id =
2419 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id,
2420 : : RTE_UINT16);
2421 : : static cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq =
2422 : : TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name,
2423 : : "txq");
2424 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id =
2425 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id,
2426 : : RTE_UINT16);
2427 : : static cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt =
2428 : : TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt,
2429 : : RTE_UINT32);
2430 : :
2431 : : static cmdline_parse_inst_t cmd_cleanup_txq_mbufs = {
2432 : : .f = cmd_cleanup_txq_mbufs_parsed,
2433 : : .data = NULL,
2434 : : .help_str = "port cleanup <port_id> txq <queue_id> <free_cnt>",
2435 : : .tokens = {
2436 : : (void *)&cmd_cleanup_txq_mbufs_port,
2437 : : (void *)&cmd_cleanup_txq_mbufs_cleanup,
2438 : : (void *)&cmd_cleanup_txq_mbufs_port_id,
2439 : : (void *)&cmd_cleanup_txq_mbufs_txq,
2440 : : (void *)&cmd_cleanup_txq_mbufs_queue_id,
2441 : : (void *)&cmd_cleanup_txq_mbufs_free_cnt,
2442 : : NULL,
2443 : : },
2444 : : };
2445 : :
2446 : : /* *** configure port rxq/txq ring size *** */
2447 : : struct cmd_config_rxtx_ring_size {
2448 : : cmdline_fixed_string_t port;
2449 : : cmdline_fixed_string_t config;
2450 : : portid_t portid;
2451 : : cmdline_fixed_string_t rxtxq;
2452 : : uint16_t qid;
2453 : : cmdline_fixed_string_t rsize;
2454 : : uint16_t size;
2455 : : };
2456 : :
2457 : : static void
2458 : 0 : cmd_config_rxtx_ring_size_parsed(void *parsed_result,
2459 : : __rte_unused struct cmdline *cl,
2460 : : __rte_unused void *data)
2461 : : {
2462 : : struct cmd_config_rxtx_ring_size *res = parsed_result;
2463 : : struct rte_port *port;
2464 : : uint8_t isrx;
2465 : :
2466 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2467 : : return;
2468 : :
2469 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2470 : 0 : fprintf(stderr, "Invalid port id\n");
2471 : 0 : return;
2472 : : }
2473 : :
2474 : 0 : port = &ports[res->portid];
2475 : :
2476 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2477 : : isrx = 1;
2478 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2479 : : isrx = 0;
2480 : : else {
2481 : 0 : fprintf(stderr, "Unknown parameter\n");
2482 : 0 : return;
2483 : : }
2484 : :
2485 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2486 : : return;
2487 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2488 : : return;
2489 : :
2490 : 0 : if (isrx && res->size != 0 && res->size <= rx_free_thresh) {
2491 : 0 : fprintf(stderr,
2492 : : "Invalid rx ring_size, must > rx_free_thresh: %d\n",
2493 : : rx_free_thresh);
2494 : 0 : return;
2495 : : }
2496 : :
2497 : 0 : if (isrx)
2498 : 0 : port->nb_rx_desc[res->qid] = res->size;
2499 : : else
2500 : 0 : port->nb_tx_desc[res->qid] = res->size;
2501 : :
2502 : 0 : cmd_reconfig_device_queue(res->portid, 0, 1);
2503 : : }
2504 : :
2505 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port =
2506 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2507 : : port, "port");
2508 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config =
2509 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2510 : : config, "config");
2511 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid =
2512 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2513 : : portid, RTE_UINT16);
2514 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq =
2515 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2516 : : rxtxq, "rxq#txq");
2517 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid =
2518 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2519 : : qid, RTE_UINT16);
2520 : : static cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize =
2521 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size,
2522 : : rsize, "ring_size");
2523 : : static cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size =
2524 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size,
2525 : : size, RTE_UINT16);
2526 : :
2527 : : static cmdline_parse_inst_t cmd_config_rxtx_ring_size = {
2528 : : .f = cmd_config_rxtx_ring_size_parsed,
2529 : : .data = NULL,
2530 : : .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>",
2531 : : .tokens = {
2532 : : (void *)&cmd_config_rxtx_ring_size_port,
2533 : : (void *)&cmd_config_rxtx_ring_size_config,
2534 : : (void *)&cmd_config_rxtx_ring_size_portid,
2535 : : (void *)&cmd_config_rxtx_ring_size_rxtxq,
2536 : : (void *)&cmd_config_rxtx_ring_size_qid,
2537 : : (void *)&cmd_config_rxtx_ring_size_rsize,
2538 : : (void *)&cmd_config_rxtx_ring_size_size,
2539 : : NULL,
2540 : : },
2541 : : };
2542 : :
2543 : : /* *** configure port rxq/txq start/stop *** */
2544 : : struct cmd_config_rxtx_queue {
2545 : : cmdline_fixed_string_t port;
2546 : : portid_t portid;
2547 : : cmdline_fixed_string_t rxtxq;
2548 : : uint16_t qid;
2549 : : cmdline_fixed_string_t opname;
2550 : : };
2551 : :
2552 : : static void
2553 : 0 : cmd_config_rxtx_queue_parsed(void *parsed_result,
2554 : : __rte_unused struct cmdline *cl,
2555 : : __rte_unused void *data)
2556 : : {
2557 : : struct cmd_config_rxtx_queue *res = parsed_result;
2558 : : struct rte_port *port;
2559 : : uint8_t isrx;
2560 : : uint8_t isstart;
2561 : : uint8_t *state;
2562 : : int ret = 0;
2563 : :
2564 : 0 : if (test_done == 0) {
2565 : 0 : fprintf(stderr, "Please stop forwarding first\n");
2566 : 0 : return;
2567 : : }
2568 : :
2569 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2570 : : return;
2571 : :
2572 : 0 : if (port_is_started(res->portid) != 1) {
2573 : 0 : fprintf(stderr, "Please start port %u first\n", res->portid);
2574 : 0 : return;
2575 : : }
2576 : :
2577 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2578 : : isrx = 1;
2579 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2580 : : isrx = 0;
2581 : : else {
2582 : 0 : fprintf(stderr, "Unknown parameter\n");
2583 : 0 : return;
2584 : : }
2585 : :
2586 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2587 : : return;
2588 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2589 : : return;
2590 : :
2591 : 0 : if (!strcmp(res->opname, "start"))
2592 : : isstart = 1;
2593 : 0 : else if (!strcmp(res->opname, "stop"))
2594 : : isstart = 0;
2595 : : else {
2596 : 0 : fprintf(stderr, "Unknown parameter\n");
2597 : 0 : return;
2598 : : }
2599 : :
2600 : 0 : if (isstart && isrx)
2601 : 0 : ret = rte_eth_dev_rx_queue_start(res->portid, res->qid);
2602 : 0 : else if (!isstart && isrx)
2603 : 0 : ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid);
2604 : 0 : else if (isstart && !isrx)
2605 : 0 : ret = rte_eth_dev_tx_queue_start(res->portid, res->qid);
2606 : : else
2607 : 0 : ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid);
2608 : :
2609 : 0 : if (ret == -ENOTSUP) {
2610 : 0 : fprintf(stderr, "Function not supported in PMD\n");
2611 : 0 : return;
2612 : : }
2613 : :
2614 : 0 : port = &ports[res->portid];
2615 : 0 : state = isrx ? &port->rxq[res->qid].state : &port->txq[res->qid].state;
2616 : 0 : *state = isstart ? RTE_ETH_QUEUE_STATE_STARTED :
2617 : : RTE_ETH_QUEUE_STATE_STOPPED;
2618 : : }
2619 : :
2620 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_port =
2621 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port");
2622 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_portid =
2623 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, RTE_UINT16);
2624 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq =
2625 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq");
2626 : : static cmdline_parse_token_num_t cmd_config_rxtx_queue_qid =
2627 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, RTE_UINT16);
2628 : : static cmdline_parse_token_string_t cmd_config_rxtx_queue_opname =
2629 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname,
2630 : : "start#stop");
2631 : :
2632 : : static cmdline_parse_inst_t cmd_config_rxtx_queue = {
2633 : : .f = cmd_config_rxtx_queue_parsed,
2634 : : .data = NULL,
2635 : : .help_str = "port <port_id> rxq|txq <queue_id> start|stop",
2636 : : .tokens = {
2637 : : (void *)&cmd_config_rxtx_queue_port,
2638 : : (void *)&cmd_config_rxtx_queue_portid,
2639 : : (void *)&cmd_config_rxtx_queue_rxtxq,
2640 : : (void *)&cmd_config_rxtx_queue_qid,
2641 : : (void *)&cmd_config_rxtx_queue_opname,
2642 : : NULL,
2643 : : },
2644 : : };
2645 : :
2646 : : /* *** configure port rxq/txq deferred start on/off *** */
2647 : : struct cmd_config_deferred_start_rxtx_queue {
2648 : : cmdline_fixed_string_t port;
2649 : : portid_t port_id;
2650 : : cmdline_fixed_string_t rxtxq;
2651 : : uint16_t qid;
2652 : : cmdline_fixed_string_t opname;
2653 : : cmdline_fixed_string_t state;
2654 : : };
2655 : :
2656 : : static void
2657 : 0 : cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result,
2658 : : __rte_unused struct cmdline *cl,
2659 : : __rte_unused void *data)
2660 : : {
2661 : : struct cmd_config_deferred_start_rxtx_queue *res = parsed_result;
2662 : : struct rte_port *port;
2663 : : uint8_t isrx;
2664 : : uint8_t ison;
2665 : : uint8_t needreconfig = 0;
2666 : :
2667 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
2668 : : return;
2669 : :
2670 : 0 : if (port_is_started(res->port_id) != 0) {
2671 : 0 : fprintf(stderr, "Please stop port %u first\n", res->port_id);
2672 : 0 : return;
2673 : : }
2674 : :
2675 : 0 : port = &ports[res->port_id];
2676 : :
2677 : 0 : isrx = !strcmp(res->rxtxq, "rxq");
2678 : :
2679 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid))
2680 : : return;
2681 : 0 : else if (!isrx && tx_queue_id_is_invalid(res->qid))
2682 : : return;
2683 : :
2684 : 0 : ison = !strcmp(res->state, "on");
2685 : :
2686 : 0 : if (isrx && port->rxq[res->qid].conf.rx_deferred_start != ison) {
2687 : 0 : port->rxq[res->qid].conf.rx_deferred_start = ison;
2688 : : needreconfig = 1;
2689 : 0 : } else if (!isrx && port->txq[res->qid].conf.tx_deferred_start != ison) {
2690 : 0 : port->txq[res->qid].conf.tx_deferred_start = ison;
2691 : : needreconfig = 1;
2692 : : }
2693 : :
2694 : : if (needreconfig)
2695 : 0 : cmd_reconfig_device_queue(res->port_id, 0, 1);
2696 : : }
2697 : :
2698 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port =
2699 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2700 : : port, "port");
2701 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id =
2702 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2703 : : port_id, RTE_UINT16);
2704 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq =
2705 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2706 : : rxtxq, "rxq#txq");
2707 : : static cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid =
2708 : : TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2709 : : qid, RTE_UINT16);
2710 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname =
2711 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2712 : : opname, "deferred_start");
2713 : : static cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state =
2714 : : TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue,
2715 : : state, "on#off");
2716 : :
2717 : : static cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = {
2718 : : .f = cmd_config_deferred_start_rxtx_queue_parsed,
2719 : : .data = NULL,
2720 : : .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off",
2721 : : .tokens = {
2722 : : (void *)&cmd_config_deferred_start_rxtx_queue_port,
2723 : : (void *)&cmd_config_deferred_start_rxtx_queue_port_id,
2724 : : (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq,
2725 : : (void *)&cmd_config_deferred_start_rxtx_queue_qid,
2726 : : (void *)&cmd_config_deferred_start_rxtx_queue_opname,
2727 : : (void *)&cmd_config_deferred_start_rxtx_queue_state,
2728 : : NULL,
2729 : : },
2730 : : };
2731 : :
2732 : : /* *** configure port rxq/txq setup *** */
2733 : : struct cmd_setup_rxtx_queue {
2734 : : cmdline_fixed_string_t port;
2735 : : portid_t portid;
2736 : : cmdline_fixed_string_t rxtxq;
2737 : : uint16_t qid;
2738 : : cmdline_fixed_string_t setup;
2739 : : };
2740 : :
2741 : : /* Common CLI fields for queue setup */
2742 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_port =
2743 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port");
2744 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid =
2745 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, RTE_UINT16);
2746 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq =
2747 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq");
2748 : : static cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid =
2749 : : TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, RTE_UINT16);
2750 : : static cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup =
2751 : : TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup");
2752 : :
2753 : : static void
2754 : 0 : cmd_setup_rxtx_queue_parsed(
2755 : : void *parsed_result,
2756 : : __rte_unused struct cmdline *cl,
2757 : : __rte_unused void *data)
2758 : : {
2759 : : struct cmd_setup_rxtx_queue *res = parsed_result;
2760 : : struct rte_port *port;
2761 : : struct rte_mempool *mp;
2762 : : unsigned int socket_id;
2763 : : uint8_t isrx = 0;
2764 : : int ret;
2765 : :
2766 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
2767 : : return;
2768 : :
2769 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
2770 : 0 : fprintf(stderr, "Invalid port id\n");
2771 : 0 : return;
2772 : : }
2773 : :
2774 : 0 : if (!strcmp(res->rxtxq, "rxq"))
2775 : : isrx = 1;
2776 : 0 : else if (!strcmp(res->rxtxq, "txq"))
2777 : : isrx = 0;
2778 : : else {
2779 : 0 : fprintf(stderr, "Unknown parameter\n");
2780 : 0 : return;
2781 : : }
2782 : :
2783 : 0 : if (isrx && rx_queue_id_is_invalid(res->qid)) {
2784 : 0 : fprintf(stderr, "Invalid rx queue\n");
2785 : 0 : return;
2786 : 0 : } else if (!isrx && tx_queue_id_is_invalid(res->qid)) {
2787 : 0 : fprintf(stderr, "Invalid tx queue\n");
2788 : 0 : return;
2789 : : }
2790 : :
2791 : 0 : port = &ports[res->portid];
2792 : 0 : if (isrx) {
2793 : 0 : socket_id = rxring_numa[res->portid];
2794 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
2795 : 0 : socket_id = port->socket_id;
2796 : :
2797 : : mp = mbuf_pool_find(socket_id, 0);
2798 : 0 : if (mp == NULL) {
2799 : 0 : fprintf(stderr,
2800 : : "Failed to setup RX queue: No mempool allocation on the socket %d\n",
2801 : 0 : rxring_numa[res->portid]);
2802 : 0 : return;
2803 : : }
2804 : 0 : ret = rx_queue_setup(res->portid,
2805 : : res->qid,
2806 : 0 : port->nb_rx_desc[res->qid],
2807 : : socket_id,
2808 : 0 : &port->rxq[res->qid].conf,
2809 : : mp);
2810 : 0 : if (ret)
2811 : 0 : fprintf(stderr, "Failed to setup RX queue\n");
2812 : : } else {
2813 : 0 : socket_id = txring_numa[res->portid];
2814 : 0 : if (!numa_support || socket_id == NUMA_NO_CONFIG)
2815 : 0 : socket_id = port->socket_id;
2816 : :
2817 : 0 : if (port->nb_tx_desc[res->qid] < tx_pkt_nb_segs) {
2818 : 0 : fprintf(stderr,
2819 : : "Failed to setup TX queue: not enough descriptors\n");
2820 : 0 : return;
2821 : : }
2822 : 0 : ret = rte_eth_tx_queue_setup(res->portid,
2823 : : res->qid,
2824 : : port->nb_tx_desc[res->qid],
2825 : : socket_id,
2826 : 0 : &port->txq[res->qid].conf);
2827 : 0 : if (ret)
2828 : 0 : fprintf(stderr, "Failed to setup TX queue\n");
2829 : : }
2830 : : }
2831 : :
2832 : : static cmdline_parse_inst_t cmd_setup_rxtx_queue = {
2833 : : .f = cmd_setup_rxtx_queue_parsed,
2834 : : .data = NULL,
2835 : : .help_str = "port <port_id> rxq|txq <queue_idx> setup",
2836 : : .tokens = {
2837 : : (void *)&cmd_setup_rxtx_queue_port,
2838 : : (void *)&cmd_setup_rxtx_queue_portid,
2839 : : (void *)&cmd_setup_rxtx_queue_rxtxq,
2840 : : (void *)&cmd_setup_rxtx_queue_qid,
2841 : : (void *)&cmd_setup_rxtx_queue_setup,
2842 : : NULL,
2843 : : },
2844 : : };
2845 : :
2846 : :
2847 : : /* *** Configure RSS RETA *** */
2848 : : struct cmd_config_rss_reta {
2849 : : cmdline_fixed_string_t port;
2850 : : cmdline_fixed_string_t keyword;
2851 : : portid_t port_id;
2852 : : cmdline_fixed_string_t name;
2853 : : cmdline_fixed_string_t list_name;
2854 : : cmdline_fixed_string_t list_of_items;
2855 : : };
2856 : :
2857 : : static int
2858 : 0 : parse_reta_config(const char *str,
2859 : : struct rte_eth_rss_reta_entry64 *reta_conf,
2860 : : uint16_t nb_entries)
2861 : : {
2862 : : int i;
2863 : : unsigned size;
2864 : : uint16_t hash_index, idx, shift;
2865 : : uint16_t nb_queue;
2866 : : char s[256];
2867 : : const char *p, *p0 = str;
2868 : : char *end;
2869 : : enum fieldnames {
2870 : : FLD_HASH_INDEX = 0,
2871 : : FLD_QUEUE,
2872 : : _NUM_FLD
2873 : : };
2874 : : unsigned long int_fld[_NUM_FLD];
2875 : : char *str_fld[_NUM_FLD];
2876 : :
2877 : 0 : while ((p = strchr(p0,'(')) != NULL) {
2878 : 0 : ++p;
2879 : 0 : if((p0 = strchr(p,')')) == NULL)
2880 : : return -1;
2881 : :
2882 : 0 : size = p0 - p;
2883 : 0 : if(size >= sizeof(s))
2884 : : return -1;
2885 : :
2886 : : snprintf(s, sizeof(s), "%.*s", size, p);
2887 : 0 : if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD)
2888 : : return -1;
2889 : 0 : for (i = 0; i < _NUM_FLD; i++) {
2890 : 0 : errno = 0;
2891 : 0 : int_fld[i] = strtoul(str_fld[i], &end, 0);
2892 : 0 : if (errno != 0 || end == str_fld[i] ||
2893 : : int_fld[i] > 65535)
2894 : : return -1;
2895 : : }
2896 : :
2897 : 0 : hash_index = (uint16_t)int_fld[FLD_HASH_INDEX];
2898 : 0 : nb_queue = (uint16_t)int_fld[FLD_QUEUE];
2899 : :
2900 : 0 : if (hash_index >= nb_entries) {
2901 : 0 : fprintf(stderr, "Invalid RETA hash index=%d\n",
2902 : : hash_index);
2903 : 0 : return -1;
2904 : : }
2905 : :
2906 : 0 : idx = hash_index / RTE_ETH_RETA_GROUP_SIZE;
2907 : 0 : shift = hash_index % RTE_ETH_RETA_GROUP_SIZE;
2908 : 0 : reta_conf[idx].mask |= (1ULL << shift);
2909 : 0 : reta_conf[idx].reta[shift] = nb_queue;
2910 : : }
2911 : :
2912 : : return 0;
2913 : : }
2914 : :
2915 : : static void
2916 : 0 : cmd_set_rss_reta_parsed(void *parsed_result,
2917 : : __rte_unused struct cmdline *cl,
2918 : : __rte_unused void *data)
2919 : : {
2920 : : int ret;
2921 : : struct rte_eth_dev_info dev_info;
2922 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
2923 : : struct cmd_config_rss_reta *res = parsed_result;
2924 : :
2925 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
2926 : 0 : if (ret != 0)
2927 : 0 : return;
2928 : :
2929 : 0 : if (dev_info.reta_size == 0) {
2930 : 0 : fprintf(stderr,
2931 : : "Redirection table size is 0 which is invalid for RSS\n");
2932 : 0 : return;
2933 : : } else
2934 : 0 : printf("The reta size of port %d is %u\n",
2935 : 0 : res->port_id, dev_info.reta_size);
2936 : 0 : if (dev_info.reta_size > RTE_ETH_RSS_RETA_SIZE_512) {
2937 : 0 : fprintf(stderr,
2938 : : "Currently do not support more than %u entries of redirection table\n",
2939 : : RTE_ETH_RSS_RETA_SIZE_512);
2940 : 0 : return;
2941 : : }
2942 : :
2943 : : memset(reta_conf, 0, sizeof(reta_conf));
2944 : 0 : if (!strcmp(res->list_name, "reta")) {
2945 : 0 : if (parse_reta_config(res->list_of_items, reta_conf,
2946 : : dev_info.reta_size)) {
2947 : 0 : fprintf(stderr,
2948 : : "Invalid RSS Redirection Table config entered\n");
2949 : 0 : return;
2950 : : }
2951 : 0 : ret = rte_eth_dev_rss_reta_update(res->port_id,
2952 : 0 : reta_conf, dev_info.reta_size);
2953 : 0 : if (ret != 0)
2954 : 0 : fprintf(stderr,
2955 : : "Bad redirection table parameter, return code = %d\n",
2956 : : ret);
2957 : : }
2958 : : }
2959 : :
2960 : : static cmdline_parse_token_string_t cmd_config_rss_reta_port =
2961 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port");
2962 : : static cmdline_parse_token_string_t cmd_config_rss_reta_keyword =
2963 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config");
2964 : : static cmdline_parse_token_num_t cmd_config_rss_reta_port_id =
2965 : : TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, RTE_UINT16);
2966 : : static cmdline_parse_token_string_t cmd_config_rss_reta_name =
2967 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss");
2968 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_name =
2969 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta");
2970 : : static cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items =
2971 : : TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items,
2972 : : NULL);
2973 : : static cmdline_parse_inst_t cmd_config_rss_reta = {
2974 : : .f = cmd_set_rss_reta_parsed,
2975 : : .data = NULL,
2976 : : .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>",
2977 : : .tokens = {
2978 : : (void *)&cmd_config_rss_reta_port,
2979 : : (void *)&cmd_config_rss_reta_keyword,
2980 : : (void *)&cmd_config_rss_reta_port_id,
2981 : : (void *)&cmd_config_rss_reta_name,
2982 : : (void *)&cmd_config_rss_reta_list_name,
2983 : : (void *)&cmd_config_rss_reta_list_of_items,
2984 : : NULL,
2985 : : },
2986 : : };
2987 : :
2988 : : /* *** SHOW PORT RETA INFO *** */
2989 : : struct cmd_showport_reta {
2990 : : cmdline_fixed_string_t show;
2991 : : cmdline_fixed_string_t port;
2992 : : portid_t port_id;
2993 : : cmdline_fixed_string_t rss;
2994 : : cmdline_fixed_string_t reta;
2995 : : uint16_t size;
2996 : : cmdline_fixed_string_t list_of_items;
2997 : : };
2998 : :
2999 : : static int
3000 : 0 : showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf,
3001 : : uint16_t nb_entries,
3002 : : char *str)
3003 : : {
3004 : : uint32_t size;
3005 : : const char *p, *p0 = str;
3006 : : char s[256];
3007 : : char *end;
3008 : : char *str_fld[8];
3009 : : uint16_t i;
3010 : 0 : uint16_t num = (nb_entries + RTE_ETH_RETA_GROUP_SIZE - 1) /
3011 : : RTE_ETH_RETA_GROUP_SIZE;
3012 : : int ret;
3013 : :
3014 : 0 : p = strchr(p0, '(');
3015 : 0 : if (p == NULL)
3016 : : return -1;
3017 : 0 : p++;
3018 : 0 : p0 = strchr(p, ')');
3019 : 0 : if (p0 == NULL)
3020 : : return -1;
3021 : 0 : size = p0 - p;
3022 : 0 : if (size >= sizeof(s)) {
3023 : 0 : fprintf(stderr,
3024 : : "The string size exceeds the internal buffer size\n");
3025 : 0 : return -1;
3026 : : }
3027 : : snprintf(s, sizeof(s), "%.*s", size, p);
3028 : 0 : ret = rte_strsplit(s, sizeof(s), str_fld, num, ',');
3029 : 0 : if (ret <= 0 || ret != num) {
3030 : 0 : fprintf(stderr,
3031 : : "The bits of masks do not match the number of reta entries: %u\n",
3032 : : num);
3033 : 0 : return -1;
3034 : : }
3035 : 0 : for (i = 0; i < ret; i++)
3036 : 0 : conf[i].mask = (uint64_t)strtoull(str_fld[i], &end, 0);
3037 : :
3038 : : return 0;
3039 : : }
3040 : :
3041 : : static void
3042 : 0 : cmd_showport_reta_parsed(void *parsed_result,
3043 : : __rte_unused struct cmdline *cl,
3044 : : __rte_unused void *data)
3045 : : {
3046 : : struct cmd_showport_reta *res = parsed_result;
3047 : : struct rte_eth_rss_reta_entry64 reta_conf[8];
3048 : : struct rte_eth_dev_info dev_info;
3049 : : uint16_t max_reta_size;
3050 : : int ret;
3051 : :
3052 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
3053 : 0 : if (ret != 0)
3054 : 0 : return;
3055 : :
3056 : 0 : max_reta_size = RTE_MIN(dev_info.reta_size, RTE_ETH_RSS_RETA_SIZE_512);
3057 : 0 : if (res->size == 0 || res->size > max_reta_size) {
3058 : 0 : fprintf(stderr, "Invalid redirection table size: %u (1-%u)\n",
3059 : : res->size, max_reta_size);
3060 : 0 : return;
3061 : : }
3062 : :
3063 : : memset(reta_conf, 0, sizeof(reta_conf));
3064 : 0 : if (showport_parse_reta_config(reta_conf, res->size,
3065 : 0 : res->list_of_items) < 0) {
3066 : 0 : fprintf(stderr, "Invalid string: %s for reta masks\n",
3067 : : res->list_of_items);
3068 : 0 : return;
3069 : : }
3070 : 0 : port_rss_reta_info(res->port_id, reta_conf, res->size);
3071 : : }
3072 : :
3073 : : static cmdline_parse_token_string_t cmd_showport_reta_show =
3074 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show");
3075 : : static cmdline_parse_token_string_t cmd_showport_reta_port =
3076 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port");
3077 : : static cmdline_parse_token_num_t cmd_showport_reta_port_id =
3078 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, RTE_UINT16);
3079 : : static cmdline_parse_token_string_t cmd_showport_reta_rss =
3080 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss");
3081 : : static cmdline_parse_token_string_t cmd_showport_reta_reta =
3082 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta");
3083 : : static cmdline_parse_token_num_t cmd_showport_reta_size =
3084 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, RTE_UINT16);
3085 : : static cmdline_parse_token_string_t cmd_showport_reta_list_of_items =
3086 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_reta,
3087 : : list_of_items, NULL);
3088 : :
3089 : : static cmdline_parse_inst_t cmd_showport_reta = {
3090 : : .f = cmd_showport_reta_parsed,
3091 : : .data = NULL,
3092 : : .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>",
3093 : : .tokens = {
3094 : : (void *)&cmd_showport_reta_show,
3095 : : (void *)&cmd_showport_reta_port,
3096 : : (void *)&cmd_showport_reta_port_id,
3097 : : (void *)&cmd_showport_reta_rss,
3098 : : (void *)&cmd_showport_reta_reta,
3099 : : (void *)&cmd_showport_reta_size,
3100 : : (void *)&cmd_showport_reta_list_of_items,
3101 : : NULL,
3102 : : },
3103 : : };
3104 : :
3105 : : /* *** Show RSS hash configuration *** */
3106 : : struct cmd_showport_rss_hash {
3107 : : cmdline_fixed_string_t show;
3108 : : cmdline_fixed_string_t port;
3109 : : portid_t port_id;
3110 : : cmdline_fixed_string_t rss_hash;
3111 : : cmdline_fixed_string_t rss_type;
3112 : : cmdline_fixed_string_t key; /* optional argument */
3113 : : cmdline_fixed_string_t algorithm; /* optional argument */
3114 : : };
3115 : :
3116 : 0 : static void cmd_showport_rss_hash_parsed(void *parsed_result,
3117 : : __rte_unused struct cmdline *cl,
3118 : : __rte_unused void *data)
3119 : : {
3120 : : struct cmd_showport_rss_hash *res = parsed_result;
3121 : :
3122 : 0 : port_rss_hash_conf_show(res->port_id,
3123 : 0 : !strcmp(res->key, "key"), !strcmp(res->algorithm, "algorithm"));
3124 : 0 : }
3125 : :
3126 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_show =
3127 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show");
3128 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_port =
3129 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port");
3130 : : static cmdline_parse_token_num_t cmd_showport_rss_hash_port_id =
3131 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id,
3132 : : RTE_UINT16);
3133 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash =
3134 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash,
3135 : : "rss-hash");
3136 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key =
3137 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key");
3138 : : static cmdline_parse_token_string_t cmd_showport_rss_hash_rss_algo =
3139 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, algorithm, "algorithm");
3140 : :
3141 : : static cmdline_parse_inst_t cmd_showport_rss_hash = {
3142 : : .f = cmd_showport_rss_hash_parsed,
3143 : : .data = NULL,
3144 : : .help_str = "show port <port_id> rss-hash",
3145 : : .tokens = {
3146 : : (void *)&cmd_showport_rss_hash_show,
3147 : : (void *)&cmd_showport_rss_hash_port,
3148 : : (void *)&cmd_showport_rss_hash_port_id,
3149 : : (void *)&cmd_showport_rss_hash_rss_hash,
3150 : : NULL,
3151 : : },
3152 : : };
3153 : :
3154 : : static cmdline_parse_inst_t cmd_showport_rss_hash_key = {
3155 : : .f = cmd_showport_rss_hash_parsed,
3156 : : .data = NULL,
3157 : : .help_str = "show port <port_id> rss-hash key",
3158 : : .tokens = {
3159 : : (void *)&cmd_showport_rss_hash_show,
3160 : : (void *)&cmd_showport_rss_hash_port,
3161 : : (void *)&cmd_showport_rss_hash_port_id,
3162 : : (void *)&cmd_showport_rss_hash_rss_hash,
3163 : : (void *)&cmd_showport_rss_hash_rss_key,
3164 : : NULL,
3165 : : },
3166 : : };
3167 : :
3168 : : static cmdline_parse_inst_t cmd_showport_rss_hash_algo = {
3169 : : .f = cmd_showport_rss_hash_parsed,
3170 : : .data = NULL,
3171 : : .help_str = "show port <port_id> rss-hash algorithm",
3172 : : .tokens = {
3173 : : (void *)&cmd_showport_rss_hash_show,
3174 : : (void *)&cmd_showport_rss_hash_port,
3175 : : (void *)&cmd_showport_rss_hash_port_id,
3176 : : (void *)&cmd_showport_rss_hash_rss_hash,
3177 : : (void *)&cmd_showport_rss_hash_rss_algo,
3178 : : NULL,
3179 : : },
3180 : : };
3181 : :
3182 : : /* *** Configure DCB *** */
3183 : : struct cmd_config_dcb {
3184 : : cmdline_fixed_string_t port;
3185 : : cmdline_fixed_string_t config;
3186 : : portid_t port_id;
3187 : : cmdline_fixed_string_t dcb;
3188 : : cmdline_fixed_string_t vt;
3189 : : cmdline_fixed_string_t vt_en;
3190 : : uint8_t num_tcs;
3191 : : cmdline_fixed_string_t pfc;
3192 : : cmdline_fixed_string_t pfc_en;
3193 : : };
3194 : :
3195 : : static void
3196 : 0 : cmd_config_dcb_parsed(void *parsed_result,
3197 : : __rte_unused struct cmdline *cl,
3198 : : __rte_unused void *data)
3199 : : {
3200 : : struct cmd_config_dcb *res = parsed_result;
3201 : : struct rte_eth_dcb_info dcb_info;
3202 : 0 : portid_t port_id = res->port_id;
3203 : : struct rte_port *port;
3204 : : uint8_t pfc_en;
3205 : : int ret;
3206 : :
3207 : 0 : port = &ports[port_id];
3208 : : /** Check if the port is not started **/
3209 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
3210 : 0 : fprintf(stderr, "Please stop port %d first\n", port_id);
3211 : 0 : return;
3212 : : }
3213 : :
3214 : 0 : if ((res->num_tcs != RTE_ETH_4_TCS) && (res->num_tcs != RTE_ETH_8_TCS)) {
3215 : 0 : fprintf(stderr,
3216 : : "The invalid number of traffic class, only 4 or 8 allowed.\n");
3217 : 0 : return;
3218 : : }
3219 : :
3220 : 0 : if (nb_fwd_lcores < res->num_tcs) {
3221 : 0 : fprintf(stderr,
3222 : : "nb_cores shouldn't be less than number of TCs.\n");
3223 : 0 : return;
3224 : : }
3225 : :
3226 : : /* Check whether the port supports the report of DCB info. */
3227 : 0 : ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
3228 : 0 : if (ret == -ENOTSUP) {
3229 : 0 : fprintf(stderr, "rte_eth_dev_get_dcb_info not supported.\n");
3230 : 0 : return;
3231 : : }
3232 : :
3233 : 0 : if (!strncmp(res->pfc_en, "on", 2))
3234 : : pfc_en = 1;
3235 : : else
3236 : : pfc_en = 0;
3237 : :
3238 : : /* DCB in VT mode */
3239 : 0 : if (!strncmp(res->vt_en, "on", 2))
3240 : 0 : ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
3241 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3242 : : pfc_en);
3243 : : else
3244 : 0 : ret = init_port_dcb_config(port_id, DCB_ENABLED,
3245 : 0 : (enum rte_eth_nb_tcs)res->num_tcs,
3246 : : pfc_en);
3247 : 0 : if (ret != 0) {
3248 : 0 : fprintf(stderr, "Cannot initialize network ports.\n");
3249 : 0 : return;
3250 : : }
3251 : :
3252 : 0 : fwd_config_setup();
3253 : :
3254 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
3255 : : }
3256 : :
3257 : : static cmdline_parse_token_string_t cmd_config_dcb_port =
3258 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port");
3259 : : static cmdline_parse_token_string_t cmd_config_dcb_config =
3260 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config");
3261 : : static cmdline_parse_token_num_t cmd_config_dcb_port_id =
3262 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, RTE_UINT16);
3263 : : static cmdline_parse_token_string_t cmd_config_dcb_dcb =
3264 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb");
3265 : : static cmdline_parse_token_string_t cmd_config_dcb_vt =
3266 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt");
3267 : : static cmdline_parse_token_string_t cmd_config_dcb_vt_en =
3268 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off");
3269 : : static cmdline_parse_token_num_t cmd_config_dcb_num_tcs =
3270 : : TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, RTE_UINT8);
3271 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc =
3272 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc");
3273 : : static cmdline_parse_token_string_t cmd_config_dcb_pfc_en =
3274 : : TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off");
3275 : :
3276 : : static cmdline_parse_inst_t cmd_config_dcb = {
3277 : : .f = cmd_config_dcb_parsed,
3278 : : .data = NULL,
3279 : : .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off",
3280 : : .tokens = {
3281 : : (void *)&cmd_config_dcb_port,
3282 : : (void *)&cmd_config_dcb_config,
3283 : : (void *)&cmd_config_dcb_port_id,
3284 : : (void *)&cmd_config_dcb_dcb,
3285 : : (void *)&cmd_config_dcb_vt,
3286 : : (void *)&cmd_config_dcb_vt_en,
3287 : : (void *)&cmd_config_dcb_num_tcs,
3288 : : (void *)&cmd_config_dcb_pfc,
3289 : : (void *)&cmd_config_dcb_pfc_en,
3290 : : NULL,
3291 : : },
3292 : : };
3293 : :
3294 : : /* *** configure number of packets per burst *** */
3295 : : struct cmd_config_burst {
3296 : : cmdline_fixed_string_t port;
3297 : : cmdline_fixed_string_t keyword;
3298 : : cmdline_fixed_string_t all;
3299 : : cmdline_fixed_string_t name;
3300 : : uint16_t value;
3301 : : };
3302 : :
3303 : : static void
3304 : 0 : cmd_config_burst_parsed(void *parsed_result,
3305 : : __rte_unused struct cmdline *cl,
3306 : : __rte_unused void *data)
3307 : : {
3308 : : struct cmd_config_burst *res = parsed_result;
3309 : : struct rte_eth_dev_info dev_info;
3310 : : uint16_t rec_nb_pkts;
3311 : : int ret;
3312 : :
3313 : 0 : if (!all_ports_stopped()) {
3314 : 0 : fprintf(stderr, "Please stop all ports first\n");
3315 : 0 : return;
3316 : : }
3317 : :
3318 : 0 : if (!strcmp(res->name, "burst")) {
3319 : 0 : if (res->value == 0) {
3320 : : /* If user gives a value of zero, query the PMD for
3321 : : * its recommended Rx burst size. Testpmd uses a single
3322 : : * size for all ports, so assume all ports are the same
3323 : : * NIC model and use the values from Port 0.
3324 : : */
3325 : 0 : ret = eth_dev_info_get_print_err(0, &dev_info);
3326 : 0 : if (ret != 0)
3327 : : return;
3328 : :
3329 : 0 : rec_nb_pkts = dev_info.default_rxportconf.burst_size;
3330 : :
3331 : 0 : if (rec_nb_pkts == 0) {
3332 : : printf("PMD does not recommend a burst size.\n"
3333 : : "User provided value must be between"
3334 : : " 1 and %d\n", MAX_PKT_BURST);
3335 : 0 : return;
3336 : 0 : } else if (rec_nb_pkts > MAX_PKT_BURST) {
3337 : 0 : printf("PMD recommended burst size of %d"
3338 : : " exceeds maximum value of %d\n",
3339 : : rec_nb_pkts, MAX_PKT_BURST);
3340 : 0 : return;
3341 : : }
3342 : 0 : printf("Using PMD-provided burst value of %d\n",
3343 : : rec_nb_pkts);
3344 : 0 : nb_pkt_per_burst = rec_nb_pkts;
3345 : 0 : } else if (res->value > MAX_PKT_BURST) {
3346 : 0 : fprintf(stderr, "burst must be >= 1 && <= %d\n",
3347 : : MAX_PKT_BURST);
3348 : 0 : return;
3349 : : } else
3350 : 0 : nb_pkt_per_burst = res->value;
3351 : : } else {
3352 : 0 : fprintf(stderr, "Unknown parameter\n");
3353 : 0 : return;
3354 : : }
3355 : :
3356 : 0 : init_port_config();
3357 : :
3358 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3359 : : }
3360 : :
3361 : : static cmdline_parse_token_string_t cmd_config_burst_port =
3362 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port");
3363 : : static cmdline_parse_token_string_t cmd_config_burst_keyword =
3364 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config");
3365 : : static cmdline_parse_token_string_t cmd_config_burst_all =
3366 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all");
3367 : : static cmdline_parse_token_string_t cmd_config_burst_name =
3368 : : TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst");
3369 : : static cmdline_parse_token_num_t cmd_config_burst_value =
3370 : : TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, RTE_UINT16);
3371 : :
3372 : : static cmdline_parse_inst_t cmd_config_burst = {
3373 : : .f = cmd_config_burst_parsed,
3374 : : .data = NULL,
3375 : : .help_str = "port config all burst <value>",
3376 : : .tokens = {
3377 : : (void *)&cmd_config_burst_port,
3378 : : (void *)&cmd_config_burst_keyword,
3379 : : (void *)&cmd_config_burst_all,
3380 : : (void *)&cmd_config_burst_name,
3381 : : (void *)&cmd_config_burst_value,
3382 : : NULL,
3383 : : },
3384 : : };
3385 : :
3386 : : /* *** configure rx/tx queues *** */
3387 : : struct cmd_config_thresh {
3388 : : cmdline_fixed_string_t port;
3389 : : cmdline_fixed_string_t keyword;
3390 : : cmdline_fixed_string_t all;
3391 : : cmdline_fixed_string_t name;
3392 : : uint8_t value;
3393 : : };
3394 : :
3395 : : static void
3396 : 0 : cmd_config_thresh_parsed(void *parsed_result,
3397 : : __rte_unused struct cmdline *cl,
3398 : : __rte_unused void *data)
3399 : : {
3400 : : struct cmd_config_thresh *res = parsed_result;
3401 : :
3402 : 0 : if (!all_ports_stopped()) {
3403 : 0 : fprintf(stderr, "Please stop all ports first\n");
3404 : 0 : return;
3405 : : }
3406 : :
3407 : 0 : if (!strcmp(res->name, "txpt"))
3408 : 0 : tx_pthresh = res->value;
3409 : 0 : else if(!strcmp(res->name, "txht"))
3410 : 0 : tx_hthresh = res->value;
3411 : 0 : else if(!strcmp(res->name, "txwt"))
3412 : 0 : tx_wthresh = res->value;
3413 : 0 : else if(!strcmp(res->name, "rxpt"))
3414 : 0 : rx_pthresh = res->value;
3415 : 0 : else if(!strcmp(res->name, "rxht"))
3416 : 0 : rx_hthresh = res->value;
3417 : 0 : else if(!strcmp(res->name, "rxwt"))
3418 : 0 : rx_wthresh = res->value;
3419 : : else {
3420 : 0 : fprintf(stderr, "Unknown parameter\n");
3421 : 0 : return;
3422 : : }
3423 : :
3424 : 0 : init_port_config();
3425 : :
3426 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3427 : : }
3428 : :
3429 : : static cmdline_parse_token_string_t cmd_config_thresh_port =
3430 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port");
3431 : : static cmdline_parse_token_string_t cmd_config_thresh_keyword =
3432 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config");
3433 : : static cmdline_parse_token_string_t cmd_config_thresh_all =
3434 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all");
3435 : : static cmdline_parse_token_string_t cmd_config_thresh_name =
3436 : : TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name,
3437 : : "txpt#txht#txwt#rxpt#rxht#rxwt");
3438 : : static cmdline_parse_token_num_t cmd_config_thresh_value =
3439 : : TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, RTE_UINT8);
3440 : :
3441 : : static cmdline_parse_inst_t cmd_config_thresh = {
3442 : : .f = cmd_config_thresh_parsed,
3443 : : .data = NULL,
3444 : : .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>",
3445 : : .tokens = {
3446 : : (void *)&cmd_config_thresh_port,
3447 : : (void *)&cmd_config_thresh_keyword,
3448 : : (void *)&cmd_config_thresh_all,
3449 : : (void *)&cmd_config_thresh_name,
3450 : : (void *)&cmd_config_thresh_value,
3451 : : NULL,
3452 : : },
3453 : : };
3454 : :
3455 : : /* *** configure free/rs threshold *** */
3456 : : struct cmd_config_threshold {
3457 : : cmdline_fixed_string_t port;
3458 : : cmdline_fixed_string_t keyword;
3459 : : cmdline_fixed_string_t all;
3460 : : cmdline_fixed_string_t name;
3461 : : uint16_t value;
3462 : : };
3463 : :
3464 : : static void
3465 : 0 : cmd_config_threshold_parsed(void *parsed_result,
3466 : : __rte_unused struct cmdline *cl,
3467 : : __rte_unused void *data)
3468 : : {
3469 : : struct cmd_config_threshold *res = parsed_result;
3470 : :
3471 : 0 : if (!all_ports_stopped()) {
3472 : 0 : fprintf(stderr, "Please stop all ports first\n");
3473 : 0 : return;
3474 : : }
3475 : :
3476 : 0 : if (!strcmp(res->name, "txfreet"))
3477 : 0 : tx_free_thresh = res->value;
3478 : 0 : else if (!strcmp(res->name, "txrst"))
3479 : 0 : tx_rs_thresh = res->value;
3480 : 0 : else if (!strcmp(res->name, "rxfreet"))
3481 : 0 : rx_free_thresh = res->value;
3482 : : else {
3483 : 0 : fprintf(stderr, "Unknown parameter\n");
3484 : 0 : return;
3485 : : }
3486 : :
3487 : 0 : init_port_config();
3488 : :
3489 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1);
3490 : : }
3491 : :
3492 : : static cmdline_parse_token_string_t cmd_config_threshold_port =
3493 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port");
3494 : : static cmdline_parse_token_string_t cmd_config_threshold_keyword =
3495 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword,
3496 : : "config");
3497 : : static cmdline_parse_token_string_t cmd_config_threshold_all =
3498 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all");
3499 : : static cmdline_parse_token_string_t cmd_config_threshold_name =
3500 : : TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name,
3501 : : "txfreet#txrst#rxfreet");
3502 : : static cmdline_parse_token_num_t cmd_config_threshold_value =
3503 : : TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, RTE_UINT16);
3504 : :
3505 : : static cmdline_parse_inst_t cmd_config_threshold = {
3506 : : .f = cmd_config_threshold_parsed,
3507 : : .data = NULL,
3508 : : .help_str = "port config all txfreet|txrst|rxfreet <value>",
3509 : : .tokens = {
3510 : : (void *)&cmd_config_threshold_port,
3511 : : (void *)&cmd_config_threshold_keyword,
3512 : : (void *)&cmd_config_threshold_all,
3513 : : (void *)&cmd_config_threshold_name,
3514 : : (void *)&cmd_config_threshold_value,
3515 : : NULL,
3516 : : },
3517 : : };
3518 : :
3519 : : /* *** stop *** */
3520 : : struct cmd_stop_result {
3521 : : cmdline_fixed_string_t stop;
3522 : : };
3523 : :
3524 : 0 : static void cmd_stop_parsed(__rte_unused void *parsed_result,
3525 : : __rte_unused struct cmdline *cl,
3526 : : __rte_unused void *data)
3527 : : {
3528 : 0 : stop_packet_forwarding();
3529 : 0 : }
3530 : :
3531 : : static cmdline_parse_token_string_t cmd_stop_stop =
3532 : : TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop");
3533 : :
3534 : : static cmdline_parse_inst_t cmd_stop = {
3535 : : .f = cmd_stop_parsed,
3536 : : .data = NULL,
3537 : : .help_str = "stop: Stop packet forwarding",
3538 : : .tokens = {
3539 : : (void *)&cmd_stop_stop,
3540 : : NULL,
3541 : : },
3542 : : };
3543 : :
3544 : : static unsigned int
3545 : 0 : get_ptype(char *value)
3546 : : {
3547 : : uint32_t protocol;
3548 : :
3549 : 0 : if (!strcmp(value, "eth"))
3550 : : protocol = RTE_PTYPE_L2_ETHER;
3551 : 0 : else if (!strcmp(value, "ipv4"))
3552 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN;
3553 : 0 : else if (!strcmp(value, "ipv6"))
3554 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN;
3555 : 0 : else if (!strcmp(value, "ipv4-tcp"))
3556 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3557 : 0 : else if (!strcmp(value, "ipv4-udp"))
3558 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3559 : 0 : else if (!strcmp(value, "ipv4-sctp"))
3560 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3561 : 0 : else if (!strcmp(value, "ipv6-tcp"))
3562 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_TCP;
3563 : 0 : else if (!strcmp(value, "ipv6-udp"))
3564 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_UDP;
3565 : 0 : else if (!strcmp(value, "ipv6-sctp"))
3566 : : protocol = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_L4_SCTP;
3567 : 0 : else if (!strcmp(value, "grenat"))
3568 : : protocol = RTE_PTYPE_TUNNEL_GRENAT;
3569 : 0 : else if (!strcmp(value, "inner-eth"))
3570 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER;
3571 : 0 : else if (!strcmp(value, "inner-ipv4"))
3572 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3573 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN;
3574 : 0 : else if (!strcmp(value, "inner-ipv6"))
3575 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3576 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN;
3577 : 0 : else if (!strcmp(value, "inner-ipv4-tcp"))
3578 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3579 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3580 : 0 : else if (!strcmp(value, "inner-ipv4-udp"))
3581 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3582 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
3583 : 0 : else if (!strcmp(value, "inner-ipv4-sctp"))
3584 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3585 : : RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
3586 : 0 : else if (!strcmp(value, "inner-ipv6-tcp"))
3587 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3588 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_TCP;
3589 : 0 : else if (!strcmp(value, "inner-ipv6-udp"))
3590 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3591 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_UDP;
3592 : 0 : else if (!strcmp(value, "inner-ipv6-sctp"))
3593 : : protocol = RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
3594 : : RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | RTE_PTYPE_INNER_L4_SCTP;
3595 : : else {
3596 : 0 : fprintf(stderr, "Unsupported protocol: %s\n", value);
3597 : : protocol = RTE_PTYPE_UNKNOWN;
3598 : : }
3599 : :
3600 : 0 : return protocol;
3601 : : }
3602 : :
3603 : : /* *** SET RXHDRSLIST *** */
3604 : :
3605 : : unsigned int
3606 : 0 : parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
3607 : : unsigned int *parsed_items)
3608 : : {
3609 : : unsigned int nb_item;
3610 : : char *cur;
3611 : : char *tmp;
3612 : :
3613 : : nb_item = 0;
3614 : 0 : char *str2 = strdup(str);
3615 : 0 : if (str2 == NULL)
3616 : : return nb_item;
3617 : 0 : cur = strtok_r(str2, ",", &tmp);
3618 : 0 : while (cur != NULL) {
3619 : 0 : parsed_items[nb_item] = get_ptype(cur);
3620 : 0 : cur = strtok_r(NULL, ",", &tmp);
3621 : 0 : nb_item++;
3622 : : }
3623 : 0 : if (nb_item > max_items)
3624 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3625 : : item_name, nb_item + 1, max_items);
3626 : 0 : free(str2);
3627 : 0 : return nb_item;
3628 : : }
3629 : :
3630 : : /* *** SET CORELIST and PORTLIST CONFIGURATION *** */
3631 : :
3632 : : unsigned int
3633 : 0 : parse_item_list(const char *str, const char *item_name, unsigned int max_items,
3634 : : unsigned int *parsed_items, int check_unique_values)
3635 : : {
3636 : : unsigned int nb_item;
3637 : : unsigned int value;
3638 : : unsigned int i;
3639 : : unsigned int j;
3640 : : int value_ok;
3641 : : char c;
3642 : :
3643 : : /*
3644 : : * First parse all items in the list and store their value.
3645 : : */
3646 : : value = 0;
3647 : : nb_item = 0;
3648 : : value_ok = 0;
3649 : 0 : for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) {
3650 : 0 : c = str[i];
3651 : 0 : if ((c >= '0') && (c <= '9')) {
3652 : 0 : value = (unsigned int) (value * 10 + (c - '0'));
3653 : : value_ok = 1;
3654 : 0 : continue;
3655 : : }
3656 : 0 : if (c != ',') {
3657 : 0 : fprintf(stderr, "character %c is not a decimal digit\n", c);
3658 : 0 : return 0;
3659 : : }
3660 : 0 : if (! value_ok) {
3661 : 0 : fprintf(stderr, "No valid value before comma\n");
3662 : 0 : return 0;
3663 : : }
3664 : 0 : if (nb_item < max_items) {
3665 : 0 : parsed_items[nb_item] = value;
3666 : : value_ok = 0;
3667 : : value = 0;
3668 : : }
3669 : 0 : nb_item++;
3670 : : }
3671 : 0 : if (nb_item >= max_items) {
3672 : 0 : fprintf(stderr, "Number of %s = %u > %u (maximum items)\n",
3673 : : item_name, nb_item + 1, max_items);
3674 : 0 : return 0;
3675 : : }
3676 : 0 : parsed_items[nb_item++] = value;
3677 : 0 : if (! check_unique_values)
3678 : : return nb_item;
3679 : :
3680 : : /*
3681 : : * Then, check that all values in the list are different.
3682 : : * No optimization here...
3683 : : */
3684 : 0 : for (i = 0; i < nb_item; i++) {
3685 : 0 : for (j = i + 1; j < nb_item; j++) {
3686 : 0 : if (parsed_items[j] == parsed_items[i]) {
3687 : 0 : fprintf(stderr,
3688 : : "duplicated %s %u at index %u and %u\n",
3689 : : item_name, parsed_items[i], i, j);
3690 : 0 : return 0;
3691 : : }
3692 : : }
3693 : : }
3694 : : return nb_item;
3695 : : }
3696 : :
3697 : : struct cmd_set_list_result {
3698 : : cmdline_fixed_string_t cmd_keyword;
3699 : : cmdline_fixed_string_t list_name;
3700 : : cmdline_fixed_string_t list_of_items;
3701 : : };
3702 : :
3703 : 0 : static void cmd_set_list_parsed(void *parsed_result,
3704 : : __rte_unused struct cmdline *cl,
3705 : : __rte_unused void *data)
3706 : : {
3707 : : struct cmd_set_list_result *res;
3708 : : union {
3709 : : unsigned int lcorelist[RTE_MAX_LCORE];
3710 : : unsigned int portlist[RTE_MAX_ETHPORTS];
3711 : : } parsed_items;
3712 : : unsigned int nb_item;
3713 : :
3714 : 0 : if (test_done == 0) {
3715 : 0 : fprintf(stderr, "Please stop forwarding first\n");
3716 : 0 : return;
3717 : : }
3718 : :
3719 : : res = parsed_result;
3720 : 0 : if (!strcmp(res->list_name, "corelist")) {
3721 : 0 : nb_item = parse_item_list(res->list_of_items, "core",
3722 : : RTE_MAX_LCORE,
3723 : : parsed_items.lcorelist, 1);
3724 : 0 : if (nb_item > 0) {
3725 : 0 : set_fwd_lcores_list(parsed_items.lcorelist, nb_item);
3726 : 0 : fwd_config_setup();
3727 : : }
3728 : 0 : return;
3729 : : }
3730 : 0 : if (!strcmp(res->list_name, "portlist")) {
3731 : 0 : nb_item = parse_item_list(res->list_of_items, "port",
3732 : : RTE_MAX_ETHPORTS,
3733 : : parsed_items.portlist, 1);
3734 : 0 : if (nb_item > 0) {
3735 : 0 : set_fwd_ports_list(parsed_items.portlist, nb_item);
3736 : 0 : fwd_config_setup();
3737 : : }
3738 : : }
3739 : : }
3740 : :
3741 : : static cmdline_parse_token_string_t cmd_set_list_keyword =
3742 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword,
3743 : : "set");
3744 : : static cmdline_parse_token_string_t cmd_set_list_name =
3745 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name,
3746 : : "corelist#portlist");
3747 : : static cmdline_parse_token_string_t cmd_set_list_of_items =
3748 : : TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items,
3749 : : NULL);
3750 : :
3751 : : static cmdline_parse_inst_t cmd_set_fwd_list = {
3752 : : .f = cmd_set_list_parsed,
3753 : : .data = NULL,
3754 : : .help_str = "set corelist|portlist <list0[,list1]*>",
3755 : : .tokens = {
3756 : : (void *)&cmd_set_list_keyword,
3757 : : (void *)&cmd_set_list_name,
3758 : : (void *)&cmd_set_list_of_items,
3759 : : NULL,
3760 : : },
3761 : : };
3762 : :
3763 : : /* *** SET COREMASK and PORTMASK CONFIGURATION *** */
3764 : :
3765 : : struct cmd_setmask_result {
3766 : : cmdline_fixed_string_t set;
3767 : : cmdline_fixed_string_t mask;
3768 : : uint64_t hexavalue;
3769 : : };
3770 : :
3771 : 0 : static void cmd_set_mask_parsed(void *parsed_result,
3772 : : __rte_unused struct cmdline *cl,
3773 : : __rte_unused void *data)
3774 : : {
3775 : : struct cmd_setmask_result *res = parsed_result;
3776 : :
3777 : 0 : if (test_done == 0) {
3778 : 0 : fprintf(stderr, "Please stop forwarding first\n");
3779 : 0 : return;
3780 : : }
3781 : 0 : if (!strcmp(res->mask, "coremask")) {
3782 : 0 : set_fwd_lcores_mask(res->hexavalue);
3783 : 0 : fwd_config_setup();
3784 : 0 : } else if (!strcmp(res->mask, "portmask")) {
3785 : 0 : set_fwd_ports_mask(res->hexavalue);
3786 : 0 : fwd_config_setup();
3787 : : }
3788 : : }
3789 : :
3790 : : static cmdline_parse_token_string_t cmd_setmask_set =
3791 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set");
3792 : : static cmdline_parse_token_string_t cmd_setmask_mask =
3793 : : TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask,
3794 : : "coremask#portmask");
3795 : : static cmdline_parse_token_num_t cmd_setmask_value =
3796 : : TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, RTE_UINT64);
3797 : :
3798 : : static cmdline_parse_inst_t cmd_set_fwd_mask = {
3799 : : .f = cmd_set_mask_parsed,
3800 : : .data = NULL,
3801 : : .help_str = "set coremask|portmask <hexadecimal value>",
3802 : : .tokens = {
3803 : : (void *)&cmd_setmask_set,
3804 : : (void *)&cmd_setmask_mask,
3805 : : (void *)&cmd_setmask_value,
3806 : : NULL,
3807 : : },
3808 : : };
3809 : :
3810 : : /*
3811 : : * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
3812 : : */
3813 : : struct cmd_set_result {
3814 : : cmdline_fixed_string_t set;
3815 : : cmdline_fixed_string_t what;
3816 : : uint16_t value;
3817 : : };
3818 : :
3819 : 0 : static void cmd_set_parsed(void *parsed_result,
3820 : : __rte_unused struct cmdline *cl,
3821 : : __rte_unused void *data)
3822 : : {
3823 : : struct cmd_set_result *res = parsed_result;
3824 : 0 : if (!strcmp(res->what, "nbport")) {
3825 : 0 : set_fwd_ports_number(res->value);
3826 : 0 : fwd_config_setup();
3827 : 0 : } else if (!strcmp(res->what, "nbcore")) {
3828 : 0 : set_fwd_lcores_number(res->value);
3829 : 0 : fwd_config_setup();
3830 : 0 : } else if (!strcmp(res->what, "burst"))
3831 : 0 : set_nb_pkt_per_burst(res->value);
3832 : 0 : else if (!strcmp(res->what, "verbose"))
3833 : 0 : set_verbose_level(res->value);
3834 : 0 : }
3835 : :
3836 : : static cmdline_parse_token_string_t cmd_set_set =
3837 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set");
3838 : : static cmdline_parse_token_string_t cmd_set_what =
3839 : : TOKEN_STRING_INITIALIZER(struct cmd_set_result, what,
3840 : : "nbport#nbcore#burst#verbose");
3841 : : static cmdline_parse_token_num_t cmd_set_value =
3842 : : TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, RTE_UINT16);
3843 : :
3844 : : static cmdline_parse_inst_t cmd_set_numbers = {
3845 : : .f = cmd_set_parsed,
3846 : : .data = NULL,
3847 : : .help_str = "set nbport|nbcore|burst|verbose <value>",
3848 : : .tokens = {
3849 : : (void *)&cmd_set_set,
3850 : : (void *)&cmd_set_what,
3851 : : (void *)&cmd_set_value,
3852 : : NULL,
3853 : : },
3854 : : };
3855 : :
3856 : : /* *** SET LOG LEVEL CONFIGURATION *** */
3857 : :
3858 : : struct cmd_set_log_result {
3859 : : cmdline_fixed_string_t set;
3860 : : cmdline_fixed_string_t log;
3861 : : cmdline_fixed_string_t type;
3862 : : uint32_t level;
3863 : : };
3864 : :
3865 : : static void
3866 : 0 : cmd_set_log_parsed(void *parsed_result,
3867 : : __rte_unused struct cmdline *cl,
3868 : : __rte_unused void *data)
3869 : : {
3870 : : struct cmd_set_log_result *res;
3871 : : int ret;
3872 : :
3873 : : res = parsed_result;
3874 : 0 : if (!strcmp(res->type, "global"))
3875 : 0 : rte_log_set_global_level(res->level);
3876 : : else {
3877 : 0 : ret = rte_log_set_level_regexp(res->type, res->level);
3878 : 0 : if (ret < 0)
3879 : 0 : fprintf(stderr, "Unable to set log level\n");
3880 : : }
3881 : 0 : }
3882 : :
3883 : : static cmdline_parse_token_string_t cmd_set_log_set =
3884 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set");
3885 : : static cmdline_parse_token_string_t cmd_set_log_log =
3886 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log");
3887 : : static cmdline_parse_token_string_t cmd_set_log_type =
3888 : : TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL);
3889 : : static cmdline_parse_token_num_t cmd_set_log_level =
3890 : : TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, RTE_UINT32);
3891 : :
3892 : : static cmdline_parse_inst_t cmd_set_log = {
3893 : : .f = cmd_set_log_parsed,
3894 : : .data = NULL,
3895 : : .help_str = "set log global|<type> <level>",
3896 : : .tokens = {
3897 : : (void *)&cmd_set_log_set,
3898 : : (void *)&cmd_set_log_log,
3899 : : (void *)&cmd_set_log_type,
3900 : : (void *)&cmd_set_log_level,
3901 : : NULL,
3902 : : },
3903 : : };
3904 : :
3905 : : /* *** SET SEGMENT OFFSETS OF RX PACKETS SPLIT *** */
3906 : :
3907 : : struct cmd_set_rxoffs_result {
3908 : : cmdline_fixed_string_t cmd_keyword;
3909 : : cmdline_fixed_string_t rxoffs;
3910 : : cmdline_fixed_string_t seg_offsets;
3911 : : };
3912 : :
3913 : : static void
3914 : 0 : cmd_set_rxoffs_parsed(void *parsed_result,
3915 : : __rte_unused struct cmdline *cl,
3916 : : __rte_unused void *data)
3917 : : {
3918 : : struct cmd_set_rxoffs_result *res;
3919 : : unsigned int seg_offsets[MAX_SEGS_BUFFER_SPLIT];
3920 : : unsigned int nb_segs;
3921 : :
3922 : : res = parsed_result;
3923 : 0 : nb_segs = parse_item_list(res->seg_offsets, "segment offsets",
3924 : : MAX_SEGS_BUFFER_SPLIT, seg_offsets, 0);
3925 : 0 : if (nb_segs > 0)
3926 : 0 : set_rx_pkt_offsets(seg_offsets, nb_segs);
3927 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3928 : 0 : }
3929 : :
3930 : : static cmdline_parse_token_string_t cmd_set_rxoffs_keyword =
3931 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3932 : : cmd_keyword, "set");
3933 : : static cmdline_parse_token_string_t cmd_set_rxoffs_name =
3934 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3935 : : rxoffs, "rxoffs");
3936 : : static cmdline_parse_token_string_t cmd_set_rxoffs_offsets =
3937 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxoffs_result,
3938 : : seg_offsets, NULL);
3939 : :
3940 : : static cmdline_parse_inst_t cmd_set_rxoffs = {
3941 : : .f = cmd_set_rxoffs_parsed,
3942 : : .data = NULL,
3943 : : .help_str = "set rxoffs <len0[,len1]*>",
3944 : : .tokens = {
3945 : : (void *)&cmd_set_rxoffs_keyword,
3946 : : (void *)&cmd_set_rxoffs_name,
3947 : : (void *)&cmd_set_rxoffs_offsets,
3948 : : NULL,
3949 : : },
3950 : : };
3951 : :
3952 : : /* *** SET SEGMENT LENGTHS OF RX PACKETS SPLIT *** */
3953 : :
3954 : : struct cmd_set_rxpkts_result {
3955 : : cmdline_fixed_string_t cmd_keyword;
3956 : : cmdline_fixed_string_t rxpkts;
3957 : : cmdline_fixed_string_t seg_lengths;
3958 : : };
3959 : :
3960 : : static void
3961 : 0 : cmd_set_rxpkts_parsed(void *parsed_result,
3962 : : __rte_unused struct cmdline *cl,
3963 : : __rte_unused void *data)
3964 : : {
3965 : : struct cmd_set_rxpkts_result *res;
3966 : : unsigned int seg_lengths[MAX_SEGS_BUFFER_SPLIT];
3967 : : unsigned int nb_segs;
3968 : :
3969 : : res = parsed_result;
3970 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
3971 : : MAX_SEGS_BUFFER_SPLIT, seg_lengths, 0);
3972 : 0 : if (nb_segs > 0)
3973 : 0 : set_rx_pkt_segments(seg_lengths, nb_segs);
3974 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
3975 : 0 : }
3976 : :
3977 : : static cmdline_parse_token_string_t cmd_set_rxpkts_keyword =
3978 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3979 : : cmd_keyword, "set");
3980 : : static cmdline_parse_token_string_t cmd_set_rxpkts_name =
3981 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3982 : : rxpkts, "rxpkts");
3983 : : static cmdline_parse_token_string_t cmd_set_rxpkts_lengths =
3984 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxpkts_result,
3985 : : seg_lengths, NULL);
3986 : :
3987 : : static cmdline_parse_inst_t cmd_set_rxpkts = {
3988 : : .f = cmd_set_rxpkts_parsed,
3989 : : .data = NULL,
3990 : : .help_str = "set rxpkts <len0[,len1]*>",
3991 : : .tokens = {
3992 : : (void *)&cmd_set_rxpkts_keyword,
3993 : : (void *)&cmd_set_rxpkts_name,
3994 : : (void *)&cmd_set_rxpkts_lengths,
3995 : : NULL,
3996 : : },
3997 : : };
3998 : :
3999 : : /* *** SET SEGMENT HEADERS OF RX PACKETS SPLIT *** */
4000 : : struct cmd_set_rxhdrs_result {
4001 : : cmdline_fixed_string_t set;
4002 : : cmdline_fixed_string_t rxhdrs;
4003 : : cmdline_fixed_string_t values;
4004 : : };
4005 : :
4006 : : static void
4007 : 0 : cmd_set_rxhdrs_parsed(void *parsed_result,
4008 : : __rte_unused struct cmdline *cl,
4009 : : __rte_unused void *data)
4010 : : {
4011 : : struct cmd_set_rxhdrs_result *res;
4012 : : unsigned int seg_hdrs[MAX_SEGS_BUFFER_SPLIT];
4013 : : unsigned int nb_segs;
4014 : :
4015 : : res = parsed_result;
4016 : 0 : nb_segs = parse_hdrs_list(res->values, "segment hdrs",
4017 : : MAX_SEGS_BUFFER_SPLIT, seg_hdrs);
4018 : 0 : if (nb_segs > 0)
4019 : 0 : set_rx_pkt_hdrs(seg_hdrs, nb_segs);
4020 : 0 : cmd_reconfig_device_queue(RTE_PORT_ALL, 0, 1);
4021 : 0 : }
4022 : :
4023 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_set =
4024 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4025 : : set, "set");
4026 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_rxhdrs =
4027 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4028 : : rxhdrs, "rxhdrs");
4029 : : static cmdline_parse_token_string_t cmd_set_rxhdrs_values =
4030 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxhdrs_result,
4031 : : values, NULL);
4032 : :
4033 : : static cmdline_parse_inst_t cmd_set_rxhdrs = {
4034 : : .f = cmd_set_rxhdrs_parsed,
4035 : : .data = NULL,
4036 : : .help_str = "set rxhdrs <eth[,ipv4]*>",
4037 : : .tokens = {
4038 : : (void *)&cmd_set_rxhdrs_set,
4039 : : (void *)&cmd_set_rxhdrs_rxhdrs,
4040 : : (void *)&cmd_set_rxhdrs_values,
4041 : : NULL,
4042 : : },
4043 : : };
4044 : :
4045 : : /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */
4046 : :
4047 : : struct cmd_set_txpkts_result {
4048 : : cmdline_fixed_string_t cmd_keyword;
4049 : : cmdline_fixed_string_t txpkts;
4050 : : cmdline_fixed_string_t seg_lengths;
4051 : : };
4052 : :
4053 : : static void
4054 : 0 : cmd_set_txpkts_parsed(void *parsed_result,
4055 : : __rte_unused struct cmdline *cl,
4056 : : __rte_unused void *data)
4057 : : {
4058 : : struct cmd_set_txpkts_result *res;
4059 : : unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT];
4060 : : unsigned int nb_segs;
4061 : :
4062 : : res = parsed_result;
4063 : 0 : nb_segs = parse_item_list(res->seg_lengths, "segment lengths",
4064 : : RTE_MAX_SEGS_PER_PKT, seg_lengths, 0);
4065 : 0 : if (nb_segs > 0)
4066 : 0 : set_tx_pkt_segments(seg_lengths, nb_segs);
4067 : 0 : }
4068 : :
4069 : : static cmdline_parse_token_string_t cmd_set_txpkts_keyword =
4070 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4071 : : cmd_keyword, "set");
4072 : : static cmdline_parse_token_string_t cmd_set_txpkts_name =
4073 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4074 : : txpkts, "txpkts");
4075 : : static cmdline_parse_token_string_t cmd_set_txpkts_lengths =
4076 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result,
4077 : : seg_lengths, NULL);
4078 : :
4079 : : static cmdline_parse_inst_t cmd_set_txpkts = {
4080 : : .f = cmd_set_txpkts_parsed,
4081 : : .data = NULL,
4082 : : .help_str = "set txpkts <len0[,len1]*>",
4083 : : .tokens = {
4084 : : (void *)&cmd_set_txpkts_keyword,
4085 : : (void *)&cmd_set_txpkts_name,
4086 : : (void *)&cmd_set_txpkts_lengths,
4087 : : NULL,
4088 : : },
4089 : : };
4090 : :
4091 : : /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */
4092 : :
4093 : : struct cmd_set_txsplit_result {
4094 : : cmdline_fixed_string_t cmd_keyword;
4095 : : cmdline_fixed_string_t txsplit;
4096 : : cmdline_fixed_string_t mode;
4097 : : };
4098 : :
4099 : : static void
4100 : 0 : cmd_set_txsplit_parsed(void *parsed_result,
4101 : : __rte_unused struct cmdline *cl,
4102 : : __rte_unused void *data)
4103 : : {
4104 : : struct cmd_set_txsplit_result *res;
4105 : :
4106 : : res = parsed_result;
4107 : 0 : set_tx_pkt_split(res->mode);
4108 : 0 : }
4109 : :
4110 : : static cmdline_parse_token_string_t cmd_set_txsplit_keyword =
4111 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4112 : : cmd_keyword, "set");
4113 : : static cmdline_parse_token_string_t cmd_set_txsplit_name =
4114 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4115 : : txsplit, "txsplit");
4116 : : static cmdline_parse_token_string_t cmd_set_txsplit_mode =
4117 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result,
4118 : : mode, NULL);
4119 : :
4120 : : static cmdline_parse_inst_t cmd_set_txsplit = {
4121 : : .f = cmd_set_txsplit_parsed,
4122 : : .data = NULL,
4123 : : .help_str = "set txsplit on|off|rand",
4124 : : .tokens = {
4125 : : (void *)&cmd_set_txsplit_keyword,
4126 : : (void *)&cmd_set_txsplit_name,
4127 : : (void *)&cmd_set_txsplit_mode,
4128 : : NULL,
4129 : : },
4130 : : };
4131 : :
4132 : : /* *** SET TIMES FOR TXONLY PACKETS SCHEDULING ON TIMESTAMPS *** */
4133 : :
4134 : : struct cmd_set_txtimes_result {
4135 : : cmdline_fixed_string_t cmd_keyword;
4136 : : cmdline_fixed_string_t txtimes;
4137 : : cmdline_fixed_string_t tx_times;
4138 : : };
4139 : :
4140 : : static void
4141 : 0 : cmd_set_txtimes_parsed(void *parsed_result,
4142 : : __rte_unused struct cmdline *cl,
4143 : : __rte_unused void *data)
4144 : : {
4145 : : struct cmd_set_txtimes_result *res;
4146 : 0 : unsigned int tx_times[2] = {0, 0};
4147 : : unsigned int n_times;
4148 : :
4149 : : res = parsed_result;
4150 : 0 : n_times = parse_item_list(res->tx_times, "tx times",
4151 : : 2, tx_times, 0);
4152 : 0 : if (n_times == 2)
4153 : 0 : set_tx_pkt_times(tx_times);
4154 : 0 : }
4155 : :
4156 : : static cmdline_parse_token_string_t cmd_set_txtimes_keyword =
4157 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4158 : : cmd_keyword, "set");
4159 : : static cmdline_parse_token_string_t cmd_set_txtimes_name =
4160 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4161 : : txtimes, "txtimes");
4162 : : static cmdline_parse_token_string_t cmd_set_txtimes_value =
4163 : : TOKEN_STRING_INITIALIZER(struct cmd_set_txtimes_result,
4164 : : tx_times, NULL);
4165 : :
4166 : : static cmdline_parse_inst_t cmd_set_txtimes = {
4167 : : .f = cmd_set_txtimes_parsed,
4168 : : .data = NULL,
4169 : : .help_str = "set txtimes <inter_burst>,<intra_burst>",
4170 : : .tokens = {
4171 : : (void *)&cmd_set_txtimes_keyword,
4172 : : (void *)&cmd_set_txtimes_name,
4173 : : (void *)&cmd_set_txtimes_value,
4174 : : NULL,
4175 : : },
4176 : : };
4177 : :
4178 : : /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */
4179 : : struct cmd_rx_vlan_filter_all_result {
4180 : : cmdline_fixed_string_t rx_vlan;
4181 : : cmdline_fixed_string_t what;
4182 : : cmdline_fixed_string_t all;
4183 : : portid_t port_id;
4184 : : };
4185 : :
4186 : : static void
4187 : 0 : cmd_rx_vlan_filter_all_parsed(void *parsed_result,
4188 : : __rte_unused struct cmdline *cl,
4189 : : __rte_unused void *data)
4190 : : {
4191 : : struct cmd_rx_vlan_filter_all_result *res = parsed_result;
4192 : :
4193 : 0 : if (!strcmp(res->what, "add"))
4194 : 0 : rx_vlan_all_filter_set(res->port_id, 1);
4195 : : else
4196 : 0 : rx_vlan_all_filter_set(res->port_id, 0);
4197 : 0 : }
4198 : :
4199 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan =
4200 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4201 : : rx_vlan, "rx_vlan");
4202 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what =
4203 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4204 : : what, "add#rm");
4205 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all =
4206 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4207 : : all, "all");
4208 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid =
4209 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result,
4210 : : port_id, RTE_UINT16);
4211 : :
4212 : : static cmdline_parse_inst_t cmd_rx_vlan_filter_all = {
4213 : : .f = cmd_rx_vlan_filter_all_parsed,
4214 : : .data = NULL,
4215 : : .help_str = "rx_vlan add|rm all <port_id>: "
4216 : : "Add/Remove all identifiers to/from the set of VLAN "
4217 : : "identifiers filtered by a port",
4218 : : .tokens = {
4219 : : (void *)&cmd_rx_vlan_filter_all_rx_vlan,
4220 : : (void *)&cmd_rx_vlan_filter_all_what,
4221 : : (void *)&cmd_rx_vlan_filter_all_all,
4222 : : (void *)&cmd_rx_vlan_filter_all_portid,
4223 : : NULL,
4224 : : },
4225 : : };
4226 : :
4227 : : /* *** VLAN OFFLOAD SET ON A PORT *** */
4228 : : struct cmd_vlan_offload_result {
4229 : : cmdline_fixed_string_t vlan;
4230 : : cmdline_fixed_string_t set;
4231 : : cmdline_fixed_string_t vlan_type;
4232 : : cmdline_fixed_string_t what;
4233 : : cmdline_fixed_string_t on;
4234 : : cmdline_fixed_string_t port_id;
4235 : : };
4236 : :
4237 : : static void
4238 : 0 : cmd_vlan_offload_parsed(void *parsed_result,
4239 : : __rte_unused struct cmdline *cl,
4240 : : __rte_unused void *data)
4241 : : {
4242 : : int on;
4243 : : struct cmd_vlan_offload_result *res = parsed_result;
4244 : : char *str;
4245 : : int i, len = 0;
4246 : : portid_t port_id = 0;
4247 : : unsigned int tmp;
4248 : :
4249 : 0 : str = res->port_id;
4250 : 0 : len = strnlen(str, STR_TOKEN_SIZE);
4251 : : i = 0;
4252 : : /* Get port_id first */
4253 : 0 : while(i < len){
4254 : 0 : if(str[i] == ',')
4255 : : break;
4256 : :
4257 : 0 : i++;
4258 : : }
4259 : 0 : str[i]='\0';
4260 : 0 : tmp = strtoul(str, NULL, 0);
4261 : : /* If port_id greater that what portid_t can represent, return */
4262 : 0 : if(tmp >= RTE_MAX_ETHPORTS)
4263 : : return;
4264 : 0 : port_id = (portid_t)tmp;
4265 : :
4266 : 0 : if (!strcmp(res->on, "on"))
4267 : : on = 1;
4268 : : else
4269 : : on = 0;
4270 : :
4271 : 0 : if (!strcmp(res->what, "strip"))
4272 : 0 : rx_vlan_strip_set(port_id, on);
4273 : 0 : else if(!strcmp(res->what, "stripq")){
4274 : : uint16_t queue_id = 0;
4275 : :
4276 : : /* No queue_id, return */
4277 : 0 : if(i + 1 >= len) {
4278 : 0 : fprintf(stderr, "must specify (port,queue_id)\n");
4279 : 0 : return;
4280 : : }
4281 : 0 : tmp = strtoul(str + i + 1, NULL, 0);
4282 : : /* If queue_id greater that what 16-bits can represent, return */
4283 : 0 : if(tmp > 0xffff)
4284 : : return;
4285 : :
4286 : 0 : queue_id = (uint16_t)tmp;
4287 : 0 : rx_vlan_strip_set_on_queue(port_id, queue_id, on);
4288 : : }
4289 : 0 : else if (!strcmp(res->what, "filter"))
4290 : 0 : rx_vlan_filter_set(port_id, on);
4291 : 0 : else if (!strcmp(res->what, "qinq_strip"))
4292 : 0 : rx_vlan_qinq_strip_set(port_id, on);
4293 : : else
4294 : 0 : vlan_extend_set(port_id, on);
4295 : :
4296 : : return;
4297 : : }
4298 : :
4299 : : static cmdline_parse_token_string_t cmd_vlan_offload_vlan =
4300 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4301 : : vlan, "vlan");
4302 : : static cmdline_parse_token_string_t cmd_vlan_offload_set =
4303 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4304 : : set, "set");
4305 : : static cmdline_parse_token_string_t cmd_vlan_offload_what =
4306 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4307 : : what, "strip#filter#qinq_strip#extend#stripq");
4308 : : static cmdline_parse_token_string_t cmd_vlan_offload_on =
4309 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4310 : : on, "on#off");
4311 : : static cmdline_parse_token_string_t cmd_vlan_offload_portid =
4312 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result,
4313 : : port_id, NULL);
4314 : :
4315 : : static cmdline_parse_inst_t cmd_vlan_offload = {
4316 : : .f = cmd_vlan_offload_parsed,
4317 : : .data = NULL,
4318 : : .help_str = "vlan set strip|filter|qinq_strip|extend|stripq on|off "
4319 : : "<port_id[,queue_id]>: "
4320 : : "Strip/Filter/QinQ for rx side Extend for both rx/tx sides",
4321 : : .tokens = {
4322 : : (void *)&cmd_vlan_offload_vlan,
4323 : : (void *)&cmd_vlan_offload_set,
4324 : : (void *)&cmd_vlan_offload_what,
4325 : : (void *)&cmd_vlan_offload_on,
4326 : : (void *)&cmd_vlan_offload_portid,
4327 : : NULL,
4328 : : },
4329 : : };
4330 : :
4331 : : /* *** VLAN TPID SET ON A PORT *** */
4332 : : struct cmd_vlan_tpid_result {
4333 : : cmdline_fixed_string_t vlan;
4334 : : cmdline_fixed_string_t set;
4335 : : cmdline_fixed_string_t vlan_type;
4336 : : cmdline_fixed_string_t what;
4337 : : uint16_t tp_id;
4338 : : portid_t port_id;
4339 : : };
4340 : :
4341 : : static void
4342 : 0 : cmd_vlan_tpid_parsed(void *parsed_result,
4343 : : __rte_unused struct cmdline *cl,
4344 : : __rte_unused void *data)
4345 : : {
4346 : : struct cmd_vlan_tpid_result *res = parsed_result;
4347 : : enum rte_vlan_type vlan_type;
4348 : :
4349 : 0 : if (!strcmp(res->vlan_type, "inner"))
4350 : : vlan_type = RTE_ETH_VLAN_TYPE_INNER;
4351 : 0 : else if (!strcmp(res->vlan_type, "outer"))
4352 : : vlan_type = RTE_ETH_VLAN_TYPE_OUTER;
4353 : : else {
4354 : 0 : fprintf(stderr, "Unknown vlan type\n");
4355 : 0 : return;
4356 : : }
4357 : 0 : vlan_tpid_set(res->port_id, vlan_type, res->tp_id);
4358 : : }
4359 : :
4360 : : static cmdline_parse_token_string_t cmd_vlan_tpid_vlan =
4361 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4362 : : vlan, "vlan");
4363 : : static cmdline_parse_token_string_t cmd_vlan_tpid_set =
4364 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4365 : : set, "set");
4366 : : static cmdline_parse_token_string_t cmd_vlan_type =
4367 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4368 : : vlan_type, "inner#outer");
4369 : : static cmdline_parse_token_string_t cmd_vlan_tpid_what =
4370 : : TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result,
4371 : : what, "tpid");
4372 : : static cmdline_parse_token_num_t cmd_vlan_tpid_tpid =
4373 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4374 : : tp_id, RTE_UINT16);
4375 : : static cmdline_parse_token_num_t cmd_vlan_tpid_portid =
4376 : : TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result,
4377 : : port_id, RTE_UINT16);
4378 : :
4379 : : static cmdline_parse_inst_t cmd_vlan_tpid = {
4380 : : .f = cmd_vlan_tpid_parsed,
4381 : : .data = NULL,
4382 : : .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: "
4383 : : "Set the VLAN Ether type",
4384 : : .tokens = {
4385 : : (void *)&cmd_vlan_tpid_vlan,
4386 : : (void *)&cmd_vlan_tpid_set,
4387 : : (void *)&cmd_vlan_type,
4388 : : (void *)&cmd_vlan_tpid_what,
4389 : : (void *)&cmd_vlan_tpid_tpid,
4390 : : (void *)&cmd_vlan_tpid_portid,
4391 : : NULL,
4392 : : },
4393 : : };
4394 : :
4395 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
4396 : : struct cmd_rx_vlan_filter_result {
4397 : : cmdline_fixed_string_t rx_vlan;
4398 : : cmdline_fixed_string_t what;
4399 : : uint16_t vlan_id;
4400 : : portid_t port_id;
4401 : : };
4402 : :
4403 : : static void
4404 : 0 : cmd_rx_vlan_filter_parsed(void *parsed_result,
4405 : : __rte_unused struct cmdline *cl,
4406 : : __rte_unused void *data)
4407 : : {
4408 : : struct cmd_rx_vlan_filter_result *res = parsed_result;
4409 : :
4410 : 0 : if (!strcmp(res->what, "add"))
4411 : 0 : rx_vft_set(res->port_id, res->vlan_id, 1);
4412 : : else
4413 : 0 : rx_vft_set(res->port_id, res->vlan_id, 0);
4414 : 0 : }
4415 : :
4416 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan =
4417 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4418 : : rx_vlan, "rx_vlan");
4419 : : static cmdline_parse_token_string_t cmd_rx_vlan_filter_what =
4420 : : TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result,
4421 : : what, "add#rm");
4422 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid =
4423 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4424 : : vlan_id, RTE_UINT16);
4425 : : static cmdline_parse_token_num_t cmd_rx_vlan_filter_portid =
4426 : : TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result,
4427 : : port_id, RTE_UINT16);
4428 : :
4429 : : static cmdline_parse_inst_t cmd_rx_vlan_filter = {
4430 : : .f = cmd_rx_vlan_filter_parsed,
4431 : : .data = NULL,
4432 : : .help_str = "rx_vlan add|rm <vlan_id> <port_id>: "
4433 : : "Add/Remove a VLAN identifier to/from the set of VLAN "
4434 : : "identifiers filtered by a port",
4435 : : .tokens = {
4436 : : (void *)&cmd_rx_vlan_filter_rx_vlan,
4437 : : (void *)&cmd_rx_vlan_filter_what,
4438 : : (void *)&cmd_rx_vlan_filter_vlanid,
4439 : : (void *)&cmd_rx_vlan_filter_portid,
4440 : : NULL,
4441 : : },
4442 : : };
4443 : :
4444 : : /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4445 : : struct cmd_tx_vlan_set_result {
4446 : : cmdline_fixed_string_t tx_vlan;
4447 : : cmdline_fixed_string_t set;
4448 : : portid_t port_id;
4449 : : uint16_t vlan_id;
4450 : : };
4451 : :
4452 : : static void
4453 : 0 : cmd_tx_vlan_set_parsed(void *parsed_result,
4454 : : __rte_unused struct cmdline *cl,
4455 : : __rte_unused void *data)
4456 : : {
4457 : : struct cmd_tx_vlan_set_result *res = parsed_result;
4458 : :
4459 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4460 : : return;
4461 : :
4462 : 0 : if (!port_is_stopped(res->port_id)) {
4463 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4464 : 0 : return;
4465 : : }
4466 : :
4467 : 0 : tx_vlan_set(res->port_id, res->vlan_id);
4468 : :
4469 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4470 : : }
4471 : :
4472 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan =
4473 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4474 : : tx_vlan, "tx_vlan");
4475 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_set =
4476 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result,
4477 : : set, "set");
4478 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_portid =
4479 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4480 : : port_id, RTE_UINT16);
4481 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid =
4482 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result,
4483 : : vlan_id, RTE_UINT16);
4484 : :
4485 : : static cmdline_parse_inst_t cmd_tx_vlan_set = {
4486 : : .f = cmd_tx_vlan_set_parsed,
4487 : : .data = NULL,
4488 : : .help_str = "tx_vlan set <port_id> <vlan_id>: "
4489 : : "Enable hardware insertion of a single VLAN header "
4490 : : "with a given TAG Identifier in packets sent on a port",
4491 : : .tokens = {
4492 : : (void *)&cmd_tx_vlan_set_tx_vlan,
4493 : : (void *)&cmd_tx_vlan_set_set,
4494 : : (void *)&cmd_tx_vlan_set_portid,
4495 : : (void *)&cmd_tx_vlan_set_vlanid,
4496 : : NULL,
4497 : : },
4498 : : };
4499 : :
4500 : : /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */
4501 : : struct cmd_tx_vlan_set_qinq_result {
4502 : : cmdline_fixed_string_t tx_vlan;
4503 : : cmdline_fixed_string_t set;
4504 : : portid_t port_id;
4505 : : uint16_t vlan_id;
4506 : : uint16_t vlan_id_outer;
4507 : : };
4508 : :
4509 : : static void
4510 : 0 : cmd_tx_vlan_set_qinq_parsed(void *parsed_result,
4511 : : __rte_unused struct cmdline *cl,
4512 : : __rte_unused void *data)
4513 : : {
4514 : : struct cmd_tx_vlan_set_qinq_result *res = parsed_result;
4515 : :
4516 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4517 : : return;
4518 : :
4519 : 0 : if (!port_is_stopped(res->port_id)) {
4520 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4521 : 0 : return;
4522 : : }
4523 : :
4524 : 0 : tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer);
4525 : :
4526 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4527 : : }
4528 : :
4529 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan =
4530 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4531 : : tx_vlan, "tx_vlan");
4532 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set =
4533 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4534 : : set, "set");
4535 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid =
4536 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4537 : : port_id, RTE_UINT16);
4538 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid =
4539 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4540 : : vlan_id, RTE_UINT16);
4541 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer =
4542 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result,
4543 : : vlan_id_outer, RTE_UINT16);
4544 : :
4545 : : static cmdline_parse_inst_t cmd_tx_vlan_set_qinq = {
4546 : : .f = cmd_tx_vlan_set_qinq_parsed,
4547 : : .data = NULL,
4548 : : .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: "
4549 : : "Enable hardware insertion of double VLAN header "
4550 : : "with given TAG Identifiers in packets sent on a port",
4551 : : .tokens = {
4552 : : (void *)&cmd_tx_vlan_set_qinq_tx_vlan,
4553 : : (void *)&cmd_tx_vlan_set_qinq_set,
4554 : : (void *)&cmd_tx_vlan_set_qinq_portid,
4555 : : (void *)&cmd_tx_vlan_set_qinq_vlanid,
4556 : : (void *)&cmd_tx_vlan_set_qinq_vlanid_outer,
4557 : : NULL,
4558 : : },
4559 : : };
4560 : :
4561 : : /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */
4562 : : struct cmd_tx_vlan_set_pvid_result {
4563 : : cmdline_fixed_string_t tx_vlan;
4564 : : cmdline_fixed_string_t set;
4565 : : cmdline_fixed_string_t pvid;
4566 : : portid_t port_id;
4567 : : uint16_t vlan_id;
4568 : : cmdline_fixed_string_t mode;
4569 : : };
4570 : :
4571 : : static void
4572 : 0 : cmd_tx_vlan_set_pvid_parsed(void *parsed_result,
4573 : : __rte_unused struct cmdline *cl,
4574 : : __rte_unused void *data)
4575 : : {
4576 : : struct cmd_tx_vlan_set_pvid_result *res = parsed_result;
4577 : :
4578 : 0 : if (strcmp(res->mode, "on") == 0)
4579 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 1);
4580 : : else
4581 : 0 : tx_vlan_pvid_set(res->port_id, res->vlan_id, 0);
4582 : 0 : }
4583 : :
4584 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan =
4585 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4586 : : tx_vlan, "tx_vlan");
4587 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set =
4588 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4589 : : set, "set");
4590 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid =
4591 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4592 : : pvid, "pvid");
4593 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id =
4594 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4595 : : port_id, RTE_UINT16);
4596 : : static cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id =
4597 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4598 : : vlan_id, RTE_UINT16);
4599 : : static cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode =
4600 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result,
4601 : : mode, "on#off");
4602 : :
4603 : : static cmdline_parse_inst_t cmd_tx_vlan_set_pvid = {
4604 : : .f = cmd_tx_vlan_set_pvid_parsed,
4605 : : .data = NULL,
4606 : : .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off",
4607 : : .tokens = {
4608 : : (void *)&cmd_tx_vlan_set_pvid_tx_vlan,
4609 : : (void *)&cmd_tx_vlan_set_pvid_set,
4610 : : (void *)&cmd_tx_vlan_set_pvid_pvid,
4611 : : (void *)&cmd_tx_vlan_set_pvid_port_id,
4612 : : (void *)&cmd_tx_vlan_set_pvid_vlan_id,
4613 : : (void *)&cmd_tx_vlan_set_pvid_mode,
4614 : : NULL,
4615 : : },
4616 : : };
4617 : :
4618 : : /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */
4619 : : struct cmd_tx_vlan_reset_result {
4620 : : cmdline_fixed_string_t tx_vlan;
4621 : : cmdline_fixed_string_t reset;
4622 : : portid_t port_id;
4623 : : };
4624 : :
4625 : : static void
4626 : 0 : cmd_tx_vlan_reset_parsed(void *parsed_result,
4627 : : __rte_unused struct cmdline *cl,
4628 : : __rte_unused void *data)
4629 : : {
4630 : : struct cmd_tx_vlan_reset_result *res = parsed_result;
4631 : :
4632 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4633 : : return;
4634 : :
4635 : 0 : if (!port_is_stopped(res->port_id)) {
4636 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4637 : 0 : return;
4638 : : }
4639 : :
4640 : 0 : tx_vlan_reset(res->port_id);
4641 : :
4642 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4643 : : }
4644 : :
4645 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan =
4646 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4647 : : tx_vlan, "tx_vlan");
4648 : : static cmdline_parse_token_string_t cmd_tx_vlan_reset_reset =
4649 : : TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result,
4650 : : reset, "reset");
4651 : : static cmdline_parse_token_num_t cmd_tx_vlan_reset_portid =
4652 : : TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result,
4653 : : port_id, RTE_UINT16);
4654 : :
4655 : : static cmdline_parse_inst_t cmd_tx_vlan_reset = {
4656 : : .f = cmd_tx_vlan_reset_parsed,
4657 : : .data = NULL,
4658 : : .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a "
4659 : : "VLAN header in packets sent on a port",
4660 : : .tokens = {
4661 : : (void *)&cmd_tx_vlan_reset_tx_vlan,
4662 : : (void *)&cmd_tx_vlan_reset_reset,
4663 : : (void *)&cmd_tx_vlan_reset_portid,
4664 : : NULL,
4665 : : },
4666 : : };
4667 : :
4668 : :
4669 : : /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */
4670 : : struct cmd_csum_result {
4671 : : cmdline_fixed_string_t csum;
4672 : : cmdline_fixed_string_t mode;
4673 : : cmdline_fixed_string_t proto;
4674 : : cmdline_fixed_string_t hwsw;
4675 : : portid_t port_id;
4676 : : };
4677 : :
4678 : : static void
4679 : 0 : csum_show(int port_id)
4680 : : {
4681 : : struct rte_eth_dev_info dev_info;
4682 : : uint64_t tx_offloads;
4683 : : int ret;
4684 : :
4685 : 0 : tx_offloads = ports[port_id].dev_conf.txmode.offloads;
4686 : 0 : printf("Parse tunnel is %s\n",
4687 : 0 : (ports[port_id].parse_tunnel) ? "on" : "off");
4688 : 0 : printf("IP checksum offload is %s\n",
4689 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw");
4690 : 0 : printf("UDP checksum offload is %s\n",
4691 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw");
4692 : 0 : printf("TCP checksum offload is %s\n",
4693 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw");
4694 : 0 : printf("SCTP checksum offload is %s\n",
4695 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw");
4696 : 0 : printf("Outer-Ip checksum offload is %s\n",
4697 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw");
4698 : 0 : printf("Outer-Udp checksum offload is %s\n",
4699 : 0 : (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw");
4700 : :
4701 : : /* display warnings if configuration is not supported by the NIC */
4702 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
4703 : 0 : if (ret != 0)
4704 : 0 : return;
4705 : :
4706 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) &&
4707 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM) == 0) {
4708 : 0 : fprintf(stderr,
4709 : : "Warning: hardware IP checksum enabled but not supported by port %d\n",
4710 : : port_id);
4711 : : }
4712 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) &&
4713 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) == 0) {
4714 : 0 : fprintf(stderr,
4715 : : "Warning: hardware UDP checksum enabled but not supported by port %d\n",
4716 : : port_id);
4717 : : }
4718 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) &&
4719 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) == 0) {
4720 : 0 : fprintf(stderr,
4721 : : "Warning: hardware TCP checksum enabled but not supported by port %d\n",
4722 : : port_id);
4723 : : }
4724 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) &&
4725 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM) == 0) {
4726 : 0 : fprintf(stderr,
4727 : : "Warning: hardware SCTP checksum enabled but not supported by port %d\n",
4728 : : port_id);
4729 : : }
4730 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) &&
4731 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) {
4732 : 0 : fprintf(stderr,
4733 : : "Warning: hardware outer IP checksum enabled but not supported by port %d\n",
4734 : : port_id);
4735 : : }
4736 : 0 : if ((tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) &&
4737 : 0 : (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
4738 : : == 0) {
4739 : 0 : fprintf(stderr,
4740 : : "Warning: hardware outer UDP checksum enabled but not supported by port %d\n",
4741 : : port_id);
4742 : : }
4743 : : }
4744 : :
4745 : : static void
4746 : : cmd_config_queue_tx_offloads(struct rte_port *port)
4747 : : {
4748 : : int k;
4749 : :
4750 : : /* Apply queue tx offloads configuration */
4751 : 0 : for (k = 0; k < port->dev_info.max_tx_queues; k++)
4752 : 0 : port->txq[k].conf.offloads =
4753 : 0 : port->dev_conf.txmode.offloads;
4754 : : }
4755 : :
4756 : : static void
4757 : 0 : cmd_csum_parsed(void *parsed_result,
4758 : : __rte_unused struct cmdline *cl,
4759 : : __rte_unused void *data)
4760 : : {
4761 : : struct cmd_csum_result *res = parsed_result;
4762 : : int hw = 0;
4763 : : uint64_t csum_offloads = 0;
4764 : : struct rte_eth_dev_info dev_info;
4765 : : int ret;
4766 : :
4767 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN)) {
4768 : 0 : fprintf(stderr, "invalid port %d\n", res->port_id);
4769 : 0 : return;
4770 : : }
4771 : 0 : if (!port_is_stopped(res->port_id)) {
4772 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
4773 : 0 : return;
4774 : : }
4775 : :
4776 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
4777 : 0 : if (ret != 0)
4778 : : return;
4779 : :
4780 : 0 : if (!strcmp(res->mode, "set")) {
4781 : :
4782 : 0 : if (!strcmp(res->hwsw, "hw"))
4783 : : hw = 1;
4784 : :
4785 : 0 : if (!strcmp(res->proto, "ip")) {
4786 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4787 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)) {
4788 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_IPV4_CKSUM;
4789 : : } else {
4790 : 0 : fprintf(stderr,
4791 : : "IP checksum offload is not supported by port %u\n",
4792 : 0 : res->port_id);
4793 : : }
4794 : 0 : } else if (!strcmp(res->proto, "udp")) {
4795 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4796 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM)) {
4797 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_UDP_CKSUM;
4798 : : } else {
4799 : 0 : fprintf(stderr,
4800 : : "UDP checksum offload is not supported by port %u\n",
4801 : 0 : res->port_id);
4802 : : }
4803 : 0 : } else if (!strcmp(res->proto, "tcp")) {
4804 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4805 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM)) {
4806 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
4807 : : } else {
4808 : 0 : fprintf(stderr,
4809 : : "TCP checksum offload is not supported by port %u\n",
4810 : 0 : res->port_id);
4811 : : }
4812 : 0 : } else if (!strcmp(res->proto, "sctp")) {
4813 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4814 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM)) {
4815 : : csum_offloads |= RTE_ETH_TX_OFFLOAD_SCTP_CKSUM;
4816 : : } else {
4817 : 0 : fprintf(stderr,
4818 : : "SCTP checksum offload is not supported by port %u\n",
4819 : 0 : res->port_id);
4820 : : }
4821 : 0 : } else if (!strcmp(res->proto, "outer-ip")) {
4822 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4823 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
4824 : : csum_offloads |=
4825 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM;
4826 : : } else {
4827 : 0 : fprintf(stderr,
4828 : : "Outer IP checksum offload is not supported by port %u\n",
4829 : 0 : res->port_id);
4830 : : }
4831 : 0 : } else if (!strcmp(res->proto, "outer-udp")) {
4832 : 0 : if (hw == 0 || (dev_info.tx_offload_capa &
4833 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)) {
4834 : : csum_offloads |=
4835 : : RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM;
4836 : : } else {
4837 : 0 : fprintf(stderr,
4838 : : "Outer UDP checksum offload is not supported by port %u\n",
4839 : 0 : res->port_id);
4840 : : }
4841 : : }
4842 : :
4843 : 0 : if (hw) {
4844 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
4845 : : csum_offloads;
4846 : : } else {
4847 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
4848 : 0 : (~csum_offloads);
4849 : : }
4850 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
4851 : : }
4852 : 0 : csum_show(res->port_id);
4853 : :
4854 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
4855 : : }
4856 : :
4857 : : static cmdline_parse_token_string_t cmd_csum_csum =
4858 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4859 : : csum, "csum");
4860 : : static cmdline_parse_token_string_t cmd_csum_mode =
4861 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4862 : : mode, "set");
4863 : : static cmdline_parse_token_string_t cmd_csum_proto =
4864 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4865 : : proto, "ip#tcp#udp#sctp#outer-ip#outer-udp");
4866 : : static cmdline_parse_token_string_t cmd_csum_hwsw =
4867 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4868 : : hwsw, "hw#sw");
4869 : : static cmdline_parse_token_num_t cmd_csum_portid =
4870 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_result,
4871 : : port_id, RTE_UINT16);
4872 : :
4873 : : static cmdline_parse_inst_t cmd_csum_set = {
4874 : : .f = cmd_csum_parsed,
4875 : : .data = NULL,
4876 : : .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: "
4877 : : "Enable/Disable hardware calculation of L3/L4 checksum when "
4878 : : "using csum forward engine",
4879 : : .tokens = {
4880 : : (void *)&cmd_csum_csum,
4881 : : (void *)&cmd_csum_mode,
4882 : : (void *)&cmd_csum_proto,
4883 : : (void *)&cmd_csum_hwsw,
4884 : : (void *)&cmd_csum_portid,
4885 : : NULL,
4886 : : },
4887 : : };
4888 : :
4889 : : static cmdline_parse_token_string_t cmd_csum_mode_show =
4890 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_result,
4891 : : mode, "show");
4892 : :
4893 : : static cmdline_parse_inst_t cmd_csum_show = {
4894 : : .f = cmd_csum_parsed,
4895 : : .data = NULL,
4896 : : .help_str = "csum show <port_id>: Show checksum offload configuration",
4897 : : .tokens = {
4898 : : (void *)&cmd_csum_csum,
4899 : : (void *)&cmd_csum_mode_show,
4900 : : (void *)&cmd_csum_portid,
4901 : : NULL,
4902 : : },
4903 : : };
4904 : :
4905 : : /* Enable/disable tunnel parsing */
4906 : : struct cmd_csum_tunnel_result {
4907 : : cmdline_fixed_string_t csum;
4908 : : cmdline_fixed_string_t parse;
4909 : : cmdline_fixed_string_t onoff;
4910 : : portid_t port_id;
4911 : : };
4912 : :
4913 : : static void
4914 : 0 : cmd_csum_tunnel_parsed(void *parsed_result,
4915 : : __rte_unused struct cmdline *cl,
4916 : : __rte_unused void *data)
4917 : : {
4918 : : struct cmd_csum_tunnel_result *res = parsed_result;
4919 : :
4920 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4921 : : return;
4922 : :
4923 : 0 : if (!strcmp(res->onoff, "on"))
4924 : 0 : ports[res->port_id].parse_tunnel = 1;
4925 : : else
4926 : 0 : ports[res->port_id].parse_tunnel = 0;
4927 : :
4928 : 0 : csum_show(res->port_id);
4929 : : }
4930 : :
4931 : : static cmdline_parse_token_string_t cmd_csum_tunnel_csum =
4932 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4933 : : csum, "csum");
4934 : : static cmdline_parse_token_string_t cmd_csum_tunnel_parse =
4935 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4936 : : parse, "parse-tunnel");
4937 : : static cmdline_parse_token_string_t cmd_csum_tunnel_onoff =
4938 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result,
4939 : : onoff, "on#off");
4940 : : static cmdline_parse_token_num_t cmd_csum_tunnel_portid =
4941 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result,
4942 : : port_id, RTE_UINT16);
4943 : :
4944 : : static cmdline_parse_inst_t cmd_csum_tunnel = {
4945 : : .f = cmd_csum_tunnel_parsed,
4946 : : .data = NULL,
4947 : : .help_str = "csum parse-tunnel on|off <port_id>: "
4948 : : "Enable/Disable parsing of tunnels for csum engine",
4949 : : .tokens = {
4950 : : (void *)&cmd_csum_tunnel_csum,
4951 : : (void *)&cmd_csum_tunnel_parse,
4952 : : (void *)&cmd_csum_tunnel_onoff,
4953 : : (void *)&cmd_csum_tunnel_portid,
4954 : : NULL,
4955 : : },
4956 : : };
4957 : :
4958 : : struct cmd_csum_mac_swap_result {
4959 : : cmdline_fixed_string_t csum;
4960 : : cmdline_fixed_string_t parse;
4961 : : cmdline_fixed_string_t onoff;
4962 : : portid_t port_id;
4963 : : };
4964 : :
4965 : : static void
4966 : 0 : cmd_csum_mac_swap_parsed(void *parsed_result,
4967 : : __rte_unused struct cmdline *cl,
4968 : : __rte_unused void *data)
4969 : : {
4970 : : struct cmd_csum_mac_swap_result *res = parsed_result;
4971 : :
4972 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
4973 : : return;
4974 : 0 : if (strcmp(res->onoff, "on") == 0)
4975 : 0 : ports[res->port_id].fwd_mac_swap = 1;
4976 : : else
4977 : 0 : ports[res->port_id].fwd_mac_swap = 0;
4978 : : }
4979 : :
4980 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_csum =
4981 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4982 : : csum, "csum");
4983 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_parse =
4984 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4985 : : parse, "mac-swap");
4986 : : static cmdline_parse_token_string_t cmd_csum_mac_swap_onoff =
4987 : : TOKEN_STRING_INITIALIZER(struct cmd_csum_mac_swap_result,
4988 : : onoff, "on#off");
4989 : : static cmdline_parse_token_num_t cmd_csum_mac_swap_portid =
4990 : : TOKEN_NUM_INITIALIZER(struct cmd_csum_mac_swap_result,
4991 : : port_id, RTE_UINT16);
4992 : :
4993 : : static cmdline_parse_inst_t cmd_csum_mac_swap = {
4994 : : .f = cmd_csum_mac_swap_parsed,
4995 : : .data = NULL,
4996 : : .help_str = "csum mac-swap on|off <port_id>: "
4997 : : "Enable/Disable forward mac address swap",
4998 : : .tokens = {
4999 : : (void *)&cmd_csum_mac_swap_csum,
5000 : : (void *)&cmd_csum_mac_swap_parse,
5001 : : (void *)&cmd_csum_mac_swap_onoff,
5002 : : (void *)&cmd_csum_mac_swap_portid,
5003 : : NULL,
5004 : : },
5005 : : };
5006 : :
5007 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */
5008 : : struct cmd_tso_set_result {
5009 : : cmdline_fixed_string_t tso;
5010 : : cmdline_fixed_string_t mode;
5011 : : uint16_t tso_segsz;
5012 : : portid_t port_id;
5013 : : };
5014 : :
5015 : : static void
5016 : 0 : cmd_tso_set_parsed(void *parsed_result,
5017 : : __rte_unused struct cmdline *cl,
5018 : : __rte_unused void *data)
5019 : : {
5020 : : struct cmd_tso_set_result *res = parsed_result;
5021 : : struct rte_eth_dev_info dev_info;
5022 : : uint64_t offloads;
5023 : : int ret;
5024 : :
5025 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5026 : 0 : return;
5027 : 0 : if (!port_is_stopped(res->port_id)) {
5028 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5029 : 0 : return;
5030 : : }
5031 : :
5032 : 0 : if (!strcmp(res->mode, "set"))
5033 : 0 : ports[res->port_id].tso_segsz = res->tso_segsz;
5034 : :
5035 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5036 : 0 : if (ret != 0)
5037 : : return;
5038 : :
5039 : 0 : if (ports[res->port_id].tso_segsz != 0) {
5040 : 0 : if ((dev_info.tx_offload_capa & (RTE_ETH_TX_OFFLOAD_TCP_TSO |
5041 : : RTE_ETH_TX_OFFLOAD_UDP_TSO)) == 0) {
5042 : 0 : fprintf(stderr, "Error: both TSO and UFO are not supported by port %d\n",
5043 : : res->port_id);
5044 : 0 : return;
5045 : : }
5046 : : /* display warnings if configuration is not supported by the NIC */
5047 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) == 0)
5048 : 0 : printf("Warning: port %d doesn't support TSO\n", res->port_id);
5049 : 0 : if ((dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) == 0)
5050 : 0 : printf("Warning: port %d doesn't support UFO\n", res->port_id);
5051 : : }
5052 : :
5053 : 0 : if (ports[res->port_id].tso_segsz == 0) {
5054 : 0 : ports[res->port_id].dev_conf.txmode.offloads &=
5055 : : ~(RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_UDP_TSO);
5056 : : printf("TSO and UFO for non-tunneled packets is disabled\n");
5057 : : } else {
5058 : 0 : offloads = (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_TCP_TSO) ?
5059 : : RTE_ETH_TX_OFFLOAD_TCP_TSO : 0;
5060 : 0 : offloads |= (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TSO) ?
5061 : 0 : RTE_ETH_TX_OFFLOAD_UDP_TSO : 0;
5062 : 0 : ports[res->port_id].dev_conf.txmode.offloads |= offloads;
5063 : 0 : printf("segment size for non-tunneled packets is %d\n",
5064 : : ports[res->port_id].tso_segsz);
5065 : : }
5066 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5067 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5068 : : }
5069 : :
5070 : : static cmdline_parse_token_string_t cmd_tso_set_tso =
5071 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5072 : : tso, "tso");
5073 : : static cmdline_parse_token_string_t cmd_tso_set_mode =
5074 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5075 : : mode, "set");
5076 : : static cmdline_parse_token_num_t cmd_tso_set_tso_segsz =
5077 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5078 : : tso_segsz, RTE_UINT16);
5079 : : static cmdline_parse_token_num_t cmd_tso_set_portid =
5080 : : TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result,
5081 : : port_id, RTE_UINT16);
5082 : :
5083 : : static cmdline_parse_inst_t cmd_tso_set = {
5084 : : .f = cmd_tso_set_parsed,
5085 : : .data = NULL,
5086 : : .help_str = "tso set <tso_segsz> <port_id>: "
5087 : : "Set TSO segment size of non-tunneled packets for csum engine "
5088 : : "(0 to disable)",
5089 : : .tokens = {
5090 : : (void *)&cmd_tso_set_tso,
5091 : : (void *)&cmd_tso_set_mode,
5092 : : (void *)&cmd_tso_set_tso_segsz,
5093 : : (void *)&cmd_tso_set_portid,
5094 : : NULL,
5095 : : },
5096 : : };
5097 : :
5098 : : static cmdline_parse_token_string_t cmd_tso_show_mode =
5099 : : TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result,
5100 : : mode, "show");
5101 : :
5102 : :
5103 : : static cmdline_parse_inst_t cmd_tso_show = {
5104 : : .f = cmd_tso_set_parsed,
5105 : : .data = NULL,
5106 : : .help_str = "tso show <port_id>: "
5107 : : "Show TSO segment size of non-tunneled packets for csum engine",
5108 : : .tokens = {
5109 : : (void *)&cmd_tso_set_tso,
5110 : : (void *)&cmd_tso_show_mode,
5111 : : (void *)&cmd_tso_set_portid,
5112 : : NULL,
5113 : : },
5114 : : };
5115 : :
5116 : : /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */
5117 : : struct cmd_tunnel_tso_set_result {
5118 : : cmdline_fixed_string_t tso;
5119 : : cmdline_fixed_string_t mode;
5120 : : uint16_t tso_segsz;
5121 : : portid_t port_id;
5122 : : };
5123 : :
5124 : : static void
5125 : 0 : check_tunnel_tso_nic_support(portid_t port_id, uint64_t tx_offload_capa)
5126 : : {
5127 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO))
5128 : 0 : printf("Warning: VXLAN TUNNEL TSO not supported therefore not enabled for port %d\n",
5129 : : port_id);
5130 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO))
5131 : 0 : printf("Warning: GRE TUNNEL TSO not supported therefore not enabled for port %d\n",
5132 : : port_id);
5133 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO))
5134 : 0 : printf("Warning: IPIP TUNNEL TSO not supported therefore not enabled for port %d\n",
5135 : : port_id);
5136 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO))
5137 : 0 : printf("Warning: GENEVE TUNNEL TSO not supported therefore not enabled for port %d\n",
5138 : : port_id);
5139 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_IP_TNL_TSO))
5140 : 0 : printf("Warning: IP TUNNEL TSO not supported therefore not enabled for port %d\n",
5141 : : port_id);
5142 : 0 : if (!(tx_offload_capa & RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO))
5143 : 0 : printf("Warning: UDP TUNNEL TSO not supported therefore not enabled for port %d\n",
5144 : : port_id);
5145 : 0 : }
5146 : :
5147 : : static void
5148 : 0 : cmd_tunnel_tso_set_parsed(void *parsed_result,
5149 : : __rte_unused struct cmdline *cl,
5150 : : __rte_unused void *data)
5151 : : {
5152 : : struct cmd_tunnel_tso_set_result *res = parsed_result;
5153 : : struct rte_eth_dev_info dev_info;
5154 : : uint64_t all_tunnel_tso = RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
5155 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
5156 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
5157 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO |
5158 : : RTE_ETH_TX_OFFLOAD_IP_TNL_TSO |
5159 : : RTE_ETH_TX_OFFLOAD_UDP_TNL_TSO;
5160 : : int ret;
5161 : :
5162 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
5163 : 0 : return;
5164 : 0 : if (!port_is_stopped(res->port_id)) {
5165 : 0 : fprintf(stderr, "Please stop port %d first\n", res->port_id);
5166 : 0 : return;
5167 : : }
5168 : :
5169 : 0 : if (!strcmp(res->mode, "set"))
5170 : 0 : ports[res->port_id].tunnel_tso_segsz = res->tso_segsz;
5171 : :
5172 : 0 : if (ports[res->port_id].tunnel_tso_segsz == 0) {
5173 : 0 : ports[res->port_id].dev_conf.txmode.offloads &= ~all_tunnel_tso;
5174 : : printf("TSO for tunneled packets is disabled\n");
5175 : : } else {
5176 : 0 : ret = eth_dev_info_get_print_err(res->port_id, &dev_info);
5177 : 0 : if (ret != 0)
5178 : : return;
5179 : :
5180 : 0 : if ((all_tunnel_tso & dev_info.tx_offload_capa) == 0) {
5181 : 0 : fprintf(stderr, "Error: port=%u don't support tunnel TSO offloads.\n",
5182 : 0 : res->port_id);
5183 : 0 : return;
5184 : : }
5185 : :
5186 : : /* Below conditions are needed to make it work:
5187 : : * (1) tunnel TSO is supported by the NIC;
5188 : : * (2) "csum parse_tunnel" must be set so that tunneled pkts
5189 : : * are recognized;
5190 : : * (3) for tunneled pkts with outer L3 of IPv4,
5191 : : * "csum set outer-ip" must be set to hw, because after tso,
5192 : : * total_len of outer IP header is changed, and the checksum
5193 : : * of outer IP header calculated by sw should be wrong; that
5194 : : * is not necessary for IPv6 tunneled pkts because there's no
5195 : : * checksum in IP header anymore.
5196 : : */
5197 : 0 : if (!ports[res->port_id].parse_tunnel) {
5198 : 0 : fprintf(stderr,
5199 : : "Error: csum parse_tunnel must be set so that tunneled packets are recognized\n");
5200 : 0 : return;
5201 : : }
5202 : 0 : if (!(ports[res->port_id].dev_conf.txmode.offloads &
5203 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM)) {
5204 : 0 : fprintf(stderr,
5205 : : "Error: csum set outer-ip must be set to hw if outer L3 is IPv4; not necessary for IPv6\n");
5206 : 0 : return;
5207 : : }
5208 : :
5209 : 0 : check_tunnel_tso_nic_support(res->port_id, dev_info.tx_offload_capa);
5210 : 0 : ports[res->port_id].dev_conf.txmode.offloads |=
5211 : 0 : (all_tunnel_tso & dev_info.tx_offload_capa);
5212 : 0 : printf("TSO segment size for tunneled packets is %d\n",
5213 : 0 : ports[res->port_id].tunnel_tso_segsz);
5214 : : }
5215 : :
5216 : 0 : cmd_config_queue_tx_offloads(&ports[res->port_id]);
5217 : 0 : cmd_reconfig_device_queue(res->port_id, 1, 1);
5218 : : }
5219 : :
5220 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_tso =
5221 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5222 : : tso, "tunnel_tso");
5223 : : static cmdline_parse_token_string_t cmd_tunnel_tso_set_mode =
5224 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5225 : : mode, "set");
5226 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz =
5227 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5228 : : tso_segsz, RTE_UINT16);
5229 : : static cmdline_parse_token_num_t cmd_tunnel_tso_set_portid =
5230 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result,
5231 : : port_id, RTE_UINT16);
5232 : :
5233 : : static cmdline_parse_inst_t cmd_tunnel_tso_set = {
5234 : : .f = cmd_tunnel_tso_set_parsed,
5235 : : .data = NULL,
5236 : : .help_str = "tunnel_tso set <tso_segsz> <port_id>: "
5237 : : "Set TSO segment size of tunneled packets for csum engine "
5238 : : "(0 to disable)",
5239 : : .tokens = {
5240 : : (void *)&cmd_tunnel_tso_set_tso,
5241 : : (void *)&cmd_tunnel_tso_set_mode,
5242 : : (void *)&cmd_tunnel_tso_set_tso_segsz,
5243 : : (void *)&cmd_tunnel_tso_set_portid,
5244 : : NULL,
5245 : : },
5246 : : };
5247 : :
5248 : : static cmdline_parse_token_string_t cmd_tunnel_tso_show_mode =
5249 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result,
5250 : : mode, "show");
5251 : :
5252 : :
5253 : : static cmdline_parse_inst_t cmd_tunnel_tso_show = {
5254 : : .f = cmd_tunnel_tso_set_parsed,
5255 : : .data = NULL,
5256 : : .help_str = "tunnel_tso show <port_id> "
5257 : : "Show TSO segment size of tunneled packets for csum engine",
5258 : : .tokens = {
5259 : : (void *)&cmd_tunnel_tso_set_tso,
5260 : : (void *)&cmd_tunnel_tso_show_mode,
5261 : : (void *)&cmd_tunnel_tso_set_portid,
5262 : : NULL,
5263 : : },
5264 : : };
5265 : :
5266 : : #ifdef RTE_LIB_GRO
5267 : : /* *** SET GRO FOR A PORT *** */
5268 : : struct cmd_gro_enable_result {
5269 : : cmdline_fixed_string_t cmd_set;
5270 : : cmdline_fixed_string_t cmd_port;
5271 : : cmdline_fixed_string_t cmd_keyword;
5272 : : cmdline_fixed_string_t cmd_onoff;
5273 : : portid_t cmd_pid;
5274 : : };
5275 : :
5276 : : static void
5277 : 0 : cmd_gro_enable_parsed(void *parsed_result,
5278 : : __rte_unused struct cmdline *cl,
5279 : : __rte_unused void *data)
5280 : : {
5281 : : struct cmd_gro_enable_result *res;
5282 : :
5283 : : res = parsed_result;
5284 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5285 : 0 : setup_gro(res->cmd_onoff, res->cmd_pid);
5286 : 0 : }
5287 : :
5288 : : static cmdline_parse_token_string_t cmd_gro_enable_set =
5289 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5290 : : cmd_set, "set");
5291 : : static cmdline_parse_token_string_t cmd_gro_enable_port =
5292 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5293 : : cmd_keyword, "port");
5294 : : static cmdline_parse_token_num_t cmd_gro_enable_pid =
5295 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result,
5296 : : cmd_pid, RTE_UINT16);
5297 : : static cmdline_parse_token_string_t cmd_gro_enable_keyword =
5298 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5299 : : cmd_keyword, "gro");
5300 : : static cmdline_parse_token_string_t cmd_gro_enable_onoff =
5301 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result,
5302 : : cmd_onoff, "on#off");
5303 : :
5304 : : static cmdline_parse_inst_t cmd_gro_enable = {
5305 : : .f = cmd_gro_enable_parsed,
5306 : : .data = NULL,
5307 : : .help_str = "set port <port_id> gro on|off",
5308 : : .tokens = {
5309 : : (void *)&cmd_gro_enable_set,
5310 : : (void *)&cmd_gro_enable_port,
5311 : : (void *)&cmd_gro_enable_pid,
5312 : : (void *)&cmd_gro_enable_keyword,
5313 : : (void *)&cmd_gro_enable_onoff,
5314 : : NULL,
5315 : : },
5316 : : };
5317 : :
5318 : : /* *** DISPLAY GRO CONFIGURATION *** */
5319 : : struct cmd_gro_show_result {
5320 : : cmdline_fixed_string_t cmd_show;
5321 : : cmdline_fixed_string_t cmd_port;
5322 : : cmdline_fixed_string_t cmd_keyword;
5323 : : portid_t cmd_pid;
5324 : : };
5325 : :
5326 : : static void
5327 : 0 : cmd_gro_show_parsed(void *parsed_result,
5328 : : __rte_unused struct cmdline *cl,
5329 : : __rte_unused void *data)
5330 : : {
5331 : : struct cmd_gro_show_result *res;
5332 : :
5333 : : res = parsed_result;
5334 : 0 : if (!strcmp(res->cmd_keyword, "gro"))
5335 : 0 : show_gro(res->cmd_pid);
5336 : 0 : }
5337 : :
5338 : : static cmdline_parse_token_string_t cmd_gro_show_show =
5339 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5340 : : cmd_show, "show");
5341 : : static cmdline_parse_token_string_t cmd_gro_show_port =
5342 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5343 : : cmd_port, "port");
5344 : : static cmdline_parse_token_num_t cmd_gro_show_pid =
5345 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result,
5346 : : cmd_pid, RTE_UINT16);
5347 : : static cmdline_parse_token_string_t cmd_gro_show_keyword =
5348 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result,
5349 : : cmd_keyword, "gro");
5350 : :
5351 : : static cmdline_parse_inst_t cmd_gro_show = {
5352 : : .f = cmd_gro_show_parsed,
5353 : : .data = NULL,
5354 : : .help_str = "show port <port_id> gro",
5355 : : .tokens = {
5356 : : (void *)&cmd_gro_show_show,
5357 : : (void *)&cmd_gro_show_port,
5358 : : (void *)&cmd_gro_show_pid,
5359 : : (void *)&cmd_gro_show_keyword,
5360 : : NULL,
5361 : : },
5362 : : };
5363 : :
5364 : : /* *** SET FLUSH CYCLES FOR GRO *** */
5365 : : struct cmd_gro_flush_result {
5366 : : cmdline_fixed_string_t cmd_set;
5367 : : cmdline_fixed_string_t cmd_keyword;
5368 : : cmdline_fixed_string_t cmd_flush;
5369 : : uint8_t cmd_cycles;
5370 : : };
5371 : :
5372 : : static void
5373 : 0 : cmd_gro_flush_parsed(void *parsed_result,
5374 : : __rte_unused struct cmdline *cl,
5375 : : __rte_unused void *data)
5376 : : {
5377 : : struct cmd_gro_flush_result *res;
5378 : :
5379 : : res = parsed_result;
5380 : 0 : if ((!strcmp(res->cmd_keyword, "gro")) &&
5381 : 0 : (!strcmp(res->cmd_flush, "flush")))
5382 : 0 : setup_gro_flush_cycles(res->cmd_cycles);
5383 : 0 : }
5384 : :
5385 : : static cmdline_parse_token_string_t cmd_gro_flush_set =
5386 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5387 : : cmd_set, "set");
5388 : : static cmdline_parse_token_string_t cmd_gro_flush_keyword =
5389 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5390 : : cmd_keyword, "gro");
5391 : : static cmdline_parse_token_string_t cmd_gro_flush_flush =
5392 : : TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result,
5393 : : cmd_flush, "flush");
5394 : : static cmdline_parse_token_num_t cmd_gro_flush_cycles =
5395 : : TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result,
5396 : : cmd_cycles, RTE_UINT8);
5397 : :
5398 : : static cmdline_parse_inst_t cmd_gro_flush = {
5399 : : .f = cmd_gro_flush_parsed,
5400 : : .data = NULL,
5401 : : .help_str = "set gro flush <cycles>",
5402 : : .tokens = {
5403 : : (void *)&cmd_gro_flush_set,
5404 : : (void *)&cmd_gro_flush_keyword,
5405 : : (void *)&cmd_gro_flush_flush,
5406 : : (void *)&cmd_gro_flush_cycles,
5407 : : NULL,
5408 : : },
5409 : : };
5410 : : #endif /* RTE_LIB_GRO */
5411 : :
5412 : : #ifdef RTE_LIB_GSO
5413 : : /* *** ENABLE/DISABLE GSO *** */
5414 : : struct cmd_gso_enable_result {
5415 : : cmdline_fixed_string_t cmd_set;
5416 : : cmdline_fixed_string_t cmd_port;
5417 : : cmdline_fixed_string_t cmd_keyword;
5418 : : cmdline_fixed_string_t cmd_mode;
5419 : : portid_t cmd_pid;
5420 : : };
5421 : :
5422 : : static void
5423 : 0 : cmd_gso_enable_parsed(void *parsed_result,
5424 : : __rte_unused struct cmdline *cl,
5425 : : __rte_unused void *data)
5426 : : {
5427 : : struct cmd_gso_enable_result *res;
5428 : :
5429 : : res = parsed_result;
5430 : 0 : if (!strcmp(res->cmd_keyword, "gso"))
5431 : 0 : setup_gso(res->cmd_mode, res->cmd_pid);
5432 : 0 : }
5433 : :
5434 : : static cmdline_parse_token_string_t cmd_gso_enable_set =
5435 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5436 : : cmd_set, "set");
5437 : : static cmdline_parse_token_string_t cmd_gso_enable_port =
5438 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5439 : : cmd_port, "port");
5440 : : static cmdline_parse_token_string_t cmd_gso_enable_keyword =
5441 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5442 : : cmd_keyword, "gso");
5443 : : static cmdline_parse_token_string_t cmd_gso_enable_mode =
5444 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result,
5445 : : cmd_mode, "on#off");
5446 : : static cmdline_parse_token_num_t cmd_gso_enable_pid =
5447 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result,
5448 : : cmd_pid, RTE_UINT16);
5449 : :
5450 : : static cmdline_parse_inst_t cmd_gso_enable = {
5451 : : .f = cmd_gso_enable_parsed,
5452 : : .data = NULL,
5453 : : .help_str = "set port <port_id> gso on|off",
5454 : : .tokens = {
5455 : : (void *)&cmd_gso_enable_set,
5456 : : (void *)&cmd_gso_enable_port,
5457 : : (void *)&cmd_gso_enable_pid,
5458 : : (void *)&cmd_gso_enable_keyword,
5459 : : (void *)&cmd_gso_enable_mode,
5460 : : NULL,
5461 : : },
5462 : : };
5463 : :
5464 : : /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */
5465 : : struct cmd_gso_size_result {
5466 : : cmdline_fixed_string_t cmd_set;
5467 : : cmdline_fixed_string_t cmd_keyword;
5468 : : cmdline_fixed_string_t cmd_segsz;
5469 : : uint16_t cmd_size;
5470 : : };
5471 : :
5472 : : static void
5473 : 0 : cmd_gso_size_parsed(void *parsed_result,
5474 : : __rte_unused struct cmdline *cl,
5475 : : __rte_unused void *data)
5476 : : {
5477 : : struct cmd_gso_size_result *res = parsed_result;
5478 : :
5479 : 0 : if (test_done == 0) {
5480 : 0 : fprintf(stderr,
5481 : : "Before setting GSO segsz, please first stop forwarding\n");
5482 : 0 : return;
5483 : : }
5484 : :
5485 : 0 : if (!strcmp(res->cmd_keyword, "gso") &&
5486 : 0 : !strcmp(res->cmd_segsz, "segsz")) {
5487 : 0 : if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN)
5488 : 0 : fprintf(stderr,
5489 : : "gso_size should be larger than %zu. Please input a legal value\n",
5490 : : RTE_GSO_SEG_SIZE_MIN);
5491 : : else
5492 : 0 : gso_max_segment_size = res->cmd_size;
5493 : : }
5494 : : }
5495 : :
5496 : : static cmdline_parse_token_string_t cmd_gso_size_set =
5497 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5498 : : cmd_set, "set");
5499 : : static cmdline_parse_token_string_t cmd_gso_size_keyword =
5500 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5501 : : cmd_keyword, "gso");
5502 : : static cmdline_parse_token_string_t cmd_gso_size_segsz =
5503 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result,
5504 : : cmd_segsz, "segsz");
5505 : : static cmdline_parse_token_num_t cmd_gso_size_size =
5506 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result,
5507 : : cmd_size, RTE_UINT16);
5508 : :
5509 : : static cmdline_parse_inst_t cmd_gso_size = {
5510 : : .f = cmd_gso_size_parsed,
5511 : : .data = NULL,
5512 : : .help_str = "set gso segsz <length>",
5513 : : .tokens = {
5514 : : (void *)&cmd_gso_size_set,
5515 : : (void *)&cmd_gso_size_keyword,
5516 : : (void *)&cmd_gso_size_segsz,
5517 : : (void *)&cmd_gso_size_size,
5518 : : NULL,
5519 : : },
5520 : : };
5521 : :
5522 : : /* *** SHOW GSO CONFIGURATION *** */
5523 : : struct cmd_gso_show_result {
5524 : : cmdline_fixed_string_t cmd_show;
5525 : : cmdline_fixed_string_t cmd_port;
5526 : : cmdline_fixed_string_t cmd_keyword;
5527 : : portid_t cmd_pid;
5528 : : };
5529 : :
5530 : : static void
5531 : 0 : cmd_gso_show_parsed(void *parsed_result,
5532 : : __rte_unused struct cmdline *cl,
5533 : : __rte_unused void *data)
5534 : : {
5535 : : struct cmd_gso_show_result *res = parsed_result;
5536 : :
5537 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
5538 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
5539 : 0 : return;
5540 : : }
5541 : 0 : if (!strcmp(res->cmd_keyword, "gso")) {
5542 : 0 : if (gso_ports[res->cmd_pid].enable) {
5543 : 0 : printf("Max GSO'd packet size: %uB\n"
5544 : : "Supported GSO types: TCP/IPv4, "
5545 : : "UDP/IPv4, VxLAN with inner "
5546 : : "TCP/IPv4 packet, GRE with inner "
5547 : : "TCP/IPv4 packet\n",
5548 : : gso_max_segment_size);
5549 : : } else
5550 : : printf("GSO is not enabled on Port %u\n", res->cmd_pid);
5551 : : }
5552 : : }
5553 : :
5554 : : static cmdline_parse_token_string_t cmd_gso_show_show =
5555 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5556 : : cmd_show, "show");
5557 : : static cmdline_parse_token_string_t cmd_gso_show_port =
5558 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5559 : : cmd_port, "port");
5560 : : static cmdline_parse_token_string_t cmd_gso_show_keyword =
5561 : : TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result,
5562 : : cmd_keyword, "gso");
5563 : : static cmdline_parse_token_num_t cmd_gso_show_pid =
5564 : : TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result,
5565 : : cmd_pid, RTE_UINT16);
5566 : :
5567 : : static cmdline_parse_inst_t cmd_gso_show = {
5568 : : .f = cmd_gso_show_parsed,
5569 : : .data = NULL,
5570 : : .help_str = "show port <port_id> gso",
5571 : : .tokens = {
5572 : : (void *)&cmd_gso_show_show,
5573 : : (void *)&cmd_gso_show_port,
5574 : : (void *)&cmd_gso_show_pid,
5575 : : (void *)&cmd_gso_show_keyword,
5576 : : NULL,
5577 : : },
5578 : : };
5579 : : #endif /* RTE_LIB_GSO */
5580 : :
5581 : : /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */
5582 : : struct cmd_set_flush_rx {
5583 : : cmdline_fixed_string_t set;
5584 : : cmdline_fixed_string_t flush_rx;
5585 : : cmdline_fixed_string_t mode;
5586 : : };
5587 : :
5588 : : static void
5589 : 0 : cmd_set_flush_rx_parsed(void *parsed_result,
5590 : : __rte_unused struct cmdline *cl,
5591 : : __rte_unused void *data)
5592 : : {
5593 : : struct cmd_set_flush_rx *res = parsed_result;
5594 : :
5595 : 0 : if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) {
5596 : : printf("multi-process doesn't support to flush Rx queues.\n");
5597 : 0 : return;
5598 : : }
5599 : :
5600 : 0 : no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5601 : : }
5602 : :
5603 : : static cmdline_parse_token_string_t cmd_setflushrx_set =
5604 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5605 : : set, "set");
5606 : : static cmdline_parse_token_string_t cmd_setflushrx_flush_rx =
5607 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5608 : : flush_rx, "flush_rx");
5609 : : static cmdline_parse_token_string_t cmd_setflushrx_mode =
5610 : : TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx,
5611 : : mode, "on#off");
5612 : :
5613 : :
5614 : : static cmdline_parse_inst_t cmd_set_flush_rx = {
5615 : : .f = cmd_set_flush_rx_parsed,
5616 : : .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams",
5617 : : .data = NULL,
5618 : : .tokens = {
5619 : : (void *)&cmd_setflushrx_set,
5620 : : (void *)&cmd_setflushrx_flush_rx,
5621 : : (void *)&cmd_setflushrx_mode,
5622 : : NULL,
5623 : : },
5624 : : };
5625 : :
5626 : : /* *** ENABLE/DISABLE LINK STATUS CHECK *** */
5627 : : struct cmd_set_link_check {
5628 : : cmdline_fixed_string_t set;
5629 : : cmdline_fixed_string_t link_check;
5630 : : cmdline_fixed_string_t mode;
5631 : : };
5632 : :
5633 : : static void
5634 : 0 : cmd_set_link_check_parsed(void *parsed_result,
5635 : : __rte_unused struct cmdline *cl,
5636 : : __rte_unused void *data)
5637 : : {
5638 : : struct cmd_set_link_check *res = parsed_result;
5639 : 0 : no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1);
5640 : 0 : }
5641 : :
5642 : : static cmdline_parse_token_string_t cmd_setlinkcheck_set =
5643 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5644 : : set, "set");
5645 : : static cmdline_parse_token_string_t cmd_setlinkcheck_link_check =
5646 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5647 : : link_check, "link_check");
5648 : : static cmdline_parse_token_string_t cmd_setlinkcheck_mode =
5649 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_check,
5650 : : mode, "on#off");
5651 : :
5652 : :
5653 : : static cmdline_parse_inst_t cmd_set_link_check = {
5654 : : .f = cmd_set_link_check_parsed,
5655 : : .help_str = "set link_check on|off: Enable/Disable link status check "
5656 : : "when starting/stopping a port",
5657 : : .data = NULL,
5658 : : .tokens = {
5659 : : (void *)&cmd_setlinkcheck_set,
5660 : : (void *)&cmd_setlinkcheck_link_check,
5661 : : (void *)&cmd_setlinkcheck_mode,
5662 : : NULL,
5663 : : },
5664 : : };
5665 : :
5666 : : /* *** SET FORWARDING MODE *** */
5667 : : struct cmd_set_fwd_mode_result {
5668 : : cmdline_fixed_string_t set;
5669 : : cmdline_fixed_string_t fwd;
5670 : : cmdline_fixed_string_t mode;
5671 : : };
5672 : :
5673 : 0 : static void cmd_set_fwd_mode_parsed(void *parsed_result,
5674 : : __rte_unused struct cmdline *cl,
5675 : : __rte_unused void *data)
5676 : : {
5677 : : struct cmd_set_fwd_mode_result *res = parsed_result;
5678 : :
5679 : 0 : retry_enabled = 0;
5680 : 0 : set_pkt_forwarding_mode(res->mode);
5681 : 0 : }
5682 : :
5683 : : static cmdline_parse_token_string_t cmd_setfwd_set =
5684 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set");
5685 : : static cmdline_parse_token_string_t cmd_setfwd_fwd =
5686 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd");
5687 : : static cmdline_parse_token_string_t cmd_setfwd_mode =
5688 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode,
5689 : : "" /* defined at init */);
5690 : :
5691 : : static cmdline_parse_inst_t cmd_set_fwd_mode = {
5692 : : .f = cmd_set_fwd_mode_parsed,
5693 : : .data = NULL,
5694 : : .help_str = NULL, /* defined at init */
5695 : : .tokens = {
5696 : : (void *)&cmd_setfwd_set,
5697 : : (void *)&cmd_setfwd_fwd,
5698 : : (void *)&cmd_setfwd_mode,
5699 : : NULL,
5700 : : },
5701 : : };
5702 : :
5703 : 0 : static void cmd_set_fwd_mode_init(void)
5704 : : {
5705 : : char *modes, *c;
5706 : : static char token[128];
5707 : : static char help[256];
5708 : : cmdline_parse_token_string_t *token_struct;
5709 : :
5710 : 0 : modes = list_pkt_forwarding_modes();
5711 : : snprintf(help, sizeof(help), "set fwd %s: "
5712 : : "Set packet forwarding mode", modes);
5713 : 0 : cmd_set_fwd_mode.help_str = help;
5714 : :
5715 : : /* string token separator is # */
5716 : 0 : for (c = token; *modes != '\0'; modes++)
5717 : 0 : if (*modes == '|')
5718 : 0 : *c++ = '#';
5719 : : else
5720 : 0 : *c++ = *modes;
5721 : 0 : token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2];
5722 : 0 : token_struct->string_data.str = token;
5723 : 0 : }
5724 : :
5725 : : /* *** SET RETRY FORWARDING MODE *** */
5726 : : struct cmd_set_fwd_retry_mode_result {
5727 : : cmdline_fixed_string_t set;
5728 : : cmdline_fixed_string_t fwd;
5729 : : cmdline_fixed_string_t mode;
5730 : : cmdline_fixed_string_t retry;
5731 : : };
5732 : :
5733 : 0 : static void cmd_set_fwd_retry_mode_parsed(void *parsed_result,
5734 : : __rte_unused struct cmdline *cl,
5735 : : __rte_unused void *data)
5736 : : {
5737 : : struct cmd_set_fwd_retry_mode_result *res = parsed_result;
5738 : :
5739 : 0 : retry_enabled = 1;
5740 : 0 : set_pkt_forwarding_mode(res->mode);
5741 : 0 : }
5742 : :
5743 : : static cmdline_parse_token_string_t cmd_setfwd_retry_set =
5744 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5745 : : set, "set");
5746 : : static cmdline_parse_token_string_t cmd_setfwd_retry_fwd =
5747 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5748 : : fwd, "fwd");
5749 : : static cmdline_parse_token_string_t cmd_setfwd_retry_mode =
5750 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5751 : : mode,
5752 : : "" /* defined at init */);
5753 : : static cmdline_parse_token_string_t cmd_setfwd_retry_retry =
5754 : : TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result,
5755 : : retry, "retry");
5756 : :
5757 : : static cmdline_parse_inst_t cmd_set_fwd_retry_mode = {
5758 : : .f = cmd_set_fwd_retry_mode_parsed,
5759 : : .data = NULL,
5760 : : .help_str = NULL, /* defined at init */
5761 : : .tokens = {
5762 : : (void *)&cmd_setfwd_retry_set,
5763 : : (void *)&cmd_setfwd_retry_fwd,
5764 : : (void *)&cmd_setfwd_retry_mode,
5765 : : (void *)&cmd_setfwd_retry_retry,
5766 : : NULL,
5767 : : },
5768 : : };
5769 : :
5770 : 0 : static void cmd_set_fwd_retry_mode_init(void)
5771 : : {
5772 : : char *modes, *c;
5773 : : static char token[128];
5774 : : static char help[256];
5775 : : cmdline_parse_token_string_t *token_struct;
5776 : :
5777 : 0 : modes = list_pkt_forwarding_retry_modes();
5778 : : snprintf(help, sizeof(help), "set fwd %s retry: "
5779 : : "Set packet forwarding mode with retry", modes);
5780 : 0 : cmd_set_fwd_retry_mode.help_str = help;
5781 : :
5782 : : /* string token separator is # */
5783 : 0 : for (c = token; *modes != '\0'; modes++)
5784 : 0 : if (*modes == '|')
5785 : 0 : *c++ = '#';
5786 : : else
5787 : 0 : *c++ = *modes;
5788 : 0 : token_struct = (cmdline_parse_token_string_t *)
5789 : : cmd_set_fwd_retry_mode.tokens[2];
5790 : 0 : token_struct->string_data.str = token;
5791 : 0 : }
5792 : :
5793 : : /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */
5794 : : struct cmd_set_burst_tx_retry_result {
5795 : : cmdline_fixed_string_t set;
5796 : : cmdline_fixed_string_t burst;
5797 : : cmdline_fixed_string_t tx;
5798 : : cmdline_fixed_string_t delay;
5799 : : uint32_t time;
5800 : : cmdline_fixed_string_t retry;
5801 : : uint32_t retry_num;
5802 : : };
5803 : :
5804 : 0 : static void cmd_set_burst_tx_retry_parsed(void *parsed_result,
5805 : : __rte_unused struct cmdline *cl,
5806 : : __rte_unused void *data)
5807 : : {
5808 : : struct cmd_set_burst_tx_retry_result *res = parsed_result;
5809 : :
5810 : 0 : if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst")
5811 : 0 : && !strcmp(res->tx, "tx")) {
5812 : 0 : if (!strcmp(res->delay, "delay"))
5813 : 0 : burst_tx_delay_time = res->time;
5814 : 0 : if (!strcmp(res->retry, "retry"))
5815 : 0 : burst_tx_retry_num = res->retry_num;
5816 : : }
5817 : :
5818 : 0 : }
5819 : :
5820 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_set =
5821 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set");
5822 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst =
5823 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst,
5824 : : "burst");
5825 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx =
5826 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx");
5827 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay =
5828 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay");
5829 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_time =
5830 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time,
5831 : : RTE_UINT32);
5832 : : static cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry =
5833 : : TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry");
5834 : : static cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num =
5835 : : TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num,
5836 : : RTE_UINT32);
5837 : :
5838 : : static cmdline_parse_inst_t cmd_set_burst_tx_retry = {
5839 : : .f = cmd_set_burst_tx_retry_parsed,
5840 : : .help_str = "set burst tx delay <delay_usec> retry <num_retry>",
5841 : : .tokens = {
5842 : : (void *)&cmd_set_burst_tx_retry_set,
5843 : : (void *)&cmd_set_burst_tx_retry_burst,
5844 : : (void *)&cmd_set_burst_tx_retry_tx,
5845 : : (void *)&cmd_set_burst_tx_retry_delay,
5846 : : (void *)&cmd_set_burst_tx_retry_time,
5847 : : (void *)&cmd_set_burst_tx_retry_retry,
5848 : : (void *)&cmd_set_burst_tx_retry_retry_num,
5849 : : NULL,
5850 : : },
5851 : : };
5852 : :
5853 : : /* *** SET PROMISC MODE *** */
5854 : : struct cmd_set_promisc_mode_result {
5855 : : cmdline_fixed_string_t set;
5856 : : cmdline_fixed_string_t promisc;
5857 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5858 : : uint16_t port_num; /* valid if "allports" argument == 0 */
5859 : : cmdline_fixed_string_t mode;
5860 : : };
5861 : :
5862 : 0 : static void cmd_set_promisc_mode_parsed(void *parsed_result,
5863 : : __rte_unused struct cmdline *cl,
5864 : : void *allports)
5865 : : {
5866 : : struct cmd_set_promisc_mode_result *res = parsed_result;
5867 : : int enable;
5868 : : portid_t i;
5869 : :
5870 : 0 : if (!strcmp(res->mode, "on"))
5871 : : enable = 1;
5872 : : else
5873 : : enable = 0;
5874 : :
5875 : : /* all ports */
5876 : 0 : if (allports) {
5877 : 0 : RTE_ETH_FOREACH_DEV(i)
5878 : 0 : eth_set_promisc_mode(i, enable);
5879 : : } else {
5880 : 0 : eth_set_promisc_mode(res->port_num, enable);
5881 : : }
5882 : 0 : }
5883 : :
5884 : : static cmdline_parse_token_string_t cmd_setpromisc_set =
5885 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set");
5886 : : static cmdline_parse_token_string_t cmd_setpromisc_promisc =
5887 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc,
5888 : : "promisc");
5889 : : static cmdline_parse_token_string_t cmd_setpromisc_portall =
5890 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all,
5891 : : "all");
5892 : : static cmdline_parse_token_num_t cmd_setpromisc_portnum =
5893 : : TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num,
5894 : : RTE_UINT16);
5895 : : static cmdline_parse_token_string_t cmd_setpromisc_mode =
5896 : : TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode,
5897 : : "on#off");
5898 : :
5899 : : static cmdline_parse_inst_t cmd_set_promisc_mode_all = {
5900 : : .f = cmd_set_promisc_mode_parsed,
5901 : : .data = (void *)1,
5902 : : .help_str = "set promisc all on|off: Set promisc mode for all ports",
5903 : : .tokens = {
5904 : : (void *)&cmd_setpromisc_set,
5905 : : (void *)&cmd_setpromisc_promisc,
5906 : : (void *)&cmd_setpromisc_portall,
5907 : : (void *)&cmd_setpromisc_mode,
5908 : : NULL,
5909 : : },
5910 : : };
5911 : :
5912 : : static cmdline_parse_inst_t cmd_set_promisc_mode_one = {
5913 : : .f = cmd_set_promisc_mode_parsed,
5914 : : .data = (void *)0,
5915 : : .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id",
5916 : : .tokens = {
5917 : : (void *)&cmd_setpromisc_set,
5918 : : (void *)&cmd_setpromisc_promisc,
5919 : : (void *)&cmd_setpromisc_portnum,
5920 : : (void *)&cmd_setpromisc_mode,
5921 : : NULL,
5922 : : },
5923 : : };
5924 : :
5925 : : /* *** SET ALLMULTI MODE *** */
5926 : : struct cmd_set_allmulti_mode_result {
5927 : : cmdline_fixed_string_t set;
5928 : : cmdline_fixed_string_t allmulti;
5929 : : cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */
5930 : : uint16_t port_num; /* valid if "allports" argument == 0 */
5931 : : cmdline_fixed_string_t mode;
5932 : : };
5933 : :
5934 : 0 : static void cmd_set_allmulti_mode_parsed(void *parsed_result,
5935 : : __rte_unused struct cmdline *cl,
5936 : : void *allports)
5937 : : {
5938 : : struct cmd_set_allmulti_mode_result *res = parsed_result;
5939 : : int enable;
5940 : : portid_t i;
5941 : :
5942 : 0 : if (!strcmp(res->mode, "on"))
5943 : : enable = 1;
5944 : : else
5945 : : enable = 0;
5946 : :
5947 : : /* all ports */
5948 : 0 : if (allports) {
5949 : 0 : RTE_ETH_FOREACH_DEV(i) {
5950 : 0 : eth_set_allmulticast_mode(i, enable);
5951 : : }
5952 : : }
5953 : : else {
5954 : 0 : eth_set_allmulticast_mode(res->port_num, enable);
5955 : : }
5956 : 0 : }
5957 : :
5958 : : static cmdline_parse_token_string_t cmd_setallmulti_set =
5959 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set");
5960 : : static cmdline_parse_token_string_t cmd_setallmulti_allmulti =
5961 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti,
5962 : : "allmulti");
5963 : : static cmdline_parse_token_string_t cmd_setallmulti_portall =
5964 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all,
5965 : : "all");
5966 : : static cmdline_parse_token_num_t cmd_setallmulti_portnum =
5967 : : TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num,
5968 : : RTE_UINT16);
5969 : : static cmdline_parse_token_string_t cmd_setallmulti_mode =
5970 : : TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode,
5971 : : "on#off");
5972 : :
5973 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_all = {
5974 : : .f = cmd_set_allmulti_mode_parsed,
5975 : : .data = (void *)1,
5976 : : .help_str = "set allmulti all on|off: Set allmulti mode for all ports",
5977 : : .tokens = {
5978 : : (void *)&cmd_setallmulti_set,
5979 : : (void *)&cmd_setallmulti_allmulti,
5980 : : (void *)&cmd_setallmulti_portall,
5981 : : (void *)&cmd_setallmulti_mode,
5982 : : NULL,
5983 : : },
5984 : : };
5985 : :
5986 : : static cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
5987 : : .f = cmd_set_allmulti_mode_parsed,
5988 : : .data = (void *)0,
5989 : : .help_str = "set allmulti <port_id> on|off: "
5990 : : "Set allmulti mode on port_id",
5991 : : .tokens = {
5992 : : (void *)&cmd_setallmulti_set,
5993 : : (void *)&cmd_setallmulti_allmulti,
5994 : : (void *)&cmd_setallmulti_portnum,
5995 : : (void *)&cmd_setallmulti_mode,
5996 : : NULL,
5997 : : },
5998 : : };
5999 : :
6000 : : /* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
6001 : : struct cmd_link_flow_ctrl_show {
6002 : : cmdline_fixed_string_t show;
6003 : : cmdline_fixed_string_t port;
6004 : : portid_t port_id;
6005 : : cmdline_fixed_string_t flow_ctrl;
6006 : : };
6007 : :
6008 : : static cmdline_parse_token_string_t cmd_lfc_show_show =
6009 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6010 : : show, "show");
6011 : : static cmdline_parse_token_string_t cmd_lfc_show_port =
6012 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6013 : : port, "port");
6014 : : static cmdline_parse_token_num_t cmd_lfc_show_portid =
6015 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
6016 : : port_id, RTE_UINT16);
6017 : : static cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
6018 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
6019 : : flow_ctrl, "flow_ctrl");
6020 : :
6021 : : static void
6022 : 0 : cmd_link_flow_ctrl_show_parsed(void *parsed_result,
6023 : : __rte_unused struct cmdline *cl,
6024 : : __rte_unused void *data)
6025 : : {
6026 : : struct cmd_link_flow_ctrl_show *res = parsed_result;
6027 : : static const char *info_border = "*********************";
6028 : : struct rte_eth_fc_conf fc_conf;
6029 : : bool rx_fc_en = false;
6030 : : bool tx_fc_en = false;
6031 : : int ret;
6032 : :
6033 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6034 : 0 : if (ret != 0) {
6035 : 0 : fprintf(stderr,
6036 : : "Failed to get current flow ctrl information: err = %d\n",
6037 : : ret);
6038 : 0 : return;
6039 : : }
6040 : :
6041 : 0 : if (fc_conf.mode == RTE_ETH_FC_RX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6042 : : rx_fc_en = true;
6043 : 0 : if (fc_conf.mode == RTE_ETH_FC_TX_PAUSE || fc_conf.mode == RTE_ETH_FC_FULL)
6044 : : tx_fc_en = true;
6045 : :
6046 : 0 : printf("\n%s Flow control infos for port %-2d %s\n",
6047 : 0 : info_border, res->port_id, info_border);
6048 : : printf("FC mode:\n");
6049 : 0 : printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off");
6050 : 0 : printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off");
6051 : 0 : printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off");
6052 : 0 : printf("Pause time: 0x%x\n", fc_conf.pause_time);
6053 : 0 : printf("High waterline: 0x%x\n", fc_conf.high_water);
6054 : 0 : printf("Low waterline: 0x%x\n", fc_conf.low_water);
6055 : 0 : printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off");
6056 : 0 : printf("Forward MAC control frames: %s\n",
6057 : 0 : fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
6058 : 0 : printf("\n%s************** End ***********%s\n",
6059 : : info_border, info_border);
6060 : : }
6061 : :
6062 : : static cmdline_parse_inst_t cmd_link_flow_control_show = {
6063 : : .f = cmd_link_flow_ctrl_show_parsed,
6064 : : .data = NULL,
6065 : : .help_str = "show port <port_id> flow_ctrl",
6066 : : .tokens = {
6067 : : (void *)&cmd_lfc_show_show,
6068 : : (void *)&cmd_lfc_show_port,
6069 : : (void *)&cmd_lfc_show_portid,
6070 : : (void *)&cmd_lfc_show_flow_ctrl,
6071 : : NULL,
6072 : : },
6073 : : };
6074 : :
6075 : : /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
6076 : : struct cmd_link_flow_ctrl_set_result {
6077 : : cmdline_fixed_string_t set;
6078 : : cmdline_fixed_string_t flow_ctrl;
6079 : : cmdline_fixed_string_t rx;
6080 : : cmdline_fixed_string_t rx_lfc_mode;
6081 : : cmdline_fixed_string_t tx;
6082 : : cmdline_fixed_string_t tx_lfc_mode;
6083 : : cmdline_fixed_string_t mac_ctrl_frame_fwd;
6084 : : cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
6085 : : cmdline_fixed_string_t autoneg_str;
6086 : : cmdline_fixed_string_t autoneg;
6087 : : cmdline_fixed_string_t hw_str;
6088 : : uint32_t high_water;
6089 : : cmdline_fixed_string_t lw_str;
6090 : : uint32_t low_water;
6091 : : cmdline_fixed_string_t pt_str;
6092 : : uint16_t pause_time;
6093 : : cmdline_fixed_string_t xon_str;
6094 : : uint16_t send_xon;
6095 : : portid_t port_id;
6096 : : };
6097 : :
6098 : : static cmdline_parse_token_string_t cmd_lfc_set_set =
6099 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6100 : : set, "set");
6101 : : static cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl =
6102 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6103 : : flow_ctrl, "flow_ctrl");
6104 : : static cmdline_parse_token_string_t cmd_lfc_set_rx =
6105 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6106 : : rx, "rx");
6107 : : static cmdline_parse_token_string_t cmd_lfc_set_rx_mode =
6108 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6109 : : rx_lfc_mode, "on#off");
6110 : : static cmdline_parse_token_string_t cmd_lfc_set_tx =
6111 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6112 : : tx, "tx");
6113 : : static cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
6114 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6115 : : tx_lfc_mode, "on#off");
6116 : : static cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
6117 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6118 : : hw_str, "high_water");
6119 : : static cmdline_parse_token_num_t cmd_lfc_set_high_water =
6120 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6121 : : high_water, RTE_UINT32);
6122 : : static cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
6123 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6124 : : lw_str, "low_water");
6125 : : static cmdline_parse_token_num_t cmd_lfc_set_low_water =
6126 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6127 : : low_water, RTE_UINT32);
6128 : : static cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
6129 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6130 : : pt_str, "pause_time");
6131 : : static cmdline_parse_token_num_t cmd_lfc_set_pause_time =
6132 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6133 : : pause_time, RTE_UINT16);
6134 : : static cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
6135 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6136 : : xon_str, "send_xon");
6137 : : static cmdline_parse_token_num_t cmd_lfc_set_send_xon =
6138 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6139 : : send_xon, RTE_UINT16);
6140 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
6141 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6142 : : mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd");
6143 : : static cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
6144 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6145 : : mac_ctrl_frame_fwd_mode, "on#off");
6146 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
6147 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6148 : : autoneg_str, "autoneg");
6149 : : static cmdline_parse_token_string_t cmd_lfc_set_autoneg =
6150 : : TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6151 : : autoneg, "on#off");
6152 : : static cmdline_parse_token_num_t cmd_lfc_set_portid =
6153 : : TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
6154 : : port_id, RTE_UINT16);
6155 : :
6156 : : /* forward declaration */
6157 : : static void
6158 : : cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
6159 : : void *data);
6160 : :
6161 : : static cmdline_parse_inst_t cmd_link_flow_control_set = {
6162 : : .f = cmd_link_flow_ctrl_set_parsed,
6163 : : .data = NULL,
6164 : : .help_str = "set flow_ctrl rx on|off tx on|off <high_water> "
6165 : : "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off "
6166 : : "autoneg on|off <port_id>: Configure the Ethernet flow control",
6167 : : .tokens = {
6168 : : (void *)&cmd_lfc_set_set,
6169 : : (void *)&cmd_lfc_set_flow_ctrl,
6170 : : (void *)&cmd_lfc_set_rx,
6171 : : (void *)&cmd_lfc_set_rx_mode,
6172 : : (void *)&cmd_lfc_set_tx,
6173 : : (void *)&cmd_lfc_set_tx_mode,
6174 : : (void *)&cmd_lfc_set_high_water,
6175 : : (void *)&cmd_lfc_set_low_water,
6176 : : (void *)&cmd_lfc_set_pause_time,
6177 : : (void *)&cmd_lfc_set_send_xon,
6178 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6179 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6180 : : (void *)&cmd_lfc_set_autoneg_str,
6181 : : (void *)&cmd_lfc_set_autoneg,
6182 : : (void *)&cmd_lfc_set_portid,
6183 : : NULL,
6184 : : },
6185 : : };
6186 : :
6187 : : static cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
6188 : : .f = cmd_link_flow_ctrl_set_parsed,
6189 : : .data = (void *)&cmd_link_flow_control_set_rx,
6190 : : .help_str = "set flow_ctrl rx on|off <port_id>: "
6191 : : "Change rx flow control parameter",
6192 : : .tokens = {
6193 : : (void *)&cmd_lfc_set_set,
6194 : : (void *)&cmd_lfc_set_flow_ctrl,
6195 : : (void *)&cmd_lfc_set_rx,
6196 : : (void *)&cmd_lfc_set_rx_mode,
6197 : : (void *)&cmd_lfc_set_portid,
6198 : : NULL,
6199 : : },
6200 : : };
6201 : :
6202 : : static cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
6203 : : .f = cmd_link_flow_ctrl_set_parsed,
6204 : : .data = (void *)&cmd_link_flow_control_set_tx,
6205 : : .help_str = "set flow_ctrl tx on|off <port_id>: "
6206 : : "Change tx flow control parameter",
6207 : : .tokens = {
6208 : : (void *)&cmd_lfc_set_set,
6209 : : (void *)&cmd_lfc_set_flow_ctrl,
6210 : : (void *)&cmd_lfc_set_tx,
6211 : : (void *)&cmd_lfc_set_tx_mode,
6212 : : (void *)&cmd_lfc_set_portid,
6213 : : NULL,
6214 : : },
6215 : : };
6216 : :
6217 : : static cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
6218 : : .f = cmd_link_flow_ctrl_set_parsed,
6219 : : .data = (void *)&cmd_link_flow_control_set_hw,
6220 : : .help_str = "set flow_ctrl high_water <value> <port_id>: "
6221 : : "Change high water flow control parameter",
6222 : : .tokens = {
6223 : : (void *)&cmd_lfc_set_set,
6224 : : (void *)&cmd_lfc_set_flow_ctrl,
6225 : : (void *)&cmd_lfc_set_high_water_str,
6226 : : (void *)&cmd_lfc_set_high_water,
6227 : : (void *)&cmd_lfc_set_portid,
6228 : : NULL,
6229 : : },
6230 : : };
6231 : :
6232 : : static cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
6233 : : .f = cmd_link_flow_ctrl_set_parsed,
6234 : : .data = (void *)&cmd_link_flow_control_set_lw,
6235 : : .help_str = "set flow_ctrl low_water <value> <port_id>: "
6236 : : "Change low water flow control parameter",
6237 : : .tokens = {
6238 : : (void *)&cmd_lfc_set_set,
6239 : : (void *)&cmd_lfc_set_flow_ctrl,
6240 : : (void *)&cmd_lfc_set_low_water_str,
6241 : : (void *)&cmd_lfc_set_low_water,
6242 : : (void *)&cmd_lfc_set_portid,
6243 : : NULL,
6244 : : },
6245 : : };
6246 : :
6247 : : static cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
6248 : : .f = cmd_link_flow_ctrl_set_parsed,
6249 : : .data = (void *)&cmd_link_flow_control_set_pt,
6250 : : .help_str = "set flow_ctrl pause_time <value> <port_id>: "
6251 : : "Change pause time flow control parameter",
6252 : : .tokens = {
6253 : : (void *)&cmd_lfc_set_set,
6254 : : (void *)&cmd_lfc_set_flow_ctrl,
6255 : : (void *)&cmd_lfc_set_pause_time_str,
6256 : : (void *)&cmd_lfc_set_pause_time,
6257 : : (void *)&cmd_lfc_set_portid,
6258 : : NULL,
6259 : : },
6260 : : };
6261 : :
6262 : : static cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
6263 : : .f = cmd_link_flow_ctrl_set_parsed,
6264 : : .data = (void *)&cmd_link_flow_control_set_xon,
6265 : : .help_str = "set flow_ctrl send_xon <value> <port_id>: "
6266 : : "Change send_xon flow control parameter",
6267 : : .tokens = {
6268 : : (void *)&cmd_lfc_set_set,
6269 : : (void *)&cmd_lfc_set_flow_ctrl,
6270 : : (void *)&cmd_lfc_set_send_xon_str,
6271 : : (void *)&cmd_lfc_set_send_xon,
6272 : : (void *)&cmd_lfc_set_portid,
6273 : : NULL,
6274 : : },
6275 : : };
6276 : :
6277 : : static cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
6278 : : .f = cmd_link_flow_ctrl_set_parsed,
6279 : : .data = (void *)&cmd_link_flow_control_set_macfwd,
6280 : : .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: "
6281 : : "Change mac ctrl fwd flow control parameter",
6282 : : .tokens = {
6283 : : (void *)&cmd_lfc_set_set,
6284 : : (void *)&cmd_lfc_set_flow_ctrl,
6285 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
6286 : : (void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
6287 : : (void *)&cmd_lfc_set_portid,
6288 : : NULL,
6289 : : },
6290 : : };
6291 : :
6292 : : static cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
6293 : : .f = cmd_link_flow_ctrl_set_parsed,
6294 : : .data = (void *)&cmd_link_flow_control_set_autoneg,
6295 : : .help_str = "set flow_ctrl autoneg on|off <port_id>: "
6296 : : "Change autoneg flow control parameter",
6297 : : .tokens = {
6298 : : (void *)&cmd_lfc_set_set,
6299 : : (void *)&cmd_lfc_set_flow_ctrl,
6300 : : (void *)&cmd_lfc_set_autoneg_str,
6301 : : (void *)&cmd_lfc_set_autoneg,
6302 : : (void *)&cmd_lfc_set_portid,
6303 : : NULL,
6304 : : },
6305 : : };
6306 : :
6307 : : static void
6308 : 0 : cmd_link_flow_ctrl_set_parsed(void *parsed_result,
6309 : : __rte_unused struct cmdline *cl,
6310 : : void *data)
6311 : : {
6312 : : struct cmd_link_flow_ctrl_set_result *res = parsed_result;
6313 : : cmdline_parse_inst_t *cmd = data;
6314 : : struct rte_eth_fc_conf fc_conf;
6315 : : int rx_fc_en = 0;
6316 : : int tx_fc_en = 0;
6317 : : int ret;
6318 : :
6319 : : /*
6320 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6321 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6322 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6323 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6324 : : */
6325 : : static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
6326 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6327 : : };
6328 : :
6329 : : /* Partial command line, retrieve current configuration */
6330 : 0 : if (cmd) {
6331 : 0 : ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
6332 : 0 : if (ret != 0) {
6333 : 0 : fprintf(stderr,
6334 : : "cannot get current flow ctrl parameters, return code = %d\n",
6335 : : ret);
6336 : 0 : return;
6337 : : }
6338 : :
6339 : 0 : if ((fc_conf.mode == RTE_ETH_FC_RX_PAUSE) ||
6340 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6341 : : rx_fc_en = 1;
6342 : 0 : if ((fc_conf.mode == RTE_ETH_FC_TX_PAUSE) ||
6343 : : (fc_conf.mode == RTE_ETH_FC_FULL))
6344 : : tx_fc_en = 1;
6345 : : }
6346 : :
6347 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_rx)
6348 : 0 : rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
6349 : :
6350 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_tx)
6351 : 0 : tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
6352 : :
6353 : 0 : fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
6354 : :
6355 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_hw)
6356 : 0 : fc_conf.high_water = res->high_water;
6357 : :
6358 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_lw)
6359 : 0 : fc_conf.low_water = res->low_water;
6360 : :
6361 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_pt)
6362 : 0 : fc_conf.pause_time = res->pause_time;
6363 : :
6364 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_xon)
6365 : 0 : fc_conf.send_xon = res->send_xon;
6366 : :
6367 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
6368 : 0 : if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
6369 : 0 : fc_conf.mac_ctrl_frame_fwd = 1;
6370 : : else
6371 : 0 : fc_conf.mac_ctrl_frame_fwd = 0;
6372 : : }
6373 : :
6374 : 0 : if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
6375 : 0 : fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
6376 : :
6377 : 0 : ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
6378 : 0 : if (ret != 0)
6379 : 0 : fprintf(stderr,
6380 : : "bad flow control parameter, return code = %d\n",
6381 : : ret);
6382 : : }
6383 : :
6384 : : /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */
6385 : : struct cmd_priority_flow_ctrl_set_result {
6386 : : cmdline_fixed_string_t set;
6387 : : cmdline_fixed_string_t pfc_ctrl;
6388 : : cmdline_fixed_string_t rx;
6389 : : cmdline_fixed_string_t rx_pfc_mode;
6390 : : cmdline_fixed_string_t tx;
6391 : : cmdline_fixed_string_t tx_pfc_mode;
6392 : : uint32_t high_water;
6393 : : uint32_t low_water;
6394 : : uint16_t pause_time;
6395 : : uint8_t priority;
6396 : : portid_t port_id;
6397 : : };
6398 : :
6399 : : static void
6400 : 0 : cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
6401 : : __rte_unused struct cmdline *cl,
6402 : : __rte_unused void *data)
6403 : : {
6404 : : struct cmd_priority_flow_ctrl_set_result *res = parsed_result;
6405 : : struct rte_eth_pfc_conf pfc_conf;
6406 : : int rx_fc_enable, tx_fc_enable;
6407 : : int ret;
6408 : :
6409 : : /*
6410 : : * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
6411 : : * the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx side.
6412 : : * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
6413 : : * the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
6414 : : */
6415 : : static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = {
6416 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE}, {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6417 : : };
6418 : :
6419 : : memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
6420 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
6421 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
6422 : 0 : pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];
6423 : 0 : pfc_conf.fc.high_water = res->high_water;
6424 : 0 : pfc_conf.fc.low_water = res->low_water;
6425 : 0 : pfc_conf.fc.pause_time = res->pause_time;
6426 : 0 : pfc_conf.priority = res->priority;
6427 : :
6428 : 0 : ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf);
6429 : 0 : if (ret != 0)
6430 : 0 : fprintf(stderr,
6431 : : "bad priority flow control parameter, return code = %d\n",
6432 : : ret);
6433 : 0 : }
6434 : :
6435 : : static cmdline_parse_token_string_t cmd_pfc_set_set =
6436 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6437 : : set, "set");
6438 : : static cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl =
6439 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6440 : : pfc_ctrl, "pfc_ctrl");
6441 : : static cmdline_parse_token_string_t cmd_pfc_set_rx =
6442 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6443 : : rx, "rx");
6444 : : static cmdline_parse_token_string_t cmd_pfc_set_rx_mode =
6445 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6446 : : rx_pfc_mode, "on#off");
6447 : : static cmdline_parse_token_string_t cmd_pfc_set_tx =
6448 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6449 : : tx, "tx");
6450 : : static cmdline_parse_token_string_t cmd_pfc_set_tx_mode =
6451 : : TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6452 : : tx_pfc_mode, "on#off");
6453 : : static cmdline_parse_token_num_t cmd_pfc_set_high_water =
6454 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6455 : : high_water, RTE_UINT32);
6456 : : static cmdline_parse_token_num_t cmd_pfc_set_low_water =
6457 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6458 : : low_water, RTE_UINT32);
6459 : : static cmdline_parse_token_num_t cmd_pfc_set_pause_time =
6460 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6461 : : pause_time, RTE_UINT16);
6462 : : static cmdline_parse_token_num_t cmd_pfc_set_priority =
6463 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6464 : : priority, RTE_UINT8);
6465 : : static cmdline_parse_token_num_t cmd_pfc_set_portid =
6466 : : TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result,
6467 : : port_id, RTE_UINT16);
6468 : :
6469 : : static cmdline_parse_inst_t cmd_priority_flow_control_set = {
6470 : : .f = cmd_priority_flow_ctrl_set_parsed,
6471 : : .data = NULL,
6472 : : .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> "
6473 : : "<pause_time> <priority> <port_id>: "
6474 : : "Configure the Ethernet priority flow control",
6475 : : .tokens = {
6476 : : (void *)&cmd_pfc_set_set,
6477 : : (void *)&cmd_pfc_set_flow_ctrl,
6478 : : (void *)&cmd_pfc_set_rx,
6479 : : (void *)&cmd_pfc_set_rx_mode,
6480 : : (void *)&cmd_pfc_set_tx,
6481 : : (void *)&cmd_pfc_set_tx_mode,
6482 : : (void *)&cmd_pfc_set_high_water,
6483 : : (void *)&cmd_pfc_set_low_water,
6484 : : (void *)&cmd_pfc_set_pause_time,
6485 : : (void *)&cmd_pfc_set_priority,
6486 : : (void *)&cmd_pfc_set_portid,
6487 : : NULL,
6488 : : },
6489 : : };
6490 : :
6491 : : struct cmd_queue_priority_flow_ctrl_set_result {
6492 : : cmdline_fixed_string_t set;
6493 : : cmdline_fixed_string_t pfc_queue_ctrl;
6494 : : portid_t port_id;
6495 : : cmdline_fixed_string_t rx;
6496 : : cmdline_fixed_string_t rx_pfc_mode;
6497 : : uint16_t tx_qid;
6498 : : uint8_t tx_tc;
6499 : : cmdline_fixed_string_t tx;
6500 : : cmdline_fixed_string_t tx_pfc_mode;
6501 : : uint16_t rx_qid;
6502 : : uint8_t rx_tc;
6503 : : uint16_t pause_time;
6504 : : };
6505 : :
6506 : : static void
6507 : 0 : cmd_queue_priority_flow_ctrl_set_parsed(void *parsed_result,
6508 : : __rte_unused struct cmdline *cl,
6509 : : __rte_unused void *data)
6510 : : {
6511 : : struct cmd_queue_priority_flow_ctrl_set_result *res = parsed_result;
6512 : : struct rte_eth_pfc_queue_conf pfc_queue_conf;
6513 : : int rx_fc_enable, tx_fc_enable;
6514 : : int ret;
6515 : :
6516 : : /*
6517 : : * Rx on/off, flow control is enabled/disabled on RX side. This can
6518 : : * indicate the RTE_ETH_FC_TX_PAUSE, Transmit pause frame at the Rx
6519 : : * side. Tx on/off, flow control is enabled/disabled on TX side. This
6520 : : * can indicate the RTE_ETH_FC_RX_PAUSE, Respond to the pause frame at
6521 : : * the Tx side.
6522 : : */
6523 : : static enum rte_eth_fc_mode rx_tx_onoff_2_mode[2][2] = {
6524 : : {RTE_ETH_FC_NONE, RTE_ETH_FC_TX_PAUSE},
6525 : : {RTE_ETH_FC_RX_PAUSE, RTE_ETH_FC_FULL}
6526 : : };
6527 : :
6528 : : memset(&pfc_queue_conf, 0, sizeof(struct rte_eth_pfc_queue_conf));
6529 : 0 : rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on", 2)) ? 1 : 0;
6530 : 0 : tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on", 2)) ? 1 : 0;
6531 : 0 : pfc_queue_conf.mode = rx_tx_onoff_2_mode[rx_fc_enable][tx_fc_enable];
6532 : 0 : pfc_queue_conf.rx_pause.tc = res->tx_tc;
6533 : 0 : pfc_queue_conf.rx_pause.tx_qid = res->tx_qid;
6534 : 0 : pfc_queue_conf.tx_pause.tc = res->rx_tc;
6535 : 0 : pfc_queue_conf.tx_pause.rx_qid = res->rx_qid;
6536 : 0 : pfc_queue_conf.tx_pause.pause_time = res->pause_time;
6537 : :
6538 : 0 : ret = rte_eth_dev_priority_flow_ctrl_queue_configure(res->port_id,
6539 : : &pfc_queue_conf);
6540 : 0 : if (ret != 0) {
6541 : 0 : fprintf(stderr,
6542 : : "bad queue priority flow control parameter, rc = %d\n",
6543 : : ret);
6544 : : }
6545 : 0 : }
6546 : :
6547 : : static cmdline_parse_token_string_t cmd_q_pfc_set_set =
6548 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6549 : : set, "set");
6550 : : static cmdline_parse_token_string_t cmd_q_pfc_set_flow_ctrl =
6551 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6552 : : pfc_queue_ctrl, "pfc_queue_ctrl");
6553 : : static cmdline_parse_token_num_t cmd_q_pfc_set_portid =
6554 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6555 : : port_id, RTE_UINT16);
6556 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx =
6557 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6558 : : rx, "rx");
6559 : : static cmdline_parse_token_string_t cmd_q_pfc_set_rx_mode =
6560 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6561 : : rx_pfc_mode, "on#off");
6562 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_qid =
6563 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6564 : : tx_qid, RTE_UINT16);
6565 : : static cmdline_parse_token_num_t cmd_q_pfc_set_tx_tc =
6566 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6567 : : tx_tc, RTE_UINT8);
6568 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx =
6569 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6570 : : tx, "tx");
6571 : : static cmdline_parse_token_string_t cmd_q_pfc_set_tx_mode =
6572 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6573 : : tx_pfc_mode, "on#off");
6574 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_qid =
6575 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6576 : : rx_qid, RTE_UINT16);
6577 : : static cmdline_parse_token_num_t cmd_q_pfc_set_rx_tc =
6578 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6579 : : rx_tc, RTE_UINT8);
6580 : : static cmdline_parse_token_num_t cmd_q_pfc_set_pause_time =
6581 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_priority_flow_ctrl_set_result,
6582 : : pause_time, RTE_UINT16);
6583 : :
6584 : : static cmdline_parse_inst_t cmd_queue_priority_flow_control_set = {
6585 : : .f = cmd_queue_priority_flow_ctrl_set_parsed,
6586 : : .data = NULL,
6587 : : .help_str = "set pfc_queue_ctrl <port_id> rx <on|off> <tx_qid> <tx_tc> "
6588 : : "tx <on|off> <rx_qid> <rx_tc> <pause_time>: "
6589 : : "Configure the Ethernet queue priority flow control",
6590 : : .tokens = {
6591 : : (void *)&cmd_q_pfc_set_set,
6592 : : (void *)&cmd_q_pfc_set_flow_ctrl,
6593 : : (void *)&cmd_q_pfc_set_portid,
6594 : : (void *)&cmd_q_pfc_set_rx,
6595 : : (void *)&cmd_q_pfc_set_rx_mode,
6596 : : (void *)&cmd_q_pfc_set_tx_qid,
6597 : : (void *)&cmd_q_pfc_set_tx_tc,
6598 : : (void *)&cmd_q_pfc_set_tx,
6599 : : (void *)&cmd_q_pfc_set_tx_mode,
6600 : : (void *)&cmd_q_pfc_set_rx_qid,
6601 : : (void *)&cmd_q_pfc_set_rx_tc,
6602 : : (void *)&cmd_q_pfc_set_pause_time,
6603 : : NULL,
6604 : : },
6605 : : };
6606 : :
6607 : : /* *** RESET CONFIGURATION *** */
6608 : : struct cmd_reset_result {
6609 : : cmdline_fixed_string_t reset;
6610 : : cmdline_fixed_string_t def;
6611 : : };
6612 : :
6613 : 0 : static void cmd_reset_parsed(__rte_unused void *parsed_result,
6614 : : struct cmdline *cl,
6615 : : __rte_unused void *data)
6616 : : {
6617 : 0 : cmdline_printf(cl, "Reset to default forwarding configuration...\n");
6618 : 0 : set_def_fwd_config();
6619 : 0 : }
6620 : :
6621 : : static cmdline_parse_token_string_t cmd_reset_set =
6622 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set");
6623 : : static cmdline_parse_token_string_t cmd_reset_def =
6624 : : TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def,
6625 : : "default");
6626 : :
6627 : : static cmdline_parse_inst_t cmd_reset = {
6628 : : .f = cmd_reset_parsed,
6629 : : .data = NULL,
6630 : : .help_str = "set default: Reset default forwarding configuration",
6631 : : .tokens = {
6632 : : (void *)&cmd_reset_set,
6633 : : (void *)&cmd_reset_def,
6634 : : NULL,
6635 : : },
6636 : : };
6637 : :
6638 : : /* *** START FORWARDING *** */
6639 : : struct cmd_start_result {
6640 : : cmdline_fixed_string_t start;
6641 : : };
6642 : :
6643 : : static cmdline_parse_token_string_t cmd_start_start =
6644 : : TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start");
6645 : :
6646 : 0 : static void cmd_start_parsed(__rte_unused void *parsed_result,
6647 : : __rte_unused struct cmdline *cl,
6648 : : __rte_unused void *data)
6649 : : {
6650 : 0 : start_packet_forwarding(0);
6651 : 0 : }
6652 : :
6653 : : static cmdline_parse_inst_t cmd_start = {
6654 : : .f = cmd_start_parsed,
6655 : : .data = NULL,
6656 : : .help_str = "start: Start packet forwarding",
6657 : : .tokens = {
6658 : : (void *)&cmd_start_start,
6659 : : NULL,
6660 : : },
6661 : : };
6662 : :
6663 : : /* *** START FORWARDING WITH ONE TX BURST FIRST *** */
6664 : : struct cmd_start_tx_first_result {
6665 : : cmdline_fixed_string_t start;
6666 : : cmdline_fixed_string_t tx_first;
6667 : : };
6668 : :
6669 : : static void
6670 : 0 : cmd_start_tx_first_parsed(__rte_unused void *parsed_result,
6671 : : __rte_unused struct cmdline *cl,
6672 : : __rte_unused void *data)
6673 : : {
6674 : 0 : start_packet_forwarding(1);
6675 : 0 : }
6676 : :
6677 : : static cmdline_parse_token_string_t cmd_start_tx_first_start =
6678 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start,
6679 : : "start");
6680 : : static cmdline_parse_token_string_t cmd_start_tx_first_tx_first =
6681 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result,
6682 : : tx_first, "tx_first");
6683 : :
6684 : : static cmdline_parse_inst_t cmd_start_tx_first = {
6685 : : .f = cmd_start_tx_first_parsed,
6686 : : .data = NULL,
6687 : : .help_str = "start tx_first: Start packet forwarding, "
6688 : : "after sending 1 burst of packets",
6689 : : .tokens = {
6690 : : (void *)&cmd_start_tx_first_start,
6691 : : (void *)&cmd_start_tx_first_tx_first,
6692 : : NULL,
6693 : : },
6694 : : };
6695 : :
6696 : : /* *** START FORWARDING WITH N TX BURST FIRST *** */
6697 : : struct cmd_start_tx_first_n_result {
6698 : : cmdline_fixed_string_t start;
6699 : : cmdline_fixed_string_t tx_first;
6700 : : uint32_t tx_num;
6701 : : };
6702 : :
6703 : : static void
6704 : 0 : cmd_start_tx_first_n_parsed(void *parsed_result,
6705 : : __rte_unused struct cmdline *cl,
6706 : : __rte_unused void *data)
6707 : : {
6708 : : struct cmd_start_tx_first_n_result *res = parsed_result;
6709 : :
6710 : 0 : start_packet_forwarding(res->tx_num);
6711 : 0 : }
6712 : :
6713 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_start =
6714 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6715 : : start, "start");
6716 : : static cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first =
6717 : : TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result,
6718 : : tx_first, "tx_first");
6719 : : static cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num =
6720 : : TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result,
6721 : : tx_num, RTE_UINT32);
6722 : :
6723 : : static cmdline_parse_inst_t cmd_start_tx_first_n = {
6724 : : .f = cmd_start_tx_first_n_parsed,
6725 : : .data = NULL,
6726 : : .help_str = "start tx_first <num>: "
6727 : : "packet forwarding, after sending <num> bursts of packets",
6728 : : .tokens = {
6729 : : (void *)&cmd_start_tx_first_n_start,
6730 : : (void *)&cmd_start_tx_first_n_tx_first,
6731 : : (void *)&cmd_start_tx_first_n_tx_num,
6732 : : NULL,
6733 : : },
6734 : : };
6735 : :
6736 : : /* *** SET LINK UP *** */
6737 : : struct cmd_set_link_up_result {
6738 : : cmdline_fixed_string_t set;
6739 : : cmdline_fixed_string_t link_up;
6740 : : cmdline_fixed_string_t port;
6741 : : portid_t port_id;
6742 : : };
6743 : :
6744 : : static cmdline_parse_token_string_t cmd_set_link_up_set =
6745 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set");
6746 : : static cmdline_parse_token_string_t cmd_set_link_up_link_up =
6747 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up,
6748 : : "link-up");
6749 : : static cmdline_parse_token_string_t cmd_set_link_up_port =
6750 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port");
6751 : : static cmdline_parse_token_num_t cmd_set_link_up_port_id =
6752 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id,
6753 : : RTE_UINT16);
6754 : :
6755 : 0 : static void cmd_set_link_up_parsed(__rte_unused void *parsed_result,
6756 : : __rte_unused struct cmdline *cl,
6757 : : __rte_unused void *data)
6758 : : {
6759 : : struct cmd_set_link_up_result *res = parsed_result;
6760 : 0 : dev_set_link_up(res->port_id);
6761 : 0 : }
6762 : :
6763 : : static cmdline_parse_inst_t cmd_set_link_up = {
6764 : : .f = cmd_set_link_up_parsed,
6765 : : .data = NULL,
6766 : : .help_str = "set link-up port <port id>",
6767 : : .tokens = {
6768 : : (void *)&cmd_set_link_up_set,
6769 : : (void *)&cmd_set_link_up_link_up,
6770 : : (void *)&cmd_set_link_up_port,
6771 : : (void *)&cmd_set_link_up_port_id,
6772 : : NULL,
6773 : : },
6774 : : };
6775 : :
6776 : : /* *** SET LINK DOWN *** */
6777 : : struct cmd_set_link_down_result {
6778 : : cmdline_fixed_string_t set;
6779 : : cmdline_fixed_string_t link_down;
6780 : : cmdline_fixed_string_t port;
6781 : : portid_t port_id;
6782 : : };
6783 : :
6784 : : static cmdline_parse_token_string_t cmd_set_link_down_set =
6785 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set");
6786 : : static cmdline_parse_token_string_t cmd_set_link_down_link_down =
6787 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down,
6788 : : "link-down");
6789 : : static cmdline_parse_token_string_t cmd_set_link_down_port =
6790 : : TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port");
6791 : : static cmdline_parse_token_num_t cmd_set_link_down_port_id =
6792 : : TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id,
6793 : : RTE_UINT16);
6794 : :
6795 : 0 : static void cmd_set_link_down_parsed(
6796 : : __rte_unused void *parsed_result,
6797 : : __rte_unused struct cmdline *cl,
6798 : : __rte_unused void *data)
6799 : : {
6800 : : struct cmd_set_link_down_result *res = parsed_result;
6801 : 0 : dev_set_link_down(res->port_id);
6802 : 0 : }
6803 : :
6804 : : static cmdline_parse_inst_t cmd_set_link_down = {
6805 : : .f = cmd_set_link_down_parsed,
6806 : : .data = NULL,
6807 : : .help_str = "set link-down port <port id>",
6808 : : .tokens = {
6809 : : (void *)&cmd_set_link_down_set,
6810 : : (void *)&cmd_set_link_down_link_down,
6811 : : (void *)&cmd_set_link_down_port,
6812 : : (void *)&cmd_set_link_down_port_id,
6813 : : NULL,
6814 : : },
6815 : : };
6816 : :
6817 : : /* *** SHOW CFG *** */
6818 : : struct cmd_showcfg_result {
6819 : : cmdline_fixed_string_t show;
6820 : : cmdline_fixed_string_t cfg;
6821 : : cmdline_fixed_string_t what;
6822 : : };
6823 : :
6824 : 0 : static void cmd_showcfg_parsed(void *parsed_result,
6825 : : __rte_unused struct cmdline *cl,
6826 : : __rte_unused void *data)
6827 : : {
6828 : : struct cmd_showcfg_result *res = parsed_result;
6829 : 0 : if (!strcmp(res->what, "rxtx"))
6830 : 0 : rxtx_config_display();
6831 : 0 : else if (!strcmp(res->what, "cores"))
6832 : 0 : fwd_lcores_config_display();
6833 : 0 : else if (!strcmp(res->what, "fwd"))
6834 : 0 : pkt_fwd_config_display(&cur_fwd_config);
6835 : 0 : else if (!strcmp(res->what, "rxoffs"))
6836 : 0 : show_rx_pkt_offsets();
6837 : 0 : else if (!strcmp(res->what, "rxpkts"))
6838 : 0 : show_rx_pkt_segments();
6839 : 0 : else if (!strcmp(res->what, "rxhdrs"))
6840 : 0 : show_rx_pkt_hdrs();
6841 : 0 : else if (!strcmp(res->what, "txpkts"))
6842 : 0 : show_tx_pkt_segments();
6843 : 0 : else if (!strcmp(res->what, "txtimes"))
6844 : 0 : show_tx_pkt_times();
6845 : 0 : }
6846 : :
6847 : : static cmdline_parse_token_string_t cmd_showcfg_show =
6848 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show");
6849 : : static cmdline_parse_token_string_t cmd_showcfg_port =
6850 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config");
6851 : : static cmdline_parse_token_string_t cmd_showcfg_what =
6852 : : TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what,
6853 : : "rxtx#cores#fwd#rxoffs#rxpkts#rxhdrs#txpkts#txtimes");
6854 : :
6855 : : static cmdline_parse_inst_t cmd_showcfg = {
6856 : : .f = cmd_showcfg_parsed,
6857 : : .data = NULL,
6858 : : .help_str = "show config rxtx|cores|fwd|rxoffs|rxpkts|rxhdrs|txpkts|txtimes",
6859 : : .tokens = {
6860 : : (void *)&cmd_showcfg_show,
6861 : : (void *)&cmd_showcfg_port,
6862 : : (void *)&cmd_showcfg_what,
6863 : : NULL,
6864 : : },
6865 : : };
6866 : :
6867 : : /* *** SHOW ALL PORT INFO *** */
6868 : : struct cmd_showportall_result {
6869 : : cmdline_fixed_string_t show;
6870 : : cmdline_fixed_string_t port;
6871 : : cmdline_fixed_string_t what;
6872 : : cmdline_fixed_string_t all;
6873 : : };
6874 : :
6875 : 0 : static void cmd_showportall_parsed(void *parsed_result,
6876 : : __rte_unused struct cmdline *cl,
6877 : : __rte_unused void *data)
6878 : : {
6879 : : portid_t i;
6880 : :
6881 : : struct cmd_showportall_result *res = parsed_result;
6882 : 0 : if (!strcmp(res->show, "clear")) {
6883 : 0 : if (!strcmp(res->what, "stats"))
6884 : 0 : RTE_ETH_FOREACH_DEV(i)
6885 : 0 : nic_stats_clear(i);
6886 : 0 : else if (!strcmp(res->what, "xstats"))
6887 : 0 : RTE_ETH_FOREACH_DEV(i)
6888 : 0 : nic_xstats_clear(i);
6889 : 0 : } else if (!strcmp(res->what, "info"))
6890 : 0 : RTE_ETH_FOREACH_DEV(i)
6891 : 0 : port_infos_display(i);
6892 : 0 : else if (!strcmp(res->what, "summary")) {
6893 : 0 : port_summary_header_display();
6894 : 0 : RTE_ETH_FOREACH_DEV(i)
6895 : 0 : port_summary_display(i);
6896 : : }
6897 : 0 : else if (!strcmp(res->what, "stats"))
6898 : 0 : RTE_ETH_FOREACH_DEV(i)
6899 : 0 : nic_stats_display(i);
6900 : 0 : else if (!strcmp(res->what, "xstats"))
6901 : 0 : RTE_ETH_FOREACH_DEV(i)
6902 : 0 : nic_xstats_display(i);
6903 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
6904 : 0 : else if (!strcmp(res->what, "fdir"))
6905 : 0 : RTE_ETH_FOREACH_DEV(i)
6906 : 0 : fdir_get_infos(i);
6907 : : #endif
6908 : 0 : else if (!strcmp(res->what, "dcb_tc"))
6909 : 0 : RTE_ETH_FOREACH_DEV(i)
6910 : 0 : port_dcb_info_display(i);
6911 : 0 : }
6912 : :
6913 : : static cmdline_parse_token_string_t cmd_showportall_show =
6914 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show,
6915 : : "show#clear");
6916 : : static cmdline_parse_token_string_t cmd_showportall_port =
6917 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
6918 : : static cmdline_parse_token_string_t cmd_showportall_what =
6919 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
6920 : : "info#summary#stats#xstats#fdir#dcb_tc");
6921 : : static cmdline_parse_token_string_t cmd_showportall_all =
6922 : : TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
6923 : : static cmdline_parse_inst_t cmd_showportall = {
6924 : : .f = cmd_showportall_parsed,
6925 : : .data = NULL,
6926 : : .help_str = "show|clear port "
6927 : : "info|summary|stats|xstats|fdir|dcb_tc all",
6928 : : .tokens = {
6929 : : (void *)&cmd_showportall_show,
6930 : : (void *)&cmd_showportall_port,
6931 : : (void *)&cmd_showportall_what,
6932 : : (void *)&cmd_showportall_all,
6933 : : NULL,
6934 : : },
6935 : : };
6936 : :
6937 : : /* *** SHOW PORT INFO *** */
6938 : : struct cmd_showport_result {
6939 : : cmdline_fixed_string_t show;
6940 : : cmdline_fixed_string_t port;
6941 : : cmdline_fixed_string_t what;
6942 : : uint16_t portnum;
6943 : : };
6944 : :
6945 : 0 : static void cmd_showport_parsed(void *parsed_result,
6946 : : __rte_unused struct cmdline *cl,
6947 : : __rte_unused void *data)
6948 : : {
6949 : : struct cmd_showport_result *res = parsed_result;
6950 : 0 : if (!strcmp(res->show, "clear")) {
6951 : 0 : if (!strcmp(res->what, "stats"))
6952 : 0 : nic_stats_clear(res->portnum);
6953 : 0 : else if (!strcmp(res->what, "xstats"))
6954 : 0 : nic_xstats_clear(res->portnum);
6955 : 0 : } else if (!strcmp(res->what, "info"))
6956 : 0 : port_infos_display(res->portnum);
6957 : 0 : else if (!strcmp(res->what, "summary")) {
6958 : 0 : port_summary_header_display();
6959 : 0 : port_summary_display(res->portnum);
6960 : : }
6961 : 0 : else if (!strcmp(res->what, "stats"))
6962 : 0 : nic_stats_display(res->portnum);
6963 : 0 : else if (!strcmp(res->what, "xstats"))
6964 : 0 : nic_xstats_display(res->portnum);
6965 : : #if defined(RTE_NET_I40E) || defined(RTE_NET_IXGBE)
6966 : 0 : else if (!strcmp(res->what, "fdir"))
6967 : 0 : fdir_get_infos(res->portnum);
6968 : : #endif
6969 : 0 : else if (!strcmp(res->what, "dcb_tc"))
6970 : 0 : port_dcb_info_display(res->portnum);
6971 : 0 : }
6972 : :
6973 : : static cmdline_parse_token_string_t cmd_showport_show =
6974 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show,
6975 : : "show#clear");
6976 : : static cmdline_parse_token_string_t cmd_showport_port =
6977 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
6978 : : static cmdline_parse_token_string_t cmd_showport_what =
6979 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
6980 : : "info#summary#stats#xstats#fdir#dcb_tc");
6981 : : static cmdline_parse_token_num_t cmd_showport_portnum =
6982 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16);
6983 : :
6984 : : static cmdline_parse_inst_t cmd_showport = {
6985 : : .f = cmd_showport_parsed,
6986 : : .data = NULL,
6987 : : .help_str = "show|clear port "
6988 : : "info|summary|stats|xstats|fdir|dcb_tc "
6989 : : "<port_id>",
6990 : : .tokens = {
6991 : : (void *)&cmd_showport_show,
6992 : : (void *)&cmd_showport_port,
6993 : : (void *)&cmd_showport_what,
6994 : : (void *)&cmd_showport_portnum,
6995 : : NULL,
6996 : : },
6997 : : };
6998 : :
6999 : : /* *** show port representors information *** */
7000 : : struct cmd_representor_info_result {
7001 : : cmdline_fixed_string_t cmd_show;
7002 : : cmdline_fixed_string_t cmd_port;
7003 : : cmdline_fixed_string_t cmd_info;
7004 : : cmdline_fixed_string_t cmd_keyword;
7005 : : portid_t cmd_pid;
7006 : : };
7007 : :
7008 : : static void
7009 : 0 : cmd_representor_info_parsed(void *parsed_result,
7010 : : __rte_unused struct cmdline *cl,
7011 : : __rte_unused void *data)
7012 : : {
7013 : : struct cmd_representor_info_result *res = parsed_result;
7014 : : struct rte_eth_representor_info *info;
7015 : : struct rte_eth_representor_range *range;
7016 : : uint32_t range_diff;
7017 : : uint32_t i;
7018 : : int ret;
7019 : : int num;
7020 : :
7021 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
7022 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
7023 : 0 : return;
7024 : : }
7025 : :
7026 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, NULL);
7027 : 0 : if (ret < 0) {
7028 : 0 : fprintf(stderr,
7029 : : "Failed to get the number of representor info ranges for port %hu: %s\n",
7030 : 0 : res->cmd_pid, rte_strerror(-ret));
7031 : 0 : return;
7032 : : }
7033 : : num = ret;
7034 : :
7035 : 0 : info = calloc(1, sizeof(*info) + num * sizeof(info->ranges[0]));
7036 : 0 : if (info == NULL) {
7037 : 0 : fprintf(stderr,
7038 : : "Failed to allocate memory for representor info for port %hu\n",
7039 : 0 : res->cmd_pid);
7040 : 0 : return;
7041 : : }
7042 : 0 : info->nb_ranges_alloc = num;
7043 : :
7044 : 0 : ret = rte_eth_representor_info_get(res->cmd_pid, info);
7045 : 0 : if (ret < 0) {
7046 : 0 : fprintf(stderr,
7047 : : "Failed to get the representor info for port %hu: %s\n",
7048 : 0 : res->cmd_pid, rte_strerror(-ret));
7049 : 0 : free(info);
7050 : 0 : return;
7051 : : }
7052 : :
7053 : 0 : printf("Port controller: %hu\n", info->controller);
7054 : 0 : printf("Port PF: %hu\n", info->pf);
7055 : :
7056 : 0 : printf("Ranges: %u\n", info->nb_ranges);
7057 : 0 : for (i = 0; i < info->nb_ranges; i++) {
7058 : : range = &info->ranges[i];
7059 : 0 : range_diff = range->id_end - range->id_base;
7060 : :
7061 : 0 : printf("%u. ", i + 1);
7062 : 0 : printf("'%s' ", range->name);
7063 : 0 : if (range_diff > 0)
7064 : 0 : printf("[%u-%u]: ", range->id_base, range->id_end);
7065 : : else
7066 : 0 : printf("[%u]: ", range->id_base);
7067 : :
7068 : 0 : printf("Controller %d, PF %d", range->controller, range->pf);
7069 : :
7070 : 0 : switch (range->type) {
7071 : : case RTE_ETH_REPRESENTOR_NONE:
7072 : : printf(", NONE\n");
7073 : : break;
7074 : 0 : case RTE_ETH_REPRESENTOR_VF:
7075 : 0 : if (range_diff > 0)
7076 : 0 : printf(", VF %d..%d\n", range->vf,
7077 : 0 : range->vf + range_diff);
7078 : : else
7079 : 0 : printf(", VF %d\n", range->vf);
7080 : : break;
7081 : 0 : case RTE_ETH_REPRESENTOR_SF:
7082 : 0 : printf(", SF %d\n", range->sf);
7083 : : break;
7084 : 0 : case RTE_ETH_REPRESENTOR_PF:
7085 : 0 : if (range_diff > 0)
7086 : 0 : printf("..%d\n", range->pf + range_diff);
7087 : : else
7088 : : printf("\n");
7089 : : break;
7090 : 0 : default:
7091 : : printf(", UNKNOWN TYPE %d\n", range->type);
7092 : : break;
7093 : : }
7094 : : }
7095 : :
7096 : 0 : free(info);
7097 : : }
7098 : :
7099 : : static cmdline_parse_token_string_t cmd_representor_info_show =
7100 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7101 : : cmd_show, "show");
7102 : : static cmdline_parse_token_string_t cmd_representor_info_port =
7103 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7104 : : cmd_port, "port");
7105 : : static cmdline_parse_token_string_t cmd_representor_info_info =
7106 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7107 : : cmd_info, "info");
7108 : : static cmdline_parse_token_num_t cmd_representor_info_pid =
7109 : : TOKEN_NUM_INITIALIZER(struct cmd_representor_info_result,
7110 : : cmd_pid, RTE_UINT16);
7111 : : static cmdline_parse_token_string_t cmd_representor_info_keyword =
7112 : : TOKEN_STRING_INITIALIZER(struct cmd_representor_info_result,
7113 : : cmd_keyword, "representor");
7114 : :
7115 : : static cmdline_parse_inst_t cmd_representor_info = {
7116 : : .f = cmd_representor_info_parsed,
7117 : : .data = NULL,
7118 : : .help_str = "show port info <port_id> representor",
7119 : : .tokens = {
7120 : : (void *)&cmd_representor_info_show,
7121 : : (void *)&cmd_representor_info_port,
7122 : : (void *)&cmd_representor_info_info,
7123 : : (void *)&cmd_representor_info_pid,
7124 : : (void *)&cmd_representor_info_keyword,
7125 : : NULL,
7126 : : },
7127 : : };
7128 : :
7129 : :
7130 : : /* *** SHOW DEVICE INFO *** */
7131 : : struct cmd_showdevice_result {
7132 : : cmdline_fixed_string_t show;
7133 : : cmdline_fixed_string_t device;
7134 : : cmdline_fixed_string_t what;
7135 : : cmdline_fixed_string_t identifier;
7136 : : };
7137 : :
7138 : 0 : static void cmd_showdevice_parsed(void *parsed_result,
7139 : : __rte_unused struct cmdline *cl,
7140 : : __rte_unused void *data)
7141 : : {
7142 : : struct cmd_showdevice_result *res = parsed_result;
7143 : 0 : if (!strcmp(res->what, "info")) {
7144 : 0 : if (!strcmp(res->identifier, "all"))
7145 : 0 : device_infos_display(NULL);
7146 : : else
7147 : 0 : device_infos_display(res->identifier);
7148 : : }
7149 : 0 : }
7150 : :
7151 : : static cmdline_parse_token_string_t cmd_showdevice_show =
7152 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, show,
7153 : : "show");
7154 : : static cmdline_parse_token_string_t cmd_showdevice_device =
7155 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, device, "device");
7156 : : static cmdline_parse_token_string_t cmd_showdevice_what =
7157 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, what,
7158 : : "info");
7159 : : static cmdline_parse_token_string_t cmd_showdevice_identifier =
7160 : : TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result,
7161 : : identifier, NULL);
7162 : :
7163 : : static cmdline_parse_inst_t cmd_showdevice = {
7164 : : .f = cmd_showdevice_parsed,
7165 : : .data = NULL,
7166 : : .help_str = "show device info <identifier>|all",
7167 : : .tokens = {
7168 : : (void *)&cmd_showdevice_show,
7169 : : (void *)&cmd_showdevice_device,
7170 : : (void *)&cmd_showdevice_what,
7171 : : (void *)&cmd_showdevice_identifier,
7172 : : NULL,
7173 : : },
7174 : : };
7175 : :
7176 : : /* *** SHOW MODULE EEPROM/EEPROM port INFO *** */
7177 : : struct cmd_showeeprom_result {
7178 : : cmdline_fixed_string_t show;
7179 : : cmdline_fixed_string_t port;
7180 : : uint16_t portnum;
7181 : : cmdline_fixed_string_t type;
7182 : : };
7183 : :
7184 : 0 : static void cmd_showeeprom_parsed(void *parsed_result,
7185 : : __rte_unused struct cmdline *cl,
7186 : : __rte_unused void *data)
7187 : : {
7188 : : struct cmd_showeeprom_result *res = parsed_result;
7189 : :
7190 : 0 : if (!strcmp(res->type, "eeprom"))
7191 : 0 : port_eeprom_display(res->portnum);
7192 : 0 : else if (!strcmp(res->type, "module_eeprom"))
7193 : 0 : port_module_eeprom_display(res->portnum);
7194 : : else
7195 : 0 : fprintf(stderr, "Unknown argument\n");
7196 : 0 : }
7197 : :
7198 : : static cmdline_parse_token_string_t cmd_showeeprom_show =
7199 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, show, "show");
7200 : : static cmdline_parse_token_string_t cmd_showeeprom_port =
7201 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, port, "port");
7202 : : static cmdline_parse_token_num_t cmd_showeeprom_portnum =
7203 : : TOKEN_NUM_INITIALIZER(struct cmd_showeeprom_result, portnum,
7204 : : RTE_UINT16);
7205 : : static cmdline_parse_token_string_t cmd_showeeprom_type =
7206 : : TOKEN_STRING_INITIALIZER(struct cmd_showeeprom_result, type, "module_eeprom#eeprom");
7207 : :
7208 : : static cmdline_parse_inst_t cmd_showeeprom = {
7209 : : .f = cmd_showeeprom_parsed,
7210 : : .data = NULL,
7211 : : .help_str = "show port <port_id> module_eeprom|eeprom",
7212 : : .tokens = {
7213 : : (void *)&cmd_showeeprom_show,
7214 : : (void *)&cmd_showeeprom_port,
7215 : : (void *)&cmd_showeeprom_portnum,
7216 : : (void *)&cmd_showeeprom_type,
7217 : : NULL,
7218 : : },
7219 : : };
7220 : :
7221 : : /* *** SHOW QUEUE INFO *** */
7222 : : struct cmd_showqueue_result {
7223 : : cmdline_fixed_string_t show;
7224 : : cmdline_fixed_string_t type;
7225 : : cmdline_fixed_string_t what;
7226 : : uint16_t portnum;
7227 : : uint16_t queuenum;
7228 : : };
7229 : :
7230 : : static void
7231 : 0 : cmd_showqueue_parsed(void *parsed_result,
7232 : : __rte_unused struct cmdline *cl,
7233 : : __rte_unused void *data)
7234 : : {
7235 : : struct cmd_showqueue_result *res = parsed_result;
7236 : :
7237 : 0 : if (!strcmp(res->type, "rxq"))
7238 : 0 : rx_queue_infos_display(res->portnum, res->queuenum);
7239 : 0 : else if (!strcmp(res->type, "txq"))
7240 : 0 : tx_queue_infos_display(res->portnum, res->queuenum);
7241 : 0 : }
7242 : :
7243 : : static cmdline_parse_token_string_t cmd_showqueue_show =
7244 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show");
7245 : : static cmdline_parse_token_string_t cmd_showqueue_type =
7246 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq");
7247 : : static cmdline_parse_token_string_t cmd_showqueue_what =
7248 : : TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info");
7249 : : static cmdline_parse_token_num_t cmd_showqueue_portnum =
7250 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum,
7251 : : RTE_UINT16);
7252 : : static cmdline_parse_token_num_t cmd_showqueue_queuenum =
7253 : : TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum,
7254 : : RTE_UINT16);
7255 : :
7256 : : static cmdline_parse_inst_t cmd_showqueue = {
7257 : : .f = cmd_showqueue_parsed,
7258 : : .data = NULL,
7259 : : .help_str = "show rxq|txq info <port_id> <queue_id>",
7260 : : .tokens = {
7261 : : (void *)&cmd_showqueue_show,
7262 : : (void *)&cmd_showqueue_type,
7263 : : (void *)&cmd_showqueue_what,
7264 : : (void *)&cmd_showqueue_portnum,
7265 : : (void *)&cmd_showqueue_queuenum,
7266 : : NULL,
7267 : : },
7268 : : };
7269 : :
7270 : : /* show/clear fwd engine statistics */
7271 : : struct fwd_result {
7272 : : cmdline_fixed_string_t action;
7273 : : cmdline_fixed_string_t fwd;
7274 : : cmdline_fixed_string_t stats;
7275 : : cmdline_fixed_string_t all;
7276 : : };
7277 : :
7278 : : static cmdline_parse_token_string_t cmd_fwd_action =
7279 : : TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear");
7280 : : static cmdline_parse_token_string_t cmd_fwd_fwd =
7281 : : TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd");
7282 : : static cmdline_parse_token_string_t cmd_fwd_stats =
7283 : : TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats");
7284 : : static cmdline_parse_token_string_t cmd_fwd_all =
7285 : : TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all");
7286 : :
7287 : : static void
7288 : 0 : cmd_showfwdall_parsed(void *parsed_result,
7289 : : __rte_unused struct cmdline *cl,
7290 : : __rte_unused void *data)
7291 : : {
7292 : : struct fwd_result *res = parsed_result;
7293 : :
7294 : 0 : if (!strcmp(res->action, "show"))
7295 : 0 : fwd_stats_display();
7296 : : else
7297 : 0 : fwd_stats_reset();
7298 : 0 : }
7299 : :
7300 : : static cmdline_parse_inst_t cmd_showfwdall = {
7301 : : .f = cmd_showfwdall_parsed,
7302 : : .data = NULL,
7303 : : .help_str = "show|clear fwd stats all",
7304 : : .tokens = {
7305 : : (void *)&cmd_fwd_action,
7306 : : (void *)&cmd_fwd_fwd,
7307 : : (void *)&cmd_fwd_stats,
7308 : : (void *)&cmd_fwd_all,
7309 : : NULL,
7310 : : },
7311 : : };
7312 : :
7313 : : /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */
7314 : : struct cmd_read_rxd_txd_result {
7315 : : cmdline_fixed_string_t read;
7316 : : cmdline_fixed_string_t rxd_txd;
7317 : : portid_t port_id;
7318 : : uint16_t queue_id;
7319 : : uint16_t desc_id;
7320 : : };
7321 : :
7322 : : static void
7323 : 0 : cmd_read_rxd_txd_parsed(void *parsed_result,
7324 : : __rte_unused struct cmdline *cl,
7325 : : __rte_unused void *data)
7326 : : {
7327 : : struct cmd_read_rxd_txd_result *res = parsed_result;
7328 : :
7329 : 0 : if (!strcmp(res->rxd_txd, "rxd"))
7330 : 0 : rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7331 : 0 : else if (!strcmp(res->rxd_txd, "txd"))
7332 : 0 : tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id);
7333 : 0 : }
7334 : :
7335 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_read =
7336 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read");
7337 : : static cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd =
7338 : : TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd,
7339 : : "rxd#txd");
7340 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_port_id =
7341 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id,
7342 : : RTE_UINT16);
7343 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id =
7344 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id,
7345 : : RTE_UINT16);
7346 : : static cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id =
7347 : : TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id,
7348 : : RTE_UINT16);
7349 : :
7350 : : static cmdline_parse_inst_t cmd_read_rxd_txd = {
7351 : : .f = cmd_read_rxd_txd_parsed,
7352 : : .data = NULL,
7353 : : .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>",
7354 : : .tokens = {
7355 : : (void *)&cmd_read_rxd_txd_read,
7356 : : (void *)&cmd_read_rxd_txd_rxd_txd,
7357 : : (void *)&cmd_read_rxd_txd_port_id,
7358 : : (void *)&cmd_read_rxd_txd_queue_id,
7359 : : (void *)&cmd_read_rxd_txd_desc_id,
7360 : : NULL,
7361 : : },
7362 : : };
7363 : :
7364 : : /* *** QUIT *** */
7365 : : struct cmd_quit_result {
7366 : : cmdline_fixed_string_t quit;
7367 : : };
7368 : :
7369 : 0 : static void cmd_quit_parsed(__rte_unused void *parsed_result,
7370 : : struct cmdline *cl,
7371 : : __rte_unused void *data)
7372 : : {
7373 : 0 : cmdline_quit(cl);
7374 : 0 : cl_quit = 1;
7375 : 0 : }
7376 : :
7377 : : static cmdline_parse_token_string_t cmd_quit_quit =
7378 : : TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
7379 : :
7380 : : static cmdline_parse_inst_t cmd_quit = {
7381 : : .f = cmd_quit_parsed,
7382 : : .data = NULL,
7383 : : .help_str = "quit: Exit application",
7384 : : .tokens = {
7385 : : (void *)&cmd_quit_quit,
7386 : : NULL,
7387 : : },
7388 : : };
7389 : :
7390 : : /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */
7391 : : struct cmd_mac_addr_result {
7392 : : cmdline_fixed_string_t mac_addr_cmd;
7393 : : cmdline_fixed_string_t what;
7394 : : uint16_t port_num;
7395 : : struct rte_ether_addr address;
7396 : : };
7397 : :
7398 : 0 : static void cmd_mac_addr_parsed(void *parsed_result,
7399 : : __rte_unused struct cmdline *cl,
7400 : : __rte_unused void *data)
7401 : : {
7402 : : struct cmd_mac_addr_result *res = parsed_result;
7403 : : int ret;
7404 : :
7405 : 0 : if (strcmp(res->what, "add") == 0)
7406 : 0 : ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
7407 : 0 : else if (strcmp(res->what, "set") == 0)
7408 : 0 : ret = rte_eth_dev_default_mac_addr_set(res->port_num,
7409 : : &res->address);
7410 : : else
7411 : 0 : ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address);
7412 : :
7413 : : /* check the return value and print it if is < 0 */
7414 : 0 : if(ret < 0)
7415 : 0 : fprintf(stderr, "mac_addr_cmd error: (%s)\n", strerror(-ret));
7416 : :
7417 : 0 : }
7418 : :
7419 : : static cmdline_parse_token_string_t cmd_mac_addr_cmd =
7420 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd,
7421 : : "mac_addr");
7422 : : static cmdline_parse_token_string_t cmd_mac_addr_what =
7423 : : TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what,
7424 : : "add#remove#set");
7425 : : static cmdline_parse_token_num_t cmd_mac_addr_portnum =
7426 : : TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num,
7427 : : RTE_UINT16);
7428 : : static cmdline_parse_token_etheraddr_t cmd_mac_addr_addr =
7429 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
7430 : :
7431 : : static cmdline_parse_inst_t cmd_mac_addr = {
7432 : : .f = cmd_mac_addr_parsed,
7433 : : .data = (void *)0,
7434 : : .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: "
7435 : : "Add/Remove/Set MAC address on port_id",
7436 : : .tokens = {
7437 : : (void *)&cmd_mac_addr_cmd,
7438 : : (void *)&cmd_mac_addr_what,
7439 : : (void *)&cmd_mac_addr_portnum,
7440 : : (void *)&cmd_mac_addr_addr,
7441 : : NULL,
7442 : : },
7443 : : };
7444 : :
7445 : : /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */
7446 : : struct cmd_eth_peer_result {
7447 : : cmdline_fixed_string_t set;
7448 : : cmdline_fixed_string_t eth_peer;
7449 : : portid_t port_id;
7450 : : cmdline_fixed_string_t peer_addr;
7451 : : };
7452 : :
7453 : 0 : static void cmd_set_eth_peer_parsed(void *parsed_result,
7454 : : __rte_unused struct cmdline *cl,
7455 : : __rte_unused void *data)
7456 : : {
7457 : : struct cmd_eth_peer_result *res = parsed_result;
7458 : :
7459 : 0 : if (test_done == 0) {
7460 : 0 : fprintf(stderr, "Please stop forwarding first\n");
7461 : 0 : return;
7462 : : }
7463 : 0 : if (!strcmp(res->eth_peer, "eth-peer")) {
7464 : 0 : set_fwd_eth_peer(res->port_id, res->peer_addr);
7465 : 0 : fwd_config_setup();
7466 : : }
7467 : : }
7468 : : static cmdline_parse_token_string_t cmd_eth_peer_set =
7469 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set");
7470 : : static cmdline_parse_token_string_t cmd_eth_peer =
7471 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer");
7472 : : static cmdline_parse_token_num_t cmd_eth_peer_port_id =
7473 : : TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id,
7474 : : RTE_UINT16);
7475 : : static cmdline_parse_token_string_t cmd_eth_peer_addr =
7476 : : TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
7477 : :
7478 : : static cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
7479 : : .f = cmd_set_eth_peer_parsed,
7480 : : .data = NULL,
7481 : : .help_str = "set eth-peer <port_id> <peer_mac>",
7482 : : .tokens = {
7483 : : (void *)&cmd_eth_peer_set,
7484 : : (void *)&cmd_eth_peer,
7485 : : (void *)&cmd_eth_peer_port_id,
7486 : : (void *)&cmd_eth_peer_addr,
7487 : : NULL,
7488 : : },
7489 : : };
7490 : :
7491 : : /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
7492 : : struct cmd_set_qmap_result {
7493 : : cmdline_fixed_string_t set;
7494 : : cmdline_fixed_string_t qmap;
7495 : : cmdline_fixed_string_t what;
7496 : : portid_t port_id;
7497 : : uint16_t queue_id;
7498 : : uint8_t map_value;
7499 : : };
7500 : :
7501 : : static void
7502 : 0 : cmd_set_qmap_parsed(void *parsed_result,
7503 : : __rte_unused struct cmdline *cl,
7504 : : __rte_unused void *data)
7505 : : {
7506 : : struct cmd_set_qmap_result *res = parsed_result;
7507 : 0 : int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1;
7508 : :
7509 : 0 : set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value);
7510 : 0 : }
7511 : :
7512 : : static cmdline_parse_token_string_t cmd_setqmap_set =
7513 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7514 : : set, "set");
7515 : : static cmdline_parse_token_string_t cmd_setqmap_qmap =
7516 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7517 : : qmap, "stat_qmap");
7518 : : static cmdline_parse_token_string_t cmd_setqmap_what =
7519 : : TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result,
7520 : : what, "tx#rx");
7521 : : static cmdline_parse_token_num_t cmd_setqmap_portid =
7522 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7523 : : port_id, RTE_UINT16);
7524 : : static cmdline_parse_token_num_t cmd_setqmap_queueid =
7525 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7526 : : queue_id, RTE_UINT16);
7527 : : static cmdline_parse_token_num_t cmd_setqmap_mapvalue =
7528 : : TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result,
7529 : : map_value, RTE_UINT8);
7530 : :
7531 : : static cmdline_parse_inst_t cmd_set_qmap = {
7532 : : .f = cmd_set_qmap_parsed,
7533 : : .data = NULL,
7534 : : .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: "
7535 : : "Set statistics mapping value on tx|rx queue_id of port_id",
7536 : : .tokens = {
7537 : : (void *)&cmd_setqmap_set,
7538 : : (void *)&cmd_setqmap_qmap,
7539 : : (void *)&cmd_setqmap_what,
7540 : : (void *)&cmd_setqmap_portid,
7541 : : (void *)&cmd_setqmap_queueid,
7542 : : (void *)&cmd_setqmap_mapvalue,
7543 : : NULL,
7544 : : },
7545 : : };
7546 : :
7547 : : /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */
7548 : : struct cmd_set_xstats_hide_zero_result {
7549 : : cmdline_fixed_string_t keyword;
7550 : : cmdline_fixed_string_t name;
7551 : : cmdline_fixed_string_t on_off;
7552 : : };
7553 : :
7554 : : static void
7555 : 0 : cmd_set_xstats_hide_zero_parsed(void *parsed_result,
7556 : : __rte_unused struct cmdline *cl,
7557 : : __rte_unused void *data)
7558 : : {
7559 : : struct cmd_set_xstats_hide_zero_result *res;
7560 : : uint16_t on_off = 0;
7561 : :
7562 : : res = parsed_result;
7563 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7564 : 0 : set_xstats_hide_zero(on_off);
7565 : 0 : }
7566 : :
7567 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword =
7568 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7569 : : keyword, "set");
7570 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name =
7571 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7572 : : name, "xstats-hide-zero");
7573 : : static cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off =
7574 : : TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result,
7575 : : on_off, "on#off");
7576 : :
7577 : : static cmdline_parse_inst_t cmd_set_xstats_hide_zero = {
7578 : : .f = cmd_set_xstats_hide_zero_parsed,
7579 : : .data = NULL,
7580 : : .help_str = "set xstats-hide-zero on|off",
7581 : : .tokens = {
7582 : : (void *)&cmd_set_xstats_hide_zero_keyword,
7583 : : (void *)&cmd_set_xstats_hide_zero_name,
7584 : : (void *)&cmd_set_xstats_hide_zero_on_off,
7585 : : NULL,
7586 : : },
7587 : : };
7588 : :
7589 : : /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */
7590 : : struct cmd_set_record_core_cycles_result {
7591 : : cmdline_fixed_string_t keyword;
7592 : : cmdline_fixed_string_t name;
7593 : : cmdline_fixed_string_t on_off;
7594 : : };
7595 : :
7596 : : static void
7597 : 0 : cmd_set_record_core_cycles_parsed(void *parsed_result,
7598 : : __rte_unused struct cmdline *cl,
7599 : : __rte_unused void *data)
7600 : : {
7601 : : struct cmd_set_record_core_cycles_result *res;
7602 : : uint16_t on_off = 0;
7603 : :
7604 : : res = parsed_result;
7605 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7606 : 0 : set_record_core_cycles(on_off);
7607 : 0 : }
7608 : :
7609 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_keyword =
7610 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7611 : : keyword, "set");
7612 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_name =
7613 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7614 : : name, "record-core-cycles");
7615 : : static cmdline_parse_token_string_t cmd_set_record_core_cycles_on_off =
7616 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_core_cycles_result,
7617 : : on_off, "on#off");
7618 : :
7619 : : static cmdline_parse_inst_t cmd_set_record_core_cycles = {
7620 : : .f = cmd_set_record_core_cycles_parsed,
7621 : : .data = NULL,
7622 : : .help_str = "set record-core-cycles on|off",
7623 : : .tokens = {
7624 : : (void *)&cmd_set_record_core_cycles_keyword,
7625 : : (void *)&cmd_set_record_core_cycles_name,
7626 : : (void *)&cmd_set_record_core_cycles_on_off,
7627 : : NULL,
7628 : : },
7629 : : };
7630 : :
7631 : : /* *** SET OPTION TO ENABLE DISPLAY OF RX AND TX BURSTS *** */
7632 : : struct cmd_set_record_burst_stats_result {
7633 : : cmdline_fixed_string_t keyword;
7634 : : cmdline_fixed_string_t name;
7635 : : cmdline_fixed_string_t on_off;
7636 : : };
7637 : :
7638 : : static void
7639 : 0 : cmd_set_record_burst_stats_parsed(void *parsed_result,
7640 : : __rte_unused struct cmdline *cl,
7641 : : __rte_unused void *data)
7642 : : {
7643 : : struct cmd_set_record_burst_stats_result *res;
7644 : : uint16_t on_off = 0;
7645 : :
7646 : : res = parsed_result;
7647 : 0 : on_off = !strcmp(res->on_off, "on") ? 1 : 0;
7648 : 0 : set_record_burst_stats(on_off);
7649 : 0 : }
7650 : :
7651 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_keyword =
7652 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7653 : : keyword, "set");
7654 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_name =
7655 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7656 : : name, "record-burst-stats");
7657 : : static cmdline_parse_token_string_t cmd_set_record_burst_stats_on_off =
7658 : : TOKEN_STRING_INITIALIZER(struct cmd_set_record_burst_stats_result,
7659 : : on_off, "on#off");
7660 : :
7661 : : static cmdline_parse_inst_t cmd_set_record_burst_stats = {
7662 : : .f = cmd_set_record_burst_stats_parsed,
7663 : : .data = NULL,
7664 : : .help_str = "set record-burst-stats on|off",
7665 : : .tokens = {
7666 : : (void *)&cmd_set_record_burst_stats_keyword,
7667 : : (void *)&cmd_set_record_burst_stats_name,
7668 : : (void *)&cmd_set_record_burst_stats_on_off,
7669 : : NULL,
7670 : : },
7671 : : };
7672 : :
7673 : : /* *** CONFIGURE UNICAST HASH TABLE *** */
7674 : : struct cmd_set_uc_hash_table {
7675 : : cmdline_fixed_string_t set;
7676 : : cmdline_fixed_string_t port;
7677 : : portid_t port_id;
7678 : : cmdline_fixed_string_t what;
7679 : : struct rte_ether_addr address;
7680 : : cmdline_fixed_string_t mode;
7681 : : };
7682 : :
7683 : : static void
7684 : 0 : cmd_set_uc_hash_parsed(void *parsed_result,
7685 : : __rte_unused struct cmdline *cl,
7686 : : __rte_unused void *data)
7687 : : {
7688 : : int ret=0;
7689 : : struct cmd_set_uc_hash_table *res = parsed_result;
7690 : :
7691 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7692 : :
7693 : 0 : if (strcmp(res->what, "uta") == 0)
7694 : 0 : ret = rte_eth_dev_uc_hash_table_set(res->port_id,
7695 : : &res->address,(uint8_t)is_on);
7696 : 0 : if (ret < 0)
7697 : 0 : fprintf(stderr,
7698 : : "bad unicast hash table parameter, return code = %d\n",
7699 : : ret);
7700 : :
7701 : 0 : }
7702 : :
7703 : : static cmdline_parse_token_string_t cmd_set_uc_hash_set =
7704 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7705 : : set, "set");
7706 : : static cmdline_parse_token_string_t cmd_set_uc_hash_port =
7707 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7708 : : port, "port");
7709 : : static cmdline_parse_token_num_t cmd_set_uc_hash_portid =
7710 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table,
7711 : : port_id, RTE_UINT16);
7712 : : static cmdline_parse_token_string_t cmd_set_uc_hash_what =
7713 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7714 : : what, "uta");
7715 : : static cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac =
7716 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table,
7717 : : address);
7718 : : static cmdline_parse_token_string_t cmd_set_uc_hash_mode =
7719 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table,
7720 : : mode, "on#off");
7721 : :
7722 : : static cmdline_parse_inst_t cmd_set_uc_hash_filter = {
7723 : : .f = cmd_set_uc_hash_parsed,
7724 : : .data = NULL,
7725 : : .help_str = "set port <port_id> uta <mac_addr> on|off)",
7726 : : .tokens = {
7727 : : (void *)&cmd_set_uc_hash_set,
7728 : : (void *)&cmd_set_uc_hash_port,
7729 : : (void *)&cmd_set_uc_hash_portid,
7730 : : (void *)&cmd_set_uc_hash_what,
7731 : : (void *)&cmd_set_uc_hash_mac,
7732 : : (void *)&cmd_set_uc_hash_mode,
7733 : : NULL,
7734 : : },
7735 : : };
7736 : :
7737 : : struct cmd_set_uc_all_hash_table {
7738 : : cmdline_fixed_string_t set;
7739 : : cmdline_fixed_string_t port;
7740 : : portid_t port_id;
7741 : : cmdline_fixed_string_t what;
7742 : : cmdline_fixed_string_t value;
7743 : : cmdline_fixed_string_t mode;
7744 : : };
7745 : :
7746 : : static void
7747 : 0 : cmd_set_uc_all_hash_parsed(void *parsed_result,
7748 : : __rte_unused struct cmdline *cl,
7749 : : __rte_unused void *data)
7750 : : {
7751 : : int ret=0;
7752 : : struct cmd_set_uc_all_hash_table *res = parsed_result;
7753 : :
7754 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7755 : :
7756 : 0 : if ((strcmp(res->what, "uta") == 0) &&
7757 : 0 : (strcmp(res->value, "all") == 0))
7758 : 0 : ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on);
7759 : 0 : if (ret < 0)
7760 : 0 : fprintf(stderr,
7761 : : "bad unicast hash table parameter, return code = %d\n",
7762 : : ret);
7763 : 0 : }
7764 : :
7765 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_set =
7766 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7767 : : set, "set");
7768 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_port =
7769 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7770 : : port, "port");
7771 : : static cmdline_parse_token_num_t cmd_set_uc_all_hash_portid =
7772 : : TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table,
7773 : : port_id, RTE_UINT16);
7774 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_what =
7775 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7776 : : what, "uta");
7777 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_value =
7778 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7779 : : value,"all");
7780 : : static cmdline_parse_token_string_t cmd_set_uc_all_hash_mode =
7781 : : TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table,
7782 : : mode, "on#off");
7783 : :
7784 : : static cmdline_parse_inst_t cmd_set_uc_all_hash_filter = {
7785 : : .f = cmd_set_uc_all_hash_parsed,
7786 : : .data = NULL,
7787 : : .help_str = "set port <port_id> uta all on|off",
7788 : : .tokens = {
7789 : : (void *)&cmd_set_uc_all_hash_set,
7790 : : (void *)&cmd_set_uc_all_hash_port,
7791 : : (void *)&cmd_set_uc_all_hash_portid,
7792 : : (void *)&cmd_set_uc_all_hash_what,
7793 : : (void *)&cmd_set_uc_all_hash_value,
7794 : : (void *)&cmd_set_uc_all_hash_mode,
7795 : : NULL,
7796 : : },
7797 : : };
7798 : :
7799 : : /* *** CONFIGURE VF TRAFFIC CONTROL *** */
7800 : : struct cmd_set_vf_traffic {
7801 : : cmdline_fixed_string_t set;
7802 : : cmdline_fixed_string_t port;
7803 : : portid_t port_id;
7804 : : cmdline_fixed_string_t vf;
7805 : : uint8_t vf_id;
7806 : : cmdline_fixed_string_t what;
7807 : : cmdline_fixed_string_t mode;
7808 : : };
7809 : :
7810 : : static void
7811 : 0 : cmd_set_vf_traffic_parsed(void *parsed_result,
7812 : : __rte_unused struct cmdline *cl,
7813 : : __rte_unused void *data)
7814 : : {
7815 : : struct cmd_set_vf_traffic *res = parsed_result;
7816 : 0 : int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0;
7817 : 0 : int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0;
7818 : :
7819 : 0 : set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on);
7820 : 0 : }
7821 : :
7822 : : static cmdline_parse_token_string_t cmd_setvf_traffic_set =
7823 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7824 : : set, "set");
7825 : : static cmdline_parse_token_string_t cmd_setvf_traffic_port =
7826 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7827 : : port, "port");
7828 : : static cmdline_parse_token_num_t cmd_setvf_traffic_portid =
7829 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7830 : : port_id, RTE_UINT16);
7831 : : static cmdline_parse_token_string_t cmd_setvf_traffic_vf =
7832 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7833 : : vf, "vf");
7834 : : static cmdline_parse_token_num_t cmd_setvf_traffic_vfid =
7835 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic,
7836 : : vf_id, RTE_UINT8);
7837 : : static cmdline_parse_token_string_t cmd_setvf_traffic_what =
7838 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7839 : : what, "tx#rx");
7840 : : static cmdline_parse_token_string_t cmd_setvf_traffic_mode =
7841 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic,
7842 : : mode, "on#off");
7843 : :
7844 : : static cmdline_parse_inst_t cmd_set_vf_traffic = {
7845 : : .f = cmd_set_vf_traffic_parsed,
7846 : : .data = NULL,
7847 : : .help_str = "set port <port_id> vf <vf_id> rx|tx on|off",
7848 : : .tokens = {
7849 : : (void *)&cmd_setvf_traffic_set,
7850 : : (void *)&cmd_setvf_traffic_port,
7851 : : (void *)&cmd_setvf_traffic_portid,
7852 : : (void *)&cmd_setvf_traffic_vf,
7853 : : (void *)&cmd_setvf_traffic_vfid,
7854 : : (void *)&cmd_setvf_traffic_what,
7855 : : (void *)&cmd_setvf_traffic_mode,
7856 : : NULL,
7857 : : },
7858 : : };
7859 : :
7860 : : /* *** CONFIGURE VF RECEIVE MODE *** */
7861 : : struct cmd_set_vf_rxmode {
7862 : : cmdline_fixed_string_t set;
7863 : : cmdline_fixed_string_t port;
7864 : : portid_t port_id;
7865 : : cmdline_fixed_string_t vf;
7866 : : uint8_t vf_id;
7867 : : cmdline_fixed_string_t what;
7868 : : cmdline_fixed_string_t mode;
7869 : : cmdline_fixed_string_t on;
7870 : : };
7871 : :
7872 : : static void
7873 : 0 : cmd_set_vf_rxmode_parsed(void *parsed_result,
7874 : : __rte_unused struct cmdline *cl,
7875 : : __rte_unused void *data)
7876 : : {
7877 : : int ret = -ENOTSUP;
7878 : : uint16_t vf_rxmode = 0;
7879 : : struct cmd_set_vf_rxmode *res = parsed_result;
7880 : :
7881 : 0 : int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0;
7882 : 0 : if (!strcmp(res->what,"rxmode")) {
7883 : 0 : if (!strcmp(res->mode, "AUPE"))
7884 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_UNTAG;
7885 : 0 : else if (!strcmp(res->mode, "ROPE"))
7886 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_HASH_UC;
7887 : 0 : else if (!strcmp(res->mode, "BAM"))
7888 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_BROADCAST;
7889 : 0 : else if (!strncmp(res->mode, "MPE",3))
7890 : : vf_rxmode |= RTE_ETH_VMDQ_ACCEPT_MULTICAST;
7891 : : }
7892 : :
7893 : : RTE_SET_USED(is_on);
7894 : : RTE_SET_USED(vf_rxmode);
7895 : :
7896 : : #ifdef RTE_NET_IXGBE
7897 : : if (ret == -ENOTSUP)
7898 : 0 : ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id,
7899 : : vf_rxmode, (uint8_t)is_on);
7900 : : #endif
7901 : : #ifdef RTE_NET_BNXT
7902 : 0 : if (ret == -ENOTSUP)
7903 : 0 : ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id,
7904 : : vf_rxmode, (uint8_t)is_on);
7905 : : #endif
7906 : 0 : if (ret < 0)
7907 : 0 : fprintf(stderr,
7908 : : "bad VF receive mode parameter, return code = %d\n",
7909 : : ret);
7910 : 0 : }
7911 : :
7912 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_set =
7913 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7914 : : set, "set");
7915 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_port =
7916 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7917 : : port, "port");
7918 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_portid =
7919 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7920 : : port_id, RTE_UINT16);
7921 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_vf =
7922 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7923 : : vf, "vf");
7924 : : static cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid =
7925 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode,
7926 : : vf_id, RTE_UINT8);
7927 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_what =
7928 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7929 : : what, "rxmode");
7930 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_mode =
7931 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7932 : : mode, "AUPE#ROPE#BAM#MPE");
7933 : : static cmdline_parse_token_string_t cmd_set_vf_rxmode_on =
7934 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode,
7935 : : on, "on#off");
7936 : :
7937 : : static cmdline_parse_inst_t cmd_set_vf_rxmode = {
7938 : : .f = cmd_set_vf_rxmode_parsed,
7939 : : .data = NULL,
7940 : : .help_str = "set port <port_id> vf <vf_id> rxmode "
7941 : : "AUPE|ROPE|BAM|MPE on|off",
7942 : : .tokens = {
7943 : : (void *)&cmd_set_vf_rxmode_set,
7944 : : (void *)&cmd_set_vf_rxmode_port,
7945 : : (void *)&cmd_set_vf_rxmode_portid,
7946 : : (void *)&cmd_set_vf_rxmode_vf,
7947 : : (void *)&cmd_set_vf_rxmode_vfid,
7948 : : (void *)&cmd_set_vf_rxmode_what,
7949 : : (void *)&cmd_set_vf_rxmode_mode,
7950 : : (void *)&cmd_set_vf_rxmode_on,
7951 : : NULL,
7952 : : },
7953 : : };
7954 : :
7955 : : /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */
7956 : : struct cmd_vf_mac_addr_result {
7957 : : cmdline_fixed_string_t mac_addr_cmd;
7958 : : cmdline_fixed_string_t what;
7959 : : cmdline_fixed_string_t port;
7960 : : uint16_t port_num;
7961 : : cmdline_fixed_string_t vf;
7962 : : uint8_t vf_num;
7963 : : struct rte_ether_addr address;
7964 : : };
7965 : :
7966 : 0 : static void cmd_vf_mac_addr_parsed(void *parsed_result,
7967 : : __rte_unused struct cmdline *cl,
7968 : : __rte_unused void *data)
7969 : : {
7970 : : struct cmd_vf_mac_addr_result *res = parsed_result;
7971 : : int ret = -ENOTSUP;
7972 : :
7973 : 0 : if (strcmp(res->what, "add") != 0)
7974 : : return;
7975 : :
7976 : : #ifdef RTE_NET_I40E
7977 : : if (ret == -ENOTSUP)
7978 : 0 : ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num,
7979 : : &res->address);
7980 : : #endif
7981 : : #ifdef RTE_NET_BNXT
7982 : 0 : if (ret == -ENOTSUP)
7983 : 0 : ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address,
7984 : 0 : res->vf_num);
7985 : : #endif
7986 : :
7987 : 0 : if(ret < 0)
7988 : 0 : fprintf(stderr, "vf_mac_addr_cmd error: (%s)\n", strerror(-ret));
7989 : :
7990 : : }
7991 : :
7992 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_cmd =
7993 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7994 : : mac_addr_cmd,"mac_addr");
7995 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_what =
7996 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
7997 : : what,"add");
7998 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_port =
7999 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8000 : : port,"port");
8001 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_portnum =
8002 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8003 : : port_num, RTE_UINT16);
8004 : : static cmdline_parse_token_string_t cmd_vf_mac_addr_vf =
8005 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result,
8006 : : vf,"vf");
8007 : : static cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum =
8008 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result,
8009 : : vf_num, RTE_UINT8);
8010 : : static cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr =
8011 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result,
8012 : : address);
8013 : :
8014 : : static cmdline_parse_inst_t cmd_vf_mac_addr_filter = {
8015 : : .f = cmd_vf_mac_addr_parsed,
8016 : : .data = (void *)0,
8017 : : .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: "
8018 : : "Add MAC address filtering for a VF on port_id",
8019 : : .tokens = {
8020 : : (void *)&cmd_vf_mac_addr_cmd,
8021 : : (void *)&cmd_vf_mac_addr_what,
8022 : : (void *)&cmd_vf_mac_addr_port,
8023 : : (void *)&cmd_vf_mac_addr_portnum,
8024 : : (void *)&cmd_vf_mac_addr_vf,
8025 : : (void *)&cmd_vf_mac_addr_vfnum,
8026 : : (void *)&cmd_vf_mac_addr_addr,
8027 : : NULL,
8028 : : },
8029 : : };
8030 : :
8031 : : /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */
8032 : : struct cmd_vf_rx_vlan_filter {
8033 : : cmdline_fixed_string_t rx_vlan;
8034 : : cmdline_fixed_string_t what;
8035 : : uint16_t vlan_id;
8036 : : cmdline_fixed_string_t port;
8037 : : portid_t port_id;
8038 : : cmdline_fixed_string_t vf;
8039 : : uint64_t vf_mask;
8040 : : };
8041 : :
8042 : : static void
8043 : 0 : cmd_vf_rx_vlan_filter_parsed(void *parsed_result,
8044 : : __rte_unused struct cmdline *cl,
8045 : : __rte_unused void *data)
8046 : : {
8047 : : struct cmd_vf_rx_vlan_filter *res = parsed_result;
8048 : : int ret = -ENOTSUP;
8049 : :
8050 : 0 : __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0;
8051 : :
8052 : : #ifdef RTE_NET_IXGBE
8053 : : if (ret == -ENOTSUP)
8054 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id,
8055 : 0 : res->vlan_id, res->vf_mask, is_add);
8056 : : #endif
8057 : : #ifdef RTE_NET_I40E
8058 : 0 : if (ret == -ENOTSUP)
8059 : 0 : ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id,
8060 : 0 : res->vlan_id, res->vf_mask, is_add);
8061 : : #endif
8062 : : #ifdef RTE_NET_BNXT
8063 : 0 : if (ret == -ENOTSUP)
8064 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id,
8065 : 0 : res->vlan_id, res->vf_mask, is_add);
8066 : : #endif
8067 : :
8068 : 0 : switch (ret) {
8069 : : case 0:
8070 : : break;
8071 : 0 : case -EINVAL:
8072 : 0 : fprintf(stderr, "invalid vlan_id %d or vf_mask %"PRIu64"\n",
8073 : 0 : res->vlan_id, res->vf_mask);
8074 : : break;
8075 : 0 : case -ENODEV:
8076 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8077 : : break;
8078 : 0 : case -ENOTSUP:
8079 : 0 : fprintf(stderr, "function not implemented or supported\n");
8080 : : break;
8081 : 0 : default:
8082 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8083 : : }
8084 : 0 : }
8085 : :
8086 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan =
8087 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8088 : : rx_vlan, "rx_vlan");
8089 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what =
8090 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8091 : : what, "add#rm");
8092 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid =
8093 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8094 : : vlan_id, RTE_UINT16);
8095 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port =
8096 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8097 : : port, "port");
8098 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid =
8099 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8100 : : port_id, RTE_UINT16);
8101 : : static cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf =
8102 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8103 : : vf, "vf");
8104 : : static cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask =
8105 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter,
8106 : : vf_mask, RTE_UINT64);
8107 : :
8108 : : static cmdline_parse_inst_t cmd_vf_rxvlan_filter = {
8109 : : .f = cmd_vf_rx_vlan_filter_parsed,
8110 : : .data = NULL,
8111 : : .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: "
8112 : : "(vf_mask = hexadecimal VF mask)",
8113 : : .tokens = {
8114 : : (void *)&cmd_vf_rx_vlan_filter_rx_vlan,
8115 : : (void *)&cmd_vf_rx_vlan_filter_what,
8116 : : (void *)&cmd_vf_rx_vlan_filter_vlanid,
8117 : : (void *)&cmd_vf_rx_vlan_filter_port,
8118 : : (void *)&cmd_vf_rx_vlan_filter_portid,
8119 : : (void *)&cmd_vf_rx_vlan_filter_vf,
8120 : : (void *)&cmd_vf_rx_vlan_filter_vf_mask,
8121 : : NULL,
8122 : : },
8123 : : };
8124 : :
8125 : : /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */
8126 : : struct cmd_queue_rate_limit_result {
8127 : : cmdline_fixed_string_t set;
8128 : : cmdline_fixed_string_t port;
8129 : : uint16_t port_num;
8130 : : cmdline_fixed_string_t queue;
8131 : : uint8_t queue_num;
8132 : : cmdline_fixed_string_t rate;
8133 : : uint32_t rate_num;
8134 : : };
8135 : :
8136 : 0 : static void cmd_queue_rate_limit_parsed(void *parsed_result,
8137 : : __rte_unused struct cmdline *cl,
8138 : : __rte_unused void *data)
8139 : : {
8140 : : struct cmd_queue_rate_limit_result *res = parsed_result;
8141 : : int ret = 0;
8142 : :
8143 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8144 : 0 : && (strcmp(res->queue, "queue") == 0)
8145 : 0 : && (strcmp(res->rate, "rate") == 0))
8146 : 0 : ret = set_queue_rate_limit(res->port_num, res->queue_num,
8147 : : res->rate_num);
8148 : 0 : if (ret < 0)
8149 : 0 : fprintf(stderr, "queue_rate_limit_cmd error: (%s)\n",
8150 : : strerror(-ret));
8151 : :
8152 : 0 : }
8153 : :
8154 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_set =
8155 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8156 : : set, "set");
8157 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_port =
8158 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8159 : : port, "port");
8160 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_portnum =
8161 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8162 : : port_num, RTE_UINT16);
8163 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_queue =
8164 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8165 : : queue, "queue");
8166 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum =
8167 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8168 : : queue_num, RTE_UINT8);
8169 : : static cmdline_parse_token_string_t cmd_queue_rate_limit_rate =
8170 : : TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result,
8171 : : rate, "rate");
8172 : : static cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum =
8173 : : TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result,
8174 : : rate_num, RTE_UINT32);
8175 : :
8176 : : static cmdline_parse_inst_t cmd_queue_rate_limit = {
8177 : : .f = cmd_queue_rate_limit_parsed,
8178 : : .data = (void *)0,
8179 : : .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: "
8180 : : "Set rate limit for a queue on port_id",
8181 : : .tokens = {
8182 : : (void *)&cmd_queue_rate_limit_set,
8183 : : (void *)&cmd_queue_rate_limit_port,
8184 : : (void *)&cmd_queue_rate_limit_portnum,
8185 : : (void *)&cmd_queue_rate_limit_queue,
8186 : : (void *)&cmd_queue_rate_limit_queuenum,
8187 : : (void *)&cmd_queue_rate_limit_rate,
8188 : : (void *)&cmd_queue_rate_limit_ratenum,
8189 : : NULL,
8190 : : },
8191 : : };
8192 : :
8193 : : /* *** SET RATE LIMIT FOR A VF OF A PORT *** */
8194 : : struct cmd_vf_rate_limit_result {
8195 : : cmdline_fixed_string_t set;
8196 : : cmdline_fixed_string_t port;
8197 : : uint16_t port_num;
8198 : : cmdline_fixed_string_t vf;
8199 : : uint8_t vf_num;
8200 : : cmdline_fixed_string_t rate;
8201 : : uint32_t rate_num;
8202 : : cmdline_fixed_string_t q_msk;
8203 : : uint64_t q_msk_val;
8204 : : };
8205 : :
8206 : 0 : static void cmd_vf_rate_limit_parsed(void *parsed_result,
8207 : : __rte_unused struct cmdline *cl,
8208 : : __rte_unused void *data)
8209 : : {
8210 : : struct cmd_vf_rate_limit_result *res = parsed_result;
8211 : : int ret = 0;
8212 : :
8213 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
8214 : 0 : && (strcmp(res->vf, "vf") == 0)
8215 : 0 : && (strcmp(res->rate, "rate") == 0)
8216 : 0 : && (strcmp(res->q_msk, "queue_mask") == 0))
8217 : 0 : ret = set_vf_rate_limit(res->port_num, res->vf_num,
8218 : : res->rate_num, res->q_msk_val);
8219 : 0 : if (ret < 0)
8220 : 0 : fprintf(stderr, "vf_rate_limit_cmd error: (%s)\n",
8221 : : strerror(-ret));
8222 : :
8223 : 0 : }
8224 : :
8225 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_set =
8226 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8227 : : set, "set");
8228 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_port =
8229 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8230 : : port, "port");
8231 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_portnum =
8232 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8233 : : port_num, RTE_UINT16);
8234 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_vf =
8235 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8236 : : vf, "vf");
8237 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum =
8238 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8239 : : vf_num, RTE_UINT8);
8240 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_rate =
8241 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8242 : : rate, "rate");
8243 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum =
8244 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8245 : : rate_num, RTE_UINT32);
8246 : : static cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk =
8247 : : TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result,
8248 : : q_msk, "queue_mask");
8249 : : static cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val =
8250 : : TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result,
8251 : : q_msk_val, RTE_UINT64);
8252 : :
8253 : : static cmdline_parse_inst_t cmd_vf_rate_limit = {
8254 : : .f = cmd_vf_rate_limit_parsed,
8255 : : .data = (void *)0,
8256 : : .help_str = "set port <port_id> vf <vf_id> rate <rate_value> "
8257 : : "queue_mask <queue_mask_value>: "
8258 : : "Set rate limit for queues of VF on port_id",
8259 : : .tokens = {
8260 : : (void *)&cmd_vf_rate_limit_set,
8261 : : (void *)&cmd_vf_rate_limit_port,
8262 : : (void *)&cmd_vf_rate_limit_portnum,
8263 : : (void *)&cmd_vf_rate_limit_vf,
8264 : : (void *)&cmd_vf_rate_limit_vfnum,
8265 : : (void *)&cmd_vf_rate_limit_rate,
8266 : : (void *)&cmd_vf_rate_limit_ratenum,
8267 : : (void *)&cmd_vf_rate_limit_q_msk,
8268 : : (void *)&cmd_vf_rate_limit_q_msk_val,
8269 : : NULL,
8270 : : },
8271 : : };
8272 : :
8273 : : /* *** CONFIGURE TUNNEL UDP PORT *** */
8274 : : struct cmd_tunnel_udp_config {
8275 : : cmdline_fixed_string_t rx_vxlan_port;
8276 : : cmdline_fixed_string_t what;
8277 : : uint16_t udp_port;
8278 : : portid_t port_id;
8279 : : };
8280 : :
8281 : : static void
8282 : 0 : cmd_tunnel_udp_config_parsed(void *parsed_result,
8283 : : __rte_unused struct cmdline *cl,
8284 : : __rte_unused void *data)
8285 : : {
8286 : : struct cmd_tunnel_udp_config *res = parsed_result;
8287 : : struct rte_eth_udp_tunnel tunnel_udp;
8288 : : int ret;
8289 : :
8290 : 0 : tunnel_udp.udp_port = res->udp_port;
8291 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8292 : :
8293 : 0 : if (!strcmp(res->what, "add"))
8294 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8295 : : &tunnel_udp);
8296 : : else
8297 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8298 : : &tunnel_udp);
8299 : :
8300 : 0 : if (ret < 0)
8301 : 0 : fprintf(stderr, "udp tunneling add error: (%s)\n",
8302 : : strerror(-ret));
8303 : 0 : }
8304 : :
8305 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_rx_vxlan_port =
8306 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8307 : : rx_vxlan_port, "rx_vxlan_port");
8308 : : static cmdline_parse_token_string_t cmd_tunnel_udp_config_what =
8309 : : TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config,
8310 : : what, "add#rm");
8311 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port =
8312 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8313 : : udp_port, RTE_UINT16);
8314 : : static cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id =
8315 : : TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config,
8316 : : port_id, RTE_UINT16);
8317 : :
8318 : : static cmdline_parse_inst_t cmd_tunnel_udp_config = {
8319 : : .f = cmd_tunnel_udp_config_parsed,
8320 : : .data = (void *)0,
8321 : : .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: "
8322 : : "Add/Remove a tunneling UDP port filter",
8323 : : .tokens = {
8324 : : (void *)&cmd_tunnel_udp_config_rx_vxlan_port,
8325 : : (void *)&cmd_tunnel_udp_config_what,
8326 : : (void *)&cmd_tunnel_udp_config_udp_port,
8327 : : (void *)&cmd_tunnel_udp_config_port_id,
8328 : : NULL,
8329 : : },
8330 : : };
8331 : :
8332 : : struct cmd_config_tunnel_udp_port {
8333 : : cmdline_fixed_string_t port;
8334 : : cmdline_fixed_string_t config;
8335 : : portid_t port_id;
8336 : : cmdline_fixed_string_t udp_tunnel_port;
8337 : : cmdline_fixed_string_t action;
8338 : : cmdline_fixed_string_t tunnel_type;
8339 : : uint16_t udp_port;
8340 : : };
8341 : :
8342 : : static void
8343 : 0 : cmd_cfg_tunnel_udp_port_parsed(void *parsed_result,
8344 : : __rte_unused struct cmdline *cl,
8345 : : __rte_unused void *data)
8346 : : {
8347 : : struct cmd_config_tunnel_udp_port *res = parsed_result;
8348 : : struct rte_eth_udp_tunnel tunnel_udp;
8349 : : int ret = 0;
8350 : :
8351 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8352 : 0 : return;
8353 : :
8354 : 0 : tunnel_udp.udp_port = res->udp_port;
8355 : :
8356 : 0 : if (!strcmp(res->tunnel_type, "vxlan")) {
8357 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN;
8358 : 0 : } else if (!strcmp(res->tunnel_type, "geneve")) {
8359 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_GENEVE;
8360 : 0 : } else if (!strcmp(res->tunnel_type, "vxlan-gpe")) {
8361 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_VXLAN_GPE;
8362 : 0 : } else if (!strcmp(res->tunnel_type, "ecpri")) {
8363 : 0 : tunnel_udp.prot_type = RTE_ETH_TUNNEL_TYPE_ECPRI;
8364 : : } else {
8365 : 0 : fprintf(stderr, "Invalid tunnel type\n");
8366 : 0 : return;
8367 : : }
8368 : :
8369 : 0 : if (!strcmp(res->action, "add"))
8370 : 0 : ret = rte_eth_dev_udp_tunnel_port_add(res->port_id,
8371 : : &tunnel_udp);
8372 : : else
8373 : 0 : ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id,
8374 : : &tunnel_udp);
8375 : :
8376 : 0 : if (ret < 0)
8377 : 0 : fprintf(stderr, "udp tunneling port add error: (%s)\n",
8378 : : strerror(-ret));
8379 : : }
8380 : :
8381 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port =
8382 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port,
8383 : : "port");
8384 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config =
8385 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config,
8386 : : "config");
8387 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id =
8388 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id,
8389 : : RTE_UINT16);
8390 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port =
8391 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port,
8392 : : udp_tunnel_port,
8393 : : "udp_tunnel_port");
8394 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action =
8395 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action,
8396 : : "add#rm");
8397 : : static cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type =
8398 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type,
8399 : : "vxlan#geneve#vxlan-gpe#ecpri");
8400 : : static cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value =
8401 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port,
8402 : : RTE_UINT16);
8403 : :
8404 : : static cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = {
8405 : : .f = cmd_cfg_tunnel_udp_port_parsed,
8406 : : .data = NULL,
8407 : : .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|"
8408 : : "geneve|vxlan-gpe|ecpri <udp_port>",
8409 : : .tokens = {
8410 : : (void *)&cmd_config_tunnel_udp_port_port,
8411 : : (void *)&cmd_config_tunnel_udp_port_config,
8412 : : (void *)&cmd_config_tunnel_udp_port_port_id,
8413 : : (void *)&cmd_config_tunnel_udp_port_tunnel_port,
8414 : : (void *)&cmd_config_tunnel_udp_port_action,
8415 : : (void *)&cmd_config_tunnel_udp_port_tunnel_type,
8416 : : (void *)&cmd_config_tunnel_udp_port_value,
8417 : : NULL,
8418 : : },
8419 : : };
8420 : :
8421 : : /* ******************************************************************************** */
8422 : :
8423 : : struct cmd_dump_result {
8424 : : cmdline_fixed_string_t dump;
8425 : : };
8426 : :
8427 : : static void
8428 : 0 : dump_struct_sizes(void)
8429 : : {
8430 : : #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t));
8431 : : DUMP_SIZE(struct rte_mbuf);
8432 : : DUMP_SIZE(struct rte_mempool);
8433 : : DUMP_SIZE(struct rte_ring);
8434 : : #undef DUMP_SIZE
8435 : 0 : }
8436 : :
8437 : :
8438 : : /* Dump the socket memory statistics on console */
8439 : : static void
8440 : 0 : dump_socket_mem(FILE *f)
8441 : : {
8442 : : struct rte_malloc_socket_stats socket_stats;
8443 : : unsigned int i;
8444 : : size_t total = 0;
8445 : : size_t alloc = 0;
8446 : : size_t free = 0;
8447 : : unsigned int n_alloc = 0;
8448 : : unsigned int n_free = 0;
8449 : : static size_t last_allocs;
8450 : : static size_t last_total;
8451 : :
8452 : :
8453 : 0 : for (i = 0; i < RTE_MAX_NUMA_NODES; i++) {
8454 : 0 : if (rte_malloc_get_socket_stats(i, &socket_stats) ||
8455 : 0 : !socket_stats.heap_totalsz_bytes)
8456 : 0 : continue;
8457 : 0 : total += socket_stats.heap_totalsz_bytes;
8458 : 0 : alloc += socket_stats.heap_allocsz_bytes;
8459 : 0 : free += socket_stats.heap_freesz_bytes;
8460 : 0 : n_alloc += socket_stats.alloc_count;
8461 : 0 : n_free += socket_stats.free_count;
8462 : 0 : fprintf(f,
8463 : : "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
8464 : : i,
8465 : : (double)socket_stats.heap_totalsz_bytes / (1024 * 1024),
8466 : : (double)socket_stats.heap_allocsz_bytes / (1024 * 1024),
8467 : 0 : (double)socket_stats.heap_allocsz_bytes * 100 /
8468 : 0 : (double)socket_stats.heap_totalsz_bytes,
8469 : 0 : (double)socket_stats.heap_freesz_bytes / (1024 * 1024),
8470 : : socket_stats.alloc_count,
8471 : : socket_stats.free_count);
8472 : : }
8473 : 0 : fprintf(f,
8474 : : "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n",
8475 : 0 : (double)total / (1024 * 1024), (double)alloc / (1024 * 1024),
8476 : 0 : total ? ((double)alloc * 100 / (double)total) : 0,
8477 : 0 : (double)free / (1024 * 1024),
8478 : : n_alloc, n_free);
8479 : 0 : if (last_allocs)
8480 : 0 : fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
8481 : 0 : ((double)total - (double)last_total) / (1024 * 1024),
8482 : 0 : (double)(alloc - (double)last_allocs) / 1024 / 1024);
8483 : 0 : last_allocs = alloc;
8484 : 0 : last_total = total;
8485 : 0 : }
8486 : :
8487 : 0 : static void cmd_dump_parsed(void *parsed_result,
8488 : : __rte_unused struct cmdline *cl,
8489 : : __rte_unused void *data)
8490 : : {
8491 : : struct cmd_dump_result *res = parsed_result;
8492 : :
8493 : 0 : if (!strcmp(res->dump, "dump_physmem"))
8494 : 0 : rte_dump_physmem_layout(stdout);
8495 : 0 : else if (!strcmp(res->dump, "dump_socket_mem"))
8496 : 0 : dump_socket_mem(stdout);
8497 : 0 : else if (!strcmp(res->dump, "dump_memzone"))
8498 : 0 : rte_memzone_dump(stdout);
8499 : 0 : else if (!strcmp(res->dump, "dump_struct_sizes"))
8500 : 0 : dump_struct_sizes();
8501 : 0 : else if (!strcmp(res->dump, "dump_ring"))
8502 : 0 : rte_ring_list_dump(stdout);
8503 : 0 : else if (!strcmp(res->dump, "dump_mempool"))
8504 : 0 : rte_mempool_list_dump(stdout);
8505 : 0 : else if (!strcmp(res->dump, "dump_devargs"))
8506 : 0 : rte_devargs_dump(stdout);
8507 : 0 : else if (!strcmp(res->dump, "dump_lcores"))
8508 : 0 : rte_lcore_dump(stdout);
8509 : : #ifndef RTE_EXEC_ENV_WINDOWS
8510 : 0 : else if (!strcmp(res->dump, "dump_trace"))
8511 : 0 : rte_trace_save();
8512 : : #endif
8513 : 0 : else if (!strcmp(res->dump, "dump_log_types"))
8514 : 0 : rte_log_dump(stdout);
8515 : 0 : }
8516 : :
8517 : : static cmdline_parse_token_string_t cmd_dump_dump =
8518 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
8519 : : "dump_physmem#"
8520 : : "dump_memzone#"
8521 : : "dump_socket_mem#"
8522 : : "dump_struct_sizes#"
8523 : : "dump_ring#"
8524 : : "dump_mempool#"
8525 : : "dump_devargs#"
8526 : : "dump_lcores#"
8527 : : #ifndef RTE_EXEC_ENV_WINDOWS
8528 : : "dump_trace#"
8529 : : #endif
8530 : : "dump_log_types");
8531 : :
8532 : : static cmdline_parse_inst_t cmd_dump = {
8533 : : .f = cmd_dump_parsed, /* function to call */
8534 : : .data = NULL, /* 2nd arg of func */
8535 : : .help_str = "Dump status",
8536 : : .tokens = { /* token list, NULL terminated */
8537 : : (void *)&cmd_dump_dump,
8538 : : NULL,
8539 : : },
8540 : : };
8541 : :
8542 : : /* ******************************************************************************** */
8543 : :
8544 : : struct cmd_dump_one_result {
8545 : : cmdline_fixed_string_t dump;
8546 : : cmdline_fixed_string_t name;
8547 : : };
8548 : :
8549 : 0 : static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl,
8550 : : __rte_unused void *data)
8551 : : {
8552 : : struct cmd_dump_one_result *res = parsed_result;
8553 : :
8554 : 0 : if (!strcmp(res->dump, "dump_ring")) {
8555 : : struct rte_ring *r;
8556 : 0 : r = rte_ring_lookup(res->name);
8557 : 0 : if (r == NULL) {
8558 : 0 : cmdline_printf(cl, "Cannot find ring\n");
8559 : 0 : return;
8560 : : }
8561 : 0 : rte_ring_dump(stdout, r);
8562 : 0 : } else if (!strcmp(res->dump, "dump_mempool")) {
8563 : : struct rte_mempool *mp;
8564 : 0 : mp = rte_mempool_lookup(res->name);
8565 : 0 : if (mp == NULL) {
8566 : 0 : cmdline_printf(cl, "Cannot find mempool\n");
8567 : 0 : return;
8568 : : }
8569 : 0 : rte_mempool_dump(stdout, mp);
8570 : : }
8571 : : }
8572 : :
8573 : : static cmdline_parse_token_string_t cmd_dump_one_dump =
8574 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump,
8575 : : "dump_ring#dump_mempool");
8576 : :
8577 : : static cmdline_parse_token_string_t cmd_dump_one_name =
8578 : : TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL);
8579 : :
8580 : : static cmdline_parse_inst_t cmd_dump_one = {
8581 : : .f = cmd_dump_one_parsed, /* function to call */
8582 : : .data = NULL, /* 2nd arg of func */
8583 : : .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool",
8584 : : .tokens = { /* token list, NULL terminated */
8585 : : (void *)&cmd_dump_one_dump,
8586 : : (void *)&cmd_dump_one_name,
8587 : : NULL,
8588 : : },
8589 : : };
8590 : :
8591 : : /* *** Filters Control *** */
8592 : :
8593 : : #define IPV4_ADDR_TO_UINT(ip_addr, ip) \
8594 : : do { \
8595 : : if ((ip_addr).family == AF_INET) \
8596 : : (ip) = (ip_addr).addr.ipv4.s_addr; \
8597 : : else { \
8598 : : fprintf(stderr, "invalid parameter.\n"); \
8599 : : return; \
8600 : : } \
8601 : : } while (0)
8602 : :
8603 : : #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
8604 : : do { \
8605 : : if ((ip_addr).family == AF_INET6) \
8606 : : rte_memcpy(&(ip), \
8607 : : &((ip_addr).addr.ipv6), \
8608 : : sizeof(struct in6_addr)); \
8609 : : else { \
8610 : : fprintf(stderr, "invalid parameter.\n"); \
8611 : : return; \
8612 : : } \
8613 : : } while (0)
8614 : :
8615 : : /* Generic flow interface command. */
8616 : : extern cmdline_parse_inst_t cmd_flow;
8617 : :
8618 : : /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */
8619 : : struct cmd_mcast_addr_result {
8620 : : cmdline_fixed_string_t mcast_addr_cmd;
8621 : : cmdline_fixed_string_t what;
8622 : : uint16_t port_num;
8623 : : struct rte_ether_addr mc_addr;
8624 : : };
8625 : :
8626 : 0 : static void cmd_mcast_addr_parsed(void *parsed_result,
8627 : : __rte_unused struct cmdline *cl,
8628 : : __rte_unused void *data)
8629 : : {
8630 : : struct cmd_mcast_addr_result *res = parsed_result;
8631 : :
8632 : 0 : if (!rte_is_multicast_ether_addr(&res->mc_addr)) {
8633 : 0 : fprintf(stderr,
8634 : : "Invalid multicast addr " RTE_ETHER_ADDR_PRT_FMT "\n",
8635 : 0 : RTE_ETHER_ADDR_BYTES(&res->mc_addr));
8636 : 0 : return;
8637 : : }
8638 : 0 : if (strcmp(res->what, "add") == 0)
8639 : 0 : mcast_addr_add(res->port_num, &res->mc_addr);
8640 : : else
8641 : 0 : mcast_addr_remove(res->port_num, &res->mc_addr);
8642 : : }
8643 : :
8644 : : static cmdline_parse_token_string_t cmd_mcast_addr_cmd =
8645 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8646 : : mcast_addr_cmd, "mcast_addr");
8647 : : static cmdline_parse_token_string_t cmd_mcast_addr_what =
8648 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8649 : : "add#remove");
8650 : : static cmdline_parse_token_num_t cmd_mcast_addr_portnum =
8651 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
8652 : : RTE_UINT16);
8653 : : static cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr =
8654 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address);
8655 : :
8656 : : static cmdline_parse_inst_t cmd_mcast_addr = {
8657 : : .f = cmd_mcast_addr_parsed,
8658 : : .data = (void *)0,
8659 : : .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: "
8660 : : "Add/Remove multicast MAC address on port_id",
8661 : : .tokens = {
8662 : : (void *)&cmd_mcast_addr_cmd,
8663 : : (void *)&cmd_mcast_addr_what,
8664 : : (void *)&cmd_mcast_addr_portnum,
8665 : : (void *)&cmd_mcast_addr_addr,
8666 : : NULL,
8667 : : },
8668 : : };
8669 : :
8670 : : /* *** FLUSH MULTICAST MAC ADDRESS ON PORT *** */
8671 : : struct cmd_mcast_addr_flush_result {
8672 : : cmdline_fixed_string_t mcast_addr_cmd;
8673 : : cmdline_fixed_string_t what;
8674 : : uint16_t port_num;
8675 : : };
8676 : :
8677 : 0 : static void cmd_mcast_addr_flush_parsed(void *parsed_result,
8678 : : __rte_unused struct cmdline *cl,
8679 : : __rte_unused void *data)
8680 : : {
8681 : : struct cmd_mcast_addr_flush_result *res = parsed_result;
8682 : :
8683 : 0 : mcast_addr_flush(res->port_num);
8684 : 0 : }
8685 : :
8686 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_cmd =
8687 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result,
8688 : : mcast_addr_cmd, "mcast_addr");
8689 : : static cmdline_parse_token_string_t cmd_mcast_addr_flush_what =
8690 : : TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what,
8691 : : "flush");
8692 : : static cmdline_parse_token_num_t cmd_mcast_addr_flush_portnum =
8693 : : TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num,
8694 : : RTE_UINT16);
8695 : :
8696 : : static cmdline_parse_inst_t cmd_mcast_addr_flush = {
8697 : : .f = cmd_mcast_addr_flush_parsed,
8698 : : .data = (void *)0,
8699 : : .help_str = "mcast_addr flush <port_id> : "
8700 : : "flush all multicast MAC addresses on port_id",
8701 : : .tokens = {
8702 : : (void *)&cmd_mcast_addr_flush_cmd,
8703 : : (void *)&cmd_mcast_addr_flush_what,
8704 : : (void *)&cmd_mcast_addr_flush_portnum,
8705 : : NULL,
8706 : : },
8707 : : };
8708 : :
8709 : : /* vf vlan anti spoof configuration */
8710 : :
8711 : : /* Common result structure for vf vlan anti spoof */
8712 : : struct cmd_vf_vlan_anti_spoof_result {
8713 : : cmdline_fixed_string_t set;
8714 : : cmdline_fixed_string_t vf;
8715 : : cmdline_fixed_string_t vlan;
8716 : : cmdline_fixed_string_t antispoof;
8717 : : portid_t port_id;
8718 : : uint32_t vf_id;
8719 : : cmdline_fixed_string_t on_off;
8720 : : };
8721 : :
8722 : : /* Common CLI fields for vf vlan anti spoof enable disable */
8723 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
8724 : : TOKEN_STRING_INITIALIZER
8725 : : (struct cmd_vf_vlan_anti_spoof_result,
8726 : : set, "set");
8727 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
8728 : : TOKEN_STRING_INITIALIZER
8729 : : (struct cmd_vf_vlan_anti_spoof_result,
8730 : : vf, "vf");
8731 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
8732 : : TOKEN_STRING_INITIALIZER
8733 : : (struct cmd_vf_vlan_anti_spoof_result,
8734 : : vlan, "vlan");
8735 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
8736 : : TOKEN_STRING_INITIALIZER
8737 : : (struct cmd_vf_vlan_anti_spoof_result,
8738 : : antispoof, "antispoof");
8739 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
8740 : : TOKEN_NUM_INITIALIZER
8741 : : (struct cmd_vf_vlan_anti_spoof_result,
8742 : : port_id, RTE_UINT16);
8743 : : static cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
8744 : : TOKEN_NUM_INITIALIZER
8745 : : (struct cmd_vf_vlan_anti_spoof_result,
8746 : : vf_id, RTE_UINT32);
8747 : : static cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
8748 : : TOKEN_STRING_INITIALIZER
8749 : : (struct cmd_vf_vlan_anti_spoof_result,
8750 : : on_off, "on#off");
8751 : :
8752 : : static void
8753 : 0 : cmd_set_vf_vlan_anti_spoof_parsed(
8754 : : void *parsed_result,
8755 : : __rte_unused struct cmdline *cl,
8756 : : __rte_unused void *data)
8757 : : {
8758 : : struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
8759 : : int ret = -ENOTSUP;
8760 : :
8761 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8762 : :
8763 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8764 : : return;
8765 : :
8766 : : #ifdef RTE_NET_IXGBE
8767 : : if (ret == -ENOTSUP)
8768 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id,
8769 : 0 : res->vf_id, is_on);
8770 : : #endif
8771 : : #ifdef RTE_NET_I40E
8772 : 0 : if (ret == -ENOTSUP)
8773 : 0 : ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id,
8774 : 0 : res->vf_id, is_on);
8775 : : #endif
8776 : : #ifdef RTE_NET_BNXT
8777 : 0 : if (ret == -ENOTSUP)
8778 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id,
8779 : 0 : res->vf_id, is_on);
8780 : : #endif
8781 : :
8782 : 0 : switch (ret) {
8783 : : case 0:
8784 : : break;
8785 : 0 : case -EINVAL:
8786 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
8787 : : break;
8788 : 0 : case -ENODEV:
8789 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8790 : : break;
8791 : 0 : case -ENOTSUP:
8792 : 0 : fprintf(stderr, "function not implemented\n");
8793 : : break;
8794 : 0 : default:
8795 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8796 : : }
8797 : : }
8798 : :
8799 : : static cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
8800 : : .f = cmd_set_vf_vlan_anti_spoof_parsed,
8801 : : .data = NULL,
8802 : : .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off",
8803 : : .tokens = {
8804 : : (void *)&cmd_vf_vlan_anti_spoof_set,
8805 : : (void *)&cmd_vf_vlan_anti_spoof_vf,
8806 : : (void *)&cmd_vf_vlan_anti_spoof_vlan,
8807 : : (void *)&cmd_vf_vlan_anti_spoof_antispoof,
8808 : : (void *)&cmd_vf_vlan_anti_spoof_port_id,
8809 : : (void *)&cmd_vf_vlan_anti_spoof_vf_id,
8810 : : (void *)&cmd_vf_vlan_anti_spoof_on_off,
8811 : : NULL,
8812 : : },
8813 : : };
8814 : :
8815 : : /* vf mac anti spoof configuration */
8816 : :
8817 : : /* Common result structure for vf mac anti spoof */
8818 : : struct cmd_vf_mac_anti_spoof_result {
8819 : : cmdline_fixed_string_t set;
8820 : : cmdline_fixed_string_t vf;
8821 : : cmdline_fixed_string_t mac;
8822 : : cmdline_fixed_string_t antispoof;
8823 : : portid_t port_id;
8824 : : uint32_t vf_id;
8825 : : cmdline_fixed_string_t on_off;
8826 : : };
8827 : :
8828 : : /* Common CLI fields for vf mac anti spoof enable disable */
8829 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
8830 : : TOKEN_STRING_INITIALIZER
8831 : : (struct cmd_vf_mac_anti_spoof_result,
8832 : : set, "set");
8833 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
8834 : : TOKEN_STRING_INITIALIZER
8835 : : (struct cmd_vf_mac_anti_spoof_result,
8836 : : vf, "vf");
8837 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
8838 : : TOKEN_STRING_INITIALIZER
8839 : : (struct cmd_vf_mac_anti_spoof_result,
8840 : : mac, "mac");
8841 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
8842 : : TOKEN_STRING_INITIALIZER
8843 : : (struct cmd_vf_mac_anti_spoof_result,
8844 : : antispoof, "antispoof");
8845 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
8846 : : TOKEN_NUM_INITIALIZER
8847 : : (struct cmd_vf_mac_anti_spoof_result,
8848 : : port_id, RTE_UINT16);
8849 : : static cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
8850 : : TOKEN_NUM_INITIALIZER
8851 : : (struct cmd_vf_mac_anti_spoof_result,
8852 : : vf_id, RTE_UINT32);
8853 : : static cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
8854 : : TOKEN_STRING_INITIALIZER
8855 : : (struct cmd_vf_mac_anti_spoof_result,
8856 : : on_off, "on#off");
8857 : :
8858 : : static void
8859 : 0 : cmd_set_vf_mac_anti_spoof_parsed(
8860 : : void *parsed_result,
8861 : : __rte_unused struct cmdline *cl,
8862 : : __rte_unused void *data)
8863 : : {
8864 : : struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
8865 : : int ret = -ENOTSUP;
8866 : :
8867 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8868 : :
8869 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8870 : : return;
8871 : :
8872 : : #ifdef RTE_NET_IXGBE
8873 : : if (ret == -ENOTSUP)
8874 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id,
8875 : 0 : res->vf_id, is_on);
8876 : : #endif
8877 : : #ifdef RTE_NET_I40E
8878 : 0 : if (ret == -ENOTSUP)
8879 : 0 : ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id,
8880 : 0 : res->vf_id, is_on);
8881 : : #endif
8882 : : #ifdef RTE_NET_BNXT
8883 : 0 : if (ret == -ENOTSUP)
8884 : 0 : ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id,
8885 : 0 : res->vf_id, is_on);
8886 : : #endif
8887 : :
8888 : 0 : switch (ret) {
8889 : : case 0:
8890 : : break;
8891 : 0 : case -EINVAL:
8892 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
8893 : : res->vf_id, is_on);
8894 : : break;
8895 : 0 : case -ENODEV:
8896 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
8897 : : break;
8898 : 0 : case -ENOTSUP:
8899 : 0 : fprintf(stderr, "function not implemented\n");
8900 : : break;
8901 : 0 : default:
8902 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
8903 : : }
8904 : : }
8905 : :
8906 : : static cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
8907 : : .f = cmd_set_vf_mac_anti_spoof_parsed,
8908 : : .data = NULL,
8909 : : .help_str = "set vf mac antispoof <port_id> <vf_id> on|off",
8910 : : .tokens = {
8911 : : (void *)&cmd_vf_mac_anti_spoof_set,
8912 : : (void *)&cmd_vf_mac_anti_spoof_vf,
8913 : : (void *)&cmd_vf_mac_anti_spoof_mac,
8914 : : (void *)&cmd_vf_mac_anti_spoof_antispoof,
8915 : : (void *)&cmd_vf_mac_anti_spoof_port_id,
8916 : : (void *)&cmd_vf_mac_anti_spoof_vf_id,
8917 : : (void *)&cmd_vf_mac_anti_spoof_on_off,
8918 : : NULL,
8919 : : },
8920 : : };
8921 : :
8922 : : /* vf vlan strip queue configuration */
8923 : :
8924 : : /* Common result structure for vf mac anti spoof */
8925 : : struct cmd_vf_vlan_stripq_result {
8926 : : cmdline_fixed_string_t set;
8927 : : cmdline_fixed_string_t vf;
8928 : : cmdline_fixed_string_t vlan;
8929 : : cmdline_fixed_string_t stripq;
8930 : : portid_t port_id;
8931 : : uint16_t vf_id;
8932 : : cmdline_fixed_string_t on_off;
8933 : : };
8934 : :
8935 : : /* Common CLI fields for vf vlan strip enable disable */
8936 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
8937 : : TOKEN_STRING_INITIALIZER
8938 : : (struct cmd_vf_vlan_stripq_result,
8939 : : set, "set");
8940 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
8941 : : TOKEN_STRING_INITIALIZER
8942 : : (struct cmd_vf_vlan_stripq_result,
8943 : : vf, "vf");
8944 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
8945 : : TOKEN_STRING_INITIALIZER
8946 : : (struct cmd_vf_vlan_stripq_result,
8947 : : vlan, "vlan");
8948 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
8949 : : TOKEN_STRING_INITIALIZER
8950 : : (struct cmd_vf_vlan_stripq_result,
8951 : : stripq, "stripq");
8952 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
8953 : : TOKEN_NUM_INITIALIZER
8954 : : (struct cmd_vf_vlan_stripq_result,
8955 : : port_id, RTE_UINT16);
8956 : : static cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
8957 : : TOKEN_NUM_INITIALIZER
8958 : : (struct cmd_vf_vlan_stripq_result,
8959 : : vf_id, RTE_UINT16);
8960 : : static cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
8961 : : TOKEN_STRING_INITIALIZER
8962 : : (struct cmd_vf_vlan_stripq_result,
8963 : : on_off, "on#off");
8964 : :
8965 : : static void
8966 : 0 : cmd_set_vf_vlan_stripq_parsed(
8967 : : void *parsed_result,
8968 : : __rte_unused struct cmdline *cl,
8969 : : __rte_unused void *data)
8970 : : {
8971 : : struct cmd_vf_vlan_stripq_result *res = parsed_result;
8972 : : int ret = -ENOTSUP;
8973 : :
8974 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
8975 : :
8976 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
8977 : : return;
8978 : :
8979 : : #ifdef RTE_NET_IXGBE
8980 : : if (ret == -ENOTSUP)
8981 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id,
8982 : 0 : res->vf_id, is_on);
8983 : : #endif
8984 : : #ifdef RTE_NET_I40E
8985 : 0 : if (ret == -ENOTSUP)
8986 : 0 : ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id,
8987 : 0 : res->vf_id, is_on);
8988 : : #endif
8989 : : #ifdef RTE_NET_BNXT
8990 : 0 : if (ret == -ENOTSUP)
8991 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id,
8992 : 0 : res->vf_id, is_on);
8993 : : #endif
8994 : :
8995 : 0 : switch (ret) {
8996 : : case 0:
8997 : : break;
8998 : 0 : case -EINVAL:
8999 : 0 : fprintf(stderr, "invalid vf_id %d or is_on %d\n",
9000 : 0 : res->vf_id, is_on);
9001 : : break;
9002 : 0 : case -ENODEV:
9003 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9004 : : break;
9005 : 0 : case -ENOTSUP:
9006 : 0 : fprintf(stderr, "function not implemented\n");
9007 : : break;
9008 : 0 : default:
9009 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9010 : : }
9011 : : }
9012 : :
9013 : : static cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
9014 : : .f = cmd_set_vf_vlan_stripq_parsed,
9015 : : .data = NULL,
9016 : : .help_str = "set vf vlan stripq <port_id> <vf_id> on|off",
9017 : : .tokens = {
9018 : : (void *)&cmd_vf_vlan_stripq_set,
9019 : : (void *)&cmd_vf_vlan_stripq_vf,
9020 : : (void *)&cmd_vf_vlan_stripq_vlan,
9021 : : (void *)&cmd_vf_vlan_stripq_stripq,
9022 : : (void *)&cmd_vf_vlan_stripq_port_id,
9023 : : (void *)&cmd_vf_vlan_stripq_vf_id,
9024 : : (void *)&cmd_vf_vlan_stripq_on_off,
9025 : : NULL,
9026 : : },
9027 : : };
9028 : :
9029 : : /* vf vlan insert configuration */
9030 : :
9031 : : /* Common result structure for vf vlan insert */
9032 : : struct cmd_vf_vlan_insert_result {
9033 : : cmdline_fixed_string_t set;
9034 : : cmdline_fixed_string_t vf;
9035 : : cmdline_fixed_string_t vlan;
9036 : : cmdline_fixed_string_t insert;
9037 : : portid_t port_id;
9038 : : uint16_t vf_id;
9039 : : uint16_t vlan_id;
9040 : : };
9041 : :
9042 : : /* Common CLI fields for vf vlan insert enable disable */
9043 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
9044 : : TOKEN_STRING_INITIALIZER
9045 : : (struct cmd_vf_vlan_insert_result,
9046 : : set, "set");
9047 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
9048 : : TOKEN_STRING_INITIALIZER
9049 : : (struct cmd_vf_vlan_insert_result,
9050 : : vf, "vf");
9051 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
9052 : : TOKEN_STRING_INITIALIZER
9053 : : (struct cmd_vf_vlan_insert_result,
9054 : : vlan, "vlan");
9055 : : static cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
9056 : : TOKEN_STRING_INITIALIZER
9057 : : (struct cmd_vf_vlan_insert_result,
9058 : : insert, "insert");
9059 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
9060 : : TOKEN_NUM_INITIALIZER
9061 : : (struct cmd_vf_vlan_insert_result,
9062 : : port_id, RTE_UINT16);
9063 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
9064 : : TOKEN_NUM_INITIALIZER
9065 : : (struct cmd_vf_vlan_insert_result,
9066 : : vf_id, RTE_UINT16);
9067 : : static cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id =
9068 : : TOKEN_NUM_INITIALIZER
9069 : : (struct cmd_vf_vlan_insert_result,
9070 : : vlan_id, RTE_UINT16);
9071 : :
9072 : : static void
9073 : 0 : cmd_set_vf_vlan_insert_parsed(
9074 : : void *parsed_result,
9075 : : __rte_unused struct cmdline *cl,
9076 : : __rte_unused void *data)
9077 : : {
9078 : : struct cmd_vf_vlan_insert_result *res = parsed_result;
9079 : : int ret = -ENOTSUP;
9080 : :
9081 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9082 : : return;
9083 : :
9084 : : #ifdef RTE_NET_IXGBE
9085 : : if (ret == -ENOTSUP)
9086 : 0 : ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id,
9087 : 0 : res->vlan_id);
9088 : : #endif
9089 : : #ifdef RTE_NET_I40E
9090 : 0 : if (ret == -ENOTSUP)
9091 : 0 : ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id,
9092 : 0 : res->vlan_id);
9093 : : #endif
9094 : : #ifdef RTE_NET_BNXT
9095 : 0 : if (ret == -ENOTSUP)
9096 : 0 : ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id,
9097 : 0 : res->vlan_id);
9098 : : #endif
9099 : :
9100 : 0 : switch (ret) {
9101 : : case 0:
9102 : : break;
9103 : 0 : case -EINVAL:
9104 : 0 : fprintf(stderr, "invalid vf_id %d or vlan_id %d\n",
9105 : 0 : res->vf_id, res->vlan_id);
9106 : : break;
9107 : 0 : case -ENODEV:
9108 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9109 : : break;
9110 : 0 : case -ENOTSUP:
9111 : 0 : fprintf(stderr, "function not implemented\n");
9112 : : break;
9113 : 0 : default:
9114 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9115 : : }
9116 : : }
9117 : :
9118 : : static cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
9119 : : .f = cmd_set_vf_vlan_insert_parsed,
9120 : : .data = NULL,
9121 : : .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>",
9122 : : .tokens = {
9123 : : (void *)&cmd_vf_vlan_insert_set,
9124 : : (void *)&cmd_vf_vlan_insert_vf,
9125 : : (void *)&cmd_vf_vlan_insert_vlan,
9126 : : (void *)&cmd_vf_vlan_insert_insert,
9127 : : (void *)&cmd_vf_vlan_insert_port_id,
9128 : : (void *)&cmd_vf_vlan_insert_vf_id,
9129 : : (void *)&cmd_vf_vlan_insert_vlan_id,
9130 : : NULL,
9131 : : },
9132 : : };
9133 : :
9134 : : /* tx loopback configuration */
9135 : :
9136 : : /* Common result structure for tx loopback */
9137 : : struct cmd_tx_loopback_result {
9138 : : cmdline_fixed_string_t set;
9139 : : cmdline_fixed_string_t tx;
9140 : : cmdline_fixed_string_t loopback;
9141 : : portid_t port_id;
9142 : : cmdline_fixed_string_t on_off;
9143 : : };
9144 : :
9145 : : /* Common CLI fields for tx loopback enable disable */
9146 : : static cmdline_parse_token_string_t cmd_tx_loopback_set =
9147 : : TOKEN_STRING_INITIALIZER
9148 : : (struct cmd_tx_loopback_result,
9149 : : set, "set");
9150 : : static cmdline_parse_token_string_t cmd_tx_loopback_tx =
9151 : : TOKEN_STRING_INITIALIZER
9152 : : (struct cmd_tx_loopback_result,
9153 : : tx, "tx");
9154 : : static cmdline_parse_token_string_t cmd_tx_loopback_loopback =
9155 : : TOKEN_STRING_INITIALIZER
9156 : : (struct cmd_tx_loopback_result,
9157 : : loopback, "loopback");
9158 : : static cmdline_parse_token_num_t cmd_tx_loopback_port_id =
9159 : : TOKEN_NUM_INITIALIZER
9160 : : (struct cmd_tx_loopback_result,
9161 : : port_id, RTE_UINT16);
9162 : : static cmdline_parse_token_string_t cmd_tx_loopback_on_off =
9163 : : TOKEN_STRING_INITIALIZER
9164 : : (struct cmd_tx_loopback_result,
9165 : : on_off, "on#off");
9166 : :
9167 : : static void
9168 : 0 : cmd_set_tx_loopback_parsed(
9169 : : void *parsed_result,
9170 : : __rte_unused struct cmdline *cl,
9171 : : __rte_unused void *data)
9172 : : {
9173 : : struct cmd_tx_loopback_result *res = parsed_result;
9174 : : int ret = -ENOTSUP;
9175 : :
9176 : 0 : __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9177 : :
9178 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9179 : : return;
9180 : :
9181 : : #ifdef RTE_NET_IXGBE
9182 : : if (ret == -ENOTSUP)
9183 : 0 : ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
9184 : : #endif
9185 : : #ifdef RTE_NET_I40E
9186 : 0 : if (ret == -ENOTSUP)
9187 : 0 : ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on);
9188 : : #endif
9189 : : #ifdef RTE_NET_BNXT
9190 : 0 : if (ret == -ENOTSUP)
9191 : 0 : ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on);
9192 : : #endif
9193 : : #if defined RTE_BUS_DPAA && defined RTE_NET_DPAA
9194 : 0 : if (ret == -ENOTSUP)
9195 : 0 : ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on);
9196 : : #endif
9197 : :
9198 : 0 : switch (ret) {
9199 : : case 0:
9200 : : break;
9201 : 0 : case -EINVAL:
9202 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9203 : : break;
9204 : 0 : case -ENODEV:
9205 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9206 : : break;
9207 : 0 : case -ENOTSUP:
9208 : 0 : fprintf(stderr, "function not implemented\n");
9209 : : break;
9210 : 0 : default:
9211 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9212 : : }
9213 : : }
9214 : :
9215 : : static cmdline_parse_inst_t cmd_set_tx_loopback = {
9216 : : .f = cmd_set_tx_loopback_parsed,
9217 : : .data = NULL,
9218 : : .help_str = "set tx loopback <port_id> on|off",
9219 : : .tokens = {
9220 : : (void *)&cmd_tx_loopback_set,
9221 : : (void *)&cmd_tx_loopback_tx,
9222 : : (void *)&cmd_tx_loopback_loopback,
9223 : : (void *)&cmd_tx_loopback_port_id,
9224 : : (void *)&cmd_tx_loopback_on_off,
9225 : : NULL,
9226 : : },
9227 : : };
9228 : :
9229 : : /* all queues drop enable configuration */
9230 : :
9231 : : /* Common result structure for all queues drop enable */
9232 : : struct cmd_all_queues_drop_en_result {
9233 : : cmdline_fixed_string_t set;
9234 : : cmdline_fixed_string_t all;
9235 : : cmdline_fixed_string_t queues;
9236 : : cmdline_fixed_string_t drop;
9237 : : portid_t port_id;
9238 : : cmdline_fixed_string_t on_off;
9239 : : };
9240 : :
9241 : : /* Common CLI fields for tx loopback enable disable */
9242 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
9243 : : TOKEN_STRING_INITIALIZER
9244 : : (struct cmd_all_queues_drop_en_result,
9245 : : set, "set");
9246 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
9247 : : TOKEN_STRING_INITIALIZER
9248 : : (struct cmd_all_queues_drop_en_result,
9249 : : all, "all");
9250 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
9251 : : TOKEN_STRING_INITIALIZER
9252 : : (struct cmd_all_queues_drop_en_result,
9253 : : queues, "queues");
9254 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
9255 : : TOKEN_STRING_INITIALIZER
9256 : : (struct cmd_all_queues_drop_en_result,
9257 : : drop, "drop");
9258 : : static cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
9259 : : TOKEN_NUM_INITIALIZER
9260 : : (struct cmd_all_queues_drop_en_result,
9261 : : port_id, RTE_UINT16);
9262 : : static cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
9263 : : TOKEN_STRING_INITIALIZER
9264 : : (struct cmd_all_queues_drop_en_result,
9265 : : on_off, "on#off");
9266 : :
9267 : : static void
9268 : 0 : cmd_set_all_queues_drop_en_parsed(
9269 : : void *parsed_result,
9270 : : __rte_unused struct cmdline *cl,
9271 : : __rte_unused void *data)
9272 : : {
9273 : : struct cmd_all_queues_drop_en_result *res = parsed_result;
9274 : : int ret = -ENOTSUP;
9275 : 0 : int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
9276 : :
9277 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9278 : : return;
9279 : :
9280 : : #ifdef RTE_NET_IXGBE
9281 : : if (ret == -ENOTSUP)
9282 : 0 : ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
9283 : : #endif
9284 : : #ifdef RTE_NET_BNXT
9285 : 0 : if (ret == -ENOTSUP)
9286 : 0 : ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on);
9287 : : #endif
9288 : 0 : switch (ret) {
9289 : : case 0:
9290 : : break;
9291 : 0 : case -EINVAL:
9292 : 0 : fprintf(stderr, "invalid is_on %d\n", is_on);
9293 : : break;
9294 : 0 : case -ENODEV:
9295 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9296 : : break;
9297 : 0 : case -ENOTSUP:
9298 : 0 : fprintf(stderr, "function not implemented\n");
9299 : : break;
9300 : 0 : default:
9301 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9302 : : }
9303 : : }
9304 : :
9305 : : static cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
9306 : : .f = cmd_set_all_queues_drop_en_parsed,
9307 : : .data = NULL,
9308 : : .help_str = "set all queues drop <port_id> on|off",
9309 : : .tokens = {
9310 : : (void *)&cmd_all_queues_drop_en_set,
9311 : : (void *)&cmd_all_queues_drop_en_all,
9312 : : (void *)&cmd_all_queues_drop_en_queues,
9313 : : (void *)&cmd_all_queues_drop_en_drop,
9314 : : (void *)&cmd_all_queues_drop_en_port_id,
9315 : : (void *)&cmd_all_queues_drop_en_on_off,
9316 : : NULL,
9317 : : },
9318 : : };
9319 : :
9320 : : /* vf mac address configuration */
9321 : :
9322 : : /* Common result structure for vf mac address */
9323 : : struct cmd_set_vf_mac_addr_result {
9324 : : cmdline_fixed_string_t set;
9325 : : cmdline_fixed_string_t vf;
9326 : : cmdline_fixed_string_t mac;
9327 : : cmdline_fixed_string_t addr;
9328 : : portid_t port_id;
9329 : : uint16_t vf_id;
9330 : : struct rte_ether_addr mac_addr;
9331 : :
9332 : : };
9333 : :
9334 : : /* Common CLI fields for vf split drop enable disable */
9335 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
9336 : : TOKEN_STRING_INITIALIZER
9337 : : (struct cmd_set_vf_mac_addr_result,
9338 : : set, "set");
9339 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
9340 : : TOKEN_STRING_INITIALIZER
9341 : : (struct cmd_set_vf_mac_addr_result,
9342 : : vf, "vf");
9343 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
9344 : : TOKEN_STRING_INITIALIZER
9345 : : (struct cmd_set_vf_mac_addr_result,
9346 : : mac, "mac");
9347 : : static cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
9348 : : TOKEN_STRING_INITIALIZER
9349 : : (struct cmd_set_vf_mac_addr_result,
9350 : : addr, "addr");
9351 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
9352 : : TOKEN_NUM_INITIALIZER
9353 : : (struct cmd_set_vf_mac_addr_result,
9354 : : port_id, RTE_UINT16);
9355 : : static cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
9356 : : TOKEN_NUM_INITIALIZER
9357 : : (struct cmd_set_vf_mac_addr_result,
9358 : : vf_id, RTE_UINT16);
9359 : : static cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
9360 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
9361 : : mac_addr);
9362 : :
9363 : : static void
9364 : 0 : cmd_set_vf_mac_addr_parsed(
9365 : : void *parsed_result,
9366 : : __rte_unused struct cmdline *cl,
9367 : : __rte_unused void *data)
9368 : : {
9369 : : struct cmd_set_vf_mac_addr_result *res = parsed_result;
9370 : : int ret = -ENOTSUP;
9371 : :
9372 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
9373 : : return;
9374 : :
9375 : : #ifdef RTE_NET_IXGBE
9376 : : if (ret == -ENOTSUP)
9377 : 0 : ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
9378 : : &res->mac_addr);
9379 : : #endif
9380 : : #ifdef RTE_NET_I40E
9381 : 0 : if (ret == -ENOTSUP)
9382 : 0 : ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
9383 : : &res->mac_addr);
9384 : : #endif
9385 : : #ifdef RTE_NET_BNXT
9386 : 0 : if (ret == -ENOTSUP)
9387 : 0 : ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
9388 : : &res->mac_addr);
9389 : : #endif
9390 : :
9391 : 0 : switch (ret) {
9392 : : case 0:
9393 : : break;
9394 : 0 : case -EINVAL:
9395 : 0 : fprintf(stderr, "invalid vf_id %d or mac_addr\n", res->vf_id);
9396 : : break;
9397 : 0 : case -ENODEV:
9398 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
9399 : : break;
9400 : 0 : case -ENOTSUP:
9401 : 0 : fprintf(stderr, "function not implemented\n");
9402 : : break;
9403 : 0 : default:
9404 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
9405 : : }
9406 : : }
9407 : :
9408 : : static cmdline_parse_inst_t cmd_set_vf_mac_addr = {
9409 : : .f = cmd_set_vf_mac_addr_parsed,
9410 : : .data = NULL,
9411 : : .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>",
9412 : : .tokens = {
9413 : : (void *)&cmd_set_vf_mac_addr_set,
9414 : : (void *)&cmd_set_vf_mac_addr_vf,
9415 : : (void *)&cmd_set_vf_mac_addr_mac,
9416 : : (void *)&cmd_set_vf_mac_addr_addr,
9417 : : (void *)&cmd_set_vf_mac_addr_port_id,
9418 : : (void *)&cmd_set_vf_mac_addr_vf_id,
9419 : : (void *)&cmd_set_vf_mac_addr_mac_addr,
9420 : : NULL,
9421 : : },
9422 : : };
9423 : :
9424 : : /** Set VXLAN encapsulation details */
9425 : : struct cmd_set_vxlan_result {
9426 : : cmdline_fixed_string_t set;
9427 : : cmdline_fixed_string_t vxlan;
9428 : : cmdline_fixed_string_t pos_token;
9429 : : cmdline_fixed_string_t ip_version;
9430 : : uint32_t vlan_present:1;
9431 : : uint32_t vni;
9432 : : uint16_t udp_src;
9433 : : uint16_t udp_dst;
9434 : : cmdline_ipaddr_t ip_src;
9435 : : cmdline_ipaddr_t ip_dst;
9436 : : uint16_t tci;
9437 : : uint8_t tos;
9438 : : uint8_t ttl;
9439 : : struct rte_ether_addr eth_src;
9440 : : struct rte_ether_addr eth_dst;
9441 : : };
9442 : :
9443 : : static cmdline_parse_token_string_t cmd_set_vxlan_set =
9444 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set");
9445 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan =
9446 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan");
9447 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl =
9448 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
9449 : : "vxlan-tos-ttl");
9450 : : static cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan =
9451 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan,
9452 : : "vxlan-with-vlan");
9453 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version =
9454 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9455 : : "ip-version");
9456 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value =
9457 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version,
9458 : : "ipv4#ipv6");
9459 : : static cmdline_parse_token_string_t cmd_set_vxlan_vni =
9460 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9461 : : "vni");
9462 : : static cmdline_parse_token_num_t cmd_set_vxlan_vni_value =
9463 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, RTE_UINT32);
9464 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_src =
9465 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9466 : : "udp-src");
9467 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value =
9468 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, RTE_UINT16);
9469 : : static cmdline_parse_token_string_t cmd_set_vxlan_udp_dst =
9470 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9471 : : "udp-dst");
9472 : : static cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value =
9473 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, RTE_UINT16);
9474 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_tos =
9475 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9476 : : "ip-tos");
9477 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value =
9478 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, RTE_UINT8);
9479 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl =
9480 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9481 : : "ip-ttl");
9482 : : static cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value =
9483 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, RTE_UINT8);
9484 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_src =
9485 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9486 : : "ip-src");
9487 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value =
9488 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src);
9489 : : static cmdline_parse_token_string_t cmd_set_vxlan_ip_dst =
9490 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9491 : : "ip-dst");
9492 : : static cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value =
9493 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst);
9494 : : static cmdline_parse_token_string_t cmd_set_vxlan_vlan =
9495 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9496 : : "vlan-tci");
9497 : : static cmdline_parse_token_num_t cmd_set_vxlan_vlan_value =
9498 : : TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, RTE_UINT16);
9499 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_src =
9500 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9501 : : "eth-src");
9502 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value =
9503 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src);
9504 : : static cmdline_parse_token_string_t cmd_set_vxlan_eth_dst =
9505 : : TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token,
9506 : : "eth-dst");
9507 : : static cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value =
9508 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst);
9509 : :
9510 : 0 : static void cmd_set_vxlan_parsed(void *parsed_result,
9511 : : __rte_unused struct cmdline *cl,
9512 : : __rte_unused void *data)
9513 : : {
9514 : : struct cmd_set_vxlan_result *res = parsed_result;
9515 : : union {
9516 : : uint32_t vxlan_id;
9517 : : uint8_t vni[4];
9518 : 0 : } id = {
9519 : 0 : .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff),
9520 : : };
9521 : :
9522 : 0 : vxlan_encap_conf.select_tos_ttl = 0;
9523 : 0 : if (strcmp(res->vxlan, "vxlan") == 0)
9524 : 0 : vxlan_encap_conf.select_vlan = 0;
9525 : 0 : else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0)
9526 : 0 : vxlan_encap_conf.select_vlan = 1;
9527 : 0 : else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) {
9528 : 0 : vxlan_encap_conf.select_vlan = 0;
9529 : 0 : vxlan_encap_conf.select_tos_ttl = 1;
9530 : : }
9531 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
9532 : 0 : vxlan_encap_conf.select_ipv4 = 1;
9533 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
9534 : 0 : vxlan_encap_conf.select_ipv4 = 0;
9535 : : else
9536 : 0 : return;
9537 : : rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3);
9538 : 0 : vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
9539 : 0 : vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
9540 : 0 : vxlan_encap_conf.ip_tos = res->tos;
9541 : 0 : vxlan_encap_conf.ip_ttl = res->ttl;
9542 : 0 : if (vxlan_encap_conf.select_ipv4) {
9543 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src);
9544 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst);
9545 : : } else {
9546 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src);
9547 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst);
9548 : : }
9549 : 0 : if (vxlan_encap_conf.select_vlan)
9550 : 0 : vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9551 : 0 : rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes,
9552 : : RTE_ETHER_ADDR_LEN);
9553 : : rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9554 : : RTE_ETHER_ADDR_LEN);
9555 : : }
9556 : :
9557 : : static cmdline_parse_inst_t cmd_set_vxlan = {
9558 : : .f = cmd_set_vxlan_parsed,
9559 : : .data = NULL,
9560 : : .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src"
9561 : : " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>"
9562 : : " eth-src <eth-src> eth-dst <eth-dst>",
9563 : : .tokens = {
9564 : : (void *)&cmd_set_vxlan_set,
9565 : : (void *)&cmd_set_vxlan_vxlan,
9566 : : (void *)&cmd_set_vxlan_ip_version,
9567 : : (void *)&cmd_set_vxlan_ip_version_value,
9568 : : (void *)&cmd_set_vxlan_vni,
9569 : : (void *)&cmd_set_vxlan_vni_value,
9570 : : (void *)&cmd_set_vxlan_udp_src,
9571 : : (void *)&cmd_set_vxlan_udp_src_value,
9572 : : (void *)&cmd_set_vxlan_udp_dst,
9573 : : (void *)&cmd_set_vxlan_udp_dst_value,
9574 : : (void *)&cmd_set_vxlan_ip_src,
9575 : : (void *)&cmd_set_vxlan_ip_src_value,
9576 : : (void *)&cmd_set_vxlan_ip_dst,
9577 : : (void *)&cmd_set_vxlan_ip_dst_value,
9578 : : (void *)&cmd_set_vxlan_eth_src,
9579 : : (void *)&cmd_set_vxlan_eth_src_value,
9580 : : (void *)&cmd_set_vxlan_eth_dst,
9581 : : (void *)&cmd_set_vxlan_eth_dst_value,
9582 : : NULL,
9583 : : },
9584 : : };
9585 : :
9586 : : static cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = {
9587 : : .f = cmd_set_vxlan_parsed,
9588 : : .data = NULL,
9589 : : .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src"
9590 : : " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>"
9591 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
9592 : : " eth-dst <eth-dst>",
9593 : : .tokens = {
9594 : : (void *)&cmd_set_vxlan_set,
9595 : : (void *)&cmd_set_vxlan_vxlan_tos_ttl,
9596 : : (void *)&cmd_set_vxlan_ip_version,
9597 : : (void *)&cmd_set_vxlan_ip_version_value,
9598 : : (void *)&cmd_set_vxlan_vni,
9599 : : (void *)&cmd_set_vxlan_vni_value,
9600 : : (void *)&cmd_set_vxlan_udp_src,
9601 : : (void *)&cmd_set_vxlan_udp_src_value,
9602 : : (void *)&cmd_set_vxlan_udp_dst,
9603 : : (void *)&cmd_set_vxlan_udp_dst_value,
9604 : : (void *)&cmd_set_vxlan_ip_tos,
9605 : : (void *)&cmd_set_vxlan_ip_tos_value,
9606 : : (void *)&cmd_set_vxlan_ip_ttl,
9607 : : (void *)&cmd_set_vxlan_ip_ttl_value,
9608 : : (void *)&cmd_set_vxlan_ip_src,
9609 : : (void *)&cmd_set_vxlan_ip_src_value,
9610 : : (void *)&cmd_set_vxlan_ip_dst,
9611 : : (void *)&cmd_set_vxlan_ip_dst_value,
9612 : : (void *)&cmd_set_vxlan_eth_src,
9613 : : (void *)&cmd_set_vxlan_eth_src_value,
9614 : : (void *)&cmd_set_vxlan_eth_dst,
9615 : : (void *)&cmd_set_vxlan_eth_dst_value,
9616 : : NULL,
9617 : : },
9618 : : };
9619 : :
9620 : : static cmdline_parse_inst_t cmd_set_vxlan_with_vlan = {
9621 : : .f = cmd_set_vxlan_parsed,
9622 : : .data = NULL,
9623 : : .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>"
9624 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst"
9625 : : " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst"
9626 : : " <eth-dst>",
9627 : : .tokens = {
9628 : : (void *)&cmd_set_vxlan_set,
9629 : : (void *)&cmd_set_vxlan_vxlan_with_vlan,
9630 : : (void *)&cmd_set_vxlan_ip_version,
9631 : : (void *)&cmd_set_vxlan_ip_version_value,
9632 : : (void *)&cmd_set_vxlan_vni,
9633 : : (void *)&cmd_set_vxlan_vni_value,
9634 : : (void *)&cmd_set_vxlan_udp_src,
9635 : : (void *)&cmd_set_vxlan_udp_src_value,
9636 : : (void *)&cmd_set_vxlan_udp_dst,
9637 : : (void *)&cmd_set_vxlan_udp_dst_value,
9638 : : (void *)&cmd_set_vxlan_ip_src,
9639 : : (void *)&cmd_set_vxlan_ip_src_value,
9640 : : (void *)&cmd_set_vxlan_ip_dst,
9641 : : (void *)&cmd_set_vxlan_ip_dst_value,
9642 : : (void *)&cmd_set_vxlan_vlan,
9643 : : (void *)&cmd_set_vxlan_vlan_value,
9644 : : (void *)&cmd_set_vxlan_eth_src,
9645 : : (void *)&cmd_set_vxlan_eth_src_value,
9646 : : (void *)&cmd_set_vxlan_eth_dst,
9647 : : (void *)&cmd_set_vxlan_eth_dst_value,
9648 : : NULL,
9649 : : },
9650 : : };
9651 : :
9652 : : /** Set NVGRE encapsulation details */
9653 : : struct cmd_set_nvgre_result {
9654 : : cmdline_fixed_string_t set;
9655 : : cmdline_fixed_string_t nvgre;
9656 : : cmdline_fixed_string_t pos_token;
9657 : : cmdline_fixed_string_t ip_version;
9658 : : uint32_t tni;
9659 : : cmdline_ipaddr_t ip_src;
9660 : : cmdline_ipaddr_t ip_dst;
9661 : : uint16_t tci;
9662 : : struct rte_ether_addr eth_src;
9663 : : struct rte_ether_addr eth_dst;
9664 : : };
9665 : :
9666 : : static cmdline_parse_token_string_t cmd_set_nvgre_set =
9667 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set");
9668 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre =
9669 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre");
9670 : : static cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan =
9671 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre,
9672 : : "nvgre-with-vlan");
9673 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version =
9674 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9675 : : "ip-version");
9676 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value =
9677 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version,
9678 : : "ipv4#ipv6");
9679 : : static cmdline_parse_token_string_t cmd_set_nvgre_tni =
9680 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9681 : : "tni");
9682 : : static cmdline_parse_token_num_t cmd_set_nvgre_tni_value =
9683 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, RTE_UINT32);
9684 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_src =
9685 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9686 : : "ip-src");
9687 : : static cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value =
9688 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src);
9689 : : static cmdline_parse_token_string_t cmd_set_nvgre_ip_dst =
9690 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9691 : : "ip-dst");
9692 : : static cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value =
9693 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst);
9694 : : static cmdline_parse_token_string_t cmd_set_nvgre_vlan =
9695 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9696 : : "vlan-tci");
9697 : : static cmdline_parse_token_num_t cmd_set_nvgre_vlan_value =
9698 : : TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, RTE_UINT16);
9699 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_src =
9700 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9701 : : "eth-src");
9702 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value =
9703 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src);
9704 : : static cmdline_parse_token_string_t cmd_set_nvgre_eth_dst =
9705 : : TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token,
9706 : : "eth-dst");
9707 : : static cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value =
9708 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst);
9709 : :
9710 : 0 : static void cmd_set_nvgre_parsed(void *parsed_result,
9711 : : __rte_unused struct cmdline *cl,
9712 : : __rte_unused void *data)
9713 : : {
9714 : : struct cmd_set_nvgre_result *res = parsed_result;
9715 : : union {
9716 : : uint32_t nvgre_tni;
9717 : : uint8_t tni[4];
9718 : 0 : } id = {
9719 : 0 : .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff),
9720 : : };
9721 : :
9722 : 0 : if (strcmp(res->nvgre, "nvgre") == 0)
9723 : 0 : nvgre_encap_conf.select_vlan = 0;
9724 : 0 : else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0)
9725 : 0 : nvgre_encap_conf.select_vlan = 1;
9726 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
9727 : 0 : nvgre_encap_conf.select_ipv4 = 1;
9728 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
9729 : 0 : nvgre_encap_conf.select_ipv4 = 0;
9730 : : else
9731 : 0 : return;
9732 : : rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3);
9733 : 0 : if (nvgre_encap_conf.select_ipv4) {
9734 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src);
9735 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst);
9736 : : } else {
9737 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src);
9738 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst);
9739 : : }
9740 : 0 : if (nvgre_encap_conf.select_vlan)
9741 : 0 : nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9742 : : rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes,
9743 : : RTE_ETHER_ADDR_LEN);
9744 : 0 : rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9745 : : RTE_ETHER_ADDR_LEN);
9746 : : }
9747 : :
9748 : : static cmdline_parse_inst_t cmd_set_nvgre = {
9749 : : .f = cmd_set_nvgre_parsed,
9750 : : .data = NULL,
9751 : : .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src"
9752 : : " <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
9753 : : " eth-dst <eth-dst>",
9754 : : .tokens = {
9755 : : (void *)&cmd_set_nvgre_set,
9756 : : (void *)&cmd_set_nvgre_nvgre,
9757 : : (void *)&cmd_set_nvgre_ip_version,
9758 : : (void *)&cmd_set_nvgre_ip_version_value,
9759 : : (void *)&cmd_set_nvgre_tni,
9760 : : (void *)&cmd_set_nvgre_tni_value,
9761 : : (void *)&cmd_set_nvgre_ip_src,
9762 : : (void *)&cmd_set_nvgre_ip_src_value,
9763 : : (void *)&cmd_set_nvgre_ip_dst,
9764 : : (void *)&cmd_set_nvgre_ip_dst_value,
9765 : : (void *)&cmd_set_nvgre_eth_src,
9766 : : (void *)&cmd_set_nvgre_eth_src_value,
9767 : : (void *)&cmd_set_nvgre_eth_dst,
9768 : : (void *)&cmd_set_nvgre_eth_dst_value,
9769 : : NULL,
9770 : : },
9771 : : };
9772 : :
9773 : : static cmdline_parse_inst_t cmd_set_nvgre_with_vlan = {
9774 : : .f = cmd_set_nvgre_parsed,
9775 : : .data = NULL,
9776 : : .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>"
9777 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
9778 : : " eth-src <eth-src> eth-dst <eth-dst>",
9779 : : .tokens = {
9780 : : (void *)&cmd_set_nvgre_set,
9781 : : (void *)&cmd_set_nvgre_nvgre_with_vlan,
9782 : : (void *)&cmd_set_nvgre_ip_version,
9783 : : (void *)&cmd_set_nvgre_ip_version_value,
9784 : : (void *)&cmd_set_nvgre_tni,
9785 : : (void *)&cmd_set_nvgre_tni_value,
9786 : : (void *)&cmd_set_nvgre_ip_src,
9787 : : (void *)&cmd_set_nvgre_ip_src_value,
9788 : : (void *)&cmd_set_nvgre_ip_dst,
9789 : : (void *)&cmd_set_nvgre_ip_dst_value,
9790 : : (void *)&cmd_set_nvgre_vlan,
9791 : : (void *)&cmd_set_nvgre_vlan_value,
9792 : : (void *)&cmd_set_nvgre_eth_src,
9793 : : (void *)&cmd_set_nvgre_eth_src_value,
9794 : : (void *)&cmd_set_nvgre_eth_dst,
9795 : : (void *)&cmd_set_nvgre_eth_dst_value,
9796 : : NULL,
9797 : : },
9798 : : };
9799 : :
9800 : : /** Set L2 encapsulation details */
9801 : : struct cmd_set_l2_encap_result {
9802 : : cmdline_fixed_string_t set;
9803 : : cmdline_fixed_string_t l2_encap;
9804 : : cmdline_fixed_string_t pos_token;
9805 : : cmdline_fixed_string_t ip_version;
9806 : : uint32_t vlan_present:1;
9807 : : uint16_t tci;
9808 : : struct rte_ether_addr eth_src;
9809 : : struct rte_ether_addr eth_dst;
9810 : : };
9811 : :
9812 : : static cmdline_parse_token_string_t cmd_set_l2_encap_set =
9813 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set");
9814 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap =
9815 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap");
9816 : : static cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan =
9817 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap,
9818 : : "l2_encap-with-vlan");
9819 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version =
9820 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9821 : : "ip-version");
9822 : : static cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value =
9823 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version,
9824 : : "ipv4#ipv6");
9825 : : static cmdline_parse_token_string_t cmd_set_l2_encap_vlan =
9826 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9827 : : "vlan-tci");
9828 : : static cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value =
9829 : : TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, RTE_UINT16);
9830 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_src =
9831 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9832 : : "eth-src");
9833 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value =
9834 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src);
9835 : : static cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst =
9836 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token,
9837 : : "eth-dst");
9838 : : static cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value =
9839 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst);
9840 : :
9841 : 0 : static void cmd_set_l2_encap_parsed(void *parsed_result,
9842 : : __rte_unused struct cmdline *cl,
9843 : : __rte_unused void *data)
9844 : : {
9845 : : struct cmd_set_l2_encap_result *res = parsed_result;
9846 : :
9847 : 0 : if (strcmp(res->l2_encap, "l2_encap") == 0)
9848 : 0 : l2_encap_conf.select_vlan = 0;
9849 : 0 : else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0)
9850 : 0 : l2_encap_conf.select_vlan = 1;
9851 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
9852 : 0 : l2_encap_conf.select_ipv4 = 1;
9853 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
9854 : 0 : l2_encap_conf.select_ipv4 = 0;
9855 : : else
9856 : : return;
9857 : 0 : if (l2_encap_conf.select_vlan)
9858 : 0 : l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
9859 : 0 : rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes,
9860 : : RTE_ETHER_ADDR_LEN);
9861 : : rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes,
9862 : : RTE_ETHER_ADDR_LEN);
9863 : : }
9864 : :
9865 : : static cmdline_parse_inst_t cmd_set_l2_encap = {
9866 : : .f = cmd_set_l2_encap_parsed,
9867 : : .data = NULL,
9868 : : .help_str = "set l2_encap ip-version ipv4|ipv6"
9869 : : " eth-src <eth-src> eth-dst <eth-dst>",
9870 : : .tokens = {
9871 : : (void *)&cmd_set_l2_encap_set,
9872 : : (void *)&cmd_set_l2_encap_l2_encap,
9873 : : (void *)&cmd_set_l2_encap_ip_version,
9874 : : (void *)&cmd_set_l2_encap_ip_version_value,
9875 : : (void *)&cmd_set_l2_encap_eth_src,
9876 : : (void *)&cmd_set_l2_encap_eth_src_value,
9877 : : (void *)&cmd_set_l2_encap_eth_dst,
9878 : : (void *)&cmd_set_l2_encap_eth_dst_value,
9879 : : NULL,
9880 : : },
9881 : : };
9882 : :
9883 : : static cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = {
9884 : : .f = cmd_set_l2_encap_parsed,
9885 : : .data = NULL,
9886 : : .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6"
9887 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
9888 : : .tokens = {
9889 : : (void *)&cmd_set_l2_encap_set,
9890 : : (void *)&cmd_set_l2_encap_l2_encap_with_vlan,
9891 : : (void *)&cmd_set_l2_encap_ip_version,
9892 : : (void *)&cmd_set_l2_encap_ip_version_value,
9893 : : (void *)&cmd_set_l2_encap_vlan,
9894 : : (void *)&cmd_set_l2_encap_vlan_value,
9895 : : (void *)&cmd_set_l2_encap_eth_src,
9896 : : (void *)&cmd_set_l2_encap_eth_src_value,
9897 : : (void *)&cmd_set_l2_encap_eth_dst,
9898 : : (void *)&cmd_set_l2_encap_eth_dst_value,
9899 : : NULL,
9900 : : },
9901 : : };
9902 : :
9903 : : /** Set L2 decapsulation details */
9904 : : struct cmd_set_l2_decap_result {
9905 : : cmdline_fixed_string_t set;
9906 : : cmdline_fixed_string_t l2_decap;
9907 : : cmdline_fixed_string_t pos_token;
9908 : : uint32_t vlan_present:1;
9909 : : };
9910 : :
9911 : : static cmdline_parse_token_string_t cmd_set_l2_decap_set =
9912 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set");
9913 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap =
9914 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
9915 : : "l2_decap");
9916 : : static cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan =
9917 : : TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap,
9918 : : "l2_decap-with-vlan");
9919 : :
9920 : 0 : static void cmd_set_l2_decap_parsed(void *parsed_result,
9921 : : __rte_unused struct cmdline *cl,
9922 : : __rte_unused void *data)
9923 : : {
9924 : : struct cmd_set_l2_decap_result *res = parsed_result;
9925 : :
9926 : 0 : if (strcmp(res->l2_decap, "l2_decap") == 0)
9927 : 0 : l2_decap_conf.select_vlan = 0;
9928 : 0 : else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0)
9929 : 0 : l2_decap_conf.select_vlan = 1;
9930 : 0 : }
9931 : :
9932 : : static cmdline_parse_inst_t cmd_set_l2_decap = {
9933 : : .f = cmd_set_l2_decap_parsed,
9934 : : .data = NULL,
9935 : : .help_str = "set l2_decap",
9936 : : .tokens = {
9937 : : (void *)&cmd_set_l2_decap_set,
9938 : : (void *)&cmd_set_l2_decap_l2_decap,
9939 : : NULL,
9940 : : },
9941 : : };
9942 : :
9943 : : static cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = {
9944 : : .f = cmd_set_l2_decap_parsed,
9945 : : .data = NULL,
9946 : : .help_str = "set l2_decap-with-vlan",
9947 : : .tokens = {
9948 : : (void *)&cmd_set_l2_decap_set,
9949 : : (void *)&cmd_set_l2_decap_l2_decap_with_vlan,
9950 : : NULL,
9951 : : },
9952 : : };
9953 : :
9954 : : /** Set MPLSoGRE encapsulation details */
9955 : : struct cmd_set_mplsogre_encap_result {
9956 : : cmdline_fixed_string_t set;
9957 : : cmdline_fixed_string_t mplsogre;
9958 : : cmdline_fixed_string_t pos_token;
9959 : : cmdline_fixed_string_t ip_version;
9960 : : uint32_t vlan_present:1;
9961 : : uint32_t label;
9962 : : cmdline_ipaddr_t ip_src;
9963 : : cmdline_ipaddr_t ip_dst;
9964 : : uint16_t tci;
9965 : : struct rte_ether_addr eth_src;
9966 : : struct rte_ether_addr eth_dst;
9967 : : };
9968 : :
9969 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_set =
9970 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set,
9971 : : "set");
9972 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap =
9973 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre,
9974 : : "mplsogre_encap");
9975 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan =
9976 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9977 : : mplsogre, "mplsogre_encap-with-vlan");
9978 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version =
9979 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9980 : : pos_token, "ip-version");
9981 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value =
9982 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9983 : : ip_version, "ipv4#ipv6");
9984 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_label =
9985 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9986 : : pos_token, "label");
9987 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value =
9988 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label,
9989 : : RTE_UINT32);
9990 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src =
9991 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9992 : : pos_token, "ip-src");
9993 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value =
9994 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src);
9995 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst =
9996 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
9997 : : pos_token, "ip-dst");
9998 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value =
9999 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst);
10000 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan =
10001 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10002 : : pos_token, "vlan-tci");
10003 : : static cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value =
10004 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci,
10005 : : RTE_UINT16);
10006 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src =
10007 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10008 : : pos_token, "eth-src");
10009 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value =
10010 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10011 : : eth_src);
10012 : : static cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst =
10013 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10014 : : pos_token, "eth-dst");
10015 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value =
10016 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result,
10017 : : eth_dst);
10018 : :
10019 : 0 : static void cmd_set_mplsogre_encap_parsed(void *parsed_result,
10020 : : __rte_unused struct cmdline *cl,
10021 : : __rte_unused void *data)
10022 : : {
10023 : : struct cmd_set_mplsogre_encap_result *res = parsed_result;
10024 : : union {
10025 : : uint32_t mplsogre_label;
10026 : : uint8_t label[4];
10027 : 0 : } id = {
10028 : 0 : .mplsogre_label = rte_cpu_to_be_32(res->label<<12),
10029 : : };
10030 : :
10031 : 0 : if (strcmp(res->mplsogre, "mplsogre_encap") == 0)
10032 : 0 : mplsogre_encap_conf.select_vlan = 0;
10033 : 0 : else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0)
10034 : 0 : mplsogre_encap_conf.select_vlan = 1;
10035 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10036 : 0 : mplsogre_encap_conf.select_ipv4 = 1;
10037 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10038 : 0 : mplsogre_encap_conf.select_ipv4 = 0;
10039 : : else
10040 : 0 : return;
10041 : : rte_memcpy(mplsogre_encap_conf.label, &id.label, 3);
10042 : 0 : if (mplsogre_encap_conf.select_ipv4) {
10043 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src);
10044 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst);
10045 : : } else {
10046 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src);
10047 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst);
10048 : : }
10049 : 0 : if (mplsogre_encap_conf.select_vlan)
10050 : 0 : mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10051 : : rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes,
10052 : : RTE_ETHER_ADDR_LEN);
10053 : 0 : rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10054 : : RTE_ETHER_ADDR_LEN);
10055 : : }
10056 : :
10057 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap = {
10058 : : .f = cmd_set_mplsogre_encap_parsed,
10059 : : .data = NULL,
10060 : : .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>"
10061 : : " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>"
10062 : : " eth-dst <eth-dst>",
10063 : : .tokens = {
10064 : : (void *)&cmd_set_mplsogre_encap_set,
10065 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap,
10066 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10067 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10068 : : (void *)&cmd_set_mplsogre_encap_label,
10069 : : (void *)&cmd_set_mplsogre_encap_label_value,
10070 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10071 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10072 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10073 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10074 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10075 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10076 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10077 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10078 : : NULL,
10079 : : },
10080 : : };
10081 : :
10082 : : static cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = {
10083 : : .f = cmd_set_mplsogre_encap_parsed,
10084 : : .data = NULL,
10085 : : .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6"
10086 : : " label <label> ip-src <ip-src> ip-dst <ip-dst>"
10087 : : " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>",
10088 : : .tokens = {
10089 : : (void *)&cmd_set_mplsogre_encap_set,
10090 : : (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan,
10091 : : (void *)&cmd_set_mplsogre_encap_ip_version,
10092 : : (void *)&cmd_set_mplsogre_encap_ip_version_value,
10093 : : (void *)&cmd_set_mplsogre_encap_label,
10094 : : (void *)&cmd_set_mplsogre_encap_label_value,
10095 : : (void *)&cmd_set_mplsogre_encap_ip_src,
10096 : : (void *)&cmd_set_mplsogre_encap_ip_src_value,
10097 : : (void *)&cmd_set_mplsogre_encap_ip_dst,
10098 : : (void *)&cmd_set_mplsogre_encap_ip_dst_value,
10099 : : (void *)&cmd_set_mplsogre_encap_vlan,
10100 : : (void *)&cmd_set_mplsogre_encap_vlan_value,
10101 : : (void *)&cmd_set_mplsogre_encap_eth_src,
10102 : : (void *)&cmd_set_mplsogre_encap_eth_src_value,
10103 : : (void *)&cmd_set_mplsogre_encap_eth_dst,
10104 : : (void *)&cmd_set_mplsogre_encap_eth_dst_value,
10105 : : NULL,
10106 : : },
10107 : : };
10108 : :
10109 : : /** Set MPLSoGRE decapsulation details */
10110 : : struct cmd_set_mplsogre_decap_result {
10111 : : cmdline_fixed_string_t set;
10112 : : cmdline_fixed_string_t mplsogre;
10113 : : cmdline_fixed_string_t pos_token;
10114 : : cmdline_fixed_string_t ip_version;
10115 : : uint32_t vlan_present:1;
10116 : : };
10117 : :
10118 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_set =
10119 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set,
10120 : : "set");
10121 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap =
10122 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre,
10123 : : "mplsogre_decap");
10124 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan =
10125 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10126 : : mplsogre, "mplsogre_decap-with-vlan");
10127 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version =
10128 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10129 : : pos_token, "ip-version");
10130 : : static cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value =
10131 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result,
10132 : : ip_version, "ipv4#ipv6");
10133 : :
10134 : 0 : static void cmd_set_mplsogre_decap_parsed(void *parsed_result,
10135 : : __rte_unused struct cmdline *cl,
10136 : : __rte_unused void *data)
10137 : : {
10138 : : struct cmd_set_mplsogre_decap_result *res = parsed_result;
10139 : :
10140 : 0 : if (strcmp(res->mplsogre, "mplsogre_decap") == 0)
10141 : 0 : mplsogre_decap_conf.select_vlan = 0;
10142 : 0 : else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0)
10143 : 0 : mplsogre_decap_conf.select_vlan = 1;
10144 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10145 : 0 : mplsogre_decap_conf.select_ipv4 = 1;
10146 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10147 : 0 : mplsogre_decap_conf.select_ipv4 = 0;
10148 : 0 : }
10149 : :
10150 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap = {
10151 : : .f = cmd_set_mplsogre_decap_parsed,
10152 : : .data = NULL,
10153 : : .help_str = "set mplsogre_decap ip-version ipv4|ipv6",
10154 : : .tokens = {
10155 : : (void *)&cmd_set_mplsogre_decap_set,
10156 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap,
10157 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10158 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10159 : : NULL,
10160 : : },
10161 : : };
10162 : :
10163 : : static cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = {
10164 : : .f = cmd_set_mplsogre_decap_parsed,
10165 : : .data = NULL,
10166 : : .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6",
10167 : : .tokens = {
10168 : : (void *)&cmd_set_mplsogre_decap_set,
10169 : : (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan,
10170 : : (void *)&cmd_set_mplsogre_decap_ip_version,
10171 : : (void *)&cmd_set_mplsogre_decap_ip_version_value,
10172 : : NULL,
10173 : : },
10174 : : };
10175 : :
10176 : : /** Set MPLSoUDP encapsulation details */
10177 : : struct cmd_set_mplsoudp_encap_result {
10178 : : cmdline_fixed_string_t set;
10179 : : cmdline_fixed_string_t mplsoudp;
10180 : : cmdline_fixed_string_t pos_token;
10181 : : cmdline_fixed_string_t ip_version;
10182 : : uint32_t vlan_present:1;
10183 : : uint32_t label;
10184 : : uint16_t udp_src;
10185 : : uint16_t udp_dst;
10186 : : cmdline_ipaddr_t ip_src;
10187 : : cmdline_ipaddr_t ip_dst;
10188 : : uint16_t tci;
10189 : : struct rte_ether_addr eth_src;
10190 : : struct rte_ether_addr eth_dst;
10191 : : };
10192 : :
10193 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set =
10194 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set,
10195 : : "set");
10196 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap =
10197 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp,
10198 : : "mplsoudp_encap");
10199 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan =
10200 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10201 : : mplsoudp, "mplsoudp_encap-with-vlan");
10202 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version =
10203 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10204 : : pos_token, "ip-version");
10205 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value =
10206 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10207 : : ip_version, "ipv4#ipv6");
10208 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label =
10209 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10210 : : pos_token, "label");
10211 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value =
10212 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label,
10213 : : RTE_UINT32);
10214 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src =
10215 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10216 : : pos_token, "udp-src");
10217 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value =
10218 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src,
10219 : : RTE_UINT16);
10220 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst =
10221 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10222 : : pos_token, "udp-dst");
10223 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value =
10224 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst,
10225 : : RTE_UINT16);
10226 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src =
10227 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10228 : : pos_token, "ip-src");
10229 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value =
10230 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src);
10231 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst =
10232 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10233 : : pos_token, "ip-dst");
10234 : : static cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value =
10235 : : TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst);
10236 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan =
10237 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10238 : : pos_token, "vlan-tci");
10239 : : static cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value =
10240 : : TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci,
10241 : : RTE_UINT16);
10242 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src =
10243 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10244 : : pos_token, "eth-src");
10245 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value =
10246 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10247 : : eth_src);
10248 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst =
10249 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10250 : : pos_token, "eth-dst");
10251 : : static cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value =
10252 : : TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result,
10253 : : eth_dst);
10254 : :
10255 : 0 : static void cmd_set_mplsoudp_encap_parsed(void *parsed_result,
10256 : : __rte_unused struct cmdline *cl,
10257 : : __rte_unused void *data)
10258 : : {
10259 : : struct cmd_set_mplsoudp_encap_result *res = parsed_result;
10260 : : union {
10261 : : uint32_t mplsoudp_label;
10262 : : uint8_t label[4];
10263 : 0 : } id = {
10264 : 0 : .mplsoudp_label = rte_cpu_to_be_32(res->label<<12),
10265 : : };
10266 : :
10267 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0)
10268 : 0 : mplsoudp_encap_conf.select_vlan = 0;
10269 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0)
10270 : 0 : mplsoudp_encap_conf.select_vlan = 1;
10271 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10272 : 0 : mplsoudp_encap_conf.select_ipv4 = 1;
10273 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10274 : 0 : mplsoudp_encap_conf.select_ipv4 = 0;
10275 : : else
10276 : 0 : return;
10277 : : rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3);
10278 : 0 : mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src);
10279 : 0 : mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst);
10280 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10281 : 0 : IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src);
10282 : 0 : IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst);
10283 : : } else {
10284 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src);
10285 : 0 : IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst);
10286 : : }
10287 : 0 : if (mplsoudp_encap_conf.select_vlan)
10288 : 0 : mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci);
10289 : : rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes,
10290 : : RTE_ETHER_ADDR_LEN);
10291 : 0 : rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes,
10292 : : RTE_ETHER_ADDR_LEN);
10293 : : }
10294 : :
10295 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap = {
10296 : : .f = cmd_set_mplsoudp_encap_parsed,
10297 : : .data = NULL,
10298 : : .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>"
10299 : : " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>"
10300 : : " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>",
10301 : : .tokens = {
10302 : : (void *)&cmd_set_mplsoudp_encap_set,
10303 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap,
10304 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10305 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10306 : : (void *)&cmd_set_mplsoudp_encap_label,
10307 : : (void *)&cmd_set_mplsoudp_encap_label_value,
10308 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
10309 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
10310 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
10311 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10312 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
10313 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
10314 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
10315 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10316 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
10317 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
10318 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
10319 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10320 : : NULL,
10321 : : },
10322 : : };
10323 : :
10324 : : static cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = {
10325 : : .f = cmd_set_mplsoudp_encap_parsed,
10326 : : .data = NULL,
10327 : : .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6"
10328 : : " label <label> udp-src <udp-src> udp-dst <udp-dst>"
10329 : : " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>"
10330 : : " eth-src <eth-src> eth-dst <eth-dst>",
10331 : : .tokens = {
10332 : : (void *)&cmd_set_mplsoudp_encap_set,
10333 : : (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan,
10334 : : (void *)&cmd_set_mplsoudp_encap_ip_version,
10335 : : (void *)&cmd_set_mplsoudp_encap_ip_version_value,
10336 : : (void *)&cmd_set_mplsoudp_encap_label,
10337 : : (void *)&cmd_set_mplsoudp_encap_label_value,
10338 : : (void *)&cmd_set_mplsoudp_encap_udp_src,
10339 : : (void *)&cmd_set_mplsoudp_encap_udp_src_value,
10340 : : (void *)&cmd_set_mplsoudp_encap_udp_dst,
10341 : : (void *)&cmd_set_mplsoudp_encap_udp_dst_value,
10342 : : (void *)&cmd_set_mplsoudp_encap_ip_src,
10343 : : (void *)&cmd_set_mplsoudp_encap_ip_src_value,
10344 : : (void *)&cmd_set_mplsoudp_encap_ip_dst,
10345 : : (void *)&cmd_set_mplsoudp_encap_ip_dst_value,
10346 : : (void *)&cmd_set_mplsoudp_encap_vlan,
10347 : : (void *)&cmd_set_mplsoudp_encap_vlan_value,
10348 : : (void *)&cmd_set_mplsoudp_encap_eth_src,
10349 : : (void *)&cmd_set_mplsoudp_encap_eth_src_value,
10350 : : (void *)&cmd_set_mplsoudp_encap_eth_dst,
10351 : : (void *)&cmd_set_mplsoudp_encap_eth_dst_value,
10352 : : NULL,
10353 : : },
10354 : : };
10355 : :
10356 : : /** Set MPLSoUDP decapsulation details */
10357 : : struct cmd_set_mplsoudp_decap_result {
10358 : : cmdline_fixed_string_t set;
10359 : : cmdline_fixed_string_t mplsoudp;
10360 : : cmdline_fixed_string_t pos_token;
10361 : : cmdline_fixed_string_t ip_version;
10362 : : uint32_t vlan_present:1;
10363 : : };
10364 : :
10365 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set =
10366 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set,
10367 : : "set");
10368 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap =
10369 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp,
10370 : : "mplsoudp_decap");
10371 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan =
10372 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10373 : : mplsoudp, "mplsoudp_decap-with-vlan");
10374 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version =
10375 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10376 : : pos_token, "ip-version");
10377 : : static cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value =
10378 : : TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result,
10379 : : ip_version, "ipv4#ipv6");
10380 : :
10381 : 0 : static void cmd_set_mplsoudp_decap_parsed(void *parsed_result,
10382 : : __rte_unused struct cmdline *cl,
10383 : : __rte_unused void *data)
10384 : : {
10385 : : struct cmd_set_mplsoudp_decap_result *res = parsed_result;
10386 : :
10387 : 0 : if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0)
10388 : 0 : mplsoudp_decap_conf.select_vlan = 0;
10389 : 0 : else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0)
10390 : 0 : mplsoudp_decap_conf.select_vlan = 1;
10391 : 0 : if (strcmp(res->ip_version, "ipv4") == 0)
10392 : 0 : mplsoudp_decap_conf.select_ipv4 = 1;
10393 : 0 : else if (strcmp(res->ip_version, "ipv6") == 0)
10394 : 0 : mplsoudp_decap_conf.select_ipv4 = 0;
10395 : 0 : }
10396 : :
10397 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap = {
10398 : : .f = cmd_set_mplsoudp_decap_parsed,
10399 : : .data = NULL,
10400 : : .help_str = "set mplsoudp_decap ip-version ipv4|ipv6",
10401 : : .tokens = {
10402 : : (void *)&cmd_set_mplsoudp_decap_set,
10403 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap,
10404 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
10405 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
10406 : : NULL,
10407 : : },
10408 : : };
10409 : :
10410 : : static cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
10411 : : .f = cmd_set_mplsoudp_decap_parsed,
10412 : : .data = NULL,
10413 : : .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6",
10414 : : .tokens = {
10415 : : (void *)&cmd_set_mplsoudp_decap_set,
10416 : : (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan,
10417 : : (void *)&cmd_set_mplsoudp_decap_ip_version,
10418 : : (void *)&cmd_set_mplsoudp_decap_ip_version_value,
10419 : : NULL,
10420 : : },
10421 : : };
10422 : :
10423 : : /** Set connection tracking object common details */
10424 : : struct cmd_set_conntrack_common_result {
10425 : : cmdline_fixed_string_t set;
10426 : : cmdline_fixed_string_t conntrack;
10427 : : cmdline_fixed_string_t common;
10428 : : cmdline_fixed_string_t peer;
10429 : : cmdline_fixed_string_t is_orig;
10430 : : cmdline_fixed_string_t enable;
10431 : : cmdline_fixed_string_t live;
10432 : : cmdline_fixed_string_t sack;
10433 : : cmdline_fixed_string_t cack;
10434 : : cmdline_fixed_string_t last_dir;
10435 : : cmdline_fixed_string_t liberal;
10436 : : cmdline_fixed_string_t state;
10437 : : cmdline_fixed_string_t max_ack_win;
10438 : : cmdline_fixed_string_t retrans;
10439 : : cmdline_fixed_string_t last_win;
10440 : : cmdline_fixed_string_t last_seq;
10441 : : cmdline_fixed_string_t last_ack;
10442 : : cmdline_fixed_string_t last_end;
10443 : : cmdline_fixed_string_t last_index;
10444 : : uint8_t stat;
10445 : : uint8_t factor;
10446 : : uint16_t peer_port;
10447 : : uint32_t is_original;
10448 : : uint32_t en;
10449 : : uint32_t is_live;
10450 : : uint32_t s_ack;
10451 : : uint32_t c_ack;
10452 : : uint32_t ld;
10453 : : uint32_t lb;
10454 : : uint8_t re_num;
10455 : : uint8_t li;
10456 : : uint16_t lw;
10457 : : uint32_t ls;
10458 : : uint32_t la;
10459 : : uint32_t le;
10460 : : };
10461 : :
10462 : : static cmdline_parse_token_string_t cmd_set_conntrack_set =
10463 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10464 : : set, "set");
10465 : : static cmdline_parse_token_string_t cmd_set_conntrack_conntrack =
10466 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10467 : : conntrack, "conntrack");
10468 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_com =
10469 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10470 : : common, "com");
10471 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_peer =
10472 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10473 : : peer, "peer");
10474 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value =
10475 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10476 : : peer_port, RTE_UINT16);
10477 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig =
10478 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10479 : : is_orig, "is_orig");
10480 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value =
10481 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10482 : : is_original, RTE_UINT32);
10483 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_enable =
10484 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10485 : : enable, "enable");
10486 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value =
10487 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10488 : : en, RTE_UINT32);
10489 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_live =
10490 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10491 : : live, "live");
10492 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_live_value =
10493 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10494 : : is_live, RTE_UINT32);
10495 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_sack =
10496 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10497 : : sack, "sack");
10498 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value =
10499 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10500 : : s_ack, RTE_UINT32);
10501 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_cack =
10502 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10503 : : cack, "cack");
10504 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value =
10505 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10506 : : c_ack, RTE_UINT32);
10507 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir =
10508 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10509 : : last_dir, "last_dir");
10510 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value =
10511 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10512 : : ld, RTE_UINT32);
10513 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_liberal =
10514 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10515 : : liberal, "liberal");
10516 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value =
10517 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10518 : : lb, RTE_UINT32);
10519 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_state =
10520 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10521 : : state, "state");
10522 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_state_value =
10523 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10524 : : stat, RTE_UINT8);
10525 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin =
10526 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10527 : : max_ack_win, "max_ack_win");
10528 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value =
10529 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10530 : : factor, RTE_UINT8);
10531 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_retrans =
10532 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10533 : : retrans, "r_lim");
10534 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value =
10535 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10536 : : re_num, RTE_UINT8);
10537 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_win =
10538 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10539 : : last_win, "last_win");
10540 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value =
10541 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10542 : : lw, RTE_UINT16);
10543 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq =
10544 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10545 : : last_seq, "last_seq");
10546 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value =
10547 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10548 : : ls, RTE_UINT32);
10549 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack =
10550 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10551 : : last_ack, "last_ack");
10552 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value =
10553 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10554 : : la, RTE_UINT32);
10555 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_end =
10556 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10557 : : last_end, "last_end");
10558 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value =
10559 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10560 : : le, RTE_UINT32);
10561 : : static cmdline_parse_token_string_t cmd_set_conntrack_common_last_index =
10562 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result,
10563 : : last_index, "last_index");
10564 : : static cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value =
10565 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result,
10566 : : li, RTE_UINT8);
10567 : :
10568 : 0 : static void cmd_set_conntrack_common_parsed(void *parsed_result,
10569 : : __rte_unused struct cmdline *cl,
10570 : : __rte_unused void *data)
10571 : : {
10572 : : struct cmd_set_conntrack_common_result *res = parsed_result;
10573 : :
10574 : : /* No need to swap to big endian. */
10575 : 0 : conntrack_context.peer_port = res->peer_port;
10576 : 0 : conntrack_context.is_original_dir = res->is_original;
10577 : 0 : conntrack_context.enable = res->en;
10578 : 0 : conntrack_context.live_connection = res->is_live;
10579 : 0 : conntrack_context.selective_ack = res->s_ack;
10580 : 0 : conntrack_context.challenge_ack_passed = res->c_ack;
10581 : 0 : conntrack_context.last_direction = res->ld;
10582 : 0 : conntrack_context.liberal_mode = res->lb;
10583 : 0 : conntrack_context.state = (enum rte_flow_conntrack_state)res->stat;
10584 : 0 : conntrack_context.max_ack_window = res->factor;
10585 : 0 : conntrack_context.retransmission_limit = res->re_num;
10586 : 0 : conntrack_context.last_window = res->lw;
10587 : 0 : conntrack_context.last_index =
10588 : 0 : (enum rte_flow_conntrack_tcp_last_index)res->li;
10589 : 0 : conntrack_context.last_seq = res->ls;
10590 : 0 : conntrack_context.last_ack = res->la;
10591 : 0 : conntrack_context.last_end = res->le;
10592 : 0 : }
10593 : :
10594 : : static cmdline_parse_inst_t cmd_set_conntrack_common = {
10595 : : .f = cmd_set_conntrack_common_parsed,
10596 : : .data = NULL,
10597 : : .help_str = "set conntrack com peer <port_id> is_orig <dir> enable <en>"
10598 : : " live <ack_seen> sack <en> cack <passed> last_dir <dir>"
10599 : : " liberal <en> state <s> max_ack_win <factor> r_lim <num>"
10600 : : " last_win <win> last_seq <seq> last_ack <ack> last_end <end>"
10601 : : " last_index <flag>",
10602 : : .tokens = {
10603 : : (void *)&cmd_set_conntrack_set,
10604 : : (void *)&cmd_set_conntrack_conntrack,
10605 : : (void *)&cmd_set_conntrack_common_com,
10606 : : (void *)&cmd_set_conntrack_common_peer,
10607 : : (void *)&cmd_set_conntrack_common_peer_value,
10608 : : (void *)&cmd_set_conntrack_common_is_orig,
10609 : : (void *)&cmd_set_conntrack_common_is_orig_value,
10610 : : (void *)&cmd_set_conntrack_common_enable,
10611 : : (void *)&cmd_set_conntrack_common_enable_value,
10612 : : (void *)&cmd_set_conntrack_common_live,
10613 : : (void *)&cmd_set_conntrack_common_live_value,
10614 : : (void *)&cmd_set_conntrack_common_sack,
10615 : : (void *)&cmd_set_conntrack_common_sack_value,
10616 : : (void *)&cmd_set_conntrack_common_cack,
10617 : : (void *)&cmd_set_conntrack_common_cack_value,
10618 : : (void *)&cmd_set_conntrack_common_last_dir,
10619 : : (void *)&cmd_set_conntrack_common_last_dir_value,
10620 : : (void *)&cmd_set_conntrack_common_liberal,
10621 : : (void *)&cmd_set_conntrack_common_liberal_value,
10622 : : (void *)&cmd_set_conntrack_common_state,
10623 : : (void *)&cmd_set_conntrack_common_state_value,
10624 : : (void *)&cmd_set_conntrack_common_max_ackwin,
10625 : : (void *)&cmd_set_conntrack_common_max_ackwin_value,
10626 : : (void *)&cmd_set_conntrack_common_retrans,
10627 : : (void *)&cmd_set_conntrack_common_retrans_value,
10628 : : (void *)&cmd_set_conntrack_common_last_win,
10629 : : (void *)&cmd_set_conntrack_common_last_win_value,
10630 : : (void *)&cmd_set_conntrack_common_last_seq,
10631 : : (void *)&cmd_set_conntrack_common_last_seq_value,
10632 : : (void *)&cmd_set_conntrack_common_last_ack,
10633 : : (void *)&cmd_set_conntrack_common_last_ack_value,
10634 : : (void *)&cmd_set_conntrack_common_last_end,
10635 : : (void *)&cmd_set_conntrack_common_last_end_value,
10636 : : (void *)&cmd_set_conntrack_common_last_index,
10637 : : (void *)&cmd_set_conntrack_common_last_index_value,
10638 : : NULL,
10639 : : },
10640 : : };
10641 : :
10642 : : /** Set connection tracking object both directions' details */
10643 : : struct cmd_set_conntrack_dir_result {
10644 : : cmdline_fixed_string_t set;
10645 : : cmdline_fixed_string_t conntrack;
10646 : : cmdline_fixed_string_t dir;
10647 : : cmdline_fixed_string_t scale;
10648 : : cmdline_fixed_string_t fin;
10649 : : cmdline_fixed_string_t ack_seen;
10650 : : cmdline_fixed_string_t unack;
10651 : : cmdline_fixed_string_t sent_end;
10652 : : cmdline_fixed_string_t reply_end;
10653 : : cmdline_fixed_string_t max_win;
10654 : : cmdline_fixed_string_t max_ack;
10655 : : uint32_t factor;
10656 : : uint32_t f;
10657 : : uint32_t as;
10658 : : uint32_t un;
10659 : : uint32_t se;
10660 : : uint32_t re;
10661 : : uint32_t mw;
10662 : : uint32_t ma;
10663 : : };
10664 : :
10665 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_dir =
10666 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10667 : : dir, "orig#rply");
10668 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_scale =
10669 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10670 : : scale, "scale");
10671 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value =
10672 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10673 : : factor, RTE_UINT32);
10674 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_fin =
10675 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10676 : : fin, "fin");
10677 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value =
10678 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10679 : : f, RTE_UINT32);
10680 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_ack =
10681 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10682 : : ack_seen, "acked");
10683 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value =
10684 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10685 : : as, RTE_UINT32);
10686 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data =
10687 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10688 : : unack, "unack_data");
10689 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value =
10690 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10691 : : un, RTE_UINT32);
10692 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end =
10693 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10694 : : sent_end, "sent_end");
10695 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value =
10696 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10697 : : se, RTE_UINT32);
10698 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end =
10699 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10700 : : reply_end, "reply_end");
10701 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value =
10702 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10703 : : re, RTE_UINT32);
10704 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win =
10705 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10706 : : max_win, "max_win");
10707 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value =
10708 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10709 : : mw, RTE_UINT32);
10710 : : static cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack =
10711 : : TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result,
10712 : : max_ack, "max_ack");
10713 : : static cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value =
10714 : : TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result,
10715 : : ma, RTE_UINT32);
10716 : :
10717 : 0 : static void cmd_set_conntrack_dir_parsed(void *parsed_result,
10718 : : __rte_unused struct cmdline *cl,
10719 : : __rte_unused void *data)
10720 : : {
10721 : : struct cmd_set_conntrack_dir_result *res = parsed_result;
10722 : : struct rte_flow_tcp_dir_param *dir = NULL;
10723 : :
10724 : 0 : if (strcmp(res->dir, "orig") == 0)
10725 : : dir = &conntrack_context.original_dir;
10726 : 0 : else if (strcmp(res->dir, "rply") == 0)
10727 : : dir = &conntrack_context.reply_dir;
10728 : : else
10729 : : return;
10730 : 0 : dir->scale = res->factor;
10731 : 0 : dir->close_initiated = res->f;
10732 : 0 : dir->last_ack_seen = res->as;
10733 : 0 : dir->data_unacked = res->un;
10734 : 0 : dir->sent_end = res->se;
10735 : 0 : dir->reply_end = res->re;
10736 : 0 : dir->max_ack = res->ma;
10737 : 0 : dir->max_win = res->mw;
10738 : : }
10739 : :
10740 : : static cmdline_parse_inst_t cmd_set_conntrack_dir = {
10741 : : .f = cmd_set_conntrack_dir_parsed,
10742 : : .data = NULL,
10743 : : .help_str = "set conntrack orig|rply scale <factor> fin <sent>"
10744 : : " acked <seen> unack_data <unack> sent_end <sent>"
10745 : : " reply_end <reply> max_win <win> max_ack <ack>",
10746 : : .tokens = {
10747 : : (void *)&cmd_set_conntrack_set,
10748 : : (void *)&cmd_set_conntrack_conntrack,
10749 : : (void *)&cmd_set_conntrack_dir_dir,
10750 : : (void *)&cmd_set_conntrack_dir_scale,
10751 : : (void *)&cmd_set_conntrack_dir_scale_value,
10752 : : (void *)&cmd_set_conntrack_dir_fin,
10753 : : (void *)&cmd_set_conntrack_dir_fin_value,
10754 : : (void *)&cmd_set_conntrack_dir_ack,
10755 : : (void *)&cmd_set_conntrack_dir_ack_value,
10756 : : (void *)&cmd_set_conntrack_dir_unack_data,
10757 : : (void *)&cmd_set_conntrack_dir_unack_data_value,
10758 : : (void *)&cmd_set_conntrack_dir_sent_end,
10759 : : (void *)&cmd_set_conntrack_dir_sent_end_value,
10760 : : (void *)&cmd_set_conntrack_dir_reply_end,
10761 : : (void *)&cmd_set_conntrack_dir_reply_end_value,
10762 : : (void *)&cmd_set_conntrack_dir_max_win,
10763 : : (void *)&cmd_set_conntrack_dir_max_win_value,
10764 : : (void *)&cmd_set_conntrack_dir_max_ack,
10765 : : (void *)&cmd_set_conntrack_dir_max_ack_value,
10766 : : NULL,
10767 : : },
10768 : : };
10769 : :
10770 : : /* show vf stats */
10771 : :
10772 : : /* Common result structure for show vf stats */
10773 : : struct cmd_show_vf_stats_result {
10774 : : cmdline_fixed_string_t show;
10775 : : cmdline_fixed_string_t vf;
10776 : : cmdline_fixed_string_t stats;
10777 : : portid_t port_id;
10778 : : uint16_t vf_id;
10779 : : };
10780 : :
10781 : : /* Common CLI fields show vf stats*/
10782 : : static cmdline_parse_token_string_t cmd_show_vf_stats_show =
10783 : : TOKEN_STRING_INITIALIZER
10784 : : (struct cmd_show_vf_stats_result,
10785 : : show, "show");
10786 : : static cmdline_parse_token_string_t cmd_show_vf_stats_vf =
10787 : : TOKEN_STRING_INITIALIZER
10788 : : (struct cmd_show_vf_stats_result,
10789 : : vf, "vf");
10790 : : static cmdline_parse_token_string_t cmd_show_vf_stats_stats =
10791 : : TOKEN_STRING_INITIALIZER
10792 : : (struct cmd_show_vf_stats_result,
10793 : : stats, "stats");
10794 : : static cmdline_parse_token_num_t cmd_show_vf_stats_port_id =
10795 : : TOKEN_NUM_INITIALIZER
10796 : : (struct cmd_show_vf_stats_result,
10797 : : port_id, RTE_UINT16);
10798 : : static cmdline_parse_token_num_t cmd_show_vf_stats_vf_id =
10799 : : TOKEN_NUM_INITIALIZER
10800 : : (struct cmd_show_vf_stats_result,
10801 : : vf_id, RTE_UINT16);
10802 : :
10803 : : static void
10804 : 0 : cmd_show_vf_stats_parsed(
10805 : : void *parsed_result,
10806 : : __rte_unused struct cmdline *cl,
10807 : : __rte_unused void *data)
10808 : : {
10809 : : struct cmd_show_vf_stats_result *res = parsed_result;
10810 : : struct rte_eth_stats stats;
10811 : : int ret = -ENOTSUP;
10812 : : static const char *nic_stats_border = "########################";
10813 : :
10814 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10815 : 0 : return;
10816 : :
10817 : : memset(&stats, 0, sizeof(stats));
10818 : :
10819 : : #ifdef RTE_NET_I40E
10820 : : if (ret == -ENOTSUP)
10821 : 0 : ret = rte_pmd_i40e_get_vf_stats(res->port_id,
10822 : 0 : res->vf_id,
10823 : : &stats);
10824 : : #endif
10825 : : #ifdef RTE_NET_BNXT
10826 : 0 : if (ret == -ENOTSUP)
10827 : 0 : ret = rte_pmd_bnxt_get_vf_stats(res->port_id,
10828 : 0 : res->vf_id,
10829 : : &stats);
10830 : : #endif
10831 : :
10832 : 0 : switch (ret) {
10833 : : case 0:
10834 : : break;
10835 : 0 : case -EINVAL:
10836 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
10837 : : break;
10838 : 0 : case -ENODEV:
10839 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10840 : : break;
10841 : 0 : case -ENOTSUP:
10842 : 0 : fprintf(stderr, "function not implemented\n");
10843 : : break;
10844 : 0 : default:
10845 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10846 : : }
10847 : :
10848 : 0 : printf("\n %s NIC statistics for port %-2d vf %-2d %s\n",
10849 : 0 : nic_stats_border, res->port_id, res->vf_id, nic_stats_border);
10850 : :
10851 : 0 : printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: "
10852 : : "%-"PRIu64"\n",
10853 : : stats.ipackets, stats.imissed, stats.ibytes);
10854 : 0 : printf(" RX-errors: %-"PRIu64"\n", stats.ierrors);
10855 : 0 : printf(" RX-nombuf: %-10"PRIu64"\n",
10856 : : stats.rx_nombuf);
10857 : 0 : printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: "
10858 : : "%-"PRIu64"\n",
10859 : : stats.opackets, stats.oerrors, stats.obytes);
10860 : :
10861 : 0 : printf(" %s############################%s\n",
10862 : : nic_stats_border, nic_stats_border);
10863 : : }
10864 : :
10865 : : static cmdline_parse_inst_t cmd_show_vf_stats = {
10866 : : .f = cmd_show_vf_stats_parsed,
10867 : : .data = NULL,
10868 : : .help_str = "show vf stats <port_id> <vf_id>",
10869 : : .tokens = {
10870 : : (void *)&cmd_show_vf_stats_show,
10871 : : (void *)&cmd_show_vf_stats_vf,
10872 : : (void *)&cmd_show_vf_stats_stats,
10873 : : (void *)&cmd_show_vf_stats_port_id,
10874 : : (void *)&cmd_show_vf_stats_vf_id,
10875 : : NULL,
10876 : : },
10877 : : };
10878 : :
10879 : : /* clear vf stats */
10880 : :
10881 : : /* Common result structure for clear vf stats */
10882 : : struct cmd_clear_vf_stats_result {
10883 : : cmdline_fixed_string_t clear;
10884 : : cmdline_fixed_string_t vf;
10885 : : cmdline_fixed_string_t stats;
10886 : : portid_t port_id;
10887 : : uint16_t vf_id;
10888 : : };
10889 : :
10890 : : /* Common CLI fields clear vf stats*/
10891 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_clear =
10892 : : TOKEN_STRING_INITIALIZER
10893 : : (struct cmd_clear_vf_stats_result,
10894 : : clear, "clear");
10895 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_vf =
10896 : : TOKEN_STRING_INITIALIZER
10897 : : (struct cmd_clear_vf_stats_result,
10898 : : vf, "vf");
10899 : : static cmdline_parse_token_string_t cmd_clear_vf_stats_stats =
10900 : : TOKEN_STRING_INITIALIZER
10901 : : (struct cmd_clear_vf_stats_result,
10902 : : stats, "stats");
10903 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_port_id =
10904 : : TOKEN_NUM_INITIALIZER
10905 : : (struct cmd_clear_vf_stats_result,
10906 : : port_id, RTE_UINT16);
10907 : : static cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id =
10908 : : TOKEN_NUM_INITIALIZER
10909 : : (struct cmd_clear_vf_stats_result,
10910 : : vf_id, RTE_UINT16);
10911 : :
10912 : : static void
10913 : 0 : cmd_clear_vf_stats_parsed(
10914 : : void *parsed_result,
10915 : : __rte_unused struct cmdline *cl,
10916 : : __rte_unused void *data)
10917 : : {
10918 : : struct cmd_clear_vf_stats_result *res = parsed_result;
10919 : : int ret = -ENOTSUP;
10920 : :
10921 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
10922 : : return;
10923 : :
10924 : : #ifdef RTE_NET_I40E
10925 : : if (ret == -ENOTSUP)
10926 : 0 : ret = rte_pmd_i40e_reset_vf_stats(res->port_id,
10927 : 0 : res->vf_id);
10928 : : #endif
10929 : : #ifdef RTE_NET_BNXT
10930 : 0 : if (ret == -ENOTSUP)
10931 : 0 : ret = rte_pmd_bnxt_reset_vf_stats(res->port_id,
10932 : 0 : res->vf_id);
10933 : : #endif
10934 : :
10935 : 0 : switch (ret) {
10936 : : case 0:
10937 : : break;
10938 : 0 : case -EINVAL:
10939 : 0 : fprintf(stderr, "invalid vf_id %d\n", res->vf_id);
10940 : : break;
10941 : 0 : case -ENODEV:
10942 : 0 : fprintf(stderr, "invalid port_id %d\n", res->port_id);
10943 : : break;
10944 : 0 : case -ENOTSUP:
10945 : 0 : fprintf(stderr, "function not implemented\n");
10946 : : break;
10947 : 0 : default:
10948 : 0 : fprintf(stderr, "programming error: (%s)\n", strerror(-ret));
10949 : : }
10950 : : }
10951 : :
10952 : : static cmdline_parse_inst_t cmd_clear_vf_stats = {
10953 : : .f = cmd_clear_vf_stats_parsed,
10954 : : .data = NULL,
10955 : : .help_str = "clear vf stats <port_id> <vf_id>",
10956 : : .tokens = {
10957 : : (void *)&cmd_clear_vf_stats_clear,
10958 : : (void *)&cmd_clear_vf_stats_vf,
10959 : : (void *)&cmd_clear_vf_stats_stats,
10960 : : (void *)&cmd_clear_vf_stats_port_id,
10961 : : (void *)&cmd_clear_vf_stats_vf_id,
10962 : : NULL,
10963 : : },
10964 : : };
10965 : :
10966 : : /* Common result structure for file commands */
10967 : : struct cmd_cmdfile_result {
10968 : : cmdline_fixed_string_t load;
10969 : : cmdline_fixed_string_t filename;
10970 : : };
10971 : :
10972 : : /* Common CLI fields for file commands */
10973 : : static cmdline_parse_token_string_t cmd_load_cmdfile =
10974 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load");
10975 : : static cmdline_parse_token_string_t cmd_load_cmdfile_filename =
10976 : : TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL);
10977 : :
10978 : : static void
10979 : 0 : cmd_load_from_file_parsed(
10980 : : void *parsed_result,
10981 : : __rte_unused struct cmdline *cl,
10982 : : __rte_unused void *data)
10983 : : {
10984 : : struct cmd_cmdfile_result *res = parsed_result;
10985 : :
10986 : 0 : cmdline_read_from_file(res->filename);
10987 : 0 : }
10988 : :
10989 : : static cmdline_parse_inst_t cmd_load_from_file = {
10990 : : .f = cmd_load_from_file_parsed,
10991 : : .data = NULL,
10992 : : .help_str = "load <filename>",
10993 : : .tokens = {
10994 : : (void *)&cmd_load_cmdfile,
10995 : : (void *)&cmd_load_cmdfile_filename,
10996 : : NULL,
10997 : : },
10998 : : };
10999 : :
11000 : : /* Get Rx offloads capabilities */
11001 : : struct cmd_rx_offload_get_capa_result {
11002 : : cmdline_fixed_string_t show;
11003 : : cmdline_fixed_string_t port;
11004 : : portid_t port_id;
11005 : : cmdline_fixed_string_t rx_offload;
11006 : : cmdline_fixed_string_t capabilities;
11007 : : };
11008 : :
11009 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_show =
11010 : : TOKEN_STRING_INITIALIZER
11011 : : (struct cmd_rx_offload_get_capa_result,
11012 : : show, "show");
11013 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_port =
11014 : : TOKEN_STRING_INITIALIZER
11015 : : (struct cmd_rx_offload_get_capa_result,
11016 : : port, "port");
11017 : : static cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id =
11018 : : TOKEN_NUM_INITIALIZER
11019 : : (struct cmd_rx_offload_get_capa_result,
11020 : : port_id, RTE_UINT16);
11021 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload =
11022 : : TOKEN_STRING_INITIALIZER
11023 : : (struct cmd_rx_offload_get_capa_result,
11024 : : rx_offload, "rx_offload");
11025 : : static cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities =
11026 : : TOKEN_STRING_INITIALIZER
11027 : : (struct cmd_rx_offload_get_capa_result,
11028 : : capabilities, "capabilities");
11029 : :
11030 : : static void
11031 : 0 : print_rx_offloads(uint64_t offloads)
11032 : : {
11033 : : uint64_t single_offload;
11034 : : int begin;
11035 : : int end;
11036 : : int bit;
11037 : :
11038 : 0 : if (offloads == 0)
11039 : : return;
11040 : :
11041 : : begin = rte_ctz64(offloads);
11042 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11043 : :
11044 : 0 : single_offload = 1ULL << begin;
11045 : 0 : for (bit = begin; bit < end; bit++) {
11046 : 0 : if (offloads & single_offload)
11047 : 0 : printf(" %s",
11048 : : rte_eth_dev_rx_offload_name(single_offload));
11049 : 0 : single_offload <<= 1;
11050 : : }
11051 : : }
11052 : :
11053 : : static void
11054 : 0 : cmd_rx_offload_get_capa_parsed(
11055 : : void *parsed_result,
11056 : : __rte_unused struct cmdline *cl,
11057 : : __rte_unused void *data)
11058 : : {
11059 : : struct cmd_rx_offload_get_capa_result *res = parsed_result;
11060 : : struct rte_eth_dev_info dev_info;
11061 : 0 : portid_t port_id = res->port_id;
11062 : : uint64_t queue_offloads;
11063 : : uint64_t port_offloads;
11064 : : int ret;
11065 : :
11066 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11067 : 0 : if (ret != 0)
11068 : 0 : return;
11069 : :
11070 : 0 : queue_offloads = dev_info.rx_queue_offload_capa;
11071 : 0 : port_offloads = dev_info.rx_offload_capa ^ queue_offloads;
11072 : :
11073 : : printf("Rx Offloading Capabilities of port %d :\n", port_id);
11074 : : printf(" Per Queue :");
11075 : 0 : print_rx_offloads(queue_offloads);
11076 : :
11077 : : printf("\n");
11078 : : printf(" Per Port :");
11079 : 0 : print_rx_offloads(port_offloads);
11080 : : printf("\n\n");
11081 : : }
11082 : :
11083 : : static cmdline_parse_inst_t cmd_rx_offload_get_capa = {
11084 : : .f = cmd_rx_offload_get_capa_parsed,
11085 : : .data = NULL,
11086 : : .help_str = "show port <port_id> rx_offload capabilities",
11087 : : .tokens = {
11088 : : (void *)&cmd_rx_offload_get_capa_show,
11089 : : (void *)&cmd_rx_offload_get_capa_port,
11090 : : (void *)&cmd_rx_offload_get_capa_port_id,
11091 : : (void *)&cmd_rx_offload_get_capa_rx_offload,
11092 : : (void *)&cmd_rx_offload_get_capa_capabilities,
11093 : : NULL,
11094 : : }
11095 : : };
11096 : :
11097 : : /* Get Rx offloads configuration */
11098 : : struct cmd_rx_offload_get_configuration_result {
11099 : : cmdline_fixed_string_t show;
11100 : : cmdline_fixed_string_t port;
11101 : : portid_t port_id;
11102 : : cmdline_fixed_string_t rx_offload;
11103 : : cmdline_fixed_string_t configuration;
11104 : : };
11105 : :
11106 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show =
11107 : : TOKEN_STRING_INITIALIZER
11108 : : (struct cmd_rx_offload_get_configuration_result,
11109 : : show, "show");
11110 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port =
11111 : : TOKEN_STRING_INITIALIZER
11112 : : (struct cmd_rx_offload_get_configuration_result,
11113 : : port, "port");
11114 : : static cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id =
11115 : : TOKEN_NUM_INITIALIZER
11116 : : (struct cmd_rx_offload_get_configuration_result,
11117 : : port_id, RTE_UINT16);
11118 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload =
11119 : : TOKEN_STRING_INITIALIZER
11120 : : (struct cmd_rx_offload_get_configuration_result,
11121 : : rx_offload, "rx_offload");
11122 : : static cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration =
11123 : : TOKEN_STRING_INITIALIZER
11124 : : (struct cmd_rx_offload_get_configuration_result,
11125 : : configuration, "configuration");
11126 : :
11127 : : static void
11128 : 0 : cmd_rx_offload_get_configuration_parsed(
11129 : : void *parsed_result,
11130 : : __rte_unused struct cmdline *cl,
11131 : : __rte_unused void *data)
11132 : : {
11133 : : struct cmd_rx_offload_get_configuration_result *res = parsed_result;
11134 : : struct rte_eth_dev_info dev_info;
11135 : 0 : portid_t port_id = res->port_id;
11136 : 0 : struct rte_port *port = &ports[port_id];
11137 : : struct rte_eth_conf dev_conf;
11138 : : uint64_t port_offloads;
11139 : : uint64_t queue_offloads;
11140 : : uint16_t nb_rx_queues;
11141 : : int q;
11142 : : int ret;
11143 : :
11144 : 0 : printf("Rx Offloading Configuration of port %d :\n", port_id);
11145 : :
11146 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11147 : 0 : if (ret != 0)
11148 : 0 : return;
11149 : :
11150 : 0 : port_offloads = dev_conf.rxmode.offloads;
11151 : : printf(" Port :");
11152 : 0 : print_rx_offloads(port_offloads);
11153 : : printf("\n");
11154 : :
11155 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11156 : 0 : if (ret != 0)
11157 : : return;
11158 : :
11159 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11160 : 0 : for (q = 0; q < nb_rx_queues; q++) {
11161 : 0 : queue_offloads = port->rxq[q].conf.offloads;
11162 : : printf(" Queue[%2d] :", q);
11163 : 0 : print_rx_offloads(queue_offloads);
11164 : : printf("\n");
11165 : : }
11166 : : printf("\n");
11167 : : }
11168 : :
11169 : : static cmdline_parse_inst_t cmd_rx_offload_get_configuration = {
11170 : : .f = cmd_rx_offload_get_configuration_parsed,
11171 : : .data = NULL,
11172 : : .help_str = "show port <port_id> rx_offload configuration",
11173 : : .tokens = {
11174 : : (void *)&cmd_rx_offload_get_configuration_show,
11175 : : (void *)&cmd_rx_offload_get_configuration_port,
11176 : : (void *)&cmd_rx_offload_get_configuration_port_id,
11177 : : (void *)&cmd_rx_offload_get_configuration_rx_offload,
11178 : : (void *)&cmd_rx_offload_get_configuration_configuration,
11179 : : NULL,
11180 : : }
11181 : : };
11182 : :
11183 : : /* Enable/Disable a per port offloading */
11184 : : struct cmd_config_per_port_rx_offload_result {
11185 : : cmdline_fixed_string_t port;
11186 : : cmdline_fixed_string_t config;
11187 : : portid_t port_id;
11188 : : cmdline_fixed_string_t rx_offload;
11189 : : cmdline_fixed_string_t offload;
11190 : : cmdline_fixed_string_t on_off;
11191 : : };
11192 : :
11193 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port =
11194 : : TOKEN_STRING_INITIALIZER
11195 : : (struct cmd_config_per_port_rx_offload_result,
11196 : : port, "port");
11197 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config =
11198 : : TOKEN_STRING_INITIALIZER
11199 : : (struct cmd_config_per_port_rx_offload_result,
11200 : : config, "config");
11201 : : static cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id =
11202 : : TOKEN_NUM_INITIALIZER
11203 : : (struct cmd_config_per_port_rx_offload_result,
11204 : : port_id, RTE_UINT16);
11205 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload =
11206 : : TOKEN_STRING_INITIALIZER
11207 : : (struct cmd_config_per_port_rx_offload_result,
11208 : : rx_offload, "rx_offload");
11209 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload =
11210 : : TOKEN_STRING_INITIALIZER
11211 : : (struct cmd_config_per_port_rx_offload_result,
11212 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11213 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11214 : : "vlan_filter#vlan_extend#"
11215 : : "scatter#buffer_split#timestamp#security#"
11216 : : "keep_crc#rss_hash");
11217 : : static cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off =
11218 : : TOKEN_STRING_INITIALIZER
11219 : : (struct cmd_config_per_port_rx_offload_result,
11220 : : on_off, "on#off");
11221 : :
11222 : : static uint64_t
11223 : 0 : search_rx_offload(const char *name)
11224 : : {
11225 : : uint64_t single_offload;
11226 : : const char *single_name;
11227 : : int found = 0;
11228 : : unsigned int bit;
11229 : :
11230 : : single_offload = 1;
11231 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11232 : 0 : single_name = rte_eth_dev_rx_offload_name(single_offload);
11233 : 0 : if (!strcasecmp(single_name, name)) {
11234 : : found = 1;
11235 : : break;
11236 : : }
11237 : 0 : single_offload <<= 1;
11238 : : }
11239 : :
11240 : 0 : if (found)
11241 : 0 : return single_offload;
11242 : :
11243 : : return 0;
11244 : : }
11245 : :
11246 : : static void
11247 : 0 : config_port_rx_offload(portid_t port_id, char *name, bool on)
11248 : : {
11249 : : struct rte_eth_dev_info dev_info;
11250 : 0 : struct rte_port *port = &ports[port_id];
11251 : : uint16_t nb_rx_queues;
11252 : : uint64_t offload;
11253 : : int q;
11254 : : int ret;
11255 : :
11256 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11257 : 0 : fprintf(stderr,
11258 : : "Error: Can't config offload when Port %d is not stopped\n",
11259 : : port_id);
11260 : 0 : return;
11261 : : }
11262 : :
11263 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11264 : 0 : if (ret != 0)
11265 : : return;
11266 : :
11267 : 0 : if (!strcmp(name, "all")) {
11268 : 0 : offload = dev_info.rx_offload_capa;
11269 : : } else {
11270 : 0 : offload = search_rx_offload(name);
11271 : 0 : if (offload == 0) {
11272 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
11273 : 0 : return;
11274 : : }
11275 : 0 : if ((offload & dev_info.rx_offload_capa) == 0) {
11276 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11277 : : port_id, name);
11278 : 0 : return;
11279 : : }
11280 : : }
11281 : :
11282 : 0 : nb_rx_queues = dev_info.nb_rx_queues;
11283 : 0 : if (on) {
11284 : 0 : port->dev_conf.rxmode.offloads |= offload;
11285 : 0 : for (q = 0; q < nb_rx_queues; q++)
11286 : 0 : port->rxq[q].conf.offloads |= offload;
11287 : : } else {
11288 : 0 : port->dev_conf.rxmode.offloads &= ~offload;
11289 : 0 : for (q = 0; q < nb_rx_queues; q++)
11290 : 0 : port->rxq[q].conf.offloads &= ~offload;
11291 : : }
11292 : :
11293 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11294 : : }
11295 : :
11296 : : static void
11297 : 0 : cmd_config_per_port_rx_offload_parsed(void *parsed_result,
11298 : : __rte_unused struct cmdline *cl,
11299 : : __rte_unused void *data)
11300 : : {
11301 : : struct cmd_config_per_port_rx_offload_result *res = parsed_result;
11302 : : bool on;
11303 : :
11304 : 0 : on = strcmp(res->on_off, "on") == 0;
11305 : 0 : config_port_rx_offload(res->port_id, res->offload, on);
11306 : 0 : }
11307 : :
11308 : : static cmdline_parse_inst_t cmd_config_per_port_rx_offload = {
11309 : : .f = cmd_config_per_port_rx_offload_parsed,
11310 : : .data = NULL,
11311 : : .help_str = "port config <port_id> rx_offload all|vlan_strip|ipv4_cksum|"
11312 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11313 : : "macsec_strip|vlan_filter|vlan_extend|"
11314 : : "scatter|buffer_split|timestamp|security|"
11315 : : "keep_crc|rss_hash on|off",
11316 : : .tokens = {
11317 : : (void *)&cmd_config_per_port_rx_offload_result_port,
11318 : : (void *)&cmd_config_per_port_rx_offload_result_config,
11319 : : (void *)&cmd_config_per_port_rx_offload_result_port_id,
11320 : : (void *)&cmd_config_per_port_rx_offload_result_rx_offload,
11321 : : (void *)&cmd_config_per_port_rx_offload_result_offload,
11322 : : (void *)&cmd_config_per_port_rx_offload_result_on_off,
11323 : : NULL,
11324 : : }
11325 : : };
11326 : :
11327 : : /* Enable/Disable all port Rx offloading */
11328 : : struct cmd_config_all_port_rx_offload_result {
11329 : : cmdline_fixed_string_t port;
11330 : : cmdline_fixed_string_t config;
11331 : : cmdline_fixed_string_t port_all;
11332 : : cmdline_fixed_string_t rx_offload;
11333 : : cmdline_fixed_string_t offload;
11334 : : cmdline_fixed_string_t on_off;
11335 : : };
11336 : :
11337 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port =
11338 : : TOKEN_STRING_INITIALIZER
11339 : : (struct cmd_config_all_port_rx_offload_result,
11340 : : port, "port");
11341 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_config =
11342 : : TOKEN_STRING_INITIALIZER
11343 : : (struct cmd_config_all_port_rx_offload_result,
11344 : : config, "config");
11345 : :
11346 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_port_all =
11347 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_rx_offload_result,
11348 : : port_all, "all");
11349 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_rx_offload =
11350 : : TOKEN_STRING_INITIALIZER
11351 : : (struct cmd_config_all_port_rx_offload_result,
11352 : : rx_offload, "rx_offload");
11353 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_offload =
11354 : : TOKEN_STRING_INITIALIZER
11355 : : (struct cmd_config_all_port_rx_offload_result,
11356 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11357 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11358 : : "vlan_filter#vlan_extend#"
11359 : : "scatter#buffer_split#timestamp#security#"
11360 : : "keep_crc#rss_hash");
11361 : : static cmdline_parse_token_string_t cmd_config_all_port_rx_offload_result_on_off =
11362 : : TOKEN_STRING_INITIALIZER
11363 : : (struct cmd_config_all_port_rx_offload_result,
11364 : : on_off, "on#off");
11365 : :
11366 : : static void
11367 : 0 : cmd_config_all_port_rx_offload_parsed(void *parsed_result,
11368 : : __rte_unused struct cmdline *cl,
11369 : : __rte_unused void *data)
11370 : : {
11371 : : struct cmd_config_all_port_rx_offload_result *res = parsed_result;
11372 : : bool on_off;
11373 : : portid_t i;
11374 : :
11375 : 0 : on_off = strcmp(res->on_off, "on") == 0;
11376 : 0 : RTE_ETH_FOREACH_DEV(i)
11377 : 0 : config_port_rx_offload(i, res->offload, on_off);
11378 : :
11379 : 0 : }
11380 : :
11381 : : static cmdline_parse_inst_t cmd_config_all_port_rx_offload = {
11382 : : .f = cmd_config_all_port_rx_offload_parsed,
11383 : : .data = NULL,
11384 : : .help_str = "port config all rx_offload all|vlan_strip|ipv4_cksum|"
11385 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11386 : : "macsec_strip|vlan_filter|vlan_extend|"
11387 : : "scatter|buffer_split|timestamp|security|"
11388 : : "keep_crc|rss_hash on|off",
11389 : : .tokens = {
11390 : : (void *)&cmd_config_all_port_rx_offload_result_port,
11391 : : (void *)&cmd_config_all_port_rx_offload_result_config,
11392 : : (void *)&cmd_config_all_port_rx_offload_result_port_all,
11393 : : (void *)&cmd_config_all_port_rx_offload_result_rx_offload,
11394 : : (void *)&cmd_config_all_port_rx_offload_result_offload,
11395 : : (void *)&cmd_config_all_port_rx_offload_result_on_off,
11396 : : NULL,
11397 : : }
11398 : : };
11399 : :
11400 : : /* Enable/Disable a per queue offloading */
11401 : : struct cmd_config_per_queue_rx_offload_result {
11402 : : cmdline_fixed_string_t port;
11403 : : portid_t port_id;
11404 : : cmdline_fixed_string_t rxq;
11405 : : uint16_t queue_id;
11406 : : cmdline_fixed_string_t rx_offload;
11407 : : cmdline_fixed_string_t offload;
11408 : : cmdline_fixed_string_t on_off;
11409 : : };
11410 : :
11411 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port =
11412 : : TOKEN_STRING_INITIALIZER
11413 : : (struct cmd_config_per_queue_rx_offload_result,
11414 : : port, "port");
11415 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id =
11416 : : TOKEN_NUM_INITIALIZER
11417 : : (struct cmd_config_per_queue_rx_offload_result,
11418 : : port_id, RTE_UINT16);
11419 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq =
11420 : : TOKEN_STRING_INITIALIZER
11421 : : (struct cmd_config_per_queue_rx_offload_result,
11422 : : rxq, "rxq");
11423 : : static cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id =
11424 : : TOKEN_NUM_INITIALIZER
11425 : : (struct cmd_config_per_queue_rx_offload_result,
11426 : : queue_id, RTE_UINT16);
11427 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload =
11428 : : TOKEN_STRING_INITIALIZER
11429 : : (struct cmd_config_per_queue_rx_offload_result,
11430 : : rx_offload, "rx_offload");
11431 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload =
11432 : : TOKEN_STRING_INITIALIZER
11433 : : (struct cmd_config_per_queue_rx_offload_result,
11434 : : offload, "all#vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#"
11435 : : "qinq_strip#outer_ipv4_cksum#macsec_strip#"
11436 : : "vlan_filter#vlan_extend#"
11437 : : "scatter#buffer_split#timestamp#security#keep_crc");
11438 : : static cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off =
11439 : : TOKEN_STRING_INITIALIZER
11440 : : (struct cmd_config_per_queue_rx_offload_result,
11441 : : on_off, "on#off");
11442 : :
11443 : : static void
11444 : 0 : cmd_config_per_queue_rx_offload_parsed(void *parsed_result,
11445 : : __rte_unused struct cmdline *cl,
11446 : : __rte_unused void *data)
11447 : : {
11448 : : struct cmd_config_per_queue_rx_offload_result *res = parsed_result;
11449 : : struct rte_eth_dev_info dev_info;
11450 : 0 : portid_t port_id = res->port_id;
11451 : 0 : uint16_t queue_id = res->queue_id;
11452 : 0 : struct rte_port *port = &ports[port_id];
11453 : : uint64_t offload;
11454 : : int ret;
11455 : :
11456 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11457 : 0 : fprintf(stderr,
11458 : : "Error: Can't config offload when Port %d is not stopped\n",
11459 : : port_id);
11460 : 0 : return;
11461 : : }
11462 : :
11463 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11464 : 0 : if (ret != 0)
11465 : : return;
11466 : :
11467 : 0 : if (queue_id >= dev_info.nb_rx_queues) {
11468 : 0 : fprintf(stderr,
11469 : : "Error: input queue_id should be 0 ... %d\n",
11470 : 0 : dev_info.nb_rx_queues - 1);
11471 : 0 : return;
11472 : : }
11473 : :
11474 : 0 : if (!strcmp(res->offload, "all")) {
11475 : 0 : offload = dev_info.rx_queue_offload_capa;
11476 : : } else {
11477 : 0 : offload = search_rx_offload(res->offload);
11478 : 0 : if (offload == 0) {
11479 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
11480 : 0 : return;
11481 : : }
11482 : 0 : if ((offload & dev_info.rx_queue_offload_capa) == 0) {
11483 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
11484 : : port_id, res->offload);
11485 : 0 : return;
11486 : : }
11487 : : }
11488 : :
11489 : 0 : if (!strcmp(res->on_off, "on"))
11490 : 0 : port->rxq[queue_id].conf.offloads |= offload;
11491 : : else
11492 : 0 : port->rxq[queue_id].conf.offloads &= ~offload;
11493 : :
11494 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11495 : : }
11496 : :
11497 : : static cmdline_parse_inst_t cmd_config_per_queue_rx_offload = {
11498 : : .f = cmd_config_per_queue_rx_offload_parsed,
11499 : : .data = NULL,
11500 : : .help_str = "port <port_id> rxq <queue_id> rx_offload "
11501 : : "all|vlan_strip|ipv4_cksum|"
11502 : : "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|"
11503 : : "macsec_strip|vlan_filter|vlan_extend|"
11504 : : "scatter|buffer_split|timestamp|security|"
11505 : : "keep_crc on|off",
11506 : : .tokens = {
11507 : : (void *)&cmd_config_per_queue_rx_offload_result_port,
11508 : : (void *)&cmd_config_per_queue_rx_offload_result_port_id,
11509 : : (void *)&cmd_config_per_queue_rx_offload_result_rxq,
11510 : : (void *)&cmd_config_per_queue_rx_offload_result_queue_id,
11511 : : (void *)&cmd_config_per_queue_rx_offload_result_rxoffload,
11512 : : (void *)&cmd_config_per_queue_rx_offload_result_offload,
11513 : : (void *)&cmd_config_per_queue_rx_offload_result_on_off,
11514 : : NULL,
11515 : : }
11516 : : };
11517 : :
11518 : : /* Get Tx offloads capabilities */
11519 : : struct cmd_tx_offload_get_capa_result {
11520 : : cmdline_fixed_string_t show;
11521 : : cmdline_fixed_string_t port;
11522 : : portid_t port_id;
11523 : : cmdline_fixed_string_t tx_offload;
11524 : : cmdline_fixed_string_t capabilities;
11525 : : };
11526 : :
11527 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_show =
11528 : : TOKEN_STRING_INITIALIZER
11529 : : (struct cmd_tx_offload_get_capa_result,
11530 : : show, "show");
11531 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_port =
11532 : : TOKEN_STRING_INITIALIZER
11533 : : (struct cmd_tx_offload_get_capa_result,
11534 : : port, "port");
11535 : : static cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id =
11536 : : TOKEN_NUM_INITIALIZER
11537 : : (struct cmd_tx_offload_get_capa_result,
11538 : : port_id, RTE_UINT16);
11539 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload =
11540 : : TOKEN_STRING_INITIALIZER
11541 : : (struct cmd_tx_offload_get_capa_result,
11542 : : tx_offload, "tx_offload");
11543 : : static cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities =
11544 : : TOKEN_STRING_INITIALIZER
11545 : : (struct cmd_tx_offload_get_capa_result,
11546 : : capabilities, "capabilities");
11547 : :
11548 : : static void
11549 : 0 : print_tx_offloads(uint64_t offloads)
11550 : : {
11551 : : uint64_t single_offload;
11552 : : int begin;
11553 : : int end;
11554 : : int bit;
11555 : :
11556 : 0 : if (offloads == 0)
11557 : : return;
11558 : :
11559 : : begin = rte_ctz64(offloads);
11560 : 0 : end = sizeof(offloads) * CHAR_BIT - rte_clz64(offloads);
11561 : :
11562 : 0 : single_offload = 1ULL << begin;
11563 : 0 : for (bit = begin; bit < end; bit++) {
11564 : 0 : if (offloads & single_offload)
11565 : 0 : printf(" %s",
11566 : : rte_eth_dev_tx_offload_name(single_offload));
11567 : 0 : single_offload <<= 1;
11568 : : }
11569 : : }
11570 : :
11571 : : static void
11572 : 0 : cmd_tx_offload_get_capa_parsed(
11573 : : void *parsed_result,
11574 : : __rte_unused struct cmdline *cl,
11575 : : __rte_unused void *data)
11576 : : {
11577 : : struct cmd_tx_offload_get_capa_result *res = parsed_result;
11578 : : struct rte_eth_dev_info dev_info;
11579 : 0 : portid_t port_id = res->port_id;
11580 : : uint64_t queue_offloads;
11581 : : uint64_t port_offloads;
11582 : : int ret;
11583 : :
11584 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11585 : 0 : if (ret != 0)
11586 : 0 : return;
11587 : :
11588 : 0 : queue_offloads = dev_info.tx_queue_offload_capa;
11589 : 0 : port_offloads = dev_info.tx_offload_capa ^ queue_offloads;
11590 : :
11591 : : printf("Tx Offloading Capabilities of port %d :\n", port_id);
11592 : : printf(" Per Queue :");
11593 : 0 : print_tx_offloads(queue_offloads);
11594 : :
11595 : : printf("\n");
11596 : : printf(" Per Port :");
11597 : 0 : print_tx_offloads(port_offloads);
11598 : : printf("\n\n");
11599 : : }
11600 : :
11601 : : static cmdline_parse_inst_t cmd_tx_offload_get_capa = {
11602 : : .f = cmd_tx_offload_get_capa_parsed,
11603 : : .data = NULL,
11604 : : .help_str = "show port <port_id> tx_offload capabilities",
11605 : : .tokens = {
11606 : : (void *)&cmd_tx_offload_get_capa_show,
11607 : : (void *)&cmd_tx_offload_get_capa_port,
11608 : : (void *)&cmd_tx_offload_get_capa_port_id,
11609 : : (void *)&cmd_tx_offload_get_capa_tx_offload,
11610 : : (void *)&cmd_tx_offload_get_capa_capabilities,
11611 : : NULL,
11612 : : }
11613 : : };
11614 : :
11615 : : /* Get Tx offloads configuration */
11616 : : struct cmd_tx_offload_get_configuration_result {
11617 : : cmdline_fixed_string_t show;
11618 : : cmdline_fixed_string_t port;
11619 : : portid_t port_id;
11620 : : cmdline_fixed_string_t tx_offload;
11621 : : cmdline_fixed_string_t configuration;
11622 : : };
11623 : :
11624 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show =
11625 : : TOKEN_STRING_INITIALIZER
11626 : : (struct cmd_tx_offload_get_configuration_result,
11627 : : show, "show");
11628 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port =
11629 : : TOKEN_STRING_INITIALIZER
11630 : : (struct cmd_tx_offload_get_configuration_result,
11631 : : port, "port");
11632 : : static cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id =
11633 : : TOKEN_NUM_INITIALIZER
11634 : : (struct cmd_tx_offload_get_configuration_result,
11635 : : port_id, RTE_UINT16);
11636 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload =
11637 : : TOKEN_STRING_INITIALIZER
11638 : : (struct cmd_tx_offload_get_configuration_result,
11639 : : tx_offload, "tx_offload");
11640 : : static cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration =
11641 : : TOKEN_STRING_INITIALIZER
11642 : : (struct cmd_tx_offload_get_configuration_result,
11643 : : configuration, "configuration");
11644 : :
11645 : : static void
11646 : 0 : cmd_tx_offload_get_configuration_parsed(
11647 : : void *parsed_result,
11648 : : __rte_unused struct cmdline *cl,
11649 : : __rte_unused void *data)
11650 : : {
11651 : : struct cmd_tx_offload_get_configuration_result *res = parsed_result;
11652 : : struct rte_eth_dev_info dev_info;
11653 : 0 : portid_t port_id = res->port_id;
11654 : 0 : struct rte_port *port = &ports[port_id];
11655 : : struct rte_eth_conf dev_conf;
11656 : : uint64_t port_offloads;
11657 : : uint64_t queue_offloads;
11658 : : uint16_t nb_tx_queues;
11659 : : int q;
11660 : : int ret;
11661 : :
11662 : 0 : printf("Tx Offloading Configuration of port %d :\n", port_id);
11663 : :
11664 : 0 : ret = eth_dev_conf_get_print_err(port_id, &dev_conf);
11665 : 0 : if (ret != 0)
11666 : 0 : return;
11667 : :
11668 : 0 : port_offloads = dev_conf.txmode.offloads;
11669 : : printf(" Port :");
11670 : 0 : print_tx_offloads(port_offloads);
11671 : : printf("\n");
11672 : :
11673 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11674 : 0 : if (ret != 0)
11675 : : return;
11676 : :
11677 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
11678 : 0 : for (q = 0; q < nb_tx_queues; q++) {
11679 : 0 : queue_offloads = port->txq[q].conf.offloads;
11680 : : printf(" Queue[%2d] :", q);
11681 : 0 : print_tx_offloads(queue_offloads);
11682 : : printf("\n");
11683 : : }
11684 : : printf("\n");
11685 : : }
11686 : :
11687 : : static cmdline_parse_inst_t cmd_tx_offload_get_configuration = {
11688 : : .f = cmd_tx_offload_get_configuration_parsed,
11689 : : .data = NULL,
11690 : : .help_str = "show port <port_id> tx_offload configuration",
11691 : : .tokens = {
11692 : : (void *)&cmd_tx_offload_get_configuration_show,
11693 : : (void *)&cmd_tx_offload_get_configuration_port,
11694 : : (void *)&cmd_tx_offload_get_configuration_port_id,
11695 : : (void *)&cmd_tx_offload_get_configuration_tx_offload,
11696 : : (void *)&cmd_tx_offload_get_configuration_configuration,
11697 : : NULL,
11698 : : }
11699 : : };
11700 : :
11701 : : /* Enable/Disable a per port offloading */
11702 : : struct cmd_config_per_port_tx_offload_result {
11703 : : cmdline_fixed_string_t port;
11704 : : cmdline_fixed_string_t config;
11705 : : portid_t port_id;
11706 : : cmdline_fixed_string_t tx_offload;
11707 : : cmdline_fixed_string_t offload;
11708 : : cmdline_fixed_string_t on_off;
11709 : : };
11710 : :
11711 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port =
11712 : : TOKEN_STRING_INITIALIZER
11713 : : (struct cmd_config_per_port_tx_offload_result,
11714 : : port, "port");
11715 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config =
11716 : : TOKEN_STRING_INITIALIZER
11717 : : (struct cmd_config_per_port_tx_offload_result,
11718 : : config, "config");
11719 : : static cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id =
11720 : : TOKEN_NUM_INITIALIZER
11721 : : (struct cmd_config_per_port_tx_offload_result,
11722 : : port_id, RTE_UINT16);
11723 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload =
11724 : : TOKEN_STRING_INITIALIZER
11725 : : (struct cmd_config_per_port_tx_offload_result,
11726 : : tx_offload, "tx_offload");
11727 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload =
11728 : : TOKEN_STRING_INITIALIZER
11729 : : (struct cmd_config_per_port_tx_offload_result,
11730 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11731 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11732 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11733 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11734 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
11735 : : "send_on_timestamp");
11736 : : static cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off =
11737 : : TOKEN_STRING_INITIALIZER
11738 : : (struct cmd_config_per_port_tx_offload_result,
11739 : : on_off, "on#off");
11740 : :
11741 : : static uint64_t
11742 : 0 : search_tx_offload(const char *name)
11743 : : {
11744 : : uint64_t single_offload;
11745 : : const char *single_name;
11746 : : int found = 0;
11747 : : unsigned int bit;
11748 : :
11749 : : single_offload = 1;
11750 : 0 : for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) {
11751 : 0 : single_name = rte_eth_dev_tx_offload_name(single_offload);
11752 : 0 : if (single_name == NULL)
11753 : : break;
11754 : 0 : if (!strcasecmp(single_name, name)) {
11755 : : found = 1;
11756 : : break;
11757 : 0 : } else if (!strcasecmp(single_name, "UNKNOWN"))
11758 : : break;
11759 : 0 : single_offload <<= 1;
11760 : : }
11761 : :
11762 : 0 : if (found)
11763 : 0 : return single_offload;
11764 : :
11765 : : return 0;
11766 : : }
11767 : :
11768 : : static void
11769 : 0 : config_port_tx_offload(portid_t port_id, char *name, bool on)
11770 : : {
11771 : : struct rte_eth_dev_info dev_info;
11772 : 0 : struct rte_port *port = &ports[port_id];
11773 : : uint16_t nb_tx_queues;
11774 : : uint64_t offload;
11775 : : int q;
11776 : : int ret;
11777 : :
11778 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11779 : 0 : fprintf(stderr,
11780 : : "Error: Can't config offload when Port %d is not stopped\n",
11781 : : port_id);
11782 : 0 : return;
11783 : : }
11784 : :
11785 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11786 : 0 : if (ret != 0)
11787 : : return;
11788 : :
11789 : 0 : if (!strcmp(name, "all")) {
11790 : 0 : offload = dev_info.tx_offload_capa;
11791 : : } else {
11792 : 0 : offload = search_tx_offload(name);
11793 : 0 : if (offload == 0) {
11794 : 0 : fprintf(stderr, "Unknown offload name: %s\n", name);
11795 : 0 : return;
11796 : : }
11797 : 0 : if ((offload & dev_info.tx_offload_capa) == 0) {
11798 : 0 : fprintf(stderr, "Error: port %u doesn't support offload: %s.\n",
11799 : : port_id, name);
11800 : 0 : return;
11801 : : }
11802 : : }
11803 : :
11804 : 0 : nb_tx_queues = dev_info.nb_tx_queues;
11805 : 0 : if (on) {
11806 : 0 : port->dev_conf.txmode.offloads |= offload;
11807 : 0 : for (q = 0; q < nb_tx_queues; q++)
11808 : 0 : port->txq[q].conf.offloads |= offload;
11809 : : } else {
11810 : 0 : port->dev_conf.txmode.offloads &= ~offload;
11811 : 0 : for (q = 0; q < nb_tx_queues; q++)
11812 : 0 : port->txq[q].conf.offloads &= ~offload;
11813 : : }
11814 : :
11815 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
11816 : : }
11817 : :
11818 : : static void
11819 : 0 : cmd_config_per_port_tx_offload_parsed(void *parsed_result,
11820 : : __rte_unused struct cmdline *cl,
11821 : : __rte_unused void *data)
11822 : : {
11823 : : struct cmd_config_per_port_tx_offload_result *res = parsed_result;
11824 : : bool on;
11825 : :
11826 : 0 : on = strcmp(res->on_off, "on") == 0;
11827 : 0 : config_port_tx_offload(res->port_id, res->offload, on);
11828 : 0 : }
11829 : :
11830 : : static cmdline_parse_inst_t cmd_config_per_port_tx_offload = {
11831 : : .f = cmd_config_per_port_tx_offload_parsed,
11832 : : .data = NULL,
11833 : : .help_str = "port config <port_id> tx_offload "
11834 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
11835 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
11836 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
11837 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
11838 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
11839 : : "send_on_timestamp on|off",
11840 : : .tokens = {
11841 : : (void *)&cmd_config_per_port_tx_offload_result_port,
11842 : : (void *)&cmd_config_per_port_tx_offload_result_config,
11843 : : (void *)&cmd_config_per_port_tx_offload_result_port_id,
11844 : : (void *)&cmd_config_per_port_tx_offload_result_tx_offload,
11845 : : (void *)&cmd_config_per_port_tx_offload_result_offload,
11846 : : (void *)&cmd_config_per_port_tx_offload_result_on_off,
11847 : : NULL,
11848 : : }
11849 : : };
11850 : :
11851 : : /* Enable/Disable all port Tx offloading */
11852 : : struct cmd_config_all_port_tx_offload_result {
11853 : : cmdline_fixed_string_t port;
11854 : : cmdline_fixed_string_t config;
11855 : : cmdline_fixed_string_t port_all;
11856 : : cmdline_fixed_string_t tx_offload;
11857 : : cmdline_fixed_string_t offload;
11858 : : cmdline_fixed_string_t on_off;
11859 : : };
11860 : :
11861 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port =
11862 : : TOKEN_STRING_INITIALIZER
11863 : : (struct cmd_config_all_port_tx_offload_result,
11864 : : port, "port");
11865 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_config =
11866 : : TOKEN_STRING_INITIALIZER
11867 : : (struct cmd_config_all_port_tx_offload_result,
11868 : : config, "config");
11869 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_port_all =
11870 : : TOKEN_STRING_INITIALIZER(struct cmd_config_all_port_tx_offload_result,
11871 : : port_all, "all");
11872 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_tx_offload =
11873 : : TOKEN_STRING_INITIALIZER
11874 : : (struct cmd_config_all_port_tx_offload_result,
11875 : : tx_offload, "tx_offload");
11876 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_offload =
11877 : : TOKEN_STRING_INITIALIZER
11878 : : (struct cmd_config_all_port_tx_offload_result,
11879 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11880 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11881 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11882 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11883 : : "mt_lockfree#multi_segs#mbuf_fast_free#security#"
11884 : : "send_on_timestamp");
11885 : : static cmdline_parse_token_string_t cmd_config_all_port_tx_offload_result_on_off =
11886 : : TOKEN_STRING_INITIALIZER
11887 : : (struct cmd_config_all_port_tx_offload_result,
11888 : : on_off, "on#off");
11889 : :
11890 : : static void
11891 : 0 : cmd_config_all_port_tx_offload_parsed(void *parsed_result,
11892 : : __rte_unused struct cmdline *cl,
11893 : : __rte_unused void *data)
11894 : : {
11895 : : struct cmd_config_all_port_tx_offload_result *res = parsed_result;
11896 : : portid_t i;
11897 : : bool on_off;
11898 : :
11899 : 0 : on_off = strcmp(res->on_off, "on") == 0;
11900 : 0 : RTE_ETH_FOREACH_DEV(i)
11901 : 0 : config_port_tx_offload(i, res->offload, on_off);
11902 : 0 : }
11903 : :
11904 : : static cmdline_parse_inst_t cmd_config_all_port_tx_offload = {
11905 : : .f = cmd_config_all_port_tx_offload_parsed,
11906 : : .data = NULL,
11907 : : .help_str = "port config all tx_offload "
11908 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
11909 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
11910 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
11911 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
11912 : : "mt_lockfree|multi_segs|mbuf_fast_free|security|"
11913 : : "send_on_timestamp on|off",
11914 : : .tokens = {
11915 : : (void *)&cmd_config_all_port_tx_offload_result_port,
11916 : : (void *)&cmd_config_all_port_tx_offload_result_config,
11917 : : (void *)&cmd_config_all_port_tx_offload_result_port_all,
11918 : : (void *)&cmd_config_all_port_tx_offload_result_tx_offload,
11919 : : (void *)&cmd_config_all_port_tx_offload_result_offload,
11920 : : (void *)&cmd_config_all_port_tx_offload_result_on_off,
11921 : : NULL,
11922 : : }
11923 : : };
11924 : :
11925 : : /* Enable/Disable a per queue offloading */
11926 : : struct cmd_config_per_queue_tx_offload_result {
11927 : : cmdline_fixed_string_t port;
11928 : : portid_t port_id;
11929 : : cmdline_fixed_string_t txq;
11930 : : uint16_t queue_id;
11931 : : cmdline_fixed_string_t tx_offload;
11932 : : cmdline_fixed_string_t offload;
11933 : : cmdline_fixed_string_t on_off;
11934 : : };
11935 : :
11936 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port =
11937 : : TOKEN_STRING_INITIALIZER
11938 : : (struct cmd_config_per_queue_tx_offload_result,
11939 : : port, "port");
11940 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id =
11941 : : TOKEN_NUM_INITIALIZER
11942 : : (struct cmd_config_per_queue_tx_offload_result,
11943 : : port_id, RTE_UINT16);
11944 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq =
11945 : : TOKEN_STRING_INITIALIZER
11946 : : (struct cmd_config_per_queue_tx_offload_result,
11947 : : txq, "txq");
11948 : : static cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id =
11949 : : TOKEN_NUM_INITIALIZER
11950 : : (struct cmd_config_per_queue_tx_offload_result,
11951 : : queue_id, RTE_UINT16);
11952 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload =
11953 : : TOKEN_STRING_INITIALIZER
11954 : : (struct cmd_config_per_queue_tx_offload_result,
11955 : : tx_offload, "tx_offload");
11956 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload =
11957 : : TOKEN_STRING_INITIALIZER
11958 : : (struct cmd_config_per_queue_tx_offload_result,
11959 : : offload, "all#vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#"
11960 : : "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#"
11961 : : "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#"
11962 : : "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#"
11963 : : "mt_lockfree#multi_segs#mbuf_fast_free#security");
11964 : : static cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off =
11965 : : TOKEN_STRING_INITIALIZER
11966 : : (struct cmd_config_per_queue_tx_offload_result,
11967 : : on_off, "on#off");
11968 : :
11969 : : static void
11970 : 0 : cmd_config_per_queue_tx_offload_parsed(void *parsed_result,
11971 : : __rte_unused struct cmdline *cl,
11972 : : __rte_unused void *data)
11973 : : {
11974 : : struct cmd_config_per_queue_tx_offload_result *res = parsed_result;
11975 : : struct rte_eth_dev_info dev_info;
11976 : 0 : portid_t port_id = res->port_id;
11977 : 0 : uint16_t queue_id = res->queue_id;
11978 : 0 : struct rte_port *port = &ports[port_id];
11979 : : uint64_t offload;
11980 : : int ret;
11981 : :
11982 : 0 : if (port->port_status != RTE_PORT_STOPPED) {
11983 : 0 : fprintf(stderr,
11984 : : "Error: Can't config offload when Port %d is not stopped\n",
11985 : : port_id);
11986 : 0 : return;
11987 : : }
11988 : :
11989 : 0 : ret = eth_dev_info_get_print_err(port_id, &dev_info);
11990 : 0 : if (ret != 0)
11991 : : return;
11992 : :
11993 : 0 : if (queue_id >= dev_info.nb_tx_queues) {
11994 : 0 : fprintf(stderr,
11995 : : "Error: input queue_id should be 0 ... %d\n",
11996 : 0 : dev_info.nb_tx_queues - 1);
11997 : 0 : return;
11998 : : }
11999 : :
12000 : 0 : if (!strcmp(res->offload, "all")) {
12001 : 0 : offload = dev_info.tx_queue_offload_capa;
12002 : : } else {
12003 : 0 : offload = search_tx_offload(res->offload);
12004 : 0 : if (offload == 0) {
12005 : 0 : fprintf(stderr, "Unknown offload name: %s\n", res->offload);
12006 : 0 : return;
12007 : : }
12008 : 0 : if ((offload & dev_info.tx_queue_offload_capa) == 0) {
12009 : 0 : fprintf(stderr, "Error: port %u doesn't support per queue offload: %s.\n",
12010 : : port_id, res->offload);
12011 : 0 : return;
12012 : : }
12013 : : }
12014 : :
12015 : 0 : if (!strcmp(res->on_off, "on"))
12016 : 0 : port->txq[queue_id].conf.offloads |= offload;
12017 : : else
12018 : 0 : port->txq[queue_id].conf.offloads &= ~offload;
12019 : :
12020 : 0 : cmd_reconfig_device_queue(port_id, 1, 1);
12021 : : }
12022 : :
12023 : : static cmdline_parse_inst_t cmd_config_per_queue_tx_offload = {
12024 : : .f = cmd_config_per_queue_tx_offload_parsed,
12025 : : .data = NULL,
12026 : : .help_str = "port <port_id> txq <queue_id> tx_offload "
12027 : : "all|vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|"
12028 : : "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|"
12029 : : "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|"
12030 : : "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|"
12031 : : "mt_lockfree|multi_segs|mbuf_fast_free|security "
12032 : : "on|off",
12033 : : .tokens = {
12034 : : (void *)&cmd_config_per_queue_tx_offload_result_port,
12035 : : (void *)&cmd_config_per_queue_tx_offload_result_port_id,
12036 : : (void *)&cmd_config_per_queue_tx_offload_result_txq,
12037 : : (void *)&cmd_config_per_queue_tx_offload_result_queue_id,
12038 : : (void *)&cmd_config_per_queue_tx_offload_result_txoffload,
12039 : : (void *)&cmd_config_per_queue_tx_offload_result_offload,
12040 : : (void *)&cmd_config_per_queue_tx_offload_result_on_off,
12041 : : NULL,
12042 : : }
12043 : : };
12044 : :
12045 : : /* *** configure tx_metadata for specific port *** */
12046 : : struct cmd_config_tx_metadata_specific_result {
12047 : : cmdline_fixed_string_t port;
12048 : : cmdline_fixed_string_t keyword;
12049 : : uint16_t port_id;
12050 : : cmdline_fixed_string_t item;
12051 : : uint32_t value;
12052 : : };
12053 : :
12054 : : static void
12055 : 0 : cmd_config_tx_metadata_specific_parsed(void *parsed_result,
12056 : : __rte_unused struct cmdline *cl,
12057 : : __rte_unused void *data)
12058 : : {
12059 : : struct cmd_config_tx_metadata_specific_result *res = parsed_result;
12060 : :
12061 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12062 : : return;
12063 : 0 : ports[res->port_id].tx_metadata = res->value;
12064 : : /* Add/remove callback to insert valid metadata in every Tx packet. */
12065 : 0 : if (ports[res->port_id].tx_metadata)
12066 : 0 : add_tx_md_callback(res->port_id);
12067 : : else
12068 : 0 : remove_tx_md_callback(res->port_id);
12069 : 0 : rte_flow_dynf_metadata_register();
12070 : : }
12071 : :
12072 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port =
12073 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12074 : : port, "port");
12075 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword =
12076 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12077 : : keyword, "config");
12078 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id =
12079 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12080 : : port_id, RTE_UINT16);
12081 : : static cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item =
12082 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12083 : : item, "tx_metadata");
12084 : : static cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value =
12085 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result,
12086 : : value, RTE_UINT32);
12087 : :
12088 : : static cmdline_parse_inst_t cmd_config_tx_metadata_specific = {
12089 : : .f = cmd_config_tx_metadata_specific_parsed,
12090 : : .data = NULL,
12091 : : .help_str = "port config <port_id> tx_metadata <value>",
12092 : : .tokens = {
12093 : : (void *)&cmd_config_tx_metadata_specific_port,
12094 : : (void *)&cmd_config_tx_metadata_specific_keyword,
12095 : : (void *)&cmd_config_tx_metadata_specific_id,
12096 : : (void *)&cmd_config_tx_metadata_specific_item,
12097 : : (void *)&cmd_config_tx_metadata_specific_value,
12098 : : NULL,
12099 : : },
12100 : : };
12101 : :
12102 : : /* *** set dynf *** */
12103 : : struct cmd_config_tx_dynf_specific_result {
12104 : : cmdline_fixed_string_t port;
12105 : : cmdline_fixed_string_t keyword;
12106 : : uint16_t port_id;
12107 : : cmdline_fixed_string_t item;
12108 : : cmdline_fixed_string_t name;
12109 : : cmdline_fixed_string_t value;
12110 : : };
12111 : :
12112 : : static void
12113 : 0 : cmd_config_dynf_specific_parsed(void *parsed_result,
12114 : : __rte_unused struct cmdline *cl,
12115 : : __rte_unused void *data)
12116 : : {
12117 : : struct cmd_config_tx_dynf_specific_result *res = parsed_result;
12118 : : struct rte_mbuf_dynflag desc_flag;
12119 : : int flag;
12120 : : uint64_t old_port_flags;
12121 : :
12122 : 0 : if (port_id_is_invalid(res->port_id, ENABLED_WARN))
12123 : 0 : return;
12124 : 0 : flag = rte_mbuf_dynflag_lookup(res->name, NULL);
12125 : 0 : if (flag <= 0) {
12126 : 0 : if (strlcpy(desc_flag.name, res->name,
12127 : : RTE_MBUF_DYN_NAMESIZE) >= RTE_MBUF_DYN_NAMESIZE) {
12128 : 0 : fprintf(stderr, "Flag name too long\n");
12129 : 0 : return;
12130 : : }
12131 : 0 : desc_flag.flags = 0;
12132 : 0 : flag = rte_mbuf_dynflag_register(&desc_flag);
12133 : 0 : if (flag < 0) {
12134 : 0 : fprintf(stderr, "Can't register flag\n");
12135 : 0 : return;
12136 : : }
12137 : 0 : strcpy(dynf_names[flag], desc_flag.name);
12138 : : }
12139 : 0 : old_port_flags = ports[res->port_id].mbuf_dynf;
12140 : 0 : if (!strcmp(res->value, "set")) {
12141 : 0 : ports[res->port_id].mbuf_dynf |= 1UL << flag;
12142 : 0 : if (old_port_flags == 0)
12143 : 0 : add_tx_dynf_callback(res->port_id);
12144 : : } else {
12145 : 0 : ports[res->port_id].mbuf_dynf &= ~(1UL << flag);
12146 : 0 : if (ports[res->port_id].mbuf_dynf == 0)
12147 : 0 : remove_tx_dynf_callback(res->port_id);
12148 : : }
12149 : : }
12150 : :
12151 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_port =
12152 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12153 : : keyword, "port");
12154 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_keyword =
12155 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12156 : : keyword, "config");
12157 : : static cmdline_parse_token_num_t cmd_config_tx_dynf_specific_port_id =
12158 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12159 : : port_id, RTE_UINT16);
12160 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_item =
12161 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12162 : : item, "dynf");
12163 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_name =
12164 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12165 : : name, NULL);
12166 : : static cmdline_parse_token_string_t cmd_config_tx_dynf_specific_value =
12167 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_dynf_specific_result,
12168 : : value, "set#clear");
12169 : :
12170 : : static cmdline_parse_inst_t cmd_config_tx_dynf_specific = {
12171 : : .f = cmd_config_dynf_specific_parsed,
12172 : : .data = NULL,
12173 : : .help_str = "port config <port id> dynf <name> set|clear",
12174 : : .tokens = {
12175 : : (void *)&cmd_config_tx_dynf_specific_port,
12176 : : (void *)&cmd_config_tx_dynf_specific_keyword,
12177 : : (void *)&cmd_config_tx_dynf_specific_port_id,
12178 : : (void *)&cmd_config_tx_dynf_specific_item,
12179 : : (void *)&cmd_config_tx_dynf_specific_name,
12180 : : (void *)&cmd_config_tx_dynf_specific_value,
12181 : : NULL,
12182 : : },
12183 : : };
12184 : :
12185 : : /* *** display tx_metadata per port configuration *** */
12186 : : struct cmd_show_tx_metadata_result {
12187 : : cmdline_fixed_string_t cmd_show;
12188 : : cmdline_fixed_string_t cmd_port;
12189 : : cmdline_fixed_string_t cmd_keyword;
12190 : : portid_t cmd_pid;
12191 : : };
12192 : :
12193 : : static void
12194 : 0 : cmd_show_tx_metadata_parsed(void *parsed_result,
12195 : : __rte_unused struct cmdline *cl,
12196 : : __rte_unused void *data)
12197 : : {
12198 : : struct cmd_show_tx_metadata_result *res = parsed_result;
12199 : :
12200 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12201 : 0 : fprintf(stderr, "invalid port id %u\n", res->cmd_pid);
12202 : 0 : return;
12203 : : }
12204 : 0 : if (!strcmp(res->cmd_keyword, "tx_metadata")) {
12205 : 0 : printf("Port %u tx_metadata: %u\n", res->cmd_pid,
12206 : 0 : ports[res->cmd_pid].tx_metadata);
12207 : : }
12208 : : }
12209 : :
12210 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_show =
12211 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12212 : : cmd_show, "show");
12213 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_port =
12214 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12215 : : cmd_port, "port");
12216 : : static cmdline_parse_token_num_t cmd_show_tx_metadata_pid =
12217 : : TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result,
12218 : : cmd_pid, RTE_UINT16);
12219 : : static cmdline_parse_token_string_t cmd_show_tx_metadata_keyword =
12220 : : TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result,
12221 : : cmd_keyword, "tx_metadata");
12222 : :
12223 : : static cmdline_parse_inst_t cmd_show_tx_metadata = {
12224 : : .f = cmd_show_tx_metadata_parsed,
12225 : : .data = NULL,
12226 : : .help_str = "show port <port_id> tx_metadata",
12227 : : .tokens = {
12228 : : (void *)&cmd_show_tx_metadata_show,
12229 : : (void *)&cmd_show_tx_metadata_port,
12230 : : (void *)&cmd_show_tx_metadata_pid,
12231 : : (void *)&cmd_show_tx_metadata_keyword,
12232 : : NULL,
12233 : : },
12234 : : };
12235 : :
12236 : : /* *** show fec capability per port configuration *** */
12237 : : struct cmd_show_fec_capability_result {
12238 : : cmdline_fixed_string_t cmd_show;
12239 : : cmdline_fixed_string_t cmd_port;
12240 : : cmdline_fixed_string_t cmd_fec;
12241 : : cmdline_fixed_string_t cmd_keyword;
12242 : : portid_t cmd_pid;
12243 : : };
12244 : :
12245 : : static void
12246 : 0 : cmd_show_fec_capability_parsed(void *parsed_result,
12247 : : __rte_unused struct cmdline *cl,
12248 : : __rte_unused void *data)
12249 : : {
12250 : : struct cmd_show_fec_capability_result *res = parsed_result;
12251 : : struct rte_eth_fec_capa *speed_fec_capa;
12252 : : unsigned int num;
12253 : : int ret;
12254 : :
12255 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12256 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12257 : 0 : return;
12258 : : }
12259 : :
12260 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, NULL, 0);
12261 : 0 : if (ret == -ENOTSUP) {
12262 : 0 : fprintf(stderr, "Function not implemented\n");
12263 : 0 : return;
12264 : 0 : } else if (ret < 0) {
12265 : 0 : fprintf(stderr, "Get FEC capability failed: %d\n", ret);
12266 : 0 : return;
12267 : : }
12268 : :
12269 : 0 : num = (unsigned int)ret;
12270 : 0 : speed_fec_capa = calloc(num, sizeof(*speed_fec_capa));
12271 : 0 : if (speed_fec_capa == NULL) {
12272 : 0 : fprintf(stderr, "Failed to alloc FEC capability buffer\n");
12273 : 0 : return;
12274 : : }
12275 : :
12276 : 0 : ret = rte_eth_fec_get_capability(res->cmd_pid, speed_fec_capa, num);
12277 : 0 : if (ret < 0) {
12278 : 0 : fprintf(stderr, "Error getting FEC capability: %d\n", ret);
12279 : 0 : goto out;
12280 : : }
12281 : :
12282 : 0 : show_fec_capability(num, speed_fec_capa);
12283 : 0 : out:
12284 : 0 : free(speed_fec_capa);
12285 : : }
12286 : :
12287 : : static cmdline_parse_token_string_t cmd_show_fec_capability_show =
12288 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12289 : : cmd_show, "show");
12290 : : static cmdline_parse_token_string_t cmd_show_fec_capability_port =
12291 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12292 : : cmd_port, "port");
12293 : : static cmdline_parse_token_num_t cmd_show_fec_capability_pid =
12294 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_capability_result,
12295 : : cmd_pid, RTE_UINT16);
12296 : : static cmdline_parse_token_string_t cmd_show_fec_capability_fec =
12297 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12298 : : cmd_fec, "fec");
12299 : : static cmdline_parse_token_string_t cmd_show_fec_capability_keyword =
12300 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_capability_result,
12301 : : cmd_keyword, "capabilities");
12302 : :
12303 : : static cmdline_parse_inst_t cmd_show_capability = {
12304 : : .f = cmd_show_fec_capability_parsed,
12305 : : .data = NULL,
12306 : : .help_str = "show port <port_id> fec capabilities",
12307 : : .tokens = {
12308 : : (void *)&cmd_show_fec_capability_show,
12309 : : (void *)&cmd_show_fec_capability_port,
12310 : : (void *)&cmd_show_fec_capability_pid,
12311 : : (void *)&cmd_show_fec_capability_fec,
12312 : : (void *)&cmd_show_fec_capability_keyword,
12313 : : NULL,
12314 : : },
12315 : : };
12316 : :
12317 : : /* *** show fec mode per port configuration *** */
12318 : : struct cmd_show_fec_metadata_result {
12319 : : cmdline_fixed_string_t cmd_show;
12320 : : cmdline_fixed_string_t cmd_port;
12321 : : cmdline_fixed_string_t cmd_keyword;
12322 : : portid_t cmd_pid;
12323 : : };
12324 : :
12325 : : static void
12326 : 0 : cmd_show_fec_mode_parsed(void *parsed_result,
12327 : : __rte_unused struct cmdline *cl,
12328 : : __rte_unused void *data)
12329 : : {
12330 : : #define FEC_NAME_SIZE 16
12331 : : struct cmd_show_fec_metadata_result *res = parsed_result;
12332 : : uint32_t mode;
12333 : : char buf[FEC_NAME_SIZE];
12334 : : int ret;
12335 : :
12336 : 0 : if (!rte_eth_dev_is_valid_port(res->cmd_pid)) {
12337 : 0 : fprintf(stderr, "Invalid port id %u\n", res->cmd_pid);
12338 : 0 : return;
12339 : : }
12340 : 0 : ret = rte_eth_fec_get(res->cmd_pid, &mode);
12341 : 0 : if (ret == -ENOTSUP) {
12342 : 0 : fprintf(stderr, "Function not implemented\n");
12343 : 0 : return;
12344 : 0 : } else if (ret < 0) {
12345 : 0 : fprintf(stderr, "Get FEC mode failed\n");
12346 : 0 : return;
12347 : : }
12348 : :
12349 : 0 : switch (mode) {
12350 : : case RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC):
12351 : : strlcpy(buf, "off", sizeof(buf));
12352 : : break;
12353 : : case RTE_ETH_FEC_MODE_CAPA_MASK(AUTO):
12354 : : strlcpy(buf, "auto", sizeof(buf));
12355 : : break;
12356 : : case RTE_ETH_FEC_MODE_CAPA_MASK(BASER):
12357 : : strlcpy(buf, "baser", sizeof(buf));
12358 : : break;
12359 : : case RTE_ETH_FEC_MODE_CAPA_MASK(RS):
12360 : : strlcpy(buf, "rs", sizeof(buf));
12361 : : break;
12362 : : case RTE_ETH_FEC_MODE_CAPA_MASK(LLRS):
12363 : : strlcpy(buf, "llrs", sizeof(buf));
12364 : : break;
12365 : : default:
12366 : : return;
12367 : : }
12368 : :
12369 : : printf("%s\n", buf);
12370 : : }
12371 : :
12372 : : static cmdline_parse_token_string_t cmd_show_fec_mode_show =
12373 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12374 : : cmd_show, "show");
12375 : : static cmdline_parse_token_string_t cmd_show_fec_mode_port =
12376 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12377 : : cmd_port, "port");
12378 : : static cmdline_parse_token_num_t cmd_show_fec_mode_pid =
12379 : : TOKEN_NUM_INITIALIZER(struct cmd_show_fec_metadata_result,
12380 : : cmd_pid, RTE_UINT16);
12381 : : static cmdline_parse_token_string_t cmd_show_fec_mode_keyword =
12382 : : TOKEN_STRING_INITIALIZER(struct cmd_show_fec_metadata_result,
12383 : : cmd_keyword, "fec_mode");
12384 : :
12385 : : static cmdline_parse_inst_t cmd_show_fec_mode = {
12386 : : .f = cmd_show_fec_mode_parsed,
12387 : : .data = NULL,
12388 : : .help_str = "show port <port_id> fec_mode",
12389 : : .tokens = {
12390 : : (void *)&cmd_show_fec_mode_show,
12391 : : (void *)&cmd_show_fec_mode_port,
12392 : : (void *)&cmd_show_fec_mode_pid,
12393 : : (void *)&cmd_show_fec_mode_keyword,
12394 : : NULL,
12395 : : },
12396 : : };
12397 : :
12398 : : /* *** set fec mode per port configuration *** */
12399 : : struct cmd_set_port_fec_mode {
12400 : : cmdline_fixed_string_t set;
12401 : : cmdline_fixed_string_t port;
12402 : : portid_t port_id;
12403 : : cmdline_fixed_string_t fec_mode;
12404 : : cmdline_fixed_string_t fec_value;
12405 : : };
12406 : :
12407 : : /* Common CLI fields for set fec mode */
12408 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_set =
12409 : : TOKEN_STRING_INITIALIZER
12410 : : (struct cmd_set_port_fec_mode,
12411 : : set, "set");
12412 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_port =
12413 : : TOKEN_STRING_INITIALIZER
12414 : : (struct cmd_set_port_fec_mode,
12415 : : port, "port");
12416 : : static cmdline_parse_token_num_t cmd_set_port_fec_mode_port_id =
12417 : : TOKEN_NUM_INITIALIZER
12418 : : (struct cmd_set_port_fec_mode,
12419 : : port_id, RTE_UINT16);
12420 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_str =
12421 : : TOKEN_STRING_INITIALIZER
12422 : : (struct cmd_set_port_fec_mode,
12423 : : fec_mode, "fec_mode");
12424 : : static cmdline_parse_token_string_t cmd_set_port_fec_mode_value =
12425 : : TOKEN_STRING_INITIALIZER
12426 : : (struct cmd_set_port_fec_mode,
12427 : : fec_value, NULL);
12428 : :
12429 : : static void
12430 : 0 : cmd_set_port_fec_mode_parsed(
12431 : : void *parsed_result,
12432 : : __rte_unused struct cmdline *cl,
12433 : : __rte_unused void *data)
12434 : : {
12435 : : struct cmd_set_port_fec_mode *res = parsed_result;
12436 : 0 : uint16_t port_id = res->port_id;
12437 : : uint32_t fec_capa;
12438 : : int ret;
12439 : :
12440 : 0 : ret = parse_fec_mode(res->fec_value, &fec_capa);
12441 : 0 : if (ret < 0) {
12442 : 0 : fprintf(stderr, "Unknown fec mode: %s for port %d\n",
12443 : : res->fec_value, port_id);
12444 : 0 : return;
12445 : : }
12446 : :
12447 : 0 : ret = rte_eth_fec_set(port_id, fec_capa);
12448 : 0 : if (ret == -ENOTSUP) {
12449 : 0 : fprintf(stderr, "Function not implemented\n");
12450 : 0 : return;
12451 : 0 : } else if (ret < 0) {
12452 : 0 : fprintf(stderr, "Set FEC mode failed\n");
12453 : 0 : return;
12454 : : }
12455 : : }
12456 : :
12457 : : static cmdline_parse_inst_t cmd_set_fec_mode = {
12458 : : .f = cmd_set_port_fec_mode_parsed,
12459 : : .data = NULL,
12460 : : .help_str = "set port <port_id> fec_mode auto|off|rs|baser|llrs",
12461 : : .tokens = {
12462 : : (void *)&cmd_set_port_fec_mode_set,
12463 : : (void *)&cmd_set_port_fec_mode_port,
12464 : : (void *)&cmd_set_port_fec_mode_port_id,
12465 : : (void *)&cmd_set_port_fec_mode_str,
12466 : : (void *)&cmd_set_port_fec_mode_value,
12467 : : NULL,
12468 : : },
12469 : : };
12470 : :
12471 : : /* *** set available descriptors threshold for an RxQ of a port *** */
12472 : : struct cmd_set_rxq_avail_thresh_result {
12473 : : cmdline_fixed_string_t set;
12474 : : cmdline_fixed_string_t port;
12475 : : uint16_t port_num;
12476 : : cmdline_fixed_string_t rxq;
12477 : : uint16_t rxq_num;
12478 : : cmdline_fixed_string_t avail_thresh;
12479 : : uint8_t avail_thresh_num;
12480 : : };
12481 : :
12482 : 0 : static void cmd_set_rxq_avail_thresh_parsed(void *parsed_result,
12483 : : __rte_unused struct cmdline *cl,
12484 : : __rte_unused void *data)
12485 : : {
12486 : : struct cmd_set_rxq_avail_thresh_result *res = parsed_result;
12487 : : int ret = 0;
12488 : :
12489 : 0 : if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0)
12490 : 0 : && (strcmp(res->rxq, "rxq") == 0)
12491 : 0 : && (strcmp(res->avail_thresh, "avail_thresh") == 0))
12492 : 0 : ret = set_rxq_avail_thresh(res->port_num, res->rxq_num,
12493 : 0 : res->avail_thresh_num);
12494 : 0 : if (ret < 0)
12495 : 0 : printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret));
12496 : :
12497 : 0 : }
12498 : :
12499 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_set =
12500 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12501 : : set, "set");
12502 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_port =
12503 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12504 : : port, "port");
12505 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_portnum =
12506 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12507 : : port_num, RTE_UINT16);
12508 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_rxq =
12509 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12510 : : rxq, "rxq");
12511 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_rxqnum =
12512 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12513 : : rxq_num, RTE_UINT16);
12514 : : static cmdline_parse_token_string_t cmd_set_rxq_avail_thresh_avail_thresh =
12515 : : TOKEN_STRING_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12516 : : avail_thresh, "avail_thresh");
12517 : : static cmdline_parse_token_num_t cmd_set_rxq_avail_thresh_avail_threshnum =
12518 : : TOKEN_NUM_INITIALIZER(struct cmd_set_rxq_avail_thresh_result,
12519 : : avail_thresh_num, RTE_UINT8);
12520 : :
12521 : : static cmdline_parse_inst_t cmd_set_rxq_avail_thresh = {
12522 : : .f = cmd_set_rxq_avail_thresh_parsed,
12523 : : .data = (void *)0,
12524 : : .help_str =
12525 : : "set port <port_id> rxq <queue_id> avail_thresh <0..99>: "
12526 : : "Set available descriptors threshold for Rx queue",
12527 : : .tokens = {
12528 : : (void *)&cmd_set_rxq_avail_thresh_set,
12529 : : (void *)&cmd_set_rxq_avail_thresh_port,
12530 : : (void *)&cmd_set_rxq_avail_thresh_portnum,
12531 : : (void *)&cmd_set_rxq_avail_thresh_rxq,
12532 : : (void *)&cmd_set_rxq_avail_thresh_rxqnum,
12533 : : (void *)&cmd_set_rxq_avail_thresh_avail_thresh,
12534 : : (void *)&cmd_set_rxq_avail_thresh_avail_threshnum,
12535 : : NULL,
12536 : : },
12537 : : };
12538 : :
12539 : : /* show port supported ptypes */
12540 : :
12541 : : /* Common result structure for show port ptypes */
12542 : : struct cmd_show_port_supported_ptypes_result {
12543 : : cmdline_fixed_string_t show;
12544 : : cmdline_fixed_string_t port;
12545 : : portid_t port_id;
12546 : : cmdline_fixed_string_t ptypes;
12547 : : };
12548 : :
12549 : : /* Common CLI fields for show port ptypes */
12550 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_show =
12551 : : TOKEN_STRING_INITIALIZER
12552 : : (struct cmd_show_port_supported_ptypes_result,
12553 : : show, "show");
12554 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_port =
12555 : : TOKEN_STRING_INITIALIZER
12556 : : (struct cmd_show_port_supported_ptypes_result,
12557 : : port, "port");
12558 : : static cmdline_parse_token_num_t cmd_show_port_supported_ptypes_port_id =
12559 : : TOKEN_NUM_INITIALIZER
12560 : : (struct cmd_show_port_supported_ptypes_result,
12561 : : port_id, RTE_UINT16);
12562 : : static cmdline_parse_token_string_t cmd_show_port_supported_ptypes_ptypes =
12563 : : TOKEN_STRING_INITIALIZER
12564 : : (struct cmd_show_port_supported_ptypes_result,
12565 : : ptypes, "ptypes");
12566 : :
12567 : : static void
12568 : 0 : cmd_show_port_supported_ptypes_parsed(
12569 : : void *parsed_result,
12570 : : __rte_unused struct cmdline *cl,
12571 : : __rte_unused void *data)
12572 : : {
12573 : : #define RSVD_PTYPE_MASK 0xf0000000
12574 : : #define MAX_PTYPES_PER_LAYER 16
12575 : : #define LTYPE_NAMESIZE 32
12576 : : #define PTYPE_NAMESIZE 256
12577 : : struct cmd_show_port_supported_ptypes_result *res = parsed_result;
12578 : : char buf[PTYPE_NAMESIZE], ltype[LTYPE_NAMESIZE];
12579 : : uint32_t ptype_mask = RTE_PTYPE_L2_MASK;
12580 : : uint32_t ptypes[MAX_PTYPES_PER_LAYER];
12581 : 0 : uint16_t port_id = res->port_id;
12582 : : int ret, i;
12583 : :
12584 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, ptype_mask, NULL, 0);
12585 : 0 : if (ret < 0)
12586 : 0 : return;
12587 : :
12588 : 0 : while (ptype_mask != RSVD_PTYPE_MASK) {
12589 : :
12590 : 0 : switch (ptype_mask) {
12591 : : case RTE_PTYPE_L2_MASK:
12592 : : strlcpy(ltype, "L2", sizeof(ltype));
12593 : : break;
12594 : : case RTE_PTYPE_L3_MASK:
12595 : : strlcpy(ltype, "L3", sizeof(ltype));
12596 : : break;
12597 : : case RTE_PTYPE_L4_MASK:
12598 : : strlcpy(ltype, "L4", sizeof(ltype));
12599 : : break;
12600 : : case RTE_PTYPE_TUNNEL_MASK:
12601 : : strlcpy(ltype, "Tunnel", sizeof(ltype));
12602 : : break;
12603 : : case RTE_PTYPE_INNER_L2_MASK:
12604 : : strlcpy(ltype, "Inner L2", sizeof(ltype));
12605 : : break;
12606 : : case RTE_PTYPE_INNER_L3_MASK:
12607 : : strlcpy(ltype, "Inner L3", sizeof(ltype));
12608 : : break;
12609 : : case RTE_PTYPE_INNER_L4_MASK:
12610 : : strlcpy(ltype, "Inner L4", sizeof(ltype));
12611 : : break;
12612 : : default:
12613 : : return;
12614 : : }
12615 : :
12616 : 0 : ret = rte_eth_dev_get_supported_ptypes(res->port_id,
12617 : : ptype_mask, ptypes,
12618 : : MAX_PTYPES_PER_LAYER);
12619 : :
12620 : 0 : if (ret > 0)
12621 : : printf("Supported %s ptypes:\n", ltype);
12622 : : else
12623 : : printf("%s ptypes unsupported\n", ltype);
12624 : :
12625 : 0 : for (i = 0; i < ret; ++i) {
12626 : 0 : rte_get_ptype_name(ptypes[i], buf, sizeof(buf));
12627 : : printf("%s\n", buf);
12628 : : }
12629 : :
12630 : 0 : ptype_mask <<= 4;
12631 : : }
12632 : : }
12633 : :
12634 : : static cmdline_parse_inst_t cmd_show_port_supported_ptypes = {
12635 : : .f = cmd_show_port_supported_ptypes_parsed,
12636 : : .data = NULL,
12637 : : .help_str = "show port <port_id> ptypes",
12638 : : .tokens = {
12639 : : (void *)&cmd_show_port_supported_ptypes_show,
12640 : : (void *)&cmd_show_port_supported_ptypes_port,
12641 : : (void *)&cmd_show_port_supported_ptypes_port_id,
12642 : : (void *)&cmd_show_port_supported_ptypes_ptypes,
12643 : : NULL,
12644 : : },
12645 : : };
12646 : :
12647 : : /* *** display rx/tx descriptor status *** */
12648 : : struct cmd_show_rx_tx_desc_status_result {
12649 : : cmdline_fixed_string_t cmd_show;
12650 : : cmdline_fixed_string_t cmd_port;
12651 : : cmdline_fixed_string_t cmd_keyword;
12652 : : cmdline_fixed_string_t cmd_desc;
12653 : : cmdline_fixed_string_t cmd_status;
12654 : : portid_t cmd_pid;
12655 : : portid_t cmd_qid;
12656 : : portid_t cmd_did;
12657 : : };
12658 : :
12659 : : static void
12660 : 0 : cmd_show_rx_tx_desc_status_parsed(void *parsed_result,
12661 : : __rte_unused struct cmdline *cl,
12662 : : __rte_unused void *data)
12663 : : {
12664 : : struct cmd_show_rx_tx_desc_status_result *res = parsed_result;
12665 : : int rc;
12666 : :
12667 : 0 : if (!strcmp(res->cmd_keyword, "rxq")) {
12668 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12669 : 0 : fprintf(stderr,
12670 : : "Invalid input: port id = %d, queue id = %d\n",
12671 : 0 : res->cmd_pid, res->cmd_qid);
12672 : 0 : return;
12673 : : }
12674 : 0 : rc = rte_eth_rx_descriptor_status(res->cmd_pid, res->cmd_qid,
12675 : 0 : res->cmd_did);
12676 : 0 : if (rc < 0) {
12677 : 0 : fprintf(stderr,
12678 : : "Invalid input: queue id = %d, desc id = %d\n",
12679 : 0 : res->cmd_qid, res->cmd_did);
12680 : 0 : return;
12681 : : }
12682 : 0 : if (rc == RTE_ETH_RX_DESC_AVAIL)
12683 : : printf("Desc status = AVAILABLE\n");
12684 : 0 : else if (rc == RTE_ETH_RX_DESC_DONE)
12685 : : printf("Desc status = DONE\n");
12686 : : else
12687 : : printf("Desc status = UNAVAILABLE\n");
12688 : 0 : } else if (!strcmp(res->cmd_keyword, "txq")) {
12689 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12690 : 0 : fprintf(stderr,
12691 : : "Invalid input: port id = %d, queue id = %d\n",
12692 : 0 : res->cmd_pid, res->cmd_qid);
12693 : 0 : return;
12694 : : }
12695 : 0 : rc = rte_eth_tx_descriptor_status(res->cmd_pid, res->cmd_qid,
12696 : 0 : res->cmd_did);
12697 : 0 : if (rc < 0) {
12698 : 0 : fprintf(stderr,
12699 : : "Invalid input: queue id = %d, desc id = %d\n",
12700 : 0 : res->cmd_qid, res->cmd_did);
12701 : 0 : return;
12702 : : }
12703 : 0 : if (rc == RTE_ETH_TX_DESC_FULL)
12704 : : printf("Desc status = FULL\n");
12705 : 0 : else if (rc == RTE_ETH_TX_DESC_DONE)
12706 : : printf("Desc status = DONE\n");
12707 : : else
12708 : : printf("Desc status = UNAVAILABLE\n");
12709 : : }
12710 : : }
12711 : :
12712 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_show =
12713 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12714 : : cmd_show, "show");
12715 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_port =
12716 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12717 : : cmd_port, "port");
12718 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_pid =
12719 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12720 : : cmd_pid, RTE_UINT16);
12721 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_keyword =
12722 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12723 : : cmd_keyword, "rxq#txq");
12724 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_qid =
12725 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12726 : : cmd_qid, RTE_UINT16);
12727 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_desc =
12728 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12729 : : cmd_desc, "desc");
12730 : : static cmdline_parse_token_num_t cmd_show_rx_tx_desc_status_did =
12731 : : TOKEN_NUM_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12732 : : cmd_did, RTE_UINT16);
12733 : : static cmdline_parse_token_string_t cmd_show_rx_tx_desc_status_status =
12734 : : TOKEN_STRING_INITIALIZER(struct cmd_show_rx_tx_desc_status_result,
12735 : : cmd_status, "status");
12736 : : static cmdline_parse_inst_t cmd_show_rx_tx_desc_status = {
12737 : : .f = cmd_show_rx_tx_desc_status_parsed,
12738 : : .data = NULL,
12739 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc <desc_id> "
12740 : : "status",
12741 : : .tokens = {
12742 : : (void *)&cmd_show_rx_tx_desc_status_show,
12743 : : (void *)&cmd_show_rx_tx_desc_status_port,
12744 : : (void *)&cmd_show_rx_tx_desc_status_pid,
12745 : : (void *)&cmd_show_rx_tx_desc_status_keyword,
12746 : : (void *)&cmd_show_rx_tx_desc_status_qid,
12747 : : (void *)&cmd_show_rx_tx_desc_status_desc,
12748 : : (void *)&cmd_show_rx_tx_desc_status_did,
12749 : : (void *)&cmd_show_rx_tx_desc_status_status,
12750 : : NULL,
12751 : : },
12752 : : };
12753 : :
12754 : : /* *** display rx/tx queue descriptor used count *** */
12755 : : struct cmd_show_rx_tx_queue_desc_used_count_result {
12756 : : cmdline_fixed_string_t cmd_show;
12757 : : cmdline_fixed_string_t cmd_port;
12758 : : cmdline_fixed_string_t cmd_dir;
12759 : : cmdline_fixed_string_t cmd_desc;
12760 : : cmdline_fixed_string_t cmd_used;
12761 : : cmdline_fixed_string_t cmd_count;
12762 : : portid_t cmd_pid;
12763 : : portid_t cmd_qid;
12764 : : };
12765 : :
12766 : : static void
12767 : 0 : cmd_show_rx_tx_queue_desc_used_count_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
12768 : : __rte_unused void *data)
12769 : : {
12770 : : struct cmd_show_rx_tx_queue_desc_used_count_result *res = parsed_result;
12771 : : int rc;
12772 : :
12773 : 0 : if (!strcmp(res->cmd_dir, "rxq")) {
12774 : 0 : if (rte_eth_rx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12775 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
12776 : 0 : res->cmd_pid, res->cmd_qid);
12777 : 0 : return;
12778 : : }
12779 : :
12780 : 0 : rc = rte_eth_rx_queue_count(res->cmd_pid, res->cmd_qid);
12781 : 0 : if (rc < 0) {
12782 : 0 : fprintf(stderr, "Rx queue count get failed rc=%d queue_id=%d\n", rc,
12783 : 0 : res->cmd_qid);
12784 : 0 : return;
12785 : : }
12786 : 0 : printf("RxQ %d used desc count = %d\n", res->cmd_qid, rc);
12787 : 0 : } else if (!strcmp(res->cmd_dir, "txq")) {
12788 : 0 : if (rte_eth_tx_queue_is_valid(res->cmd_pid, res->cmd_qid) != 0) {
12789 : 0 : fprintf(stderr, "Invalid input: port id = %d, queue id = %d\n",
12790 : 0 : res->cmd_pid, res->cmd_qid);
12791 : 0 : return;
12792 : : }
12793 : :
12794 : 0 : rc = rte_eth_tx_queue_count(res->cmd_pid, res->cmd_qid);
12795 : 0 : if (rc < 0) {
12796 : 0 : fprintf(stderr, "Tx queue count get failed rc=%d queue_id=%d\n", rc,
12797 : 0 : res->cmd_qid);
12798 : 0 : return;
12799 : : }
12800 : 0 : printf("TxQ %d used desc count = %d\n", res->cmd_qid, rc);
12801 : : }
12802 : : }
12803 : :
12804 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_show =
12805 : : TOKEN_STRING_INITIALIZER
12806 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12807 : : cmd_show, "show");
12808 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_port =
12809 : : TOKEN_STRING_INITIALIZER
12810 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12811 : : cmd_port, "port");
12812 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_pid =
12813 : : TOKEN_NUM_INITIALIZER
12814 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12815 : : cmd_pid, RTE_UINT16);
12816 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_dir =
12817 : : TOKEN_STRING_INITIALIZER
12818 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12819 : : cmd_dir, "rxq#txq");
12820 : : static cmdline_parse_token_num_t cmd_show_rx_tx_queue_desc_used_count_qid =
12821 : : TOKEN_NUM_INITIALIZER
12822 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12823 : : cmd_qid, RTE_UINT16);
12824 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_desc =
12825 : : TOKEN_STRING_INITIALIZER
12826 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12827 : : cmd_desc, "desc");
12828 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_used =
12829 : : TOKEN_STRING_INITIALIZER
12830 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12831 : : cmd_count, "used");
12832 : : static cmdline_parse_token_string_t cmd_show_rx_tx_queue_desc_used_count_count =
12833 : : TOKEN_STRING_INITIALIZER
12834 : : (struct cmd_show_rx_tx_queue_desc_used_count_result,
12835 : : cmd_count, "count");
12836 : : static cmdline_parse_inst_t cmd_show_rx_tx_queue_desc_used_count = {
12837 : : .f = cmd_show_rx_tx_queue_desc_used_count_parsed,
12838 : : .data = NULL,
12839 : : .help_str = "show port <port_id> rxq|txq <queue_id> desc used count",
12840 : : .tokens = {
12841 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_show,
12842 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_port,
12843 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_pid,
12844 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_dir,
12845 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_qid,
12846 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_desc,
12847 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_used,
12848 : : (void *)&cmd_show_rx_tx_queue_desc_used_count_count,
12849 : : NULL,
12850 : : },
12851 : : };
12852 : :
12853 : : /* Common result structure for set port ptypes */
12854 : : struct cmd_set_port_ptypes_result {
12855 : : cmdline_fixed_string_t set;
12856 : : cmdline_fixed_string_t port;
12857 : : portid_t port_id;
12858 : : cmdline_fixed_string_t ptype_mask;
12859 : : uint32_t mask;
12860 : : };
12861 : :
12862 : : /* Common CLI fields for set port ptypes */
12863 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_set =
12864 : : TOKEN_STRING_INITIALIZER
12865 : : (struct cmd_set_port_ptypes_result,
12866 : : set, "set");
12867 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_port =
12868 : : TOKEN_STRING_INITIALIZER
12869 : : (struct cmd_set_port_ptypes_result,
12870 : : port, "port");
12871 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_port_id =
12872 : : TOKEN_NUM_INITIALIZER
12873 : : (struct cmd_set_port_ptypes_result,
12874 : : port_id, RTE_UINT16);
12875 : : static cmdline_parse_token_string_t cmd_set_port_ptypes_mask_str =
12876 : : TOKEN_STRING_INITIALIZER
12877 : : (struct cmd_set_port_ptypes_result,
12878 : : ptype_mask, "ptype_mask");
12879 : : static cmdline_parse_token_num_t cmd_set_port_ptypes_mask_u32 =
12880 : : TOKEN_NUM_INITIALIZER
12881 : : (struct cmd_set_port_ptypes_result,
12882 : : mask, RTE_UINT32);
12883 : :
12884 : : static void
12885 : 0 : cmd_set_port_ptypes_parsed(
12886 : : void *parsed_result,
12887 : : __rte_unused struct cmdline *cl,
12888 : : __rte_unused void *data)
12889 : 0 : {
12890 : : struct cmd_set_port_ptypes_result *res = parsed_result;
12891 : : #define PTYPE_NAMESIZE 256
12892 : : char ptype_name[PTYPE_NAMESIZE];
12893 : 0 : uint16_t port_id = res->port_id;
12894 : 0 : uint32_t ptype_mask = res->mask;
12895 : : int ret, i;
12896 : :
12897 : 0 : ret = rte_eth_dev_get_supported_ptypes(port_id, RTE_PTYPE_ALL_MASK,
12898 : : NULL, 0);
12899 : 0 : if (ret <= 0) {
12900 : 0 : fprintf(stderr, "Port %d doesn't support any ptypes.\n",
12901 : : port_id);
12902 : 0 : return;
12903 : : }
12904 : :
12905 : 0 : uint32_t ptypes[ret];
12906 : :
12907 : 0 : ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret);
12908 : 0 : if (ret < 0) {
12909 : 0 : fprintf(stderr, "Unable to set requested ptypes for Port %d\n",
12910 : : port_id);
12911 : 0 : return;
12912 : : }
12913 : :
12914 : : printf("Successfully set following ptypes for Port %d\n", port_id);
12915 : 0 : for (i = 0; i < ret && ptypes[i] != RTE_PTYPE_UNKNOWN; i++) {
12916 : 0 : rte_get_ptype_name(ptypes[i], ptype_name, sizeof(ptype_name));
12917 : : printf("%s\n", ptype_name);
12918 : : }
12919 : :
12920 : 0 : clear_ptypes = false;
12921 : : }
12922 : :
12923 : : static cmdline_parse_inst_t cmd_set_port_ptypes = {
12924 : : .f = cmd_set_port_ptypes_parsed,
12925 : : .data = NULL,
12926 : : .help_str = "set port <port_id> ptype_mask <mask>",
12927 : : .tokens = {
12928 : : (void *)&cmd_set_port_ptypes_set,
12929 : : (void *)&cmd_set_port_ptypes_port,
12930 : : (void *)&cmd_set_port_ptypes_port_id,
12931 : : (void *)&cmd_set_port_ptypes_mask_str,
12932 : : (void *)&cmd_set_port_ptypes_mask_u32,
12933 : : NULL,
12934 : : },
12935 : : };
12936 : :
12937 : : /* *** display mac addresses added to a port *** */
12938 : : struct cmd_showport_macs_result {
12939 : : cmdline_fixed_string_t cmd_show;
12940 : : cmdline_fixed_string_t cmd_port;
12941 : : cmdline_fixed_string_t cmd_keyword;
12942 : : portid_t cmd_pid;
12943 : : };
12944 : :
12945 : : static void
12946 : 0 : cmd_showport_macs_parsed(void *parsed_result,
12947 : : __rte_unused struct cmdline *cl,
12948 : : __rte_unused void *data)
12949 : : {
12950 : : struct cmd_showport_macs_result *res = parsed_result;
12951 : :
12952 : 0 : if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN))
12953 : : return;
12954 : :
12955 : 0 : if (!strcmp(res->cmd_keyword, "macs"))
12956 : 0 : show_macs(res->cmd_pid);
12957 : 0 : else if (!strcmp(res->cmd_keyword, "mcast_macs"))
12958 : 0 : show_mcast_macs(res->cmd_pid);
12959 : : }
12960 : :
12961 : : static cmdline_parse_token_string_t cmd_showport_macs_show =
12962 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12963 : : cmd_show, "show");
12964 : : static cmdline_parse_token_string_t cmd_showport_macs_port =
12965 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12966 : : cmd_port, "port");
12967 : : static cmdline_parse_token_num_t cmd_showport_macs_pid =
12968 : : TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result,
12969 : : cmd_pid, RTE_UINT16);
12970 : : static cmdline_parse_token_string_t cmd_showport_macs_keyword =
12971 : : TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result,
12972 : : cmd_keyword, "macs#mcast_macs");
12973 : :
12974 : : static cmdline_parse_inst_t cmd_showport_macs = {
12975 : : .f = cmd_showport_macs_parsed,
12976 : : .data = NULL,
12977 : : .help_str = "show port <port_id> macs|mcast_macs",
12978 : : .tokens = {
12979 : : (void *)&cmd_showport_macs_show,
12980 : : (void *)&cmd_showport_macs_port,
12981 : : (void *)&cmd_showport_macs_pid,
12982 : : (void *)&cmd_showport_macs_keyword,
12983 : : NULL,
12984 : : },
12985 : : };
12986 : :
12987 : : /* *** show flow transfer proxy port ID for the given port *** */
12988 : : struct cmd_show_port_flow_transfer_proxy_result {
12989 : : cmdline_fixed_string_t show;
12990 : : cmdline_fixed_string_t port;
12991 : : portid_t port_id;
12992 : : cmdline_fixed_string_t flow;
12993 : : cmdline_fixed_string_t transfer;
12994 : : cmdline_fixed_string_t proxy;
12995 : : };
12996 : :
12997 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_show =
12998 : : TOKEN_STRING_INITIALIZER
12999 : : (struct cmd_show_port_flow_transfer_proxy_result,
13000 : : show, "show");
13001 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_port =
13002 : : TOKEN_STRING_INITIALIZER
13003 : : (struct cmd_show_port_flow_transfer_proxy_result,
13004 : : port, "port");
13005 : : static cmdline_parse_token_num_t cmd_show_port_flow_transfer_proxy_port_id =
13006 : : TOKEN_NUM_INITIALIZER
13007 : : (struct cmd_show_port_flow_transfer_proxy_result,
13008 : : port_id, RTE_UINT16);
13009 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_flow =
13010 : : TOKEN_STRING_INITIALIZER
13011 : : (struct cmd_show_port_flow_transfer_proxy_result,
13012 : : flow, "flow");
13013 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_transfer =
13014 : : TOKEN_STRING_INITIALIZER
13015 : : (struct cmd_show_port_flow_transfer_proxy_result,
13016 : : transfer, "transfer");
13017 : : static cmdline_parse_token_string_t cmd_show_port_flow_transfer_proxy_proxy =
13018 : : TOKEN_STRING_INITIALIZER
13019 : : (struct cmd_show_port_flow_transfer_proxy_result,
13020 : : proxy, "proxy");
13021 : :
13022 : : static void
13023 : 0 : cmd_show_port_flow_transfer_proxy_parsed(void *parsed_result,
13024 : : __rte_unused struct cmdline *cl,
13025 : : __rte_unused void *data)
13026 : : {
13027 : : struct cmd_show_port_flow_transfer_proxy_result *res = parsed_result;
13028 : : portid_t proxy_port_id;
13029 : : int ret;
13030 : :
13031 : : printf("\n");
13032 : :
13033 : 0 : ret = rte_flow_pick_transfer_proxy(res->port_id, &proxy_port_id, NULL);
13034 : 0 : if (ret != 0) {
13035 : 0 : fprintf(stderr, "Failed to pick transfer proxy: %s\n",
13036 : : rte_strerror(-ret));
13037 : 0 : return;
13038 : : }
13039 : :
13040 : 0 : printf("Transfer proxy port ID: %u\n\n", proxy_port_id);
13041 : : }
13042 : :
13043 : : static cmdline_parse_inst_t cmd_show_port_flow_transfer_proxy = {
13044 : : .f = cmd_show_port_flow_transfer_proxy_parsed,
13045 : : .data = NULL,
13046 : : .help_str = "show port <port_id> flow transfer proxy",
13047 : : .tokens = {
13048 : : (void *)&cmd_show_port_flow_transfer_proxy_show,
13049 : : (void *)&cmd_show_port_flow_transfer_proxy_port,
13050 : : (void *)&cmd_show_port_flow_transfer_proxy_port_id,
13051 : : (void *)&cmd_show_port_flow_transfer_proxy_flow,
13052 : : (void *)&cmd_show_port_flow_transfer_proxy_transfer,
13053 : : (void *)&cmd_show_port_flow_transfer_proxy_proxy,
13054 : : NULL,
13055 : : }
13056 : : };
13057 : :
13058 : : /* *** configure port txq affinity value *** */
13059 : : struct cmd_config_tx_affinity_map {
13060 : : cmdline_fixed_string_t port;
13061 : : cmdline_fixed_string_t config;
13062 : : portid_t portid;
13063 : : cmdline_fixed_string_t txq;
13064 : : uint16_t qid;
13065 : : cmdline_fixed_string_t affinity;
13066 : : uint8_t value;
13067 : : };
13068 : :
13069 : : static void
13070 : 0 : cmd_config_tx_affinity_map_parsed(void *parsed_result,
13071 : : __rte_unused struct cmdline *cl,
13072 : : __rte_unused void *data)
13073 : : {
13074 : : struct cmd_config_tx_affinity_map *res = parsed_result;
13075 : : int ret;
13076 : :
13077 : 0 : if (port_id_is_invalid(res->portid, ENABLED_WARN))
13078 : : return;
13079 : :
13080 : 0 : if (res->portid == (portid_t)RTE_PORT_ALL) {
13081 : : printf("Invalid port id\n");
13082 : 0 : return;
13083 : : }
13084 : :
13085 : 0 : if (strcmp(res->txq, "txq")) {
13086 : : printf("Unknown parameter\n");
13087 : 0 : return;
13088 : : }
13089 : 0 : if (tx_queue_id_is_invalid(res->qid))
13090 : : return;
13091 : :
13092 : 0 : ret = rte_eth_dev_count_aggr_ports(res->portid);
13093 : 0 : if (ret < 0) {
13094 : 0 : printf("Failed to count the aggregated ports: (%s)\n",
13095 : : strerror(-ret));
13096 : 0 : return;
13097 : : }
13098 : :
13099 : 0 : ret = rte_eth_dev_map_aggr_tx_affinity(res->portid, res->qid, res->value);
13100 : 0 : if (ret != 0) {
13101 : 0 : printf("Failed to map tx queue with an aggregated port: %s\n",
13102 : : rte_strerror(-ret));
13103 : 0 : return;
13104 : : }
13105 : : }
13106 : :
13107 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_port =
13108 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13109 : : port, "port");
13110 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_config =
13111 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13112 : : config, "config");
13113 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_portid =
13114 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13115 : : portid, RTE_UINT16);
13116 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_txq =
13117 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13118 : : txq, "txq");
13119 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_qid =
13120 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13121 : : qid, RTE_UINT16);
13122 : : cmdline_parse_token_string_t cmd_config_tx_affinity_map_affinity =
13123 : : TOKEN_STRING_INITIALIZER(struct cmd_config_tx_affinity_map,
13124 : : affinity, "affinity");
13125 : : cmdline_parse_token_num_t cmd_config_tx_affinity_map_value =
13126 : : TOKEN_NUM_INITIALIZER(struct cmd_config_tx_affinity_map,
13127 : : value, RTE_UINT8);
13128 : :
13129 : : static cmdline_parse_inst_t cmd_config_tx_affinity_map = {
13130 : : .f = cmd_config_tx_affinity_map_parsed,
13131 : : .data = (void *)0,
13132 : : .help_str = "port config <port_id> txq <queue_id> affinity <value>",
13133 : : .tokens = {
13134 : : (void *)&cmd_config_tx_affinity_map_port,
13135 : : (void *)&cmd_config_tx_affinity_map_config,
13136 : : (void *)&cmd_config_tx_affinity_map_portid,
13137 : : (void *)&cmd_config_tx_affinity_map_txq,
13138 : : (void *)&cmd_config_tx_affinity_map_qid,
13139 : : (void *)&cmd_config_tx_affinity_map_affinity,
13140 : : (void *)&cmd_config_tx_affinity_map_value,
13141 : : NULL,
13142 : : },
13143 : : };
13144 : :
13145 : : /* ******************************************************************************** */
13146 : :
13147 : : /* list of instructions */
13148 : : static cmdline_parse_ctx_t builtin_ctx[] = {
13149 : : (cmdline_parse_inst_t *)&cmd_help_brief,
13150 : : (cmdline_parse_inst_t *)&cmd_help_long,
13151 : : (cmdline_parse_inst_t *)&cmd_quit,
13152 : : (cmdline_parse_inst_t *)&cmd_load_from_file,
13153 : : (cmdline_parse_inst_t *)&cmd_showport,
13154 : : (cmdline_parse_inst_t *)&cmd_showqueue,
13155 : : (cmdline_parse_inst_t *)&cmd_showeeprom,
13156 : : (cmdline_parse_inst_t *)&cmd_showportall,
13157 : : (cmdline_parse_inst_t *)&cmd_representor_info,
13158 : : (cmdline_parse_inst_t *)&cmd_showdevice,
13159 : : (cmdline_parse_inst_t *)&cmd_showcfg,
13160 : : (cmdline_parse_inst_t *)&cmd_showfwdall,
13161 : : (cmdline_parse_inst_t *)&cmd_start,
13162 : : (cmdline_parse_inst_t *)&cmd_start_tx_first,
13163 : : (cmdline_parse_inst_t *)&cmd_start_tx_first_n,
13164 : : (cmdline_parse_inst_t *)&cmd_set_link_up,
13165 : : (cmdline_parse_inst_t *)&cmd_set_link_down,
13166 : : (cmdline_parse_inst_t *)&cmd_reset,
13167 : : (cmdline_parse_inst_t *)&cmd_set_numbers,
13168 : : (cmdline_parse_inst_t *)&cmd_set_log,
13169 : : (cmdline_parse_inst_t *)&cmd_set_rxoffs,
13170 : : (cmdline_parse_inst_t *)&cmd_set_rxpkts,
13171 : : (cmdline_parse_inst_t *)&cmd_set_rxhdrs,
13172 : : (cmdline_parse_inst_t *)&cmd_set_txpkts,
13173 : : (cmdline_parse_inst_t *)&cmd_set_txsplit,
13174 : : (cmdline_parse_inst_t *)&cmd_set_txtimes,
13175 : : (cmdline_parse_inst_t *)&cmd_set_fwd_list,
13176 : : (cmdline_parse_inst_t *)&cmd_set_fwd_mask,
13177 : : (cmdline_parse_inst_t *)&cmd_set_fwd_mode,
13178 : : (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
13179 : : (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry,
13180 : : (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one,
13181 : : (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all,
13182 : : (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one,
13183 : : (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all,
13184 : : (cmdline_parse_inst_t *)&cmd_set_flush_rx,
13185 : : (cmdline_parse_inst_t *)&cmd_set_link_check,
13186 : : (cmdline_parse_inst_t *)&cmd_vlan_offload,
13187 : : (cmdline_parse_inst_t *)&cmd_vlan_tpid,
13188 : : (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all,
13189 : : (cmdline_parse_inst_t *)&cmd_rx_vlan_filter,
13190 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_set,
13191 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq,
13192 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_reset,
13193 : : (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
13194 : : (cmdline_parse_inst_t *)&cmd_csum_set,
13195 : : (cmdline_parse_inst_t *)&cmd_csum_show,
13196 : : (cmdline_parse_inst_t *)&cmd_csum_tunnel,
13197 : : (cmdline_parse_inst_t *)&cmd_csum_mac_swap,
13198 : : (cmdline_parse_inst_t *)&cmd_tso_set,
13199 : : (cmdline_parse_inst_t *)&cmd_tso_show,
13200 : : (cmdline_parse_inst_t *)&cmd_tunnel_tso_set,
13201 : : (cmdline_parse_inst_t *)&cmd_tunnel_tso_show,
13202 : : #ifdef RTE_LIB_GRO
13203 : : (cmdline_parse_inst_t *)&cmd_gro_enable,
13204 : : (cmdline_parse_inst_t *)&cmd_gro_flush,
13205 : : (cmdline_parse_inst_t *)&cmd_gro_show,
13206 : : #endif
13207 : : #ifdef RTE_LIB_GSO
13208 : : (cmdline_parse_inst_t *)&cmd_gso_enable,
13209 : : (cmdline_parse_inst_t *)&cmd_gso_size,
13210 : : (cmdline_parse_inst_t *)&cmd_gso_show,
13211 : : #endif
13212 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set,
13213 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
13214 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
13215 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
13216 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
13217 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
13218 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
13219 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
13220 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
13221 : : (cmdline_parse_inst_t *)&cmd_link_flow_control_show,
13222 : : (cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
13223 : : (cmdline_parse_inst_t *)&cmd_queue_priority_flow_control_set,
13224 : : (cmdline_parse_inst_t *)&cmd_config_dcb,
13225 : : (cmdline_parse_inst_t *)&cmd_read_rxd_txd,
13226 : : (cmdline_parse_inst_t *)&cmd_stop,
13227 : : (cmdline_parse_inst_t *)&cmd_mac_addr,
13228 : : (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
13229 : : (cmdline_parse_inst_t *)&cmd_set_qmap,
13230 : : (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
13231 : : (cmdline_parse_inst_t *)&cmd_set_record_core_cycles,
13232 : : (cmdline_parse_inst_t *)&cmd_set_record_burst_stats,
13233 : : (cmdline_parse_inst_t *)&cmd_operate_port,
13234 : : (cmdline_parse_inst_t *)&cmd_operate_specific_port,
13235 : : (cmdline_parse_inst_t *)&cmd_operate_attach_port,
13236 : : (cmdline_parse_inst_t *)&cmd_operate_detach_port,
13237 : : (cmdline_parse_inst_t *)&cmd_operate_detach_device,
13238 : : (cmdline_parse_inst_t *)&cmd_set_port_setup_on,
13239 : : (cmdline_parse_inst_t *)&cmd_config_speed_all,
13240 : : (cmdline_parse_inst_t *)&cmd_config_speed_specific,
13241 : : (cmdline_parse_inst_t *)&cmd_config_loopback_all,
13242 : : (cmdline_parse_inst_t *)&cmd_config_loopback_specific,
13243 : : (cmdline_parse_inst_t *)&cmd_config_rx_tx,
13244 : : (cmdline_parse_inst_t *)&cmd_config_mtu,
13245 : : (cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
13246 : : (cmdline_parse_inst_t *)&cmd_config_max_lro_pkt_size,
13247 : : (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
13248 : : (cmdline_parse_inst_t *)&cmd_config_rss,
13249 : : (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size,
13250 : : (cmdline_parse_inst_t *)&cmd_config_rxtx_queue,
13251 : : (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue,
13252 : : (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue,
13253 : : (cmdline_parse_inst_t *)&cmd_config_rss_reta,
13254 : : (cmdline_parse_inst_t *)&cmd_showport_reta,
13255 : : (cmdline_parse_inst_t *)&cmd_showport_macs,
13256 : : (cmdline_parse_inst_t *)&cmd_show_port_flow_transfer_proxy,
13257 : : (cmdline_parse_inst_t *)&cmd_config_burst,
13258 : : (cmdline_parse_inst_t *)&cmd_config_thresh,
13259 : : (cmdline_parse_inst_t *)&cmd_config_threshold,
13260 : : (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter,
13261 : : (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter,
13262 : : (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter,
13263 : : (cmdline_parse_inst_t *)&cmd_queue_rate_limit,
13264 : : (cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
13265 : : (cmdline_parse_inst_t *)&cmd_showport_rss_hash,
13266 : : (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key,
13267 : : (cmdline_parse_inst_t *)&cmd_showport_rss_hash_algo,
13268 : : (cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
13269 : : (cmdline_parse_inst_t *)&cmd_config_rss_hash_algo,
13270 : : (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs,
13271 : : (cmdline_parse_inst_t *)&cmd_dump,
13272 : : (cmdline_parse_inst_t *)&cmd_dump_one,
13273 : : (cmdline_parse_inst_t *)&cmd_flow,
13274 : : (cmdline_parse_inst_t *)&cmd_show_port_meter_cap,
13275 : : (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm,
13276 : : (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm,
13277 : : (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm_rfc4115,
13278 : : (cmdline_parse_inst_t *)&cmd_del_port_meter_profile,
13279 : : (cmdline_parse_inst_t *)&cmd_create_port_meter,
13280 : : (cmdline_parse_inst_t *)&cmd_enable_port_meter,
13281 : : (cmdline_parse_inst_t *)&cmd_disable_port_meter,
13282 : : (cmdline_parse_inst_t *)&cmd_del_port_meter,
13283 : : (cmdline_parse_inst_t *)&cmd_del_port_meter_policy,
13284 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_profile,
13285 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table,
13286 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_vlan_table,
13287 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_in_proto,
13288 : : (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto,
13289 : : (cmdline_parse_inst_t *)&cmd_get_port_meter_in_proto_prio,
13290 : : (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask,
13291 : : (cmdline_parse_inst_t *)&cmd_show_port_meter_stats,
13292 : : (cmdline_parse_inst_t *)&cmd_mcast_addr,
13293 : : (cmdline_parse_inst_t *)&cmd_mcast_addr_flush,
13294 : : (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
13295 : : (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
13296 : : (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
13297 : : (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
13298 : : (cmdline_parse_inst_t *)&cmd_set_tx_loopback,
13299 : : (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
13300 : : (cmdline_parse_inst_t *)&cmd_set_vf_traffic,
13301 : : (cmdline_parse_inst_t *)&cmd_set_vf_rxmode,
13302 : : (cmdline_parse_inst_t *)&cmd_vf_rate_limit,
13303 : : (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter,
13304 : : (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
13305 : : (cmdline_parse_inst_t *)&cmd_set_vxlan,
13306 : : (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl,
13307 : : (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan,
13308 : : (cmdline_parse_inst_t *)&cmd_set_nvgre,
13309 : : (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan,
13310 : : (cmdline_parse_inst_t *)&cmd_set_l2_encap,
13311 : : (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan,
13312 : : (cmdline_parse_inst_t *)&cmd_set_l2_decap,
13313 : : (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan,
13314 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap,
13315 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan,
13316 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap,
13317 : : (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan,
13318 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap,
13319 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan,
13320 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap,
13321 : : (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan,
13322 : : (cmdline_parse_inst_t *)&cmd_set_conntrack_common,
13323 : : (cmdline_parse_inst_t *)&cmd_set_conntrack_dir,
13324 : : (cmdline_parse_inst_t *)&cmd_show_vf_stats,
13325 : : (cmdline_parse_inst_t *)&cmd_clear_vf_stats,
13326 : : (cmdline_parse_inst_t *)&cmd_show_port_supported_ptypes,
13327 : : (cmdline_parse_inst_t *)&cmd_set_port_ptypes,
13328 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_cap,
13329 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap,
13330 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap,
13331 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type,
13332 : : (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats,
13333 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile,
13334 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile,
13335 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper,
13336 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper,
13337 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile,
13338 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile,
13339 : : (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile,
13340 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node,
13341 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node_pmode,
13342 : : (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node,
13343 : : (cmdline_parse_inst_t *)&cmd_del_port_tm_node,
13344 : : (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent,
13345 : : (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node,
13346 : : (cmdline_parse_inst_t *)&cmd_resume_port_tm_node,
13347 : : (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit,
13348 : : (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn,
13349 : : (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp,
13350 : : (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei,
13351 : : (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port,
13352 : : (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa,
13353 : : (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration,
13354 : : (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload,
13355 : : (cmdline_parse_inst_t *)&cmd_config_all_port_rx_offload,
13356 : : (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload,
13357 : : (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa,
13358 : : (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration,
13359 : : (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload,
13360 : : (cmdline_parse_inst_t *)&cmd_config_all_port_tx_offload,
13361 : : (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload,
13362 : : #ifdef RTE_LIB_BPF
13363 : : (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse,
13364 : : (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse,
13365 : : #endif
13366 : : (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific,
13367 : : (cmdline_parse_inst_t *)&cmd_show_tx_metadata,
13368 : : (cmdline_parse_inst_t *)&cmd_show_rx_tx_desc_status,
13369 : : (cmdline_parse_inst_t *)&cmd_show_rx_tx_queue_desc_used_count,
13370 : : (cmdline_parse_inst_t *)&cmd_set_raw,
13371 : : (cmdline_parse_inst_t *)&cmd_show_set_raw,
13372 : : (cmdline_parse_inst_t *)&cmd_show_set_raw_all,
13373 : : (cmdline_parse_inst_t *)&cmd_config_tx_dynf_specific,
13374 : : (cmdline_parse_inst_t *)&cmd_show_fec_mode,
13375 : : (cmdline_parse_inst_t *)&cmd_set_fec_mode,
13376 : : (cmdline_parse_inst_t *)&cmd_set_rxq_avail_thresh,
13377 : : (cmdline_parse_inst_t *)&cmd_show_capability,
13378 : : (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern,
13379 : : (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern,
13380 : : (cmdline_parse_inst_t *)&cmd_show_port_cman_capa,
13381 : : (cmdline_parse_inst_t *)&cmd_show_port_cman_config,
13382 : : (cmdline_parse_inst_t *)&cmd_set_port_cman_config,
13383 : : (cmdline_parse_inst_t *)&cmd_config_tx_affinity_map,
13384 : : NULL,
13385 : : };
13386 : :
13387 : : void
13388 : 0 : testpmd_add_driver_commands(struct testpmd_driver_commands *c)
13389 : : {
13390 : 0 : TAILQ_INSERT_TAIL(&driver_commands_head, c, next);
13391 : 0 : }
13392 : :
13393 : : int
13394 : 0 : init_cmdline(void)
13395 : : {
13396 : : struct testpmd_driver_commands *c;
13397 : : unsigned int count;
13398 : : unsigned int i;
13399 : :
13400 : : /* initialize non-constant commands */
13401 : 0 : cmd_set_fwd_mode_init();
13402 : 0 : cmd_set_fwd_retry_mode_init();
13403 : :
13404 : : count = 0;
13405 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++)
13406 : 0 : count++;
13407 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
13408 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++)
13409 : 0 : count++;
13410 : : }
13411 : :
13412 : : /* cmdline expects a NULL terminated array */
13413 : 0 : main_ctx = calloc(count + 1, sizeof(main_ctx[0]));
13414 : 0 : if (main_ctx == NULL)
13415 : : return -1;
13416 : :
13417 : : count = 0;
13418 : 0 : for (i = 0; builtin_ctx[i] != NULL; i++, count++)
13419 : 0 : main_ctx[count] = builtin_ctx[i];
13420 : 0 : TAILQ_FOREACH(c, &driver_commands_head, next) {
13421 : 0 : for (i = 0; c->commands[i].ctx != NULL; i++, count++)
13422 : 0 : main_ctx[count] = c->commands[i].ctx;
13423 : : }
13424 : :
13425 : : return 0;
13426 : : }
13427 : :
13428 : : /* read cmdline commands from file */
13429 : : void
13430 : 0 : cmdline_read_from_file(const char *filename)
13431 : : {
13432 : : struct cmdline *cl;
13433 : :
13434 : 0 : cl = cmdline_file_new(main_ctx, "testpmd> ", filename);
13435 : 0 : if (cl == NULL) {
13436 : 0 : fprintf(stderr,
13437 : : "Failed to create file based cmdline context: %s\n",
13438 : : filename);
13439 : 0 : return;
13440 : : }
13441 : :
13442 : 0 : cmdline_interact(cl);
13443 : 0 : cmdline_quit(cl);
13444 : :
13445 : 0 : cmdline_free(cl);
13446 : :
13447 : : printf("Read CLI commands from %s\n", filename);
13448 : : }
13449 : :
13450 : : void
13451 : 0 : prompt_exit(void)
13452 : : {
13453 : 0 : cmdline_quit(testpmd_cl);
13454 : 0 : }
13455 : :
13456 : : /* prompt function, called from main on MAIN lcore */
13457 : : void
13458 : 0 : prompt(void)
13459 : : {
13460 : 0 : testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
13461 : 0 : if (testpmd_cl == NULL) {
13462 : 0 : fprintf(stderr,
13463 : : "Failed to create stdin based cmdline context\n");
13464 : 0 : return;
13465 : : }
13466 : :
13467 : 0 : cmdline_interact(testpmd_cl);
13468 : 0 : cmdline_stdin_exit(testpmd_cl);
13469 : : }
13470 : :
13471 : : void
13472 : 0 : cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue)
13473 : : {
13474 : 0 : if (id == (portid_t)RTE_PORT_ALL) {
13475 : : portid_t pid;
13476 : :
13477 : 0 : RTE_ETH_FOREACH_DEV(pid) {
13478 : : /* check if need_reconfig has been set to 1 */
13479 : 0 : if (ports[pid].need_reconfig == 0)
13480 : 0 : ports[pid].need_reconfig = dev;
13481 : : /* check if need_reconfig_queues has been set to 1 */
13482 : 0 : if (ports[pid].need_reconfig_queues == 0)
13483 : 0 : ports[pid].need_reconfig_queues = queue;
13484 : : }
13485 : 0 : } else if (!port_id_is_invalid(id, DISABLED_WARN)) {
13486 : : /* check if need_reconfig has been set to 1 */
13487 : 0 : if (ports[id].need_reconfig == 0)
13488 : 0 : ports[id].need_reconfig = dev;
13489 : : /* check if need_reconfig_queues has been set to 1 */
13490 : 0 : if (ports[id].need_reconfig_queues == 0)
13491 : 0 : ports[id].need_reconfig_queues = queue;
13492 : : }
13493 : 0 : }
|